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
68 changes: 68 additions & 0 deletions source/source_estate/module_charge/charge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "source_hamilt/module_xc/xc_functional.h"
#include "source_io/module_parameter/parameter.h"

#include <utility>
#include <vector>

Charge::Charge()
Expand All @@ -39,6 +40,73 @@ Charge::Charge()
allocate_rho_final_scf = false; // LiuXh add 20180619
}

Charge::Charge(Charge&& other) noexcept
: rho(other.rho),
rho_save(other.rho_save),
rhog(other.rhog),
rhog_save(other.rhog_save),
kin_r(other.kin_r),
kin_r_save(other.kin_r_save),
pgrid(other.pgrid),
_space_rho(other._space_rho),
_space_rho_save(other._space_rho_save),
_space_rhog(other._space_rhog),
_space_rhog_save(other._space_rhog_save),
_space_kin_r(other._space_kin_r),
_space_kin_r_save(other._space_kin_r_save),
nhat(other.nhat),
nhat_save(other.nhat_save),
rho_core(other.rho_core),
rhog_core(other.rhog_core),
prenspin(other.prenspin),
nrxx(other.nrxx),
nxyz(other.nxyz),
ngmc(other.ngmc),
nspin(other.nspin),
rhopw(other.rhopw),
cal_elf(other.cal_elf),
omega_(other.omega_),
allocate_rho(other.allocate_rho),
allocate_rho_final_scf(other.allocate_rho_final_scf)
#ifdef __MPI
,
rec(other.rec),
dis(other.dis)
#endif
{
other.rho = nullptr;
other.rho_save = nullptr;
other.rhog = nullptr;
other.rhog_save = nullptr;
other.kin_r = nullptr;
other.kin_r_save = nullptr;
other.pgrid = nullptr;
other._space_rho = nullptr;
other._space_rho_save = nullptr;
other._space_rhog = nullptr;
other._space_rhog_save = nullptr;
other._space_kin_r = nullptr;
other._space_kin_r_save = nullptr;
other.nhat = nullptr;
other.nhat_save = nullptr;
other.rho_core = nullptr;
other.rhog_core = nullptr;
other.prenspin = 1;
other.nrxx = 0;
other.nxyz = 0;
other.ngmc = 0;
other.nspin = 0;
other.rhopw = nullptr;
other.cal_elf = false;
other.omega_ = nullptr;
other.allocate_rho = false;
other.allocate_rho_final_scf = false;
#ifdef __MPI
other.rec = nullptr;
other.dis = nullptr;
#endif
}

