Skip to content

Commit 68e924a

Browse files
committed
fix the spectra strength of singlet
1 parent 54f55fa commit 68e924a

File tree

4 files changed

+21
-14
lines changed

4 files changed

+21
-14
lines changed

source/module_lr/esolver_lrtd_lcao.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -564,12 +564,15 @@ void LR::ESolver_LR<T, TR>::after_all_runners(UnitCell& ucell)
564564
&this->pelec->ekb.c[is * nstates], this->X[is].template data<T>(), nstates, openshell,
565565
LR_Util::tolower(input.abs_gauge));
566566
spectrum.transition_analysis(spin_types[is]);
567-
spectrum.optical_absorption_method1(freq, input.abs_broadening, spin_types[is]);
568-
// =============================================== for test ====================================================
569-
// spectrum.optical_absorption_method2(freq, input.abs_broadening, spin_types[is]);
570-
// spectrum.test_transition_dipoles_velocity_ks(eig_ks.c);
571-
// spectrum.write_transition_dipole(PARAM.globalv.global_out_dir + "dipole_velocity_ks_" + spin_types[is] + ".dat");
572-
// =============================================== for test ====================================================
567+
if (spin_types[is] != "triplet") // triplets has no transition dipole and no contribution to the spectrum
568+
{
569+
spectrum.optical_absorption_method1(freq, input.abs_broadening);
570+
// =============================================== for test ====================================================
571+
// spectrum.optical_absorption_method2(freq, input.abs_broadening, spin_types[is]);
572+
// spectrum.test_transition_dipoles_velocity_ks(eig_ks.c);
573+
// spectrum.write_transition_dipole(PARAM.globalv.global_out_dir + "dipole_velocity_ks.dat");
574+
// =============================================== for test ====================================================
575+
}
573576
}
574577
}
575578

source/module_lr/lr_spectrum.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ ModuleBase::Vector3<double> LR::LR_Spectrum<double>::cal_transition_dipole_istat
8181
}
8282
trans_dipole *= (ucell.omega / static_cast<double>(gint->get_ncxyz())); // dv
8383
trans_dipole *= static_cast<double>(this->nk); // nk is divided inside DM_trans, now recover it
84+
if (this->nspin_x == 1) { trans_dipole *= sqrt(2.0); } // *2 for 2 spins, /sqrt(2) for the halfed dimension of X in the normalizaiton
8485
Parallel_Reduce::reduce_all(trans_dipole.x);
8586
Parallel_Reduce::reduce_all(trans_dipole.y);
8687
Parallel_Reduce::reduce_all(trans_dipole.z);
@@ -134,6 +135,7 @@ ModuleBase::Vector3<std::complex<double>> LR::LR_Spectrum<std::complex<double>>:
134135
}
135136
trans_dipole *= (ucell.omega / static_cast<double>(gint->get_ncxyz())); // dv
136137
trans_dipole *= static_cast<double>(this->nk); // nk is divided inside DM_trans, now recover it
138+
if (this->nspin_x == 1) { trans_dipole *= sqrt(2.0); } // *2 for 2 spins, /sqrt(2) for the halfed dimension of X in the normalizaiton
137139
Parallel_Reduce::reduce_all(trans_dipole.x);
138140
Parallel_Reduce::reduce_all(trans_dipole.y);
139141
Parallel_Reduce::reduce_all(trans_dipole.z);
@@ -177,21 +179,21 @@ void LR::LR_Spectrum<T>::oscillator_strength()
177179
}
178180

