Skip to content

Commit

Permalink
Feature: add force and stress output for noncollinear calculation wit…
Browse files Browse the repository at this point in the history
…h soc (#3933)

* release force warning in noncollinear case

* foverlap and ft pulay

* fix ft foverlap add VNL_pulay

* FH and pulay force of VNL with soc

* noncollinear stress calculation

* treat GlobalV::NSPIN and GlobalV::NPOL

* treat globalV

* treat GlobalC::ucell

* treat GlobalC::ORB

* treat GridD

* rewrite some if sentence

* treat GlobalC GlobalV and if sentence

* treat nspin_

---------

Co-authored-by: Mohan Chen <mohan.chen.chen.mohan@gmail.com>
  • Loading branch information
hongriTianqi and mohanchen committed Apr 11, 2024
1 parent 21d40ce commit aacf171
Show file tree
Hide file tree
Showing 14 changed files with 705 additions and 383 deletions.
10 changes: 4 additions & 6 deletions source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void Force_LCAO_gamma::allocate_gamma(
}
// calculate dS in LCAO basis
// ModuleBase::timer::tick("Force_LCAO_gamma","build_S_new");
gen_h.build_ST_new('S', cal_deri, GlobalC::ucell, lm.Sloc.data());
gen_h.build_ST_new('S', cal_deri, GlobalC::ucell, GlobalC::ORB, GlobalC::UOT, &(GlobalC::GridD), lm.Sloc.data());
// ModuleBase::timer::tick("Force_LCAO_gamma","build_S_new");

// calculate dT in LCAP
Expand All @@ -204,12 +204,12 @@ void Force_LCAO_gamma::allocate_gamma(
// calculate dT
// calculate T + VNL(P1) in LCAO basis
// ModuleBase::timer::tick("Force_LCAO_gamma","build_T_new");
gen_h.build_ST_new('T', cal_deri, GlobalC::ucell, lm.Hloc_fixed.data());
gen_h.build_ST_new('T', cal_deri, GlobalC::ucell, GlobalC::ORB, GlobalC::UOT, &(GlobalC::GridD), lm.Hloc_fixed.data());
// ModuleBase::timer::tick("Force_LCAO_gamma","build_T_new");
// test_gamma(lm.DHloc_fixed_x, "dHloc_fixed_x T part");

// ModuleBase::timer::tick("Force_LCAO_gamma","build_Nonlocal_mu");
gen_h.build_Nonlocal_mu_new(lm.Hloc_fixed.data(), cal_deri);
gen_h.build_Nonlocal_mu_new(lm.Hloc_fixed.data(), cal_deri, GlobalC::ucell, GlobalC::ORB, GlobalC::UOT, &(GlobalC::GridD));
// ModuleBase::timer::tick("Force_LCAO_gamma","build_Nonlocal_mu");
// test_gamma(lm.DHloc_fixed_x, "dHloc_fixed_x Vnl part");

Expand All @@ -220,9 +220,7 @@ void Force_LCAO_gamma::allocate_gamma(

lm.zeros_HSgamma('S');

gen_h.build_ST_new('S', cal_deri, GlobalC::ucell,

lm.Sloc.data(), INPUT.cal_syns, INPUT.dmax);
gen_h.build_ST_new('S', cal_deri, GlobalC::ucell, GlobalC::ORB, GlobalC::UOT, &(GlobalC::GridD), lm.Sloc.data(), INPUT.cal_syns, INPUT.dmax);

bool bit = false; // LiuXh, 2017-03-21

Expand Down
20 changes: 14 additions & 6 deletions source/module_hamilt_lcao/hamilt_lcaodft/FORCE_k.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ void Force_LCAO_k::ftable_k(const bool isforce,

this->cal_ftvnl_dphi_k(
DM,
pv,
pv,
GlobalC::ucell,
lm,
isforce,
isstress,
Expand All @@ -111,7 +112,11 @@ void Force_LCAO_k::ftable_k(const bool isforce,
DM,
isforce,
isstress,
pv,
pv,
GlobalC::ucell,
GlobalC::ORB,
GlobalC::UOT,
&(GlobalC::GridD),
fvnl_dbeta,
svnl_dbeta);

Expand Down Expand Up @@ -247,7 +252,7 @@ void Force_LCAO_k::allocate_k(const Parallel_Orbitals& pv,
// calculate dS = <phi | dphi>
//-----------------------------
bool cal_deri = true;
gen_h.build_ST_new('S', cal_deri, GlobalC::ucell, gen_h.LM->SlocR.data());
gen_h.build_ST_new('S', cal_deri, GlobalC::ucell, GlobalC::ORB, GlobalC::UOT, &(GlobalC::GridD), gen_h.LM->SlocR.data());

//-----------------------------------------
// (2) allocate for <phi | T + Vnl | dphi>
Expand All @@ -270,10 +275,10 @@ void Force_LCAO_k::allocate_k(const Parallel_Orbitals& pv,

// calculate dT=<phi|kin|dphi> in LCAO
// calculate T + VNL(P1) in LCAO basis
gen_h.build_ST_new('T', cal_deri, GlobalC::ucell, gen_h.LM->Hloc_fixedR.data());
gen_h.build_ST_new('T', cal_deri, GlobalC::ucell, GlobalC::ORB, GlobalC::UOT, &(GlobalC::GridD), gen_h.LM->Hloc_fixedR.data());

// calculate dVnl=<phi|dVnl|dphi> in LCAO
gen_h.build_Nonlocal_mu_new(gen_h.LM->Hloc_fixed.data(), cal_deri);
gen_h.build_Nonlocal_mu_new(gen_h.LM->Hloc_fixed.data(), cal_deri, GlobalC::ucell, GlobalC::ORB, GlobalC::UOT, &(GlobalC::GridD));

// calculate asynchronous S matrix to output for Hefei-NAMD
if (INPUT.cal_syns)
Expand All @@ -283,7 +288,10 @@ void Force_LCAO_k::allocate_k(const Parallel_Orbitals& pv,
// INPUT.cal_syns);
gen_h.build_ST_new('S',
cal_deri,
GlobalC::ucell,
GlobalC::ucell,
GlobalC::ORB,
GlobalC::UOT,
&(GlobalC::GridD),
lm.SlocR.data(),
INPUT.cal_syns,
INPUT.dmax);
Expand Down
5 changes: 5 additions & 0 deletions source/module_hamilt_lcao/hamilt_lcaodft/FORCE_k.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class Force_LCAO_k : public Force_LCAO_gamma
// calculate the force due to < dphi | beta > < beta | phi >
void cal_ftvnl_dphi_k(const elecstate::DensityMatrix<std::complex<double>, double>* DM,
const Parallel_Orbitals &pv,
const UnitCell &ucell,
LCAO_Matrix &lm,
const bool isforce,
const bool isstress,
Expand Down Expand Up @@ -97,6 +98,10 @@ class Force_LCAO_k : public Force_LCAO_gamma
const bool isforce,
const bool isstress,
const Parallel_Orbitals &pv,
const UnitCell &ucell,
const LCAO_Orbitals& orb,
const ORB_gen_tables& uot,
Grid_Driver* GridD,
ModuleBase::matrix& fvnl_dbeta,
ModuleBase::matrix& svnl_dbeta);

Expand Down

0 comments on commit aacf171

Please sign in to comment.