(git:899a4fa)
Loading...
Searching...
No Matches
orbital_transformation_matrices_unittest.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!--------------------------------------------------------------------------------------------------!
8 USE kinds, ONLY: dp
14
15 IMPLICIT NONE
16
17 INTEGER, PARAMETER :: lmax = 5
18 REAL(kind=dp), PARAMETER :: tolerance = 1.0e-12_dp
19 INTEGER :: i, l, n
20 REAL(kind=dp) :: rotmat(3, 3), residual(2*lmax + 1, 2*lmax + 1)
21 TYPE(orbrotmat_type), DIMENSION(:), POINTER :: orbrot => null()
22
23 CALL init_orbital_pointers(lmax)
24 ! Rotation about (1,2,2), with cos(theta)=3/5 and sin(theta)=4/5.
25 rotmat = reshape([29.0_dp, 28.0_dp, -20.0_dp, -20.0_dp, 35.0_dp, 20.0_dp, &
26 28.0_dp, -4.0_dp, 35.0_dp], [3, 3])/45.0_dp
27 CALL calculate_rotmat(orbrot, rotmat, lmax)
28 IF (.NOT. (abs(orbrot(0)%mat(1, 1) - 1.0_dp) <= tolerance)) error stop "Incorrect s rotation"
29 ! The real p harmonics are ordered (y,z,x).
30 rotmat = reshape([35.0_dp, 20.0_dp, -20.0_dp, -4.0_dp, 35.0_dp, 28.0_dp, &
31 28.0_dp, -20.0_dp, 29.0_dp], [3, 3])/45.0_dp
32 IF (.NOT. all(abs(orbrot(1)%mat - rotmat) <= tolerance)) error stop "Incorrect p rotation"
33 DO l = 0, lmax
34 n = SIZE(orbrot(l)%mat, 1)
35 residual(1:n, 1:n) = matmul(orbrot(l)%mat, transpose(orbrot(l)%mat))
36 DO i = 1, n
37 residual(i, i) = residual(i, i) - 1.0_dp
38 END DO
39 IF (.NOT. all(abs(residual(1:n, 1:n)) <= tolerance)) THEN
40 print *, "Nonorthogonal orbital rotation for l =", l
41 error stop 1
42 END IF
43 END DO
44 CALL release_rotmat(orbrot)
46
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Provides Cartesian and spherical orbital pointers and indices.
subroutine, public init_orbital_pointers(maxl)
Initialize or update the orbital pointers.
subroutine, public deallocate_orbital_pointers()
Deallocate the orbital pointers.
Calculation of the spherical harmonics and the corresponding orbital transformation matrices.
subroutine, public calculate_rotmat(orbrotmat, rotmat, lval)
Calculate rotation matrices for spherical harmonics up to value l Joseph Ivanic and Klaus Ruedenberg ...
subroutine, public release_rotmat(orbrotmat)
Release rotation matrices.
program orbital_transformation_matrices_unittest