34 #include "../base/base_uses.f90"
40 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'orbital_transformation_matrices'
43 REAL(KIND=
dp),
DIMENSION(:, :),
POINTER :: c2s => null(), slm => null(), &
44 slm_inv => null(), s2c => null()
45 END TYPE orbtramat_type
47 TYPE(orbtramat_type),
DIMENSION(:),
POINTER ::
orbtramat => null()
49 INTEGER,
SAVE :: current_maxl = -1
71 SUBROUTINE create_spherical_harmonics(maxl)
73 INTEGER,
INTENT(IN) :: maxl
75 INTEGER :: expo, i, ic, ic1, ic2, is, j, k, l, lx, &
76 lx1, lx2, ly, ly1, ly2, lz, lz1, lz2, &
78 REAL(kind=
dp) :: s, s1, s2
83 IF (current_maxl > -1)
THEN
84 CALL cp_abort(__location__, &
85 "Spherical harmonics are already allocated. "// &
86 "Use the init routine for an update")
90 CALL cp_abort(__location__, &
91 "A negative maximum angular momentum quantum "// &
127 IF ((j >= 0) .AND. (
modulo(j, 2) == 0))
THEN
133 IF (((m < 0) .AND. (
modulo(abs(ma - lx), 2) == 1)) .OR. &
134 ((m > 0) .AND. (
modulo(abs(ma - lx), 2) == 0)))
THEN
135 expo = (ma - lx + 2*k)/2
136 s = (-1.0_dp)**expo*sqrt(2.0_dp)
137 ELSE IF ((m == 0) .AND. (
modulo(lx, 2) == 0))
THEN
146 (-1.0_dp)**i*
fac(2*l - 2*i)/
fac(l - ma - 2*i)*s2
165 ic1 =
co(lx1, ly1, lz1)
166 s1 = sqrt((
fac(lx1)*
fac(ly1)*
fac(lz1))/ &
171 ic2 =
co(lx2, ly2, lz2)
175 IF ((
modulo(lx, 2) == 0) .AND. &
176 (
modulo(ly, 2) == 0) .AND. &
177 (
modulo(lz, 2) == 0))
THEN
178 s2 = sqrt((
fac(lx2)*
fac(ly2)*
fac(lz2))/ &
194 s = sqrt(0.25_dp*
dfac(2*l + 1)/
pi)
217 END SUBROUTINE create_spherical_harmonics
232 IF (current_maxl > -1)
THEN
257 INTEGER,
INTENT(IN) :: maxl
258 INTEGER :: output_unit
260 CHARACTER(LEN=78) :: headline
267 CALL cp_abort(__location__, &
268 "A negative maximum angular momentum quantum "// &
272 IF (maxl > current_maxl)
THEN
275 CALL create_spherical_harmonics(maxl)
279 IF (output_unit > 0)
THEN
286 headline =
"CARTESIAN ORBITAL TO SPHERICAL ORBITAL "// &
287 "TRANSFORMATION MATRIX"
288 CALL write_matrix(
orbtramat(l)%c2s, l, output_unit, headline)
290 headline =
"SPHERICAL ORBITAL TO CARTESIAN ORBITAL "// &
291 "TRANSFORMATION MATRIX"
292 CALL write_matrix(
orbtramat(l)%s2c, l, output_unit, headline)
294 headline =
"SPHERICAL HARMONICS"
295 CALL write_matrix(
orbtramat(l)%slm, l, output_unit, headline)
297 headline =
"INVERSE SPHERICAL HARMONICS"
298 CALL write_matrix(
orbtramat(l)%slm_inv, l, output_unit, headline)
302 WRITE (unit=output_unit, fmt=
"(A)")
""
325 SUBROUTINE write_matrix(matrix, l, lunit, headline)
327 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN) :: matrix
328 INTEGER,
INTENT(IN) :: l, lunit
329 CHARACTER(LEN=*),
INTENT(IN) :: headline
331 CHARACTER(12) :: symbol
332 CHARACTER(LEN=78) :: string
333 INTEGER :: from, i, ic, is, jc, lx, ly, lz, m, nc, &
338 WRITE (unit=lunit, fmt=
"(/,/,T2,A)") trim(headline)
346 to = min(nc, from + 2)
349 DO ly = l - lx, 0, -1
352 IF ((jc >= from) .AND. (jc <= to))
THEN
354 WRITE (unit=string(i:), fmt=
"(A18)") trim(symbol(3:12))
359 WRITE (unit=lunit, fmt=
"(/,T8,A)") trim(string)
364 WRITE (unit=lunit, fmt=
"(T4,A4,3(1X,F17.12))") &
365 symbol(3:6), (matrix(is, jc), jc=from, to)
369 END SUBROUTINE write_matrix
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
Defines the basic variable types.
integer, parameter, public dp
Definition of mathematical constants and functions.
real(kind=dp), parameter, public pi
real(kind=dp), dimension(-1:2 *maxfac+1), parameter, public dfac
real(kind=dp), dimension(0:maxfac), parameter, public fac
Collection of simple mathematical functions and subroutines.
elemental real(kind=dp) function, public binomial(n, k)
The binomial coefficient n over k for 0 <= k <= n is calculated, otherwise zero is returned.
Provides Cartesian and spherical orbital pointers and indices.
integer, dimension(:, :, :), allocatable, public co
integer, dimension(:), allocatable, public nco
integer, dimension(:), allocatable, public nsoset
integer, dimension(:), allocatable, public ncoset
integer, dimension(:), allocatable, public nso
character(len=12) function, public cgf_symbol(n, lxyz)
Build a Cartesian orbital symbol (orbital labels for printing).
character(len=6) function, public sgf_symbol(n, l, m)
Build a spherical orbital symbol (orbital labels for printing).