(git:ed6f26b)
Loading...
Searching...
No Matches
ipi_environment_types.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2025 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief The environment for the empirical interatomic potential methods.
10!> \par History
11!> 03.2024 initial create
12!> \author Sebastian Seidenath (sebastian.seidenath@uni-jena.de)
13! **************************************************************************************************
19 USE cell_types, ONLY: cell_release,&
30 USE kinds, ONLY: dp
43 USE virial_types, ONLY: virial_type
44#include "./base/base_uses.f90"
45
46 IMPLICIT NONE
47 PRIVATE
48
49 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'ipi_environment_types'
50
51 ! *** Public data types ***
52 PUBLIC :: ipi_environment_type
53
54 ! *** Public subroutines ***
55 PUBLIC :: ipi_env_release, &
59
60! **************************************************************************************************
61!> \brief The i–PI environment
62!> \param ipi_energy The total ipi energy
63!> \param ipi_forces The final ipi forces [eV/A]
64!> \param subsystem The particles, molecules,... of this environment
65!> \param force_env_input Pointer to the force_env input section
66!> \param cell_ref The reference simulation cell
67!> \par History
68!> 03.2024 initial create
69!> \author Sebastian Seidenath (sebastian.seidenath@uni-jena.de)
70! **************************************************************************************************
72 REAL(kind=dp) :: ipi_energy = 0.0_dp
73 REAL(kind=dp), DIMENSION(:, :), POINTER :: ipi_forces => null()
74 TYPE(cp_subsys_type), POINTER :: subsys => null()
75 TYPE(section_vals_type), POINTER :: force_env_input => null()
76 TYPE(cell_type), POINTER :: cell_ref => null()
77 INTEGER :: sockfd = -1
79
80CONTAINS
81
82! **************************************************************************************************
83!> \brief Releases the given ipi environment (see doc/ReferenceCounting.html)
84!> \param ipi_env The ipi environment to release
85!> \par History
86!> 03.2024 initial create
87!> \author Sebastian Seidenath (sebastian.seidenath@uni-jena.de)
88! **************************************************************************************************
89 SUBROUTINE ipi_env_release(ipi_env)
90 TYPE(ipi_environment_type), INTENT(INOUT) :: ipi_env
91
92 IF (ASSOCIATED(ipi_env%ipi_forces)) THEN
93 DEALLOCATE (ipi_env%ipi_forces)
94 END IF
95 IF (ASSOCIATED(ipi_env%subsys)) THEN
96 CALL cp_subsys_release(ipi_env%subsys)
97 END IF
98 IF (ASSOCIATED(ipi_env%force_env_input)) THEN
99 CALL section_vals_release(ipi_env%force_env_input)
100 END IF
101 IF (ASSOCIATED(ipi_env%cell_ref)) THEN
102 CALL cell_release(ipi_env%cell_ref)
103 END IF
104 END SUBROUTINE ipi_env_release
105
106! **************************************************************************************************
107!> \brief Returns various attributes of the ipi environment
108!> \param ipi_env The enquired ipi environment
109!> \param ipi_energy The total ipi energy
110!> \param ipi_forces The final ipi forces [eV/A]
111!> \param subsys the particles, molecules,... of this environment
112!> \param atomic_kind_set The set of all atomic kinds involved
113!> \param particle_set The set of all particles
114!> \param local_particles All particles on this particular node
115!> \param molecule_kind_set The set of all different molecule kinds involved
116!> \param molecule_set The set of all molecules
117!> \param local_molecules All molecules on this particular node
118!> \param force_env_input Pointer to the force_env input section
119!> \param cell The simulation cell
120!> \param cell_ref The reference simulation cell
121!> \param virial Dummy virial pointer
122!> \param sockfd File descriptor of the communications socket
123!> \par History
124!> 03.2024 initial create
125!> \author Sebastian Seidenath (sebastian.seidenath@uni-jena.de)
126! **************************************************************************************************
127 SUBROUTINE ipi_env_get(ipi_env, ipi_energy, ipi_forces, subsys, &
128 atomic_kind_set, particle_set, local_particles, &
129 molecule_kind_set, molecule_set, local_molecules, &
130 force_env_input, cell, cell_ref, virial, sockfd)
131
132 TYPE(ipi_environment_type), INTENT(IN) :: ipi_env
133 REAL(kind=dp), OPTIONAL :: ipi_energy
134 REAL(kind=dp), DIMENSION(:, :), OPTIONAL, POINTER :: ipi_forces
135 TYPE(cp_subsys_type), OPTIONAL, POINTER :: subsys
136 TYPE(atomic_kind_type), DIMENSION(:), OPTIONAL, &
137 POINTER :: atomic_kind_set
138 TYPE(particle_type), DIMENSION(:), OPTIONAL, &
139 POINTER :: particle_set
140 TYPE(distribution_1d_type), OPTIONAL, POINTER :: local_particles
141 TYPE(molecule_kind_type), DIMENSION(:), OPTIONAL, &
142 POINTER :: molecule_kind_set
143 TYPE(molecule_type), DIMENSION(:), OPTIONAL, &
144 POINTER :: molecule_set
145 TYPE(distribution_1d_type), OPTIONAL, POINTER :: local_molecules
146 TYPE(section_vals_type), OPTIONAL, POINTER :: force_env_input
147 TYPE(cell_type), OPTIONAL, POINTER :: cell, cell_ref
148 TYPE(virial_type), OPTIONAL, POINTER :: virial
149 INTEGER, OPTIONAL :: sockfd
150
151 TYPE(atomic_kind_list_type), POINTER :: atomic_kinds
152 TYPE(molecule_kind_list_type), POINTER :: molecule_kinds
153 TYPE(molecule_list_type), POINTER :: molecules
154 TYPE(particle_list_type), POINTER :: particles
155
156 NULLIFY (atomic_kinds, particles, molecules, molecule_kinds)
157
158 IF (PRESENT(ipi_energy)) ipi_energy = ipi_env%ipi_energy
159 IF (PRESENT(ipi_forces)) ipi_forces = ipi_env%ipi_forces
160 IF (PRESENT(subsys)) subsys => ipi_env%subsys
161 CALL cp_subsys_get(ipi_env%subsys, &
162 atomic_kinds=atomic_kinds, &
163 particles=particles, &
164 molecule_kinds=molecule_kinds, &
165 molecules=molecules, &
166 local_molecules=local_molecules, &
167 local_particles=local_particles, &
168 virial=virial, &
169 cell=cell)
170 IF (PRESENT(atomic_kind_set)) atomic_kind_set => atomic_kinds%els
171 IF (PRESENT(particle_set)) particle_set => particles%els
172 IF (PRESENT(molecule_kind_set)) molecule_kind_set => molecule_kinds%els
173 IF (PRESENT(molecule_set)) molecule_set => molecules%els
174
175 IF (PRESENT(force_env_input)) force_env_input => ipi_env%force_env_input
176 IF (PRESENT(cell_ref)) cell_ref => ipi_env%cell_ref
177 IF (PRESENT(sockfd)) sockfd = ipi_env%sockfd
178
179 END SUBROUTINE ipi_env_get
180
181! **************************************************************************************************
182!> \brief Sets various attributes of the ipi environment
183!> \param ipi_env The enquired ipi environment
184!> \param ipi_energy The total ipi energy
185!> \param ipi_forces The final ipi forces [eV/A]
186!> \param subsys the particles, molecules,... of this environment
187!> \param atomic_kind_set The set of all atomic kinds involved
188!> \param particle_set The set of all particles
189!> \param local_particles All particles on this particular node
190!> \param molecule_kind_set The set of all different molecule kinds involved
191!> \param molecule_set The set of all molecules
192!> \param local_molecules All molecules on this particular node
193!> \param force_env_input Pointer to the force_env input section
194!> \param cell_ref The reference simulation cell
195!> \param sockfd File descriptor of the communications socket
196!> \par History
197!> 03.2024 initial create
198!> \author Sebastian Seidenath (sebastian.seidenath@uni-jena.de)
199! **************************************************************************************************
200 SUBROUTINE ipi_env_set(ipi_env, ipi_energy, ipi_forces, subsys, &
201 atomic_kind_set, particle_set, local_particles, &
202 molecule_kind_set, molecule_set, local_molecules, &
203 force_env_input, cell_ref, sockfd)
204
205 TYPE(ipi_environment_type), INTENT(INOUT) :: ipi_env
206 REAL(kind=dp), OPTIONAL :: ipi_energy
207 REAL(kind=dp), DIMENSION(:, :), OPTIONAL, POINTER :: ipi_forces
208 TYPE(cp_subsys_type), OPTIONAL, POINTER :: subsys
209 TYPE(atomic_kind_type), DIMENSION(:), OPTIONAL, &
210 POINTER :: atomic_kind_set
211 TYPE(particle_type), DIMENSION(:), OPTIONAL, &
212 POINTER :: particle_set
213 TYPE(distribution_1d_type), OPTIONAL, POINTER :: local_particles
214 TYPE(molecule_kind_type), DIMENSION(:), OPTIONAL, &
215 POINTER :: molecule_kind_set
216 TYPE(molecule_type), DIMENSION(:), OPTIONAL, &
217 POINTER :: molecule_set
218 TYPE(distribution_1d_type), OPTIONAL, POINTER :: local_molecules
219 TYPE(section_vals_type), OPTIONAL, POINTER :: force_env_input
220 TYPE(cell_type), OPTIONAL, POINTER :: cell_ref
221 INTEGER, OPTIONAL :: sockfd
222
223 TYPE(atomic_kind_list_type), POINTER :: atomic_kinds
224 TYPE(molecule_kind_list_type), POINTER :: molecule_kinds
225 TYPE(molecule_list_type), POINTER :: molecules
226 TYPE(particle_list_type), POINTER :: particles
227
228 IF (PRESENT(ipi_energy)) ipi_env%ipi_energy = ipi_energy
229 IF (PRESENT(ipi_forces)) ipi_env%ipi_forces = ipi_forces
230 IF (PRESENT(subsys)) THEN
231 IF (ASSOCIATED(ipi_env%subsys)) THEN
232 IF (.NOT. ASSOCIATED(ipi_env%subsys, subsys)) THEN
233 CALL cp_subsys_release(ipi_env%subsys)
234 END IF
235 END IF
236 ipi_env%subsys => subsys
237 END IF
238 IF (PRESENT(atomic_kind_set)) THEN
239 CALL atomic_kind_list_create(atomic_kinds, els_ptr=atomic_kind_set)
240 CALL cp_subsys_set(ipi_env%subsys, atomic_kinds=atomic_kinds)
241 CALL atomic_kind_list_release(atomic_kinds)
242 END IF
243 IF (PRESENT(particle_set)) THEN
244 CALL particle_list_create(particles, els_ptr=particle_set)
245 CALL cp_subsys_set(ipi_env%subsys, particles=particles)
246 CALL particle_list_release(particles)
247 END IF
248 IF (PRESENT(molecule_kind_set)) THEN
249 CALL molecule_kind_list_create(molecule_kinds, els_ptr=molecule_kind_set)
250 CALL cp_subsys_set(ipi_env%subsys, molecule_kinds=molecule_kinds)
251 CALL molecule_kind_list_release(molecule_kinds)
252 END IF
253 IF (PRESENT(molecule_set)) THEN
254 CALL molecule_list_create(molecules, els_ptr=molecule_set)
255 CALL cp_subsys_set(ipi_env%subsys, molecules=molecules)
256 CALL molecule_list_release(molecules)
257 END IF
258 IF (PRESENT(local_particles)) THEN
259 CALL cp_subsys_set(ipi_env%subsys, local_particles=local_particles)
260 END IF
261 IF (PRESENT(local_molecules)) THEN
262 CALL cp_subsys_set(ipi_env%subsys, local_molecules=local_molecules)
263 END IF
264
265 IF (PRESENT(force_env_input)) THEN
266 CALL section_vals_retain(force_env_input)
267 CALL section_vals_release(ipi_env%force_env_input)
268 ipi_env%force_env_input => force_env_input
269 END IF
270 IF (PRESENT(cell_ref)) THEN
271 CALL cell_retain(cell_ref)
272 CALL cell_release(ipi_env%cell_ref)
273 ipi_env%cell_ref => cell_ref
274 END IF
275 IF (PRESENT(sockfd)) ipi_env%sockfd = sockfd
276 END SUBROUTINE ipi_env_set
277
278! **************************************************************************************************
279!> \brief Reinitializes the ipi environment
280!> \param ipi_env The ipi environment to be reinitialized
281!> \par History
282!> 03.2024 initial create
283!> \author Sebastian Seidenath (sebastian.seidenath@uni-jena.de)
284! **************************************************************************************************
285 SUBROUTINE ipi_env_clear(ipi_env)
286
287 TYPE(ipi_environment_type), INTENT(INOUT) :: ipi_env
288
289 IF (ASSOCIATED(ipi_env%ipi_forces)) THEN
290 ipi_env%ipi_forces(:, :) = 0.0_dp
291 END IF
292 IF (ASSOCIATED(ipi_env%subsys)) THEN
293 CALL cp_subsys_release(ipi_env%subsys)
294 END IF
295 IF (ASSOCIATED(ipi_env%force_env_input)) THEN
296 CALL section_vals_release(ipi_env%force_env_input)
297 END IF
298 IF (ASSOCIATED(ipi_env%cell_ref)) THEN
299 CALL cell_release(ipi_env%cell_ref)
300 END IF
301 END SUBROUTINE ipi_env_clear
302
303! **************************************************************************************************
304!> \brief Creates the ipi environment
305!> \param ipi_env The ipi environment to be created
306!> \par History
307!> 03.2024 initial create
308!> \author Sebastian Seidenath (sebastian.seidenath@uni-jena.de)
309! **************************************************************************************************
310 SUBROUTINE ipi_env_create(ipi_env)
311
312 TYPE(ipi_environment_type), INTENT(OUT) :: ipi_env
313
314 NULLIFY (ipi_env%ipi_forces)
315 NULLIFY (ipi_env%subsys)
316 NULLIFY (ipi_env%force_env_input)
317 NULLIFY (ipi_env%cell_ref)
318
319 ipi_env%ipi_energy = 0_dp
320 ipi_env%sockfd = 0 ! stdinp
321 CALL ipi_env_clear(ipi_env)
322 END SUBROUTINE ipi_env_create
323
324END MODULE ipi_environment_types
represent a simple array based list of the given type
subroutine, public atomic_kind_list_release(list)
releases a list (see doc/ReferenceCounting.html)
subroutine, public atomic_kind_list_create(list, els_ptr, owns_els, n_els)
creates a list
Define the atomic kind types and their sub types.
Handles all functions related to the CELL.
Definition cell_types.F:15
subroutine, public cell_release(cell)
releases the given cell (see doc/ReferenceCounting.html)
Definition cell_types.F:559
subroutine, public cell_retain(cell)
retains the given cell (see doc/ReferenceCounting.html)
Definition cell_types.F:542
types that represent a subsys, i.e. a part of the system
subroutine, public cp_subsys_release(subsys)
releases a subsys (see doc/ReferenceCounting.html)
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)
sets various propreties of the subsys
subroutine, public cp_subsys_get(subsys, ref_count, atomic_kinds, atomic_kind_set, particles, particle_set, local_particles, molecules, molecule_set, molecule_kinds, molecule_kind_set, local_molecules, para_env, colvar_p, shell_particles, core_particles, gci, multipoles, natom, nparticle, ncore, nshell, nkind, atprop, virial, results, cell)
returns information about various attributes of the given subsys
stores a lists of integer that are local to a processor. The idea is that these integers represent ob...
objects that represent the structure of input sections and the data contained in an input section
subroutine, public section_vals_retain(section_vals)
retains the given section values (see doc/ReferenceCounting.html)
recursive subroutine, public section_vals_release(section_vals)
releases the given object
The environment for the empirical interatomic potential methods.
subroutine, public ipi_env_get(ipi_env, ipi_energy, ipi_forces, subsys, atomic_kind_set, particle_set, local_particles, molecule_kind_set, molecule_set, local_molecules, force_env_input, cell, cell_ref, virial, sockfd)
Returns various attributes of the ipi environment.
subroutine, public ipi_env_set(ipi_env, ipi_energy, ipi_forces, subsys, atomic_kind_set, particle_set, local_particles, molecule_kind_set, molecule_set, local_molecules, force_env_input, cell_ref, sockfd)
Sets various attributes of the ipi environment.
subroutine, public ipi_env_release(ipi_env)
Releases the given ipi environment (see doc/ReferenceCounting.html)
subroutine, public ipi_env_create(ipi_env)
Creates the ipi environment.
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
represent a simple array based list of the given type
subroutine, public molecule_kind_list_create(list, els_ptr, owns_els, n_els)
creates a list
subroutine, public molecule_kind_list_release(list)
releases a list (see doc/ReferenceCounting.html)
Define the molecule kind structure types and the corresponding functionality.
represent a simple array based list of the given type
subroutine, public molecule_list_create(list, els_ptr, owns_els, n_els)
creates a list
subroutine, public molecule_list_release(list)
releases a list (see doc/ReferenceCounting.html)
Define the data structure for the molecule information.
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 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:55
represents a system: atoms, molecules, their pos,vel,...
structure to store local (to a processor) ordered lists of integers.