Skip to content
Open
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
5 changes: 0 additions & 5 deletions source/source_cell/sep_cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
#include <string>
#include <vector>

// namespace GlobalC
// {
// Sep_Cell sep_cell;
// }

Sep_Cell::Sep_Cell() noexcept : ntype(0), omega(0.0), tpiba2(0.0)
{
}
Expand Down
5 changes: 0 additions & 5 deletions source/source_cell/sep_cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,4 @@ class Sep_Cell
double tpiba2; // tpiba ^ 2
};

// namespace GlobalC
// {
// extern Sep_Cell sep_cell;
// }

#endif // SEP_CEll
5 changes: 0 additions & 5 deletions source/source_cell/unitcell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,6 @@ void UnitCell::setup_cell(const std::string& fn, std::ofstream& log)
// readl sep potential, currently using the pseudopotential folder (pseudo_dir in INPUT)
//==========================
if (PARAM.inp.dfthalf_type > 0) {
// GlobalC::sep_cell.init(this->ntype);
// ok3 = GlobalC::sep_cell.read_sep_potentials(ifa, PARAM.inp.pseudo_dir, GlobalV::ofs_warning, this->atom_label);

sep_cell.init(this->ntype);
ok3 = sep_cell.read_sep_potentials(ifa, PARAM.inp.pseudo_dir, GlobalV::ofs_warning, this->atom_label);
}
Expand Down Expand Up @@ -285,7 +282,6 @@ void UnitCell::setup_cell(const std::string& fn, std::ofstream& log)

#ifdef __MPI
unitcell::bcast_unitcell(*this);
// GlobalC::sep_cell.bcast_sep_cell();
sep_cell.bcast_sep_cell();
#endif

Expand Down Expand Up @@ -350,7 +346,6 @@ void UnitCell::setup_cell(const std::string& fn, std::ofstream& log)
//===================================
this->set_iat2itia();

// GlobalC::sep_cell.set_omega(this->omega, this->tpiba2);
sep_cell.set_omega(this->omega, this->tpiba2);

return;
Expand Down
14 changes: 11 additions & 3 deletions source/source_esolver/esolver_ks_lcaopw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "source_pw/module_pwdft/elecond.h"
#include "source_io/module_parameter/input_conv.h"
#include "source_io/module_output/output_log.h"
#include "source_hamilt/module_xc/exx_info.h"

#include <iostream>

Expand Down Expand Up @@ -141,9 +143,11 @@ namespace ModuleESolver

// add exx
#ifdef __EXX
if (GlobalC::exx_info.info_global.cal_exx)
bool cal_exx = GlobalC::exx_info.info_global.cal_exx;
double hybrid_alpha = GlobalC::exx_info.info_global.hybrid_alpha;
if (cal_exx)
{
this->pelec->set_exx(this->exx_lip->get_exx_energy()); // Peize Lin add 2019-03-09
this->pelec->set_exx(this->exx_lip->get_exx_energy(), cal_exx, hybrid_alpha); // Peize Lin add 2019-03-09
}
#endif

