Skip to content

Commit 09973cb

Browse files
committed
refactor: finish forces and stress for sdft
md is avilable for sdft with "calculation=sto-md"
1 parent 33a983b commit 09973cb

File tree

16 files changed

+979
-14
lines changed

16 files changed

+979
-14
lines changed

source/Makefile.Objects

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ sto_iter.o\
6161
sto_wf.o\
6262
sto_hchi.o\
6363
sto_che.o\
64+
sto_forces.o\
65+
sto_stress_pw.o
6466

6567
OBJS_TOOLS=complexarray.o\
6668
complexmatrix.o \

source/input.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2262,9 +2262,9 @@ void Input::Check(void)
22622262
ModuleBase::WARNING_QUIT("Input::Check", "calculate = istate is only availble for LCAO.");
22632263
}
22642264
}
2265-
else if (calculation == "md") // mohan add 2011-11-04
2265+
else if (calculation == "md" || calculation == "sto-md") // mohan add 2011-11-04
22662266
{
2267-
GlobalV::CALCULATION = "md";
2267+
GlobalV::CALCULATION = calculation;
22682268
symmetry = false;
22692269
cal_force = 1;
22702270
if (mdp.md_nstep == 0)

source/module_esolver/esolver_sdft_pw.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
#include "../src_pw/global.h"
1010
#include "../src_pw/symmetry_rho.h"
1111
//----------------------------------------------
12+
//-----force-------------------
13+
#include "../src_pw/sto_forces.h"
14+
//-----stress------------------
15+
#include "../src_pw/sto_stress_pw.h"
16+
//---------------------------------------------------
1217

1318
namespace ModuleESolver
1419
{
@@ -43,6 +48,7 @@ void ESolver_SDFT_PW::Init(Input &inp, UnitCell_pseudo &cell)
4348
void ESolver_SDFT_PW::beforescf(const int istep)
4449
{
4550
ESolver_KS_PW::beforescf(istep);
51+
if(istep > 0 && INPUT.nbands_sto != 0) Update_Sto_Orbitals(this->stowf, INPUT.seed_sto);
4652
// if(NITER==0)
4753
// {
4854
// int iter = 1;
@@ -292,11 +298,13 @@ void ESolver_SDFT_PW::cal_Energy(energy &en)
292298

293299
void ESolver_SDFT_PW::cal_Force(ModuleBase::matrix &force)
294300
{
295-
301+
Sto_Forces ff;
302+
ff.init(force, this->stowf);
296303
}
297304
void ESolver_SDFT_PW::cal_Stress(ModuleBase::matrix &stress)
298305
{
299-
306+
Sto_Stress_PW ss;
307+
ss.cal_stress(stress, this->stowf);
300308
}
301309

302310

source/run_pw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void Run_pw::plane_wave_line(ModuleESolver::ESolver *p_esolver)
4141

4242

4343

44-
if(GlobalV::CALCULATION == "md")
44+
if(GlobalV::CALCULATION == "md" || GlobalV::CALCULATION == "sto-md")
4545
{
4646
Run_MD_PW run_md_pw;
4747
run_md_pw.md_cells_pw(p_esolver);

source/src_ions/ions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ void Ions::opt_ions_pw(ModuleESolver::ESolver *p_esolver)
141141
time_t fstart = time(NULL);
142142

143143

144-
if (GlobalV::CALCULATION=="scf" || GlobalV::CALCULATION=="relax" || GlobalV::CALCULATION=="cell-relax")
144+
if (GlobalV::CALCULATION=="scf" || GlobalV::CALCULATION=="relax" || GlobalV::CALCULATION=="cell-relax" || GlobalV::CALCULATION.substr(0,3)=="sto")
145145
{
146146
stop = this->after_scf(p_esolver, istep, force_step, stress_step); // pengfei Li 2018-05-14
147147
}
@@ -171,7 +171,7 @@ void Ions::opt_ions_pw(ModuleESolver::ESolver *p_esolver)
171171

172172
}
173173

174-
if(GlobalV::CALCULATION=="scf" || GlobalV::CALCULATION=="relax" || GlobalV::CALCULATION=="cell-relax")
174+
if(GlobalV::CALCULATION=="scf" || GlobalV::CALCULATION=="relax" || GlobalV::CALCULATION=="cell-relax" || GlobalV::CALCULATION.substr(0,3)=="sto")
175175
{
176176
GlobalV::ofs_running << "\n\n --------------------------------------------" << std::endl;
177177
GlobalV::ofs_running << std::setprecision(16);

source/src_pw/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ list(APPEND objects
2626
sto_iter.cpp
2727
sto_hchi.cpp
2828
sto_wf.cpp
29+
sto_forces.cpp
30+
sto_stress_pw.cpp
2931
stress_func_cc.cpp
3032
stress_func_ewa.cpp
3133
stress_func_gga.cpp

source/src_pw/forces.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Forces
2323

2424
void init(ModuleBase::matrix& force);
2525

26-
private:
26+
protected:
2727

2828
int nat;
2929
static double output_acc;

source/src_pw/run_md_pw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ void Run_MD_PW::md_force_virial(
206206

207207
// mohan added eiter to count for the electron iteration number, 2021-01-28
208208
int eiter = 0;
209-
if (GlobalV::CALCULATION == "md")
209+
if (GlobalV::CALCULATION == "md" || GlobalV::CALCULATION == "sto-md")
210210
{
211211
Electrons elec;
212212
#ifdef __LCAO

0 commit comments

Comments
 (0)