Skip to content

Commit 8f7097d

Browse files
committed
(Fix) Fixed the uninitialized error during DFT-1/2 calculations.
* During DFT-1/2 calculations, the self-energy potential vsep_cell required for DFT-1/2 was not initialized before computing potential_new. * The generation of the self-energy potential vsep_cell has been moved forward to before the computation of potential_new.
1 parent d9ac0c6 commit 8f7097d

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

source/source_pw/module_pwdft/setup_pot.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#include "source_pw/module_pwdft/VSep_in_pw.h"
88

99
template <typename T, typename Device>
10-
void pw::setup_pot(const int istep,
11-
UnitCell& ucell, // unitcell
10+
void pw::setup_pot(const int istep,
11+
UnitCell& ucell, // unitcell
1212
const K_Vectors &kv, // kpoints
1313
Structure_Factor &sf, // structure factors
1414
elecstate::ElecState *pelec, // pointer of electrons
@@ -24,6 +24,16 @@ void pw::setup_pot(const int istep,
2424
const Input_para& inp) // input parameters
2525
{
2626
ModuleBase::TITLE("pw", "setup_pot");
27+
28+
//----------------------------------------------------------
29+
//! 0) DFT-1/2 calculations, sep potential need to generate
30+
// before effective potential calculation
31+
//----------------------------------------------------------
32+
if (PARAM.inp.dfthalf_type > 0)
33+
{
34+
vsep_cell->generate_vsep_r(pw_rhod[0], sf.strucFac, ucell.sep_cell);
35+
}
36+
2737
//----------------------------------------------------------
2838
//! 1) Renew local pseudopotential
2939
//----------------------------------------------------------
@@ -110,21 +120,12 @@ void pw::setup_pot(const int istep,
110120
dftu->init(ucell, nullptr, kv.get_nks());
111121
}
112122

113-
//----------------------------------------------------------
114-
//! 7) DFT-1/2 calculations, sep potential need to generate
115-
// before effective potential calculation
116-
//----------------------------------------------------------
117-
if (PARAM.inp.dfthalf_type > 0)
118-
{
119-
vsep_cell->generate_vsep_r(pw_rhod[0], sf.strucFac, ucell.sep_cell);
120-
}
121-
122123
return;
123124
}
124125

125126
template void pw::setup_pot<std::complex<float>, base_device::DEVICE_CPU>(
126127
const int istep, // ionic step
127-
UnitCell& ucell, // unitcell
128+
UnitCell& ucell, // unitcell
128129
const K_Vectors &kv, // kpoints
129130
Structure_Factor &sf, // structure factors
130131
elecstate::ElecState *pelec, // pointer of electrons
@@ -142,7 +143,7 @@ template void pw::setup_pot<std::complex<float>, base_device::DEVICE_CPU>(
142143

143144
template void pw::setup_pot<std::complex<double>, base_device::DEVICE_CPU>(
144145
const int istep, // ionic step
145-
UnitCell& ucell, // unitcell
146+
UnitCell& ucell, // unitcell
146147
const K_Vectors &kv, // kpoints
147148
Structure_Factor &sf, // structure factors
148149
elecstate::ElecState *pelec, // pointer of electrons
@@ -161,7 +162,7 @@ template void pw::setup_pot<std::complex<double>, base_device::DEVICE_CPU>(
161162

162163
template void pw::setup_pot<std::complex<float>, base_device::DEVICE_GPU>(
163164
const int istep, // ionic step
164-
UnitCell& ucell, // unitcell
165+
UnitCell& ucell, // unitcell
165166
const K_Vectors &kv, // kpoints
166167
Structure_Factor &sf, // structure factors
167168
elecstate::ElecState *pelec, // pointer of electrons
@@ -178,7 +179,7 @@ template void pw::setup_pot<std::complex<float>, base_device::DEVICE_GPU>(
178179

179180
template void pw::setup_pot<std::complex<double>, base_device::DEVICE_GPU>(
180181
const int istep, // ionic step
181-
UnitCell& ucell, // unitcell
182+
UnitCell& ucell, // unitcell
182183
const K_Vectors &kv, // kpoints
183184
Structure_Factor &sf, // structure factors
184185
elecstate::ElecState *pelec, // pointer of electrons

0 commit comments

Comments
 (0)