diff --git a/src/input_cp2k_properties_dft.F b/src/input_cp2k_properties_dft.F index 3a05994b27..29f05a5116 100644 --- a/src/input_cp2k_properties_dft.F +++ b/src/input_cp2k_properties_dft.F @@ -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", & diff --git a/src/qs_linres_module.F b/src/qs_linres_module.F index ab84afb35a..4799c7628f 100644 --- a/src/qs_linres_module.F +++ b/src/qs_linres_module.F @@ -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 @@ -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") diff --git a/tests/QS/regtest-dcdr/TEST_FILES b/tests/QS/regtest-dcdr/TEST_FILES index c1b3425c51..2a4dce42b4 100644 --- a/tests/QS/regtest-dcdr/TEST_FILES +++ b/tests/QS/regtest-dcdr/TEST_FILES @@ -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 diff --git a/tests/QS/regtest-dcdr/h2o_apt_dyn.inp b/tests/QS/regtest-dcdr/h2o_apt_dyn.inp new file mode 100644 index 0000000000..32505bd875 --- /dev/null +++ b/tests/QS/regtest-dcdr/h2o_apt_dyn.inp @@ -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