From 75a547f026062e2a17ffac75450e25c0b1bf14da Mon Sep 17 00:00:00 2001 From: maki49 <1579492865@qq.com> Date: Fri, 12 Jul 2024 05:50:59 +0800 Subject: [PATCH] add integrate test --- source/module_lr/lr_spectrum.cpp | 2 +- tests/integrate/291_NO_KP_LR/INPUT | 37 ++++++++++++++++++++++ tests/integrate/291_NO_KP_LR/KPT | 4 +++ tests/integrate/291_NO_KP_LR/STRU | 22 +++++++++++++ tests/integrate/291_NO_KP_LR/jd | 1 + tests/integrate/291_NO_KP_LR/result.ref | 2 ++ tests/integrate/391_NO_GO_LR/INPUT | 38 +++++++++++++++++++++++ tests/integrate/391_NO_GO_LR/STRU | 29 +++++++++++++++++ tests/integrate/391_NO_GO_LR/jd | 1 + tests/integrate/391_NO_GO_LR/result.ref | 2 ++ tests/integrate/CASES_CPU.txt | 2 ++ tests/integrate/README.md | 3 +- tests/integrate/tools/catch_properties.sh | 15 +++++++-- 13 files changed, 154 insertions(+), 4 deletions(-) create mode 100644 tests/integrate/291_NO_KP_LR/INPUT create mode 100644 tests/integrate/291_NO_KP_LR/KPT create mode 100644 tests/integrate/291_NO_KP_LR/STRU create mode 100644 tests/integrate/291_NO_KP_LR/jd create mode 100644 tests/integrate/291_NO_KP_LR/result.ref create mode 100644 tests/integrate/391_NO_GO_LR/INPUT create mode 100644 tests/integrate/391_NO_GO_LR/STRU create mode 100644 tests/integrate/391_NO_GO_LR/jd create mode 100644 tests/integrate/391_NO_GO_LR/result.ref diff --git a/source/module_lr/lr_spectrum.cpp b/source/module_lr/lr_spectrum.cpp index f56a14807f..dc718ed5d5 100644 --- a/source/module_lr/lr_spectrum.cpp +++ b/source/module_lr/lr_spectrum.cpp @@ -187,7 +187,7 @@ void LR::LR_Spectrum::transition_analysis() std::setw(45) << "Transition dipole x, y, z (a.u.)" << std::setw(30) << "Oscillator strength(a.u.)" << std::endl; ofs << "------------------------------------------------------------------------------------ " << std::endl; for (int istate = 0;istate < X.get_nbands();++istate) - ofs << std::setw(8) << istate << std::setw(15) << std::setprecision(3) << eig[istate] << std::setw(15) << eig[istate] * ModuleBase::Ry_to_eV + ofs << std::setw(8) << istate << std::setw(15) << std::setprecision(6) << eig[istate] << std::setw(15) << eig[istate] * ModuleBase::Ry_to_eV << std::setw(15) << transition_dipole_[istate].x << std::setw(15) << transition_dipole_[istate].y << std::setw(15) << transition_dipole_[istate].z << std::setw(30) << oscillator_strength_[istate] << std::endl; ofs << "------------------------------------------------------------------------------------ " << std::endl; diff --git a/tests/integrate/291_NO_KP_LR/INPUT b/tests/integrate/291_NO_KP_LR/INPUT new file mode 100644 index 0000000000..df499ddc16 --- /dev/null +++ b/tests/integrate/291_NO_KP_LR/INPUT @@ -0,0 +1,37 @@ +INPUT_PARAMETERS +#Parameters (1.General) +suffix autotest +pseudo_dir ../../../tests/PP_ORB +orbital_dir ../../../tests/PP_ORB +calculation scf +nbands 6 +symmetry -1 + +#Parameters (2.Iteration) +ecutwfc 20 +scf_thr 1e-6 +scf_nmax 20 + +#Parameters (3.Basis) +basis_type lcao +gamma_only 0 + +#Parameters (4.Smearing) +smearing_method gaussian +smearing_sigma 0.02 + +#Parameters (5.Mixing) +mixing_type pulay +mixing_beta 0.4 + +lr_nstates 2 # for test/debug, you can try a smaller one like 2 +xc_kernel lda +lr_solver dav +lr_thr 1e-2 +pw_diag_ndim 4 + +esolver_type ks-lr + +nvirt 2 +abs_wavelen_range 100 175 + diff --git a/tests/integrate/291_NO_KP_LR/KPT b/tests/integrate/291_NO_KP_LR/KPT new file mode 100644 index 0000000000..ae9ebb2ca3 --- /dev/null +++ b/tests/integrate/291_NO_KP_LR/KPT @@ -0,0 +1,4 @@ +K_POINTS +0 +Gamma +2 3 1 0 0 0 diff --git a/tests/integrate/291_NO_KP_LR/STRU b/tests/integrate/291_NO_KP_LR/STRU new file mode 100644 index 0000000000..f44aa92934 --- /dev/null +++ b/tests/integrate/291_NO_KP_LR/STRU @@ -0,0 +1,22 @@ +ATOMIC_SPECIES +Si 1.000 Si.pz-vbc.UPF #Element, Mass, Pseudopotential + +NUMERICAL_ORBITAL +./Si_lda_8.0au_50Ry_2s2p1d + +LATTICE_CONSTANT +10.2 #Lattice constant + +LATTICE_VECTORS +0.5 0.5 0.0 #Lattice vector 1 +0.5 0.0 0.5 #Lattice vector 2 +0.0 0.5 0.5 #Lattice vector 3 + +ATOMIC_POSITIONS +Cartesian #Cartesian(Unit is LATTICE_CONSTANT) +Si #Name of element +0.0 #Magnetic for this element. +2 #Number of atoms +0.00 0.00 0.00 0 0 0 #x,y,z, move_x, move_y, move_z +0.25 0.25 0.25 1 1 1 + diff --git a/tests/integrate/291_NO_KP_LR/jd b/tests/integrate/291_NO_KP_LR/jd new file mode 100644 index 0000000000..6c1689f0ab --- /dev/null +++ b/tests/integrate/291_NO_KP_LR/jd @@ -0,0 +1 @@ +test for linear response TDDFT with multiple k-points diff --git a/tests/integrate/291_NO_KP_LR/result.ref b/tests/integrate/291_NO_KP_LR/result.ref new file mode 100644 index 0000000000..bcd8824485 --- /dev/null +++ b/tests/integrate/291_NO_KP_LR/result.ref @@ -0,0 +1,2 @@ +totexcitationenergyref 0.391462 +totaltimeref diff --git a/tests/integrate/391_NO_GO_LR/INPUT b/tests/integrate/391_NO_GO_LR/INPUT new file mode 100644 index 0000000000..62a139c69d --- /dev/null +++ b/tests/integrate/391_NO_GO_LR/INPUT @@ -0,0 +1,38 @@ +INPUT_PARAMETERS +#Parameters (1.General) +suffix autotest +pseudo_dir ../../../tests/PP_ORB +orbital_dir ../../../tests/PP_ORB +calculation scf +nbands 6 +symmetry -1 + +#Parameters (2.Iteration) +ecutwfc 10 +scf_thr 1e-3 +scf_nmax 20 + +#Parameters (3.Basis) +basis_type lcao +gamma_only 1 + +#Parameters (4.Smearing) +smearing_method gaussian +smearing_sigma 0.02 + +#Parameters (5.Mixing) +mixing_type pulay +mixing_beta 0.4 +mixing_gg0 0 + +lr_nstates 2 +xc_kernel lda +lr_solver dav +lr_thr 1e-2 +pw_diag_ndim 2 + +esolver_type ks-lr + +nvirt 2 +abs_wavelen_range 40 180 +abs_broadening 0.01 \ No newline at end of file diff --git a/tests/integrate/391_NO_GO_LR/STRU b/tests/integrate/391_NO_GO_LR/STRU new file mode 100644 index 0000000000..ceb8aaa84c --- /dev/null +++ b/tests/integrate/391_NO_GO_LR/STRU @@ -0,0 +1,29 @@ +ATOMIC_SPECIES +H 1.008 H_ONCV_PBE-1.0.upf +O 15.9994 O_ONCV_PBE-1.0.upf + +NUMERICAL_ORBITAL +H_gga_8au_60Ry_2s1p.orb +O_gga_7au_60Ry_2s2p1d.orb + + +LATTICE_CONSTANT +1 + +LATTICE_VECTORS +28 0 0 +0 28 0 +0 0 28 + +ATOMIC_POSITIONS +Cartesian + +H +0 +2 +-12.046787058887078 18.76558614676448 8.395247471328744 1 1 1 +-14.228868795885418 20.61549300274637 7.611989524516571 1 1 1 +O +0 +1 +-13.486789117423204 19.684192208418636 8.958321352749174 1 1 1 diff --git a/tests/integrate/391_NO_GO_LR/jd b/tests/integrate/391_NO_GO_LR/jd new file mode 100644 index 0000000000..59460d6983 --- /dev/null +++ b/tests/integrate/391_NO_GO_LR/jd @@ -0,0 +1 @@ +test for linear response TDDFT with gamma-only diff --git a/tests/integrate/391_NO_GO_LR/result.ref b/tests/integrate/391_NO_GO_LR/result.ref new file mode 100644 index 0000000000..e40418c026 --- /dev/null +++ b/tests/integrate/391_NO_GO_LR/result.ref @@ -0,0 +1,2 @@ +totexcitationenergyref 1.313946 +totaltimeref diff --git a/tests/integrate/CASES_CPU.txt b/tests/integrate/CASES_CPU.txt index 08e5d0fd92..a44284140f 100644 --- a/tests/integrate/CASES_CPU.txt +++ b/tests/integrate/CASES_CPU.txt @@ -200,6 +200,7 @@ #282_NO_RPA 283_NO_restart 284_NO_KP_symmetry +291_NO_KP_LR 301_NO_GO_15_CF_CS 301_NO_GO_DJ_Si #303_NO_GO_HP_15 @@ -233,6 +234,7 @@ 384_NO_GO_S1_HSE_loop0_PU 385_NO_GO_RE_S1_HSE 386_NO_GO_MD_S1_HSE +391_NO_GO_LR 401_NP_KP_sp 401_NP_KP_spd #501_NO_neighboring_GaAs512 diff --git a/tests/integrate/README.md b/tests/integrate/README.md index 9e684c6efa..3923895a65 100644 --- a/tests/integrate/README.md +++ b/tests/integrate/README.md @@ -100,7 +100,8 @@ _CR cell-relax calculation _CF calculate and output force _CS calculate and output stress _MD molecular dynamics -_TD TDDFT: time dependent DFT +_TD real time TDDFT +_LR linear response TDDFT _OH output Halmitonian matrix _OB output bands file diff --git a/tests/integrate/tools/catch_properties.sh b/tests/integrate/tools/catch_properties.sh index bd43ed9b90..321467e139 100755 --- a/tests/integrate/tools/catch_properties.sh +++ b/tests/integrate/tools/catch_properties.sh @@ -64,6 +64,7 @@ has_mat_t=$(get_input_key_value "out_mat_t" "INPUT") has_mat_dh=$(get_input_key_value "out_mat_dh" "INPUT") has_scan=$(get_input_key_value "dft_functional" "INPUT") out_chg=$(get_input_key_value "out_chg" "INPUT") +esolver_type=$(get_input_key_value "esolver_type" "INPUT") #echo $running_path base=$(get_input_key_value "basis_type" "INPUT") word="driver_line" @@ -71,10 +72,11 @@ symmetry=$(get_input_key_value "symmetry" "INPUT") out_current=$(get_input_key_value "out_current" "INPUT") test -e $1 && rm $1 #-------------------------------------------- -# if NOT non-self-consistent calculations +# if NOT non-self-consistent calculations or linear response #-------------------------------------------- if [ $calculation != "nscf" ] && [ $calculation != "get_wf" ]\ -&& [ $calculation != "get_pchg" ] && [ $calculation != "get_S" ]; then +&& [ $calculation != "get_pchg" ] && [ $calculation != "get_S" ]\ +&& [ $esolver_type != "ks-lr" ] && [ $esolver_type != "lr" ]; then #etot=`grep ETOT_ $running_path | awk '{print $2}'` etot=$(grep "ETOT_" "$running_path" | tail -1 | awk '{print $2}') etotperatom=`awk 'BEGIN {x='$etot';y='$natom';printf "%.10f\n",x/y}'` @@ -465,6 +467,15 @@ if ! test -z "$out_current" && [ $out_current ]; then echo "CompareCurrent_pass $?" >>$1 fi +if ! test -z "$esolver_type" && ([ $esolver_type == "lr" ] || [ $esolver_type == "ks-lr" ]); then + lr_path=OUT.autotest/running_lr.log + lrns=$(get_input_key_value "lr_nstates" "INPUT") + lrns1=`echo "$lrns + 1" |bc` + grep -A$lrns1 "Excitation Energy" $lr_path | tail -$lrns | awk '{print $2}' > lr_eig.txt + lreig_tot=`sum_file lr_eig.txt` + echo "totexcitationenergyref $lreig_tot" >>$1 +fi + #echo $total_band ttot=`grep $word $running_path | awk '{print $3}'` echo "totaltimeref $ttot" >>$1