Debian Codegraph @

src/mbd_gradients.f90

raw
1 ! This Source Code Form is subject to the terms of the Mozilla Public
2 ! License, v. 2.0. If a copy of the MPL was not distributed with this
3 ! file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5 module mbd_gradients
6 !! Derivatives.
7
8 use mbd_constants
9
10 implicit none
11
12 private
13
14 type, public :: grad_t
15 !! Derivatives with respect to various quantities
16 real(dp), allocatable :: dcoords(:, :) ! n_atoms by 3
17 real(dp), allocatable :: dlattice(:, :) ! n_vectors by 3
18 real(dp), allocatable :: dalpha(:)
19 real(dp), allocatable :: dalpha_dyn(:, :) ! n_atoms by 0:n_freq
20 real(dp), allocatable :: dC6(:)
21 real(dp), allocatable :: dq(:)
22 real(dp), allocatable :: dr_vdw(:)
23 real(dp), allocatable :: domega(:)
24 real(dp), allocatable :: dV(:)
25 real(dp), allocatable :: dV_free(:)
26 real(dp), allocatable :: dX_free(:)
27 end type
28
29 type, public :: grad_matrix_re_t
30 !! Derivatives of a real dipole matrix with respect to various quantities
31 real(dp), allocatable :: dr(:, :, :)
32 real(dp), allocatable :: dlattice(:, :, :, :)
33 real(dp), allocatable :: dvdw(:, :)
34 real(dp), allocatable :: dsigma(:, :)
35 real(dp), allocatable :: dgamma(:, :)
36 end type
37
38 type, public :: grad_matrix_cplx_t
39 !! Derivatives of a compelx dipole matrix with respect to various quantities
40 complex(dp), allocatable :: dr(:, :, :)
41 complex(dp), allocatable :: dlattice(:, :, :, :)
42 complex(dp), allocatable :: dq(:, :, :)
43 complex(dp), allocatable :: dvdw(:, :)
44 complex(dp), allocatable :: dsigma(:, :)
45 complex(dp), allocatable :: dgamma(:, :)
46 end type
47
48 type, public :: grad_scalar_t
49 !! Derivatives of a scalar with respect to various quantities
50 real(dp), allocatable :: dr(:)
51 real(dp), allocatable :: dr_1
52 real(dp), allocatable :: dk_1
53 real(dp), allocatable :: dvdw
54 real(dp), allocatable :: dgamma
55 real(dp), allocatable :: dC6
56 real(dp), allocatable :: dC6i
57 real(dp), allocatable :: dC6j
58 real(dp), allocatable :: da0i
59 real(dp), allocatable :: da0j
60 end type
61
62 type, public :: grad_request_t
63 !! Used to request derivatives with respect to function arguments
64 logical :: dcoords = .false.
65 logical :: dalpha = .false.
66 logical :: dalpha_dyn = .false.
67 logical :: dC6 = .false.
68 logical :: dr_vdw = .false.
69 logical :: domega = .false.
70 logical :: dsigma = .false.
71 logical :: dgamma = .false.
72 logical :: dq = .false.
73 logical :: dlattice = .false.
74 logical :: dV = .false.
75 logical :: dV_free = .false.
76 logical :: dX_free = .false.
77 contains
78 procedure :: any => grad_request_any
79 end type
80
81 contains
82
83 logical function grad_request_any(this) result(any)
84 class(grad_request_t), intent(in) :: this
85
86 any = this%dcoords &
87 .or. this%dalpha &
88 .or. this%dalpha_dyn &
89 .or. this%dC6 &
90 .or. this%dr_vdw &
91 .or. this%domega &
92 .or. this%dsigma &
93 .or. this%dgamma &
94 .or. this%dq &
95 .or. this%dlattice &
96 .or. this%dV &
97 .or. this%dV_free &
98 .or. this%dX_free
99 end function
100
101 end module