Charge::~Charge()
{
this->destroy();
Expand Down
1 change: 1 addition & 0 deletions source/source_estate/module_charge/charge.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Charge
public:

Charge();
Charge(Charge&& other) noexcept;
~Charge();

//==========================================================
Expand Down
25 changes: 25 additions & 0 deletions source/source_estate/module_dm/density_matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "source_base/constants.h"
#include "source_cell/klist.h"

#include <utility>

namespace elecstate
{

Expand Down Expand Up @@ -53,6 +55,29 @@ DensityMatrix<TK, TR>::DensityMatrix(const Parallel_Orbitals* paraV_in, const in
ModuleBase::Memory::record("DensityMatrix::DMK", this->_DMK.size() * this->_DMK[0].size() * sizeof(TK));
}

template <typename TK, typename TR>
DensityMatrix<TK, TR>::DensityMatrix(DensityMatrix<TK, TR>&& other) noexcept
: EDMK(std::move(other.EDMK)),
#ifdef __PEXSI
pexsi_EDM(std::move(other.pexsi_EDM)),
#endif
_DMR(std::move(other._DMR)),
_DMR_save(std::move(other._DMR_save)),
_DMR_grid(std::move(other._DMR_grid)),
_DMK(std::move(other._DMK)),
_kvec_d(std::move(other._kvec_d)),
_paraV(other._paraV),
_nspin(other._nspin),
_nk(other._nk),
dmr_origin_(std::move(other.dmr_origin_)),
dmr_tmp_(other.dmr_tmp_)
{
other._paraV = nullptr;
other._nspin = 1;
other._nk = 0;
other.dmr_tmp_ = nullptr;
}



// calculate DMR from DMK using blas for multi-k calculation
Expand Down
3 changes: 2 additions & 1 deletion source/source_estate/module_dm/density_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class DensityMatrix
const int nspin,
const std::vector<ModuleBase::Vector3<double>>& kvec_d,
const int nk);
DensityMatrix(DensityMatrix&& other) noexcept;

/**
* @brief Constructor of class DensityMatrix for gamma-only calculation, where kvector is not required
Expand Down Expand Up @@ -301,7 +302,7 @@ class DensityMatrix
/**
* @brief K_Vectors object, which is used to get k-point information
*/
const std::vector<ModuleBase::Vector3<double>> _kvec_d;
std::vector<ModuleBase::Vector3<double>> _kvec_d;

/**
* @brief Parallel_Orbitals object, which contain all information of 2D block cyclic distribution
Expand Down
1 change: 1 addition & 0 deletions source/source_estate/module_pot/H_Hartree_pw.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class PotHartree : public PotBase
{
public:
PotHartree(const ModulePW::PW_Basis* rho_basis_in);
PotHartree(PotHartree&& other) noexcept = default;

void cal_v_eff(const Charge*const chg, const UnitCell*const ucell, ModuleBase::matrix& v_eff);
};
Expand Down
13 changes: 12 additions & 1 deletion source/source_estate/module_pot/pot_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ class PotBase
{
public:
PotBase(){}
PotBase(PotBase&& other) noexcept
: fixed_mode(other.fixed_mode),
dynamic_mode(other.dynamic_mode),
rho_basis_(other.rho_basis_),
rho_basis_smooth_(other.rho_basis_smooth_)
{
other.fixed_mode = false;
other.dynamic_mode = false;
other.rho_basis_ = nullptr;
other.rho_basis_smooth_ = nullptr;
}
virtual ~PotBase(){}

virtual void cal_v_eff(const Charge*const chg, const UnitCell*const ucell, ModuleBase::matrix& v_eff){}
Expand All @@ -40,4 +51,4 @@ class PotBase

} // namespace elecstate

#endif
#endif
19 changes: 14 additions & 5 deletions source/source_estate/module_pot/pot_cosikr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
#include "pot_cosikr.h"

#include <cmath>
#include <utility>

namespace elecstate
{

Pot_Cosikr::Pot_Cosikr(
const ModulePW::PW_Basis* rho_basis_in,
const ModuleBase::Vector3<double> &kvec_d_in,
const std::vector<double> &phase_in,
const std::vector<double> &amplitude_in)
const ModulePW::PW_Basis* rho_basis_in,
const ModuleBase::Vector3<double> &kvec_d_in,
const std::vector<double> &phase_in,
const std::vector<double> &amplitude_in)
:kvec_d(kvec_d_in),
phase(phase_in),
amplitude(amplitude_in)
Expand All @@ -24,6 +25,14 @@ Pot_Cosikr::Pot_Cosikr(
this->fixed_mode = false;
}

Pot_Cosikr::Pot_Cosikr(Pot_Cosikr&& other) noexcept
: PotBase(std::move(other)),
kvec_d(other.kvec_d),
phase(std::move(other.phase)),
amplitude(std::move(other.amplitude))
{
}


void Pot_Cosikr::cal_v_eff(const Charge*const chg, const UnitCell*const ucell, ModuleBase::matrix &v_eff)
{
Expand All @@ -50,4 +59,4 @@ void Pot_Cosikr::cal_v_eff(const Charge*const chg, const UnitCell*const ucell, M
ModuleBase::timer::end("Pot_Cosikr", "cal_veff");
}

}
}
25 changes: 13 additions & 12 deletions source/source_estate/module_pot/pot_cosikr.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,22 @@ namespace elecstate
// ampitude * cos( 2pi*( k * r + phase ) )
class Pot_Cosikr : public PotBase
{
public:
Pot_Cosikr(
const ModulePW::PW_Basis* rho_basis_in,
const ModuleBase::Vector3<double> &kvec_d_in,
const std::vector<double> &phase_in,
const std::vector<double> &amplitude_in);
public:
Pot_Cosikr(
const ModulePW::PW_Basis* rho_basis_in,
const ModuleBase::Vector3<double> &kvec_d_in,
const std::vector<double> &phase_in,
const std::vector<double> &amplitude_in);
Pot_Cosikr(Pot_Cosikr&& other) noexcept;

void cal_v_eff(const Charge*const chg, const UnitCell*const ucell, ModuleBase::matrix &v_eff) override;

private:
const ModuleBase::Vector3<double> kvec_d;
const std::vector<double> phase;
const std::vector<double> amplitude;
};
private:
ModuleBase::Vector3<double> kvec_d;
std::vector<double> phase;
std::vector<double> amplitude;
};

}

#endif
#endif
28 changes: 19 additions & 9 deletions source/source_estate/module_pot/pot_xc_fdm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
// DATE : 2025-10-01
//=======================

#include "pot_xc_fdm.h"
#include "source_hamilt/module_xc/xc_functional.h"

namespace elecstate
{
#include "pot_xc_fdm.h"
#include "source_hamilt/module_xc/xc_functional.h"

#include <utility>

namespace elecstate
{

PotXC_FDM::PotXC_FDM(
const ModulePW::PW_Basis* rho_basis_in,
Expand All @@ -21,10 +23,18 @@ PotXC_FDM::PotXC_FDM(

const std::tuple<double, double, ModuleBase::matrix> etxc_vtxc_v_0
= XC_Functional::v_xc(this->chg_0->nrxx, this->chg_0, ucell);
this->v_xc_0 = std::get<2>(etxc_vtxc_v_0);
}

void PotXC_FDM::cal_v_eff(
this->v_xc_0 = std::get<2>(etxc_vtxc_v_0);
}

PotXC_FDM::PotXC_FDM(PotXC_FDM&& other) noexcept
: PotBase(std::move(other)),
chg_0(other.chg_0),
v_xc_0(std::move(other.v_xc_0))
{
other.chg_0 = nullptr;
}

void PotXC_FDM::cal_v_eff(
const Charge*const chg_1,
const UnitCell*const ucell,
ModuleBase::matrix& v_eff)
Expand Down
15 changes: 8 additions & 7 deletions source/source_estate/module_pot/pot_xc_fdm.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@ class PotXC_FDM : public PotBase
{
public:

PotXC_FDM(
const ModulePW::PW_Basis* rho_basis_in,
const Charge*const chg_0_in,
const UnitCell*const ucell);
PotXC_FDM(
const ModulePW::PW_Basis* rho_basis_in,
const Charge*const chg_0_in,
const UnitCell*const ucell);
PotXC_FDM(PotXC_FDM&& other) noexcept;

void cal_v_eff(
const Charge*const chg_1,
const UnitCell*const ucell,
ModuleBase::matrix& v_eff) override;

const Charge*const chg_0 = nullptr;
ModuleBase::matrix v_xc_0;
const Charge* chg_0 = nullptr;
ModuleBase::matrix v_xc_0;
};

} // namespace elecstate

#endif
#endif
41 changes: 41 additions & 0 deletions source/source_estate/module_pot/potential_new.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "pot_ml_exx.h"

#include <map>
#include <utility>

namespace elecstate
{
Expand Down Expand Up @@ -38,6 +39,46 @@ Potential::Potential(const ModulePW::PW_Basis* rho_basis_in,
this->allocate();
}

Potential::Potential(Potential&& other) noexcept
: PotBase(std::move(other)),
v_eff_fixed(std::move(other.v_eff_fixed)),
v_eff(std::move(other.v_eff)),
veff_smooth(std::move(other.veff_smooth)),
vofk_smooth(std::move(other.vofk_smooth)),
v_xc(std::move(other.v_xc)),
s_veff_smooth(other.s_veff_smooth),
s_vofk_smooth(other.s_vofk_smooth),
d_veff_smooth(other.d_veff_smooth),
d_vofk_smooth(other.d_vofk_smooth),
vofk_eff(std::move(other.vofk_eff)),
fixed_done(other.fixed_done),
etxc_(other.etxc_),
vtxc_(other.vtxc_),
vl_of_0(other.vl_of_0),
components(std::move(other.components)),
ucell_(other.ucell_),
vloc_(other.vloc_),
structure_factors_(other.structure_factors_),
solvent_(other.solvent_),
vsep_cell(other.vsep_cell),
use_gpu_(other.use_gpu_)
{
other.s_veff_smooth = nullptr;
other.s_vofk_smooth = nullptr;
other.d_veff_smooth = nullptr;
other.d_vofk_smooth = nullptr;
other.fixed_done = false;
other.etxc_ = nullptr;
other.vtxc_ = nullptr;
other.use_gpu_ = false;
other.vl_of_0 = 0.0;
other.ucell_ = nullptr;
other.vloc_ = nullptr;
other.structure_factors_ = nullptr;
other.solvent_ = nullptr;
other.vsep_cell = nullptr;
}

Potential::~Potential()
{
if (this->components.size() > 0)
Expand Down
1 change: 1 addition & 0 deletions source/source_estate/module_pot/potential_new.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class Potential : public PotBase
double* etxc_in,
double* vtxc_in,
VSep* vsep_cell_in = nullptr);
Potential(Potential&& other) noexcept;
~Potential();

// initialize potential when SCF begin
Expand Down
Loading
Loading