diff --git a/scripts/generate_h_apply.py b/scripts/generate_h_apply.py index 3af1c43f..4a5ad695 100755 --- a/scripts/generate_h_apply.py +++ b/scripts/generate_h_apply.py @@ -42,7 +42,7 @@ class H_apply(object): !$OMP N_elec_in_key_hole_2,ia_ja_pairs,iproc) & !$OMP SHARED(key_in,N_int,elec_num_tab,mo_tot_num, & !$OMP hole_1, particl_1, hole_2, particl_2, & - !$OMP thresh,elec_alpha_num)""" + !$OMP thresh,elec_alpha_num,i_generator)""" s["omp_end_parallel"] = "!$OMP END PARALLEL" s["omp_master"] = "!$OMP MASTER" s["omp_end_master"] = "!$OMP END MASTER" @@ -121,10 +121,10 @@ class H_apply(object): sum_e_2_pert = sum_e_2_pert_in sum_norm_pert = sum_norm_pert_in sum_H_pert_diag = sum_H_pert_diag_in - PROVIDE CI_electronic_energy psi_ref_coef psi_ref + PROVIDE CI_electronic_energy psi_selectors_coef psi_selectors """ self.data["keys_work"] = """ - call perturb_buffer_%s(keys_out,key_idx,e_2_pert_buffer,coef_pert_buffer,sum_e_2_pert, & + call perturb_buffer_%s(i_generator,keys_out,key_idx,e_2_pert_buffer,coef_pert_buffer,sum_e_2_pert, & sum_norm_pert,sum_H_pert_diag,N_st,Nint) """%(pert,) self.data["finalization"] = """ diff --git a/src/CISD_selected/ASSUMPTIONS.rst b/src/CISD_selected/ASSUMPTIONS.rst new file mode 100644 index 00000000..e69de29b diff --git a/src/CISD_selected/H_apply.irp.f b/src/CISD_selected/H_apply.irp.f new file mode 100644 index 00000000..9b761963 --- /dev/null +++ b/src/CISD_selected/H_apply.irp.f @@ -0,0 +1,32 @@ +use bitmasks +BEGIN_SHELL [ /usr/bin/env python ] +from generate_h_apply import * +from perturbation import perturbations + +for perturbation in perturbations: + s = H_apply("cisd_selection_"+perturbation,openmp=True) + s.set_selection_pt2(perturbation) + print s +END_SHELL + + +subroutine H_apply_cisd_selection(perturbation,pt2, norm_pert, H_pert_diag, N_st) + implicit none + character*(64), intent(in) :: perturbation + integer, intent(in) :: N_st + double precision, intent(inout):: pt2(N_st), norm_pert(N_st) + double precision,intent(inout) :: H_pert_diag + +BEGIN_SHELL [ /usr/bin/env python ] +from perturbation import perturbations + +for perturbation in perturbations: + print """ + if (perturbation == '%s') then + call H_apply_cisd_selection_%s(pt2, norm_pert, H_pert_diag, N_st) + endif + """%(perturbation,perturbation) +END_SHELL + + +end diff --git a/src/CISD_selected/Makefile b/src/CISD_selected/Makefile new file mode 100644 index 00000000..b2ea1de1 --- /dev/null +++ b/src/CISD_selected/Makefile @@ -0,0 +1,8 @@ +default: all + +# Define here all new external source files and objects.Don't forget to prefix the +# object files with IRPF90_temp/ +SRC= +OBJ= + +include $(QPACKAGE_ROOT)/src/Makefile.common diff --git a/src/CISD_selected/NEEDED_MODULES b/src/CISD_selected/NEEDED_MODULES new file mode 100644 index 00000000..ac42ef59 --- /dev/null +++ b/src/CISD_selected/NEEDED_MODULES @@ -0,0 +1 @@ +AOs BiInts Bitmask CISD Dets Electrons Ezfio_files Hartree_Fock MonoInts MOs Nuclei Output Perturbation SingleRefMethod Utils Selectors_full diff --git a/src/CISD_selected/README.rst b/src/CISD_selected/README.rst new file mode 100644 index 00000000..95499a8f --- /dev/null +++ b/src/CISD_selected/README.rst @@ -0,0 +1,35 @@ +==================== +CISD_selected Module +==================== + +Documentation +============= + +.. Do not edit this section. It was auto-generated from the +.. NEEDED_MODULES file. + + + +Needed Modules +============== + +.. Do not edit this section. It was auto-generated from the +.. NEEDED_MODULES file. + +* `AOs `_ +* `BiInts `_ +* `Bitmask `_ +* `CISD `_ +* `Dets `_ +* `Electrons `_ +* `Ezfio_files `_ +* `Hartree_Fock `_ +* `MonoInts `_ +* `MOs `_ +* `Nuclei `_ +* `Output `_ +* `Perturbation `_ +* `SingleRefMethod `_ +* `Utils `_ +* `Selectors_full `_ + diff --git a/src/Perturbation/cisd_selection.irp.f b/src/CISD_selected/cisd_selection.irp.f similarity index 80% rename from src/Perturbation/cisd_selection.irp.f rename to src/CISD_selected/cisd_selection.irp.f index 267d213d..40691065 100644 --- a/src/Perturbation/cisd_selection.irp.f +++ b/src/CISD_selected/cisd_selection.irp.f @@ -6,15 +6,15 @@ program cisd double precision, allocatable :: pt2(:), norm_pert(:) double precision :: H_pert_diag, E_old integer :: N_st, iter + character*(64) :: perturbation N_st = N_states allocate (pt2(N_st), norm_pert(N_st)) pt2 = 1.d0 -! davidson_criterion = 'wall_time' -! davidson_threshold = 1.d0 + perturbation = "epstein_nesbet" do while (maxval(abs(pt2(1:N_st))) > 1.d-6) E_old = CI_energy(1) - call H_apply_cisd_selection(pt2, norm_pert, H_pert_diag, N_st) + call H_apply_cisd_selection(perturbation,pt2, norm_pert, H_pert_diag, N_st) call diagonalize_CI print *, 'N_det = ', N_det print *, 'N_states = ', N_states diff --git a/src/CISD_selected/tests/Makefile b/src/CISD_selected/tests/Makefile new file mode 100644 index 00000000..77bd84ba --- /dev/null +++ b/src/CISD_selected/tests/Makefile @@ -0,0 +1,33 @@ +OPENMP =1 +PROFILE =0 +DEBUG = 0 + +IRPF90+= -I tests + +REF_FILES=$(subst %.irp.f, %.ref, $(wildcard *.irp.f)) + +.PHONY: clean executables serial_tests parallel_tests + +all: clean executables serial_tests parallel_tests + +parallel_tests: $(REF_FILES) + @echo ; echo " ---- Running parallel tests ----" ; echo + @OMP_NUM_THREADS=10 ${QPACKAGE_ROOT}/scripts/run_tests.py + +serial_tests: $(REF_FILES) + @echo ; echo " ---- Running serial tests ----" ; echo + @OMP_NUM_THREADS=1 ${QPACKAGE_ROOT}/scripts/run_tests.py + +executables: $(wildcard *.irp.f) veryclean + $(MAKE) -C .. + +%.ref: $(wildcard $(QPACKAGE_ROOT)/data/inputs/*.md5) executables + $(QPACKAGE_ROOT)/scripts/create_test_ref.sh $* + +clean: + $(MAKE) -C .. clean + +veryclean: + $(MAKE) -C .. veryclean + + diff --git a/src/Dets/H_apply_template.f b/src/Dets/H_apply_template.f index 359ba4fb..adeff13d 100644 --- a/src/Dets/H_apply_template.f +++ b/src/Dets/H_apply_template.f @@ -1,4 +1,4 @@ -subroutine $subroutine_diexc(key_in, hole_1,particl_1, hole_2, particl_2 $parameters ) +subroutine $subroutine_diexc(key_in, hole_1,particl_1, hole_2, particl_2, i_generator $parameters ) use omp_lib use bitmasks implicit none @@ -9,6 +9,7 @@ subroutine $subroutine_diexc(key_in, hole_1,particl_1, hole_2, particl_2 $parame END_DOC integer,parameter :: size_max = $size_max $declarations + integer ,intent(in) :: i_generator integer(bit_kind),intent(in) :: key_in(N_int,2) integer(bit_kind),allocatable :: keys_out(:,:,:) integer(bit_kind), intent(in) :: hole_1(N_int,2), particl_1(N_int,2) @@ -210,7 +211,7 @@ subroutine $subroutine_diexc(key_in, hole_1,particl_1, hole_2, particl_2 $parame abort_here = abort_all end -subroutine $subroutine_monoexc(key_in, hole_1,particl_1 $parameters ) +subroutine $subroutine_monoexc(key_in, hole_1,particl_1,i_generator $parameters ) use omp_lib use bitmasks implicit none @@ -221,6 +222,7 @@ subroutine $subroutine_monoexc(key_in, hole_1,particl_1 $parameters ) END_DOC integer,parameter :: size_max = $size_max $declarations + integer ,intent(in) :: i_generator integer(bit_kind),intent(in) :: key_in(N_int,2) integer(bit_kind),allocatable :: keys_out(:,:,:) integer(bit_kind), intent(in) :: hole_1(N_int,2), particl_1(N_int,2) @@ -328,19 +330,20 @@ subroutine $subroutine($params_main) $decls_main PROVIDE H_apply_buffer_allocated mo_bielec_integrals_in_map N_det_reference psi_generators - integer :: imask + integer :: i_generator - do imask=1,N_det_generators - call $subroutine_monoexc(psi_generators(1,1,imask), & + print *, irp_here + do i_generator=1,N_det_generators + call $subroutine_monoexc(psi_generators(1,1,i_generator), & generators_bitmask(1,1,s_hole ,i_bitmask_gen), & - generators_bitmask(1,1,s_part ,i_bitmask_gen) & - $params_post) - call $subroutine_diexc(psi_generators(1,1,imask), & + generators_bitmask(1,1,s_part ,i_bitmask_gen), & + i_generator $params_post) + call $subroutine_diexc(psi_generators(1,1,i_generator), & generators_bitmask(1,1,d_hole1,i_bitmask_gen), & generators_bitmask(1,1,d_part1,i_bitmask_gen), & generators_bitmask(1,1,d_hole2,i_bitmask_gen), & - generators_bitmask(1,1,d_part2,i_bitmask_gen) & - $params_post) + generators_bitmask(1,1,d_part2,i_bitmask_gen), & + i_generator $params_post) if (abort_here) then exit endif diff --git a/src/Dets/connected_to_ref.irp.f b/src/Dets/connected_to_ref.irp.f index f824d2d6..083fedde 100644 --- a/src/Dets/connected_to_ref.irp.f +++ b/src/Dets/connected_to_ref.irp.f @@ -32,11 +32,6 @@ integer function connected_to_ref(key,keys,Nint,N_past_in,Ndet,thresh) endif if (degree_x2 > 5) then cycle -! else -! call i_H_j(keys(1,1,i),key,Nint,hij_elec) -! if(dabs(hij_elec).lt.thresh)cycle -! connected_to_ref = i -! return endif enddo @@ -69,11 +64,6 @@ integer function connected_to_ref(key,keys,Nint,N_past_in,Ndet,thresh) endif if (degree_x2 > 5) then cycle -! else -! call i_H_j(keys(1,1,i),key,Nint,hij_elec) -! if(dabs(hij_elec).lt.thresh)cycle -! connected_to_ref = i -! return endif enddo @@ -111,11 +101,6 @@ integer function connected_to_ref(key,keys,Nint,N_past_in,Ndet,thresh) endif if (degree_x2 > 5) then cycle -! else -! call i_H_j(keys(1,1,i),key,Nint,hij_elec) -! if(dabs(hij_elec).lt.thresh)cycle -! connected_to_ref = i -! return endif enddo @@ -155,11 +140,6 @@ integer function connected_to_ref(key,keys,Nint,N_past_in,Ndet,thresh) endif if (degree_x2 > 5) then cycle -! else -! call i_H_j(keys(1,1,i),key,Nint,hij_elec) -! if(dabs(hij_elec).lt.thresh)cycle -! connected_to_ref = i -! return endif enddo diff --git a/src/MP2/ASSUMPTIONS.rst b/src/MP2/ASSUMPTIONS.rst new file mode 100644 index 00000000..e69de29b diff --git a/src/MP2/H_apply.irp.f b/src/MP2/H_apply.irp.f new file mode 100644 index 00000000..e3e5e602 --- /dev/null +++ b/src/MP2/H_apply.irp.f @@ -0,0 +1,10 @@ +use bitmasks +BEGIN_SHELL [ /usr/bin/env python ] +from generate_h_apply import * +from perturbation import perturbations + +s = H_apply("mp2",openmp=True) +s.set_perturbation("Moller_plesset") +print s +END_SHELL + diff --git a/src/MP2/Makefile b/src/MP2/Makefile new file mode 100644 index 00000000..b2ea1de1 --- /dev/null +++ b/src/MP2/Makefile @@ -0,0 +1,8 @@ +default: all + +# Define here all new external source files and objects.Don't forget to prefix the +# object files with IRPF90_temp/ +SRC= +OBJ= + +include $(QPACKAGE_ROOT)/src/Makefile.common diff --git a/src/MP2/NEEDED_MODULES b/src/MP2/NEEDED_MODULES new file mode 100644 index 00000000..9b3c459d --- /dev/null +++ b/src/MP2/NEEDED_MODULES @@ -0,0 +1 @@ +AOs BiInts Bitmask Dets Electrons Ezfio_files Hartree_Fock MonoInts MOs Nuclei Output Perturbation Utils Selectors_full SingleRefMethod diff --git a/src/MP2/README.rst b/src/MP2/README.rst new file mode 100644 index 00000000..ddb7fc34 --- /dev/null +++ b/src/MP2/README.rst @@ -0,0 +1,34 @@ +========== +MP2 Module +========== + +Documentation +============= + +.. Do not edit this section. It was auto-generated from the +.. NEEDED_MODULES file. + + + +Needed Modules +============== + +.. Do not edit this section. It was auto-generated from the +.. NEEDED_MODULES file. + +* `AOs `_ +* `BiInts `_ +* `Bitmask `_ +* `Dets `_ +* `Electrons `_ +* `Ezfio_files `_ +* `Hartree_Fock `_ +* `MonoInts `_ +* `MOs `_ +* `Nuclei `_ +* `Output `_ +* `Perturbation `_ +* `Utils `_ +* `Selectors_full `_ +* `SingleRefMethod `_ + diff --git a/src/MP2/mp2.irp.f b/src/MP2/mp2.irp.f new file mode 100644 index 00000000..82265551 --- /dev/null +++ b/src/MP2/mp2.irp.f @@ -0,0 +1,17 @@ +program cisd + implicit none + double precision, allocatable :: pt2(:), norm_pert(:) + double precision :: H_pert_diag, E_old + integer :: N_st, iter + PROVIDE Fock_matrix_diag_mo + N_st = N_states + allocate (pt2(N_st), norm_pert(N_st)) + E_old = HF_energy + call H_apply_mp2(pt2, norm_pert, H_pert_diag, N_st) + print *, 'N_det = ', N_det + print *, 'N_states = ', N_states + print *, 'MP2 = ', pt2 + print *, 'E = ', E_old + print *, 'E+MP2 = ', E_old+pt2 + deallocate(pt2,norm_pert) +end diff --git a/src/MP2/tests/Makefile b/src/MP2/tests/Makefile new file mode 100644 index 00000000..77bd84ba --- /dev/null +++ b/src/MP2/tests/Makefile @@ -0,0 +1,33 @@ +OPENMP =1 +PROFILE =0 +DEBUG = 0 + +IRPF90+= -I tests + +REF_FILES=$(subst %.irp.f, %.ref, $(wildcard *.irp.f)) + +.PHONY: clean executables serial_tests parallel_tests + +all: clean executables serial_tests parallel_tests + +parallel_tests: $(REF_FILES) + @echo ; echo " ---- Running parallel tests ----" ; echo + @OMP_NUM_THREADS=10 ${QPACKAGE_ROOT}/scripts/run_tests.py + +serial_tests: $(REF_FILES) + @echo ; echo " ---- Running serial tests ----" ; echo + @OMP_NUM_THREADS=1 ${QPACKAGE_ROOT}/scripts/run_tests.py + +executables: $(wildcard *.irp.f) veryclean + $(MAKE) -C .. + +%.ref: $(wildcard $(QPACKAGE_ROOT)/data/inputs/*.md5) executables + $(QPACKAGE_ROOT)/scripts/create_test_ref.sh $* + +clean: + $(MAKE) -C .. clean + +veryclean: + $(MAKE) -C .. veryclean + + diff --git a/src/Makefile b/src/Makefile index 8cca5d71..5143e300 100644 --- a/src/Makefile +++ b/src/Makefile @@ -5,7 +5,7 @@ OBJ= include $(QPACKAGE_ROOT)/src/Makefile.common -all:$(ALL) +all: all_modules all_clean: @for i in $(NEEDED_MODULES) ; do cd $$i ; make veryclean ; make clean_links ; cd .. ; done diff --git a/src/NEEDED_MODULES b/src/NEEDED_MODULES index 2567f5aa..725707f3 100644 --- a/src/NEEDED_MODULES +++ b/src/NEEDED_MODULES @@ -1 +1 @@ -AOs Bitmask Electrons Ezfio_files MOs Nuclei Output Utils Hartree_Fock BiInts MonoInts MOGuess Dets DensityMatrix CISD Perturbation SingleRefMethod +AOs Bitmask Electrons Ezfio_files MOs Nuclei Output Utils Hartree_Fock BiInts MonoInts MOGuess Dets DensityMatrix CISD Perturbation SingleRefMethod CISD_selected Selectors_full MP2 diff --git a/src/Perturbation/Moller_plesset.irp.f b/src/Perturbation/Moller_plesset.irp.f index 4f99e9d2..bca48358 100644 --- a/src/Perturbation/Moller_plesset.irp.f +++ b/src/Perturbation/Moller_plesset.irp.f @@ -25,13 +25,13 @@ subroutine pt2_moller_plesset(det_pert,c_pert,e_2_pert,H_pert_diag,Nint,ndet,n_s integer :: h1,h2,p1,p2,s1,s2 ASSERT (Nint == N_int) ASSERT (Nint > 0) - call get_excitation(det_pert,ref_bitmask,exc,degree,phase,Nint) + call get_excitation(ref_bitmask,det_pert,exc,degree,phase,Nint) call decode_exc(exc,degree,h1,p1,h2,p2,s1,s2) delta_e = Fock_matrix_diag_mo(h1) + Fock_matrix_diag_mo(h2) - & - Fock_matrix_diag_mo(p1) + Fock_matrix_diag_mo(p2) + (Fock_matrix_diag_mo(p1) + Fock_matrix_diag_mo(p2)) delta_e = 1.d0/delta_e - call i_H_psi(det_pert,psi_ref,psi_ref_coef,Nint,ndet,psi_ref_size,n_st,i_H_psi_array) + call i_H_psi(det_pert,psi_selectors,psi_selectors_coef,Nint,N_det,psi_selectors_size,n_st,i_H_psi_array) H_pert_diag = diag_H_mat_elem(det_pert,Nint) do i =1,n_st c_pert(i) = i_H_psi_array(i) *delta_e diff --git a/src/Perturbation/NEEDED_MODULES b/src/Perturbation/NEEDED_MODULES index 0a999882..5c4f779c 100644 --- a/src/Perturbation/NEEDED_MODULES +++ b/src/Perturbation/NEEDED_MODULES @@ -1 +1 @@ -AOs BiInts Bitmask Dets Electrons Ezfio_files Hartree_Fock MonoInts MOs Nuclei Output Utils SingleRefMethod +AOs BiInts Bitmask Dets Electrons Ezfio_files Hartree_Fock MonoInts MOs Nuclei Output Utils diff --git a/src/Perturbation/README.rst b/src/Perturbation/README.rst index 1b0f8697..0e910cdd 100644 --- a/src/Perturbation/README.rst +++ b/src/Perturbation/README.rst @@ -182,36 +182,33 @@ Documentation NOTE :::: if you satisfy Brillouin Theorem, the singles don't contribute !! .br -`cisd `_ - Undocumented - -`fill_h_apply_buffer_selection `_ +`fill_h_apply_buffer_selection `_ Fill the H_apply buffer with determiants for the selection -`remove_small_contributions `_ +`n_det_selectors `_ + Undocumented + +`psi_selectors `_ + On what we apply for perturbation. If selection, it may be 0.9 of the norm. + +`psi_selectors_coef `_ + On what we apply for perturbation. If selection, it may be 0.9 of the norm. + +`psi_selectors_size `_ + Undocumented + +`remove_small_contributions `_ Remove determinants with small contributions -`selection_criterion `_ +`selection_criterion `_ Threshold to select determinants. Set by selection routines. -`selection_criterion_factor `_ +`selection_criterion_factor `_ Threshold to select determinants. Set by selection routines. -`selection_criterion_min `_ +`selection_criterion_min `_ Threshold to select determinants. Set by selection routines. -`n_det_ref `_ - Undocumented - -`psi_ref `_ - On what we apply for perturbation. If selection, it may be 0.9 of the norm. - -`psi_ref_coef `_ - On what we apply for perturbation. If selection, it may be 0.9 of the norm. - -`psi_ref_size `_ - Undocumented - Needed Modules @@ -232,5 +229,4 @@ Needed Modules * `Nuclei `_ * `Output `_ * `Utils `_ -* `SingleRefMethod `_ diff --git a/src/Perturbation/epstein_nesbet.irp.f b/src/Perturbation/epstein_nesbet.irp.f index 256bf043..b609cd02 100644 --- a/src/Perturbation/epstein_nesbet.irp.f +++ b/src/Perturbation/epstein_nesbet.irp.f @@ -21,17 +21,17 @@ subroutine pt2_epstein_nesbet(det_pert,c_pert,e_2_pert,H_pert_diag,Nint,ndet,n_s double precision :: diag_H_mat_elem ASSERT (Nint == N_int) ASSERT (Nint > 0) - call i_H_psi(det_pert,psi_ref,psi_ref_coef,Nint,ndet,psi_ref_size,n_st,i_H_psi_array) + call i_H_psi(det_pert,psi_selectors,psi_selectors_coef,Nint,N_det_selectors,psi_selectors_size,N_st,i_H_psi_array) H_pert_diag = diag_H_mat_elem(det_pert,Nint) - if (dabs(CI_electronic_energy(i) - H_pert_diag) > 1.d-6) then - do i =1,n_st - c_pert(i) = i_H_psi_array(i) / (CI_electronic_energy(i) - H_pert_diag) - e_2_pert(i) = c_pert(i) * i_H_psi_array(i) - enddo - else - c_pert = 0.d0 - e_2_pert = 0.d0 - endif + do i =1,n_st + if (dabs(CI_electronic_energy(i) - H_pert_diag) > 1.d-6) then + c_pert(i) = i_H_psi_array(i) / (CI_electronic_energy(i) - H_pert_diag) + e_2_pert(i) = c_pert(i) * i_H_psi_array(i) + else + c_pert(i) = 0.d0 + e_2_pert(i) = 0.d0 + endif + enddo end @@ -58,7 +58,7 @@ subroutine pt2_epstein_nesbet_2x2(det_pert,c_pert,e_2_pert,H_pert_diag,Nint,ndet double precision :: diag_H_mat_elem,delta_e ASSERT (Nint == N_int) ASSERT (Nint > 0) - call i_H_psi(det_pert,psi_ref,psi_ref_coef,Nint,N_det_ref,psi_ref_size,n_st,i_H_psi_array) + call i_H_psi(det_pert,psi_selectors,psi_selectors_coef,Nint,N_det_selectors,psi_selectors_size,n_st,i_H_psi_array) H_pert_diag = diag_H_mat_elem(det_pert,Nint) do i =1,n_st delta_e = H_pert_diag - CI_electronic_energy(i) @@ -108,13 +108,13 @@ subroutine pt2_epstein_nesbet_SC2(det_pert,c_pert,e_2_pert,H_pert_diag,Nint,ndet double precision :: diag_H_mat_elem,accu_e_corr,hij ASSERT (Nint == N_int) ASSERT (Nint > 0) - call i_H_psi_SC2(det_pert,psi_ref,psi_ref_coef,Nint,ndet,psi_ref_size,n_st,i_H_psi_array,idx_repeat) + call i_H_psi_SC2(det_pert,psi_selectors,psi_selectors_coef,Nint,N_det_selectors,psi_selectors_size,n_st,i_H_psi_array,idx_repeat) accu_e_corr = 0.d0 do i = 1, idx_repeat(0) - call i_H_j(psi_ref(1,1,idx_repeat(i)),det_pert,Nint,hij) - accu_e_corr = accu_e_corr + hij * psi_ref_coef(idx_repeat(i),1) + call i_H_j(psi_selectors(1,1,idx_repeat(i)),det_pert,Nint,hij) + accu_e_corr = accu_e_corr + hij * psi_selectors_coef(idx_repeat(i),1) enddo - accu_e_corr = accu_e_corr / psi_ref_coef(1,1) + accu_e_corr = accu_e_corr / psi_selectors_coef(1,1) H_pert_diag = diag_H_mat_elem(det_pert,Nint) + accu_e_corr do i =1,n_st e_2_pert(i) = c_pert(i) * i_H_psi_array(i) @@ -162,13 +162,13 @@ subroutine pt2_epstein_nesbet_2x2_SC2(det_pert,c_pert,e_2_pert,H_pert_diag,Nint, double precision :: diag_H_mat_elem,accu_e_corr,hij,delta_e ASSERT (Nint == N_int) ASSERT (Nint > 0) - call i_H_psi_SC2(det_pert,psi_ref,psi_ref_coef,Nint,ndet,psi_ref_size,n_st,i_H_psi_array,idx_repeat) + call i_H_psi_SC2(det_pert,psi_selectors,psi_selectors_coef,Nint,N_det_selectors,psi_selectors_size,n_st,i_H_psi_array,idx_repeat) accu_e_corr = 0.d0 do i = 1, idx_repeat(0) - call i_H_j(psi_ref(1,1,idx_repeat(i)),det_pert,Nint,hij) - accu_e_corr = accu_e_corr + hij * psi_ref_coef(idx_repeat(i),1) + call i_H_j(psi_selectors(1,1,idx_repeat(i)),det_pert,Nint,hij) + accu_e_corr = accu_e_corr + hij * psi_selectors_coef(idx_repeat(i),1) enddo - accu_e_corr = accu_e_corr / psi_ref_coef(1,1) + accu_e_corr = accu_e_corr / psi_selectors_coef(1,1) H_pert_diag = diag_H_mat_elem(det_pert,Nint) + accu_e_corr do i =1,n_st delta_e = H_pert_diag - CI_electronic_energy(i) @@ -222,17 +222,17 @@ subroutine pt2_epstein_nesbet_SC2_projected(det_pert,c_pert,e_2_pert,H_pert_diag double precision :: diag_H_mat_elem,accu_e_corr,hij,h0j ASSERT (Nint == N_int) ASSERT (Nint > 0) - call i_H_psi_SC2(det_pert,psi_ref,psi_ref_coef,Nint,ndet,psi_ref_size,n_st,i_H_psi_array,idx_repeat) + call i_H_psi_SC2(det_pert,psi_selectors,psi_selectors_coef,Nint,N_det_selectors,psi_selectors_size,n_st,i_H_psi_array,idx_repeat) accu_e_corr = 0.d0 call i_H_j(ref_bitmask,det_pert,Nint,h0j) do i = 1, idx_repeat(0) - call i_H_j(psi_ref(1,1,idx_repeat(i)),det_pert,Nint,hij) - accu_e_corr = accu_e_corr + hij * psi_ref_coef(idx_repeat(i),1) + call i_H_j(psi_selectors(1,1,idx_repeat(i)),det_pert,Nint,hij) + accu_e_corr = accu_e_corr + hij * psi_selectors_coef(idx_repeat(i),1) enddo - accu_e_corr = accu_e_corr / psi_ref_coef(1,1) + accu_e_corr = accu_e_corr / psi_selectors_coef(1,1) H_pert_diag = diag_H_mat_elem(det_pert,Nint) + accu_e_corr - c_pert(1) = 1.d0/psi_ref_coef(1,1) * i_H_psi_array(1) / (CI_electronic_energy(i) - H_pert_diag) + c_pert(1) = 1.d0/psi_selectors_coef(1,1) * i_H_psi_array(1) / (CI_electronic_energy(i) - H_pert_diag) e_2_pert(1) = c_pert(i) * h0j do i =2,n_st if (dabs(CI_electronic_energy(i) - H_pert_diag) > 1.d-6) then diff --git a/src/Perturbation/h_apply.py b/src/Perturbation/h_apply.py deleted file mode 100755 index 4b1b8e61..00000000 --- a/src/Perturbation/h_apply.py +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env python - -from generate_h_apply import * - -s = H_apply("cisd_pt2",openmp=True) -#s.set_perturbation("epstein_nesbet_2x2") -s.set_perturbation("epstein_nesbet") -#s["keys_work"] += """ -#call fill_H_apply_buffer_cisd(key_idx,keys_out,N_int) -#""" -print s - - -s = H_apply("cisd_selection",openmp=True) -s.set_selection_pt2("epstein_nesbet_2x2") -print s diff --git a/src/Perturbation/perturbation_template.f b/src/Perturbation/perturbation_template.f index ebcb3048..55aa7f56 100644 --- a/src/Perturbation/perturbation_template.f +++ b/src/Perturbation/perturbation_template.f @@ -2,14 +2,14 @@ BEGIN_SHELL [ /usr/bin/env python ] import perturbation END_SHELL -subroutine perturb_buffer_$PERT(buffer,buffer_size,e_2_pert_buffer,coef_pert_buffer,sum_e_2_pert,sum_norm_pert,sum_H_pert_diag,N_st,Nint) +subroutine perturb_buffer_$PERT(i_generator,buffer,buffer_size,e_2_pert_buffer,coef_pert_buffer,sum_e_2_pert,sum_norm_pert,sum_H_pert_diag,N_st,Nint) implicit none BEGIN_DOC ! Applly pertubration ``$PERT`` to the buffer of determinants generated in the H_apply ! routine. END_DOC - integer, intent(in) :: Nint, N_st, buffer_size + integer, intent(in) :: Nint, N_st, buffer_size, i_generator integer(bit_kind), intent(in) :: buffer(Nint,2,buffer_size) double precision, intent(inout) :: sum_norm_pert(N_st),sum_e_2_pert(N_st) double precision, intent(inout) :: coef_pert_buffer(N_st,buffer_size),e_2_pert_buffer(N_st,buffer_size),sum_H_pert_diag(N_st) @@ -24,14 +24,14 @@ subroutine perturb_buffer_$PERT(buffer,buffer_size,e_2_pert_buffer,coef_pert_buf ASSERT (N_st > 0) do i = 1,buffer_size - c_ref = connected_to_ref(buffer(1,1,i),psi_det,Nint,N_det_generators,N_det_reference,h_apply_threshold) + c_ref = connected_to_ref(buffer(1,1,i),psi_generators,Nint,i_generator,N_det,h_apply_threshold) if (c_ref /= 0) then cycle endif call pt2_$PERT(buffer(1,1,i), & - c_pert,e_2_pert,H_pert_diag,Nint,n_det_ref,n_st) + c_pert,e_2_pert,H_pert_diag,Nint,N_det_selectors,n_st) do k = 1,N_st e_2_pert_buffer(k,i) = e_2_pert(k) diff --git a/src/Perturbation/perturbation_test.irp.f b/src/Perturbation/perturbation_test.irp.f deleted file mode 100644 index 2d67e10e..00000000 --- a/src/Perturbation/perturbation_test.irp.f +++ /dev/null @@ -1,16 +0,0 @@ -program cisd - implicit none - integer :: i,k - double precision, allocatable :: eigvalues(:),eigvectors(:,:) - double precision, allocatable :: pt2(:), norm_pert(:) - double precision :: H_pert_diag - integer :: N_st - N_st = N_states - allocate (pt2(N_st), norm_pert(N_st)) - - call H_apply_cisd_pt2(pt2, norm_pert, H_pert_diag, N_st) - print *, 'N_det = ', N_det - print *, 'pt2 = ', pt2(1) - print *, 'E = ', CI_energy(1)+pt2(1) - return -end diff --git a/src/Perturbation/selection.irp.f b/src/Perturbation/selection.irp.f index 14d452cb..25f6cf37 100644 --- a/src/Perturbation/selection.irp.f +++ b/src/Perturbation/selection.irp.f @@ -110,3 +110,7 @@ subroutine remove_small_contributions call write_int(output_dets,N_removed, 'Removed determinants') endif end + + + + diff --git a/src/Perturbation/temporary_stuff.irp.f b/src/Perturbation/temporary_stuff.irp.f deleted file mode 100644 index 019a0f5b..00000000 --- a/src/Perturbation/temporary_stuff.irp.f +++ /dev/null @@ -1,37 +0,0 @@ -use bitmasks -BEGIN_SHELL [ /bin/bash ] -./h_apply.py -END_SHELL - - -BEGIN_PROVIDER [ integer, psi_ref_size ] - implicit none - psi_ref_size = psi_det_size -END_PROVIDER -BEGIN_PROVIDER [ integer, N_det_ref] - implicit none - N_det_ref = N_det -END_PROVIDER - - BEGIN_PROVIDER [ integer(bit_kind), psi_ref, (N_int,2,psi_ref_size) ] -&BEGIN_PROVIDER [ double precision, psi_ref_coef, (psi_ref_size,N_states) ] - implicit none - BEGIN_DOC - ! On what we apply for perturbation. If selection, it may be 0.9 of the norm. - END_DOC - integer :: i,k - - do i=1,N_det_ref - do k=1,N_int - psi_ref(k,1,i) = psi_det(k,1,i) - psi_ref(k,2,i) = psi_det(k,2,i) - enddo - enddo - do k=1,N_states - do i=1,N_det_ref - psi_ref_coef(i,k) = psi_coef(i,k) - enddo - enddo -END_PROVIDER - - diff --git a/src/Selectors_full/ASSUMPTIONS.rst b/src/Selectors_full/ASSUMPTIONS.rst new file mode 100644 index 00000000..e69de29b diff --git a/src/Selectors_full/Makefile b/src/Selectors_full/Makefile new file mode 100644 index 00000000..b2ea1de1 --- /dev/null +++ b/src/Selectors_full/Makefile @@ -0,0 +1,8 @@ +default: all + +# Define here all new external source files and objects.Don't forget to prefix the +# object files with IRPF90_temp/ +SRC= +OBJ= + +include $(QPACKAGE_ROOT)/src/Makefile.common diff --git a/src/Selectors_full/NEEDED_MODULES b/src/Selectors_full/NEEDED_MODULES new file mode 100644 index 00000000..f6551dd9 --- /dev/null +++ b/src/Selectors_full/NEEDED_MODULES @@ -0,0 +1 @@ +AOs BiInts Bitmask Dets Electrons Ezfio_files Hartree_Fock MonoInts MOs Nuclei Output Utils diff --git a/src/Selectors_full/README.rst b/src/Selectors_full/README.rst new file mode 100644 index 00000000..31bba35f --- /dev/null +++ b/src/Selectors_full/README.rst @@ -0,0 +1,4 @@ +===================== +Selectors_full Module +===================== + diff --git a/src/Selectors_full/selectors.irp.f b/src/Selectors_full/selectors.irp.f new file mode 100644 index 00000000..8f963f0d --- /dev/null +++ b/src/Selectors_full/selectors.irp.f @@ -0,0 +1,32 @@ +use bitmasks + +BEGIN_PROVIDER [ integer, psi_selectors_size ] + implicit none + psi_selectors_size = psi_det_size +END_PROVIDER +BEGIN_PROVIDER [ integer, N_det_selectors] + implicit none + N_det_selectors = N_det +END_PROVIDER + + BEGIN_PROVIDER [ integer(bit_kind), psi_selectors, (N_int,2,psi_selectors_size) ] +&BEGIN_PROVIDER [ double precision, psi_selectors_coef, (psi_selectors_size,N_states) ] + implicit none + BEGIN_DOC + ! On what we apply for perturbation. If selection, it may be 0.9 of the norm. + END_DOC + integer :: i,k + + do i=1,N_det_selectors + do k=1,N_int + psi_selectors(k,1,i) = psi_det(k,1,i) + psi_selectors(k,2,i) = psi_det(k,2,i) + enddo + enddo + do k=1,N_states + do i=1,N_det_selectors + psi_selectors_coef(i,k) = psi_coef(i,k) + enddo + enddo +END_PROVIDER + diff --git a/src/Selectors_full/tests/Makefile b/src/Selectors_full/tests/Makefile new file mode 100644 index 00000000..77bd84ba --- /dev/null +++ b/src/Selectors_full/tests/Makefile @@ -0,0 +1,33 @@ +OPENMP =1 +PROFILE =0 +DEBUG = 0 + +IRPF90+= -I tests + +REF_FILES=$(subst %.irp.f, %.ref, $(wildcard *.irp.f)) + +.PHONY: clean executables serial_tests parallel_tests + +all: clean executables serial_tests parallel_tests + +parallel_tests: $(REF_FILES) + @echo ; echo " ---- Running parallel tests ----" ; echo + @OMP_NUM_THREADS=10 ${QPACKAGE_ROOT}/scripts/run_tests.py + +serial_tests: $(REF_FILES) + @echo ; echo " ---- Running serial tests ----" ; echo + @OMP_NUM_THREADS=1 ${QPACKAGE_ROOT}/scripts/run_tests.py + +executables: $(wildcard *.irp.f) veryclean + $(MAKE) -C .. + +%.ref: $(wildcard $(QPACKAGE_ROOT)/data/inputs/*.md5) executables + $(QPACKAGE_ROOT)/scripts/create_test_ref.sh $* + +clean: + $(MAKE) -C .. clean + +veryclean: + $(MAKE) -C .. veryclean + + diff --git a/src/SingleRefMethod/generators.irp.f b/src/SingleRefMethod/generators.irp.f index bee8f4b8..0edd6175 100644 --- a/src/SingleRefMethod/generators.irp.f +++ b/src/SingleRefMethod/generators.irp.f @@ -9,20 +9,35 @@ BEGIN_PROVIDER [ integer, N_det_generators ] N_det_generators = 1 END_PROVIDER -BEGIN_PROVIDER [ integer(bit_kind), psi_generators, (N_int,2,1) ] +BEGIN_PROVIDER [ integer(bit_kind), psi_generators, (N_int,2,psi_det_size) ] implicit none BEGIN_DOC ! For Single reference wave functions, the generator is the ! Hartree-Fock determinant END_DOC psi_generators = 0_bit_kind - integer :: i + integer :: i,j,k + integer :: degree do i=1,N_int psi_generators(i,1,1) = HF_bitmask(i,1) psi_generators(i,2,1) = HF_bitmask(i,2) enddo + do j=1,N_det + call get_excitation_degree(HF_bitmask,psi_det(1,1,j),degree,N_int) + if (degree == 0) then + k = j + endif + end do + + do j=2,k + psi_generators(:,:,j) = psi_det(:,:,j-1) + enddo + do j=k+1,N_det + psi_generators(:,:,j) = psi_det(:,:,j) + enddo + END_PROVIDER