Expand Down Expand Up @@ -227,6 +231,8 @@ namespace ModuleESolver
#ifdef __LCAO
if (PARAM.inp.out_mat_xc)
{
bool cal_exx = GlobalC::exx_info.info_global.cal_exx;
double hybrid_alpha = GlobalC::exx_info.info_global.hybrid_alpha;
ModuleIO::write_Vxc(PARAM.inp.nspin,
PARAM.globalv.nlocal,
GlobalV::DRANK,
Expand All @@ -240,7 +246,9 @@ namespace ModuleESolver
this->locpp.vloc,
this->chr,
this->kv,
this->pelec->wg
this->pelec->wg,
cal_exx,
hybrid_alpha
#ifdef __EXX
,
*this->exx_lip
Expand Down
6 changes: 4 additions & 2 deletions source/source_esolver/esolver_ks_pw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,11 @@ template <typename T, typename Device>
void ESolver_KS_PW<T, Device>::iter_finish(UnitCell& ucell, const int istep, int& iter, bool& conv_esolver)
{
// Related to EXX
if (GlobalC::exx_info.info_global.cal_exx && !exx_helper->get_op_first_iter())
bool cal_exx = GlobalC::exx_info.info_global.cal_exx;
double hybrid_alpha = GlobalC::exx_info.info_global.hybrid_alpha;
if (cal_exx && !exx_helper->get_op_first_iter())
{
this->pelec->set_exx(exx_helper->cal_exx_energy(this->stp.template get_psi_t<T, Device>()));
this->pelec->set_exx(exx_helper->cal_exx_energy(this->stp.template get_psi_t<T, Device>()), cal_exx, hybrid_alpha);
}

// deband is calculated from "output" charge density
Expand Down
13 changes: 0 additions & 13 deletions source/source_esolver/esolver_of_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,19 +207,6 @@ void ESolver_OF::get_step_length(double* dEdtheta, double** ptemp_phi, UnitCell&
// while(true)
// {
// this->pelec->f_en.calculate_etot(this->pw_rho->nrxx,
// this->pw_rho->nxyz); temp_energy =
// this->pelec->f_en.etot; kinetic_energy =
// this->kinetic_energy(); pseudopot_energy = 0.; for (int
// is = 0; is < PARAM.inp.nspin; ++is) {
// pseudopot_energy +=
// this->inner_product(GlobalC::pot.vltot,
// ptemp_rho_[is], this->pw_rho->nrxx, this->dV_);
// }
// Parallel_Reduce::reduce_all(pseudopot_energy);
// temp_energy += kinetic_energy + pseudopot_energy;
// this->opt_dcsrch_->dcSrch(temp_energy, dEdalpha,
// thetaAlpha, this->task_); numDC++;

// if (strncmp(this->task_, "FG", 2) == 0)
// {
// for (int is = 0; is < PARAM.inp.nspin; ++is)
Expand Down
4 changes: 2 additions & 2 deletions source/source_estate/elecstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ class ElecState
bool vnew_exist = false;
void cal_converged();
void cal_energies(const int type);
void set_exx(const double& Eexx);
void set_exx(const std::complex<double>& Eexx);
void set_exx(const double& Eexx, const bool cal_exx, const double hybrid_alpha);
void set_exx(const std::complex<double>& Eexx, const bool cal_exx, const double hybrid_alpha);

double get_hartree_energy();
double get_etot_efield();
Expand Down
15 changes: 11 additions & 4 deletions source/source_estate/elecstate_exx.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
#include "source_estate/elecstate.h"
#include "source_hamilt/module_xc/exx_info.h" // use GlobalC::exx_info
#include "source_base/tool_quit.h"
#include <complex> // use std::complex

namespace elecstate
{

/// @brief calculation if converged
/// @date Peize Lin add 2016-12-03
void ElecState::set_exx(const double& Eexx)
void ElecState::set_exx(const double& Eexx, const bool cal_exx, const double hybrid_alpha)
{
ModuleBase::TITLE("energy", "set_exx");

if (GlobalC::exx_info.info_global.cal_exx)
if (cal_exx)
{
this->f_en.exx = GlobalC::exx_info.info_global.hybrid_alpha * Eexx;
this->f_en.exx = hybrid_alpha * Eexx;
}
return;
}

void ElecState::set_exx(const std::complex<double>& Eexx, const bool cal_exx, const double hybrid_alpha)
{
ModuleBase::WARNING_QUIT("ElecState::set_exx",
"std::complex<double> version is not implemented yet");
}

}
4 changes: 0 additions & 4 deletions source/source_estate/module_pot/pot_sep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ void PotSep::cal_fixed_v(double* vl_pseudo)
ModuleBase::TITLE("PotSep", "cal_fixed_v");
ModuleBase::timer::start("PotSep", "cal_fixed_v");

// GlobalC::vsep_cell.generate_vsep_r(this->rho_basis_[0], this->sf_[0]);

// const_cast<VSep*>(this->vsep_)->generate_vsep_r(this->rho_basis_[0], this->sf_[0]);

if (vsep_cell != nullptr)
{
for (int ir = 0; ir < this->rho_basis_->nrxx; ++ir)
Expand Down
18 changes: 16 additions & 2 deletions source/source_estate/module_pot/pot_xc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@ void PotXC::cal_v_eff(const Charge*const chg, const UnitCell*const ucell, Module
if (XC_Functional::get_ked_flag())
{
#ifdef USE_LIBXC
const double hybrid_alpha = XC_Functional::get_hybrid_alpha();
#ifdef __EXX
const double hse_omega = XC_Functional::get_hse_omega();
#else
const double hse_omega = 0.0;
#endif
const std::tuple<double, double, ModuleBase::matrix, ModuleBase::matrix> etxc_vtxc_v
= XC_Functional_Libxc::v_xc_meta(XC_Functional::get_func_id(), nrxx_current, ucell->omega, ucell->tpiba, chg,
PARAM.inp.nspin);
PARAM.inp.nspin, hybrid_alpha, hse_omega);
*(this->etxc_) = std::get<0>(etxc_vtxc_v);
*(this->vtxc_) = std::get<1>(etxc_vtxc_v);
v_eff += std::get<2>(etxc_vtxc_v);
Expand All @@ -37,11 +43,19 @@ void PotXC::cal_v_eff(const Charge*const chg, const UnitCell*const ucell, Module
}
else
{
const double hybrid_alpha = XC_Functional::get_hybrid_alpha();
#ifdef __EXX
const double hse_omega = XC_Functional::get_hse_omega();
#else
const double hse_omega = 0.0;
#endif
const std::tuple<double, double, ModuleBase::matrix> etxc_vtxc_v
= XC_Functional::v_xc(nrxx_current, chg, ucell,
PARAM.inp.nspin,
PARAM.globalv.domag,
PARAM.globalv.domag_z);
PARAM.globalv.domag_z,
hybrid_alpha,
hse_omega);
*(this->etxc_) = std::get<0>(etxc_vtxc_v);
*(this->vtxc_) = std::get<1>(etxc_vtxc_v);
v_eff += std::get<2>(etxc_vtxc_v);
Expand Down
147 changes: 82 additions & 65 deletions source/source_estate/module_pot/pot_xc_fdm.cpp
Original file line number Diff line number Diff line change
@@ -1,65 +1,82 @@
//=======================
// AUTHOR : Peize Lin
// DATE : 2025-10-01
//=======================

#include "pot_xc_fdm.h"
#include "source_hamilt/module_xc/xc_functional.h"
#include "source_io/module_parameter/parameter.h"

namespace elecstate
{

PotXC_FDM::PotXC_FDM(
const ModulePW::PW_Basis* rho_basis_in,
const Charge*const chg_0_in,
const UnitCell*const ucell)
: chg_0(chg_0_in)
{
this->rho_basis_ = rho_basis_in;
this->dynamic_mode = true;
this->fixed_mode = false;

const std::tuple<double, double, ModuleBase::matrix> etxc_vtxc_v_0
= XC_Functional::v_xc(this->chg_0->nrxx, this->chg_0, ucell,
PARAM.inp.nspin,
PARAM.globalv.domag,
PARAM.globalv.domag_z);
this->v_xc_0 = std::get<2>(etxc_vtxc_v_0);
}

void PotXC_FDM::cal_v_eff(
const Charge*const chg_1,
const UnitCell*const ucell,
ModuleBase::matrix& v_eff)
{
ModuleBase::TITLE("PotXC_FDM", "cal_veff");
ModuleBase::timer::start("PotXC_FDM", "cal_veff");

assert(this->chg_0->nrxx == chg_1->nrxx);
assert(this->chg_0->nspin == chg_1->nspin);

Charge chg_01;
chg_01.set_rhopw(chg_1->rhopw);
chg_01.allocate(chg_1->nspin, chg_01.kin_density());

for(int ir=0; ir<chg_01.nrxx; ++ir)
{
for(int is=0; is<chg_01.nspin; ++is)
{ chg_01.rho[is][ir] = chg_0->rho[is][ir] + chg_1->rho[is][ir]; }
chg_01.rho_core[ir] = chg_0->rho_core[ir] + chg_1->rho_core[ir];
}

const std::tuple<double, double, ModuleBase::matrix> etxc_vtxc_v_01
= XC_Functional::v_xc(chg_01.nrxx, &chg_01, ucell,
PARAM.inp.nspin,
PARAM.globalv.domag,
PARAM.globalv.domag_z);
const ModuleBase::matrix &v_xc_01 = std::get<2>(etxc_vtxc_v_01);

v_eff += v_xc_01 - this->v_xc_0;

ModuleBase::timer::end("PotXC_FDM", "cal_veff");
}

} // namespace elecstate
//=======================
// AUTHOR : Peize Lin
// DATE : 2025-10-01
//=======================

#include "pot_xc_fdm.h"
#include "source_hamilt/module_xc/xc_functional.h"
#include "source_io/module_parameter/parameter.h"

namespace elecstate
{

PotXC_FDM::PotXC_FDM(
const ModulePW::PW_Basis* rho_basis_in,
const Charge*const chg_0_in,
const UnitCell*const ucell)
: chg_0(chg_0_in)
{
this->rho_basis_ = rho_basis_in;
this->dynamic_mode = true;
this->fixed_mode = false;

const double hybrid_alpha = XC_Functional::get_hybrid_alpha();
#ifdef __EXX
const double hse_omega = XC_Functional::get_hse_omega();
#else
const double hse_omega = 0.0;
#endif
const std::tuple<double, double, ModuleBase::matrix> etxc_vtxc_v_0
= XC_Functional::v_xc(this->chg_0->nrxx, this->chg_0, ucell,
PARAM.inp.nspin,
PARAM.globalv.domag,
PARAM.globalv.domag_z,
hybrid_alpha,
hse_omega);
this->v_xc_0 = std::get<2>(etxc_vtxc_v_0);
}

void PotXC_FDM::cal_v_eff(
const Charge*const chg_1,
const UnitCell*const ucell,
ModuleBase::matrix& v_eff)
{
ModuleBase::TITLE("PotXC_FDM", "cal_veff");
ModuleBase::timer::start("PotXC_FDM", "cal_veff");

assert(this->chg_0->nrxx == chg_1->nrxx);
assert(this->chg_0->nspin == chg_1->nspin);

Charge chg_01;
chg_01.set_rhopw(chg_1->rhopw);
chg_01.allocate(chg_1->nspin, chg_01.kin_density());

for(int ir=0; ir<chg_01.nrxx; ++ir)
{
for(int is=0; is<chg_01.nspin; ++is)
{ chg_01.rho[is][ir] = chg_0->rho[is][ir] + chg_1->rho[is][ir]; }
chg_01.rho_core[ir] = chg_0->rho_core[ir] + chg_1->rho_core[ir];
}

const double hybrid_alpha = XC_Functional::get_hybrid_alpha();
#ifdef __EXX
const double hse_omega = XC_Functional::get_hse_omega();
#else
const double hse_omega = 0.0;
#endif
const std::tuple<double, double, ModuleBase::matrix> etxc_vtxc_v_01
= XC_Functional::v_xc(chg_01.nrxx, &chg_01, ucell,
PARAM.inp.nspin,
PARAM.globalv.domag,
PARAM.globalv.domag_z,
hybrid_alpha,
hse_omega);
const ModuleBase::matrix &v_xc_01 = std::get<2>(etxc_vtxc_v_01);

v_eff += v_xc_01 - this->v_xc_0;

ModuleBase::timer::end("PotXC_FDM", "cal_veff");
}

} // namespace elecstate

1 change: 0 additions & 1 deletion source/source_hamilt/module_surchem/sol_force.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ void surchem::force_cor_one(const UnitCell& cell,
//ModuleBase::GlobalFunc::ZEROS(delta_phi_g, rho_basis->npw);

rho_basis->real2recip(this->delta_phi, delta_phi_g);
// GlobalC::UFFT.ToReciSpace(this->delta_phi, delta_phi_g,rho_basis);
// double Ael = 0;
// double Ael1 = 0;
// ModuleBase::GlobalFunc::ZEROS(vg, ngmc);
Expand Down
Loading
Loading