Skip to content

Commit 404a364

Browse files
committed
fix nspin=2 bug in write_Vxc
1 parent bd0c126 commit 404a364

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
@@ -243,7 +243,12 @@ void write_Vxc(const int nspin,
243243
vxcs_op_ao[is] = new hamilt::Veff<hamilt::OperatorLCAO<TK, TR>>(gint,
244244
&vxc_k_ao, kv.kvec_d, potxc, &vxcs_R_ao[is], &ucell, orb_cutoff, &gd, nspin);
245245

246-
vxcs_op_ao[is]->contributeHR();
246+
vxcs_op_ao[is]->contributeHR(); // Veff::current_spin=0
247+
if (is == 1)
248+
{
249+
vxcs_R_ao[is].set_zero();
250+
vxcs_op_ao[is]->contributeHR(); //Veff::current_spin=1 (changes only when contributeHR() called)
251+
}
247252
}
248253
std::vector<std::vector<double>> e_orb_locxc; // orbital energy (local XC)
249254
std::vector<std::vector<double>> e_orb_tot; // orbital energy (total)
@@ -304,6 +309,17 @@ void write_Vxc(const int nspin,
304309
"k-" + std::to_string(ik),
305310
p2d,
306311
drank);
312+
// ModuleIO::save_mat(-1,
313+
// vxc_k_ao.get_hk(),
314+
// nbasis,
315+
// false /*binary*/,
316+
// PARAM.inp.out_ndigits,
317+
// true /*triangle*/,
318+
// false /*append*/,
319+
// "Vxc_AO",
320+
// "k-" + std::to_string(ik),
321+
// *pv,
322+
// drank);
307323
// ======test=======
308324
// total_energy += all_band_energy(ik, vxc_tot_k_mo, p2d, wg);
309325
// ======test=======

0 commit comments

Comments
 (0)