Skip to content

Commit 0ac9a66

Browse files
committed
update the compute method
1 parent ed29623 commit 0ac9a66

File tree

1 file changed

+12
-29
lines changed

1 file changed

+12
-29
lines changed

source/module_cell/read_stru.cpp

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -65,47 +65,30 @@ namespace unitcell
6565
Atom* atom1 = &atoms[it];
6666
for(int ia=0; ia<atoms[it].na; ia++)
6767
{
68-
//fmod(x,1.0) set the result as [0,1),
69-
//if x=2.3,fmod(2.3,1.0)=0.3,fmod(2.3,1.0)+1=1.3,
70-
// fmod(fmod(2.3,1.0)+1,1.0)=0.3
71-
//if x=-0.7,fmod(-0.7,1.0)=-0.7 or 0.3,fmod(-0.7,1.0)+1=1.3,
72-
// fmod(fmod(-0.7,1.0)+1,1.0)=0.3
73-
double dx2 = fmod(fmod(atom1->taud[ia].x,1.0)+1.0,1.0);
74-
double dy2 = fmod(fmod(atom1->taud[ia].y,1.0)+1.0,1.0);
75-
double dz2 = fmod(fmod(atom1->taud[ia].z,1.0)+1.0,1.0);
76-
77-
atom1->taud[ia].x = dx2;
78-
atom1->taud[ia].y = dy2;
79-
atom1->taud[ia].z = dz2;
68+
// mohan add 2011-04-07
69+
// fmod(x,1.0) set the result between the [0,1.0),
70+
// while the x may be the negtivate value,thus we add 10000.
71+
atom1->taud[ia].x=fmod(atom1->taud[ia].x + 10000,1.0);
72+
atom1->taud[ia].y=fmod(atom1->taud[ia].y + 10000,1.0);
73+
atom1->taud[ia].z=fmod(atom1->taud[ia].z + 10000,1.0);
8074

8175
double cx2=0.0;
8276
double cy2=0.0;
8377
double cz2=0.0;
8478

8579
ModuleBase::Mathzone::Direct_to_Cartesian(
86-
atom1->taud[ia].x,
87-
atom1->taud[ia].y,
88-
atom1->taud[ia].z,
89-
latvec.e11,
90-
latvec.e12,
91-
latvec.e13,
92-
latvec.e21,
93-
latvec.e22,
94-
latvec.e23,
95-
latvec.e31,
96-
latvec.e32,
97-
latvec.e33,
98-
cx2,
99-
cy2,
100-
cz2);
80+
atom1->taud[ia].x, atom1->taud[ia].y, atom1->taud[ia].z,
81+
latvec.e11, latvec.e12, latvec.e13,
82+
latvec.e21, latvec.e22, latvec.e23,
83+
latvec.e31, latvec.e32, latvec.e33,
84+
cx2, cy2, cz2);
10185

10286
atom1->tau[ia].x = cx2;
10387
atom1->tau[ia].y = cy2;
10488
atom1->tau[ia].z = cz2;
10589

10690
}
10791
}
108-
92+
return;
10993
}
110-
11194
}

0 commit comments

Comments
 (0)