Skip to content

Commit

Permalink
Refactor: external_stress in dp/lj (#5831)
Browse files Browse the repository at this point in the history
  • Loading branch information
YuLiu98 authored Jan 8, 2025
1 parent 8407ee9 commit 8d2a79f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
4 changes: 2 additions & 2 deletions source/module_esolver/esolver_dp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@ void ESolver_DP::cal_stress(UnitCell& ucell, ModuleBase::matrix& stress)
{
stress = dp_virial;

ModuleIO::print_stress("TOTAL-STRESS", stress, true, false);

// external stress
double unit_transform = ModuleBase::RYDBERG_SI / pow(ModuleBase::BOHR_RADIUS_SI, 3) * 1.0e-8;
double external_stress[3] = {PARAM.inp.press1, PARAM.inp.press2, PARAM.inp.press3};
for (int i = 0; i < 3; i++)
{
stress(i, i) -= external_stress[i] / unit_transform;
}

ModuleIO::print_stress("TOTAL-STRESS", stress, true, false);
}

void ESolver_DP::after_all_runners(UnitCell& ucell)
Expand Down
6 changes: 0 additions & 6 deletions source/module_esolver/esolver_gets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ void ESolver_GetS::before_all_runners(UnitCell& ucell, const Input_para& inp)
two_center_bundle_,
orb_);

// 4) initialize the density matrix
// DensityMatrix is allocated here, DMK is also initialized here
// DMR is not initialized here, it will be constructed in each before_scf
dynamic_cast<elecstate::ElecStateLCAO<std::complex<double>>*>(this->pelec)
->init_DM(&this->kv, &(this->pv), inp.nspin);

ModuleBase::timer::tick("ESolver_GetS", "before_all_runners");
}

Expand Down
4 changes: 2 additions & 2 deletions source/module_esolver/esolver_lj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ void ESolver_LJ::runner(UnitCell& ucell, const int istep)
{
stress = lj_virial;

ModuleIO::print_stress("TOTAL-STRESS", stress, true, false);

// external stress
double unit_transform = ModuleBase::RYDBERG_SI / pow(ModuleBase::BOHR_RADIUS_SI, 3) * 1.0e-8;
double external_stress[3] = {PARAM.inp.press1, PARAM.inp.press2, PARAM.inp.press3};
for (int i = 0; i < 3; i++)
{
stress(i, i) -= external_stress[i] / unit_transform;
}

ModuleIO::print_stress("TOTAL-STRESS", stress, true, false);
}

void ESolver_LJ::after_all_runners(UnitCell& ucell)
Expand Down

0 comments on commit 8d2a79f

Please sign in to comment.