Skip to content

Commit

Permalink
add integrate test
Browse files Browse the repository at this point in the history
  • Loading branch information
maki49 committed Jul 11, 2024
1 parent f01731f commit 02a20e8
Show file tree
Hide file tree
Showing 13 changed files with 154 additions and 4 deletions.
2 changes: 1 addition & 1 deletion source/module_lr/lr_spectrum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void LR::LR_Spectrum<T>::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;
Expand Down
37 changes: 37 additions & 0 deletions tests/integrate/291_NO_KP_LR/INPUT
Original file line number Diff line number Diff line change
@@ -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

4 changes: 4 additions & 0 deletions tests/integrate/291_NO_KP_LR/KPT
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
K_POINTS
0
Gamma
2 3 1 0 0 0
22 changes: 22 additions & 0 deletions tests/integrate/291_NO_KP_LR/STRU
Original file line number Diff line number Diff line change
@@ -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

1 change: 1 addition & 0 deletions tests/integrate/291_NO_KP_LR/jd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test for linear response TDDFT with multiple k-points
2 changes: 2 additions & 0 deletions tests/integrate/291_NO_KP_LR/result.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
totexcitationenergyref 0.391462
totaltimeref
38 changes: 38 additions & 0 deletions tests/integrate/391_NO_GO_LR/INPUT
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions tests/integrate/391_NO_GO_LR/STRU
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions tests/integrate/391_NO_GO_LR/jd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test for linear response TDDFT with gamma-only
2 changes: 2 additions & 0 deletions tests/integrate/391_NO_GO_LR/result.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
totexcitationenergyref 1.313946
totaltimeref
2 changes: 2 additions & 0 deletions tests/integrate/CASES_CPU.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion tests/integrate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 13 additions & 2 deletions tests/integrate/tools/catch_properties.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,19 @@ 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"
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}'`
Expand Down Expand Up @@ -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

0 comments on commit 02a20e8

Please sign in to comment.