@@ -148,7 +148,8 @@ template<> double LR::LR_Spectrum<double>::cal_mean_squared_dipole(ModuleBase::V
148148}
149149template <> double LR::LR_Spectrum<std::complex <double >>::cal_mean_squared_dipole(ModuleBase::Vector3<std::complex <double >> dipole)
150150{
151- return dipole.norm2 ().real () / 3 .;
151+ // return dipole.norm2().real() / 3.; // ModuleBase::Vector3::norm2 calculates x*x + y*y + z*z, but here we need x*x.conj() + y*y.conj() + z*z.conj()
152+ return (std::norm (dipole.x ) + std::norm (dipole.y ) + std::norm (dipole.z )) / 3 .;
152153}
153154
154155template <typename T>
@@ -217,12 +218,12 @@ void LR::LR_Spectrum<T>::transition_analysis(const std::string& spintype)
217218 ofs << std::setw (40 ) << spintype << std::endl;
218219 ofs << " ==================================================================== " << std::endl;
219220 ofs << std::setw (8 ) << " State" << std::setw (30 ) << " Excitation Energy (Ry, eV)" <<
220- std::setw (45 ) << " Transition dipole x, y, z (a.u.)" << std::setw (30 ) << " Oscillator strength(a.u.)" << std::endl;
221+ std::setw (90 ) << " Transition dipole x, y, z (a.u.)" << std::setw (30 ) << " Oscillator strength(a.u.)" << std::endl;
221222 ofs << " ------------------------------------------------------------------------------------ " << std::endl;
222223 for (int istate = 0 ;istate < nstate;++istate)
223224 ofs << std::setw (8 ) << istate << std::setw (15 ) << std::setprecision (6 ) << eig[istate] << std::setw (15 ) << eig[istate] * ModuleBase::Ry_to_eV
224- << std::setw (15 ) << transition_dipole_[istate].x << std::setw (15 ) << transition_dipole_[istate].y << std::setw (15 ) << transition_dipole_[istate].z
225- << std::setw (30 ) << oscillator_strength_[istate] << std::endl;
225+ << std::setprecision ( 4 ) << std:: setw (30 ) << transition_dipole_[istate].x << std::setw (30 ) << transition_dipole_[istate].y << std::setw (30 ) << transition_dipole_[istate].z
226+ << std::setprecision ( 6 ) << std:: setw (30 ) << oscillator_strength_[istate] << std::endl;
226227 ofs << " ------------------------------------------------------------------------------------ " << std::endl;
227228 ofs << std::setw (8 ) << " State" << std::setw (20 ) << " Occupied orbital"
228229 << std::setw (20 ) << " Virtual orbital" << std::setw (30 ) << " Excitation amplitude"
0 commit comments