From efcd7420bae5df61a3800d5627df734d0e07c70c Mon Sep 17 00:00:00 2001 From: Ydrnan Date: Fri, 27 Sep 2024 15:38:14 +0200 Subject: [PATCH] Precision in HF energy --- src/ccsd/ccsd_space_orb_sub.irp.f | 4 ++-- src/hartree_fock/hf_energy.irp.f | 14 +++++++++----- src/mo_two_e_ints/mo_bi_integrals.irp.f | 8 ++++---- src/scf_utils/fock_matrix.irp.f | 11 ++++++----- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/ccsd/ccsd_space_orb_sub.irp.f b/src/ccsd/ccsd_space_orb_sub.irp.f index d8131a9c..e65b4e39 100644 --- a/src/ccsd/ccsd_space_orb_sub.irp.f +++ b/src/ccsd/ccsd_space_orb_sub.irp.f @@ -154,14 +154,14 @@ subroutine run_ccsd_space_orb allocate(all_err(nO*nV+nO*nO*nV*(nV*1_8),cc_diis_depth), all_t(nO*nV+nO*nO*nV*(nV*1_8),cc_diis_depth)) !$OMP PARALLEL PRIVATE(i,j) DEFAULT(SHARED) + !$OMP DO COLLAPSE(2) do j=1,cc_diis_depth - !$OMP DO do i=1, size(all_err,1) all_err(i,j) = 0d0 all_t(i,j) = 0d0 enddo - !$OMP END DO NOWAIT enddo + !$OMP END DO NOWAIT !$OMP END PARALLEL endif diff --git a/src/hartree_fock/hf_energy.irp.f b/src/hartree_fock/hf_energy.irp.f index a0f9f897..c23b6f1e 100644 --- a/src/hartree_fock/hf_energy.irp.f +++ b/src/hartree_fock/hf_energy.irp.f @@ -19,16 +19,20 @@ END_PROVIDER ! Hartree-Fock energy containing the nuclear repulsion, and its one- and two-body components. END_DOC integer :: i,j - HF_energy = nuclear_repulsion + double precision :: tmp1, tmp2 + HF_energy = 0.d0 HF_two_electron_energy = 0.d0 HF_one_electron_energy = 0.d0 do j=1,ao_num do i=1,ao_num - HF_two_electron_energy += 0.5d0 * ( ao_two_e_integral_alpha(i,j) * SCF_density_matrix_ao_alpha(i,j) & - +ao_two_e_integral_beta(i,j) * SCF_density_matrix_ao_beta(i,j) ) - HF_one_electron_energy += ao_one_e_integrals(i,j) * (SCF_density_matrix_ao_alpha(i,j) + SCF_density_matrix_ao_beta (i,j) ) + tmp1 = 0.5d0 * ( ao_two_e_integral_alpha(i,j) * SCF_density_matrix_ao_alpha(i,j) & + +ao_two_e_integral_beta (i,j) * SCF_density_matrix_ao_beta (i,j) ) + tmp2 = ao_one_e_integrals(i,j) * (SCF_density_matrix_ao_alpha(i,j) + SCF_density_matrix_ao_beta (i,j) ) + HF_two_electron_energy += tmp1 + HF_one_electron_energy += tmp2 + HF_energy += tmp1 + tmp2 enddo enddo - HF_energy += HF_two_electron_energy + HF_one_electron_energy + HF_energy += nuclear_repulsion END_PROVIDER diff --git a/src/mo_two_e_ints/mo_bi_integrals.irp.f b/src/mo_two_e_ints/mo_bi_integrals.irp.f index 549bbed2..6ee23f4a 100644 --- a/src/mo_two_e_ints/mo_bi_integrals.irp.f +++ b/src/mo_two_e_ints/mo_bi_integrals.irp.f @@ -70,6 +70,10 @@ BEGIN_PROVIDER [ logical, mo_two_e_integrals_in_map ] else call add_integrals_to_map(full_ijkl_bitmask_4) endif + double precision, external :: map_mb + print*,'Molecular integrals provided:' + print*,' Size of MO map ', map_mb(mo_integrals_map) ,'MB' + print*,' Number of MO integrals: ', mo_map_size endif call wall_time(wall_2) @@ -78,10 +82,6 @@ BEGIN_PROVIDER [ logical, mo_two_e_integrals_in_map ] integer*8 :: get_mo_map_size, mo_map_size mo_map_size = get_mo_map_size() - double precision, external :: map_mb - print*,'Molecular integrals provided:' - print*,' Size of MO map ', map_mb(mo_integrals_map) ,'MB' - print*,' Number of MO integrals: ', mo_map_size print*,' cpu time :',cpu_2 - cpu_1, 's' print*,' wall time :',wall_2 - wall_1, 's ( x ', (cpu_2-cpu_1)/(wall_2-wall_1), ')' diff --git a/src/scf_utils/fock_matrix.irp.f b/src/scf_utils/fock_matrix.irp.f index 269a441b..051da9eb 100644 --- a/src/scf_utils/fock_matrix.irp.f +++ b/src/scf_utils/fock_matrix.irp.f @@ -253,17 +253,18 @@ BEGIN_PROVIDER [ double precision, SCF_energy ] BEGIN_DOC ! Hartree-Fock energy END_DOC - SCF_energy = nuclear_repulsion - integer :: i,j + + SCF_energy = 0.d0 + do j=1,ao_num do i=1,ao_num - SCF_energy += 0.5d0 * ( & + SCF_energy += & (ao_one_e_integrals(i,j) + Fock_matrix_ao_alpha(i,j) ) * SCF_density_matrix_ao_alpha(i,j) +& - (ao_one_e_integrals(i,j) + Fock_matrix_ao_beta (i,j) ) * SCF_density_matrix_ao_beta (i,j) ) + (ao_one_e_integrals(i,j) + Fock_matrix_ao_beta (i,j) ) * SCF_density_matrix_ao_beta (i,j) enddo enddo - SCF_energy += extra_e_contrib_density + SCF_energy = 0.5d0 * SCF_energy + extra_e_contrib_density + nuclear_repulsion END_PROVIDER