From 487ec77613d0a1de7ee5565ac4097a620d99f7cd Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 2 Mar 2015 13:58:00 +0100 Subject: [PATCH] Added CAS_SD and generators_CAS --- src/CAS_SD_selected/H_apply.irp.f | 14 +++++ src/CAS_SD_selected/Makefile | 8 +++ src/CAS_SD_selected/NEEDED_MODULES | 1 + src/CAS_SD_selected/cas_sd.irp.f | 57 ++++++++++++++++++++ src/CAS_SD_selected/options.irp.f | 32 +++++++++++ src/Generators_CAS/ASSUMPTIONS.rst | 1 + src/Generators_CAS/Makefile | 8 +++ src/Generators_CAS/NEEDED_MODULES | 1 + src/Generators_CAS/README.rst | 5 ++ src/Generators_CAS/generators.irp.f | 84 +++++++++++++++++++++++++++++ 10 files changed, 211 insertions(+) create mode 100644 src/CAS_SD_selected/H_apply.irp.f create mode 100644 src/CAS_SD_selected/Makefile create mode 100644 src/CAS_SD_selected/NEEDED_MODULES create mode 100644 src/CAS_SD_selected/cas_sd.irp.f create mode 100644 src/CAS_SD_selected/options.irp.f create mode 100644 src/Generators_CAS/ASSUMPTIONS.rst create mode 100644 src/Generators_CAS/Makefile create mode 100644 src/Generators_CAS/NEEDED_MODULES create mode 100644 src/Generators_CAS/README.rst create mode 100644 src/Generators_CAS/generators.irp.f diff --git a/src/CAS_SD_selected/H_apply.irp.f b/src/CAS_SD_selected/H_apply.irp.f new file mode 100644 index 00000000..76c046ae --- /dev/null +++ b/src/CAS_SD_selected/H_apply.irp.f @@ -0,0 +1,14 @@ +use bitmasks +BEGIN_SHELL [ /usr/bin/env python ] +from generate_h_apply import * + +s = H_apply("FCI") +s.set_selection_pt2("epstein_nesbet_2x2") +print s + +s = H_apply("FCI_PT2") +s.set_perturbation("epstein_nesbet_2x2") +print s + +END_SHELL + diff --git a/src/CAS_SD_selected/Makefile b/src/CAS_SD_selected/Makefile new file mode 100644 index 00000000..b2ea1de1 --- /dev/null +++ b/src/CAS_SD_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/CAS_SD_selected/NEEDED_MODULES b/src/CAS_SD_selected/NEEDED_MODULES new file mode 100644 index 00000000..c24125e8 --- /dev/null +++ b/src/CAS_SD_selected/NEEDED_MODULES @@ -0,0 +1 @@ +AOs BiInts Bitmask Dets Electrons Ezfio_files Generators_CAS Hartree_Fock MOGuess MonoInts MOs Nuclei Output Perturbation Selectors_full Utils diff --git a/src/CAS_SD_selected/cas_sd.irp.f b/src/CAS_SD_selected/cas_sd.irp.f new file mode 100644 index 00000000..e3a8f6ec --- /dev/null +++ b/src/CAS_SD_selected/cas_sd.irp.f @@ -0,0 +1,57 @@ +program full_ci + implicit none + integer :: i,k + + + double precision, allocatable :: pt2(:), norm_pert(:), H_pert_diag(:) + integer :: N_st, degree + N_st = N_states + allocate (pt2(N_st), norm_pert(N_st),H_pert_diag(N_st)) + character*(64) :: perturbation + + pt2 = 1.d0 + diag_algorithm = "Lapack" + if (N_det > n_det_max_fci) then + call diagonalize_CI + call save_wavefunction + psi_det = psi_det_sorted + psi_coef = psi_coef_sorted + N_det = n_det_max_fci + soft_touch N_det psi_det psi_coef + call diagonalize_CI + call save_wavefunction + print *, 'N_det = ', N_det + print *, 'N_states = ', N_states + print *, 'PT2 = ', pt2 + print *, 'E = ', CI_energy + print *, 'E+PT2 = ', CI_energy+pt2 + print *, '-----' + endif + + do while (N_det < n_det_max_fci.and.maxval(abs(pt2(1:N_st))) > pt2_max) + call H_apply_FCI(pt2, norm_pert, H_pert_diag, N_st) + + PROVIDE psi_coef + PROVIDE psi_det + PROVIDE psi_det_sorted + + if (N_det > n_det_max_fci) then + psi_det = psi_det_sorted + psi_coef = psi_coef_sorted + N_det = n_det_max_fci + soft_touch N_det psi_det psi_coef + endif + call diagonalize_CI + call save_wavefunction + print *, 'N_det = ', N_det + print *, 'N_states = ', N_states + print *, 'PT2 = ', pt2 + print *, 'E = ', CI_energy + print *, 'E+PT2 = ', CI_energy+pt2 + print *, '-----' + call ezfio_set_full_ci_energy(CI_energy) + if (abort_all) then + exit + endif + enddo +end diff --git a/src/CAS_SD_selected/options.irp.f b/src/CAS_SD_selected/options.irp.f new file mode 100644 index 00000000..553fbe9f --- /dev/null +++ b/src/CAS_SD_selected/options.irp.f @@ -0,0 +1,32 @@ +BEGIN_SHELL [ /usr/bin/python ] +from ezfio_with_default import EZFIO_Provider +T = EZFIO_Provider() +T.set_type ( "integer" ) +T.set_name ( "N_det_max_fci" ) +T.set_doc ( "Max number of determinants in the wave function" ) +T.set_ezfio_dir ( "full_ci" ) +T.set_ezfio_name( "N_det_max_fci" ) +T.set_output ( "output_full_ci" ) +print T + +T.set_type ( "logical" ) +T.set_name ( "do_pt2_end" ) +T.set_doc ( "If true, compute the PT2 at the end of the selection" ) +T.set_ezfio_name( "do_pt2_end" ) +print T + +T.set_type ( "double precision" ) +T.set_name ( "pt2_max" ) +T.set_doc ( """The selection process stops when the largest PT2 (for all the states) +is lower than pt2_max in absolute value""" ) +T.set_ezfio_name( "pt2_max" ) +print T + +T.set_type ( "double precision" ) +T.set_name ( "var_pt2_ratio" ) +T.set_doc ( """The selection process stops when the energy ratio variational/(variational+PT2) +is equal to var_pt2_ratio""" ) +T.set_ezfio_name( "var_pt2_ratio" ) +print T +END_SHELL + diff --git a/src/Generators_CAS/ASSUMPTIONS.rst b/src/Generators_CAS/ASSUMPTIONS.rst new file mode 100644 index 00000000..f1a09bde --- /dev/null +++ b/src/Generators_CAS/ASSUMPTIONS.rst @@ -0,0 +1 @@ +The active space is defined by the ``reference_bitmask``. diff --git a/src/Generators_CAS/Makefile b/src/Generators_CAS/Makefile new file mode 100644 index 00000000..b2ea1de1 --- /dev/null +++ b/src/Generators_CAS/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/Generators_CAS/NEEDED_MODULES b/src/Generators_CAS/NEEDED_MODULES new file mode 100644 index 00000000..26097b8b --- /dev/null +++ b/src/Generators_CAS/NEEDED_MODULES @@ -0,0 +1 @@ +AOs BiInts Bitmask Dets Electrons Ezfio_files MonoInts MOs Nuclei Output Utils diff --git a/src/Generators_CAS/README.rst b/src/Generators_CAS/README.rst new file mode 100644 index 00000000..06db0139 --- /dev/null +++ b/src/Generators_CAS/README.rst @@ -0,0 +1,5 @@ +===================== +Generators_CAS Module +===================== + +The generator determinants are those filtered by the ``cas_bitmask`` mask. diff --git a/src/Generators_CAS/generators.irp.f b/src/Generators_CAS/generators.irp.f new file mode 100644 index 00000000..f014cc00 --- /dev/null +++ b/src/Generators_CAS/generators.irp.f @@ -0,0 +1,84 @@ +use bitmasks + +BEGIN_PROVIDER [ integer, N_det_generators ] + implicit none + BEGIN_DOC + ! Number of generator detetrminants + END_DOC + integer :: i,k,l + logical :: good + call write_time(output_dets) + N_det_generators = 0 + do i=1,N_det + do l=1,n_cas_bitmask + good = .True. + do k=1,N_int + good = good .and. ( & + iand(not(cas_bitmask(k,1,l)), psi_det(k,1,i)) == & + iand(not(cas_bitmask(k,1,l)), psi_det(k,1,1)) ) .and. ( & + iand(not(cas_bitmask(k,2,l)), psi_det(k,2,i)) == & + iand(not(cas_bitmask(k,2,l)), psi_det(k,2,1)) ) + enddo + if (good) then + exit + endif + enddo + if (good) then + N_det_generators += 1 + endif + enddo + N_det_generators = max(N_det_generators,1) + call write_int(output_dets,N_det_generators,'Number of generators') +END_PROVIDER + +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 + integer :: i, k, l, m + logical :: good + m=0 + do i=1,N_det + do l=1,n_cas_bitmask + good = .True. + do k=1,N_int + good = good .and. ( & + iand(not(cas_bitmask(k,1,l)), psi_det(k,1,i)) == & + iand(not(cas_bitmask(k,1,l)), psi_det(k,1,1)) ) .and. ( & + iand(not(cas_bitmask(k,2,l)), psi_det(k,2,i)) == & + iand(not(cas_bitmask(k,2,l)), psi_det(k,2,1)) ) + enddo + if (good) then + exit + endif + enddo + if (good) then + m = m+1 + do k=1,N_int + psi_generators(k,1,m) = psi_det(k,1,i) + psi_generators(k,2,m) = psi_det(k,2,i) + enddo + call debug_det(psi_generators(1,1,m),N_int) + endif + enddo + +END_PROVIDER + +BEGIN_PROVIDER [ integer, size_select_max] + implicit none + BEGIN_DOC + ! Size of the select_max array + END_DOC + size_select_max = 10000 +END_PROVIDER + +BEGIN_PROVIDER [ double precision, select_max, (size_select_max) ] + implicit none + BEGIN_DOC + ! Memo to skip useless selectors + END_DOC + select_max = huge(1.d0) +END_PROVIDER +