Skip to content

Commit 9697ca6

Browse files
authored
Merge pull request #473 from dyzheng/ABACUS_2.2.0_beta
fixed bug of triclinic lattice autoset and set default nstep as 50 for relax/cell-relax/md calculations
2 parents 97b196d + f435464 commit 9697ca6

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

source/input.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ void Input::Default(void)
221221
//----------------------------------------------------------
222222
dr2 = 1.0e-9;
223223
niter = 40;
224-
nstep = 1;
224+
this->nstep = 0;
225225
out_stru = 0;
226226
//----------------------------------------------------------
227227
// occupation
@@ -947,7 +947,7 @@ bool Input::Read(const std::string &fn)
947947
}
948948
else if (strcmp("nstep", word) == 0)
949949
{
950-
read_value(ifs, nstep);
950+
read_value(ifs, this->nstep);
951951
}
952952
else if (strcmp("out_stru", word) == 0)
953953
{
@@ -2199,7 +2199,7 @@ void Input::Bcast()
21992199

22002200
Parallel_Common::bcast_double( dr2 );
22012201
Parallel_Common::bcast_int( niter );
2202-
Parallel_Common::bcast_int( nstep );
2202+
Parallel_Common::bcast_int( this->nstep );
22032203
Parallel_Common::bcast_int( out_stru ); //mohan add 2012-03-23
22042204

22052205
//Parallel_Common::bcast_string( occupations );
@@ -2556,7 +2556,7 @@ void Input::Check(void)
25562556
std::cout<<"sorry, can't calculate force with soc now, would be implement in next version!"<<std::endl;
25572557
}
25582558
*/
2559-
nstep = 1;
2559+
this->nstep = 1;
25602560

25612561
}
25622562
else if (calculation == "scf-sto") // qianrui 2021-2-20
@@ -2566,6 +2566,7 @@ void Input::Check(void)
25662566
mem_saver = 0;
25672567
ModuleBase::GlobalFunc::AUTO_SET("mem_savre","0");
25682568
}
2569+
this->nstep = 1;
25692570
}
25702571
else if (calculation == "relax") // pengfei 2014-10-13
25712572
{
@@ -2575,12 +2576,13 @@ void Input::Check(void)
25752576
ModuleBase::GlobalFunc::AUTO_SET("mem_savre","0");
25762577
}
25772578
force = 1;
2579+
if(! this->nstep) this->nstep = 50;
25782580
}
25792581

25802582
else if (calculation == "nscf")
25812583
{
25822584
GlobalV::CALCULATION = "nscf";
2583-
nstep = 1;
2585+
this->nstep = 1;
25842586
out_stru = 0;
25852587

25862588
//if (local_basis == 0 && linear_scaling == 0) xiaohui modify 2013-09-01
@@ -2604,7 +2606,7 @@ void Input::Check(void)
26042606
else if(calculation == "istate")
26052607
{
26062608
GlobalV::CALCULATION = "istate";
2607-
nstep = 1;
2609+
this->nstep = 1;
26082610
out_stru = 0;
26092611
out_dos = 0;
26102612
out_band = 0;
@@ -2625,7 +2627,7 @@ void Input::Check(void)
26252627
else if(calculation == "ienvelope")
26262628
{
26272629
GlobalV::CALCULATION = "ienvelope"; // mohan fix 2011-11-04
2628-
nstep = 1;
2630+
this->nstep = 1;
26292631
out_stru = 0;
26302632
out_dos = 0;
26312633
out_band = 0;
@@ -2647,6 +2649,10 @@ void Input::Check(void)
26472649
GlobalV::CALCULATION = "md";
26482650
symmetry = false;
26492651
force = 1;
2652+
if(this->nstep==0){
2653+
GlobalV::ofs_running<<"nstep should be set. Autoset nstep to 50!"<<endl;
2654+
this->nstep = 50;
2655+
}
26502656
if(!out_md_control) out_level = "m";//zhengdy add 2019-04-07
26512657

26522658
//deal with input parameters , 2019-04-30
@@ -2677,9 +2683,11 @@ void Input::Check(void)
26772683
{
26782684
force = 1;
26792685
stress = 1;
2686+
if(! this->nstep) this->nstep = 50;
26802687
}
26812688
else if(calculation == "test")
26822689
{
2690+
this->nstep = 1;
26832691
}
26842692
else
26852693
{

source/module_cell/read_atoms.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ int UnitCell_pseudo::read_atom_species(std::ifstream &ifa, std::ofstream &ofs_ru
323323
latvec.e22 = bba * sinab;
324324
latvec.e23 = 0.0;
325325
latvec.e31 = cba * cosac;
326-
latvec.e32 = cba * (cosbc - cosac*cosab/sinab);
326+
latvec.e32 = cba * (cosbc - cosac*cosab) / sinab;
327327
term = 1.0 + 2.0 * cosab*cosac*cosbc - cosab*cosab - cosac*cosac - cosbc*cosbc;
328328
term = sqrt(term)/sinab;
329329
latvec.e33 = cba * term;

0 commit comments

Comments
 (0)