Skip to content

Commit

Permalink
EVERY_N_STEP keyword for linear response calculations (cp2k#3692)
Browse files Browse the repository at this point in the history
  • Loading branch information
rangsimanketkaew authored Sep 24, 2024
1 parent 3f890bb commit 3de98e9
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/input_cp2k_properties_dft.F
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,12 @@ SUBROUTINE create_linres_section(section, create_subsections, default_set_tdlr)
CALL section_add_keyword(section, keyword)
CALL keyword_release(keyword)

CALL keyword_create(keyword, __LOCATION__, name="EVERY_N_STEP", &
description="Perform a linear response calculation every N-th step for MD run", &
usage="EVERY_N_STEP 50", default_i_val=1)
CALL section_add_keyword(section, keyword)
CALL keyword_release(keyword)

CALL keyword_create(keyword, __LOCATION__, name="RESTART", &
description="Restart the response calculation if the restart file exists", &
usage="RESTART", &
Expand Down
6 changes: 4 additions & 2 deletions src/qs_linres_module.F
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ SUBROUTINE linres_calculation_low(qs_env)

CHARACTER(LEN=*), PARAMETER :: routineN = 'linres_calculation_low'

INTEGER :: handle, iounit
INTEGER :: every_n_step, handle, iounit
LOGICAL :: dcdr_present, epr_present, issc_present, &
lr_calculation, nmr_present, &
polar_present, vcd_present
Expand All @@ -381,7 +381,9 @@ SUBROUTINE linres_calculation_low(qs_env)
lr_section => section_vals_get_subs_vals(qs_env%input, "PROPERTIES%LINRES")
CALL section_vals_get(lr_section, explicit=lr_calculation)

IF (lr_calculation) THEN
CALL section_vals_val_get(lr_section, "EVERY_N_STEP", i_val=every_n_step)

IF (lr_calculation .AND. MODULO(qs_env%sim_step, every_n_step) == 0) THEN
CALL linres_init(lr_section, p_env, qs_env)
iounit = cp_print_key_unit_nr(logger, lr_section, "PRINT%PROGRAM_RUN_INFO", &
extension=".linresLog")
Expand Down
1 change: 1 addition & 0 deletions tests/QS/regtest-dcdr/TEST_FILES
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# 1 compares the last total energy in the file
# for details see cp2k/tools/do_regtest
h2o_apt.inp 96 1e-06 -0.879586
h2o_apt_dyn.inp 96 1e-06 -0.776093
h2o_apt_z-matrix.inp 96 1e-06 -0.882548
h2o_apt_uks.inp 96 1e-06 -0.879582
h2o_apt_uks_z-matrix.inp 96 1e-06 -0.882544
Expand Down
104 changes: 104 additions & 0 deletions tests/QS/regtest-dcdr/h2o_apt_dyn.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
###################################
@SET RUN_TYPE MD
@SET CUTOFF 200
@SET FUNCTIONAL LDA
@SET PRINT_LEVEL MEDIUM
@SET BASIS_SET_FILE_NAME GTH_BASIS_SETS
@SET BASIS_SET SZV-GTH
@SET EPS_SCF 1.08E-5
@SET EPS_LINRES 5.0E-5
###################################
&GLOBAL
PRINT_LEVEL $PRINT_LEVEL
PROJECT second
RUN_TYPE $RUN_TYPE
&END GLOBAL

&FORCE_EVAL
METHOD Quickstep
&DFT
BASIS_SET_FILE_NAME $BASIS_SET_FILE_NAME
CHARGE 0
POTENTIAL_FILE_NAME POTENTIAL
&MGRID
CUTOFF $CUTOFF
NGRIDS 1
&END MGRID
&POISSON
PERIODIC NONE
POISSON_SOLVER ANALYTIC
&END POISSON
&PRINT
&MOMENTS
PERIODIC FALSE
&END MOMENTS
&END PRINT
&QS
EXTRAPOLATION ASPC
EXTRAPOLATION_ORDER 3
METHOD GPW
&END QS
&SCF
EPS_SCF $EPS_SCF
SCF_GUESS ATOMIC
&OT
PRECONDITIONER FULL_SINGLE_INVERSE
&END OT
&END SCF
&XC
&XC_FUNCTIONAL $FUNCTIONAL
&END XC_FUNCTIONAL
&END XC
&END DFT
&PROPERTIES
&LINRES
EPS $EPS_LINRES
EVERY_N_STEP 2
MAX_ITER 1000
PRECONDITIONER FULL_SINGLE_INVERSE
&DCDR
&PRINT
&APT
FILENAME __STD_OUT__
&END APT
&END PRINT
&END DCDR
&PRINT
&PROGRAM_RUN_INFO
&END PROGRAM_RUN_INFO
&END PRINT
&END LINRES
&END PROPERTIES
&SUBSYS
&CELL
ABC [angstrom] 5.0 5.0 5.0
PERIODIC NONE
&END CELL
&COORD
O 0.000000 0.000000 0.000000
H 0.000000 0.769665 -0.591648
H 0.000000 -0.769665 -0.591648
&END COORD
&KIND DEFAULT
BASIS_SET $BASIS_SET
POTENTIAL GTH-$FUNCTIONAL
&END KIND
&END SUBSYS
&END FORCE_EVAL

&MOTION
&MD
ENSEMBLE NVT
STEPS 6
TEMPERATURE 300.0
TIMESTEP 0.5
&THERMOSTAT
&NOSE
LENGTH 3
MTS 2
TIMECON 100.0
YOSHIDA 3
&END NOSE
&END THERMOSTAT
&END MD
&END MOTION

0 comments on commit 3de98e9

Please sign in to comment.