pure function vertex_not_allowed(n_elec_1, n_elec_3, orb, elec, ras) result(not_allowed)
integer, intent(in) :: n_elec_1, n_elec_3
integer, intent(in) :: orb, elec
type(ras_parameters), intent(in) :: ras
integer :: n_elec_2
logical :: not_allowed
not_allowed = .true.
n_elec_2 = tot_nelec - n_elec_1 - n_elec_3
! For the current (orb, elec) vertex to be allowed, it must lie within one of three
! trapeziums, defined by the RAS parameters. The first corresponds to RAS1 orbitals,
! the second to RAS2 orbitals and the third to RAS3 orbitals. The three if statements
! below correspond to these three cases, and the if statements within to the
! trapeziums which they must lie in.
if (orb <= ras%size_1) then
! If a RAS1 orbital.
! Condition for (orb,elec) combination to be allowed.
if (orb - elec <= ras%size_1 - n_elec_1 .and. orb - elec >= 0 &
.and. elec <= n_elec_1) not_allowed = .false.
else if (orb > ras%size_1 + ras%size_2) then
! If a RAS3 orbital.
if (orb + (tot_nelec - elec) <= tot_norbs .and. &
orb + (tot_nelec - elec) >= tot_norbs - (ras%size_3 - n_elec_3) .and. &
elec >= (n_elec_1 + n_elec_2)) not_allowed = .false.
else
! If a RAS2 orbital.
if (orb - (elec - n_elec_1) <= ras%size_1 + (ras%size_2 - n_elec_2) .and. &
orb - (elec - n_elec_1) >= ras%size_1 .and. &
elec >= n_elec_1 .and. elec <= (n_elec_1 + n_elec_2)) not_allowed = .false.
end if
end function vertex_not_allowed