add INTENSITIES_FILE_NAME keyword for periodic efield

This commit is contained in:
Leo Decking 2025-03-20 02:00:53 +01:00 committed by Frederick Stein
parent 4136e1a5fc
commit 44a22cd429
5 changed files with 143 additions and 7 deletions

View file

@ -25,6 +25,11 @@ MODULE cp_control_utils
cp_logger_type
USE cp_output_handling, ONLY: cp_print_key_finished_output,&
cp_print_key_unit_nr
USE cp_parser_methods, ONLY: parser_read_line
USE cp_parser_types, ONLY: cp_parser_type,&
parser_create,&
parser_release,&
parser_reset
USE cp_units, ONLY: cp_unit_from_cp2k,&
cp_unit_to_cp2k
USE eeq_input, ONLY: read_eeq_param
@ -102,18 +107,21 @@ CONTAINS
TYPE(dft_control_type), POINTER :: dft_control
TYPE(section_vals_type), POINTER :: dft_section
CHARACTER(len=default_path_length) :: basis_set_file_name, potential_file_name
CHARACTER(len=default_path_length) :: basis_set_file_name, &
intensities_file_name, &
potential_file_name
CHARACTER(LEN=default_string_length), &
DIMENSION(:), POINTER :: tmpstringlist
INTEGER :: admmtype, irep, isize, method_id, nrep, &
xc_deriv_method_id
LOGICAL :: do_hfx, do_ot, do_rpa_admm, do_rtp, &
exopt1, exopt2, exopt3, explicit, &
is_present, l_param, not_SE, &
LOGICAL :: at_end, do_hfx, do_ot, do_rpa_admm, &
do_rtp, exopt1, exopt2, exopt3, &
explicit, is_present, l_param, not_SE, &
was_present
REAL(KIND=dp) :: density_cut, gradient_cut, tau_cut
REAL(KIND=dp), DIMENSION(:), POINTER :: pol
TYPE(cp_logger_type), POINTER :: logger
TYPE(cp_parser_type) :: parser
TYPE(section_vals_type), POINTER :: hfx_section, maxwell_section, &
sccs_section, scf_section, &
tmp_section, xc_fun_section, xc_section
@ -507,16 +515,50 @@ CONTAINS
CALL section_vals_val_get(tmp_section, "INTENSITY_LIST", r_vals=pol)
CALL section_vals_val_get(tmp_section, "INTENSITIES_FILE_NAME", c_val=intensities_file_name)
IF (SIZE(pol) > 1 .OR. pol(1) /= 0.0_dp) THEN
! if INTENSITY_LIST is present, INTENSITY must not be present
IF (dft_control%period_efield%strength /= 0.0_dp) THEN
CPABORT("[PERIODIC FIELD] Only one of INTENSITY or INTENSITY_LIST can be specified.")
! if INTENSITY_LIST is present, INTENSITY and INTENSITIES_FILE_NAME must not be present
IF (dft_control%period_efield%strength /= 0.0_dp .OR. intensities_file_name /= "") THEN
CALL cp_abort(__LOCATION__, "[PERIODIC FIELD] Only one of INTENSITY, INTENSITY_LIST "// &
"or INTENSITIES_FILE_NAME can be specified.")
END IF
ALLOCATE (dft_control%period_efield%strength_list(SIZE(pol)))
dft_control%period_efield%strength_list(1:SIZE(pol)) = pol(1:SIZE(pol))
END IF
IF (intensities_file_name /= "") THEN
! if INTENSITIES_FILE_NAME is present, INTENSITY must not be present
IF (dft_control%period_efield%strength /= 0.0_dp) THEN
CALL cp_abort(__LOCATION__, "[PERIODIC FIELD] Only one of INTENSITY, INTENSITY_LIST "// &
"or INTENSITIES_FILE_NAME can be specified.")
END IF
CALL parser_create(parser, intensities_file_name)
nrep = 0
DO WHILE (.TRUE.)
CALL parser_read_line(parser, 1, at_end)
IF (at_end) EXIT
nrep = nrep + 1
END DO
IF (nrep == 0) THEN
CPABORT("[PERIODIC FIELD] No intensities found in INTENSITIES_FILE_NAME")
END IF
ALLOCATE (dft_control%period_efield%strength_list(nrep))
CALL parser_reset(parser)
DO irep = 1, nrep
CALL parser_read_line(parser, 1)
READ (parser%input_line, *) dft_control%period_efield%strength_list(irep)
END DO
CALL parser_release(parser)
END IF
CALL section_vals_val_get(tmp_section, "START_FRAME", &
i_val=dft_control%period_efield%start_frame)
CALL section_vals_val_get(tmp_section, "END_FRAME", &

View file

@ -107,6 +107,17 @@ CONTAINS
CALL section_add_keyword(section, keyword)
CALL keyword_release(keyword)
CALL keyword_create(keyword, __LOCATION__, name="INTENSITIES_FILE_NAME", &
description="File containting a list of intensities, "// &
"one per line, in a.u. "// &
"They are applied sequentially, one per frame. "// &
"If the number of frames exceeds the number of values, "// &
"the list is cyclically repeated. Attention: not implemented for eeq.", &
usage="INTENSITIES_FILE_NAME filename", &
default_lc_val="")
CALL section_add_keyword(section, keyword)
CALL keyword_release(keyword)
CALL keyword_create(keyword, __LOCATION__, name="START_FRAME", &
description="First frame the field is applied. "// &
"(0: first frame) "// &

View file

@ -0,0 +1,12 @@
0.0002
0.0005
0.001
0.0005
0.0002
0.0
-0.0002
-0.0005
-0.001
-0.0005
-0.0002
0.00

View file

@ -0,0 +1,70 @@
&GLOBAL
PRINT_LEVEL MEDIUM
PROJECT H2O-field-list
RUN_TYPE MD
&END GLOBAL
&MOTION
&MD
ENSEMBLE NVE
STEPS 32
TEMPERATURE 298
TIMESTEP 0.4
&END MD
&END MOTION
&FORCE_EVAL
METHOD Quickstep
&DFT
BASIS_SET_FILE_NAME GTH_BASIS_SETS
POTENTIAL_FILE_NAME POTENTIAL
&MGRID
CUTOFF 200
&END MGRID
&PERIODIC_EFIELD
END_FRAME 27
INTENSITIES_FILE_NAME H2O-field-file-list.data
POLARISATION 1 0 0
START_FRAME 4
&END PERIODIC_EFIELD
&PRINT
&MOMENTS
&END MOMENTS
&END PRINT
&QS
EPS_DEFAULT 1.0E-12
EXTRAPOLATION PS
EXTRAPOLATION_ORDER 2
&END QS
&SCF
EPS_SCF 1.0E-6
IGNORE_CONVERGENCE_FAILURE
MAX_SCF 6
SCF_GUESS ATOMIC
&OT
&END OT
&END SCF
&XC
&XC_FUNCTIONAL PADE
&END XC_FUNCTIONAL
&END XC
&END DFT
&SUBSYS
&CELL
ABC 6.0 6.0 6.0
&END CELL
&COORD
O 0.000000 0.000000 -0.065587 H2O
H 0.000000 -0.757136 0.520545 H2O
H 0.000000 0.757136 0.520545 H2O
&END COORD
&KIND H
BASIS_SET DZVP-GTH
POTENTIAL GTH-BLYP-q1
&END KIND
&KIND O
BASIS_SET DZVP-GTH
POTENTIAL GTH-BLYP-q6
&END KIND
&END SUBSYS
&END FORCE_EVAL

View file

@ -9,6 +9,7 @@
"H2O-field.inp" = [{matcher="E_total", tol=4e-13, ref=-15.90320150373305}]
"H2O-field-lsd.inp" = [{matcher="E_total", tol=4e-14, ref=-15.92914916395207}]
"H2O-field-list.inp" = [{matcher="M002", tol=1e-14, ref=-0.171095788220e+02}]
"H2O-field-file.inp" = [{matcher="M002", tol=1e-14, ref=-0.171095788220e+02}]
"HF-field.inp" = [{matcher="E_total", tol=1e-12, ref=-24.70767796237102}]
"HF-field-gopt.inp" = [{matcher="E_total", tol=1e-12, ref=-24.70292863028889}]
"HF-field-debug.inp" = []