Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: enable init_chg=file for metagga #5792

Merged
merged 3 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/module_elecstate/module_charge/charge.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class Charge

// mohan add 2021-02-20
int nrxx=0; // number of r vectors in this processor
int nxyz=0; // total nuber of r vectors
int nxyz = 0; // total number of r vectors
int ngmc=0; // number of g vectors in this processor
int nspin=0; // number of spins
ModulePW::PW_Basis* rhopw = nullptr;// When double_grid is used, rhopw = rhodpw (dense grid)
Expand Down
41 changes: 31 additions & 10 deletions source/module_elecstate/module_charge/charge_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
bool read_error = false;
if (PARAM.inp.init_chg == "file" || PARAM.inp.init_chg == "auto")
{
GlobalV::ofs_running << " try to read charge from file : " << std::endl;
GlobalV::ofs_running << " try to read charge from file" << std::endl;

// try to read charge from binary file first, which is the same as QE
// liuyu 2023-12-05
Expand Down Expand Up @@ -99,22 +99,43 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
break;
}
}
}

if (XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5)
{
GlobalV::ofs_running << " try to read kinetic energy density from file" << std::endl;
// try to read charge from binary file first, which is the same as QE
std::vector<std::complex<double>> kin_g_space(PARAM.inp.nspin * this->ngmc, {0.0, 0.0});
std::vector<std::complex<double>*> kin_g;
for (int is = 0; is < PARAM.inp.nspin; is++)
{
kin_g.push_back(kin_g_space.data() + is * this->ngmc);
}

if (XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5)
std::stringstream binary;
binary << PARAM.globalv.global_readin_dir << PARAM.inp.suffix + "-TAU-DENSITY.restart";
if (ModuleIO::read_rhog(binary.str(), rhopw, kin_g.data()))
{
GlobalV::ofs_running << " Read in the kinetic energy density: " << binary.str() << std::endl;
for (int is = 0; is < PARAM.inp.nspin; ++is)
{
rhopw->recip2real(kin_g[is], this->kin_r[is]);
}
}
else
{
for (int is = 0; is < PARAM.inp.nspin; is++)
{
std::stringstream ssc;
ssc << PARAM.globalv.global_readin_dir << "SPIN" << is + 1 << "_TAU.cube";
GlobalV::ofs_running << " try to read kinetic energy density from file : " << ssc.str()
<< std::endl;
// mohan update 2012-02-10, sunliang update 2023-03-09
if (ModuleIO::read_vdata_palgrid(pgrid,
(PARAM.inp.esolver_type == "sdft" ? GlobalV::RANK_IN_STOGROUP : GlobalV::MY_RANK),
GlobalV::ofs_running,
ssc.str(),
this->kin_r[is],
ucell.nat))
if (ModuleIO::read_vdata_palgrid(
pgrid,
(PARAM.inp.esolver_type == "sdft" ? GlobalV::RANK_IN_STOGROUP : GlobalV::MY_RANK),
GlobalV::ofs_running,
ssc.str(),
this->kin_r[is],
ucell.nat))
{
GlobalV::ofs_running << " Read in the kinetic energy density: " << ssc.str() << std::endl;
}
Expand Down
5 changes: 4 additions & 1 deletion tests/integrate/101_PW_15_f_pseudopots/INPUT
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
INPUT_PARAMETERS
#Parameters (1.General)
suffix autotest
calculation scf
calculation scf
dft_functional scan

nbands 8
symmetry 1
Expand All @@ -23,3 +24,5 @@ smearing_sigma 0.002
mixing_type broyden
mixing_beta 0.7

init_chg file
read_file_dir .
2 changes: 2 additions & 0 deletions tests/integrate/101_PW_15_f_pseudopots/README
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ This test for:
*SG15 pseudopotential containing f electron
*mixing_type broyden
*mixing_beta 0.7
*dft_functional scan
*init_chg file
2 changes: 1 addition & 1 deletion tests/integrate/101_PW_15_f_pseudopots/STRU
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ATOMIC_SPECIES
Ce 140.115 58_Ce.UPF upf201

LATTICE_CONSTANT
8.92
6

LATTICE_VECTORS
0.5 0.5 0.0
Expand Down
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/integrate/101_PW_15_f_pseudopots/jd
Original file line number Diff line number Diff line change
@@ -1 +1 @@
test SG15 pseudopotential containing f electron, symmetry=on
test SG15 pseudopotential containing f electron with scan, symmetry=on, init_chg=file
6 changes: 3 additions & 3 deletions tests/integrate/101_PW_15_f_pseudopots/result.ref
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
etotref -3436.745619582930
etotperatomref -3436.7456195829
etotref -3644.833836110242
etotperatomref -3644.8338361102
pointgroupref O_h
spacegroupref O_h
nksibzref 3
totaltimeref 0.16141
totaltimeref 0.33
Loading