Line data Source code
1 : !--------------------------------------------------------------------------------------------------!
2 : ! CP2K: A general program to perform molecular dynamics simulations !
3 : ! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
4 : ! !
5 : ! SPDX-License-Identifier: GPL-2.0-or-later !
6 : !--------------------------------------------------------------------------------------------------!
7 :
8 : ! **************************************************************************************************
9 : !> \brief Lumps all possible extended system variables into one
10 : !> type for easy access and passing
11 : !> \par History
12 : !> Teodoro Laino - 09.2007 - University of Zurich
13 : !> Cleaned the typo.. no need to have an extended
14 : !> type. Thermostat and Barostat type have been created
15 : !> \author CJM
16 : ! **************************************************************************************************
17 : MODULE extended_system_types
18 : USE bibliography, ONLY: Nose1984a,&
19 : Nose1984b,&
20 : cite_reference
21 : USE input_constants, ONLY: do_thermo_no_communication
22 : USE input_section_types, ONLY: section_vals_type,&
23 : section_vals_val_get
24 : USE kinds, ONLY: dp
25 : #include "./base/base_uses.f90"
26 :
27 : IMPLICIT NONE
28 : PRIVATE
29 :
30 : PUBLIC :: lnhc_dealloc, &
31 : lnhc_init, &
32 : lnhc_parameters_type, &
33 : map_info_type, &
34 : create_map_info_type, &
35 : release_map_info_type, &
36 : npt_info_type
37 :
38 : LOGICAL, PARAMETER, PUBLIC :: debug_isotropic_limit = .FALSE.
39 : LOGICAL, PARAMETER, PUBLIC :: debug_uniaxial_limit = .FALSE.
40 :
41 : ! **************************************************************************************************
42 : TYPE npt_info_type
43 : REAL(KIND=dp) :: eps = -1.0_dp
44 : REAL(KIND=dp) :: v = -1.0_dp
45 : REAL(KIND=dp) :: f = -1.0_dp
46 : REAL(KIND=dp) :: mass = -1.0_dp
47 : END TYPE npt_info_type
48 :
49 : ! **************************************************************************************************
50 : TYPE nhc_info_type
51 : INTEGER :: degrees_of_freedom = -1
52 : REAL(KIND=dp) :: eta = -1.0_dp
53 : REAL(KIND=dp) :: v = -1.0_dp
54 : REAL(KIND=dp) :: f = -1.0_dp
55 : REAL(KIND=dp) :: nkt = -1.0_dp
56 : REAL(KIND=dp) :: mass = -1.0_dp
57 : END TYPE nhc_info_type
58 :
59 : ! **************************************************************************************************
60 : TYPE point_info_type
61 : REAL(KIND=dp), POINTER :: point => NULL()
62 : END TYPE point_info_type
63 :
64 : ! **************************************************************************************************
65 : TYPE map_info_type
66 : INTEGER :: dis_type = -1
67 : INTEGER, POINTER, DIMENSION(:) :: index => NULL(), map_index => NULL()
68 : REAL(KIND=dp), POINTER, DIMENSION(:) :: v_scale => NULL()
69 : REAL(KIND=dp), POINTER, DIMENSION(:) :: s_kin => NULL()
70 : TYPE(point_info_type), POINTER, DIMENSION(:, :) :: p_scale => NULL()
71 : TYPE(point_info_type), POINTER, DIMENSION(:, :) :: p_kin => NULL()
72 : END TYPE map_info_type
73 :
74 : ! **************************************************************************************************
75 : TYPE lnhc_parameters_type
76 : INTEGER :: nyosh = -1, nc = -1, nhc_len = -1
77 : INTEGER :: glob_num_nhc = -1, loc_num_nhc = -1, region = -1
78 : REAL(KIND=dp) :: tau_nhc = -1.0_dp, dt_fact = -1.0_dp
79 : REAL(KIND=dp), POINTER :: dt_yosh(:) => NULL()
80 : TYPE(nhc_info_type), POINTER :: nvt(:, :) => NULL()
81 : TYPE(map_info_type), POINTER :: map_info => NULL()
82 : END TYPE lnhc_parameters_type
83 :
84 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'extended_system_types'
85 :
86 : CONTAINS
87 :
88 : ! **************************************************************************************************
89 : !> \brief Initialize type for Nose-Hoover thermostat
90 : !> \param lnhc ...
91 : !> \param section ...
92 : ! **************************************************************************************************
93 554 : SUBROUTINE lnhc_init(lnhc, section)
94 : TYPE(lnhc_parameters_type), POINTER :: lnhc
95 : TYPE(section_vals_type), POINTER :: section
96 :
97 554 : NULLIFY (lnhc%dt_yosh)
98 554 : NULLIFY (lnhc%nvt)
99 554 : NULLIFY (lnhc%map_info)
100 554 : lnhc%loc_num_nhc = 0
101 554 : lnhc%glob_num_nhc = 0
102 554 : lnhc%dt_fact = 1.0_dp
103 554 : CALL cite_reference(Nose1984a)
104 554 : CALL cite_reference(Nose1984b)
105 554 : CALL section_vals_val_get(section, "LENGTH", i_val=lnhc%nhc_len)
106 554 : CALL section_vals_val_get(section, "YOSHIDA", i_val=lnhc%nyosh)
107 554 : CALL section_vals_val_get(section, "TIMECON", r_val=lnhc%tau_nhc)
108 554 : CALL section_vals_val_get(section, "MTS", i_val=lnhc%nc)
109 554 : CALL create_map_info_type(lnhc%map_info)
110 :
111 554 : END SUBROUTINE lnhc_init
112 :
113 : ! **************************************************************************************************
114 : !> \brief create the map_info type
115 : !> \param map_info ...
116 : ! **************************************************************************************************
117 724 : SUBROUTINE create_map_info_type(map_info)
118 : TYPE(map_info_type), POINTER :: map_info
119 :
120 724 : ALLOCATE (map_info)
121 : NULLIFY (map_info%index, map_info%map_index)
122 : NULLIFY (map_info%v_scale)
123 : NULLIFY (map_info%p_scale)
124 : NULLIFY (map_info%s_kin)
125 : NULLIFY (map_info%p_kin)
126 724 : map_info%dis_type = do_thermo_no_communication
127 :
128 724 : END SUBROUTINE create_map_info_type
129 :
130 : ! **************************************************************************************************
131 : !> \brief release the map_info type
132 : !> \param map_info ...
133 : ! **************************************************************************************************
134 724 : SUBROUTINE release_map_info_type(map_info)
135 : TYPE(map_info_type), POINTER :: map_info
136 :
137 724 : IF (ASSOCIATED(map_info)) THEN
138 724 : IF (ASSOCIATED(map_info%p_kin)) THEN
139 722 : DEALLOCATE (map_info%p_kin)
140 : END IF
141 724 : IF (ASSOCIATED(map_info%p_scale)) THEN
142 722 : DEALLOCATE (map_info%p_scale)
143 : END IF
144 724 : IF (ASSOCIATED(map_info%v_scale)) THEN
145 722 : DEALLOCATE (map_info%v_scale)
146 : END IF
147 724 : IF (ASSOCIATED(map_info%s_kin)) THEN
148 722 : DEALLOCATE (map_info%s_kin)
149 : END IF
150 724 : IF (ASSOCIATED(map_info%index)) THEN
151 724 : DEALLOCATE (map_info%index)
152 : END IF
153 724 : IF (ASSOCIATED(map_info%map_index)) THEN
154 722 : DEALLOCATE (map_info%map_index)
155 : END IF
156 :
157 724 : DEALLOCATE (map_info)
158 : END IF
159 :
160 724 : END SUBROUTINE release_map_info_type
161 :
162 : ! **************************************************************************************************
163 : !> \brief Deallocate type for Nose-Hoover thermostat
164 : !> \param lnhc ...
165 : ! **************************************************************************************************
166 554 : SUBROUTINE lnhc_dealloc(lnhc)
167 : TYPE(lnhc_parameters_type), POINTER :: lnhc
168 :
169 554 : IF (ASSOCIATED(lnhc)) THEN
170 554 : IF (ASSOCIATED(lnhc%dt_yosh)) THEN
171 554 : DEALLOCATE (lnhc%dt_yosh)
172 : END IF
173 554 : IF (ASSOCIATED(lnhc%nvt)) THEN
174 554 : DEALLOCATE (lnhc%nvt)
175 : END IF
176 554 : CALL release_map_info_type(lnhc%map_info)
177 554 : DEALLOCATE (lnhc)
178 : END IF
179 :
180 554 : END SUBROUTINE lnhc_dealloc
181 :
182 0 : END MODULE extended_system_types
|