From e717dc89cf0eba914e311747994e6917d613d01c Mon Sep 17 00:00:00 2001 From: dyzheng Date: Tue, 22 Mar 2022 14:50:55 +0800 Subject: [PATCH 1/5] fix : when input structure doesn't have most symmetry rotation matrix, ABACUS will print which structure is better and then using the input structure for calculating. --- source/module_symmetry/symmetry.cpp | 51 +++++++++++++++-------- source/module_symmetry/symmetry.h | 1 + source/module_symmetry/symmetry_basic.cpp | 28 ++++++++----- source/module_symmetry/symmetry_basic.h | 4 ++ 4 files changed, 56 insertions(+), 28 deletions(-) diff --git a/source/module_symmetry/symmetry.cpp b/source/module_symmetry/symmetry.cpp index 5397295d13..2f33726096 100644 --- a/source/module_symmetry/symmetry.cpp +++ b/source/module_symmetry/symmetry.cpp @@ -127,7 +127,7 @@ void Symmetry::analy_sys(const UnitCell_pseudo &ucell, std::ofstream &ofs_runnin new_lat.e11=a1.x; new_lat.e12=a1.y; new_lat.e13=a1.z; new_lat.e21=a2.x; new_lat.e22=a2.y; new_lat.e23=a2.z; new_lat.e31=a3.x; new_lat.e32=a3.y; new_lat.e33=a3.z; - output::printM3(ofs_running,"STANDARD LATTICE VECTORS: (CARTESIAN COORDINATE: IN UNIT OF A0)",new_lat); + //output::printM3(ofs_running,"STANDARD LATTICE VECTORS: (CARTESIAN COORDINATE: IN UNIT OF A0)",new_lat); int iat=0; for(int it=0; itchange_lattice(); //this->pricell(); // pengfei Li 2018-05-14 //for( iat =0 ; iat < ucell.nat ; iat++) // std::cout << " newpos_now = " << newpos[3*iat] << " " << newpos[3*iat+1] << " " << newpos[3*iat+2] << std::endl; - ModuleBase::GlobalFunc::OUT(ofs_running,"ibrav",ibrav); - this->setgroup(this->symop, this->nop, this->ibrav); - //now select all symmetry operations which reproduce the lattice - //to find those symmetry operations which reproduce the entire crystal - this->getgroup(this->nrot, this->nrotk, ofs_running); - // find the name of point group - this->pointgroup(this->nrot, this->pgnumber, this->pgname, this->gmatrix, ofs_running); - ModuleBase::GlobalFunc::OUT(ofs_running,"POINT GROUP", this->pgname); - //write(); + test_brav = true; // output the real ibrav and point group + ModuleBase::GlobalFunc::OUT(ofs_running,"ibrav",real_brav); + this->setgroup(this->symop, this->nop, this->real_brav); + this->getgroup(this->nrot, this->nrotk, ofs_running); + this->pointgroup(this->nrot, this->pgnumber, this->pgname, this->gmatrix, ofs_running); + ModuleBase::GlobalFunc::OUT(ofs_running,"POINT GROUP", this->pgname); + + test_brav = false; // use the input ibrav to calculate + //ModuleBase::GlobalFunc::OUT(ofs_running,"ibrav",ibrav); + this->setgroup(this->symop, this->nop, this->ibrav); + //now select all symmetry operations which reproduce the lattice + //to find those symmetry operations which reproduce the entire crystal + this->getgroup(this->nrot, this->nrotk, ofs_running); + // find the name of point group + this->pointgroup(this->nrot, this->pgnumber, this->pgname, this->gmatrix, ofs_running); + // ModuleBase::GlobalFunc::OUT(ofs_running,"POINT GROUP", this->pgname); + //write(); delete[] dirpos; delete[] newpos; @@ -705,6 +713,7 @@ void Symmetry::lattice_type( // GlobalV::ofs_running << " pre_brav=" << pre_brav << std::endl; // GlobalV::ofs_running << " temp_brav=" << temp_brav << std::endl; + if ( temp_brav < pre_brav) { //if the symmetry of the new vectors is higher, store the new ones @@ -771,7 +780,6 @@ void Symmetry::lattice_type( } } ofs.close(); - } @@ -811,9 +819,12 @@ void Symmetry::lattice_type( } }*/ brav = pre_brav; - bravname = get_brav_name(brav); + //brav = temp_brav; + //bravname = get_brav_name(brav); + real_brav = temp_brav; // pengfei Li 15-3-2022 + bravname = get_brav_name(real_brav); - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"BRAVAIS TYPE",brav); + ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"BRAVAIS TYPE",real_brav); ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"BRAVAIS LATTICE NAME",bravname); return; } @@ -1209,8 +1220,12 @@ void Symmetry::getgroup(int &nrot, int &nrotk, std::ofstream &ofs_running) //total number of space group operations //----------------------------------------------------- nrotk += nrot; - ModuleBase::GlobalFunc::OUT(ofs_running,"PURE POINT GROUP OPERATIONS",nrot); - ModuleBase::GlobalFunc::OUT(ofs_running,"SPACE GROUP OPERATIONS",nrotk); + + if(test_brav) + { + ModuleBase::GlobalFunc::OUT(ofs_running,"PURE POINT GROUP OPERATIONS",nrot); + ModuleBase::GlobalFunc::OUT(ofs_running,"SPACE GROUP OPERATIONS",nrotk); + } //----------------------------------------------------- //fill the rest of matrices and vectors with zeros @@ -1775,4 +1790,4 @@ void Symmetry::print_pos(const double* pos, const int &nat) } return; } -} \ No newline at end of file +} diff --git a/source/module_symmetry/symmetry.h b/source/module_symmetry/symmetry.h index 52893aa160..6c9ebefc7c 100644 --- a/source/module_symmetry/symmetry.h +++ b/source/module_symmetry/symmetry.h @@ -50,6 +50,7 @@ class Symmetry : public Symmetry_Basic int sym_test; int pbrav; int ibrav; + int real_brav; // the real ibrav for the cell pengfei Li 3-15-2022 std::string ilattname; //the bravais lattice type of the supercell std::string plattname; //the bravais lattice type of the primitive cell diff --git a/source/module_symmetry/symmetry_basic.cpp b/source/module_symmetry/symmetry_basic.cpp index 04ce843ea4..e07177234f 100644 --- a/source/module_symmetry/symmetry_basic.cpp +++ b/source/module_symmetry/symmetry_basic.cpp @@ -6,6 +6,7 @@ //#include "../src_pw/global.h" #include "../module_base/mymath.h" //#include "symm_other.h" +bool ModuleSymmetry::test_brav = 0; namespace ModuleSymmetry { @@ -811,7 +812,11 @@ void Symmetry_Basic::setgroup(ModuleBase::Matrix3* symop, int &nop, const int &i this->matrigen(symgen, 3, symop, nop); } - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"ROTATION MATRICES",nop); + if(test_brav) + { + ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"ROTATION MATRICES",nop); + } + if(GlobalV::test_symmetry > 1) { GlobalV::ofs_running<<" THERE ARE " << nop << " ROTATION MATRICES FOR THE PURE BRAVAIS LATTICE"< Date: Sat, 2 Apr 2022 17:19:50 +0800 Subject: [PATCH 2/5] perf : add warning output for symmetry searching part; modified tests/integral/207_NO_DP_OD/result.ref to correct version. --- source/module_symmetry/symmetry.cpp | 2 ++ tests/integrate/207_NO_KP_OD/result.ref | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/source/module_symmetry/symmetry.cpp b/source/module_symmetry/symmetry.cpp index 2f33726096..d93b53686c 100644 --- a/source/module_symmetry/symmetry.cpp +++ b/source/module_symmetry/symmetry.cpp @@ -168,6 +168,8 @@ void Symmetry::analy_sys(const UnitCell_pseudo &ucell, std::ofstream &ofs_runnin this->getgroup(this->nrot, this->nrotk, ofs_running); this->pointgroup(this->nrot, this->pgnumber, this->pgname, this->gmatrix, ofs_running); ModuleBase::GlobalFunc::OUT(ofs_running,"POINT GROUP", this->pgname); + ofs_running<<"Warning : If the optimal symmetric configuration is not the input configuration, "<<'\n'; + ofs_running<<"you have to manually change configurations, ABACUS would only calculate the input structure!"<<'\n'; test_brav = false; // use the input ibrav to calculate //ModuleBase::GlobalFunc::OUT(ofs_running,"ibrav",ibrav); diff --git a/tests/integrate/207_NO_KP_OD/result.ref b/tests/integrate/207_NO_KP_OD/result.ref index 57d274bd3c..e6d5063a90 100644 --- a/tests/integrate/207_NO_KP_OD/result.ref +++ b/tests/integrate/207_NO_KP_OD/result.ref @@ -1,2 +1,2 @@ -totaldosref 1189.53 -totaltimeref 1.0555 +totaldosref 1189.51 +totaltimeref 0.84239 From 5eca0f1f40c290a57766be3a4e1305f2ea434c13 Mon Sep 17 00:00:00 2001 From: dyzheng Date: Sun, 3 Apr 2022 15:45:50 +0800 Subject: [PATCH 3/5] fix : UT for diago_cg.cpp and diago_david.cpp should not depend on __CUDA and __ROCM --- source/src_pw/test/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/src_pw/test/CMakeLists.txt b/source/src_pw/test/CMakeLists.txt index 3e68baa03b..3fbcd2b457 100644 --- a/source/src_pw/test/CMakeLists.txt +++ b/source/src_pw/test/CMakeLists.txt @@ -1,4 +1,6 @@ remove_definitions(-D__MPI) +remove_definitions(-D__CUDA) +remove_definitions(-D__ROCM) AddTest( TARGET hsolver_david LIBS ${math_libs} base From e02c9c0bc15c55a51b4f6fdf50fbff3169552108 Mon Sep 17 00:00:00 2001 From: dyzheng Date: Tue, 5 Apr 2022 19:11:23 +0800 Subject: [PATCH 4/5] fix : support both element magnetization and atomic magnetization for initial --- source/module_cell/read_atoms.cpp | 3 +-- source/src_pw/charge.cpp | 10 ++++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/source/module_cell/read_atoms.cpp b/source/module_cell/read_atoms.cpp index 6e924b3203..195f5fdc52 100644 --- a/source/module_cell/read_atoms.cpp +++ b/source/module_cell/read_atoms.cpp @@ -589,7 +589,7 @@ bool UnitCell_pseudo::read_atom_positions(std::ifstream &ifpos, std::ofstream &o mv.z = true ; atoms[it].vel[ia].set(0,0,0); #ifndef __CMD - //atoms[it].mag[ia]=magnet.start_magnetization[it];//if this line is used, default startmag_type would be 2 + atoms[it].mag[ia]=magnet.start_magnetization[it];//if this line is used, default startmag_type would be 2 #endif atoms[it].angle1[ia]=0; atoms[it].angle2[ia]=0; @@ -633,7 +633,6 @@ bool UnitCell_pseudo::read_atom_positions(std::ifstream &ifpos, std::ofstream &o tmp=ifpos.get(); } - cout<<"tmp"<= 48 && tmp <= 57) or tmp=='-') { ifpos.putback(tmp); diff --git a/source/src_pw/charge.cpp b/source/src_pw/charge.cpp index 527a966933..26544901cb 100644 --- a/source/src_pw/charge.cpp +++ b/source/src_pw/charge.cpp @@ -212,13 +212,11 @@ void Charge::atomic_rho(const int spin_number_need, double** rho_in)const // Pe // check the start magnetization const int startmag_type = [&]()->int { - if(GlobalV::NSPIN==4) //zhengdy-soc, type 2 is still wrong. - return 1; for(int it=0; it Date: Tue, 5 Apr 2022 22:34:27 +0800 Subject: [PATCH 5/5] add 304_NO_GO_AF_atommag case for testing initial atomic magnetization --- tests/integrate/304_NO_GO_AF/jd | 1 + tests/integrate/304_NO_GO_AF_atommag/INPUT | 34 +++++++++++++++++++ tests/integrate/304_NO_GO_AF_atommag/KPT | 4 +++ tests/integrate/304_NO_GO_AF_atommag/STRU | 29 ++++++++++++++++ tests/integrate/304_NO_GO_AF_atommag/jd | 1 + .../integrate/304_NO_GO_AF_atommag/result.ref | 3 ++ tests/integrate/CASES | 1 + 7 files changed, 73 insertions(+) create mode 100644 tests/integrate/304_NO_GO_AF/jd create mode 100644 tests/integrate/304_NO_GO_AF_atommag/INPUT create mode 100644 tests/integrate/304_NO_GO_AF_atommag/KPT create mode 100644 tests/integrate/304_NO_GO_AF_atommag/STRU create mode 100644 tests/integrate/304_NO_GO_AF_atommag/jd create mode 100644 tests/integrate/304_NO_GO_AF_atommag/result.ref diff --git a/tests/integrate/304_NO_GO_AF/jd b/tests/integrate/304_NO_GO_AF/jd new file mode 100644 index 0000000000..40823821e1 --- /dev/null +++ b/tests/integrate/304_NO_GO_AF/jd @@ -0,0 +1 @@ +test for initial magnetization from elements, anti-ferromagnetic Fe2, LCAO diff --git a/tests/integrate/304_NO_GO_AF_atommag/INPUT b/tests/integrate/304_NO_GO_AF_atommag/INPUT new file mode 100644 index 0000000000..699bec1140 --- /dev/null +++ b/tests/integrate/304_NO_GO_AF_atommag/INPUT @@ -0,0 +1,34 @@ +INPUT_PARAMETERS +suffix autotest +ntype 2 +#nbands 40 + +calculation scf +ecutwfc 20 +scf_thr 1.0e-8 +scf_nmax 50 +out_chg 0 + +#init_chg file +#out_dos 1 +#dos_sigma 0.05 +#out_band 1 + +smearing_method gaussian +smearing_sigma 0.02 + +#cal_force 1 +#force_thr_ev 0.01 +#relax_method cg +#relax_bfgs_init 0.5 + +mixing_type pulay +mixing_beta 0.4 + + +ks_solver genelpa +basis_type lcao +gamma_only 1 +symmetry 0 +nspin 2 + diff --git a/tests/integrate/304_NO_GO_AF_atommag/KPT b/tests/integrate/304_NO_GO_AF_atommag/KPT new file mode 100644 index 0000000000..c289c0158a --- /dev/null +++ b/tests/integrate/304_NO_GO_AF_atommag/KPT @@ -0,0 +1,4 @@ +K_POINTS +0 +Gamma +1 1 1 0 0 0 diff --git a/tests/integrate/304_NO_GO_AF_atommag/STRU b/tests/integrate/304_NO_GO_AF_atommag/STRU new file mode 100644 index 0000000000..4c3d62bda5 --- /dev/null +++ b/tests/integrate/304_NO_GO_AF_atommag/STRU @@ -0,0 +1,29 @@ +ATOMIC_SPECIES +Fe1 1.000 ../tools/PP_ORB/Fe_ONCV_PBE-1.0.upf +Fe2 1.000 ../tools/PP_ORB/Fe_ONCV_PBE-1.0.upf + +NUMERICAL_ORBITAL +../tools/PP_ORB/Fe_gga_9au_100Ry_4s2p2d1f.orb +../tools/PP_ORB/Fe_gga_9au_100Ry_4s2p2d1f.orb + +LATTICE_CONSTANT +15 + +LATTICE_VECTORS + 1.00 0.50 0.50 + 0.50 1.00 0.50 + 0.50 0.50 1.00 +ATOMIC_POSITIONS +Direct + +Fe1 +0.0 +1 +0.00 0.00 0.00 1 1 1 mag 1.0 + +Fe2 +0.0 +1 +0.50 0.50 0.50 1 1 1 mag -1.0 + + diff --git a/tests/integrate/304_NO_GO_AF_atommag/jd b/tests/integrate/304_NO_GO_AF_atommag/jd new file mode 100644 index 0000000000..b3b2c2d6b0 --- /dev/null +++ b/tests/integrate/304_NO_GO_AF_atommag/jd @@ -0,0 +1 @@ +test for initial magnetization from atoms, anti-ferromagnetic Fe2, LCAO diff --git a/tests/integrate/304_NO_GO_AF_atommag/result.ref b/tests/integrate/304_NO_GO_AF_atommag/result.ref new file mode 100644 index 0000000000..d0f833de55 --- /dev/null +++ b/tests/integrate/304_NO_GO_AF_atommag/result.ref @@ -0,0 +1,3 @@ +etotref -6372.520190217967 +etotperatomref -3186.2600951090 +totaltimeref 12.081 diff --git a/tests/integrate/CASES b/tests/integrate/CASES index dac81dcd5d..31e7cbf9e4 100644 --- a/tests/integrate/CASES +++ b/tests/integrate/CASES @@ -106,6 +106,7 @@ 301_NO_GO_DJ_Si #303_NO_GO_HP_15 304_NO_GO_AF +304_NO_GO_AF_atommag 304_NO_GO_FM 307_NO_GO_OH 308_NO_GO_CF_RE