Skip to content

Commit c41a325

Browse files
authored
update symmetry debug from deepmodeling (#117)
* 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. * perf : add warning output for symmetry searching part; modified tests/integral/207_NO_DP_OD/result.ref to correct version.
1 parent d6669c1 commit c41a325

File tree

5 files changed

+60
-30
lines changed

5 files changed

+60
-30
lines changed

source/module_symmetry/symmetry.cpp

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ void Symmetry::analy_sys(const UnitCell_pseudo &ucell, std::ofstream &ofs_runnin
127127
new_lat.e11=a1.x; new_lat.e12=a1.y; new_lat.e13=a1.z;
128128
new_lat.e21=a2.x; new_lat.e22=a2.y; new_lat.e23=a2.z;
129129
new_lat.e31=a3.x; new_lat.e32=a3.y; new_lat.e33=a3.z;
130-
output::printM3(ofs_running,"STANDARD LATTICE VECTORS: (CARTESIAN COORDINATE: IN UNIT OF A0)",new_lat);
130+
//output::printM3(ofs_running,"STANDARD LATTICE VECTORS: (CARTESIAN COORDINATE: IN UNIT OF A0)",new_lat);
131131

132132
int iat=0;
133133
for(int it=0; it<ucell.ntype; ++it)
@@ -156,21 +156,31 @@ void Symmetry::analy_sys(const UnitCell_pseudo &ucell, std::ofstream &ofs_runnin
156156
}
157157

158158

159-
Symm_Other::print1(ibrav, cel_const, ofs_running);
160-
159+
//Symm_Other::print1(ibrav, cel_const, ofs_running);
160+
Symm_Other::print1(real_brav, cel_const, ofs_running);
161161
this->change_lattice();
162162
//this->pricell(); // pengfei Li 2018-05-14
163163
//for( iat =0 ; iat < ucell.nat ; iat++)
164164
// std::cout << " newpos_now = " << newpos[3*iat] << " " << newpos[3*iat+1] << " " << newpos[3*iat+2] << std::endl;
165-
ModuleBase::GlobalFunc::OUT(ofs_running,"ibrav",ibrav);
166-
this->setgroup(this->symop, this->nop, this->ibrav);
167-
//now select all symmetry operations which reproduce the lattice
168-
//to find those symmetry operations which reproduce the entire crystal
169-
this->getgroup(this->nrot, this->nrotk, ofs_running);
170-
// find the name of point group
171-
this->pointgroup(this->nrot, this->pgnumber, this->pgname, this->gmatrix, ofs_running);
172-
ModuleBase::GlobalFunc::OUT(ofs_running,"POINT GROUP", this->pgname);
173-
//write();
165+
test_brav = true; // output the real ibrav and point group
166+
ModuleBase::GlobalFunc::OUT(ofs_running,"ibrav",real_brav);
167+
this->setgroup(this->symop, this->nop, this->real_brav);
168+
this->getgroup(this->nrot, this->nrotk, ofs_running);
169+
this->pointgroup(this->nrot, this->pgnumber, this->pgname, this->gmatrix, ofs_running);
170+
ModuleBase::GlobalFunc::OUT(ofs_running,"POINT GROUP", this->pgname);
171+
ofs_running<<"Warning : If the optimal symmetric configuration is not the input configuration, "<<'\n';
172+
ofs_running<<"you have to manually change configurations, ABACUS would only calculate the input structure!"<<'\n';
173+
174+
test_brav = false; // use the input ibrav to calculate
175+
//ModuleBase::GlobalFunc::OUT(ofs_running,"ibrav",ibrav);
176+
this->setgroup(this->symop, this->nop, this->ibrav);
177+
//now select all symmetry operations which reproduce the lattice
178+
//to find those symmetry operations which reproduce the entire crystal
179+
this->getgroup(this->nrot, this->nrotk, ofs_running);
180+
// find the name of point group
181+
this->pointgroup(this->nrot, this->pgnumber, this->pgname, this->gmatrix, ofs_running);
182+
// ModuleBase::GlobalFunc::OUT(ofs_running,"POINT GROUP", this->pgname);
183+
//write();
174184

175185
delete[] dirpos;
176186
delete[] newpos;
@@ -705,6 +715,7 @@ void Symmetry::lattice_type(
705715
// GlobalV::ofs_running << " pre_brav=" << pre_brav << std::endl;
706716
// GlobalV::ofs_running << " temp_brav=" << temp_brav << std::endl;
707717

718+
708719
if ( temp_brav < pre_brav)
709720
{
710721
//if the symmetry of the new vectors is higher, store the new ones
@@ -771,7 +782,6 @@ void Symmetry::lattice_type(
771782
}
772783
}
773784
ofs.close();
774-
775785

776786
}
777787

@@ -811,9 +821,12 @@ void Symmetry::lattice_type(
811821
}
812822
}*/
813823
brav = pre_brav;
814-
bravname = get_brav_name(brav);
824+
//brav = temp_brav;
825+
//bravname = get_brav_name(brav);
826+
real_brav = temp_brav; // pengfei Li 15-3-2022
827+
bravname = get_brav_name(real_brav);
815828

816-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"BRAVAIS TYPE",brav);
829+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"BRAVAIS TYPE",real_brav);
817830
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"BRAVAIS LATTICE NAME",bravname);
818831
return;
819832
}
@@ -1209,8 +1222,12 @@ void Symmetry::getgroup(int &nrot, int &nrotk, std::ofstream &ofs_running)
12091222
//total number of space group operations
12101223
//-----------------------------------------------------
12111224
nrotk += nrot;
1212-
ModuleBase::GlobalFunc::OUT(ofs_running,"PURE POINT GROUP OPERATIONS",nrot);
1213-
ModuleBase::GlobalFunc::OUT(ofs_running,"SPACE GROUP OPERATIONS",nrotk);
1225+
1226+
if(test_brav)
1227+
{
1228+
ModuleBase::GlobalFunc::OUT(ofs_running,"PURE POINT GROUP OPERATIONS",nrot);
1229+
ModuleBase::GlobalFunc::OUT(ofs_running,"SPACE GROUP OPERATIONS",nrotk);
1230+
}
12141231

