Skip to content

Commit e5c4282

Browse files
committed
new bfgs_trad method
1 parent 2c4cb0a commit e5c4282

File tree

5 files changed

+160
-225
lines changed

5 files changed

+160
-225
lines changed

SiH2-3et-relax/log

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
https://github.com/deepmodeling/abacus-develop
1010
Commit: unknown
1111

12-
Fri Nov 15 07:24:01 2024
12+
Fri Nov 15 08:05:02 2024
1313
MAKE THE DIR : OUT.abacus/
1414
RUNNING WITH DEVICE : CPU / 13th Gen Intel(R) Core(TM) i7-13700KF
1515
UNIFORM GRID DIM : 256 * 256 * 256
1616
UNIFORM GRID DIM(BIG) : 256 * 256 * 256
17-
DONE(2.0302 SEC) : SETUP UNITCELL
18-
DONE(2.10551 SEC) : INIT K-POINTS
17+
DONE(2.46674 SEC) : SETUP UNITCELL
18+
DONE(2.71952 SEC) : INIT K-POINTS
1919
---------------------------------------------------------
2020
Ion relaxation calculations
2121
---------------------------------------------------------
@@ -30,29 +30,15 @@
3030
---------------------------------------------------------
3131
Initial plane wave basis and FFT box
3232
---------------------------------------------------------
33-
DONE(2.98353 SEC) : INIT PLANEWAVE
34-
DONE(4.27888 SEC) : LOCAL POTENTIAL
35-
DONE(4.41184 SEC) : NON-LOCAL POTENTIAL
33+
DONE(3.80033 SEC) : INIT PLANEWAVE
34+
DONE(5.7434 SEC) : LOCAL POTENTIAL
35+
DONE(5.97613 SEC) : NON-LOCAL POTENTIAL
3636
MEMORY FOR PSI (MB) : 61.8411
37-
DONE(4.60712 SEC) : INIT BASIS
37+
DONE(6.25469 SEC) : INIT BASIS
3838
-------------------------------------------
3939
STEP OF ION RELAXATION : 1
4040
-------------------------------------------
4141
START CHARGE : atomic
42-
DONE(18.8758 SEC) : INIT SCF
42+
DONE(26.3435 SEC) : INIT SCF
4343
ITER TMAG AMAG ETOT/eV EDIFF/eV DRHO TIME/s
44-
DA1 2.00e+00 2.03e+00 -1.36488047e+02 0.00000000e+00 3.9185e-01 55.42
45-
DA2 2.00e+00 2.03e+00 -1.35639323e+02 8.48724853e-01 2.9515e-01 32.58
46-
DA3 2.00e+00 2.03e+00 -1.35175018e+02 4.64304219e-01 1.2141e-01 28.61
47-
DA4 2.00e+00 2.03e+00 -1.35231536e+02 -5.65178630e-02 2.5339e-02 37.91
48-
DA5 2.00e+00 2.02e+00 -1.35222711e+02 8.82512136e-03 1.0236e-02 48.13
49-
DA6 2.00e+00 2.02e+00 -1.35217865e+02 4.84660755e-03 3.1181e-03 45.60
50-
DA7 2.00e+00 2.02e+00 -1.35217872e+02 -7.33928889e-06 5.5952e-04 55.50
51-
DA8 2.00e+00 2.02e+00 -1.35201171e+02 1.67013151e-02 3.9924e-04 41.44
52-
DA9 2.00e+00 2.02e+00 -1.35194998e+02 6.17261755e-03 4.3632e-05 43.46
53-
DA10 2.00e+00 2.02e+00 -1.35193314e+02 1.68393041e-03 2.5192e-05 85.27
54-
DA11 2.00e+00 2.02e+00 -1.35189848e+02 3.46604543e-03 8.9616e-06 52.49
55-
DA12 2.00e+00 2.02e+00 -1.35189045e+02 8.02713411e-04 1.7975e-06 114.13
56-
DA13 2.00e+00 2.02e+00 -1.35188238e+02 8.07283414e-04 8.9097e-07 156.70
57-
DA14 2.00e+00 2.02e+00 -1.35188208e+02 3.00653633e-05 3.6123e-07 194.82
58-
DA15 2.00e+00 2.02e+00 -1.35188171e+02 3.68581656e-05 1.0798e-07 238.54
44+
DA1 2.00e+00 2.03e+00 -1.36488047e+02 0.00000000e+00 3.9185e-01 67.66

