Skip to content

Commit 54f55fa

Browse files
committed
fix: recover Nk divided in cal_dm_trans
1 parent 9b04eca commit 54f55fa

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

source/module_lr/lr_spectrum.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ ModuleBase::Vector3<double> LR::LR_Spectrum<double>::cal_transition_dipole_istat
8080
LR_Util::_deallocate_2order_nested_ptr(rho_trans, 1);
8181
}
8282
trans_dipole *= (ucell.omega / static_cast<double>(gint->get_ncxyz())); // dv
83+
trans_dipole *= static_cast<double>(this->nk); // nk is divided inside DM_trans, now recover it
8384
Parallel_Reduce::reduce_all(trans_dipole.x);
8485
Parallel_Reduce::reduce_all(trans_dipole.y);
8586
Parallel_Reduce::reduce_all(trans_dipole.z);
@@ -132,6 +133,7 @@ ModuleBase::Vector3<std::complex<double>> LR::LR_Spectrum<std::complex<double>>:
132133
LR_Util::_deallocate_2order_nested_ptr(rho_trans_imag, 1);
133134
}
134135
trans_dipole *= (ucell.omega / static_cast<double>(gint->get_ncxyz())); // dv
136+
trans_dipole *= static_cast<double>(this->nk); // nk is divided inside DM_trans, now recover it
135137
Parallel_Reduce::reduce_all(trans_dipole.x);
136138
Parallel_Reduce::reduce_all(trans_dipole.y);
137139
Parallel_Reduce::reduce_all(trans_dipole.z);
@@ -192,7 +194,7 @@ void LR::LR_Spectrum<T>::optical_absorption_method1(const std::vector<double>& f
192194
std::ofstream ofs(PARAM.globalv.global_out_dir + "absorption_" + spintype + ".dat");
193195
if (GlobalV::MY_RANK == 0) { ofs << "Frequency (eV) | wave length(nm) | Absorption (a.u.)" << std::endl; }
194196
double FourPI_div_c = ModuleBase::FOUR_PI / 137.036;
195-
double fac = 4 * M_PI / ucell.omega * ModuleBase::e2; // e2 for Ry to Hartree in the denominator
197+
double fac = 4 * M_PI / ucell.omega * ModuleBase::e2 / this->nk; // e2 for Ry to Hartree in the denominator
196198
for (int f = 0;f < freq.size();++f)
197199
{
198200
std::complex<double> f_complex = std::complex<double>(freq[f], eta);

source/module_lr/lr_spectrum_velocity.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ namespace LR
5555
{
5656
trans_dipole[i] += LR_Util::dot_R_matrix(*vR.get_current_term_pointer(i), *DM_trans.get_DMR_pointer(is + 1), ucell.nat) * fac;
5757
} // end for spin_x, only matter in open-shell system
58+
trans_dipole[i] *= static_cast<double>(this->nk); // nk is divided inside DM_trans, now recover it
59+
Parallel_Reduce::reduce_all(trans_dipole[i]);
5860
} // end for direction
5961
return convert_vector_to_vector3<T>(trans_dipole);
6062
}
@@ -79,6 +81,7 @@ namespace LR
7981
trans_dipole[i] += std::inner_product(vk.begin(), vk.end(), DM_trans.get_DMK_pointer(is * nk + ik), std::complex<double>(0., 0.)) * fac;
8082
}
8183
} // end for spin_x, only matter in open-shell system
84+
trans_dipole[i] *= static_cast<double>(this->nk); // nk is divided inside DM_trans, now recover it
8285
Parallel_Reduce::reduce_all(trans_dipole[i]);
8386
} // end for direction
8487
return convert_vector_to_vector3<T>(trans_dipole);
@@ -104,7 +107,7 @@ namespace LR
104107
// 4*pi^2/V * mean_squared_dipole *delta(w-Omega_S)
105108
std::ofstream ofs(PARAM.globalv.global_out_dir + "absorption_" + spintype + ".dat");
106109
if (GlobalV::MY_RANK == 0) { ofs << "Frequency (eV) | wave length(nm) | Absorption (a.u.)" << std::endl; }
107-
const double fac = 4 * M_PI * M_PI / ucell.omega * ModuleBase::e2; // e2: Ry to Hartree in the denominator
110+
const double fac = 4 * M_PI * M_PI / ucell.omega * ModuleBase::e2 / this->nk; // e2: Ry to Hartree in the denominator
108111
for (int f = 0;f < freq.size();++f)
109112
{
110113
double abs_value = 0.0;

0 commit comments

Comments
 (0)