(git:d749a20)
Loading...
Searching...
No Matches
fist_environment.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief initialize fist environment
10!> \author CJM
11! **************************************************************************************************
15 USE bibliography, ONLY: devynck2012,&
16 dick1958,&
18 cite_reference
19 USE cell_types, ONLY: cell_type
49 USE header, ONLY: fist_header
66#include "./base/base_uses.f90"
67
68 IMPLICIT NONE
69
70 PRIVATE
71
72 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'fist_environment'
73 PUBLIC :: fist_init
74
75CONTAINS
76! **************************************************************************************************
77!> \brief reads the input and database file for fist
78!> \param fist_env ...
79!> \param root_section ...
80!> \param para_env ...
81!> \param force_env_section ...
82!> \param subsys_section ...
83!> \param use_motion_section ...
84!> \param prev_subsys ...
85!> \par Used By
86!> fist_main
87! **************************************************************************************************
88 SUBROUTINE fist_init(fist_env, root_section, para_env, force_env_section, &
89 subsys_section, use_motion_section, prev_subsys)
90
91 TYPE(fist_environment_type), POINTER :: fist_env
92 TYPE(section_vals_type), POINTER :: root_section
93 TYPE(mp_para_env_type), POINTER :: para_env
94 TYPE(section_vals_type), POINTER :: force_env_section, subsys_section
95 LOGICAL, INTENT(IN) :: use_motion_section
96 TYPE(cp_subsys_type), OPTIONAL, POINTER :: prev_subsys
97
98 CHARACTER(len=*), PARAMETER :: routinen = 'fist_init'
99
100 INTEGER :: handle, iw
101 LOGICAL :: qmmm, shell_adiabatic, shell_present
102 TYPE(cp_logger_type), POINTER :: logger
103 TYPE(cp_subsys_type), POINTER :: subsys
104 TYPE(ewald_environment_type), POINTER :: ewald_env
105 TYPE(exclusion_type), DIMENSION(:), POINTER :: exclusions
106 TYPE(fist_efield_type), POINTER :: efield
107 TYPE(fist_nonbond_env_type), POINTER :: fist_nonbond_env
108 TYPE(particle_list_type), POINTER :: core_particles, shell_particles
109 TYPE(particle_type), DIMENSION(:), POINTER :: core_particle_set, shell_particle_set
110 TYPE(qmmm_env_mm_type), POINTER :: qmmm_env
111 TYPE(section_vals_type), POINTER :: ewald_section, mm_section, &
112 poisson_section
113
114 CALL timeset(routinen, handle)
115 logger => cp_get_default_logger()
116
117 NULLIFY (ewald_env, fist_nonbond_env, qmmm_env, subsys, &
118 poisson_section, shell_particle_set, shell_particles, &
119 core_particle_set, core_particles, exclusions)
120 IF (.NOT. ASSOCIATED(subsys_section)) THEN
121 subsys_section => section_vals_get_subs_vals(force_env_section, "SUBSYS")
122 END IF
123 mm_section => section_vals_get_subs_vals(force_env_section, "MM")
124 poisson_section => section_vals_get_subs_vals(mm_section, "POISSON")
125 ewald_section => section_vals_get_subs_vals(poisson_section, "EWALD")
126
127 CALL fist_env_set(fist_env, input=force_env_section)
128
129 iw = cp_print_key_unit_nr(logger, mm_section, "PRINT%PROGRAM_BANNER", &
130 extension=".mmLog")
131 CALL fist_header(iw)
132 CALL cp_print_key_finished_output(iw, logger, mm_section, "PRINT%PROGRAM_BANNER")
133
134 ! Create the ewald environment
135 ALLOCATE (ewald_env)
136 CALL ewald_env_create(ewald_env, para_env)
137
138 ! Read the input section and set the ewald_env
139 CALL read_ewald_section(ewald_env, ewald_section)
140 CALL ewald_env_set(ewald_env, poisson_section=poisson_section)
141
142 ! Read the efield section
143 NULLIFY (efield)
144 CALL read_efield_section(mm_section, efield)
145 CALL fist_env_set(fist_env, efield=efield)
146
147 ! Topology
148 CALL fist_env_get(fist_env, qmmm=qmmm, qmmm_env=qmmm_env)
149 CALL cp_subsys_create(subsys, para_env=para_env, root_section=root_section, &
150 force_env_section=force_env_section, subsys_section=subsys_section, &
151 qmmm=qmmm, qmmm_env=qmmm_env, exclusions=exclusions, &
152 use_motion_section=use_motion_section)
153 CALL fist_env_set(fist_env, subsys=subsys, exclusions=exclusions)
154
155 CALL force_field_control(subsys%atomic_kinds%els, subsys%particles%els, &
156 subsys%molecule_kinds%els, subsys%molecules%els, &
157 ewald_env, fist_nonbond_env, root_section, para_env, qmmm=qmmm, &
158 qmmm_env=qmmm_env, subsys_section=subsys_section, &
159 mm_section=mm_section, shell_particle_set=shell_particle_set, &
160 core_particle_set=core_particle_set, cell=subsys%cell)
161
162 NULLIFY (shell_particles, core_particles)
163 IF (ASSOCIATED(shell_particle_set)) THEN
164 CALL cite_reference(devynck2012)
165 CALL cite_reference(mitchell1993)
166 CALL cite_reference(dick1958)
167 CALL particle_list_create(shell_particles, els_ptr=shell_particle_set)
168 END IF
169 IF (ASSOCIATED(core_particle_set)) THEN
170 CALL particle_list_create(core_particles, els_ptr=core_particle_set)
171 END IF
172 CALL get_atomic_kind_set(atomic_kind_set=subsys%atomic_kinds%els, &
173 shell_present=shell_present, shell_adiabatic=shell_adiabatic)
174 CALL fist_env_set(fist_env, shell_model=shell_present, &
175 shell_model_ad=shell_adiabatic)
176 CALL cp_subsys_set(subsys, shell_particles=shell_particles, &
177 core_particles=core_particles)
178 CALL particle_list_release(shell_particles)
179 CALL particle_list_release(core_particles)
180
181 CALL fist_init_subsys(fist_env, subsys, fist_nonbond_env, ewald_env, &
182 force_env_section, subsys_section, prev_subsys)
183
184 CALL timestop(handle)
185
186 END SUBROUTINE fist_init
187
188! **************************************************************************************************
189!> \brief Read the input and the database files for the setup of the
190!> FIST environment.
191!> \param fist_env ...
192!> \param subsys ...
193!> \param fist_nonbond_env ...
194!> \param ewald_env ...
195!> \param force_env_section ...
196!> \param subsys_section ...
197!> \param prev_subsys ...
198!> \date 22.05.2000
199!> \author MK
200!> \version 1.0
201! **************************************************************************************************
202 SUBROUTINE fist_init_subsys(fist_env, subsys, fist_nonbond_env, &
203 ewald_env, force_env_section, subsys_section, &
204 prev_subsys)
205
206 TYPE(fist_environment_type), POINTER :: fist_env
207 TYPE(cp_subsys_type), POINTER :: subsys
208 TYPE(fist_nonbond_env_type), POINTER :: fist_nonbond_env
209 TYPE(ewald_environment_type), POINTER :: ewald_env
210 TYPE(section_vals_type), POINTER :: force_env_section, subsys_section
211 TYPE(cp_subsys_type), OPTIONAL, POINTER :: prev_subsys
212
213 CHARACTER(len=*), PARAMETER :: routinen = 'fist_init_subsys'
214
215 INTEGER :: handle, max_multipole
216 LOGICAL :: do_multipoles
217 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
218 TYPE(cell_type), POINTER :: my_cell, my_cell_ref
219 TYPE(distribution_1d_type), POINTER :: local_molecules, local_particles, &
220 prev_local_molecules
221 TYPE(ewald_pw_type), POINTER :: ewald_pw
222 TYPE(fist_energy_type), POINTER :: thermo
223 TYPE(molecule_kind_type), DIMENSION(:), POINTER :: molecule_kind_set, prev_molecule_kind_set
224 TYPE(molecule_type), DIMENSION(:), POINTER :: molecule_set
225 TYPE(multipole_type), POINTER :: multipoles
226 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
227 TYPE(section_vals_type), POINTER :: grid_print_section
228
229 CALL timeset(routinen, handle)
230 NULLIFY (thermo, ewald_pw, local_molecules, local_particles, &
231 multipoles, my_cell, my_cell_ref)
232 particle_set => subsys%particles%els
233 atomic_kind_set => subsys%atomic_kinds%els
234 molecule_set => subsys%molecules%els
235 molecule_kind_set => subsys%molecule_kinds%els
236 my_cell => subsys%cell
237 my_cell_ref => subsys%cell_ref
238
239 IF (PRESENT(prev_subsys)) THEN
240 prev_molecule_kind_set => prev_subsys%molecule_kinds%els
241 prev_local_molecules => prev_subsys%local_molecules
242 ELSE
243 NULLIFY (prev_molecule_kind_set)
244 NULLIFY (prev_local_molecules)
245 END IF
246
247 ! Create the fist_energy_type
248 CALL allocate_fist_energy(thermo)
249
250 ! Print the molecule kind set
251 CALL write_molecule_kind_set(molecule_kind_set, subsys_section)
252
253 ! Print the atomic coordinates
254 CALL write_fist_particle_coordinates(particle_set, subsys_section, &
255 fist_nonbond_env%charges)
256 CALL write_particle_distances(particle_set, my_cell, subsys_section)
257 CALL write_structure_data(particle_set, cell=my_cell, input_section=subsys_section)
258
259 ! Print symmetry information
260 CALL write_symmetry(particle_set, my_cell, subsys_section)
261
262 ! Distribute molecules and atoms using the new data structures ***
263 CALL distribute_molecules_1d(atomic_kind_set=atomic_kind_set, &
264 particle_set=particle_set, &
265 local_particles=local_particles, &
266 molecule_kind_set=molecule_kind_set, &
267 molecule_set=molecule_set, &
268 local_molecules=local_molecules, &
269 prev_molecule_kind_set=prev_molecule_kind_set, &
270 prev_local_molecules=prev_local_molecules, &
271 force_env_section=force_env_section)
272
273 ! Create ewald grids
274 grid_print_section => section_vals_get_subs_vals(force_env_section, &
275 "PRINT%GRID_INFORMATION")
276 ALLOCATE (ewald_pw)
277 CALL ewald_pw_create(ewald_pw, ewald_env, my_cell, my_cell_ref, grid_print_section)
278
279 ! Initialize ewald grids
280 CALL ewald_pw_grid_update(ewald_pw, ewald_env, my_cell%hmat)
281
282 ! Possibly Initialize the multipole environment
283 CALL ewald_env_get(ewald_env, do_multipoles=do_multipoles, &
284 max_multipole=max_multipole)
285 IF (do_multipoles) THEN
286 ALLOCATE (multipoles)
287 CALL create_multipole_type(multipoles, particle_set, subsys_section, max_multipole)
288 END IF
289 CALL cp_subsys_set(subsys, multipoles=multipoles)
290
291 ! Set the fist_env
292 CALL fist_env_set(fist_env=fist_env, &
293 cell_ref=my_cell_ref, &
294 local_molecules=local_molecules, &
295 local_particles=local_particles, &
296 ewald_env=ewald_env, ewald_pw=ewald_pw, &
297 fist_nonbond_env=fist_nonbond_env, &
298 thermo=thermo)
299
300 CALL distribution_1d_release(local_particles)
301 CALL distribution_1d_release(local_molecules)
302 CALL timestop(handle)
303
304 END SUBROUTINE fist_init_subsys
305END MODULE fist_environment
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind_set(atomic_kind_set, atom_of_kind, kind_of, natom_of_kind, maxatom, natom, nshell, fist_potential_present, shell_present, shell_adiabatic, shell_check_distance, damping_present)
Get attributes of an atomic kind set.
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public dick1958
integer, save, public devynck2012
integer, save, public mitchell1993
Handles all functions related to the CELL.
Definition cell_types.F:15
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
Initialize a small environment for a particular calculation.
subroutine, public cp_subsys_create(subsys, para_env, root_section, force_env_section, subsys_section, use_motion_section, qmmm, qmmm_env, exclusions, elkind)
Creates allocates and fills subsys from given input.
types that represent a subsys, i.e. a part of the system
subroutine, public cp_subsys_set(subsys, atomic_kinds, particles, local_particles, molecules, molecule_kinds, local_molecules, para_env, colvar_p, shell_particles, core_particles, gci, multipoles, results, cell, cell_ref, use_ref_cell)
sets various propreties of the subsys
Work with symmetry.
Definition cp_symmetry.F:13
subroutine, public write_symmetry(particle_set, cell, input_section)
Write symmetry information to output.
Definition cp_symmetry.F:61
stores a lists of integer that are local to a processor. The idea is that these integers represent ob...
subroutine, public distribution_1d_release(distribution_1d)
releases the given distribution_1d
Distribution methods for atoms, particles, or molecules.
subroutine, public distribute_molecules_1d(atomic_kind_set, particle_set, local_particles, molecule_kind_set, molecule_set, local_molecules, force_env_section, prev_molecule_kind_set, prev_local_molecules)
Distribute molecules and particles.
subroutine, public ewald_env_set(ewald_env, ewald_type, alpha, epsilon, eps_pol, gmax, ns_max, precs, o_spline, para_env, poisson_section, interaction_cutoffs, cell_hmat)
Purpose: Set the EWALD environment.
subroutine, public ewald_env_create(ewald_env, para_env)
allocates and intitializes a ewald_env
subroutine, public read_ewald_section(ewald_env, ewald_section)
Purpose: read the EWALD section.
subroutine, public ewald_env_get(ewald_env, ewald_type, alpha, eps_pol, epsilon, gmax, ns_max, o_spline, group, para_env, poisson_section, precs, rcut, do_multipoles, max_multipole, do_ipol, max_ipol_iter, interaction_cutoffs, cell_hmat)
Purpose: Get the EWALD environment.
subroutine, public ewald_pw_grid_update(ewald_pw, ewald_env, cell_hmat)
Rescales pw_grids for given box, if necessary.
subroutine, public ewald_pw_create(ewald_pw, ewald_env, cell, cell_ref, print_section)
creates the structure ewald_pw_type
an exclusion type
subroutine, public read_efield_section(input_section, efield)
Read input section PERIODIC_EFIELD.
subroutine, public allocate_fist_energy(fist_energy)
Allocate and/or initialise a Fist energy data structure.
subroutine, public fist_env_get(fist_env, atomic_kind_set, particle_set, ewald_pw, local_particles, local_molecules, molecule_kind_set, molecule_set, cell, cell_ref, ewald_env, fist_nonbond_env, thermo, para_env, subsys, qmmm, qmmm_env, input, shell_model, shell_model_ad, shell_particle_set, core_particle_set, multipoles, results, exclusions, efield)
Purpose: Get the FIST environment.
subroutine, public fist_env_set(fist_env, atomic_kind_set, particle_set, ewald_pw, local_particles, local_molecules, molecule_kind_set, molecule_set, cell_ref, ewald_env, fist_nonbond_env, thermo, subsys, qmmm, qmmm_env, input, shell_model, shell_model_ad, exclusions, efield)
Set the FIST environment.
initialize fist environment
subroutine, public fist_init(fist_env, root_section, para_env, force_env_section, subsys_section, use_motion_section, prev_subsys)
reads the input and database file for fist
subroutine, public force_field_control(atomic_kind_set, particle_set, molecule_kind_set, molecule_set, ewald_env, fist_nonbond_env, root_section, para_env, qmmm, qmmm_env, subsys_section, mm_section, shell_particle_set, core_particle_set, cell)
If reading in from external file, make sure its there first
subroutine, public fist_header(iw)
...
Definition header.F:164
objects that represent the structure of input sections and the data contained in an input section
recursive type(section_vals_type) function, pointer, public section_vals_get_subs_vals(section_vals, subsection_name, i_rep_section, can_return_null)
returns the values of the requested subsection
Interface to the message passing library MPI.
Define the molecule kind structure types and the corresponding functionality.
subroutine, public write_molecule_kind_set(molecule_kind_set, subsys_section)
Write a moleculeatomic kind set data set to the output unit.
Define the data structure for the molecule information.
Multipole structure: for multipole (fixed and induced) in FF based MD.
subroutine, public create_multipole_type(multipoles, particle_set, subsys_section, max_multipole)
Create a multipole type.
represent a simple array based list of the given type
subroutine, public particle_list_create(list, els_ptr, owns_els, n_els)
creates a list
subroutine, public particle_list_release(list)
releases a list (see doc/ReferenceCounting.html)
Define methods related to particle_type.
subroutine, public write_fist_particle_coordinates(particle_set, subsys_section, charges)
Write the atomic coordinates to the output unit.
subroutine, public write_structure_data(particle_set, cell, input_section)
Write structure data requested by a separate structure data input section to the output unit....
subroutine, public write_particle_distances(particle_set, cell, subsys_section)
Write the matrix of the particle distances to the output unit.
Define the data structure for the particle information.
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
Definition cell_types.F:60
type of a logger, at the moment it contains just a print level starting at which level it should be l...
represents a system: atoms, molecules, their pos,vel,...
structure to store local (to a processor) ordered lists of integers.
A type used to store lists of exclusions and onfos.
stores all the informations relevant to an mpi environment