179181
template<typename T>
180-
void LR::LR_Spectrum<T>::optical_absorption_method1(const std::vector<double>& freq, const double eta, const std::string& spintype)
182+
void LR::LR_Spectrum<T>::optical_absorption_method1(const std::vector<double>& freq, const double eta)
181183
{
182184
// ============test dipole================
183185
// this->cal_transition_dipoles_length();
184-
// this->write_transition_dipole(PARAM.globalv.global_out_dir + "dipole_length_" + spintype + ".dat");
186+
// this->write_transition_dipole(PARAM.globalv.global_out_dir + "dipole_length.dat");
185187
// this->cal_transition_dipoles_velocity();
186-
// this->write_transition_dipole(PARAM.globalv.global_out_dir + "dipole_velocity_" + spintype + ".dat");
188+
// this->write_transition_dipole(PARAM.globalv.global_out_dir + "dipole_velocity.dat");
187189
// exit(0);
188190
// ============test dipole================
189191
ModuleBase::TITLE("LR::LR_Spectrum", "optical_absorption");
190192
// 4*pi^2/V * mean_squared_dipole *delta(w-Omega_S)
191193
// = -8*pi*Omega_S/V * mean_squared_dipole * Im[1/[(w+i\eta)^2-\Omega_S^2]]
192194
// = -4*pi/V * oscilator_strength * Im[1/[(w+i\eta)^2-\Omega_S^2]]
193195
std::vector<double>& osc = this->oscillator_strength_;
194-
std::ofstream ofs(PARAM.globalv.global_out_dir + "absorption_" + spintype + ".dat");
196+
std::ofstream ofs(PARAM.globalv.global_out_dir + "absorption.dat");
195197
if (GlobalV::MY_RANK == 0) { ofs << "Frequency (eV) | wave length(nm) | Absorption (a.u.)" << std::endl; }
196198
double FourPI_div_c = ModuleBase::FOUR_PI / 137.036;
197199
double fac = 4 * M_PI / ucell.omega * ModuleBase::e2 / this->nk; // e2 for Ry to Hartree in the denominator

source/module_lr/lr_spectrum.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ namespace LR
3232
this->oscillator_strength();
3333
};
3434
/// @brief calculate the optical absorption spectrum with $Im[1/[(w+i\eta)^2-\Omega_S^2]]$
35-
void optical_absorption_method1(const std::vector<double>& freq, const double eta, const std::string& spintype);
35+
void optical_absorption_method1(const std::vector<double>& freq, const double eta);
3636
/// @brief calculate the optical absorption spectrum with lorentzian delta function
37-
void optical_absorption_method2(const std::vector<double>& freq, const double eta, const std::string& spintype);
37+
void optical_absorption_method2(const std::vector<double>& freq, const double eta);
3838
/// @brief print out the transition dipole moment and the main contributions to the transition amplitude
3939
void transition_analysis(const std::string& spintype);
4040

source/module_lr/lr_spectrum_velocity.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ namespace LR
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
5858
trans_dipole[i] *= static_cast<double>(this->nk); // nk is divided inside DM_trans, now recover it
59+
if (this->nspin_x == 1) { trans_dipole[i] *= sqrt(2.0); } // *2 for 2 spins, /sqrt(2) for the halfed dimension of X in the normalizaiton
5960
Parallel_Reduce::reduce_all(trans_dipole[i]);
6061
} // end for direction
6162
return convert_vector_to_vector3<T>(trans_dipole);
@@ -82,6 +83,7 @@ namespace LR
8283
}
8384
} // end for spin_x, only matter in open-shell system
8485
trans_dipole[i] *= static_cast<double>(this->nk); // nk is divided inside DM_trans, now recover it
86+
if (this->nspin_x == 1) { trans_dipole[i] *= sqrt(2.0); } // *2 for 2 spins, /sqrt(2) for the halfed dimension of X in the normalizaiton
8587
Parallel_Reduce::reduce_all(trans_dipole[i]);
8688
} // end for direction
8789
return convert_vector_to_vector3<T>(trans_dipole);
@@ -101,11 +103,11 @@ namespace LR
101103
}
102104

103105
template<typename T>
104-
void LR::LR_Spectrum<T>::optical_absorption_method2(const std::vector<double>& freq, const double eta, const std::string& spintype)
106+
void LR::LR_Spectrum<T>::optical_absorption_method2(const std::vector<double>& freq, const double eta)
105107
{
106108
ModuleBase::TITLE("LR::LR_Spectrum", "optical_absorption_velocity");
107109
// 4*pi^2/V * mean_squared_dipole *delta(w-Omega_S)
108-
std::ofstream ofs(PARAM.globalv.global_out_dir + "absorption_" + spintype + ".dat");
110+
std::ofstream ofs(PARAM.globalv.global_out_dir + "absorption.dat");
109111
if (GlobalV::MY_RANK == 0) { ofs << "Frequency (eV) | wave length(nm) | Absorption (a.u.)" << std::endl; }
110112
const double fac = 4 * M_PI * M_PI / ucell.omega * ModuleBase::e2 / this->nk; // e2: Ry to Hartree in the denominator
111113
for (int f = 0;f < freq.size();++f)

0 commit comments

Comments
 (0)