@@ -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
179181template <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
0 commit comments