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

Refactor: remove GlobalC::solvent_model #5735

Merged
merged 4 commits into from
Dec 16, 2024
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
4 changes: 2 additions & 2 deletions source/module_elecstate/elecstate_energy_terms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ double ElecState::get_etot_gatefield()

double ElecState::get_solvent_model_Ael()
{
return GlobalC::solvent_model.Ael;
return surchem::Ael;
}

double ElecState::get_solvent_model_Acav()
{
return GlobalC::solvent_model.Acav;
return surchem::Acav;
}

double ElecState::get_dftu_energy()
Expand Down
4 changes: 2 additions & 2 deletions source/module_elecstate/potentials/efield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ModuleBase::matrix Efield::add_efield(const UnitCell& cell,
const ModulePW::PW_Basis* rho_basis,
const int& nspin,
const double* const* const rho,
surchem& solvent)
const surchem& solvent)
{
ModuleBase::TITLE("Efield", "add_efield");
ModuleBase::timer::tick("Efield", "add_efield");
Expand Down Expand Up @@ -202,7 +202,7 @@ double Efield::cal_elec_dipole(const UnitCell& cell,

double Efield::cal_induced_dipole(const UnitCell& cell,
const ModulePW::PW_Basis* rho_basis,
surchem& solvent,
const surchem& solvent,
const double& bmod)
{
double induced_dipole = 0;
Expand Down
17 changes: 10 additions & 7 deletions source/module_elecstate/potentials/efield.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#ifndef EFIELD_H
#define EFIELD_H

#include "module_cell/unitcell.h"
#include "module_basis/module_pw/pw_basis.h"
#include "module_cell/unitcell.h"
#include "module_hamilt_general/module_surchem/surchem.h"
#include "module_parameter/parameter.h"

namespace elecstate
{
Expand All @@ -17,7 +18,7 @@ class Efield
const ModulePW::PW_Basis* rho_basis,
const int& nspin,
const double* const* const rho,
surchem& solvent);
const surchem& solvent);

static double cal_elec_dipole(const UnitCell& cell,
const ModulePW::PW_Basis* rho_basis,
Expand All @@ -29,7 +30,7 @@ class Efield

static double cal_induced_dipole(const UnitCell& cell,
const ModulePW::PW_Basis* rho_basis,
surchem& solvent,
const surchem& solvent,
const double& bmod);

static double saw_function(const double &a, const double &b, const double &x);
Expand Down Expand Up @@ -59,7 +60,8 @@ namespace elecstate
class PotEfield : public PotBase
{
public:
PotEfield(const ModulePW::PW_Basis* rho_basis_in, const UnitCell* ucell_in, bool dipole) : ucell_(ucell_in)
PotEfield(const ModulePW::PW_Basis* rho_basis_in, const UnitCell* ucell_in, const surchem* solvent_in, bool dipole)
: ucell_(ucell_in), solvent_(solvent_in)
{
this->rho_basis_ = rho_basis_in;
if (!dipole)
Expand All @@ -81,7 +83,7 @@ class PotEfield : public PotBase
const_cast<const ModulePW::PW_Basis*>(rho_basis_),
PARAM.inp.nspin,
nullptr,
GlobalC::solvent_model);
*solvent_);
for (int ir = 0; ir < rho_basis_->nrxx; ++ir)
{
vl_pseudo[ir] += v_efield(0, ir);
Expand All @@ -94,11 +96,12 @@ class PotEfield : public PotBase
const_cast<const ModulePW::PW_Basis*>(rho_basis_),
v_eff.nr,
chg->rho,
GlobalC::solvent_model);
*solvent_);
}

private:
const UnitCell *ucell_ = nullptr;
const UnitCell* ucell_ = nullptr;
const surchem* solvent_ = nullptr;
};

} // namespace elecstate
Expand Down
4 changes: 3 additions & 1 deletion source/module_elecstate/potentials/potential_new.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ Potential::Potential(const ModulePW::PW_Basis* rho_basis_in,
const UnitCell* ucell_in,
const ModuleBase::matrix* vloc_in,
Structure_Factor* structure_factors_in,
surchem* solvent_in,
double* etxc_in,
double* vtxc_in)
: ucell_(ucell_in), vloc_(vloc_in), structure_factors_(structure_factors_in), etxc_(etxc_in), vtxc_(vtxc_in)
: ucell_(ucell_in), vloc_(vloc_in), structure_factors_(structure_factors_in), solvent_(solvent_in), etxc_(etxc_in),
vtxc_(vtxc_in)
{
this->rho_basis_ = rho_basis_in;
this->rho_basis_smooth_ = rho_basis_smooth_in;
Expand Down
7 changes: 5 additions & 2 deletions source/module_elecstate/potentials/potential_new.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#ifndef POTENTIALNEW_H
#define POTENTIALNEW_H

#include <vector>

#include "module_base/complexmatrix.h"
#include "module_hamilt_general/module_surchem/surchem.h"
#include "module_hamilt_pw/hamilt_pwdft/VNL_in_pw.h"
#include "module_hamilt_pw/hamilt_pwdft/structure_factor.h"
#include "pot_base.h"

#include <vector>

namespace elecstate
{
/**
Expand Down Expand Up @@ -58,6 +59,7 @@ class Potential : public PotBase
const UnitCell* ucell_in,
const ModuleBase::matrix* vloc_in,
Structure_Factor* structure_factors_in,
surchem* solvent_in,
double* etxc_in,
double* vtxc_in);
~Potential();
Expand Down Expand Up @@ -211,6 +213,7 @@ class Potential : public PotBase
const UnitCell* ucell_ = nullptr;
const ModuleBase::matrix* vloc_ = nullptr;
Structure_Factor* structure_factors_ = nullptr;
surchem* solvent_ = nullptr;
};

} // namespace elecstate
Expand Down
4 changes: 2 additions & 2 deletions source/module_elecstate/potentials/potential_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ PotBase* Potential::get_pot_type(const std::string& pot_type)
return new PotSurChem(this->rho_basis_,
this->structure_factors_,
this->v_effective_fixed.data(),
&GlobalC::solvent_model);
this->solvent_);
}
else if (pot_type == "efield")
{
return new PotEfield(this->rho_basis_, this->ucell_, PARAM.inp.dip_cor_flag);
return new PotEfield(this->rho_basis_, this->ucell_, this->solvent_, PARAM.inp.dip_cor_flag);
}
else if (pot_type == "gatefield")
{
Expand Down
Loading
Loading