source/module_relax/bfgs_traditional/bfgs.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ void bfgs::initialize(int _size) // initialize H0、H、pos0、force0、force
1313
for (int i = 0; i < 3*size; ++i) {
1414
H[i][i] = alpha;
1515
}
16-
1716
pos = std::vector<std::vector<double>> (size, std::vector<double>(3, 0.0));
1817
pos0 = std::vector<double>(3*size, 0.0);
1918
dpos = std::vector<std::vector<double>>(size, std::vector<double>(3, 0.0));
@@ -29,10 +28,13 @@ bool bfgs::Step(std::vector<std::vector<double>> _force,UnitCell& ucell)
2928
std::cout<<"enter Step"<<std::endl;
3029
GlobalC::ucell.ionic_position_updated = true;
3130
force = _force;
32-
31+
//std::cout<<"enter Step0"<<std::endl;
32+
//std::cout<<size<<std::endl;
3333
//GetPos(ucell);
3434
PrepareStep();
35+
//std::cout<<"enter Step1"<<std::endl;
3536
DetermineStep();
37+
//std::cout<<"enter Step2"<<std::endl;
3638
/*for(int i=0;i<size;i++)
3739
{
3840
for(int j=0;j<3;j++)
@@ -42,6 +44,7 @@ bool bfgs::Step(std::vector<std::vector<double>> _force,UnitCell& ucell)
4244
std::cout<<std::endl;
4345
}*/
4446
UpdatePos();
47+
//std::cout<<"enter Step3"<<std::endl;
4548
return IsRestrain();
4649
}
4750

@@ -63,9 +66,12 @@ void bfgs::GetPos()
6366

6467
void bfgs::PrepareStep()
6568
{
69+
//std::cout<<"enter prepareStep0"<<std::endl;
6670
std::vector<double> changedforce = ReshapeMToV(force);
6771
std::vector<double> changedpos = ReshapeMToV(pos);
72+
//std::cout<<"enter prepareStep1"<<std::endl;
6873
Update(changedpos, changedforce);
74+
//std::cout<<"enter prepareStep2"<<std::endl;
6975
/*for(int i = 0; i < 3*size; i++)
7076
{
7177
for(int j = 0; j < 3*size; j++)
@@ -75,8 +81,11 @@ void bfgs::PrepareStep()
7581
std::cout<<std::endl;
7682
}*/
7783
//call dysev
84+
//std::cout<<size<<std::endl;
7885
std::vector<double> omega(3*size);
86+
//std::cout<<"enter prepareStep3"<<std::endl;
7987
std::vector<double> work(3*size*3*size);
88+
//std::cout<<"enter prepareStep4"<<std::endl;
8089
int lwork=3*size*3*size;
8190
int info;
8291
std::vector<double> H_flat;
@@ -88,13 +97,15 @@ void bfgs::PrepareStep()
8897
int* ptr=&value;
8998
dsyev_("V","U",ptr,H_flat.data(),ptr,omega.data(),work.data(),&lwork,&info);
9099
std::vector<std::vector<double>> V(3*size, std::vector<double>(3*size, 0.0));
100+
//std::cout<<"enter prepareStep5"<<std::endl;
91101
for(int i = 0; i < 3*size; i++)
92102
{
93103
for(int j = 0; j < 3*size; j++)
94104
{
95105
V[j][i] = H_flat[3*size*i + j];
96106
}
97107
}
108+
98109

99110
/*for(int i=0;i<3*size;i++)
100111
{

source/module_relax/relax_driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ void Relax_Driver::relax_driver(ModuleESolver::ESolver* p_esolver)
1616

1717
if (PARAM.inp.calculation == "relax" || PARAM.inp.calculation == "cell-relax" )
1818
{
19-
if(PARAM.inp.relax_method == "relax_trad")
19+
if(PARAM.inp.relax_method == "bfgs_trad")
2020
{
2121
mybfgs.initialize(GlobalC::ucell.nat);
2222
}

tests/integrate/109_PW_CR/INPUT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ nspin 1
1414
basis_type pw
1515
relax_nmax 5
1616
relax_new 0
17-
17+
relax_method bfgs_trad
1818
cal_stress 1
1919
stress_thr 1e-6
2020
cal_force 1

0 commit comments

Comments
 (0)