@@ -283,14 +283,17 @@ void UnitCell::update_pos_tau(const double* pos)
283283 {
284284 if (atom->mbl [ia].x != 0 )
285285 {
286+ atom->tau_original [ia].x += (pos[3 * iat] / this ->lat0 - atom->tau [ia].x );
286287 atom->tau [ia].x = pos[3 * iat] / this ->lat0 ;
287288 }
288289 if (atom->mbl [ia].y != 0 )
289290 {
291+ atom->tau_original [ia].y += (pos[3 * iat + 1 ] / this ->lat0 - atom->tau [ia].y );
290292 atom->tau [ia].y = pos[3 * iat + 1 ] / this ->lat0 ;
291293 }
292294 if (atom->mbl [ia].z != 0 )
293295 {
296+ atom->tau_original [ia].z += (pos[3 * iat + 2 ] / this ->lat0 - atom->tau [ia].z );
294297 atom->tau [ia].z = pos[3 * iat + 2 ] / this ->lat0 ;
295298 }
296299
@@ -313,14 +316,17 @@ void UnitCell::update_pos_tau(const ModuleBase::Vector3<double>* posd_in)
313316 {
314317 if (atom->mbl [ia].x != 0 )
315318 {
319+ atom->tau_original [ia].x += (posd_in[iat].x / this ->lat0 - atom->tau [ia].x );
316320 atom->tau [ia].x = posd_in[iat].x / this ->lat0 ;
317321 }
318322 if (atom->mbl [ia].y != 0 )
319323 {
324+ atom->tau_original [ia].y += (posd_in[iat].y / this ->lat0 - atom->tau [ia].y );
320325 atom->tau [ia].y = posd_in[iat].y / this ->lat0 ;
321326 }
322327 if (atom->mbl [ia].z != 0 )
323328 {
329+ atom->tau_original [ia].z += (posd_in[iat].z / this ->lat0 - atom->tau [ia].z );
324330 atom->tau [ia].z = posd_in[iat].z / this ->lat0 ;
325331 }
326332
@@ -444,7 +450,41 @@ void UnitCell::save_cartesian_position(ModuleBase::Vector3<double>* pos) const
444450 Atom* atom = &this ->atoms [it];
445451 for (int ia = 0 ; ia < atom->na ; ++ia)
446452 {
447- pos[iat] = atom->tau [ia] * this ->lat0 ;
453+ pos[iat] = atom->tau_original [ia] * this ->lat0 ;
454+ iat++;
455+ }
456+ }
457+ assert (iat == this ->nat );
458+ return ;
459+ }
460+
461+ void UnitCell::save_cartesian_position_original (double * pos) const
462+ {
463+ int iat = 0 ;
464+ for (int it = 0 ; it < this ->ntype ; it++)
465+ {
466+ Atom* atom = &this ->atoms [it];
467+ for (int ia = 0 ; ia < atom->na ; ia++)
468+ {
469+ pos[3 * iat] = atom->tau_original [ia].x * this ->lat0 ;
470+ pos[3 * iat + 1 ] = atom->tau_original [ia].y * this ->lat0 ;
471+ pos[3 * iat + 2 ] = atom->tau_original [ia].z * this ->lat0 ;
472+ iat++;
473+ }
474+ }
475+ assert (iat == this ->nat );
476+ return ;
477+ }
478+
479+ void UnitCell::save_cartesian_position_original (ModuleBase::Vector3<double >* pos) const
480+ {
481+ int iat = 0 ;
482+ for (int it = 0 ; it < this ->ntype ; ++it)
483+ {
484+ Atom* atom = &this ->atoms [it];
485+ for (int ia = 0 ; ia < atom->na ; ++ia)
486+ {
487+ pos[iat] = atom->tau_original [ia] * this ->lat0 ;
448488 iat++;
449489 }
450490 }
0 commit comments