15 USE iso_c_binding,
ONLY: c_null_ptr, &
27 USE sirius,
ONLY: sirius_free_handler, &
28 sirius_context_handler, &
29 sirius_ground_state_handler, &
30 sirius_kpoint_set_handler
33 #include "./base/base_uses.f90"
38 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'pwdft_environment_types'
41 PUBLIC :: pwdft_environment_type, pwdft_energy_type
55 TYPE pwdft_energy_type
56 REAL(KIND=
dp) :: etotal = 0.0_dp
57 REAL(KIND=
dp) :: entropy = 0.0_dp
58 REAL(KIND=
dp) :: band_gap = -1.0_dp
59 END TYPE pwdft_energy_type
67 TYPE pwdft_environment_type
68 TYPE(mp_para_env_type),
POINTER :: para_env => null()
69 TYPE(qs_subsys_type),
POINTER :: qs_subsys => null()
70 TYPE(section_vals_type),
POINTER :: pwdft_input => null()
71 TYPE(section_vals_type),
POINTER :: force_env_input => null()
72 TYPE(section_vals_type),
POINTER :: xc_input => null()
73 TYPE(pwdft_energy_type),
POINTER :: energy => null()
74 REAL(KIND=
dp),
DIMENSION(:, :),
POINTER :: forces => null()
75 REAL(KIND=
dp),
DIMENSION(3, 3) :: stress = 0.0_dp
77 CHARACTER(len=80),
DIMENSION(16) :: xc_func =
""
79 TYPE(sirius_context_handler) :: sctx
80 TYPE(sirius_ground_state_handler) :: gs_handler
81 TYPE(sirius_kpoint_set_handler) :: ks_handler
83 TYPE(C_PTR) :: sctx = c_null_ptr
84 TYPE(C_PTR) :: gs_handler = c_null_ptr
85 TYPE(C_PTR) :: ks_handler = c_null_ptr
88 END TYPE pwdft_environment_type
101 TYPE(pwdft_environment_type),
INTENT(INOUT) :: pwdft_env
103 #if defined(__SIRIUS)
105 CALL sirius_free_handler(pwdft_env%gs_handler)
106 CALL sirius_free_handler(pwdft_env%ks_handler)
107 CALL sirius_free_handler(pwdft_env%sctx)
109 IF (
ASSOCIATED(pwdft_env%qs_subsys))
THEN
111 DEALLOCATE (pwdft_env%qs_subsys)
113 IF (
ASSOCIATED(pwdft_env%energy))
THEN
114 DEALLOCATE (pwdft_env%energy)
116 IF (
ASSOCIATED(pwdft_env%forces))
THEN
117 DEALLOCATE (pwdft_env%forces)
143 SUBROUTINE pwdft_env_get(pwdft_env, pwdft_input, force_env_input, xc_input, &
144 cp_subsys, qs_subsys, para_env, energy, forces, stress, &
145 sctx, gs_handler, ks_handler)
147 TYPE(pwdft_environment_type),
INTENT(IN) :: pwdft_env
148 TYPE(section_vals_type),
OPTIONAL,
POINTER :: pwdft_input, force_env_input, xc_input
149 TYPE(cp_subsys_type),
OPTIONAL,
POINTER :: cp_subsys
150 TYPE(qs_subsys_type),
OPTIONAL,
POINTER :: qs_subsys
151 TYPE(mp_para_env_type),
OPTIONAL,
POINTER :: para_env
152 TYPE(pwdft_energy_type),
OPTIONAL,
POINTER :: energy
153 REAL(kind=
dp),
DIMENSION(:, :),
OPTIONAL,
POINTER :: forces
154 REAL(kind=
dp),
DIMENSION(3, 3),
OPTIONAL :: stress
155 #if defined(__SIRIUS)
156 TYPE(sirius_context_handler),
OPTIONAL :: sctx
157 TYPE(sirius_ground_state_handler),
OPTIONAL :: gs_handler
158 TYPE(sirius_kpoint_set_handler),
OPTIONAL :: ks_handler
161 TYPE(c_ptr),
OPTIONAL :: sctx
162 TYPE(c_ptr),
OPTIONAL :: gs_handler
163 TYPE(c_ptr),
OPTIONAL :: ks_handler
166 IF (
PRESENT(pwdft_input)) pwdft_input => pwdft_env%pwdft_input
167 IF (
PRESENT(force_env_input)) force_env_input => pwdft_env%force_env_input
168 IF (
PRESENT(xc_input)) xc_input => pwdft_env%xc_input
169 IF (
PRESENT(qs_subsys)) qs_subsys => pwdft_env%qs_subsys
170 IF (
PRESENT(cp_subsys))
THEN
173 IF (
PRESENT(para_env)) para_env => pwdft_env%para_env
174 IF (
PRESENT(energy)) energy => pwdft_env%energy
175 IF (
PRESENT(forces)) forces => pwdft_env%forces
176 IF (
PRESENT(stress)) stress(1:3, 1:3) = pwdft_env%stress(1:3, 1:3)
178 IF (
PRESENT(sctx)) sctx = pwdft_env%sctx
179 IF (
PRESENT(gs_handler)) gs_handler = pwdft_env%gs_handler
180 IF (
PRESENT(ks_handler)) ks_handler = pwdft_env%ks_handler
204 SUBROUTINE pwdft_env_set(pwdft_env, pwdft_input, force_env_input, xc_input, &
205 qs_subsys, cp_subsys, para_env, energy, forces, stress, &
206 sctx, gs_handler, ks_handler)
208 TYPE(pwdft_environment_type),
INTENT(INOUT) :: pwdft_env
209 TYPE(section_vals_type),
OPTIONAL,
POINTER :: pwdft_input, force_env_input, xc_input
210 TYPE(qs_subsys_type),
OPTIONAL,
POINTER :: qs_subsys
211 TYPE(cp_subsys_type),
OPTIONAL,
POINTER :: cp_subsys
212 TYPE(mp_para_env_type),
OPTIONAL,
POINTER :: para_env
213 TYPE(pwdft_energy_type),
OPTIONAL,
POINTER :: energy
214 REAL(kind=
dp),
DIMENSION(:, :),
OPTIONAL,
POINTER :: forces
215 REAL(kind=
dp),
DIMENSION(3, 3),
OPTIONAL :: stress
216 #if defined(__SIRIUS)
217 TYPE(sirius_context_handler),
OPTIONAL :: sctx
218 TYPE(sirius_ground_state_handler),
OPTIONAL :: gs_handler
219 TYPE(sirius_kpoint_set_handler),
OPTIONAL :: ks_handler
222 TYPE(c_ptr),
OPTIONAL :: sctx
223 TYPE(c_ptr),
OPTIONAL :: gs_handler
224 TYPE(c_ptr),
OPTIONAL :: ks_handler
227 IF (
PRESENT(para_env)) pwdft_env%para_env => para_env
228 IF (
PRESENT(pwdft_input)) pwdft_env%pwdft_input => pwdft_input
229 IF (
PRESENT(force_env_input)) pwdft_env%force_env_input => force_env_input
230 IF (
PRESENT(xc_input)) pwdft_env%xc_input => xc_input
232 IF (
PRESENT(qs_subsys))
THEN
233 IF (
ASSOCIATED(pwdft_env%qs_subsys))
THEN
234 IF (.NOT.
ASSOCIATED(pwdft_env%qs_subsys, qs_subsys))
THEN
236 DEALLOCATE (pwdft_env%qs_subsys)
239 pwdft_env%qs_subsys => qs_subsys
241 IF (
PRESENT(cp_subsys))
THEN
245 IF (
PRESENT(energy)) pwdft_env%energy => energy
246 IF (
PRESENT(forces)) pwdft_env%forces => forces
247 IF (
PRESENT(stress)) pwdft_env%stress(1:3, 1:3) = stress(1:3, 1:3)
248 IF (
PRESENT(sctx)) pwdft_env%sctx = sctx
249 IF (
PRESENT(gs_handler)) pwdft_env%gs_handler = gs_handler
250 IF (
PRESENT(ks_handler)) pwdft_env%ks_handler = ks_handler
260 SUBROUTINE pwdft_env_clear(pwdft_env)
262 TYPE(pwdft_environment_type),
INTENT(INOUT) :: pwdft_env
266 NULLIFY (pwdft_env%para_env)
267 NULLIFY (pwdft_env%pwdft_input)
268 NULLIFY (pwdft_env%force_env_input)
269 IF (
ASSOCIATED(pwdft_env%qs_subsys))
THEN
271 DEALLOCATE (pwdft_env%qs_subsys)
273 IF (
ASSOCIATED(pwdft_env%energy))
THEN
274 DEALLOCATE (pwdft_env%energy)
276 IF (
ASSOCIATED(pwdft_env%forces))
THEN
277 DEALLOCATE (pwdft_env%forces)
278 NULLIFY (pwdft_env%forces)
280 pwdft_env%stress = 0.0_dp
282 END SUBROUTINE pwdft_env_clear
293 TYPE(pwdft_environment_type),
INTENT(OUT) :: pwdft_env
295 CALL pwdft_env_clear(pwdft_env)
types that represent a subsys, i.e. a part of the system
Defines the basic variable types.
integer, parameter, public dp
Interface to the message passing library MPI.
The type definitions for the PWDFT environment.
subroutine, public pwdft_env_get(pwdft_env, pwdft_input, force_env_input, xc_input, cp_subsys, qs_subsys, para_env, energy, forces, stress, sctx, gs_handler, ks_handler)
Returns various attributes of the pwdft environment.
subroutine, public pwdft_env_create(pwdft_env)
Creates the pwdft environment.
subroutine, public pwdft_env_set(pwdft_env, pwdft_input, force_env_input, xc_input, qs_subsys, cp_subsys, para_env, energy, forces, stress, sctx, gs_handler, ks_handler)
Sets various attributes of the pwdft environment.
subroutine, public pwdft_env_release(pwdft_env)
Releases the given pwdft environment (see doc/ReferenceCounting.html)
types that represent a quickstep subsys
subroutine, public qs_subsys_release(subsys)
releases a subsys (see doc/ReferenceCounting.html)
subroutine, public qs_subsys_get(subsys, 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, cell_ref, use_ref_cell, energy, force, qs_kind_set, cp_subsys, nelectron_total, nelectron_spin)
...
subroutine, public qs_subsys_set(subsys, cp_subsys, local_particles, local_molecules, cell, cell_ref, use_ref_cell, energy, force, qs_kind_set, nelectron_total, nelectron_spin)
...