2727#include " module_ri/serialization_cereal.h"
2828#endif
2929
30+
31+ #include " update_cell.h"
3032UnitCell::UnitCell () {
3133 if (test_unitcell) {
3234 ModuleBase::TITLE (" unitcell" , " Constructor" );
@@ -312,29 +314,7 @@ std::vector<ModuleBase::Vector3<int>> UnitCell::get_constrain() const
312314 return constrain;
313315}
314316
315- void UnitCell::update_pos_tau (const double * pos) {
316- int iat = 0 ;
317- for (int it = 0 ; it < this ->ntype ; it++) {
318- Atom* atom = &this ->atoms [it];
319- for (int ia = 0 ; ia < atom->na ; ia++) {
320- for (int ik = 0 ; ik < 3 ; ++ik) {
321- if (atom->mbl [ia][ik]) {
322- atom->dis [ia][ik]
323- = pos[3 * iat + ik] / this ->lat0 - atom->tau [ia][ik];
324- atom->tau [ia][ik] = pos[3 * iat + ik] / this ->lat0 ;
325- }
326- }
327317
328- // the direct coordinates also need to be updated.
329- atom->dis [ia] = atom->dis [ia] * this ->GT ;
330- atom->taud [ia] = atom->tau [ia] * this ->GT ;
331- iat++;
332- }
333- }
334- assert (iat == this ->nat );
335- this ->periodic_boundary_adjustment ();
336- this ->bcast_atoms_tau ();
337- }
338318
339319void UnitCell::update_pos_taud (double * posd_in) {
340320 int iat = 0 ;
@@ -349,7 +329,7 @@ void UnitCell::update_pos_taud(double* posd_in) {
349329 }
350330 }
351331 assert (iat == this ->nat );
352- this ->periodic_boundary_adjustment ( );
332+ unitcell::periodic_boundary_adjustment ( this ->atoms , this -> latvec , this -> ntype );
353333 this ->bcast_atoms_tau ();
354334}
355335
@@ -367,7 +347,7 @@ void UnitCell::update_pos_taud(const ModuleBase::Vector3<double>* posd_in) {
367347 }
368348 }
369349 assert (iat == this ->nat );
370- this ->periodic_boundary_adjustment ( );
350+ unitcell::periodic_boundary_adjustment ( this ->atoms , this -> latvec , this -> ntype );
371351 this ->bcast_atoms_tau ();
372352}
373353
@@ -383,54 +363,6 @@ void UnitCell::update_vel(const ModuleBase::Vector3<double>* vel_in) {
383363 assert (iat == this ->nat );
384364}
385365
386- void UnitCell::periodic_boundary_adjustment () {
387- // ----------------------------------------------
388- // because of the periodic boundary condition
389- // we need to adjust the atom positions,
390- // first adjust direct coordinates,
391- // then update them into cartesian coordinates,
392- // ----------------------------------------------
393- for (int it = 0 ; it < this ->ntype ; it++) {
394- Atom* atom = &this ->atoms [it];
395- for (int ia = 0 ; ia < atom->na ; ia++) {
396- // mohan update 2011-03-21
397- if (atom->taud [ia].x < 0 ) {
398- atom->taud [ia].x += 1.0 ;
399- }
400- if (atom->taud [ia].y < 0 ) {
401- atom->taud [ia].y += 1.0 ;
402- }
403- if (atom->taud [ia].z < 0 ) {
404- atom->taud [ia].z += 1.0 ;
405- }
406- if (atom->taud [ia].x >= 1.0 ) {
407- atom->taud [ia].x -= 1.0 ;
408- }
409- if (atom->taud [ia].y >= 1.0 ) {
410- atom->taud [ia].y -= 1.0 ;
411- }
412- if (atom->taud [ia].z >= 1.0 ) {
413- atom->taud [ia].z -= 1.0 ;
414- }
415-
416- if (atom->taud [ia].x < 0 || atom->taud [ia].y < 0
417- || atom->taud [ia].z < 0 || atom->taud [ia].x >= 1.0
418- || atom->taud [ia].y >= 1.0 || atom->taud [ia].z >= 1.0 ) {
419- GlobalV::ofs_warning << " it=" << it + 1 << " ia=" << ia + 1
420- << std::endl;
421- GlobalV::ofs_warning << " d=" << atom->taud [ia].x << " "
422- << atom->taud [ia].y << " "
423- << atom->taud [ia].z << std::endl;
424- ModuleBase::WARNING_QUIT (
425- " Ions_Move_Basic::move_ions" ,
426- " the movement of atom is larger than the length of cell." );
427- }
428-
429- atom->tau [ia] = atom->taud [ia] * this ->latvec ;
430- }
431- }
432- return ;
433- }
434366
435367void UnitCell::bcast_atoms_tau () {
436368#ifdef __MPI
0 commit comments