Line data Source code
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 : MODULE pint_types
9 :
10 : USE cp_log_handling, ONLY: cp_logger_type
11 : USE gle_system_types, ONLY: gle_type
12 : USE input_section_types, ONLY: section_vals_type
13 : USE kinds, ONLY: dp
14 : USE parallel_rng_types, ONLY: rng_record_length,&
15 : rng_stream_type
16 : USE replica_types, ONLY: replica_env_type
17 : USE simpar_types, ONLY: simpar_type
18 : #include "../base/base_uses.f90"
19 :
20 : IMPLICIT NONE
21 :
22 : PRIVATE
23 :
24 : ! Energy contributions - symbolic names for indexing energy arrays
25 : INTEGER, PARAMETER, PUBLIC :: e_conserved_id = 1, &
26 : e_potential_id = 2, &
27 : e_kin_thermo_id = 3, &
28 : e_kin_virial_id = 4
29 :
30 : ! Number of energy contributions for static array allocation
31 : INTEGER, PARAMETER, PUBLIC :: e_num_ids = 4
32 :
33 : INTEGER, PARAMETER, PUBLIC :: thermostat_none = 0, &
34 : thermostat_nose = 1, &
35 : thermostat_gle = 2, &
36 : thermostat_pile = 3, &
37 : thermostat_piglet = 4, &
38 : thermostat_qtb = 5
39 :
40 : PUBLIC :: pint_env_type
41 : PUBLIC :: normalmode_env_type
42 : PUBLIC :: staging_env_type
43 : PUBLIC :: pile_therm_type
44 : PUBLIC :: piglet_therm_type
45 : PUBLIC :: qtb_therm_type
46 :
47 : ! ***************************************************************************
48 : !> \brief environment for a path integral run
49 : !> \param p number of replicas/beads
50 : !> \param nnos nose hoover chain length
51 : !> \param nrespa number of respa steps
52 : !> \param nsteps - number of PIMD steps to be performed
53 : !> \param iter current iteration number
54 : !> \param ndim number of coordinates per replica/bead
55 : !> \param transform type of transform (normalmode or staging)
56 : !> \param t_tol temperature tolerance for rescaling
57 : !> \param v_tol velocity tolerance for rescaling
58 : !> \param kT boltzmann factor times temperature (simulation temperature
59 : !> \param not necessarily the physical temperature)
60 : !> \param beta 1/kT (physical temperature)
61 : !> \param dt time step for dynamic
62 : !> \param e_pot_h potential energy in harmonic springs
63 : !> \param e_kin_beads (fictitious) kinetic energy of the beads
64 : !> \param e_pot_t potential energy of thermostats
65 : !> \param e_kin_t kinetic energy of thermostats
66 : !> \param energy - energy contributions updated every step REAL(e_num_ids)
67 : !> \param e_kin_virial_id - virial estimator of the (real) kinetic energy
68 : !> \param t current simulation time
69 : !> \param replicas replica environment for force calculations
70 : !> \param input input data structure
71 : !> \param staging_env description for the staging transformation
72 : !> \param normalmode_env description for the normal mode transformation
73 : !> \param randomG random number stream descriptor
74 : !> \param mass real masses
75 : !> \param e_pot_bead array with last energies from QS per replica
76 : !> \param x array with real space coordinates (P, 3*N)
77 : !> \param v array with real space velocities
78 : !> \param f array with real space forces
79 : !> \param mass_beads masses of the beads for harmonic forces (harmonic mass)
80 : !> \param mass_fict fictitious mass of the beads for dynamics (kinetic mass)
81 : !> \param ux array with transformed space coordinates (P, 3*N)
82 : !> \param uv array with transformed velocities
83 : !> \param uv_t array with temporary transformed velocities
84 : !> \param uv_new array with new transformed velocities
85 : !> \param uf array with transformed accelerations (QS part)
86 : !> \param uf_h array with harmonic part transformed forces
87 : !> \param tx nose hoover chain positions (pint_env%nnos,pint_env%p,pint_env%ndim)
88 : !> \param tv nose hoover chain velocities
89 : !> \param tv_t nose hoover chain velocities (temporary)
90 : !> \param tv_old nose hoover chain velocities (older)
91 : !> \param tv_new nose hoover chain velocities (newer)
92 : !> \param tf nose hoover chain forces (?)
93 : !> \param Q nose hoover chain masses
94 : !> \param time_per_step - time per step in seconds (updated every step)
95 : !> \param pile_therm data used for the pile thermostat
96 : !> \param wsinex omega*sin(omega*deltat) for exact harminic integrator
97 : !> \param iwsinex 1/omega*sin(omega*deltat) for exact harminic integrator
98 : !> \param cosex cos(omega*deltat) for exact harminic integrator
99 : !> \param propagator contains propagator related constants
100 : !> \param harm_integrator selects between numeric and exact harmonic integrator scheme
101 : !> \param first_propagated_mode if 1 - propagate all normal modes,
102 : !> if 2 - keep centoid fixed
103 : !> \author fawzi
104 : !> \par History
105 : !> Added some comments - hforbert
106 : !> Added normal mode transformation - hforbert
107 : !> 2009-06-15 helium_solvent_type object is no longer a member of
108 : !> pint_env_type [lwalewski]
109 : !> 2014-10-23 added pile_therm [Felix Uhl]
110 : !> 2018-02-13 added qtb_therm [Fabien Brieuc]
111 : ! ***************************************************************************
112 : TYPE pint_env_type
113 : INTEGER :: p = 0, nnos = 0, nrespa = 0, iter = 0, ndim = 0, transform = 0
114 : INTEGER :: first_step = 0, last_step = 0, num_steps = 0, first_propagated_mode = 0
115 : INTEGER :: pimd_thermostat = 0, harm_integrator = 0, thermostat_rng_seed = 0
116 : REAL(KIND=dp) :: t_tol = 0.0_dp, v_tol = 0.0_dp, kT = 0.0_dp, beta = 0.0_dp, dt = 0.0_dp, &
117 : e_gle = 0.0_dp, e_pile = 0.0_dp, e_piglet = 0.0_dp, e_qtb = 0.0_dp, e_pot_h = 0.0_dp, &
118 : e_kin_beads = 0.0_dp, e_pot_t = 0.0_dp, e_kin_t = 0.0_dp, t = 0.0_dp, time_per_step = 0.0_dp
119 : REAL(KIND=dp) :: link_action = 0.0_dp, pot_action = 0.0_dp
120 : TYPE(cp_logger_type), POINTER :: logger => NULL()
121 : TYPE(replica_env_type), POINTER :: replicas => NULL()
122 : TYPE(section_vals_type), POINTER :: input => NULL()
123 : TYPE(staging_env_type), POINTER :: staging_env => NULL()
124 : TYPE(normalmode_env_type), POINTER :: normalmode_env => NULL()
125 : TYPE(rng_stream_type) :: randomG = rng_stream_type()
126 : TYPE(gle_type), POINTER :: gle => NULL()
127 : REAL(KIND=dp), DIMENSION(e_num_ids) :: energy = 0.0_dp
128 : REAL(KIND=dp), DIMENSION(:), POINTER :: mass => NULL(), e_pot_bead => NULL()
129 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: x => NULL(), v => NULL(), f => NULL(), mass_beads => NULL(), &
130 : mass_fict => NULL(), ux => NULL(), ux_t => NULL(), uv => NULL(), uv_t => NULL(), &
131 : uv_new => NULL(), uf => NULL(), uf_h => NULL(), external_f => NULL()
132 : REAL(KIND=dp), DIMENSION(:), POINTER :: centroid => NULL()
133 : REAL(KIND=dp), DIMENSION(:, :, :), POINTER :: tx => NULL(), tv => NULL(), tv_t => NULL(), &
134 : tv_old => NULL(), tv_new => NULL(), tf => NULL()
135 : REAL(KIND=dp), DIMENSION(:), POINTER :: Q => NULL() ! dim p, make it (p,ndim)?
136 : REAL(KIND=dp), DIMENSION(:), POINTER :: rtmp_ndim => NULL(), rtmp_natom => NULL()
137 : REAL(KIND=dp), DIMENSION(:), POINTER :: iwsinex => NULL(), wsinex => NULL(), cosex => NULL()
138 : TYPE(pile_therm_type), POINTER :: pile_therm => NULL()
139 : TYPE(piglet_therm_type), POINTER :: piglet_therm => NULL()
140 : TYPE(qtb_therm_type), POINTER :: qtb_therm => NULL()
141 : TYPE(pint_propagator_type), POINTER :: propagator => NULL()
142 : TYPE(simpar_type), POINTER :: simpar => NULL()
143 : INTEGER :: n_atoms_constraints = 0
144 : INTEGER, DIMENSION(:), POINTER :: atoms_constraints => NULL()
145 : LOGICAL :: beadwise_constraints = .FALSE.
146 : REAL(KIND=dp) :: kTcorr = 0.0_dp
147 :
148 : END TYPE pint_env_type
149 :
150 : ! ***************************************************************************
151 : !> \brief data to perform the normalmode transformation
152 : !> \note
153 : !> p - number of beads
154 : !> Q_bead - thermostat mass for a non-centroid bead
155 : !> Q_centroid - thermostat mass for a centroid degree of freedom
156 : !> modefactor - mass scale factor for non-centroid degrees of freedom
157 : !> harm - factor for harmonic potential ( w_p^2/modefactor )
158 : !> x2u - transformation matrix real coord to normal mode space
159 : !> u2x - transformation matrix normal mode coord to real space
160 : !> lambda - propagator frequencies of the ring polymer
161 : !>
162 : !> This could be done via FFT calls as well, but for now...
163 : !> \author hforbert
164 : ! ***************************************************************************
165 : TYPE normalmode_env_type
166 : INTEGER :: p = 0
167 : REAL(KIND=dp) :: Q_bead = 0.0_dp, Q_centroid = 0.0_dp, modefactor = 0.0_dp, harm = 0.0_dp
168 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: x2u => NULL(), u2x => NULL()
169 : REAL(KIND=dp), DIMENSION(:), POINTER :: lambda => NULL()
170 : END TYPE normalmode_env_type
171 :
172 : ! ***************************************************************************
173 : !> \brief data to perform the staging transformation
174 : !> \note
175 : !> nseg
176 : !> j
177 : !> p
178 : !> w_p
179 : !> w_j
180 : !> Q_stage
181 : !> Q_end
182 : !> \author fawzi
183 : ! ***************************************************************************
184 : TYPE staging_env_type
185 : INTEGER :: nseg = 0, j = 0, p = 0
186 : REAL(KIND=dp) :: w_p = 0.0_dp, w_j = 0.0_dp, Q_stage = 0.0_dp, Q_end = 0.0_dp
187 : END TYPE staging_env_type
188 :
189 : ! ***************************************************************************
190 : !> \brief data to use the pile thermostat
191 : !> \note
192 : !> lamb - coupling constant of pile to the normal modes
193 : !> tau - time constant for centroid mode
194 : !> thermostat_energy - energy difference for conxerved quantity
195 : !> c1 - scaling of the old momenta
196 : !> c2 - scaling of the friction term
197 : !> g_fric - mode specific friction
198 : !> massfact - Mass prefactor to get units right
199 : !> gaussian_rng_stream - random number generator
200 : !> \author Felix Uhl
201 : ! ***************************************************************************
202 : TYPE pile_therm_type
203 : REAL(KIND=dp) :: lamb = 0.0_dp, tau = 0.0_dp, thermostat_energy = 0.0_dp
204 : REAL(KIND=dp), DIMENSION(:), POINTER :: c1 => NULL()
205 : REAL(KIND=dp), DIMENSION(:), POINTER :: c2 => NULL()
206 : REAL(KIND=dp), DIMENSION(:), POINTER :: g_fric => NULL()
207 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: massfact => NULL()
208 : TYPE(rng_stream_type) :: gaussian_rng_stream = rng_stream_type()
209 : END TYPE pile_therm_type
210 :
211 : ! ***************************************************************************
212 : !> \brief data to use the piglet thermostat
213 : !> \note
214 : !> ndim - number of degrees of freedom
215 : !> p - trotter number
216 : !> nsp1 - number of additional degrees of freedom for Markovian
217 : !dynamics + 1
218 : !> thermostat_energy - energy difference for conxerved quantity
219 : !> a_mat - A matrices (9,9,P)
220 : !> c_mat - C matrices (9,9,P)
221 : !> gle_t - Deterministic part of propagator
222 : !> gle_s - Stochastic part of propagator
223 : !> smalls - Keeps a copy of momenta and additional degrees of
224 : !freedom
225 : !> to ensure Markovian dynamics
226 : !> temp1 - Big storage array that is needed on the way
227 : !> temp2 - vector to store the random numbers
228 : !> sqrtmass - contains the squareroot of the dynamical masses
229 : !> gaussian_rng_stream - random number generator
230 : !> \author Felix Uhl
231 : ! ***************************************************************************
232 : TYPE piglet_therm_type
233 : INTEGER :: ndim = 0, p = 0, nsp1 = 0
234 : REAL(KIND=dp) :: thermostat_energy = 0.0_dp
235 : REAL(KIND=dp), DIMENSION(:, :, :), POINTER :: a_mat => NULL(), c_mat => NULL()
236 : REAL(KIND=dp), DIMENSION(:, :, :), POINTER :: gle_s => NULL(), gle_t => NULL()
237 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: smalls => NULL()
238 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: temp1 => NULL()
239 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: temp2 => NULL()
240 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: sqrtmass => NULL()
241 : TYPE(rng_stream_type) :: gaussian_rng_stream = rng_stream_type()
242 : END TYPE piglet_therm_type
243 :
244 : ! ***************************************************************************
245 : !> \brief data to use the qtb thermostat
246 : !> \note
247 : !> tau - time constant (1/friction) for centroid mode
248 : !> lamb - scaling of time constants to the ring polymer NM freq.
249 : !> taucut - inverse of frequency cutoff for QTB forces
250 : !> lambcut - scaling of the cutoff angular freq. to the ring polymer
251 : !> c1 - scaling of the old momenta
252 : !> c2 - scaling of the friction term
253 : !> g_fric - mode specific friction
254 : !> massfact - Mass prefactor to get units right
255 : !> rf - stores the QTB forces
256 : !> h - filter for computation of QTB forces
257 : !> r - store random numbers for computation of QTB forces
258 : !> - NM freq.
259 : !> step - update QTB forces every qtb_step
260 : !> cpt - to know when to draw new random forces (every qtb_step)
261 : !> fp - defines if we use f_P^(0) or f_P^(1)
262 : !> nf - nb of points used for the convolution product (memory)
263 : !> gaussian_rng_stream - random number generator
264 : !> rng_status - keep track of rng status for restart purposes
265 : !> thermostat_energy - energy difference for conserved quantity
266 : !> \author Fabien Brieuc
267 : ! ***************************************************************************
268 : TYPE qtb_therm_type
269 : REAL(KIND=dp) :: tau = 0.0_dp, lamb = 0.0_dp
270 : REAL(KIND=dp) :: taucut = 0.0_dp, lambcut = 0.0_dp
271 : REAL(KIND=dp), DIMENSION(:), POINTER :: c1 => NULL()
272 : REAL(KIND=dp), DIMENSION(:), POINTER :: c2 => NULL()
273 : REAL(KIND=dp), DIMENSION(:), POINTER :: g_fric => NULL()
274 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: massfact => NULL()
275 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: rf => NULL()
276 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: h => NULL()
277 : REAL(KIND=dp), DIMENSION(:, :, :), POINTER :: r => NULL()
278 : INTEGER, DIMENSION(:), POINTER :: step => NULL()
279 : INTEGER, DIMENSION(:), POINTER :: cpt => NULL()
280 : INTEGER :: fp = 0
281 : INTEGER :: nf = 0
282 : REAL(KIND=dp) :: thermostat_energy = 0.0_dp
283 : TYPE(rng_stream_type) :: gaussian_rng_stream = rng_stream_type()
284 : CHARACTER(LEN=rng_record_length), DIMENSION(:), POINTER :: rng_status => NULL()
285 : END TYPE qtb_therm_type
286 :
287 : ! ***************************************************************************
288 : !> \brief data for the use of different Path Integral propagators
289 : !> \note
290 : !> prop_kind - selects a hamiltonian for the equations of motion
291 : !> temp_sim2phys - conversion factor for simulation to physical temperature
292 : !> temp_phys2sim - conversion factor for physical to simulation temperature
293 : !> physpotscale - factor to scale the physical interaction potential
294 : !> \author Felix Uhl
295 : ! ***************************************************************************
296 : TYPE pint_propagator_type
297 : INTEGER :: prop_kind = 0
298 : REAL(KIND=dp) :: temp_phys2sim = 0.0_dp
299 : REAL(KIND=dp) :: temp_sim2phys = 0.0_dp
300 : REAL(KIND=dp) :: physpotscale = 0.0_dp
301 : END TYPE pint_propagator_type
302 :
303 0 : END MODULE pint_types
|