Skip to content

Commit b9ba351

Browse files
committed
fix nspin=2 bug in write_Vxc (deepmodeling#6702)
1 parent d4023b4 commit b9ba351

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

source/module_io/write_vxc.hpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,12 @@ void write_Vxc(const int nspin,
236236
vxcs_op_ao[is] = new hamilt::Veff<hamilt::OperatorLCAO<TK, TR>>(gint,
237237
&vxc_k_ao, kv.kvec_d, potxc, &vxcs_R_ao[is], &ucell, orb_cutoff, &gd, nspin);
238238

239-
vxcs_op_ao[is]->contributeHR();
239+
vxcs_op_ao[is]->contributeHR(); // Veff::current_spin=0
240+
if (is == 1)
241+
{
242+
vxcs_R_ao[is].set_zero();
243+
vxcs_op_ao[is]->contributeHR(); //Veff::current_spin=1 (changes only when contributeHR() called)
244+
}
240245
}
241246
std::vector<std::vector<double>> e_orb_locxc; // orbital energy (local XC)
242247
std::vector<std::vector<double>> e_orb_tot; // orbital energy (total)
@@ -297,6 +302,17 @@ void write_Vxc(const int nspin,
297302
"k-" + std::to_string(ik),
298303
p2d,
299304
drank);
305+
// ModuleIO::save_mat(-1,
306+
// vxc_k_ao.get_hk(),
307+
// nbasis,
308+
// false /*binary*/,
309+
// PARAM.inp.out_ndigits,
310+
// true /*triangle*/,
311+
// false /*append*/,
312+
// "Vxc_AO",
313+
// "k-" + std::to_string(ik),
314+
// *pv,
315+
// drank);
300316
// ======test=======
301317
// total_energy += all_band_energy(ik, vxc_tot_k_mo, p2d, wg);
302318
// ======test=======

0 commit comments

Comments
 (0)