Skip to content

Commit 090030a

Browse files
authored
Fix a bug in symmetry::pricell (#2231)
* optimize rhog_symmetry * move tmp_gdirect0.z after continue * revert the quit assertion, important to put \!GAMMA inside * use libm::sincos * fix a wrong call of sincos * extract gtrans-factor out of the ptrans-loop * fix a cout * pricell: change tmp_ptrans from Vector3<double> to double[3]
1 parent c179477 commit 090030a

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

source/module_cell/module_symmetry/symmetry.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ void Symmetry::pricell(double* pos)
984984
}
985985

986986
ModuleBase::Vector3<double> diff;
987-
ModuleBase::Vector3<double> tmp_ptrans;
987+
double tmp_ptrans[3];
988988

989989
//---------------------------------------------------------
990990
// itmin_start = the start atom positions of species itmin
@@ -996,17 +996,17 @@ void Symmetry::pricell(double* pos)
996996
{
997997
//set up the current test std::vector "gtrans"
998998
//and "gtrans" could possibly contain trivial translations:
999-
tmp_ptrans.x = this->get_translation_vector( pos[i*3+0], sptmin.x);
1000-
tmp_ptrans.y = this->get_translation_vector( pos[i*3+1], sptmin.y);
1001-
tmp_ptrans.z = this->get_translation_vector( pos[i*3+2], sptmin.z);
999+
tmp_ptrans[0] = this->get_translation_vector( pos[i*3+0], sptmin.x);
1000+
tmp_ptrans[1] = this->get_translation_vector( pos[i*3+1], sptmin.y);
1001+
tmp_ptrans[2] = this->get_translation_vector( pos[i*3+2], sptmin.z);
10021002
//translate all the atomic coordinates by "gtrans"
10031003
for (int it = 0; it < ntype; it++)
10041004
{
10051005
for (int ia = istart[it]; ia < na[it] + istart[it]; ia++)
10061006
{
1007-
this->check_translation( rotpos[ia*3+0], tmp_ptrans.x );
1008-
this->check_translation( rotpos[ia*3+1], tmp_ptrans.y );
1009-
this->check_translation( rotpos[ia*3+2], tmp_ptrans.z );
1007+
this->check_translation( rotpos[ia*3+0], tmp_ptrans[0] );
1008+
this->check_translation( rotpos[ia*3+1], tmp_ptrans[1] );
1009+
this->check_translation( rotpos[ia*3+2], tmp_ptrans[2] );
10101010

10111011
this->check_boundary( rotpos[ia*3+0] );
10121012
this->check_boundary( rotpos[ia*3+1] );
@@ -1039,16 +1039,17 @@ void Symmetry::pricell(double* pos)
10391039
}
10401040

10411041
//the current test is successful
1042-
if (no_diff) ptrans.push_back(tmp_ptrans);
1042+
if (no_diff) ptrans.push_back(ModuleBase::Vector3<double>
1043+
(tmp_ptrans[0], tmp_ptrans[1], tmp_ptrans[2]));
10431044

10441045
//restore the original rotated coordinates by subtracting "ptrans"
10451046
for (int it = 0; it < ntype; it++)
10461047
{
10471048
for (int ia = istart[it]; ia < na[it] + istart[it]; ia++)
10481049
{
1049-
rotpos[ia*3+0] -= tmp_ptrans.x;
1050-
rotpos[ia*3+1] -= tmp_ptrans.y;
1051-
rotpos[ia*3+2] -= tmp_ptrans.z;
1050+
rotpos[ia*3+0] -= tmp_ptrans[0];
1051+
rotpos[ia*3+1] -= tmp_ptrans[1];
1052+
rotpos[ia*3+2] -= tmp_ptrans[2];
10521053
}
10531054
}
10541055
}

0 commit comments

Comments
 (0)