12151232
//-----------------------------------------------------
12161233
//fill the rest of matrices and vectors with zeros
@@ -1775,4 +1792,4 @@ void Symmetry::print_pos(const double* pos, const int &nat)
17751792
}
17761793
return;
17771794
}
1778-
}
1795+
}

source/module_symmetry/symmetry.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class Symmetry : public Symmetry_Basic
5050
int sym_test;
5151
int pbrav;
5252
int ibrav;
53+
int real_brav; // the real ibrav for the cell pengfei Li 3-15-2022
5354
std::string ilattname; //the bravais lattice type of the supercell
5455
std::string plattname; //the bravais lattice type of the primitive cell
5556

source/module_symmetry/symmetry_basic.cpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//#include "../src_pw/global.h"
77
#include "../module_base/mymath.h"
88
//#include "symm_other.h"
9+
bool ModuleSymmetry::test_brav = 0;
910

1011
namespace ModuleSymmetry
1112
{
@@ -811,7 +812,11 @@ void Symmetry_Basic::setgroup(ModuleBase::Matrix3* symop, int &nop, const int &i
811812
this->matrigen(symgen, 3, symop, nop);
812813
}
813814

814-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"ROTATION MATRICES",nop);
815+
if(test_brav)
816+
{
817+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"ROTATION MATRICES",nop);
818+
}
819+
815820
if(GlobalV::test_symmetry > 1)
816821
{
817822
GlobalV::ofs_running<<" THERE ARE " << nop << " ROTATION MATRICES FOR THE PURE BRAVAIS LATTICE"<<std::endl;
@@ -939,14 +944,17 @@ void Symmetry_Basic::pointgroup(const int &nrot, int &pgnumber, std::string &pgn
939944
else if(trace == -2 && det == -1) ++ns3; //mohan add 2012-01-15
940945
}
941946

942-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"C2",nc2);
943-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"C3",nc3);
944-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"C4",nc4);
945-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"C6",nc6);
946-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"S1",ns1);
947-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"S3",ns3);
948-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"S4",ns4);
949-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"S6",ns6);
947+
if(test_brav)
948+
{
949+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"C2",nc2);
950+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"C3",nc3);
951+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"C4",nc4);
952+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"C6",nc6);
953+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"S1",ns1);
954+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"S3",ns3);
955+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"S4",ns4);
956+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"S6",ns6);
957+
}
950958

951959
if(nrot == 2)
952960
{
@@ -1176,4 +1184,4 @@ void Symmetry_Basic::rotate( ModuleBase::Matrix3 &gmatrix, ModuleBase::Vector3<d
11761184
rk = rk%nr3;
11771185
return;
11781186
}
1179-
}
1187+
}

source/module_symmetry/symmetry_basic.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ class Symmetry_Basic
6969
void order_y(double *pos, const int &oldpos, const int &newpos);
7070
void order_z(double *pos, const int &oldpos, const int &newpos);
7171
};
72+
73+
//for test only
74+
extern bool test_brav;
75+
7276
}//end of define namespace
7377

7478
#endif
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
totaldosref 1189.53
2-
totaltimeref 1.0555
1+
totaldosref 1189.51
2+
totaltimeref 0.84239

0 commit comments

Comments
 (0)