(git:2c0d679)
Loading...
Searching...
No Matches
xc_derivative_desc.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 Module with functions to handle derivative descriptors.
10!> derivative description are strings have the following form
11!> "rhorhorhoa" which means that it is a forth order
12!> derivative, twice with respect to rho, once with respect to rhoa
13!> and once with respect to drhoa.
14!> Possible derivatives are:
15!> - rho: total density
16!> - norm_drho: norm of the gradient of the total density
17!> - rhoa, rhob: alpha and beta spin density (with LSD)
18!> - norm_drhoa, norm_drhob: norm of the gradient of the alpha and beta
19!> spin density
20!> - tau: the local kinetic part
21!> - taua, taub: the kinetic part of the different spins
22!> \note
23!> add drhox, drhoy, drhoz, drhoax,...?
24!> \author thomas & fawzi
25! **************************************************************************************************
27
28 USE util, ONLY: sort
29#include "../base/base_uses.f90"
30
31 IMPLICIT NONE
32
33 PRIVATE
34
35 INTEGER, PARAMETER, PUBLIC :: &
36 deriv_rho = 1, &
37 deriv_rhoa = 2, &
38 deriv_rhob = 3, &
39 deriv_norm_drho = 4, &
40 deriv_norm_drhoa = 5, &
41 deriv_norm_drhob = 6, &
42 deriv_tau = 7, &
43 deriv_tau_a = 8, &
44 deriv_tau_b = 9, &
45 deriv_laplace_rho = 10, &
46 deriv_laplace_rhoa = 11, &
47 deriv_laplace_rhob = 12, &
48 ! Reduced gradients gamma_ij = grad rho_i . grad rho_j. These are the
49 ! variables LibXC itself differentiates with respect to (its sigma), and
50 ! unlike norm_drho they leave the chain rule free of 1/|grad rho| factors.
51 deriv_gamma = 13, &
52 deriv_gamma_aa = 14, &
53 deriv_gamma_ab = 15, &
55
56 INTEGER, PARAMETER :: max_label_length = 12
57
58 LOGICAL, PARAMETER :: debug_this_module = .false.
59
60 CHARACTER(len=*), PARAMETER, PRIVATE :: modulen = 'xc_derivative_desc'
61
63
64CONTAINS
65
66! **************************************************************************************************
67!> \brief ...
68!> \param desc ...
69!> \return ...
70! **************************************************************************************************
71 FUNCTION desc_to_id(desc) RESULT(id)
72 CHARACTER(LEN=*), INTENT(IN) :: desc
73 INTEGER :: id
74
75 SELECT CASE (trim(desc))
76 CASE ("rho")
77 id = deriv_rho
78 CASE ("rhoa")
79 id = deriv_rhoa
80 CASE ("rhob")
81 id = deriv_rhob
82 CASE ("norm_drho")
84 CASE ("norm_drhoa")
86 CASE ("norm_drhob")
88 CASE ("tau")
89 id = deriv_tau
90 CASE ("tau_a")
91 id = deriv_tau_a
92 CASE ("tau_b")
93 id = deriv_tau_b
94 CASE ("laplace_rho")
96 CASE ("laplace_rhoa")
98 CASE ("laplace_rhob")
100 CASE ("gamma")
101 id = deriv_gamma
102 CASE ("gamma_aa")
103 id = deriv_gamma_aa
104 CASE ("gamma_ab")
105 id = deriv_gamma_ab
106 CASE ("gamma_bb")
107 id = deriv_gamma_bb
108 CASE DEFAULT
109 cpabort("Unknown derivative variable: "//desc)
110 END SELECT
111
112 END FUNCTION desc_to_id
113
114! **************************************************************************************************
115!> \brief ...
116!> \param id ...
117!> \return ...
118! **************************************************************************************************
119 FUNCTION id_to_desc(id) RESULT(desc)
120 INTEGER, INTENT(IN) :: id
121 CHARACTER(LEN=MAX_LABEL_LENGTH) :: desc
122
123 SELECT CASE (id)
124 CASE (deriv_rho)
125 desc = "rho"
126 CASE (deriv_rhoa)
127 desc = "rhoa"
128 CASE (deriv_rhob)
129 desc = "rhob"
130 CASE (deriv_norm_drho)
131 desc = "norm_drho"
132 CASE (deriv_norm_drhoa)
133 desc = "norm_drhoa"
134 CASE (deriv_norm_drhob)
135 desc = "norm_drhob"
136 CASE (deriv_tau)
137 desc = "tau"
138 CASE (deriv_tau_a)
139 desc = "tau_a"
140 CASE (deriv_tau_b)
141 desc = "tau_b"
142 CASE (deriv_laplace_rho)
143 desc = "laplace_rho"
144 CASE (deriv_laplace_rhoa)
145 desc = "laplace_rhoa"
146 CASE (deriv_laplace_rhob)
147 desc = "laplace_rhob"
148 CASE (deriv_gamma)
149 desc = "gamma"
150 CASE (deriv_gamma_aa)
151 desc = "gamma_aa"
152 CASE (deriv_gamma_ab)
153 desc = "gamma_ab"
154 CASE (deriv_gamma_bb)
155 desc = "gamma_bb"
156 CASE DEFAULT
157 cpabort("Unknown derivative id!")
158 END SELECT
159
160 END FUNCTION id_to_desc
161
162! **************************************************************************************************
163!> \brief ...
164!> \param desc ...
165!> \param split_desc ...
166! **************************************************************************************************
167 SUBROUTINE create_split_desc(desc, split_desc)
168 INTEGER, DIMENSION(:), INTENT(IN) :: desc
169 INTEGER, DIMENSION(:), POINTER :: split_desc
170
171 INTEGER, ALLOCATABLE, DIMENSION(:) :: indices
172
173 ALLOCATE (split_desc(SIZE(desc)))
174 IF (SIZE(desc) > 0) THEN
175 ALLOCATE (indices(SIZE(desc)))
176 split_desc = desc
177 CALL sort(split_desc, SIZE(desc), indices)
178 DEALLOCATE (indices)
179 END IF
180
181 END SUBROUTINE create_split_desc
182
183! **************************************************************************************************
184!> \brief ...
185!> \param desc ...
186!> \param split_desc ...
187! **************************************************************************************************
188 SUBROUTINE standardize_desc(desc, split_desc)
189 INTEGER, DIMENSION(:), INTENT(IN) :: desc
190 INTEGER, ALLOCATABLE, DIMENSION(:), INTENT(OUT) :: split_desc
191
192 INTEGER, ALLOCATABLE, DIMENSION(:) :: indices
193
194 ALLOCATE (split_desc(SIZE(desc)))
195 IF (SIZE(desc) > 0) THEN
196 ALLOCATE (indices(SIZE(desc)))
197 split_desc(:) = desc
198 CALL sort(split_desc, SIZE(desc), indices)
199 DEALLOCATE (indices)
200 END IF
201
202 END SUBROUTINE standardize_desc
203
204END MODULE xc_derivative_desc
All kind of helpful little routines.
Definition util.F:14
Module with functions to handle derivative descriptors. derivative description are strings have the f...
integer, parameter, public deriv_norm_drho
integer, parameter, public deriv_laplace_rhob
integer, parameter, public deriv_gamma
integer, parameter, public deriv_norm_drhoa
integer, parameter, public deriv_rhob
integer, parameter, public deriv_gamma_aa
integer, parameter, public deriv_rhoa
integer, parameter, public deriv_tau
integer, parameter, public deriv_tau_b
subroutine, public standardize_desc(desc, split_desc)
...
integer, parameter, public deriv_tau_a
integer, parameter, public deriv_laplace_rhoa
subroutine, public create_split_desc(desc, split_desc)
...
integer function, public desc_to_id(desc)
...
integer, parameter, public deriv_rho
integer, parameter, public deriv_gamma_bb
integer, parameter, public deriv_norm_drhob
character(len=max_label_length) function, public id_to_desc(id)
...
integer, parameter, public deriv_gamma_ab
integer, parameter, public deriv_laplace_rho