@@ -14,9 +14,13 @@ void Relax_Driver::relax_driver(ModuleESolver::ESolver* p_esolver)
1414 ModuleBase::TITLE (" Ions" , " opt_ions" );
1515 ModuleBase::timer::tick (" Ions" , " opt_ions" );
1616
17- if (PARAM.inp .calculation == " relax" || PARAM.inp .calculation == " cell-relax" )
17+ if (PARAM.inp .calculation == " relax" || PARAM.inp .calculation == " cell-relax" )
1818 {
19- if (!PARAM.inp .relax_new )
19+ if (PARAM.inp .relax_method == " relax_trad" )
20+ {
21+ mybfgs.initialize (GlobalC::ucell.nat );
22+ }
23+ else if (!PARAM.inp .relax_new )
2024 {
2125 rl_old.init_relax (GlobalC::ucell.nat );
2226 }
@@ -25,7 +29,7 @@ void Relax_Driver::relax_driver(ModuleESolver::ESolver* p_esolver)
2529 rl.init_relax (GlobalC::ucell.nat );
2630 }
2731 }
28- mybfgs. initialize (GlobalC::ucell. nat );
32+
2933
3034 this ->istep = 1 ;
3135 int force_step = 1 ; // pengfei Li 2018-05-14
@@ -78,10 +82,27 @@ void Relax_Driver::relax_driver(ModuleESolver::ESolver* p_esolver)
7882
7983 if (PARAM.inp .calculation == " relax" || PARAM.inp .calculation == " cell-relax" )
8084 {
81- /* if (PARAM.inp.relax_new)
85+ if (PARAM.inp .relax_method == " bfgs_trad" )
86+ {
87+ std::vector<std::vector<double >> _force (force.nr ,std::vector<double >(force.nc ,0 ));
88+ for (int i = 0 ; i < force.nr ; i++)
89+ {
90+
91+ for (int j=0 ;j<force.nc ;j++)
92+ {
93+ _force[i][j]=force (i,j)*13.605693009 /ModuleBase::BOHR_TO_A;
94+ // std::cout<<_force[i][j]<<' ';
95+ }
96+ // std::cout<<std::endl;
97+ }
98+ stop=mybfgs.Step (_force,GlobalC::ucell);
99+ }
100+
101+ else if (PARAM.inp .relax_new )
82102 {
83103 stop = rl.relax_step (force, stress, this ->etot );
84104 }
105+
85106 else
86107 {
87108 stop = rl_old.relax_step (istep,
@@ -91,19 +112,8 @@ void Relax_Driver::relax_driver(ModuleESolver::ESolver* p_esolver)
91112 stress,
92113 force_step,
93114 stress_step); // pengfei Li 2018-05-14
94- }*/
95- std::vector<std::vector<double >> _force (force.nr ,std::vector<double >(force.nc ,0 ));
96- for (int i = 0 ; i < force.nr ; i++)
97- {
98-
99- for (int j=0 ;j<force.nc ;j++)
100- {
101- _force[i][j]=force (i,j)*13.605693009 /ModuleBase::BOHR_TO_A;
102- std::cout<<_force[i][j]<<' ' ;
103- }
104- std::cout<<std::endl;
105115 }
106- stop=mybfgs. Step (_force,GlobalC::ucell);
116+
107117
108118 // print structure
109119 // changelog 20240509
0 commit comments