(git:495eafe)
Loading...
Searching...
No Matches
ipi_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 Methods and functions on the i–PI environment
10!> \par History
11!> 03.2024 initial create
12!> \author Sebastian Seidenath (sebastian.seidenath@uni-jena.de)
13! **************************************************************************************************
16 USE cell_types, ONLY: cell_type
26 USE ipi_server, ONLY: start_server
27 USE kinds, ONLY: dp
36#include "./base/base_uses.f90"
37
38 IMPLICIT NONE
39
40 PRIVATE
41
42! *** Global parameters ***
43
44 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'ipi_environment'
45
46! *** Public subroutines ***
47
48 PUBLIC :: ipi_init
49
50CONTAINS
51
52! **************************************************************************************************
53!> \brief Initialize the ipi environment
54!> \param ipi_env The ipi environment to retain
55!> \param root_section ...
56!> \param para_env ...
57!> \param force_env_section ...
58!> \param subsys_section ...
59!> \par History
60!> 03.2006 initial create
61!> \author Sebastian Seidenath (sebastian.seidenath@uni-jena.de)
62! **************************************************************************************************
63 SUBROUTINE ipi_init(ipi_env, root_section, para_env, force_env_section, &
64 subsys_section)
65 TYPE(ipi_environment_type), POINTER :: ipi_env
66 TYPE(section_vals_type), POINTER :: root_section
67 TYPE(mp_para_env_type), POINTER :: para_env
68 TYPE(section_vals_type), POINTER :: force_env_section, subsys_section
69
70 CHARACTER(len=*), PARAMETER :: routinen = 'ipi_init'
71
72 INTEGER :: handle
73 TYPE(cp_subsys_type), POINTER :: subsys
74 TYPE(section_vals_type), POINTER :: driver_section, motion_section
75
76 CALL timeset(routinen, handle)
77
78 cpassert(ASSOCIATED(ipi_env))
79
80 ! nullifying pointers
81 NULLIFY (subsys)
82
83 IF (.NOT. ASSOCIATED(subsys_section)) THEN
84 subsys_section => section_vals_get_subs_vals(force_env_section, "SUBSYS")
85 END IF
86
87 CALL ipi_env_set(ipi_env=ipi_env, force_env_input=force_env_section)
88
89 CALL cp_subsys_create(subsys, para_env, root_section)
90
91 CALL ipi_init_subsys(ipi_env=ipi_env, subsys=subsys, subsys_section=subsys_section)
92
93 motion_section => section_vals_get_subs_vals(root_section, "MOTION")
94 driver_section => section_vals_get_subs_vals(motion_section, "DRIVER")
95 CALL start_server(para_env=para_env, driver_section=driver_section, ipi_env=ipi_env)
96
97 CALL timestop(handle)
98
99 END SUBROUTINE ipi_init
100
101! **************************************************************************************************
102!> \brief Initialize the ipi environment
103!> \param ipi_env The ipi environment
104!> \param subsys the subsys
105!> \param subsys_section ...
106!> \par History
107!> 03.2024 initial create
108!> \author Sebastian Seidenath (sebastian.seidenath@uni-jena.de)
109! **************************************************************************************************
110 SUBROUTINE ipi_init_subsys(ipi_env, subsys, subsys_section)
111 TYPE(ipi_environment_type), POINTER :: ipi_env
112 TYPE(cp_subsys_type), POINTER :: subsys
113 TYPE(section_vals_type), POINTER :: subsys_section
114
115 CHARACTER(len=*), PARAMETER :: routinen = 'ipi_init_subsys'
116
117 INTEGER :: handle, natom
118 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
119 TYPE(cell_type), POINTER :: my_cell, my_cell_ref
120 TYPE(distribution_1d_type), POINTER :: local_molecules, local_particles
121 TYPE(molecule_kind_type), DIMENSION(:), POINTER :: molecule_kind_set
122 TYPE(molecule_type), DIMENSION(:), POINTER :: molecule_set
123 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
124
125 CALL timeset(routinen, handle)
126
127 NULLIFY (atomic_kind_set, molecule_kind_set, particle_set, molecule_set, &
128 local_molecules, local_particles, my_cell, my_cell_ref)
129
130 particle_set => subsys%particles%els
131 atomic_kind_set => subsys%atomic_kinds%els
132 molecule_kind_set => subsys%molecule_kinds%els
133 molecule_set => subsys%molecules%els
134 my_cell => subsys%cell
135 my_cell_ref => subsys%cell_ref
136
137! *** Print the molecule kind set ***
138 CALL write_molecule_kind_set(molecule_kind_set, subsys_section)
139
140! *** Print the atomic coordinates ***
141 CALL write_fist_particle_coordinates(particle_set, subsys_section)
142 CALL write_particle_distances(particle_set, cell=my_cell, &
143 subsys_section=subsys_section)
144 CALL write_structure_data(particle_set, cell=my_cell, &
145 input_section=subsys_section)
146
147! *** Distribute molecules and atoms using the new data structures ***
148 CALL distribute_molecules_1d(atomic_kind_set=atomic_kind_set, &
149 particle_set=particle_set, &
150 local_particles=local_particles, &
151 molecule_kind_set=molecule_kind_set, &
152 molecule_set=molecule_set, &
153 local_molecules=local_molecules, &
154 force_env_section=ipi_env%force_env_input)
155
156 natom = SIZE(particle_set)
157
158 ALLOCATE (ipi_env%ipi_forces(3, natom))
159 ipi_env%ipi_forces(:, :) = 0.0_dp
160
161 CALL ipi_env_set(ipi_env=ipi_env, subsys=subsys, &
162 cell_ref=my_cell_ref, &
163 local_molecules=local_molecules, &
164 local_particles=local_particles)
165
166 CALL distribution_1d_release(local_particles)
167 CALL distribution_1d_release(local_molecules)
168
169 CALL timestop(handle)
170
171 END SUBROUTINE ipi_init_subsys
172
173END MODULE ipi_environment
Define the atomic kind types and their sub types.
Handles all functions related to the CELL.
Definition cell_types.F:15
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
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.
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
The environment for the empirical interatomic potential methods.
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.
Methods and functions on the i–PI environment.
subroutine, public ipi_init(ipi_env, root_section, para_env, force_env_section, subsys_section)
Initialize the ipi environment.
i–PI server mode: Communication with i–PI clients
Definition ipi_server.F:14
subroutine, public start_server(driver_section, para_env, ipi_env)
Starts the i–PI server. Will block until it recieves a connection.
Definition ipi_server.F:79
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
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.
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
represents a system: atoms, molecules, their pos,vel,...
structure to store local (to a processor) ordered lists of integers.
stores all the informations relevant to an mpi environment