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 dielectric constant data type
10 : !> \par History
11 : !> 06.2014 created [Hossein Bani-Hashemian]
12 : !> \author Mohammad Hossein Bani-Hashemian
13 : ! **************************************************************************************************
14 : MODULE dielectric_types
15 :
16 : USE kinds, ONLY: dp
17 : USE pw_pool_types, ONLY: pw_pool_type
18 : USE pw_types, ONLY: pw_r3d_rs_type
19 : #include "../base/base_uses.f90"
20 :
21 : IMPLICIT NONE
22 :
23 : PRIVATE
24 :
25 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'dielectric_types'
26 :
27 : INTEGER, PARAMETER, PUBLIC :: derivative_cd3 = 1, &
28 : derivative_cd5 = 2, &
29 : derivative_cd7 = 3, &
30 : derivative_fft = 100, &
31 : derivative_fft_use_deps = 101, &
32 : derivative_fft_use_drho = 102
33 :
34 : INTEGER, PARAMETER, PUBLIC :: rho_dependent = 10, &
35 : spatially_dependent = 20, &
36 : spatially_rho_dependent = 30
37 :
38 : TYPE dielectric_parameters
39 : LOGICAL :: dielec_core_correction = .FALSE.
40 : INTEGER :: dielec_functiontype = rho_dependent
41 : REAL(KIND=dp) :: eps0 = 0.0_dp
42 : REAL(KIND=dp) :: rho_min = 0.0_dp
43 : REAL(KIND=dp) :: rho_max = 0.0_dp
44 : INTEGER :: derivative_method = derivative_cd3
45 : INTEGER :: times_called = 0
46 :
47 : INTEGER :: n_aa_cuboidal = 0
48 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: aa_cuboidal_xxtnt => NULL()
49 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: aa_cuboidal_yxtnt => NULL()
50 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: aa_cuboidal_zxtnt => NULL()
51 : REAL(KIND=dp), DIMENSION(:), POINTER :: aa_cuboidal_eps => NULL()
52 : REAL(KIND=dp), DIMENSION(:), POINTER :: aa_cuboidal_zeta => NULL()
53 :
54 : INTEGER :: n_xaa_annular = 0
55 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: xaa_annular_xxtnt => NULL()
56 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: xaa_annular_bctr => NULL()
57 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: xaa_annular_brad => NULL()
58 : REAL(KIND=dp), DIMENSION(:), POINTER :: xaa_annular_eps => NULL()
59 : REAL(KIND=dp), DIMENSION(:), POINTER :: xaa_annular_zeta => NULL()
60 : END TYPE dielectric_parameters
61 :
62 : TYPE dielectric_type
63 : TYPE(dielectric_parameters) :: params = dielectric_parameters()
64 : TYPE(pw_r3d_rs_type), POINTER :: eps => NULL()
65 : TYPE(pw_r3d_rs_type), POINTER :: deps_drho => NULL()
66 : TYPE(pw_r3d_rs_type), DIMENSION(3) :: dln_eps = pw_r3d_rs_type()
67 : END TYPE dielectric_type
68 :
69 : PUBLIC :: dielectric_type, dielectric_parameters
70 : PUBLIC :: dielectric_release
71 :
72 : CONTAINS
73 :
74 : ! **************************************************************************************************
75 : !> \brief deallocates dielectric data type
76 : !> \param dielectric the dielectric data type to be released
77 : !> \param pw_pool pool of the plane wave grid
78 : !> \par History
79 : !> 06.2014 created [Hossein Bani-Hashemian]
80 : !> \author Mohammad Hossein Bani-Hashemian
81 : ! **************************************************************************************************
82 54 : SUBROUTINE dielectric_release(dielectric, pw_pool)
83 : TYPE(dielectric_type), POINTER :: dielectric
84 : TYPE(pw_pool_type), INTENT(IN), OPTIONAL, POINTER :: pw_pool
85 :
86 : CHARACTER(len=*), PARAMETER :: routineN = 'dielectric_release'
87 :
88 : INTEGER :: handle, i
89 : LOGICAL :: can_give_back
90 :
91 54 : CALL timeset(routineN, handle)
92 54 : IF (ASSOCIATED(dielectric)) THEN
93 54 : can_give_back = PRESENT(pw_pool)
94 54 : IF (can_give_back) can_give_back = ASSOCIATED(pw_pool)
95 54 : IF (can_give_back) THEN
96 0 : CALL pw_pool%give_back_pw(dielectric%eps)
97 0 : CALL pw_pool%give_back_pw(dielectric%deps_drho)
98 0 : DEALLOCATE (dielectric%eps, dielectric%deps_drho)
99 0 : DO i = 1, 3
100 0 : CALL pw_pool%give_back_pw(dielectric%dln_eps(i))
101 : END DO
102 : ELSE
103 54 : CALL dielectric%eps%release()
104 54 : CALL dielectric%deps_drho%release()
105 54 : DEALLOCATE (dielectric%eps, dielectric%deps_drho)
106 216 : DO i = 1, 3
107 216 : CALL dielectric%dln_eps(i)%release()
108 : END DO
109 : END IF
110 54 : CALL dielectric_parameters_dealloc(dielectric%params)
111 54 : DEALLOCATE (dielectric)
112 : END IF
113 :
114 54 : CALL timestop(handle)
115 :
116 54 : END SUBROUTINE dielectric_release
117 :
118 : ! **************************************************************************************************
119 : !> \brief deallocates dielectric_parameters type
120 : !> \param dielec_params dielectric parameters
121 : !> \par History
122 : !> 07.2015 created [Hossein Bani-Hashemian]
123 : !> \author Mohammad Hossein Bani-Hashemian
124 : ! **************************************************************************************************
125 54 : SUBROUTINE dielectric_parameters_dealloc(dielec_params)
126 :
127 : TYPE(dielectric_parameters), INTENT(INOUT) :: dielec_params
128 :
129 54 : IF (ASSOCIATED(dielec_params%aa_cuboidal_xxtnt)) DEALLOCATE (dielec_params%aa_cuboidal_xxtnt)
130 54 : IF (ASSOCIATED(dielec_params%aa_cuboidal_yxtnt)) DEALLOCATE (dielec_params%aa_cuboidal_yxtnt)
131 54 : IF (ASSOCIATED(dielec_params%aa_cuboidal_zxtnt)) DEALLOCATE (dielec_params%aa_cuboidal_zxtnt)
132 54 : IF (ASSOCIATED(dielec_params%aa_cuboidal_eps)) DEALLOCATE (dielec_params%aa_cuboidal_eps)
133 54 : IF (ASSOCIATED(dielec_params%aa_cuboidal_zeta)) DEALLOCATE (dielec_params%aa_cuboidal_zeta)
134 :
135 54 : IF (ASSOCIATED(dielec_params%xaa_annular_xxtnt)) DEALLOCATE (dielec_params%xaa_annular_xxtnt)
136 54 : IF (ASSOCIATED(dielec_params%xaa_annular_bctr)) DEALLOCATE (dielec_params%xaa_annular_bctr)
137 54 : IF (ASSOCIATED(dielec_params%xaa_annular_brad)) DEALLOCATE (dielec_params%xaa_annular_brad)
138 54 : IF (ASSOCIATED(dielec_params%xaa_annular_eps)) DEALLOCATE (dielec_params%xaa_annular_eps)
139 54 : IF (ASSOCIATED(dielec_params%xaa_annular_zeta)) DEALLOCATE (dielec_params%xaa_annular_zeta)
140 :
141 54 : END SUBROUTINE dielectric_parameters_dealloc
142 :
143 0 : END MODULE dielectric_types
|