(git:ed6f26b)
Loading...
Searching...
No Matches
libgrpp.F
Go to the documentation of this file.
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: MIT !
6!--------------------------------------------------------------------------------------------------!
7
8!
9! libgrpp - a library for the evaluation of integrals over
10! generalized relativistic pseudopotentials.
11!
12! Copyright (C) 2021-2023 Alexander Oleynichenko
13!
14
15MODULE libgrpp
16 USE iso_c_binding, ONLY: c_double,&
17 c_int32_t
18
19 INTEGER(4), PARAMETER :: libgrpp_cart_order_dirac = 0
20 INTEGER(4), PARAMETER :: libgrpp_cart_order_turbomole = 1
21
22 INTEGER(4), PARAMETER :: libgrpp_nuclear_model_point_charge = 0
23 INTEGER(4), PARAMETER :: libgrpp_nuclear_model_charged_ball = 1
24 INTEGER(4), PARAMETER :: libgrpp_nuclear_model_gaussian = 2
25 INTEGER(4), PARAMETER :: libgrpp_nuclear_model_fermi = 3
26 INTEGER(4), PARAMETER :: libgrpp_nuclear_model_fermi_bubble = 4
28
29 INTERFACE
30
31 SUBROUTINE libgrpp_init()
32 ! no arguments
33 END SUBROUTINE libgrpp_init
34
35 SUBROUTINE libgrpp_finalize()
36 ! no arguments
37 END SUBROUTINE libgrpp_finalize
38
40 ! no arguments
42
43 SUBROUTINE libgrpp_set_radial_tolerance(tolerance)
44 REAL(8), INTENT(in) :: tolerance
45
46 END SUBROUTINE libgrpp_set_radial_tolerance
47
49 REAL(8), INTENT(in) :: tolerance
50
52
54 REAL(8), INTENT(in) :: tolerance
55
57
59 INTEGER(4), INTENT(in) :: order
60
61 END SUBROUTINE libgrpp_set_cartesian_order
62
64 origin_A, L_A, num_primitives_A, coeffs_A, alpha_A, &
65 origin_B, L_B, num_primitives_B, coeffs_B, alpha_B, &
66 rpp_origin, rpp_num_primitives, rpp_powers, rpp_coeffs, rpp_alpha, &
67 matrix &
68 )
69 ! shell centered on atom A
70 REAL(8), DIMENSION(*), INTENT(in) :: origin_A
71 INTEGER(4), INTENT(in) :: L_A, num_primitives_A
72 REAL(8), INTENT(in) :: coeffs_A(*), alpha_A(*)
73 REAL(8), DIMENSION(*), INTENT(in) :: origin_B
74 INTEGER(4), INTENT(in) :: L_B, num_primitives_B
75 REAL(8), INTENT(in) :: coeffs_B(*), alpha_B(*)
76 REAL(8), DIMENSION(*), INTENT(in) :: rpp_origin
77 INTEGER(4), DIMENSION(*), INTENT(in) :: rpp_num_primitives, rpp_powers
78 REAL(8), DIMENSION(*), INTENT(in) :: rpp_coeffs, rpp_alpha
79 REAL(8), DIMENSION(*), INTENT(out) :: matrix
80
81! shell centered on atom B
82! pseudopotential expansion
83! output: matrix with PP integrals
84
85 END SUBROUTINE libgrpp_type1_integrals
86
88 origin_A, L_A, num_primitives_A, coeffs_A, alpha_A, &
89 origin_B, L_B, num_primitives_B, coeffs_B, alpha_B, &
90 rpp_origin, rpp_ang_momentum, rpp_num_primitives, rpp_powers, rpp_coeffs, rpp_alpha, &
91 matrix &
92 )
93 ! shell centered on atom A
94 REAL(8), DIMENSION(*), INTENT(in) :: origin_A
95 INTEGER(4), INTENT(in) :: L_A, num_primitives_A
96 REAL(8), INTENT(in) :: coeffs_A(*), alpha_A(*)
97 REAL(8), DIMENSION(*), INTENT(in) :: origin_B
98 INTEGER(4), INTENT(in) :: L_B, num_primitives_B
99 REAL(8), INTENT(in) :: coeffs_B(*), alpha_B(*)
100 REAL(8), DIMENSION(*), INTENT(in) :: rpp_origin
101 INTEGER(4), INTENT(in) :: rpp_ang_momentum
102 INTEGER(4), DIMENSION(*), INTENT(in) :: rpp_num_primitives, rpp_powers
103 REAL(8), DIMENSION(*), INTENT(in) :: rpp_coeffs, rpp_alpha
104 REAL(8), DIMENSION(*), INTENT(out) :: matrix
105
106! shell centered on atom B
107! pseudopotential expansion
108! output: matrix with PP integrals
109
110 END SUBROUTINE libgrpp_type2_integrals
111
113 origin_A, L_A, num_primitives_A, coeffs_A, alpha_A, &
114 origin_B, L_B, num_primitives_B, coeffs_B, alpha_B, &
115 rpp_origin, rpp_ang_momentum, rpp_num_primitives, rpp_powers, rpp_coeffs, rpp_alpha, &
116 so_x_matrix, so_y_matrix, so_z_matrix &
117 )
118 ! shell centered on atom A
119 REAL(8), DIMENSION(*), INTENT(in) :: origin_A
120 INTEGER(4), INTENT(in) :: L_A, num_primitives_A
121 REAL(8), INTENT(in) :: coeffs_A(*), alpha_A(*)
122 REAL(8), DIMENSION(*), INTENT(in) :: origin_B
123 INTEGER(4), INTENT(in) :: L_B, num_primitives_B
124 REAL(8), INTENT(in) :: coeffs_B(*), alpha_B(*)
125 REAL(8), DIMENSION(*), INTENT(in) :: rpp_origin
126 INTEGER(4), INTENT(in) :: rpp_ang_momentum
127 INTEGER(4), DIMENSION(*), INTENT(in) :: rpp_num_primitives, rpp_powers
128 REAL(8), DIMENSION(*), INTENT(in) :: rpp_coeffs, rpp_alpha
129 REAL(8), DIMENSION(*), INTENT(out) :: so_x_matrix, so_y_matrix, so_z_matrix
130
131! shell centered on atom B
132! pseudopotential expansion
133! output: matrices with PP integrals
134
135 END SUBROUTINE libgrpp_spin_orbit_integrals
136
138 origin_A, L_A, num_primitives_A, coeffs_A, alpha_A, &
139 origin_B, L_B, num_primitives_B, coeffs_B, alpha_B, &
140 rpp_origin, rpp_num_primitives, rpp_powers, rpp_coeffs, rpp_alpha, &
141 point_3d, grad_arep_x, grad_arep_y, grad_arep_z &
142 )
143 ! shell centered on atom A
144 REAL(8), DIMENSION(*), INTENT(in) :: origin_A
145 INTEGER(4), INTENT(in) :: L_A, num_primitives_A
146 REAL(8), INTENT(in) :: coeffs_A(*), alpha_A(*)
147 REAL(8), DIMENSION(*), INTENT(in) :: origin_B
148 INTEGER(4), INTENT(in) :: L_B, num_primitives_B
149 REAL(8), INTENT(in) :: coeffs_B(*), alpha_B(*)
150 REAL(8), DIMENSION(*), INTENT(in) :: rpp_origin
151 INTEGER(4), DIMENSION(*), INTENT(in) :: rpp_num_primitives, rpp_powers
152 REAL(8), DIMENSION(*), INTENT(in) :: rpp_coeffs, rpp_alpha, point_3d
153 REAL(8), DIMENSION(*), INTENT(out) :: grad_arep_x, grad_arep_y, grad_arep_z
154
155! shell centered on atom B
156! pseudopotential expansion
157! differentiation wrt the 3d point (x,y,z)
158! output: matrices d<Int>/dx, d<Int>/dy, d<Int>/dZ
159
161
163 origin_A, L_A, num_primitives_A, coeffs_A, alpha_A, &
164 origin_B, L_B, num_primitives_B, coeffs_B, alpha_B, &
165 rpp_origin, rpp_ang_momentum, rpp_num_primitives, rpp_powers, rpp_coeffs, rpp_alpha, &
166 point_3d, grad_arep_x, grad_arep_y, grad_arep_z &
167 )
168 ! shell centered on atom A
169 REAL(8), DIMENSION(*), INTENT(in) :: origin_A
170 INTEGER(4), INTENT(in) :: L_A, num_primitives_A
171 REAL(8), INTENT(in) :: coeffs_A(*), alpha_A(*)
172 REAL(8), DIMENSION(*), INTENT(in) :: origin_B
173 INTEGER(4), INTENT(in) :: L_B, num_primitives_B
174 REAL(8), INTENT(in) :: coeffs_B(*), alpha_B(*)
175 REAL(8), DIMENSION(*), INTENT(in) :: rpp_origin
176 INTEGER(4), INTENT(in) :: rpp_ang_momentum
177 INTEGER(4), DIMENSION(*), INTENT(in) :: rpp_num_primitives, rpp_powers
178 REAL(8), DIMENSION(*), INTENT(in) :: rpp_coeffs, rpp_alpha, point_3d
179 REAL(8), DIMENSION(*), INTENT(out) :: grad_arep_x, grad_arep_y, grad_arep_z
180
181! shell centered on atom B
182! pseudopotential expansion
183! differentiation wrt the 3d point (x,y,z)
184! output: matrices d<Int>/dx, d<Int>/dy, d<Int>/dZ
185
187
189 origin_A, L_A, num_primitives_A, coeffs_A, alpha_A, &
190 origin_B, L_B, num_primitives_B, coeffs_B, alpha_B, &
191 rpp_origin, rpp_ang_momentum, rpp_num_primitives, rpp_powers, rpp_coeffs, rpp_alpha, &
192 point_3d, grad_sox_x, grad_sox_y, grad_sox_z, &
193 grad_soy_x, grad_soy_y, grad_soy_z, &
194 grad_soz_x, grad_soz_y, grad_soz_z &
195 )
196 ! shell centered on atom A
197 REAL(8), DIMENSION(*), INTENT(in) :: origin_A
198 INTEGER(4), INTENT(in) :: L_A, num_primitives_A
199 REAL(8), INTENT(in) :: coeffs_A(*), alpha_A(*)
200 REAL(8), DIMENSION(*), INTENT(in) :: origin_B
201 INTEGER(4), INTENT(in) :: L_B, num_primitives_B
202 REAL(8), INTENT(in) :: coeffs_B(*), alpha_B(*)
203 REAL(8), DIMENSION(*), INTENT(in) :: rpp_origin
204 INTEGER(4), INTENT(in) :: rpp_ang_momentum
205 INTEGER(4), DIMENSION(*), INTENT(in) :: rpp_num_primitives, rpp_powers
206 REAL(8), DIMENSION(*), INTENT(in) :: rpp_coeffs, rpp_alpha, point_3d
207 REAL(8), DIMENSION(*), INTENT(out) :: grad_sox_x, grad_sox_y, grad_sox_z, &
208 grad_soy_x, grad_soy_y, grad_soy_z, &
209 grad_soz_x, grad_soz_y, grad_soz_z
210
211! shell centered on atom B
212! pseudopotential expansion
213! differentiation wrt the 3d point (x,y,z)
214! output: matrices d<SO_x>/dx, d<SO_x>/dy, d<SO_x>/dZ
215! output: matrices d<SO_y>/dx, d<SO_y>/dy, d<SO_y>/dZ
216! output: matrices d<SO_z>/dx, d<SO_z>/dy, d<SO_z>/dZ
217
219
220 END INTERFACE
221
222CONTAINS
223
224! **************************************************************************************************
225!> \brief ...
226!> \param origin_A ...
227!> \param L_A ...
228!> \param num_primitives_A ...
229!> \param coeffs_A ...
230!> \param alpha_A ...
231!> \param origin_B ...
232!> \param L_B ...
233!> \param num_primitives_B ...
234!> \param coeffs_B ...
235!> \param alpha_B ...
236!> \param rpp_origin ...
237!> \param num_oc_shells ...
238!> \param oc_shells_L ...
239!> \param oc_shells_J ...
240!> \param rpp_num_primitives ...
241!> \param rpp_powers ...
242!> \param rpp_coeffs ...
243!> \param rpp_alpha ...
244!> \param oc_shells_num_primitives ...
245!> \param oc_shells_coeffs ...
246!> \param oc_shells_alpha ...
247!> \param arep_matrix ...
248!> \param so_x_matrix ...
249!> \param so_y_matrix ...
250!> \param so_z_matrix ...
251! **************************************************************************************************
253 origin_A, L_A, num_primitives_A, coeffs_A, alpha_A, &
254 origin_B, L_B, num_primitives_B, coeffs_B, alpha_B, &
255 rpp_origin, num_oc_shells, &
256 oc_shells_L, oc_shells_J, rpp_num_primitives, rpp_powers, rpp_coeffs, rpp_alpha, &
257 oc_shells_num_primitives, oc_shells_coeffs, oc_shells_alpha, &
258 arep_matrix, so_x_matrix, so_y_matrix, so_z_matrix &
259 )
260
261 ! shell centered on atom A
262 REAL(8), INTENT(in) :: origin_A(*)
263 INTEGER(4), INTENT(in) :: L_A, num_primitives_A
264 REAL(8), INTENT(in) :: coeffs_A(*), alpha_A(*), origin_B(*)
265 INTEGER(4), INTENT(in) :: L_B, num_primitives_B
266 REAL(8), INTENT(in) :: coeffs_B(*), alpha_B(*), rpp_origin(*)
267 INTEGER(4) :: num_oc_shells
268 INTEGER(4), INTENT(in) :: oc_shells_L(:), oc_shells_J(:), &
269 rpp_num_primitives(:), rpp_powers(:, :)
270 REAL(8), INTENT(in) :: rpp_coeffs(:, :), rpp_alpha(:, :)
271 INTEGER(4) :: oc_shells_num_primitives(:)
272 REAL(8) :: oc_shells_coeffs(:, :), &
273 oc_shells_alpha(:, :)
274 REAL(8), INTENT(out) :: arep_matrix(*), so_x_matrix(*), &
275 so_y_matrix(*), so_z_matrix(*)
276
277 INTEGER :: i, j, ncart1, ncart2
278 INTERFACE
280 origin_A, L_A, num_primitives_A, coeffs_A, alpha_A, &
281 origin_B, L_B, num_primitives_B, coeffs_B, alpha_B, &
282 pot_origin, pot_L, pot_J, pot_num_primitives, pot_powers, pot_coeffs, pot_alpha, &
283 oc_shell_num_primitives, oc_shell_coeffs, oc_shell_alpha, &
284 arep_matrix, so_x_matrix, so_y_matrix, so_z_matrix) &
285 BIND(C, name="libgrpp_outercore_potential_integrals_part_1_")
286 IMPORT :: c_int32_t, c_double
287 REAL(kind=c_double), DIMENSION(*) :: origin_a
288 INTEGER(kind=C_INT32_T) :: L_A
289 INTEGER(kind=C_INT32_T) :: num_primitives_A
290 REAL(kind=c_double), DIMENSION(*) :: coeffs_a
291 REAL(kind=c_double), DIMENSION(*) :: alpha_a
292 REAL(kind=c_double), DIMENSION(*) :: origin_b
293 INTEGER(kind=C_INT32_T) :: L_B
294 INTEGER(kind=C_INT32_T) :: num_primitives_B
295 REAL(kind=c_double), DIMENSION(*) :: coeffs_b
296 REAL(kind=c_double), DIMENSION(*) :: alpha_b
297 REAL(kind=c_double), DIMENSION(*) :: pot_origin
298 INTEGER(kind=C_INT32_T) :: pot_L
299 INTEGER(kind=C_INT32_T) :: pot_J
300 INTEGER(kind=C_INT32_T) :: pot_num_primitives
301 INTEGER(kind=C_INT32_T), DIMENSION(*) :: pot_powers
302 REAL(kind=c_double), DIMENSION(*) :: pot_coeffs
303 REAL(kind=c_double), DIMENSION(*) :: pot_alpha
304 INTEGER(kind=C_INT32_T) :: oc_shell_num_primitives
305 REAL(kind=c_double), DIMENSION(*) :: oc_shell_coeffs
306 REAL(kind=c_double), DIMENSION(*) :: oc_shell_alpha
307 REAL(kind=c_double), DIMENSION(*) :: arep_matrix
308 REAL(kind=c_double), DIMENSION(*) :: so_x_matrix
309 REAL(kind=c_double), DIMENSION(*) :: so_y_matrix
310 REAL(kind=c_double), DIMENSION(*) :: so_z_matrix
312 END INTERFACE
313 INTERFACE
315 origin_A, L_A, num_primitives_A, coeffs_A, alpha_A, &
316 origin_B, L_B, num_primitives_B, coeffs_B, alpha_B, &
317 pot_origin, oc_shell_1_L, oc_shell_1_J, &
318 pot1_num_primitives, pot1_powers, pot1_coeffs, pot1_alpha, &
319 oc_shell_1_num_primitives, oc_shell_1_coeffs, oc_shell_1_alpha, &
320 oc_shell_2_L, oc_shell_2_J, pot2_num_primitives, pot2_powers, pot2_coeffs, &
321 pot2_alpha, oc_shell_2_num_primitives, oc_shell_2_coeffs, oc_shell_2_alpha, &
322 arep_matrix, so_x_matrix, so_y_matrix, so_z_matrix) &
323 BIND(C, name="libgrpp_outercore_potential_integrals_part_2_")
324 IMPORT :: c_int32_t, c_double
325 REAL(kind=c_double), DIMENSION(*) :: origin_a
326 INTEGER(kind=C_INT32_T) :: L_A
327 INTEGER(kind=C_INT32_T) :: num_primitives_A
328 REAL(kind=c_double), DIMENSION(*) :: coeffs_a
329 REAL(kind=c_double), DIMENSION(*) :: alpha_a
330 REAL(kind=c_double), DIMENSION(*) :: origin_b
331 INTEGER(kind=C_INT32_T) :: L_B
332 INTEGER(kind=C_INT32_T) :: num_primitives_B
333 REAL(kind=c_double), DIMENSION(*) :: coeffs_b
334 REAL(kind=c_double), DIMENSION(*) :: alpha_b
335 REAL(kind=c_double), DIMENSION(*) :: pot_origin
336 INTEGER(kind=C_INT32_T) :: oc_shell_1_L
337 INTEGER(kind=C_INT32_T) :: oc_shell_1_J
338 INTEGER(kind=C_INT32_T) :: pot1_num_primitives
339 INTEGER(kind=C_INT32_T), DIMENSION(*) :: pot1_powers
340 REAL(kind=c_double), DIMENSION(*) :: pot1_coeffs
341 REAL(kind=c_double), DIMENSION(*) :: pot1_alpha
342 INTEGER(kind=C_INT32_T) :: oc_shell_1_num_primitives
343 REAL(kind=c_double), DIMENSION(*) :: oc_shell_1_coeffs
344 REAL(kind=c_double), DIMENSION(*) :: oc_shell_1_alpha
345 INTEGER(kind=C_INT32_T) :: oc_shell_2_L
346 INTEGER(kind=C_INT32_T) :: oc_shell_2_J
347 INTEGER(kind=C_INT32_T) :: pot2_num_primitives
348 INTEGER(kind=C_INT32_T), DIMENSION(*) :: pot2_powers
349 REAL(kind=c_double), DIMENSION(*) :: pot2_coeffs
350 REAL(kind=c_double), DIMENSION(*) :: pot2_alpha
351 INTEGER(kind=C_INT32_T) :: oc_shell_2_num_primitives
352 REAL(kind=c_double), DIMENSION(*) :: oc_shell_2_coeffs
353 REAL(kind=c_double), DIMENSION(*) :: oc_shell_2_alpha
354 REAL(kind=c_double), DIMENSION(*) :: arep_matrix
355 REAL(kind=c_double), DIMENSION(*) :: so_x_matrix
356 REAL(kind=c_double), DIMENSION(*) :: so_y_matrix
357 REAL(kind=c_double), DIMENSION(*) :: so_z_matrix
359 END INTERFACE
360
361! shell centered on atom B
362! pseudopotential expansion
363! outercore shells
364! output: matrices with PP integrals
365! local variables
366
367 ncart1 = (l_a + 1)*(l_a + 2)/2
368 ncart2 = (l_b + 1)*(l_b + 2)/2
369
370 arep_matrix(1:ncart1*ncart2) = 0.0d0
371 so_x_matrix(1:ncart1*ncart2) = 0.0d0
372 so_y_matrix(1:ncart1*ncart2) = 0.0d0
373 so_z_matrix(1:ncart1*ncart2) = 0.0d0
374
375 ! the first non-local term:
376 ! \sum_{nlj} U*|nlj><nlj| + |nlj><nlj|*U
377 DO i = 1, num_oc_shells
379 origin_a, l_a, num_primitives_a, coeffs_a, alpha_a, &
380 origin_b, l_b, num_primitives_b, coeffs_b, alpha_b, &
381 rpp_origin, oc_shells_l(i), oc_shells_j(i), &
382 rpp_num_primitives(i), rpp_powers(i, :), rpp_coeffs(i, :), rpp_alpha(i, :), &
383 oc_shells_num_primitives(i), oc_shells_coeffs(i, :), oc_shells_alpha(i, :), &
384 arep_matrix, so_x_matrix, so_y_matrix, so_z_matrix &
385 )
386 END DO
387
388 ! the second non-local term:
389 ! \sum_{nlj,n'lj} |nlj><nlj| U |n'lj><n'lj|
390 DO i = 1, num_oc_shells
391 DO j = 1, num_oc_shells
392
394 origin_a, l_a, num_primitives_a, coeffs_a, alpha_a, &
395 origin_b, l_b, num_primitives_b, coeffs_b, alpha_b, &
396 rpp_origin, &
397 oc_shells_l(i), oc_shells_j(i), &
398 rpp_num_primitives(i), rpp_powers(i, :), rpp_coeffs(i, :), rpp_alpha(i, :), &
399 oc_shells_num_primitives(i), oc_shells_coeffs(i, :), oc_shells_alpha(i, :), &
400 oc_shells_l(j), oc_shells_j(j), &
401 rpp_num_primitives(j), rpp_powers(j, :), rpp_coeffs(j, :), rpp_alpha(j, :), &
402 oc_shells_num_primitives(j), oc_shells_coeffs(j, :), oc_shells_alpha(j, :), &
403 arep_matrix, so_x_matrix, so_y_matrix, so_z_matrix &
404 )
405
406 END DO
407 END DO
408
410END MODULE libgrpp
411
void libgrpp_outercore_potential_integrals_part_1(libgrpp_shell_t *shell_A, libgrpp_shell_t *shell_B, double *C, libgrpp_potential_t *oc_potential, libgrpp_shell_t *oc_shell, double *arep_matrix, double *so_x_matrix, double *so_y_matrix, double *so_z_matrix)
void libgrpp_outercore_potential_integrals(libgrpp_shell_t *shell_A, libgrpp_shell_t *shell_B, double *rpp_origin, int num_oc_shells, libgrpp_potential_t **oc_potentials, libgrpp_shell_t **oc_shells, double *arep, double *esop_x, double *esop_y, double *esop_z)
void libgrpp_outercore_potential_integrals_part_2(libgrpp_shell_t *shell_A, libgrpp_shell_t *shell_B, double *C, libgrpp_potential_t *oc_potential_1, libgrpp_shell_t *oc_shell_1, libgrpp_potential_t *oc_potential_2, libgrpp_shell_t *oc_shell_2, double *arep_matrix, double *so_x_matrix, double *so_y_matrix, double *so_z_matrix)
integer(4), parameter libgrpp_nuclear_model_gaussian
Definition libgrpp.F:24
integer(4), parameter libgrpp_nuclear_model_charged_ball
Definition libgrpp.F:23
integer(4), parameter libgrpp_nuclear_model_fermi_bubble
Definition libgrpp.F:26
integer(4), parameter libgrpp_cart_order_dirac
Definition libgrpp.F:19
integer(4), parameter libgrpp_nuclear_model_point_charge
Definition libgrpp.F:22
integer(4), parameter libgrpp_nuclear_model_point_charge_numerical
Definition libgrpp.F:27
integer(4), parameter libgrpp_cart_order_turbomole
Definition libgrpp.F:20
integer(4), parameter libgrpp_nuclear_model_fermi
Definition libgrpp.F:25