subroutine calc_1e_norms(rdm_defs, one_rdms, norm_1rdm)
! Calculate and return the factor by which the input 1-RDMs need to be
! divided by, in order to correctly normalise them. The transition
! RDMs need to be normalised differently - see comments below.
use rdm_data, only: rdm_definitions_t
use RotateOrbsData, only: NoOrbs
use SystemData, only: nel
type(rdm_definitions_t), intent(in) :: rdm_defs
type(one_rdm_t), intent(in) :: one_rdms(:)
real(dp), intent(out) :: norm_1rdm(:)
integer :: irdm, i
real(dp) :: trace_1rdm(size(one_rdms))
trace_1rdm = 0.0_dp
norm_1rdm = 0.0_dp
do irdm = 1, size(one_rdms)
do i = 1, NoOrbs
trace_1rdm(irdm) = trace_1rdm(irdm) + one_rdms(irdm)%matrix(i, i)
end do
end do
! The non-transition RDMs must be normalised to have a trace of nel.
do irdm = 1, rdm_defs%nrdms_standard
norm_1rdm(irdm) = real(nel, dp) / trace_1rdm(irdm)
end do
! The transition RDMs should be normalised using the normalisation of
! the contributing wave functions, which can be calculated from the
! traces of the corresponding RDMs.
do irdm = rdm_defs%nrdms_standard + 1, size(one_rdms)
norm_1rdm(irdm) = sqrt(norm_1rdm(rdm_defs%state_labels(1, irdm)) * norm_1rdm(rdm_defs%state_labels(2, irdm)))
end do
end subroutine calc_1e_norms