14#include "./base/base_uses.f90"
18 REAL(kind=
dp),
PARAMETER :: eps = 1.0e-5_dp
20 INTEGER :: first_active, first_other, npairs
21 REAL(kind=
dp),
DIMENSION(8) :: energies
24 energies = [-0.44_dp, -0.17_dp, -0.17_dp, -0.17_dp, 0.15_dp, 0.15_dp, 0.15_dp, 0.41_dp]
27 CALL find_degenerate_splits(energies, [2, 3, 4, 5, 6, 7], eps, npairs, first_active, first_other)
28 CALL check(npairs == 0 .AND. first_active == 0 .AND. first_other == 0,
"complete sets")
32 CALL check(npairs == 0,
"non-degenerate orbitals")
36 CALL check(npairs == 4 .AND. first_active == 4 .AND. first_other == 2, &
37 "two split triplets (4 with 2, 3 and 5 with 6, 7)")
41 CALL check(npairs == 4 .AND. first_active == 5 .AND. first_other == 6,
"reversed active list")
45 CALL check(npairs == 0,
"indices beyond the available orbitals")
48 energies(6) = energies(5) + 0.5_dp*eps
49 energies(7) = energies(5) + 2.0_dp*eps
51 CALL check(npairs == 1 .AND. first_other == 6,
"tolerance")
53 WRITE (*,
'(A)')
"qs_active_space_utils_unittest: all tests passed"
62 SUBROUTINE check(condition, label)
63 LOGICAL,
INTENT(IN) :: condition
64 CHARACTER(LEN=*),
INTENT(IN) :: label
66 IF (.NOT. condition)
THEN
67 WRITE (*,
'(A,A)')
"FAILED: ", label
70 WRITE (*,
'(A,A)')
"OK: ", label
Defines the basic variable types.
integer, parameter, public dp
Contains utility routines for the active space module.
pure subroutine, public find_degenerate_splits(eigenvalues, active, eps_degenerate, npairs, first_active, first_other)
Finds pairs of degenerate orbitals of which one is active and the other is not, i....
program qs_active_space_utils_unittest
Unit tests for the detection of degenerate orbital sets split by an active space.
subroutine check(condition, label)
Stops with an error message if a test fails.