Skip to content

Commit 62489d6

Browse files
committed
decrease the memeory use of pw
1 parent 40ba7d8 commit 62489d6

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

source/source_io/write_vxc_lip.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,11 @@ namespace ModuleIO
160160
{
161161
// 2.1 local xc
162162
vxcs_op_pw = new hamilt::Veff<hamilt::OperatorPW<T>>(kv.isk.data(),
163-
potxc->get_veff_smooth_data<FPTYPE>(), potxc->get_veff_smooth().nr, potxc->get_veff_smooth().nc, &wfc_basis);
163+
potxc->get_veff_smooth_data<FPTYPE>(),
164+
PARAM.inp.nspin,
165+
potxc->get_veff_smooth().nr,
166+
potxc->get_veff_smooth().nc,
167+
&wfc_basis);
164168
vxcs_op_pw->init(ik); // set k-point index
165169
psi_pw.fix_k(ik);
166170
hpsi_localxc.fix_k(ik);

source/source_pw/module_pwdft/hamilt_pw.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ HamiltPW<T, Device>::HamiltPW(elecstate::Potential* pot_in,
8080
pot_in->pot_register(pot_register_in);
8181
Operator<T, Device>* veff = new Veff<OperatorPW<T, Device>>(isk,
8282
pot_in->get_veff_smooth_data<Real>(),
83+
PARAM.inp.nspin,
8384
pot_in->get_veff_smooth().nr,
8485
pot_in->get_veff_smooth().nc,
8586
wfc_basis);

source/source_pw/module_pwdft/operator_pw/veff_pw.cpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ namespace hamilt {
77

88
template<typename T, typename Device>
99
Veff<OperatorPW<T, Device>>::Veff(const int* isk_in,
10-
const Real* veff_in,
11-
const int veff_row,
12-
const int veff_col,
13-
const ModulePW::PW_Basis_K* wfcpw_in)
10+
const Real* veff_in,
11+
const int nspin_in,
12+
const int veff_row,
13+
const int veff_col,
14+
const ModulePW::PW_Basis_K* wfcpw_in)
1415
{
1516
if (isk_in == nullptr || wfcpw_in == nullptr)
1617
{
@@ -21,23 +22,28 @@ Veff<OperatorPW<T, Device>>::Veff(const int* isk_in,
2122
this->cal_type = calculation_type::pw_veff;
2223
this->isk = isk_in;
2324
this->veff = veff_in;
25+
this->nspin = nspin_in;
2426
//note: "veff = nullptr" means that this core does not treat potential but still treats wf.
2527
this->veff_row = veff_row;
2628
this->veff_col = veff_col;
2729
this->wfcpw = wfcpw_in;
28-
resmem_complex_op()(nspin_4_veff, 4*veff_col, "Veff<PW>::porter");
29-
// this->nspin_4_veff=new std::complex<double>[4*veff_row];
3030
resmem_complex_op()(this->porter, this->wfcpw->nmaxgr, "Veff<PW>::porter");
31-
resmem_complex_op()(this->porter1, this->wfcpw->nmaxgr, "Veff<PW>::porter1");
32-
31+
if (nspin == 4)
32+
{
33+
resmem_complex_op()(nspin_4_veff, 4*veff_col, "Veff<PW>::porter");
34+
resmem_complex_op()(this->porter1, this->wfcpw->nmaxgr, "Veff<PW>::porter1");
35+
}
3336
}
3437

3538
template<typename T, typename Device>
3639
Veff<OperatorPW<T, Device>>::~Veff()
3740
{
3841
delmem_complex_op()(this->porter);
39-
delmem_complex_op()(this->porter1);
40-
delmem_complex_op()(this->nspin_4_veff);
42+
if (nspin == 4)
43+
{
44+
delmem_complex_op()(this->porter1);
45+
delmem_complex_op()(this->nspin_4_veff);
46+
}
4147
}
4248

4349
template<typename T, typename Device>

source/source_pw/module_pwdft/operator_pw/veff_pw.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class Veff<OperatorPW<T, Device>> : public OperatorPW<T, Device>
2727
public:
2828
Veff(const int* isk_in,
2929
const Real* veff_in,
30+
const int nspin_in,
3031
const int veff_row,
3132
const int veff_col,
3233
const ModulePW::PW_Basis_K* wfcpw_in);
@@ -65,6 +66,7 @@ class Veff<OperatorPW<T, Device>> : public OperatorPW<T, Device>
6566

6667
int veff_col = 0;
6768
int veff_row = 0;
69+
int nspin = 1;
6870
const Real *veff = nullptr, *h_veff = nullptr, *d_veff = nullptr;
6971
T *porter = nullptr;
7072
T *porter1 = nullptr;

0 commit comments

Comments
 (0)