Skip to content

Commit

Permalink
Feature : 1. only check relaxation parameters for calculation=relax/c…
Browse files Browse the repository at this point in the history
…ell-relax; 2. differentiates different calculations for timer and title in cal_gint (#1485)

* fix : latname in unit test elecstate_lcao_test

* refactor : removed glbalc::hm and globalc::ufft

* fix : removed 'use_fft.h' in headers

* fix : unit tests in module_elecstate

* fix : comment out lobalc::hm from cuda codes

* differentiate different gint in title and timer

* checks relax params only for relax & cell-relax

* keep the total gint timer

Co-authored-by: wenfei-li <liwenfei@gmail.com>
  • Loading branch information
wenfei-li and wenfei-li committed Nov 9, 2022
1 parent fbb0934 commit 7df238e
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 24 deletions.
34 changes: 19 additions & 15 deletions source/input_conv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,27 @@ void Input_Conv::Convert(void)
GlobalV::global_orbital_dir = INPUT.orbital_dir + "/";
// GlobalV::global_pseudo_type = INPUT.pseudo_type;
GlobalC::ucell.setup(INPUT.latname, INPUT.ntype, INPUT.lmaxmax, INPUT.init_vel, INPUT.fixed_axes);
if(INPUT.fixed_ibrav && !INPUT.relax_new)
{
ModuleBase::WARNING_QUIT("Input_Conv","fixed_ibrav only available for relax_new = 1");
}
if(INPUT.latname=="none" && INPUT.fixed_ibrav)
{
ModuleBase::WARNING_QUIT("Input_Conv","to use fixed_ibrav, latname must be provided");
}
if(INPUT.calculation == "relax" && INPUT.fixed_atoms)
{
ModuleBase::WARNING_QUIT("Input_Conv","fixed_atoms is not meant to be used for calculation = relax");
}
if(INPUT.relax_new && INPUT.relax_method!="cg")

if(INPUT.calculation=="relax" || INPUT.calculation=="cell-relax")
{
ModuleBase::WARNING_QUIT("Input_Conv","only CG has been implemented for relax_new");
if(INPUT.fixed_ibrav && !INPUT.relax_new)
{
ModuleBase::WARNING_QUIT("Input_Conv","fixed_ibrav only available for relax_new = 1");
}
if(INPUT.latname=="none" && INPUT.fixed_ibrav)
{
ModuleBase::WARNING_QUIT("Input_Conv","to use fixed_ibrav, latname must be provided");
}
if(INPUT.calculation == "relax" && INPUT.fixed_atoms)
{
ModuleBase::WARNING_QUIT("Input_Conv","fixed_atoms is not meant to be used for calculation = relax");
}
if(INPUT.relax_new && INPUT.relax_method!="cg")
{
ModuleBase::WARNING_QUIT("Input_Conv","only CG has been implemented for relax_new");
}
GlobalV::fixed_atoms = INPUT.fixed_atoms;
}
GlobalV::fixed_atoms = INPUT.fixed_atoms;

GlobalV::KSPACING = INPUT.kspacing;
GlobalV::MIN_DIST_COEF = INPUT.min_dist_coef;
Expand Down
2 changes: 1 addition & 1 deletion source/module_elecstate/test/updaterhok_pw_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ namespace GlobalC
{
K_Vectors kv;
wavefunc wf;
Charge_Broyden CHR;
Charge CHR;
Potential pot;
UnitCell_pseudo ucell;
ModuleSymmetry::Symmetry symm;
Expand Down
8 changes: 4 additions & 4 deletions source/module_esolver/esolver_ks_lcao_elec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,29 +188,29 @@ namespace ModuleESolver
// calculate the charge density
if (GlobalV::GAMMA_ONLY_LOCAL)
{
Gint_inout inout(this->LOC.DM, (Charge*)(&GlobalC::CHR), Gint_Tools::job_type::rho);
Gint_inout inout(this->LOC.DM, &GlobalC::CHR, Gint_Tools::job_type::rho);
this->UHM.GG.cal_gint(&inout);
if (XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type()==5)
{
for(int is=0; is<GlobalV::NSPIN; is++)
{
ModuleBase::GlobalFunc::ZEROS(GlobalC::CHR.kin_r[0], GlobalC::rhopw->nrxx);
}
Gint_inout inout1(this->LOC.DM, (Charge*)(&GlobalC::CHR), Gint_Tools::job_type::tau);
Gint_inout inout1(this->LOC.DM, &GlobalC::CHR, Gint_Tools::job_type::tau);
this->UHM.GG.cal_gint(&inout1);
}
}
else
{
Gint_inout inout(this->LOC.DM_R, (Charge*)(&GlobalC::CHR), Gint_Tools::job_type::rho);
Gint_inout inout(this->LOC.DM_R, &GlobalC::CHR, Gint_Tools::job_type::rho);
this->UHM.GK.cal_gint(&inout);
if (XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type()==5)
{
for(int is=0; is<GlobalV::NSPIN; is++)
{
ModuleBase::GlobalFunc::ZEROS(GlobalC::CHR.kin_r[0], GlobalC::rhopw->nrxx);
}
Gint_inout inout1(this->LOC.DM_R, (Charge*)(&GlobalC::CHR), Gint_Tools::job_type::tau);
Gint_inout inout1(this->LOC.DM_R, &GlobalC::CHR, Gint_Tools::job_type::tau);
this->UHM.GK.cal_gint(&inout1);
}
}
Expand Down
27 changes: 24 additions & 3 deletions source/module_gint/gint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,22 @@

void Gint::cal_gint(Gint_inout *inout)
{
ModuleBase::TITLE("Gint_interface","cal_gint");
ModuleBase::timer::tick("Gint_interface", "cal_gint");

ModuleBase::timer::tick("Gint_interface", "cal_gint");

if(inout->job==Gint_Tools::job_type::vlocal) ModuleBase::TITLE("Gint_interface","cal_gint_vlocal");
if(inout->job==Gint_Tools::job_type::vlocal_meta) ModuleBase::TITLE("Gint_interface","cal_gint_vlocal_meta");
if(inout->job==Gint_Tools::job_type::rho) ModuleBase::TITLE("Gint_interface","cal_gint_rho");
if(inout->job==Gint_Tools::job_type::tau) ModuleBase::TITLE("Gint_interface","cal_gint_tau");
if(inout->job==Gint_Tools::job_type::force) ModuleBase::TITLE("Gint_interface","cal_gint_force");
if(inout->job==Gint_Tools::job_type::force_meta) ModuleBase::TITLE("Gint_interface","cal_gint_force_meta");

if(inout->job==Gint_Tools::job_type::vlocal) ModuleBase::timer::tick("Gint_interface", "cal_gint_vlocal");
if(inout->job==Gint_Tools::job_type::vlocal_meta) ModuleBase::timer::tick("Gint_interface","cal_gint_vlocal_meta");
if(inout->job==Gint_Tools::job_type::rho) ModuleBase::timer::tick("Gint_interface","cal_gint_rho");
if(inout->job==Gint_Tools::job_type::tau) ModuleBase::timer::tick("Gint_interface","cal_gint_tau");
if(inout->job==Gint_Tools::job_type::force) ModuleBase::timer::tick("Gint_interface","cal_gint_force");
if(inout->job==Gint_Tools::job_type::force_meta) ModuleBase::timer::tick("Gint_interface","cal_gint_force_meta");

const int max_size = GlobalC::GridT.max_atom;
const int LD_pool = max_size*GlobalC::ucell.nwmax;
Expand Down Expand Up @@ -234,7 +248,14 @@ void Gint::cal_gint(Gint_inout *inout)
#endif
} // end of if (max_size)

ModuleBase::timer::tick("Gint_interface","cal_gint");
ModuleBase::timer::tick("Gint_interface", "cal_gint");

if(inout->job==Gint_Tools::job_type::vlocal) ModuleBase::timer::tick("Gint_interface", "cal_gint_vlocal");
if(inout->job==Gint_Tools::job_type::vlocal_meta) ModuleBase::timer::tick("Gint_interface","cal_gint_vlocal_meta");
if(inout->job==Gint_Tools::job_type::rho) ModuleBase::timer::tick("Gint_interface","cal_gint_rho");
if(inout->job==Gint_Tools::job_type::tau) ModuleBase::timer::tick("Gint_interface","cal_gint_tau");
if(inout->job==Gint_Tools::job_type::force) ModuleBase::timer::tick("Gint_interface","cal_gint_force");
if(inout->job==Gint_Tools::job_type::force_meta) ModuleBase::timer::tick("Gint_interface","cal_gint_force_meta");
return;
}

Expand Down
3 changes: 2 additions & 1 deletion source/module_gint/gint_tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ namespace Gint_Tools
//Hamiltonian, electron density, force, kinetic energy density, Hamiltonian for mGGA
}

//the class used to pass input/output variables
//the class is used to pass input/output variables
//into the unified interface gint
//not sure if this is the best practice though ..
class Gint_inout
{
public:
Expand Down

0 comments on commit 7df238e

Please sign in to comment.