Skip to content

Commit 710c6ce

Browse files
committed
bfgs1
1 parent cf1d4cf commit 710c6ce

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

source/module_relax/relax_driver.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ void Relax_Driver::relax_driver(ModuleESolver::ESolver* p_esolver)
2525
rl.init_relax(GlobalC::ucell.nat);
2626
}
2727
}
28+
mybfgs.initialize(GlobalC::ucell.nat);
2829

2930
this->istep = 1;
3031
int force_step = 1; // pengfei Li 2018-05-14
@@ -77,7 +78,7 @@ void Relax_Driver::relax_driver(ModuleESolver::ESolver* p_esolver)
7778

7879
if (PARAM.inp.calculation == "relax" || PARAM.inp.calculation == "cell-relax")
7980
{
80-
if (PARAM.inp.relax_new)
81+
/*if (PARAM.inp.relax_new)
8182
{
8283
stop = rl.relax_step(force, stress, this->etot);
8384
}
@@ -90,7 +91,18 @@ void Relax_Driver::relax_driver(ModuleESolver::ESolver* p_esolver)
9091
stress,
9192
force_step,
9293
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+
/* code */
99+
for(int j=0;j<force.nc;j++)
100+
{
101+
_force[i][j]=force(i,j)*13.605693009/ModuleBase::BOHR_TO_A;
102+
}
93103
}
104+
stop=mybfgs.Step(_force);
105+
94106
// print structure
95107
// changelog 20240509
96108
// because I move out the dependence on GlobalV from UnitCell::print_stru_file

source/module_relax/relax_driver.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "module_esolver/esolver_ks.h"
66
#include "relax_new/relax.h"
77
#include "relax_old/relax_old.h"
8-
8+
#include "mytest/bfgs.h"
99
class Relax_Driver
1010
{
1111

@@ -26,6 +26,8 @@ class Relax_Driver
2626

2727
// old relaxation method
2828
Relax_old rl_old;
29+
30+
bfgs mybfgs;
2931
};
3032

3133
#endif

0 commit comments

Comments
 (0)