diff --git a/configure b/configure index e87badbb..fa207f6e 100755 --- a/configure +++ b/configure @@ -71,7 +71,7 @@ from collections import namedtuple Info = namedtuple("Info", ["url", "description", "default_path"]) -path_github = {"head": "http://github.com/", "tail": "archive/master.tar.gz"} +path_github = {"head": "http://github.com", "tail": "archive/master.tar.gz"} ocaml = Info( url='http://raw.github.com/ocaml/opam/master/shell/opam_installer.sh', @@ -180,6 +180,8 @@ def check_output(*popenargs, **kwargs): cmd = popenargs[0] error = subprocess.CalledProcessError(retcode, cmd) error.output = output +# print output +# print unused_err raise error return output @@ -224,7 +226,7 @@ def checking(d_dependency): return a - except subprocess.CalledProcessError: + except (OSError,subprocess.CalledProcessError): default_path = d_info[binary].default_path if os.path.exists(default_path): return default_path @@ -341,9 +343,9 @@ _|_ | | _> |_ (_| | | (_| |_ | (_) | | extension = splitext(url)[1] path_archive = "Downloads/{0}{1}".format("ninja", extension) - l_cmd = ["cd install &&", - "wget {0} -O {1} -o /dev/null &&".format(url, path_archive), - "./scripts/install_ninja.sh 2> /dev/null &&", "cd -"] + l_cmd = ["set -x ;", "cd install &&", + "wget {0} -O {1} &&".format(url, path_archive), + "./scripts/install_ninja.sh &&", "cd -"] try: check_output(" ".join(l_cmd), shell=True) @@ -497,7 +499,7 @@ def recommendation(): print "Now :" print " source {0}".format(path) print " ninja" - print " cd ocaml; make " + print " make -C ocaml" print "" print "PS : For more info on compiling the code, read the COMPILE_RUN.md file." diff --git a/ocaml/qp_create_ezfio_from_xyz.ml b/ocaml/qp_create_ezfio_from_xyz.ml index 538c5f63..544e6e09 100644 --- a/ocaml/qp_create_ezfio_from_xyz.ml +++ b/ocaml/qp_create_ezfio_from_xyz.ml @@ -14,7 +14,7 @@ let spec = +> flag "m" (optional_with_default 1 int) ~doc:"int Spin multiplicity (2S+1) of the molecule. Default is 1." +> flag "p" no_arg - ~doc:"Using pseudopotentials" + ~doc:" Using pseudopotentials" +> anon ("xyz_file" %: string) ;; diff --git a/plugins/CAS_SD/README.rst b/plugins/CAS_SD/README.rst index 82bc3032..63836195 100644 --- a/plugins/CAS_SD/README.rst +++ b/plugins/CAS_SD/README.rst @@ -17,7 +17,7 @@ Documentation Undocumented -`h_apply_cas_sd `_ +`h_apply_cas_sd `_ Calls H_apply on the HF determinant and selects all connected single and double excitations (of the same symmetry). Auto-generated by the ``generate_h_apply`` script. @@ -28,58 +28,58 @@ Documentation Assume N_int is already provided. -`h_apply_cas_sd_monoexc `_ +`h_apply_cas_sd_monoexc `_ Generate all single excitations of key_in using the bit masks of holes and particles. Assume N_int is already provided. -`h_apply_cas_sd_pt2 `_ +`h_apply_cas_sd_pt2 `_ Calls H_apply on the HF determinant and selects all connected single and double excitations (of the same symmetry). Auto-generated by the ``generate_h_apply`` script. -`h_apply_cas_sd_pt2_diexc `_ +`h_apply_cas_sd_pt2_diexc `_ Generate all double excitations of key_in using the bit masks of holes and particles. Assume N_int is already provided. -`h_apply_cas_sd_pt2_monoexc `_ +`h_apply_cas_sd_pt2_monoexc `_ Generate all single excitations of key_in using the bit masks of holes and particles. Assume N_int is already provided. -`h_apply_cas_sd_selected `_ +`h_apply_cas_sd_selected `_ Calls H_apply on the HF determinant and selects all connected single and double excitations (of the same symmetry). Auto-generated by the ``generate_h_apply`` script. -`h_apply_cas_sd_selected_diexc `_ +`h_apply_cas_sd_selected_diexc `_ Generate all double excitations of key_in using the bit masks of holes and particles. Assume N_int is already provided. -`h_apply_cas_sd_selected_monoexc `_ +`h_apply_cas_sd_selected_monoexc `_ Generate all single excitations of key_in using the bit masks of holes and particles. Assume N_int is already provided. -`h_apply_cas_sd_selected_no_skip `_ +`h_apply_cas_sd_selected_no_skip `_ Calls H_apply on the HF determinant and selects all connected single and double excitations (of the same symmetry). Auto-generated by the ``generate_h_apply`` script. -`h_apply_cas_sd_selected_no_skip_diexc `_ +`h_apply_cas_sd_selected_no_skip_diexc `_ Generate all double excitations of key_in using the bit masks of holes and particles. Assume N_int is already provided. -`h_apply_cas_sd_selected_no_skip_monoexc `_ +`h_apply_cas_sd_selected_no_skip_monoexc `_ Generate all single excitations of key_in using the bit masks of holes and particles. Assume N_int is already provided. diff --git a/plugins/CIS/README.rst b/plugins/CIS/README.rst index e35aa940..008675e0 100644 --- a/plugins/CIS/README.rst +++ b/plugins/CIS/README.rst @@ -17,7 +17,7 @@ Documentation Undocumented -`h_apply_cis `_ +`h_apply_cis `_ Calls H_apply on the HF determinant and selects all connected single and double excitations (of the same symmetry). Auto-generated by the ``generate_h_apply`` script. @@ -28,7 +28,7 @@ Documentation Assume N_int is already provided. -`h_apply_cis_monoexc `_ +`h_apply_cis_monoexc `_ Generate all single excitations of key_in using the bit masks of holes and particles. Assume N_int is already provided. diff --git a/plugins/CIS/cis.irp.f b/plugins/CIS/cis.irp.f index 4859c0d1..f99b72ef 100644 --- a/plugins/CIS/cis.irp.f +++ b/plugins/CIS/cis.irp.f @@ -2,8 +2,8 @@ program cis implicit none integer :: i - print *, 'HF = ', HF_energy - print *, 'N_states = ', N_states +! print *, 'HF = ', HF_energy +! print *, 'N_states = ', N_states call H_apply_cis print *, 'N_det = ', N_det do i = 1,N_states diff --git a/plugins/CIS/tree_dependency.png b/plugins/CIS/tree_dependency.png index 36856095..d9ee1876 100644 Binary files a/plugins/CIS/tree_dependency.png and b/plugins/CIS/tree_dependency.png differ diff --git a/plugins/CISD/README.rst b/plugins/CISD/README.rst index a3168310..2ba297fb 100644 --- a/plugins/CISD/README.rst +++ b/plugins/CISD/README.rst @@ -26,7 +26,7 @@ Documentation .. Do not edit this section. It was auto-generated from the .. by the `update_README.py` script. -`h_apply_cisd `_ +`h_apply_cisd `_ Calls H_apply on the HF determinant and selects all connected single and double excitations (of the same symmetry). Auto-generated by the ``generate_h_apply`` script. @@ -37,164 +37,7 @@ Documentation Assume N_int is already provided. -`h_apply_cisd_monoexc `_ - Generate all single excitations of key_in using the bit masks of holes and - particles. - Assume N_int is already provided. - - -`h_apply_cisd_selection `_ - Undocumented - - -`h_apply_cisd_selection_delta_rho_one_point `_ - Calls H_apply on the HF determinant and selects all connected single and double - excitations (of the same symmetry). Auto-generated by the ``generate_h_apply`` script. - - -`h_apply_cisd_selection_delta_rho_one_point_diexc `_ - Generate all double excitations of key_in using the bit masks of holes and - particles. - Assume N_int is already provided. - - -`h_apply_cisd_selection_delta_rho_one_point_monoexc `_ - Generate all single excitations of key_in using the bit masks of holes and - particles. - Assume N_int is already provided. - - -`h_apply_cisd_selection_dipole_moment_z `_ - Calls H_apply on the HF determinant and selects all connected single and double - excitations (of the same symmetry). Auto-generated by the ``generate_h_apply`` script. - - -`h_apply_cisd_selection_dipole_moment_z_diexc `_ - Generate all double excitations of key_in using the bit masks of holes and - particles. - Assume N_int is already provided. - - -`h_apply_cisd_selection_dipole_moment_z_monoexc `_ - Generate all single excitations of key_in using the bit masks of holes and - particles. - Assume N_int is already provided. - - -`h_apply_cisd_selection_epstein_nesbet `_ - Calls H_apply on the HF determinant and selects all connected single and double - excitations (of the same symmetry). Auto-generated by the ``generate_h_apply`` script. - - -`h_apply_cisd_selection_epstein_nesbet_2x2 `_ - Calls H_apply on the HF determinant and selects all connected single and double - excitations (of the same symmetry). Auto-generated by the ``generate_h_apply`` script. - - -`h_apply_cisd_selection_epstein_nesbet_2x2_diexc `_ - Generate all double excitations of key_in using the bit masks of holes and - particles. - Assume N_int is already provided. - - -`h_apply_cisd_selection_epstein_nesbet_2x2_monoexc `_ - Generate all single excitations of key_in using the bit masks of holes and - particles. - Assume N_int is already provided. - - -`h_apply_cisd_selection_epstein_nesbet_diexc `_ - Generate all double excitations of key_in using the bit masks of holes and - particles. - Assume N_int is already provided. - - -`h_apply_cisd_selection_epstein_nesbet_monoexc `_ - Generate all single excitations of key_in using the bit masks of holes and - particles. - Assume N_int is already provided. - - -`h_apply_cisd_selection_epstein_nesbet_sc2 `_ - Calls H_apply on the HF determinant and selects all connected single and double - excitations (of the same symmetry). Auto-generated by the ``generate_h_apply`` script. - - -`h_apply_cisd_selection_epstein_nesbet_sc2_diexc `_ - Generate all double excitations of key_in using the bit masks of holes and - particles. - Assume N_int is already provided. - - -`h_apply_cisd_selection_epstein_nesbet_sc2_monoexc `_ - Generate all single excitations of key_in using the bit masks of holes and - particles. - Assume N_int is already provided. - - -`h_apply_cisd_selection_epstein_nesbet_sc2_no_projected `_ - Calls H_apply on the HF determinant and selects all connected single and double - excitations (of the same symmetry). Auto-generated by the ``generate_h_apply`` script. - - -`h_apply_cisd_selection_epstein_nesbet_sc2_no_projected_diexc `_ - Generate all double excitations of key_in using the bit masks of holes and - particles. - Assume N_int is already provided. - - -`h_apply_cisd_selection_epstein_nesbet_sc2_no_projected_monoexc `_ - Generate all single excitations of key_in using the bit masks of holes and - particles. - Assume N_int is already provided. - - -`h_apply_cisd_selection_epstein_nesbet_sc2_projected `_ - Calls H_apply on the HF determinant and selects all connected single and double - excitations (of the same symmetry). Auto-generated by the ``generate_h_apply`` script. - - -`h_apply_cisd_selection_epstein_nesbet_sc2_projected_diexc `_ - Generate all double excitations of key_in using the bit masks of holes and - particles. - Assume N_int is already provided. - - -`h_apply_cisd_selection_epstein_nesbet_sc2_projected_monoexc `_ - Generate all single excitations of key_in using the bit masks of holes and - particles. - Assume N_int is already provided. - - -`h_apply_cisd_selection_h_core `_ - Calls H_apply on the HF determinant and selects all connected single and double - excitations (of the same symmetry). Auto-generated by the ``generate_h_apply`` script. - - -`h_apply_cisd_selection_h_core_diexc `_ - Generate all double excitations of key_in using the bit masks of holes and - particles. - Assume N_int is already provided. - - -`h_apply_cisd_selection_h_core_monoexc `_ - Generate all single excitations of key_in using the bit masks of holes and - particles. - Assume N_int is already provided. - - -`h_apply_cisd_selection_moller_plesset `_ - Calls H_apply on the HF determinant and selects all connected single and double - excitations (of the same symmetry). Auto-generated by the ``generate_h_apply`` script. - - -`h_apply_cisd_selection_moller_plesset_diexc `_ - Generate all double excitations of key_in using the bit masks of holes and - particles. - Assume N_int is already provided. - - -`h_apply_cisd_selection_moller_plesset_monoexc `_ +`h_apply_cisd_monoexc `_ Generate all single excitations of key_in using the bit masks of holes and particles. Assume N_int is already provided. diff --git a/plugins/CISD/tree_dependency.png b/plugins/CISD/tree_dependency.png index 63daa410..fcf48831 100644 Binary files a/plugins/CISD/tree_dependency.png and b/plugins/CISD/tree_dependency.png differ diff --git a/plugins/CISD_selected/README.rst b/plugins/CISD_selected/README.rst index 2ac23234..e7a3c5cb 100644 --- a/plugins/CISD_selected/README.rst +++ b/plugins/CISD_selected/README.rst @@ -8,158 +8,162 @@ Documentation .. Do not edit this section. It was auto-generated from the .. by the `update_README.py` script. +`cisd `_ + Undocumented + + `h_apply_cisd_selection `_ Undocumented -`h_apply_cisd_selection_delta_rho_one_point `_ +`h_apply_cisd_selection_delta_rho_one_point `_ Calls H_apply on the HF determinant and selects all connected single and double excitations (of the same symmetry). Auto-generated by the ``generate_h_apply`` script. -`h_apply_cisd_selection_delta_rho_one_point_diexc `_ +`h_apply_cisd_selection_delta_rho_one_point_diexc `_ Generate all double excitations of key_in using the bit masks of holes and particles. Assume N_int is already provided. -`h_apply_cisd_selection_delta_rho_one_point_monoexc `_ +`h_apply_cisd_selection_delta_rho_one_point_monoexc `_ Generate all single excitations of key_in using the bit masks of holes and particles. Assume N_int is already provided. -`h_apply_cisd_selection_dipole_moment_z `_ +`h_apply_cisd_selection_dipole_moment_z `_ Calls H_apply on the HF determinant and selects all connected single and double excitations (of the same symmetry). Auto-generated by the ``generate_h_apply`` script. -`h_apply_cisd_selection_dipole_moment_z_diexc `_ +`h_apply_cisd_selection_dipole_moment_z_diexc `_ Generate all double excitations of key_in using the bit masks of holes and particles. Assume N_int is already provided. -`h_apply_cisd_selection_dipole_moment_z_monoexc `_ +`h_apply_cisd_selection_dipole_moment_z_monoexc `_ Generate all single excitations of key_in using the bit masks of holes and particles. Assume N_int is already provided. -`h_apply_cisd_selection_epstein_nesbet `_ +`h_apply_cisd_selection_epstein_nesbet `_ Calls H_apply on the HF determinant and selects all connected single and double excitations (of the same symmetry). Auto-generated by the ``generate_h_apply`` script. -`h_apply_cisd_selection_epstein_nesbet_2x2 `_ +`h_apply_cisd_selection_epstein_nesbet_2x2 `_ Calls H_apply on the HF determinant and selects all connected single and double excitations (of the same symmetry). Auto-generated by the ``generate_h_apply`` script. -`h_apply_cisd_selection_epstein_nesbet_2x2_diexc `_ +`h_apply_cisd_selection_epstein_nesbet_2x2_diexc `_ Generate all double excitations of key_in using the bit masks of holes and particles. Assume N_int is already provided. -`h_apply_cisd_selection_epstein_nesbet_2x2_monoexc `_ +`h_apply_cisd_selection_epstein_nesbet_2x2_monoexc `_ Generate all single excitations of key_in using the bit masks of holes and particles. Assume N_int is already provided. -`h_apply_cisd_selection_epstein_nesbet_diexc `_ +`h_apply_cisd_selection_epstein_nesbet_diexc `_ Generate all double excitations of key_in using the bit masks of holes and particles. Assume N_int is already provided. -`h_apply_cisd_selection_epstein_nesbet_monoexc `_ +`h_apply_cisd_selection_epstein_nesbet_monoexc `_ Generate all single excitations of key_in using the bit masks of holes and particles. Assume N_int is already provided. -`h_apply_cisd_selection_epstein_nesbet_sc2 `_ +`h_apply_cisd_selection_epstein_nesbet_sc2 `_ Calls H_apply on the HF determinant and selects all connected single and double excitations (of the same symmetry). Auto-generated by the ``generate_h_apply`` script. -`h_apply_cisd_selection_epstein_nesbet_sc2_diexc `_ +`h_apply_cisd_selection_epstein_nesbet_sc2_diexc `_ Generate all double excitations of key_in using the bit masks of holes and particles. Assume N_int is already provided. -`h_apply_cisd_selection_epstein_nesbet_sc2_monoexc `_ +`h_apply_cisd_selection_epstein_nesbet_sc2_monoexc `_ Generate all single excitations of key_in using the bit masks of holes and particles. Assume N_int is already provided. -`h_apply_cisd_selection_epstein_nesbet_sc2_no_projected `_ +`h_apply_cisd_selection_epstein_nesbet_sc2_no_projected `_ Calls H_apply on the HF determinant and selects all connected single and double excitations (of the same symmetry). Auto-generated by the ``generate_h_apply`` script. -`h_apply_cisd_selection_epstein_nesbet_sc2_no_projected_diexc `_ +`h_apply_cisd_selection_epstein_nesbet_sc2_no_projected_diexc `_ Generate all double excitations of key_in using the bit masks of holes and particles. Assume N_int is already provided. -`h_apply_cisd_selection_epstein_nesbet_sc2_no_projected_monoexc `_ +`h_apply_cisd_selection_epstein_nesbet_sc2_no_projected_monoexc `_ Generate all single excitations of key_in using the bit masks of holes and particles. Assume N_int is already provided. -`h_apply_cisd_selection_epstein_nesbet_sc2_projected `_ +`h_apply_cisd_selection_epstein_nesbet_sc2_projected `_ Calls H_apply on the HF determinant and selects all connected single and double excitations (of the same symmetry). Auto-generated by the ``generate_h_apply`` script. -`h_apply_cisd_selection_epstein_nesbet_sc2_projected_diexc `_ +`h_apply_cisd_selection_epstein_nesbet_sc2_projected_diexc `_ Generate all double excitations of key_in using the bit masks of holes and particles. Assume N_int is already provided. -`h_apply_cisd_selection_epstein_nesbet_sc2_projected_monoexc `_ +`h_apply_cisd_selection_epstein_nesbet_sc2_projected_monoexc `_ Generate all single excitations of key_in using the bit masks of holes and particles. Assume N_int is already provided. -`h_apply_cisd_selection_h_core `_ +`h_apply_cisd_selection_h_core `_ Calls H_apply on the HF determinant and selects all connected single and double excitations (of the same symmetry). Auto-generated by the ``generate_h_apply`` script. -`h_apply_cisd_selection_h_core_diexc `_ +`h_apply_cisd_selection_h_core_diexc `_ Generate all double excitations of key_in using the bit masks of holes and particles. Assume N_int is already provided. -`h_apply_cisd_selection_h_core_monoexc `_ +`h_apply_cisd_selection_h_core_monoexc `_ Generate all single excitations of key_in using the bit masks of holes and particles. Assume N_int is already provided. -`h_apply_cisd_selection_moller_plesset `_ +`h_apply_cisd_selection_moller_plesset `_ Calls H_apply on the HF determinant and selects all connected single and double excitations (of the same symmetry). Auto-generated by the ``generate_h_apply`` script. -`h_apply_cisd_selection_moller_plesset_diexc `_ +`h_apply_cisd_selection_moller_plesset_diexc `_ Generate all double excitations of key_in using the bit masks of holes and particles. Assume N_int is already provided. -`h_apply_cisd_selection_moller_plesset_monoexc `_ +`h_apply_cisd_selection_moller_plesset_monoexc `_ Generate all single excitations of key_in using the bit masks of holes and particles. Assume N_int is already provided. diff --git a/plugins/CISD_selected/tree_dependency.png b/plugins/CISD_selected/tree_dependency.png index 9e582bae..4d637043 100644 Binary files a/plugins/CISD_selected/tree_dependency.png and b/plugins/CISD_selected/tree_dependency.png differ diff --git a/plugins/MRCC_Utils/README.rst b/plugins/MRCC_Utils/README.rst index 71392798..c396bae7 100644 --- a/plugins/MRCC_Utils/README.rst +++ b/plugins/MRCC_Utils/README.rst @@ -21,19 +21,19 @@ Documentation .. Do not edit this section. It was auto-generated from the .. by the `update_README.py` script. -`ci_eigenvectors_dressed `_ +`ci_eigenvectors_dressed `_ Eigenvectors/values of the CI matrix -`ci_eigenvectors_s2_dressed `_ +`ci_eigenvectors_s2_dressed `_ Eigenvectors/values of the CI matrix -`ci_electronic_energy_dressed `_ +`ci_electronic_energy_dressed `_ Eigenvectors/values of the CI matrix -`ci_energy_dressed `_ +`ci_energy_dressed `_ N_states lowest eigenvalues of the dressed CI matrix @@ -77,15 +77,15 @@ Documentation Initial guess vectors are not necessarily orthonormal -`delta_ii `_ +`delta_ii `_ Dressing matrix in N_det basis -`delta_ij `_ +`delta_ij `_ Dressing matrix in N_det basis -`diagonalize_ci_dressed `_ +`diagonalize_ci_dressed `_ Replace the coefficients of the CI states by the coefficients of the eigenstates of the CI matrix @@ -94,7 +94,7 @@ Documentation Undocumented -`h_apply_mrcc `_ +`h_apply_mrcc `_ Calls H_apply on the HF determinant and selects all connected single and double excitations (of the same symmetry). Auto-generated by the ``generate_h_apply`` script. @@ -105,13 +105,13 @@ Documentation Assume N_int is already provided. -`h_apply_mrcc_monoexc `_ +`h_apply_mrcc_monoexc `_ Generate all single excitations of key_in using the bit masks of holes and particles. Assume N_int is already provided. -`h_matrix_dressed `_ +`h_matrix_dressed `_ Dressed H with Delta_ij @@ -123,11 +123,15 @@ Documentation H_jj : array of -`lambda_mrcc `_ +`lambda_mrcc `_ cm/ or perturbative 1/Delta_E(m) -`lambda_pert `_ +`lambda_mrcc_tmp `_ + Undocumented + + +`lambda_pert `_ cm/ or perturbative 1/Delta_E(m) @@ -139,6 +143,18 @@ Documentation Undocumented +`mrcc_iterations `_ + Undocumented + + +`oscillations `_ + Undocumented + + +`pert_determinants `_ + Undocumented + + `psi_ref_lock `_ Locks on ref determinants to fill delta_ij @@ -146,3 +162,7 @@ Documentation `run_mrcc `_ Undocumented + +`set_generators_bitmasks_as_holes_and_particles `_ + Undocumented + diff --git a/plugins/MRCC_Utils/mrcc_general.irp.f b/plugins/MRCC_Utils/mrcc_general.irp.f index 53650164..c567c76a 100644 --- a/plugins/MRCC_Utils/mrcc_general.irp.f +++ b/plugins/MRCC_Utils/mrcc_general.irp.f @@ -1,13 +1,23 @@ subroutine run_mrcc implicit none + call set_generators_bitmasks_as_holes_and_particles + call mrcc_iterations +end + +subroutine mrcc_iterations + implicit none + integer :: i,j double precision :: E_new, E_old, delta_e - integer :: iteration + integer :: iteration,i_oscillations + double precision :: E_past(4) E_new = 0.d0 delta_E = 1.d0 iteration = 0 - do while (delta_E > 1.d-10) + j = 1 + i_oscillations = 0 + do while (delta_E > 1.d-7) iteration += 1 print *, '===========================' print *, 'MRCC Iteration', iteration @@ -18,12 +28,70 @@ subroutine run_mrcc call diagonalize_ci_dressed E_new = sum(ci_energy_dressed) delta_E = dabs(E_new - E_old) - if (iteration > 20) then + + E_past(j) = E_new + j +=1 + if(j>4)then + j=1 + endif + if(iteration > 4) then + if(delta_E > 1.d-10)then + if(dabs(E_past(1) - E_past(3)) .le. delta_E .and. dabs(E_past(2) - E_past(4)).le. delta_E)then + print*,'OSCILLATIONS !!!' + oscillations = .True. + i_oscillations +=1 + lambda_mrcc_tmp = lambda_mrcc + endif + endif + endif + call save_wavefunction +! if (i_oscillations > 5) then +! exit +! endif + if (iteration > 200) then exit endif + print*,'------------' + print*,'VECTOR' + do i = 1, N_det_ref + print*,'' + print*,'psi_ref_coef(i,1) = ',psi_ref_coef(i,1) + print*,'delta_ii(i,1) = ',delta_ii(i,1) + enddo + print*,'------------' enddo call write_double(6,ci_energy_dressed(1),"Final MRCC energy") - call ezfio_set_mrcc_energy(ci_energy_dressed(1)) + call ezfio_set_mrcc_cassd_energy(ci_energy_dressed(1)) call save_wavefunction end + +subroutine set_generators_bitmasks_as_holes_and_particles + implicit none + integer :: i,k + do k = 1, N_generators_bitmask + do i = 1, N_int + ! Pure single part + generators_bitmask(i,1,1,k) = holes_operators(i,1) ! holes for pure single exc alpha + generators_bitmask(i,1,2,k) = particles_operators(i,1) ! particles for pure single exc alpha + generators_bitmask(i,2,1,k) = holes_operators(i,2) ! holes for pure single exc beta + generators_bitmask(i,2,2,k) = particles_operators(i,2) ! particles for pure single exc beta + + ! Double excitation + generators_bitmask(i,1,3,k) = holes_operators(i,1) ! holes for first single exc alpha + generators_bitmask(i,1,4,k) = particles_operators(i,1) ! particles for first single exc alpha + generators_bitmask(i,2,3,k) = holes_operators(i,2) ! holes for first single exc beta + generators_bitmask(i,2,4,k) = particles_operators(i,2) ! particles for first single exc beta + + generators_bitmask(i,1,5,k) = holes_operators(i,1) ! holes for second single exc alpha + generators_bitmask(i,1,6,k) = particles_operators(i,1) ! particles for second single exc alpha + generators_bitmask(i,2,5,k) = holes_operators(i,2) ! holes for second single exc beta + generators_bitmask(i,2,6,k) = particles_operators(i,2) ! particles for second single exc beta + + enddo + enddo + touch generators_bitmask + + + +end diff --git a/plugins/MRCC_Utils/mrcc_utils.irp.f b/plugins/MRCC_Utils/mrcc_utils.irp.f index d8ed5250..d5b10311 100644 --- a/plugins/MRCC_Utils/mrcc_utils.irp.f +++ b/plugins/MRCC_Utils/mrcc_utils.irp.f @@ -1,29 +1,94 @@ + BEGIN_PROVIDER [integer, pert_determinants, (N_states, psi_det_size) ] + END_PROVIDER + + BEGIN_PROVIDER [ double precision, lambda_mrcc, (N_states,psi_det_size) ] &BEGIN_PROVIDER [ double precision, lambda_pert, (N_states,psi_det_size) ] implicit none BEGIN_DOC ! cm/ or perturbative 1/Delta_E(m) END_DOC - integer :: i,k - double precision :: ihpsi(N_states), hii + integer :: i,k,j + double precision :: ihpsi(N_states), hii,delta_e_eff,ihpsi_current(N_states),hij + integer :: i_ok,i_pert,i_pert_count + i_ok = 0 + + double precision :: phase_restart(N_states),tmp + do k = 1, N_states + phase_restart(k) = dsign(1.d0,psi_ref_coef_restart(1,k)/psi_ref_coef(1,k)) + enddo + i_pert_count = 0 do i=1,N_det_non_ref - call i_h_psi(psi_non_ref(1,1,i), psi_ref, psi_ref_coef, N_int, N_det_ref,& - size(psi_ref_coef,1), n_states, ihpsi) - call i_h_j(psi_non_ref(1,1,i),psi_non_ref(1,1,i),N_int,hii) + call i_h_psi(psi_non_ref(1,1,i), psi_ref_restart, psi_ref_coef_restart, N_int, N_det_ref,& + size(psi_ref_coef_restart,1), n_states, ihpsi) + call i_H_j(psi_non_ref(1,1,i),psi_non_ref(1,1,i),N_int,hii) do k=1,N_states lambda_pert(k,i) = 1.d0 / (psi_ref_energy_diagonalized(k)-hii) - if (dabs(ihpsi(k)).le.1.d-3) then + call i_h_psi(psi_non_ref(1,1,i), psi_ref, psi_ref_coef, N_int, N_det_ref,size(psi_ref_coef,1), n_states, ihpsi_current) + tmp = psi_non_ref_coef(i,k)/ihpsi_current(k) + i_pert = 1 + if((ihpsi(k) * lambda_pert(k,i))/psi_non_ref_coef_restart(i,k) .ge. 0.5d0 & + .and. (ihpsi(k) * lambda_pert(k,i))/psi_non_ref_coef_restart(i,k) > 0.d0 )then ! test on the first order coefficient + i_pert = 0 + endif + do j = 1, N_det_ref + call i_H_j(psi_non_ref(1,1,i),psi_ref(1,1,j),N_int,hij) + if(dabs(hij * tmp).ge.0.5d0)then + i_pert_count +=1 + i_pert = 1 + exit + endif + enddo + if( i_pert == 1)then + pert_determinants(k,i) = i_pert + endif + if(pert_determinants(k,i) == 1)then + i_ok +=1 lambda_mrcc(k,i) = lambda_pert(k,i) else - lambda_mrcc(k,i) = psi_non_ref_coef(i,k)/ihpsi(k) + lambda_mrcc(k,i) = psi_non_ref_coef(i,k)/ihpsi_current(k) endif enddo enddo +!if(oscillations)then +! print*,'AVERAGING the lambda_mrcc with those of the previous iterations' +! do i = 1, N_det_non_ref +! do k = 1, N_states + +! double precision :: tmp +! tmp = lambda_mrcc(k,i) +! lambda_mrcc(k,i) += lambda_mrcc_tmp(k,i) +! lambda_mrcc(k,i) = lambda_mrcc(k,i) * 0.5d0 +! if(dabs(tmp - lambda_mrcc(k,i)).ge.1.d-9)then +! print*,'' +! print*,'i = ',i +! print*,'psi_non_ref_coef(i,k) = ',psi_non_ref_coef(i,k) +! print*,'lambda_mrcc(k,i) = ',lambda_mrcc(k,i) +! print*,' tmp = ',tmp +! endif +! enddo +! enddo +!endif + print*,'N_det_non_ref = ',N_det_non_ref + print*,'Number of Perturbatively treated determinants = ',i_ok + print*,'i_pert_count = ',i_pert_count + print*,'psi_coef_ref_ratio = ',psi_ref_coef(2,1)/psi_ref_coef(1,1) END_PROVIDER +BEGIN_PROVIDER [ double precision, lambda_mrcc_tmp, (N_states,psi_det_size) ] + implicit none + lambda_mrcc_tmp = 0.d0 +END_PROVIDER + +BEGIN_PROVIDER [ logical, oscillations ] + implicit none + oscillations = .False. +END_PROVIDER + + !BEGIN_PROVIDER [ double precision, delta_ij_non_ref, (N_det_non_ref, N_det_non_ref,N_states) ] @@ -45,6 +110,31 @@ END_PROVIDER delta_ij = 0.d0 delta_ii = 0.d0 call H_apply_mrcc(delta_ij,delta_ii,N_det_ref,N_det_non_ref) + double precision :: max_delta + double precision :: accu + integer :: imax,jmax + max_delta = 0.d0 + accu = 0.d0 + do i = 1, N_det_ref + do j = 1, N_det_non_ref + accu += psi_non_ref_coef(j,1) * psi_ref_coef(i,1) * delta_ij(i,j,1) + if(dabs(delta_ij(i,j,1)).gt.max_delta)then + max_delta = dabs(delta_ij(i,j,1)) + imax = i + jmax = j + endif + enddo + enddo + print*,'' + print*,'' + print*,' = ',accu + print*,'MAX VAL OF DRESING = ',delta_ij(imax,jmax,1) + print*,'imax,jmax = ',imax,jmax + print*,'psi_ref_coef(imax,1) = ',psi_ref_coef(imax,1) + print*,'psi_non_ref_coef(jmax,1) = ',psi_non_ref_coef(jmax,1) + do i = 1, N_det_ref + print*,'delta_ii(i,1) = ',delta_ii(i,1) + enddo END_PROVIDER BEGIN_PROVIDER [ double precision, h_matrix_dressed, (N_det,N_det,N_states) ] @@ -63,7 +153,7 @@ BEGIN_PROVIDER [ double precision, h_matrix_dressed, (N_det,N_det,N_states) ] i =idx_ref(ii) h_matrix_dressed(i,i,istate) += delta_ii(ii,istate) do jj = 1, N_det_non_ref - j =idx_ref(jj) + j =idx_non_ref(jj) h_matrix_dressed(i,j,istate) += delta_ij(ii,jj,istate) h_matrix_dressed(j,i,istate) += delta_ij(ii,jj,istate) enddo diff --git a/plugins/MRCC_Utils_new/EZFIO.cfg b/plugins/MRCC_Utils_new/EZFIO.cfg new file mode 100644 index 00000000..789f30ef --- /dev/null +++ b/plugins/MRCC_Utils_new/EZFIO.cfg @@ -0,0 +1,4 @@ +[energy] +type: double precision +doc: Calculated MRCC energy +interface: ezfio \ No newline at end of file diff --git a/plugins/MRCC_Utils_new/NEEDED_CHILDREN_MODULES b/plugins/MRCC_Utils_new/NEEDED_CHILDREN_MODULES new file mode 100644 index 00000000..5b16423e --- /dev/null +++ b/plugins/MRCC_Utils_new/NEEDED_CHILDREN_MODULES @@ -0,0 +1 @@ +Perturbation Selectors_full Generators_full Psiref_Utils diff --git a/plugins/MRCC_Utils_new/README.rst b/plugins/MRCC_Utils_new/README.rst new file mode 100644 index 00000000..6f070867 --- /dev/null +++ b/plugins/MRCC_Utils_new/README.rst @@ -0,0 +1,168 @@ +=========== +MRCC Module +=========== + +Multi-Reference Coupled Cluster. + +Needed Modules +============== + +.. Do not edit this section. It was auto-generated from the +.. by the `update_README.py` script. + +.. image:: tree_dependency.png + +* `Perturbation `_ +* `Selectors_full `_ +* `Generators_full `_ +* `Psiref_Utils `_ + +Documentation +============= + +.. Do not edit this section. It was auto-generated from the +.. by the `update_README.py` script. + +`apply_excitation_operator `_ + Undocumented + + +`ci_eigenvectors_dressed `_ + Eigenvectors/values of the CI matrix + + +`ci_eigenvectors_s2_dressed `_ + Eigenvectors/values of the CI matrix + + +`ci_electronic_energy_dressed `_ + Eigenvectors/values of the CI matrix + + +`ci_energy_dressed `_ + N_states lowest eigenvalues of the dressed CI matrix + + +`davidson_diag_hjj_mrcc `_ + Davidson diagonalization with specific diagonal elements of the H matrix + .br + H_jj : specific diagonal H matrix elements to diagonalize de Davidson + .br + dets_in : bitmasks corresponding to determinants + .br + u_in : guess coefficients on the various states. Overwritten + on exit + .br + dim_in : leftmost dimension of u_in + .br + sze : Number of determinants + .br + N_st : Number of eigenstates + .br + iunit : Unit for the I/O + .br + Initial guess vectors are not necessarily orthonormal + + +`davidson_diag_mrcc `_ + Davidson diagonalization. + .br + dets_in : bitmasks corresponding to determinants + .br + u_in : guess coefficients on the various states. Overwritten + on exit + .br + dim_in : leftmost dimension of u_in + .br + sze : Number of determinants + .br + N_st : Number of eigenstates + .br + iunit : Unit number for the I/O + .br + Initial guess vectors are not necessarily orthonormal + + +`delta_ii `_ + Dressing matrix in N_det basis + + +`delta_ij `_ + Dressing matrix in N_det basis + + +`diagonalize_ci_dressed `_ + Replace the coefficients of the CI states by the coefficients of the + eigenstates of the CI matrix + + +`get_excitation_operators_for_one_ref `_ + This subroutine provides all the amplitudes and excitation operators + that one needs to go from the reference to the non reference wave function + you enter with det_ref that is a reference determinant + .br + N_connect_ref is the number of determinants belonging to psi_non_ref + that are connected to det_ref. + .br + amplitudes_phase_less(i) = amplitude phase less t_{I->i} = * lambda_mrcc(i) * phase(I->i) + .br + excitation_operators(:,i) represents the holes and particles that + link the ith connected determinant to det_ref + if :: + excitation_operators(5,i) = 2 :: double excitation alpha + excitation_operators(5,i) = -2 :: double excitation beta + !! excitation_operators(1,i) :: hole 1 + !! excitation_operators(2,i) :: particle 1 + !! excitation_operators(3,i) :: hole 2 + !! excitation_operators(4,i) :: particle 2 + else if :: + excitation_operators(5,i) = 1 :: single excitation alpha + !! excitation_operators(1,i) :: hole 1 + !! excitation_operators(2,i) :: particle 1 + else if :: + excitation_operators(5,i) = -1 :: single excitation beta + !! excitation_operators(3,i) :: hole 1 + !! excitation_operators(4,i) :: particle 1 + else if :: + !! excitation_operators(5,i) = 0 :: double excitation alpha/beta + !! excitation_operators(1,i) :: hole 1 alpha + !! excitation_operators(2,i) :: particle 1 alpha + !! excitation_operators(3,i) :: hole 2 beta + !! excitation_operators(4,i) :: particle 2 beta + + +`h_matrix_dressed `_ + Dressed H with Delta_ij + + +`h_u_0_mrcc `_ + Computes v_0 = H|u_0> + .br + n : number of determinants + .br + H_jj : array of + + +`lambda_mrcc `_ + cm/ or perturbative 1/Delta_E(m) + + +`lambda_pert `_ + cm/ or perturbative 1/Delta_E(m) + + +`mrcc_dress `_ + Undocumented + + +`mrcc_iterations `_ + Undocumented + + +`run_mrcc `_ + Undocumented + + +`set_generators_bitmasks_as_holes_and_particles `_ + Undocumented + diff --git a/plugins/MRCC_Utils_new/davidson.irp.f b/plugins/MRCC_Utils_new/davidson.irp.f new file mode 100644 index 00000000..0c7bebbd --- /dev/null +++ b/plugins/MRCC_Utils_new/davidson.irp.f @@ -0,0 +1,430 @@ +subroutine davidson_diag_mrcc(dets_in,u_in,energies,dim_in,sze,N_st,Nint,iunit,istate) + use bitmasks + implicit none + BEGIN_DOC + ! Davidson diagonalization. + ! + ! dets_in : bitmasks corresponding to determinants + ! + ! u_in : guess coefficients on the various states. Overwritten + ! on exit + ! + ! dim_in : leftmost dimension of u_in + ! + ! sze : Number of determinants + ! + ! N_st : Number of eigenstates + ! + ! iunit : Unit number for the I/O + ! + ! Initial guess vectors are not necessarily orthonormal + END_DOC + integer, intent(in) :: dim_in, sze, N_st, Nint, iunit, istate + integer(bit_kind), intent(in) :: dets_in(Nint,2,sze) + double precision, intent(inout) :: u_in(dim_in,N_st) + double precision, intent(out) :: energies(N_st) + double precision, allocatable :: H_jj(:) + + double precision :: diag_h_mat_elem + integer :: i + ASSERT (N_st > 0) + ASSERT (sze > 0) + ASSERT (Nint > 0) + ASSERT (Nint == N_int) + PROVIDE mo_bielec_integrals_in_map + allocate(H_jj(sze)) + + !$OMP PARALLEL DEFAULT(NONE) & + !$OMP SHARED(sze,H_jj,N_det_ref,dets_in,Nint,istate,delta_ii,idx_ref) & + !$OMP PRIVATE(i) + !$OMP DO SCHEDULE(guided) + do i=1,sze + H_jj(i) = diag_h_mat_elem(dets_in(1,1,i),Nint) + enddo + !$OMP END DO + !$OMP DO SCHEDULE(guided) + do i=1,N_det_ref + H_jj(idx_ref(i)) += delta_ii(i,istate) + enddo + !$OMP END DO + !$OMP END PARALLEL + + call davidson_diag_hjj_mrcc(dets_in,u_in,H_jj,energies,dim_in,sze,N_st,Nint,iunit,istate) + deallocate (H_jj) +end + +subroutine davidson_diag_hjj_mrcc(dets_in,u_in,H_jj,energies,dim_in,sze,N_st,Nint,iunit,istate) + use bitmasks + implicit none + BEGIN_DOC + ! Davidson diagonalization with specific diagonal elements of the H matrix + ! + ! H_jj : specific diagonal H matrix elements to diagonalize de Davidson + ! + ! dets_in : bitmasks corresponding to determinants + ! + ! u_in : guess coefficients on the various states. Overwritten + ! on exit + ! + ! dim_in : leftmost dimension of u_in + ! + ! sze : Number of determinants + ! + ! N_st : Number of eigenstates + ! + ! iunit : Unit for the I/O + ! + ! Initial guess vectors are not necessarily orthonormal + END_DOC + integer, intent(in) :: dim_in, sze, N_st, Nint, istate + integer(bit_kind), intent(in) :: dets_in(Nint,2,sze) + double precision, intent(in) :: H_jj(sze) + integer, intent(in) :: iunit + double precision, intent(inout) :: u_in(dim_in,N_st) + double precision, intent(out) :: energies(N_st) + + integer :: iter + integer :: i,j,k,l,m + logical :: converged + + double precision :: overlap(N_st,N_st) + double precision :: u_dot_v, u_dot_u + + integer, allocatable :: kl_pairs(:,:) + integer :: k_pairs, kl + + integer :: iter2 + double precision, allocatable :: W(:,:,:), U(:,:,:), R(:,:) + double precision, allocatable :: y(:,:,:,:), h(:,:,:,:), lambda(:) + double precision :: diag_h_mat_elem + double precision :: residual_norm(N_st) + character*(16384) :: write_buffer + double precision :: to_print(2,N_st) + double precision :: cpu, wall + + PROVIDE det_connections + + call write_time(iunit) + call wall_time(wall) + call cpu_time(cpu) + write(iunit,'(A)') '' + write(iunit,'(A)') 'Davidson Diagonalization' + write(iunit,'(A)') '------------------------' + write(iunit,'(A)') '' + call write_int(iunit,N_st,'Number of states') + call write_int(iunit,sze,'Number of determinants') + write(iunit,'(A)') '' + write_buffer = '===== ' + do i=1,N_st + write_buffer = trim(write_buffer)//' ================ ================' + enddo + write(iunit,'(A)') trim(write_buffer) + write_buffer = ' Iter' + do i=1,N_st + write_buffer = trim(write_buffer)//' Energy Residual' + enddo + write(iunit,'(A)') trim(write_buffer) + write_buffer = '===== ' + do i=1,N_st + write_buffer = trim(write_buffer)//' ================ ================' + enddo + write(iunit,'(A)') trim(write_buffer) + + allocate( & + kl_pairs(2,N_st*(N_st+1)/2), & + W(sze,N_st,davidson_sze_max), & + U(sze,N_st,davidson_sze_max), & + R(sze,N_st), & + h(N_st,davidson_sze_max,N_st,davidson_sze_max), & + y(N_st,davidson_sze_max,N_st,davidson_sze_max), & + lambda(N_st*davidson_sze_max)) + + ASSERT (N_st > 0) + ASSERT (sze > 0) + ASSERT (Nint > 0) + ASSERT (Nint == N_int) + + ! Initialization + ! ============== + + k_pairs=0 + do l=1,N_st + do k=1,l + k_pairs+=1 + kl_pairs(1,k_pairs) = k + kl_pairs(2,k_pairs) = l + enddo + enddo + + !$OMP PARALLEL DEFAULT(NONE) & + !$OMP SHARED(U,sze,N_st,overlap,kl_pairs,k_pairs, & + !$OMP Nint,dets_in,u_in) & + !$OMP PRIVATE(k,l,kl,i) + + + ! Orthonormalize initial guess + ! ============================ + + !$OMP DO + do kl=1,k_pairs + k = kl_pairs(1,kl) + l = kl_pairs(2,kl) + if (k/=l) then + overlap(k,l) = u_dot_v(U_in(1,k),U_in(1,l),sze) + overlap(l,k) = overlap(k,l) + else + overlap(k,k) = u_dot_u(U_in(1,k),sze) + endif + enddo + !$OMP END DO + !$OMP END PARALLEL + + call ortho_lowdin(overlap,size(overlap,1),N_st,U_in,size(U_in,1),sze) + + ! Davidson iterations + ! =================== + + converged = .False. + + do while (.not.converged) + + !$OMP PARALLEL DEFAULT(NONE) & + !$OMP PRIVATE(k,i) SHARED(U,u_in,sze,N_st) + do k=1,N_st + !$OMP DO + do i=1,sze + U(i,k,1) = u_in(i,k) + enddo + !$OMP END DO + enddo + !$OMP END PARALLEL + + do iter=1,davidson_sze_max-1 + + ! Compute W_k = H |u_k> + ! ---------------------- + + do k=1,N_st + call H_u_0_mrcc(W(1,k,iter),U(1,k,iter),H_jj,sze,dets_in,Nint,istate) + enddo + + ! Compute h_kl = = + ! ------------------------------------------- + + do l=1,N_st + do k=1,N_st + do iter2=1,iter-1 + h(k,iter2,l,iter) = u_dot_v(U(1,k,iter2),W(1,l,iter),sze) + h(k,iter,l,iter2) = h(k,iter2,l,iter) + enddo + enddo + do k=1,l + h(k,iter,l,iter) = u_dot_v(U(1,k,iter),W(1,l,iter),sze) + h(l,iter,k,iter) = h(k,iter,l,iter) + enddo + enddo + + !DEBUG H MATRIX + !do i=1,iter + ! print '(10(x,F16.10))', h(1,i,1,1:i) + !enddo + !print *, '' + !END + + ! Diagonalize h + ! ------------- + call lapack_diag(lambda,y,h,N_st*davidson_sze_max,N_st*iter) + + ! Express eigenvectors of h in the determinant basis + ! -------------------------------------------------- + + do k=1,N_st + do i=1,sze + U(i,k,iter+1) = 0.d0 + W(i,k,iter+1) = 0.d0 + do l=1,N_st + do iter2=1,iter + U(i,k,iter+1) = U(i,k,iter+1) + U(i,l,iter2)*y(l,iter2,k,1) + W(i,k,iter+1) = W(i,k,iter+1) + W(i,l,iter2)*y(l,iter2,k,1) + enddo + enddo + enddo + enddo + + ! Compute residual vector + ! ----------------------- + + do k=1,N_st + do i=1,sze + R(i,k) = lambda(k) * U(i,k,iter+1) - W(i,k,iter+1) + enddo + residual_norm(k) = u_dot_u(R(1,k),sze) + to_print(1,k) = lambda(k) + nuclear_repulsion + to_print(2,k) = residual_norm(k) + enddo + + write(iunit,'(X,I3,X,100(X,F16.10,X,E16.6))'), iter, to_print(:,1:N_st) + call davidson_converged(lambda,residual_norm,wall,iter,cpu,N_st,converged) + if (converged) then + exit + endif + + + ! Davidson step + ! ------------- + + do k=1,N_st + do i=1,sze + U(i,k,iter+1) = -1.d0/max(H_jj(i) - lambda(k),1.d-2) * R(i,k) + enddo + enddo + + ! Gram-Schmidt + ! ------------ + + double precision :: c + do k=1,N_st + do iter2=1,iter + do l=1,N_st + c = u_dot_v(U(1,k,iter+1),U(1,l,iter2),sze) + do i=1,sze + U(i,k,iter+1) -= c * U(i,l,iter2) + enddo + enddo + enddo + do l=1,k-1 + c = u_dot_v(U(1,k,iter+1),U(1,l,iter+1),sze) + do i=1,sze + U(i,k,iter+1) -= c * U(i,l,iter+1) + enddo + enddo + call normalize( U(1,k,iter+1), sze ) + enddo + + !DEBUG : CHECK OVERLAP + !print *, '===' + !do k=1,iter+1 + ! do l=1,k + ! c = u_dot_v(U(1,1,k),U(1,1,l),sze) + ! print *, k,l, c + ! enddo + !enddo + !print *, '===' + !pause + !END DEBUG + + + enddo + + if (.not.converged) then + iter = davidson_sze_max-1 + endif + + ! Re-contract to u_in + ! ----------- + + do k=1,N_st + energies(k) = lambda(k) + do i=1,sze + u_in(i,k) = 0.d0 + do iter2=1,iter + do l=1,N_st + u_in(i,k) += U(i,l,iter2)*y(l,iter2,k,1) + enddo + enddo + enddo + enddo + + enddo + + write_buffer = '===== ' + do i=1,N_st + write_buffer = trim(write_buffer)//' ================ ================' + enddo + write(iunit,'(A)') trim(write_buffer) + write(iunit,'(A)') '' + call write_time(iunit) + + deallocate ( & + kl_pairs, & + W, & + U, & + R, & + h, & + y, & + lambda & + ) + abort_here = abort_all +end + +subroutine H_u_0_mrcc(v_0,u_0,H_jj,n,keys_tmp,Nint,istate) + use bitmasks + implicit none + BEGIN_DOC + ! Computes v_0 = H|u_0> + ! + ! n : number of determinants + ! + ! H_jj : array of + END_DOC + integer, intent(in) :: n,Nint,istate + double precision, intent(out) :: v_0(n) + double precision, intent(in) :: u_0(n) + double precision, intent(in) :: H_jj(n) + integer(bit_kind),intent(in) :: keys_tmp(Nint,2,n) + integer, allocatable :: idx(:) + double precision :: hij + double precision, allocatable :: vt(:) + integer :: i,j,k,l, jj,ii + integer :: i0, j0 + ASSERT (Nint > 0) + ASSERT (Nint == N_int) + ASSERT (n>0) + PROVIDE ref_bitmask_energy delta_ij + integer, parameter :: block_size = 157 + !$OMP PARALLEL DEFAULT(NONE) & + !$OMP PRIVATE(i,hij,j,k,idx,jj,ii,vt) & + !$OMP SHARED(n_det_ref,n_det_non_ref,idx_ref,idx_non_ref,n,H_jj,u_0,keys_tmp,Nint,v_0,istate,delta_ij) + !$OMP DO SCHEDULE(static) + do i=1,n + v_0(i) = H_jj(i) * u_0(i) + enddo + !$OMP END DO + allocate(idx(0:n), vt(n)) + Vt = 0.d0 + !$OMP DO SCHEDULE(guided) + do i=1,n + idx(0) = i + call filter_connected_davidson(keys_tmp,keys_tmp(1,1,i),Nint,i-1,idx) + do jj=1,idx(0) + j = idx(jj) + if ( (dabs(u_0(j)) > 1.d-7).or.((dabs(u_0(i)) > 1.d-7)) ) then + call i_H_j(keys_tmp(1,1,j),keys_tmp(1,1,i),Nint,hij) + hij = hij + vt (i) = vt (i) + hij*u_0(j) + vt (j) = vt (j) + hij*u_0(i) + endif + enddo + enddo + !$OMP END DO + + !$OMP DO SCHEDULE(guided) + do ii=1,n_det_ref + i = idx_ref(ii) + do jj = 1, n_det_non_ref + j = idx_non_ref(jj) + vt (i) = vt (i) + delta_ij(ii,jj,istate)*u_0(j) + vt (j) = vt (j) + delta_ij(ii,jj,istate)*u_0(i) + enddo + enddo + !$OMP END DO + !$OMP CRITICAL + do i=1,n + v_0(i) = v_0(i) + vt(i) + enddo + !$OMP END CRITICAL + deallocate(idx,vt) + !$OMP END PARALLEL +end + + diff --git a/plugins/MRCC_Utils_new/mrcc_amplitudes.irp.f b/plugins/MRCC_Utils_new/mrcc_amplitudes.irp.f new file mode 100644 index 00000000..6746bee1 --- /dev/null +++ b/plugins/MRCC_Utils_new/mrcc_amplitudes.irp.f @@ -0,0 +1,93 @@ +subroutine get_excitation_operators_for_one_ref(det_ref,i_state,ndetnonref,N_connect_ref,excitation_operators,amplitudes_phase_less,index_connected) + use bitmasks + implicit none + integer(bit_kind), intent(in) :: det_ref(N_int,2) + integer, intent(in) :: i_state,ndetnonref + integer*2, intent(out) :: excitation_operators(5,ndetnonref) + integer, intent(out) :: index_connected(ndetnonref) + integer, intent(out) :: N_connect_ref + double precision, intent(out) :: amplitudes_phase_less(ndetnonref) + + integer :: i,j,k,l,degree,h1,p1,h2,p2,s1,s2 + integer :: exc(0:2,2,2) + double precision :: phase,hij + BEGIN_DOC + ! This subroutine provides all the amplitudes and excitation operators + ! that one needs to go from the reference to the non reference wave function + ! you enter with det_ref that is a reference determinant + ! + ! N_connect_ref is the number of determinants belonging to psi_non_ref + ! that are connected to det_ref. + ! + ! amplitudes_phase_less(i) = amplitude phase less t_{I->i} = * lambda_mrcc(i) * phase(I->i) + ! + ! excitation_operators(:,i) represents the holes and particles that + ! link the ith connected determinant to det_ref + ! if :: + ! excitation_operators(5,i) = 2 :: double excitation alpha + ! excitation_operators(5,i) = -2 :: double excitation beta + !!! excitation_operators(1,i) :: hole 1 + !!! excitation_operators(2,i) :: particle 1 + !!! excitation_operators(3,i) :: hole 2 + !!! excitation_operators(4,i) :: particle 2 + ! else if :: + ! excitation_operators(5,i) = 1 :: single excitation alpha + !!! excitation_operators(1,i) :: hole 1 + !!! excitation_operators(2,i) :: particle 1 + ! else if :: + ! excitation_operators(5,i) = -1 :: single excitation beta + !!! excitation_operators(3,i) :: hole 1 + !!! excitation_operators(4,i) :: particle 1 + ! else if :: + !!! excitation_operators(5,i) = 0 :: double excitation alpha/beta + !!! excitation_operators(1,i) :: hole 1 alpha + !!! excitation_operators(2,i) :: particle 1 alpha + !!! excitation_operators(3,i) :: hole 2 beta + !!! excitation_operators(4,i) :: particle 2 beta + END_DOC + N_connect_ref = 0 + do i = 1, ndetnonref + call i_H_j_phase_out(det_ref,psi_non_ref(1,1,i),N_int,hij,phase,exc,degree) + if (dabs(hij) <= mo_integrals_threshold) then + cycle + endif + N_connect_ref +=1 + index_connected(N_connect_ref) = i + call decode_exc(exc,degree,h1,p1,h2,p2,s1,s2) + amplitudes_phase_less(N_connect_ref) = hij * lambda_mrcc(i_state,i) !*phase + + if (degree==2) then + + excitation_operators(1,N_connect_ref) = h1 + excitation_operators(2,N_connect_ref) = p1 + excitation_operators(3,N_connect_ref) = h2 + excitation_operators(4,N_connect_ref) = p2 + if(s1==s2.and.s1==1)then ! double alpha + excitation_operators(5,N_connect_ref) = 2 + elseif(s1==s2.and.s1==2)then ! double beta + excitation_operators(5,N_connect_ref) = -2 + else ! double alpha/beta + excitation_operators(5,N_connect_ref) = 0 + endif + + else if(degree==1) then + + if(s1==1)then ! mono alpha + excitation_operators(5,N_connect_ref) = 1 + excitation_operators(1,N_connect_ref) = h1 + excitation_operators(2,N_connect_ref) = p1 + else ! mono beta + excitation_operators(5,N_connect_ref) = -1 + excitation_operators(3,N_connect_ref) = h1 + excitation_operators(4,N_connect_ref) = p1 + endif + + else + + N_connect_ref-=1 + + endif + + enddo + +end diff --git a/plugins/MRCC_Utils_new/mrcc_dress.irp.f b/plugins/MRCC_Utils_new/mrcc_dress.irp.f new file mode 100644 index 00000000..ee998995 --- /dev/null +++ b/plugins/MRCC_Utils_new/mrcc_dress.irp.f @@ -0,0 +1,183 @@ +subroutine mrcc_dress(ndetref,ndetnonref,nstates,delta_ij_,delta_ii_) + use bitmasks + implicit none + integer, intent(in) :: ndetref,nstates,ndetnonref + double precision, intent(inout) :: delta_ii_(ndetref,nstates),delta_ij_(ndetref,ndetnonref,nstates) + integer :: i,j,k,l,m + integer :: i_state + integer :: N_connect_ref + integer*2,allocatable :: excitation_operators(:,:) + double precision, allocatable :: amplitudes_phase_less(:) + double precision, allocatable :: coef_test(:) + integer(bit_kind), allocatable :: key_test(:,:) + integer, allocatable :: index_connected(:) + integer :: i_hole,i_particle,ispin,i_ok,connected_to_ref,index_wf + integer, allocatable :: idx_vector(:) + double precision :: phase_ij + double precision :: dij,phase_la + double precision :: hij,phase + integer :: exc(0:2,2,2),degree + logical :: is_in_wavefunction + double precision, allocatable :: delta_ij_tmp(:,:,:), delta_ii_tmp(:,:) + logical, external :: is_in_psi_ref + + i_state = 1 + allocate(excitation_operators(5,N_det_non_ref)) + allocate(amplitudes_phase_less(N_det_non_ref)) + allocate(index_connected(N_det_non_ref)) + + !$OMP PARALLEL DEFAULT(NONE) & + !$OMP SHARED(N_det_ref, N_det_non_ref, psi_ref, i_state, & + !$OMP N_connect_ref,index_connected,psi_non_ref, & + !$OMP excitation_operators,amplitudes_phase_less, & + !$OMP psi_non_ref_coef,N_int,lambda_mrcc, & + !$OMP delta_ii_,delta_ij_,psi_ref_coef,nstates, & + !$OMP mo_integrals_threshold,idx_non_ref_rev) & + !$OMP PRIVATE(i,j,k,l,hil,phase_il,exc,degree,t_il, & + !$OMP key_test,i_ok,phase_la,hij,phase_ij,m, & + !$OMP dij,idx_vector,delta_ij_tmp, & + !$OMP delta_ii_tmp,phase) + allocate(idx_vector(0:N_det_non_ref)) + allocate(key_test(N_int,2)) + allocate(delta_ij_tmp(size(delta_ij_,1),size(delta_ij_,2),nstates)) + allocate(delta_ii_tmp(size(delta_ij_,1),nstates)) + delta_ij_tmp = 0.d0 + delta_ii_tmp = 0.d0 + + do i = 1, N_det_ref + !$OMP SINGLE + call get_excitation_operators_for_one_ref(psi_ref(1,1,i),i_state,N_det_non_ref,N_connect_ref,excitation_operators,amplitudes_phase_less,index_connected) + print*,'N_connect_ref =',N_connect_ref + print*,'N_det_non_ref =',N_det_non_ref + !$OMP END SINGLE + !$OMP BARRIER + + !$OMP DO SCHEDULE(dynamic) + do l = 1, N_det_non_ref +! print *, l, '/', N_det_non_ref + double precision :: t_il,phase_il,hil + call i_H_j_phase_out(psi_ref(1,1,i),psi_non_ref(1,1,l),N_int,hil,phase_il,exc,degree) + t_il = hil * lambda_mrcc(i_state,l) + if (dabs(t_il) < mo_integrals_threshold) then + cycle + endif + ! loop on the non ref determinants + + do j = 1, N_connect_ref + ! loop on the excitation operators linked to i + + do k = 1, N_int + key_test(k,1) = psi_non_ref(k,1,l) + key_test(k,2) = psi_non_ref(k,2,l) + enddo + + ! we apply the excitation operator T_I->j + call apply_excitation_operator(key_test,excitation_operators(1,j),i_ok) + if(i_ok.ne.1)cycle + + ! we check if such determinant is already in the wave function + if(is_in_wavefunction(key_test,N_int))cycle + + ! we get the phase for psi_non_ref(l) -> T_I->j |psi_non_ref(l)> + call get_excitation(psi_non_ref(1,1,l),key_test,exc,degree,phase_la,N_int) + + ! we get the phase T_I->j + call i_H_j_phase_out(psi_ref(1,1,i),psi_non_ref(1,1,index_connected(j)),N_int,hij,phase_ij,exc,degree) + + ! we compute the contribution to the coef of key_test + dij = t_il * hij * phase_la *phase_ij *lambda_mrcc(i_state,index_connected(j)) * 0.5d0 + if (dabs(dij) < mo_integrals_threshold) then + cycle + endif + + ! we compute the interaction of such determinant with all the non_ref dets + call filter_connected(psi_non_ref,key_test,N_int,N_det_non_ref,idx_vector) + + do k = 1, idx_vector(0) + m = idx_vector(k) + call i_H_j_phase_out(key_test,psi_non_ref(1,1,m),N_int,hij,phase,exc,degree) + delta_ij_tmp(i,m,i_state) += hij * dij + enddo + + + enddo + + if(dabs(psi_ref_coef(i,i_state)).le.5.d-5) then + delta_ii_tmp(i,i_state) -= & + delta_ij_tmp(i,l,i_state) * psi_non_ref_coef(l,i_state) & + / psi_ref_coef(i,i_state) + endif + + enddo + !$OMP END DO + enddo + + !$OMP CRITICAL + delta_ij_ = delta_ij_ + delta_ij_tmp + delta_ii_ = delta_ii_ + delta_ii_tmp + !$OMP END CRITICAL + + deallocate(delta_ii_tmp,delta_ij_tmp) + deallocate(idx_vector) + deallocate(key_test) + !$OMP END PARALLEL + + deallocate(excitation_operators) + deallocate(amplitudes_phase_less) + +end + + + +subroutine apply_excitation_operator(key_in,excitation_operator,i_ok) + use bitmasks + implicit none + integer(bit_kind), intent(inout) :: key_in + integer, intent (out) :: i_ok + integer*2 :: excitation_operator(5) + integer :: i_particle,i_hole,ispin + ! Do excitation + if(excitation_operator(5)==1)then ! mono alpha + i_hole = excitation_operator(1) + i_particle = excitation_operator(2) + ispin = 1 + call do_mono_excitation(key_in,i_hole,i_particle,ispin,i_ok) + else if (excitation_operator(5)==-1)then ! mono beta + i_hole = excitation_operator(3) + i_particle = excitation_operator(4) + ispin = 2 + call do_mono_excitation(key_in,i_hole,i_particle,ispin,i_ok) + else if (excitation_operator(5) == -2 )then ! double beta + i_hole = excitation_operator(1) + i_particle = excitation_operator(2) + ispin = 2 + call do_mono_excitation(key_in,i_hole,i_particle,ispin,i_ok) + if(i_ok.ne.1)return + i_hole = excitation_operator(3) + i_particle = excitation_operator(4) + ispin = 2 + call do_mono_excitation(key_in,i_hole,i_particle,ispin,i_ok) + + else if (excitation_operator(5) == 2 )then ! double alpha + i_hole = excitation_operator(1) + i_particle = excitation_operator(2) + ispin = 1 + call do_mono_excitation(key_in,i_hole,i_particle,ispin,i_ok) + if(i_ok.ne.1)return + i_hole = excitation_operator(3) + i_particle = excitation_operator(4) + ispin = 1 + call do_mono_excitation(key_in,i_hole,i_particle,ispin,i_ok) + + else if (excitation_operator(5) == 0 )then ! double alpha/alpha + i_hole = excitation_operator(1) + i_particle = excitation_operator(2) + ispin = 1 + call do_mono_excitation(key_in,i_hole,i_particle,ispin,i_ok) + if(i_ok.ne.1)return + i_hole = excitation_operator(3) + i_particle = excitation_operator(4) + ispin = 2 + call do_mono_excitation(key_in,i_hole,i_particle,ispin,i_ok) + endif +end diff --git a/plugins/MRCC_Utils_new/mrcc_general.irp.f b/plugins/MRCC_Utils_new/mrcc_general.irp.f new file mode 100644 index 00000000..245fcb05 --- /dev/null +++ b/plugins/MRCC_Utils_new/mrcc_general.irp.f @@ -0,0 +1,67 @@ +subroutine run_mrcc + implicit none + call set_generators_bitmasks_as_holes_and_particles + call mrcc_iterations +end + +subroutine mrcc_iterations + implicit none + + integer :: i,j + + double precision :: E_new, E_old, delta_e + integer :: iteration + E_new = 0.d0 + delta_E = 1.d0 + iteration = 0 + do while (delta_E > 1.d-8) + iteration += 1 + print *, '===========================' + print *, 'MRCC Iteration', iteration + print *, '===========================' + print *, '' + E_old = sum(ci_energy_dressed) + call write_double(6,ci_energy_dressed(1),"MRCC energy") + call diagonalize_ci_dressed + E_new = sum(ci_energy_dressed) + delta_E = dabs(E_new - E_old) +! stop + if (iteration > 200) then + exit + endif + enddo + call write_double(6,ci_energy_dressed(1),"Final MRCC energy") + call ezfio_set_mrcc_cassd_energy(ci_energy_dressed(1)) + call save_wavefunction + +end + +subroutine set_generators_bitmasks_as_holes_and_particles + implicit none + integer :: i,k + do k = 1, N_generators_bitmask + do i = 1, N_int + ! Pure single part + generators_bitmask(i,1,1,k) = holes_operators(i,1) ! holes for pure single exc alpha + generators_bitmask(i,1,2,k) = particles_operators(i,1) ! particles for pure single exc alpha + generators_bitmask(i,2,1,k) = holes_operators(i,2) ! holes for pure single exc beta + generators_bitmask(i,2,2,k) = particles_operators(i,2) ! particles for pure single exc beta + + ! Double excitation + generators_bitmask(i,1,3,k) = holes_operators(i,1) ! holes for first single exc alpha + generators_bitmask(i,1,4,k) = particles_operators(i,1) ! particles for first single exc alpha + generators_bitmask(i,2,3,k) = holes_operators(i,2) ! holes for first single exc beta + generators_bitmask(i,2,4,k) = particles_operators(i,2) ! particles for first single exc beta + + generators_bitmask(i,1,5,k) = holes_operators(i,1) ! holes for second single exc alpha + generators_bitmask(i,1,6,k) = particles_operators(i,1) ! particles for second single exc alpha + generators_bitmask(i,2,5,k) = holes_operators(i,2) ! holes for second single exc beta + generators_bitmask(i,2,6,k) = particles_operators(i,2) ! particles for second single exc beta + + enddo + enddo + touch generators_bitmask + + + +end diff --git a/plugins/MRCC_Utils_new/mrcc_utils.irp.f b/plugins/MRCC_Utils_new/mrcc_utils.irp.f new file mode 100644 index 00000000..d97696e5 --- /dev/null +++ b/plugins/MRCC_Utils_new/mrcc_utils.irp.f @@ -0,0 +1,179 @@ + BEGIN_PROVIDER [ double precision, lambda_mrcc, (N_states,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, lambda_pert, (N_states,psi_det_size) ] + implicit none + BEGIN_DOC + ! cm/ or perturbative 1/Delta_E(m) + END_DOC + integer :: i,k + double precision :: ihpsi(N_states), hii + integer :: i_ok + i_ok = 0 + + do i=1,N_det_non_ref + call i_h_psi(psi_non_ref(1,1,i), psi_ref, psi_ref_coef, N_int, N_det_ref,& + size(psi_ref_coef,1), n_states, ihpsi) + call i_h_j(psi_non_ref(1,1,i),psi_non_ref(1,1,i),N_int,hii) + do k=1,N_states + lambda_pert(k,i) = 1.d0 / (psi_ref_energy_diagonalized(k)-hii) + if (dabs(ihpsi(k)).le.1.d-3) then + i_ok +=1 + lambda_mrcc(k,i) = lambda_pert(k,i) + else + lambda_mrcc(k,i) = psi_non_ref_coef(i,k)/ihpsi(k) + endif + enddo + enddo + print*,'N_det_non_ref = ',N_det_non_ref + print*,'Number of Perturbatively treated determinants = ',i_ok + print*,'psi_coef_ref_ratio = ',psi_ref_coef(2,1)/psi_ref_coef(1,1) + +END_PROVIDER + + + + +!BEGIN_PROVIDER [ double precision, delta_ij_non_ref, (N_det_non_ref, N_det_non_ref,N_states) ] +!implicit none +!BEGIN_DOC +!! Dressing matrix in SD basis +!END_DOC +!delta_ij_non_ref = 0.d0 +!call H_apply_mrcc_simple(delta_ij_non_ref,N_det_non_ref) +!END_PROVIDER + + BEGIN_PROVIDER [ double precision, delta_ij, (N_det_ref,N_det_non_ref,N_states) ] +&BEGIN_PROVIDER [ double precision, delta_ii, (N_det_ref,N_states) ] + implicit none + BEGIN_DOC + ! Dressing matrix in N_det basis + END_DOC + integer :: i,j,m + delta_ij = 0.d0 + delta_ii = 0.d0 + call mrcc_dress(N_det_ref,N_det_non_ref,N_states,delta_ij,delta_ii) + write(33,*)delta_ij + write(34,*)delta_ii +END_PROVIDER + +BEGIN_PROVIDER [ double precision, h_matrix_dressed, (N_det,N_det,N_states) ] + implicit none + BEGIN_DOC + ! Dressed H with Delta_ij + END_DOC + integer :: i, j,istate,ii,jj + do istate = 1,N_states + do j=1,N_det + do i=1,N_det + h_matrix_dressed(i,j,istate) = h_matrix_all_dets(i,j) + enddo + enddo + do ii = 1, N_det_ref + i =idx_ref(ii) + h_matrix_dressed(i,i,istate) += delta_ii(ii,istate) + do jj = 1, N_det_non_ref + j =idx_non_ref(jj) + h_matrix_dressed(i,j,istate) += delta_ij(ii,jj,istate) + h_matrix_dressed(j,i,istate) += delta_ij(ii,jj,istate) + enddo + enddo + enddo +END_PROVIDER + + + BEGIN_PROVIDER [ double precision, CI_electronic_energy_dressed, (N_states_diag) ] +&BEGIN_PROVIDER [ double precision, CI_eigenvectors_dressed, (N_det,N_states_diag) ] +&BEGIN_PROVIDER [ double precision, CI_eigenvectors_s2_dressed, (N_states_diag) ] + implicit none + BEGIN_DOC + ! Eigenvectors/values of the CI matrix + END_DOC + integer :: i,j + + do j=1,N_states_diag + do i=1,N_det + CI_eigenvectors_dressed(i,j) = psi_coef(i,j) + enddo + enddo + + if (diag_algorithm == "Davidson") then + + integer :: istate + istate = 1 + call davidson_diag_mrcc(psi_det,CI_eigenvectors_dressed,CI_electronic_energy_dressed,& + size(CI_eigenvectors_dressed,1),N_det,N_states_diag,N_int,output_determinants,istate) + + else if (diag_algorithm == "Lapack") then + + double precision, allocatable :: eigenvectors(:,:), eigenvalues(:) + allocate (eigenvectors(size(H_matrix_dressed,1),N_det)) + allocate (eigenvalues(N_det)) + call lapack_diag(eigenvalues,eigenvectors, & + H_matrix_dressed,size(H_matrix_dressed,1),N_det) + CI_electronic_energy_dressed(:) = 0.d0 + do i=1,N_det + CI_eigenvectors_dressed(i,1) = eigenvectors(i,1) + enddo + integer :: i_state + double precision :: s2 + i_state = 0 + if (s2_eig) then + do j=1,N_det + call get_s2_u0(psi_det,eigenvectors(1,j),N_det,N_det,s2) + if(dabs(s2-expected_s2).le.0.3d0)then + i_state += 1 + do i=1,N_det + CI_eigenvectors_dressed(i,i_state) = eigenvectors(i,j) + enddo + CI_electronic_energy_dressed(i_state) = eigenvalues(j) + CI_eigenvectors_s2_dressed(i_state) = s2 + endif + if (i_state.ge.N_states_diag) then + exit + endif + enddo + else + do j=1,N_states_diag + call get_s2_u0(psi_det,eigenvectors(1,j),N_det,N_det,s2) + i_state += 1 + do i=1,N_det + CI_eigenvectors_dressed(i,i_state) = eigenvectors(i,j) + enddo + CI_electronic_energy_dressed(i_state) = eigenvalues(j) + CI_eigenvectors_s2_dressed(i_state) = s2 + enddo + endif + deallocate(eigenvectors,eigenvalues) + endif + +END_PROVIDER + +BEGIN_PROVIDER [ double precision, CI_energy_dressed, (N_states_diag) ] + implicit none + BEGIN_DOC + ! N_states lowest eigenvalues of the dressed CI matrix + END_DOC + + integer :: j + character*(8) :: st + call write_time(output_determinants) + do j=1,N_states_diag + CI_energy_dressed(j) = CI_electronic_energy_dressed(j) + nuclear_repulsion + enddo + +END_PROVIDER + +subroutine diagonalize_CI_dressed + implicit none + BEGIN_DOC +! Replace the coefficients of the CI states by the coefficients of the +! eigenstates of the CI matrix + END_DOC + integer :: i,j + do j=1,N_states_diag + do i=1,N_det + psi_coef(i,j) = CI_eigenvectors_dressed(i,j) + enddo + enddo + SOFT_TOUCH psi_coef + +end diff --git a/plugins/MRCC_Utils_new/tree_dependency.png b/plugins/MRCC_Utils_new/tree_dependency.png new file mode 100644 index 00000000..500e5d43 Binary files /dev/null and b/plugins/MRCC_Utils_new/tree_dependency.png differ diff --git a/plugins/Molden/.gitignore b/plugins/Molden/.gitignore index 95cab459..dad27c9b 100644 --- a/plugins/Molden/.gitignore +++ b/plugins/Molden/.gitignore @@ -1,18 +1,18 @@ -# Automatically created by /home/giner/quantum_package/scripts/module/module_handler.py -IRPF90_temp -IRPF90_man -irpf90_entities -tags -irpf90.make -Makefile -Makefile.depend -.ninja_log +# Automatically created by $QP_ROOT/scripts/module/module_handler.py .ninja_deps -ezfio_interface.irp.f -Ezfio_files -MO_Basis -Utils +.ninja_log AO_Basis Electrons +Ezfio_files +IRPF90_man +IRPF90_temp +MO_Basis +Makefile +Makefile.depend Nuclei +Utils +ezfio_interface.irp.f +irpf90.make +irpf90_entities print_mo +tags \ No newline at end of file diff --git a/plugins/Perturbation/perturbation.template.f b/plugins/Perturbation/perturbation.template.f index 9f50b636..a5ab12e7 100644 --- a/plugins/Perturbation/perturbation.template.f +++ b/plugins/Perturbation/perturbation.template.f @@ -31,7 +31,7 @@ subroutine perturb_buffer_$PERT(i_generator,buffer,buffer_size,e_2_pert_buffer,c cycle endif - if (is_in_wavefunction(buffer(1,1,i),Nint,N_det)) then + if (is_in_wavefunction(buffer(1,1,i),Nint)) then cycle endif @@ -82,7 +82,7 @@ subroutine perturb_buffer_by_mono_$PERT(i_generator,buffer,buffer_size,e_2_pert_ cycle endif - if (is_in_wavefunction(buffer(1,1,i),Nint,N_det)) then + if (is_in_wavefunction(buffer(1,1,i),Nint)) then cycle endif diff --git a/plugins/Psiref_CAS/README.rst b/plugins/Psiref_CAS/README.rst index 3d4726e1..b15aefb5 100644 --- a/plugins/Psiref_CAS/README.rst +++ b/plugins/Psiref_CAS/README.rst @@ -12,6 +12,33 @@ Documentation .. Do not edit this section. It was auto-generated from the .. by the `update_README.py` script. +`idx_ref `_ + CAS wave function, defined from the application of the CAS bitmask on the + determinants. idx_cas gives the indice of the CAS determinant in psi_det. + + +`n_det_ref `_ + CAS wave function, defined from the application of the CAS bitmask on the + determinants. idx_cas gives the indice of the CAS determinant in psi_det. + + +`psi_ref `_ + CAS wave function, defined from the application of the CAS bitmask on the + determinants. idx_cas gives the indice of the CAS determinant in psi_det. + + +`psi_ref_coef `_ + CAS wave function, defined from the application of the CAS bitmask on the + determinants. idx_cas gives the indice of the CAS determinant in psi_det. + + +`psi_ref_coef_restart `_ + Projection of the CAS wave function on the restart wave function. + + +`psi_ref_restart `_ + Projection of the CAS wave function on the restart wave function. + Needed Modules ============== diff --git a/plugins/Psiref_CAS/psi_ref.irp.f b/plugins/Psiref_CAS/psi_ref.irp.f index 81df60e9..f67f0587 100644 --- a/plugins/Psiref_CAS/psi_ref.irp.f +++ b/plugins/Psiref_CAS/psi_ref.irp.f @@ -26,3 +26,29 @@ use bitmasks END_PROVIDER + BEGIN_PROVIDER [ integer(bit_kind), psi_ref_restart, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_ref_coef_restart, (psi_det_size,n_states) ] + implicit none + BEGIN_DOC + ! Projection of the CAS wave function on the restart wave function. + END_DOC + integer :: i,j,k + integer, save :: ifirst + + if(ifirst == 0)then + ifirst = 1 + do i=1,N_det_ref + do k=1,N_int + psi_ref_restart(k,1,i) = psi_cas(k,1,i) + psi_ref_restart(k,2,i) = psi_cas(k,2,i) + enddo + enddo + do k=1,N_states + do i=1,N_det_ref + psi_ref_coef_restart(i,k) = psi_cas_coef(i,k) + enddo + enddo + endif + +END_PROVIDER + diff --git a/plugins/Psiref_Utils/README.rst b/plugins/Psiref_Utils/README.rst index 75269412..8b25e0a1 100644 --- a/plugins/Psiref_Utils/README.rst +++ b/plugins/Psiref_Utils/README.rst @@ -13,3 +13,109 @@ Documentation .. Do not edit this section. It was auto-generated from the .. by the `update_README.py` script. +`get_index_in_psi_ref_sorted_bit `_ + Returns the index of the determinant in the ``psi_ref_sorted_bit`` array + + +`h_matrix_ref `_ + Undocumented + + +`holes_operators `_ + holes_operators represents an array of integers where all the holes have + been done going from psi_ref to psi_non_ref + particles_operators represents an array of integers where all the particles have + been done going from psi_ref to psi_non_ref + + +`idx_non_ref `_ + Set of determinants which are not part of the reference, defined from the application + of the reference bitmask on the determinants. + idx_non_ref gives the indice of the determinant in psi_det. + idx_non_ref_rev gives the reverse. + + +`idx_non_ref_rev `_ + Set of determinants which are not part of the reference, defined from the application + of the reference bitmask on the determinants. + idx_non_ref gives the indice of the determinant in psi_det. + idx_non_ref_rev gives the reverse. + + +`is_in_psi_ref `_ + True if the determinant ``det`` is in the wave function + + +`n_det_non_ref `_ + Set of determinants which are not part of the reference, defined from the application + of the reference bitmask on the determinants. + idx_non_ref gives the indice of the determinant in psi_det. + idx_non_ref_rev gives the reverse. + + +`particles_operators `_ + holes_operators represents an array of integers where all the holes have + been done going from psi_ref to psi_non_ref + particles_operators represents an array of integers where all the particles have + been done going from psi_ref to psi_non_ref + + +`psi_coef_ref_diagonalized `_ + Undocumented + + +`psi_non_ref `_ + Set of determinants which are not part of the reference, defined from the application + of the reference bitmask on the determinants. + idx_non_ref gives the indice of the determinant in psi_det. + idx_non_ref_rev gives the reverse. + + +`psi_non_ref_coef `_ + Set of determinants which are not part of the reference, defined from the application + of the reference bitmask on the determinants. + idx_non_ref gives the indice of the determinant in psi_det. + idx_non_ref_rev gives the reverse. + + +`psi_non_ref_coef_restart `_ + Set of determinants which are not part of the reference, defined from the application + of the reference bitmask on the determinants. + idx_non_ref gives the indice of the determinant in psi_det. + But this is with respect to the restart wave function. + + +`psi_non_ref_coef_sorted_bit `_ + Reference determinants sorted to accelerate the search of a random determinant in the wave + function. + + +`psi_non_ref_restart `_ + Set of determinants which are not part of the reference, defined from the application + of the reference bitmask on the determinants. + idx_non_ref gives the indice of the determinant in psi_det. + But this is with respect to the restart wave function. + + +`psi_non_ref_sorted_bit `_ + Reference determinants sorted to accelerate the search of a random determinant in the wave + function. + + +`psi_ref_coef_sorted_bit `_ + Reference determinants sorted to accelerate the search of a random determinant in the wave + function. + + +`psi_ref_energy `_ + Undocumented + + +`psi_ref_energy_diagonalized `_ + Undocumented + + +`psi_ref_sorted_bit `_ + Reference determinants sorted to accelerate the search of a random determinant in the wave + function. + diff --git a/plugins/Psiref_Utils/psi_ref.irp.f b/plugins/Psiref_Utils/psi_ref.irp.f deleted file mode 100644 index 852df2d3..00000000 --- a/plugins/Psiref_Utils/psi_ref.irp.f +++ /dev/null @@ -1,36 +0,0 @@ -use bitmasks - - BEGIN_PROVIDER [ integer(bit_kind), psi_ref, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_ref_coef, (psi_det_size,n_states) ] -&BEGIN_PROVIDER [ integer, idx_ref, (psi_det_size) ] -&BEGIN_PROVIDER [ integer, N_det_ref ] - implicit none - BEGIN_DOC - ! Reference wave function, defined as determinants with coefficients > 0.05 - ! idx_ref gives the indice of the ref determinant in psi_det. - END_DOC - integer :: i, k, l - logical :: good - N_det_ref = 0 - do i=1,N_det - good = .False. - do l = 1, N_states - psi_ref_coef(i,l) = 0.d0 - good = good.or.(dabs(psi_coef(i,l)) > 0.05d0) - enddo - if (good) then - N_det_ref = N_det_ref+1 - do k=1,N_int - psi_ref(k,1,N_det_ref) = psi_det(k,1,i) - psi_ref(k,2,N_det_ref) = psi_det(k,2,i) - enddo - idx_ref(N_det_ref) = i - do k=1,N_states - psi_ref_coef(N_det_ref,k) = psi_coef(i,k) - enddo - endif - enddo - call write_int(output_determinants,N_det_ref, 'Number of determinants in the reference') - -END_PROVIDER - diff --git a/plugins/Psiref_Utils/psi_ref_excitations_operators.irp.f b/plugins/Psiref_Utils/psi_ref_excitations_operators.irp.f new file mode 100644 index 00000000..d1fe493e --- /dev/null +++ b/plugins/Psiref_Utils/psi_ref_excitations_operators.irp.f @@ -0,0 +1,45 @@ +use bitmasks + + BEGIN_PROVIDER [integer(bit_kind), holes_operators, (N_int,2)] +&BEGIN_PROVIDER [integer(bit_kind), particles_operators, (N_int,2)] + + BEGIN_DOC + ! holes_operators represents an array of integers where all the holes have + ! been done going from psi_ref to psi_non_ref + ! particles_operators represents an array of integers where all the particles have + ! been done going from psi_ref to psi_non_ref + END_DOC + holes_operators = 0_bit_kind + particles_operators = 0_bit_kind + implicit none + integer(bit_kind), allocatable :: key_test(:,:) + integer(bit_kind), allocatable :: holes(:,:),particles(:,:) + allocate(key_test(N_int,2)) + allocate(holes(N_int,2),particles(N_int,2)) + integer :: i,j,k + print*,'providing holes_operators and particles_operators' + do i = 1, N_det_ref + do j = 1, N_det_non_ref + do k = 1, N_int + key_test(k,1) = xor(psi_ref(k,1,i),psi_non_ref(k,1,j)) + key_test(k,2) = xor(psi_ref(k,2,i),psi_non_ref(k,2,j)) + enddo + do k = 1,N_int + holes(k,1) = iand(psi_ref(k,1,i),key_test(k,1)) + holes(k,2) = iand(psi_ref(k,2,i),key_test(k,2)) + particles(k,1) = iand(psi_non_ref(k,1,j),key_test(k,1)) + particles(k,2) = iand(psi_non_ref(k,2,j),key_test(k,2)) + enddo + do k = 1, N_int + holes_operators(k,1) = ior(holes_operators(k,1),holes(k,1)) + holes_operators(k,2) = ior(holes_operators(k,2),holes(k,2)) + particles_operators(k,1) = ior(particles_operators(k,1),particles(k,1)) + particles_operators(k,2) = ior(particles_operators(k,2),particles(k,2)) + enddo + enddo + enddo + + deallocate(key_test) + deallocate(holes,particles) + +END_PROVIDER diff --git a/plugins/Psiref_Utils/psi_ref_utils.irp.f b/plugins/Psiref_Utils/psi_ref_utils.irp.f index c5e80199..f9cf1303 100644 --- a/plugins/Psiref_Utils/psi_ref_utils.irp.f +++ b/plugins/Psiref_Utils/psi_ref_utils.irp.f @@ -18,17 +18,20 @@ END_PROVIDER BEGIN_PROVIDER [ integer(bit_kind), psi_non_ref, (N_int,2,psi_det_size) ] &BEGIN_PROVIDER [ double precision, psi_non_ref_coef, (psi_det_size,n_states) ] &BEGIN_PROVIDER [ integer, idx_non_ref, (psi_det_size) ] +&BEGIN_PROVIDER [ integer, idx_non_ref_rev, (psi_det_size) ] &BEGIN_PROVIDER [ integer, N_det_non_ref ] implicit none BEGIN_DOC ! Set of determinants which are not part of the reference, defined from the application ! of the reference bitmask on the determinants. ! idx_non_ref gives the indice of the determinant in psi_det. + ! idx_non_ref_rev gives the reverse. END_DOC integer :: i_non_ref,j,k integer :: degree logical :: in_ref i_non_ref =0 + idx_non_ref_rev = 0 do k=1,N_det in_ref = .False. do j=1,N_det_ref @@ -49,11 +52,54 @@ END_PROVIDER psi_non_ref_coef(i_non_ref,j) = psi_coef(k,j) enddo idx_non_ref(i_non_ref) = k + idx_non_ref_rev(k) = i_non_ref endif enddo N_det_non_ref = i_non_ref END_PROVIDER + BEGIN_PROVIDER [ integer(bit_kind), psi_non_ref_restart, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_non_ref_coef_restart, (psi_det_size,n_states) ] + implicit none + BEGIN_DOC + ! Set of determinants which are not part of the reference, defined from the application + ! of the reference bitmask on the determinants. + ! idx_non_ref gives the indice of the determinant in psi_det. + ! But this is with respect to the restart wave function. + END_DOC + integer :: i_non_ref,j,k + integer :: degree + logical :: in_ref + integer, save :: ifirst = 0 + if(ifirst==0)then + ifirst = 1 + i_non_ref =0 + do k=1,N_det + in_ref = .False. + do j=1,N_det_ref + call get_excitation_degree(psi_ref(1,1,j), psi_det(1,1,k), degree, N_int) + if (degree == 0) then + in_ref = .True. + exit + endif + enddo + if (.not.in_ref) then + double precision :: hij + i_non_ref += 1 + do j=1,N_int + psi_non_ref_restart(j,1,i_non_ref) = psi_det(j,1,k) + psi_non_ref_restart(j,2,i_non_ref) = psi_det(j,2,k) + enddo + do j=1,N_states + psi_non_ref_coef_restart(i_non_ref,j) = psi_coef(k,j) + enddo + endif + enddo + endif +END_PROVIDER + + + BEGIN_PROVIDER [ integer(bit_kind), psi_non_ref_sorted_bit, (N_int,2,psi_det_size) ] &BEGIN_PROVIDER [ double precision, psi_non_ref_coef_sorted_bit, (psi_det_size,N_states) ] implicit none @@ -119,5 +165,102 @@ END_PROVIDER END_PROVIDER +logical function is_in_psi_ref(key,Nint) + use bitmasks + implicit none + BEGIN_DOC +! True if the determinant ``det`` is in the wave function + END_DOC + integer, intent(in) :: Nint + integer(bit_kind), intent(in) :: key(Nint,2) + integer, external :: get_index_in_psi_ref_sorted_bit + !DIR$ FORCEINLINE + is_in_psi_ref = get_index_in_psi_ref_sorted_bit(key,Nint) > 0 +end + +integer function get_index_in_psi_ref_sorted_bit(key,Nint) + use bitmasks + BEGIN_DOC +! Returns the index of the determinant in the ``psi_ref_sorted_bit`` array + END_DOC + implicit none + + integer, intent(in) :: Nint + integer(bit_kind), intent(in) :: key(Nint,2) + + integer :: i, ibegin, iend, istep, l + integer*8 :: det_ref, det_search + integer*8, external :: det_search_key + logical :: in_wavefunction + + in_wavefunction = .False. + get_index_in_psi_ref_sorted_bit = 0 + ibegin = 1 + iend = N_det+1 + + !DIR$ FORCEINLINE + det_ref = det_search_key(key,Nint) + !DIR$ FORCEINLINE + det_search = det_search_key(psi_ref_sorted_bit(1,1,1),Nint) + + istep = ishft(iend-ibegin,-1) + i=ibegin+istep + do while (istep > 0) + !DIR$ FORCEINLINE + det_search = det_search_key(psi_ref_sorted_bit(1,1,i),Nint) + if ( det_search > det_ref ) then + iend = i + else if ( det_search == det_ref ) then + exit + else + ibegin = i + endif + istep = ishft(iend-ibegin,-1) + i = ibegin + istep + end do + + !DIR$ FORCEINLINE + do while (det_search_key(psi_ref_sorted_bit(1,1,i),Nint) == det_ref) + i = i-1 + if (i == 0) then + exit + endif + enddo + i += 1 + + if (i > N_det) then + return + endif + + !DIR$ FORCEINLINE + do while (det_search_key(psi_ref_sorted_bit(1,1,i),Nint) == det_ref) + if ( (key(1,1) /= psi_ref_sorted_bit(1,1,i)).or. & + (key(1,2) /= psi_ref_sorted_bit(1,2,i)) ) then + continue + else + in_wavefunction = .True. + !DIR$ IVDEP + !DIR$ LOOP COUNT MIN(3) + do l=2,Nint + if ( (key(l,1) /= psi_ref_sorted_bit(l,1,i)).or. & + (key(l,2) /= psi_ref_sorted_bit(l,2,i)) ) then + in_wavefunction = .False. + endif + enddo + if (in_wavefunction) then + get_index_in_psi_ref_sorted_bit = i +! exit + return + endif + endif + i += 1 + if (i > N_det) then +! exit + return + endif + + enddo + +end diff --git a/plugins/QmcChem/.gitignore b/plugins/QmcChem/.gitignore index 6ed62124..f2a19776 100644 --- a/plugins/QmcChem/.gitignore +++ b/plugins/QmcChem/.gitignore @@ -20,4 +20,4 @@ ezfio_interface.irp.f irpf90.make irpf90_entities save_for_qmcchem -tags +tags \ No newline at end of file diff --git a/plugins/QmcChem/README.rst b/plugins/QmcChem/README.rst index 8debf80c..0c5e452f 100644 --- a/plugins/QmcChem/README.rst +++ b/plugins/QmcChem/README.rst @@ -26,7 +26,7 @@ Documentation Undocumented -`test_pseudo_grid_ao `_ +`test_pseudo_grid_ao `_ Undocumented diff --git a/plugins/QmcChem/pot_ao_pseudo_ints.irp.f b/plugins/QmcChem/pot_ao_pseudo_ints.irp.f index 9ab4ac63..bc45f256 100644 --- a/plugins/QmcChem/pot_ao_pseudo_ints.irp.f +++ b/plugins/QmcChem/pot_ao_pseudo_ints.irp.f @@ -88,8 +88,14 @@ BEGIN_PROVIDER [ double precision, mo_pseudo_grid, (ao_num,-pseudo_lmax:pseudo_l do k=1,nucl_num do l=0,pseudo_lmax do m=-l,l - do j=1,mo_tot_num - do i=1,ao_num + do i=1,ao_num + do j=1,mo_tot_num + if (dabs(ao_pseudo_grid(i,m,l,k,n)) < 1.e-12) then + cycle + endif + if (dabs(mo_coef(i,j)) < 1.e-8) then + cycle + endif mo_pseudo_grid(j,m,l,k,n) = mo_pseudo_grid(j,m,l,k,n) + & ao_pseudo_grid(i,m,l,k,n) * mo_coef(i,j) enddo diff --git a/plugins/SingleRefMethod/tree_dependency.png b/plugins/SingleRefMethod/tree_dependency.png index 74fe5cca..2b7f777f 100644 Binary files a/plugins/SingleRefMethod/tree_dependency.png and b/plugins/SingleRefMethod/tree_dependency.png differ diff --git a/scripts/compilation/qp_create_ninja.py b/scripts/compilation/qp_create_ninja.py index 0ff96f7e..36252007 100755 --- a/scripts/compilation/qp_create_ninja.py +++ b/scripts/compilation/qp_create_ninja.py @@ -161,7 +161,7 @@ def get_l_ezfio_config(): def ninja_ezfio_cfg_rule(): """ - Return the ezfio_interface rule who will create + Return the ezfio_interface rule which will create the _ezfio_interface.irp.f the _ezfio_config from the EZFIO.cfg """ @@ -309,7 +309,7 @@ def ninja_symlink_rule(): def ninja_symlink_build(path_module, l_symlink): """ Create the symlink - and the l_symlink who are all the symlink list + and the l_symlink which are all the symlink list """ if not l_symlink: @@ -400,7 +400,7 @@ def get_l_file_for_module(path_module): def get_file_dependency(d_info_module): """ - For a module return all the irp.f90 file who depend + For a module return all the irp.f90 needed files """ d_irp = defaultdict(dict) @@ -578,13 +578,13 @@ def get_binaries(path_module): def get_dict_binaries(l_module, mode="production"): """ Return a dict [module] = list_binaries - If a the production mode is enable only header module - who will produce all binaries + If the production mode is enabled, return header modules + which will produce all binaries Example : The module Full_CI can produce the binary SCF so you dont need to compile at all the module Hartree-Fock - But you need to change the path acordingly + But you need to change the path accordingly Full_CI/Hartree-Fock/SCF """ d_binaries = defaultdict(list) @@ -907,12 +907,10 @@ if __name__ == "__main__": for module in dict_root_path.values(): if module not in d_binaries: - l_msg = ["{0} is a root module but he do not containt a main file", - "Is intolerable !", - "You need a main file:", + l_msg = ["{0} is a root module but does not contain a main file.", "- Create it in {0}", "- Or delete {0} `qp_install_module.py uninstall {0}`", - "- Or install a module who need {0} with a main "] + "- Or install a module that needs {0} with a main "] print "\n".join(l_msg).format(module.rel) sys.exit(1) diff --git a/scripts/ezfio_interface/ei_handler.py b/scripts/ezfio_interface/ei_handler.py index b25ebe6f..2a250268 100755 --- a/scripts/ezfio_interface/ei_handler.py +++ b/scripts/ezfio_interface/ei_handler.py @@ -33,7 +33,7 @@ Required: doc: The plain text documentation type: A Fancy_type supported by the ocaml. type `ei_handler.py get_supported_type` for a list - interface: The interface is list of string sepeared by "," who can containt : + interface: The interface is list of string sepeared by "," which can contain : - ezfio (if you only whant the ezfiolib) - provider (if you want the provider) - ocaml (if you want the ocaml gestion) @@ -233,7 +233,7 @@ def get_dict_config_file(module_obj): d[pvd]["module"] = module_obj - # Create the dictionary who containt the value per default + # Create the dictionary which contains the default value d_default = {"ezfio_name": pvd, "ezfio_dir": module_obj.lower, "size": "1"} @@ -309,7 +309,7 @@ def create_ezfio_provider(dict_ezfio_cfg): interface, default size} - create the a list who containt all the code for the provider + create the a list which contains all the code for the provider output = output_dict_info['ezfio_dir' return [code, ...] """ @@ -613,8 +613,8 @@ def save_ocaml_input(module_lower, str_ocaml_input): def get_l_module_with_auto_generate_ocaml_lower(): """ - Get all module who have EZFIO.cfg with ocaml data - (NB `search` in all the ligne and `match` only in one) + Get all modules which have EZFIO.cfg with Ocaml data + (NB `search` in all the lines and `match` only in one) """ # ~#~#~#~#~#~#~#~ # diff --git a/scripts/generate_h_apply.py b/scripts/generate_h_apply.py index ce944864..51ef5090 100755 --- a/scripts/generate_h_apply.py +++ b/scripts/generate_h_apply.py @@ -28,6 +28,7 @@ filterhole filterparticle do_double_excitations check_double_excitation +filter_vvvv_excitation """.split() class H_apply(object): @@ -51,7 +52,7 @@ class H_apply(object): !$OMP accu,i_a,hole_tmp,particle_tmp,occ_particle_tmp, & !$OMP occ_hole_tmp,key_idx,i_b,j_b,key,N_elec_in_key_part_1,& !$OMP N_elec_in_key_hole_1,N_elec_in_key_part_2, & - !$OMP N_elec_in_key_hole_2,ia_ja_pairs) & + !$OMP N_elec_in_key_hole_2,ia_ja_pairs,key_union_hole_part) & !$OMP SHARED(key_in,N_int,elec_num_tab,mo_tot_num, & !$OMP hole_1, particl_1, hole_2, particl_2, & !$OMP elec_alpha_num,i_generator) FIRSTPRIVATE(iproc)""" @@ -126,6 +127,21 @@ class H_apply(object): self["check_double_excitation"] = """ check_double_excitation = .False. """ + + def filter_vvvv_excitation(self): + self["filter_vvvv_excitation"] = """ + key_union_hole_part = 0_bit_kind + call set_bite_to_integer(i_a,key_union_hole_part,N_int) + call set_bite_to_integer(j_a,key_union_hole_part,N_int) + call set_bite_to_integer(i_b,key_union_hole_part,N_int) + call set_bite_to_integer(j_b,key_union_hole_part,N_int) + do jtest_vvvv = 1, N_int + if(iand(key_union_hole_part(jtest_vvvv),virt_bitmask(jtest_vvvv,1).ne.key_union_hole_part(jtest_vvvv)))then + b_cycle = .False. + endif + enddo + if(b_cycle) cycle + """ def set_filter_holes(self): self["filterhole"] = """ if(iand(ibset(0_bit_kind,j),hole(k,other_spin)).eq.0_bit_kind )cycle diff --git a/scripts/module/module_handler.py b/scripts/module/module_handler.py index 1e3546df..b491fd9d 100755 --- a/scripts/module/module_handler.py +++ b/scripts/module/module_handler.py @@ -244,7 +244,10 @@ if __name__ == '__main__': print " ".join(sorted(m.l_descendant_unique([module]))) if arguments["create_png"]: - m.create_png(l_module) + try: + m.create_png(l_module) + except RuntimeError: + pass if arguments["clean"] or arguments["create_git_ignore"]: diff --git a/src/Bitmask/README.rst b/src/Bitmask/README.rst index 6f3696b4..4a128f43 100644 --- a/src/Bitmask/README.rst +++ b/src/Bitmask/README.rst @@ -72,7 +72,7 @@ Documentation Transform a bit string to a string for printing -`cas_bitmask `_ +`cas_bitmask `_ Bitmasks for CAS reference determinants. (N_int, alpha/beta, CAS reference) @@ -80,6 +80,10 @@ Documentation Bitmask to include all possible single excitations from Hartree-Fock +`core_bitmask `_ + Reunion of the inactive, active and virtual bitmasks + + `debug_det `_ Subroutine to print the content of a determinant in '+-' notation and hexadecimal representation. @@ -94,7 +98,27 @@ Documentation Bitmask to include all possible MOs -`generators_bitmask `_ +`generators_bitmask `_ + Bitmasks for generator determinants. + (N_int, alpha/beta, hole/particle, generator). + .br + 3rd index is : + .br + * 1 : hole for single exc + .br + * 2 : particle for single exc + .br + * 3 : hole for 1st exc of double + .br + * 4 : particle for 1st exc of double + .br + * 5 : hole for 2nd exc of double + .br + * 6 : particle for 2nd exc of double + .br + + +`generators_bitmask_restart `_ Bitmasks for generator determinants. (N_int, alpha/beta, hole/particle, generator). .br @@ -118,24 +142,36 @@ Documentation Hartree Fock bit mask -`i_bitmask_gen `_ +`i_bitmask_gen `_ Current bitmask for the generators -`inact_bitmask `_ +`inact_bitmask `_ Bitmasks for the inactive orbitals that are excited in post CAS method +`inact_virt_bitmask `_ + Reunion of the inactive and virtual bitmasks + + `is_a_two_holes_two_particles `_ Undocumented +`list_inact `_ + Undocumented + + `list_to_bitstring `_ Returns the physical string "string(N_int,2)" from the array of occupations "list(N_int*bit_kind_size,2) -`n_cas_bitmask `_ +`list_virt `_ + Undocumented + + +`n_cas_bitmask `_ Number of bitmasks for CAS @@ -143,10 +179,18 @@ Documentation Number of bitmasks for generators +`n_inact_orb `_ + Bitmasks for the inactive orbitals that are excited in post CAS method + + `n_int `_ Number of 64-bit integers needed to represent determinants as binary strings +`n_virt_orb `_ + Bitmasks for the inactive orbitals that are excited in post CAS method + + `number_of_holes `_ Undocumented @@ -175,6 +219,14 @@ Documentation Reference bit mask, used in Slater rules, chosen as Hartree-Fock bitmask -`virt_bitmask `_ +`reunion_of_bitmask `_ + Reunion of the inactive, active and virtual bitmasks + + +`unpaired_alpha_electrons `_ + Bitmask reprenting the unpaired alpha electrons in the HF_bitmask + + +`virt_bitmask `_ Bitmasks for the inactive orbitals that are excited in post CAS method diff --git a/src/Bitmask/bitmasks.irp.f b/src/Bitmask/bitmasks.irp.f index 2d044ca5..044fa18b 100644 --- a/src/Bitmask/bitmasks.irp.f +++ b/src/Bitmask/bitmasks.irp.f @@ -97,6 +97,53 @@ BEGIN_PROVIDER [ integer, N_generators_bitmask ] END_PROVIDER + + + +BEGIN_PROVIDER [ integer(bit_kind), generators_bitmask_restart, (N_int,2,6,N_generators_bitmask) ] + implicit none + BEGIN_DOC + ! Bitmasks for generator determinants. + ! (N_int, alpha/beta, hole/particle, generator). + ! + ! 3rd index is : + ! + ! * 1 : hole for single exc + ! + ! * 2 : particle for single exc + ! + ! * 3 : hole for 1st exc of double + ! + ! * 4 : particle for 1st exc of double + ! + ! * 5 : hole for 2nd exc of double + ! + ! * 6 : particle for 2nd exc of double + ! + END_DOC + logical :: exists + PROVIDE ezfio_filename + + call ezfio_has_bitmasks_generators(exists) + if (exists) then + call ezfio_get_bitmasks_generators(generators_bitmask_restart) + else + integer :: k, ispin + do k=1,N_generators_bitmask + do ispin=1,2 + generators_bitmask_restart(:,ispin,s_hole ,k) = full_ijkl_bitmask(:,d_hole1) + generators_bitmask_restart(:,ispin,s_part ,k) = full_ijkl_bitmask(:,d_part1) + generators_bitmask_restart(:,ispin,d_hole1,k) = full_ijkl_bitmask(:,d_hole1) + generators_bitmask_restart(:,ispin,d_part1,k) = full_ijkl_bitmask(:,d_part1) + generators_bitmask_restart(:,ispin,d_hole2,k) = full_ijkl_bitmask(:,d_hole2) + generators_bitmask_restart(:,ispin,d_part2,k) = full_ijkl_bitmask(:,d_part2) + enddo + enddo + endif + +END_PROVIDER + + BEGIN_PROVIDER [ integer(bit_kind), generators_bitmask, (N_int,2,6,N_generators_bitmask) ] implicit none BEGIN_DOC @@ -176,38 +223,144 @@ BEGIN_PROVIDER [ integer(bit_kind), cas_bitmask, (N_int,2,N_cas_bitmask) ] ! Bitmasks for CAS reference determinants. (N_int, alpha/beta, CAS reference) END_DOC logical :: exists - integer :: i + integer :: i,i_part,i_gen,j PROVIDE ezfio_filename call ezfio_has_bitmasks_cas(exists) if (exists) then + print*,'---------------------' + print*,'CAS BITMASK RESTART' call ezfio_get_bitmasks_cas(cas_bitmask) + print*,'---------------------' else + if(N_generators_bitmask == 1)then do i=1,N_cas_bitmask cas_bitmask(:,:,i) = iand(not(HF_bitmask(:,:)),full_ijkl_bitmask(:,:)) enddo + else + i_part = 2 + i_gen = 1 + do j = 1, N_cas_bitmask + do i = 1, N_int + cas_bitmask(i,1,j) = generators_bitmask_restart(i,1,i_part,i_gen) + cas_bitmask(i,2,j) = generators_bitmask_restart(i,2,i_part,i_gen) + enddo + enddo + endif endif END_PROVIDER BEGIN_PROVIDER [ integer(bit_kind), inact_bitmask, (N_int,2) ] &BEGIN_PROVIDER [ integer(bit_kind), virt_bitmask, (N_int,2) ] +&BEGIN_PROVIDER [ integer, n_inact_orb ] +&BEGIN_PROVIDER [ integer, n_virt_orb ] implicit none BEGIN_DOC ! Bitmasks for the inactive orbitals that are excited in post CAS method END_DOC logical :: exists - integer :: j + integer :: j,i + integer :: i_hole,i_part,i_gen PROVIDE ezfio_filename - do j = 1, N_int - inact_bitmask(j,1) = xor(generators_bitmask(j,1,1,1),cas_bitmask(j,1,1)) - inact_bitmask(j,2) = xor(generators_bitmask(j,2,1,1),cas_bitmask(j,2,1)) - virt_bitmask(j,1) = xor(generators_bitmask(j,1,2,1),cas_bitmask(j,1,1)) - virt_bitmask(j,2) = xor(generators_bitmask(j,2,2,1),cas_bitmask(j,2,1)) - enddo +!do j = 1, N_int +! inact_bitmask(j,1) = xor(generators_bitmask(j,1,1,1),cas_bitmask(j,1,1)) +! inact_bitmask(j,2) = xor(generators_bitmask(j,2,1,1),cas_bitmask(j,2,1)) +! virt_bitmask(j,1) = xor(generators_bitmask(j,1,2,1),cas_bitmask(j,1,1)) +! virt_bitmask(j,2) = xor(generators_bitmask(j,2,2,1),cas_bitmask(j,2,1)) +!enddo + n_inact_orb = 0 + n_virt_orb = 0 + if(N_generators_bitmask == 1)then + do j = 1, N_int + inact_bitmask(j,1) = xor(generators_bitmask_restart(j,1,1,1),cas_bitmask(j,1,1)) + inact_bitmask(j,2) = xor(generators_bitmask_restart(j,2,1,1),cas_bitmask(j,2,1)) + virt_bitmask(j,1) = xor(generators_bitmask_restart(j,1,2,1),cas_bitmask(j,1,1)) + virt_bitmask(j,2) = xor(generators_bitmask_restart(j,2,2,1),cas_bitmask(j,2,1)) + n_inact_orb += popcnt(inact_bitmask(j,1)) + n_virt_orb += popcnt(virt_bitmask(j,1)) + enddo + else + i_hole = 1 + i_gen = 1 + do i = 1, N_int + inact_bitmask(i,1) = generators_bitmask(i,1,i_hole,i_gen) + inact_bitmask(i,2) = generators_bitmask(i,2,i_hole,i_gen) + n_inact_orb += popcnt(inact_bitmask(i,1)) + enddo + i_part = 2 + i_gen = 3 + do i = 1, N_int + virt_bitmask(i,1) = generators_bitmask(i,1,i_part,i_gen) + virt_bitmask(i,2) = generators_bitmask(i,2,i_part,i_gen) + n_virt_orb += popcnt(virt_bitmask(i,1)) + enddo + endif END_PROVIDER + + + BEGIN_PROVIDER [ integer, list_inact, (n_inact_orb)] + &BEGIN_PROVIDER [ integer, list_virt, (n_virt_orb)] + implicit none + integer :: occ_inact(N_int*bit_kind_size) + integer :: itest,i + occ_inact = 0 + call bitstring_to_list(inact_bitmask(1,1), occ_inact(1), itest, N_int) + ASSERT(itest==n_inact_orb) + do i = 1, n_inact_orb + list_inact(i) = occ_inact(i) + enddo + + occ_inact = 0 + call bitstring_to_list(virt_bitmask(1,1), occ_inact(1), itest, N_int) + ASSERT(itest==n_virt_orb) + do i = 1, n_virt_orb + list_virt(i) = occ_inact(i) + enddo + + END_PROVIDER + + BEGIN_PROVIDER [ integer(bit_kind), reunion_of_bitmask, (N_int,2)] + implicit none + BEGIN_DOC + ! Reunion of the inactive, active and virtual bitmasks + END_DOC + integer :: i,j + do i = 1, N_int + reunion_of_bitmask(i,1) = ior(ior(cas_bitmask(i,1,1),inact_bitmask(i,1)),virt_bitmask(i,1)) + reunion_of_bitmask(i,2) = ior(ior(cas_bitmask(i,2,1),inact_bitmask(i,2)),virt_bitmask(i,2)) + enddo + END_PROVIDER + + + BEGIN_PROVIDER [ integer(bit_kind), inact_virt_bitmask, (N_int,2)] + implicit none + BEGIN_DOC + ! Reunion of the inactive and virtual bitmasks + END_DOC + integer :: i,j + do i = 1, N_int + inact_virt_bitmask(i,1) = ior(inact_bitmask(i,1),virt_bitmask(i,1)) + inact_virt_bitmask(i,2) = ior(inact_bitmask(i,2),virt_bitmask(i,2)) + enddo + END_PROVIDER + + BEGIN_PROVIDER [ integer(bit_kind), core_bitmask, (N_int,2)] + implicit none + BEGIN_DOC + ! Reunion of the inactive, active and virtual bitmasks + END_DOC + integer :: i,j + do i = 1, N_int + core_bitmask(i,1) = iand(ref_bitmask(i,1),reunion_of_bitmask(i,1)) + core_bitmask(i,2) = iand(ref_bitmask(i,2),reunion_of_bitmask(i,2)) + enddo + END_PROVIDER + + + BEGIN_PROVIDER [ integer, i_bitmask_gen ] implicit none BEGIN_DOC @@ -217,3 +370,14 @@ BEGIN_PROVIDER [ integer, i_bitmask_gen ] END_PROVIDER + BEGIN_PROVIDER [ integer(bit_kind), unpaired_alpha_electrons, (N_int)] + implicit none + BEGIN_DOC + ! Bitmask reprenting the unpaired alpha electrons in the HF_bitmask + END_DOC + integer :: i + unpaired_alpha_electrons = 0_bit_kind + do i = 1, N_int + unpaired_alpha_electrons(i) = xor(HF_bitmask(i,1),HF_bitmask(i,2)) + enddo + END_PROVIDER diff --git a/src/Determinants/.gitignore b/src/Determinants/.gitignore index 516d3a70..b11c7f14 100644 --- a/src/Determinants/.gitignore +++ b/src/Determinants/.gitignore @@ -15,7 +15,6 @@ Makefile.depend Nuclei Pseudo Utils -det_svd ezfio_interface.irp.f guess_doublet guess_singlet diff --git a/src/Determinants/H_apply.template.f b/src/Determinants/H_apply.template.f index a9a282ae..3a05ee0d 100644 --- a/src/Determinants/H_apply.template.f +++ b/src/Determinants/H_apply.template.f @@ -18,6 +18,7 @@ subroutine $subroutine_diexc(key_in, hole_1,particl_1, hole_2, particl_2, i_gene integer(bit_kind), allocatable :: hole_save(:,:) integer(bit_kind), allocatable :: key(:,:),hole(:,:), particle(:,:) integer(bit_kind), allocatable :: hole_tmp(:,:), particle_tmp(:,:) + integer(bit_kind), allocatable :: key_union_hole_part(:) integer :: ii,i,jj,j,k,ispin,l integer, allocatable :: occ_particle(:,:), occ_hole(:,:) integer, allocatable :: occ_particle_tmp(:,:), occ_hole_tmp(:,:) @@ -31,6 +32,7 @@ subroutine $subroutine_diexc(key_in, hole_1,particl_1, hole_2, particl_2, i_gene integer, allocatable :: ib_jb_pairs(:,:) double precision :: diag_H_mat_elem integer :: iproc + integer :: jtest_vvvv integer(omp_lock_kind), save :: lck, ifirst=0 if (ifirst == 0) then !$ call omp_init_lock(lck) @@ -38,6 +40,7 @@ subroutine $subroutine_diexc(key_in, hole_1,particl_1, hole_2, particl_2, i_gene endif logical :: check_double_excitation + logical :: b_cycle check_double_excitation = .True. iproc = iproc_in @@ -50,7 +53,7 @@ subroutine $subroutine_diexc(key_in, hole_1,particl_1, hole_2, particl_2, i_gene key(N_int,2),hole(N_int,2), particle(N_int,2), hole_tmp(N_int,2),& particle_tmp(N_int,2), occ_particle(N_int*bit_kind_size,2), & occ_hole(N_int*bit_kind_size,2), occ_particle_tmp(N_int*bit_kind_size,2),& - occ_hole_tmp(N_int*bit_kind_size,2)) + occ_hole_tmp(N_int*bit_kind_size,2),key_union_hole_part(N_int)) $init_thread @@ -151,6 +154,7 @@ subroutine $subroutine_diexc(key_in, hole_1,particl_1, hole_2, particl_2, i_gene ASSERT (j_b > 0) ASSERT (j_b <= mo_tot_num) if (array_pairs(i_b,j_b)) then + $filter_vvvv_excitation i+= 1 ib_jb_pairs(1,i) = i_b ib_jb_pairs(2,i) = j_b @@ -200,6 +204,7 @@ subroutine $subroutine_diexc(key_in, hole_1,particl_1, hole_2, particl_2, i_gene ASSERT (j_b <= mo_tot_num) if (j_b <= j_a) cycle if (array_pairs(i_b,j_b)) then + $filter_vvvv_excitation i+= 1 ib_jb_pairs(1,i) = i_b ib_jb_pairs(2,i) = j_b @@ -245,7 +250,7 @@ subroutine $subroutine_diexc(key_in, hole_1,particl_1, hole_2, particl_2, i_gene key,hole, particle, hole_tmp,& particle_tmp, occ_particle, & occ_hole, occ_particle_tmp,& - occ_hole_tmp,array_pairs) + occ_hole_tmp,array_pairs,key_union_hole_part) $omp_end_parallel $finalization end @@ -278,6 +283,7 @@ subroutine $subroutine_monoexc(key_in, hole_1,particl_1,i_generator,iproc_in $pa integer :: N_elec_in_key_hole_1(2),N_elec_in_key_part_1(2) integer :: N_elec_in_key_hole_2(2),N_elec_in_key_part_2(2) logical :: is_a_two_holes_two_particles + integer(bit_kind), allocatable :: key_union_hole_part(:) integer, allocatable :: ia_ja_pairs(:,:,:) logical, allocatable :: array_pairs(:,:) @@ -305,7 +311,7 @@ subroutine $subroutine_monoexc(key_in, hole_1,particl_1,i_generator,iproc_in $pa key(N_int,2),hole(N_int,2), particle(N_int,2), hole_tmp(N_int,2),& particle_tmp(N_int,2), occ_particle(N_int*bit_kind_size,2), & occ_hole(N_int*bit_kind_size,2), occ_particle_tmp(N_int*bit_kind_size,2),& - occ_hole_tmp(N_int*bit_kind_size,2)) + occ_hole_tmp(N_int*bit_kind_size,2),key_union_hole_part(N_int)) $init_thread !!!! First couple hole particle do j = 1, N_int @@ -376,7 +382,7 @@ subroutine $subroutine_monoexc(key_in, hole_1,particl_1,i_generator,iproc_in $pa key,hole, particle, hole_tmp,& particle_tmp, occ_particle, & occ_hole, occ_particle_tmp,& - occ_hole_tmp) + occ_hole_tmp,key_union_hole_part) $omp_end_parallel $finalization diff --git a/src/Determinants/README.rst b/src/Determinants/README.rst index 1c114a19..2c2759ae 100644 --- a/src/Determinants/README.rst +++ b/src/Determinants/README.rst @@ -54,11 +54,7 @@ Documentation .. by the `update_README.py` script. -`a_operator `_ Needed for diag_H_mat_elem - - -`abs_psi_coef_max `_ Max and min values of the coefficients @@ -66,7 +62,7 @@ Documentation Max and min values of the coefficients -`ac_operator `_ +`ac_operator `_ Needed for diag_H_mat_elem @@ -152,8 +148,9 @@ Documentation After calling this subroutine, N_det, psi_det and psi_coef need to be touched -`create_wf_of_psi_svd_matrix `_ - Matrix of wf coefficients. Outer product of alpha and beta determinants +`create_wf_of_psi_bilinear_matrix `_ + Generate a wave function containing all possible products + of alpha and beta determinants `davidson_converged `_ @@ -228,7 +225,7 @@ Documentation det_coef -`det_connections `_ +`det_connections `_ Build connection proxy between determinants @@ -244,10 +241,6 @@ Documentation Return an integer*8 corresponding to a determinant index for searching -`det_svd `_ - Computes the SVD of the Alpha x Beta determinant coefficient matrix - - `det_to_occ_pattern `_ Transform a determinant to an occupation pattern @@ -256,7 +249,7 @@ Documentation Diagonalization algorithm (Davidson or Lapack) -`diag_h_mat_elem `_ +`diag_h_mat_elem `_ Computes @@ -358,7 +351,7 @@ Documentation Determinants are taken from the psi_det_sorted_ab array -`generate_all_alpha_beta_det_products `_ +`generate_all_alpha_beta_det_products `_ Create a wave function from all possible alpha x beta determinants @@ -374,7 +367,7 @@ Documentation Returns the excitation degree between two determinants -`get_excitation_degree_vector `_ +`get_excitation_degree_vector `_ Applies get_excitation_degree to an array of determinants @@ -394,7 +387,7 @@ Documentation Returns the excitation operator between two singly excited determinants and the phase -`get_occ_from_key `_ +`get_occ_from_key `_ Returns a list of occupation numbers from a bitstring @@ -428,7 +421,7 @@ Documentation Undocumented -`h_u_0 `_ +`h_u_0 `_ Computes v_0 = H|u_0> .br n : number of determinants @@ -440,15 +433,19 @@ Documentation Returns where i and j are determinants -`i_h_j_verbose `_ +`i_h_j_phase_out `_ Returns where i and j are determinants -`i_h_psi `_ +`i_h_j_verbose `_ + Returns where i and j are determinants + + +`i_h_psi `_ for the various Nstates -`i_h_psi_sc2 `_ +`i_h_psi_sc2 `_ for the various Nstate .br returns in addition @@ -462,7 +459,7 @@ Documentation to repeat the excitations -`i_h_psi_sc2_verbose `_ +`i_h_psi_sc2_verbose `_ for the various Nstate .br returns in addition @@ -476,7 +473,7 @@ Documentation to repeat the excitations -`i_h_psi_sec_ord `_ +`i_h_psi_sec_ord `_ for the various Nstates @@ -523,7 +520,7 @@ Documentation Energy of the reference bitmask used in Slater rules -`n_con_int `_ +`n_con_int `_ Number of integers to represent the connections between determinants @@ -640,6 +637,26 @@ Documentation Wave function sorted by determinants contribution to the norm (state-averaged) +`psi_bilinear_matrix `_ + Coefficient matrix if the wave function is expressed in a bilinear form : + D_a^t C D_b + + +`psi_bilinear_matrix_columns `_ + Sparse coefficient matrix if the wave function is expressed in a bilinear form : + D_a^t C D_b + + +`psi_bilinear_matrix_rows `_ + Sparse coefficient matrix if the wave function is expressed in a bilinear form : + D_a^t C D_b + + +`psi_bilinear_matrix_values `_ + Sparse coefficient matrix if the wave function is expressed in a bilinear form : + D_a^t C D_b + + `psi_cas `_ CAS wave function, defined from the application of the CAS bitmask on the determinants. idx_cas gives the indice of the CAS determinant in psi_det. @@ -781,34 +798,6 @@ Documentation psi_occ_pattern(:,2,j) = jth occ_pattern of the wave function : represent all the double occupation -`psi_svd_alpha `_ - SVD wave function - - -`psi_svd_beta `_ - SVD wave function - - -`psi_svd_coefs `_ - SVD wave function - - -`psi_svd_matrix `_ - Matrix of wf coefficients. Outer product of alpha and beta determinants - - -`psi_svd_matrix_columns `_ - Matrix of wf coefficients. Outer product of alpha and beta determinants - - -`psi_svd_matrix_rows `_ - Matrix of wf coefficients. Outer product of alpha and beta determinants - - -`psi_svd_matrix_values `_ - Matrix of wf coefficients. Outer product of alpha and beta determinants - - `put_gess `_ Undocumented @@ -874,10 +863,18 @@ Documentation Save the wave function into the EZFIO file +`save_wavefunction_specified `_ + Save the wave function into the EZFIO file + + `save_wavefunction_unsorted `_ Save the wave function into the EZFIO file +`set_bite_to_integer `_ + Undocumented + + `set_natural_mos `_ Set natural orbitals, obtained by diagonalization of the one-body density matrix in the MO basis diff --git a/src/Determinants/connected_to_ref.irp.f b/src/Determinants/connected_to_ref.irp.f index 3f4b62d2..49a3604a 100644 --- a/src/Determinants/connected_to_ref.irp.f +++ b/src/Determinants/connected_to_ref.irp.f @@ -33,13 +33,13 @@ end -logical function is_in_wavefunction(key,Nint,Ndet) +logical function is_in_wavefunction(key,Nint) use bitmasks implicit none BEGIN_DOC ! True if the determinant ``det`` is in the wave function END_DOC - integer, intent(in) :: Nint, Ndet + integer, intent(in) :: Nint integer(bit_kind), intent(in) :: key(Nint,2) integer, external :: get_index_in_psi_det_sorted_bit @@ -60,9 +60,9 @@ integer function get_index_in_psi_det_sorted_bit(key,Nint) integer :: i, ibegin, iend, istep, l integer*8 :: det_ref, det_search integer*8, external :: det_search_key - logical :: is_in_wavefunction + logical :: in_wavefunction - is_in_wavefunction = .False. + in_wavefunction = .False. get_index_in_psi_det_sorted_bit = 0 ibegin = 1 iend = N_det+1 @@ -107,16 +107,16 @@ integer function get_index_in_psi_det_sorted_bit(key,Nint) (key(1,2) /= psi_det_sorted_bit(1,2,i)) ) then continue else - is_in_wavefunction = .True. + in_wavefunction = .True. !DIR$ IVDEP !DIR$ LOOP COUNT MIN(3) do l=2,Nint if ( (key(l,1) /= psi_det_sorted_bit(l,1,i)).or. & (key(l,2) /= psi_det_sorted_bit(l,2,i)) ) then - is_in_wavefunction = .False. + in_wavefunction = .False. endif enddo - if (is_in_wavefunction) then + if (in_wavefunction) then get_index_in_psi_det_sorted_bit = i ! exit return @@ -131,7 +131,7 @@ integer function get_index_in_psi_det_sorted_bit(key,Nint) enddo ! DEBUG is_in_wf -! if (is_in_wavefunction) then +! if (in_wavefunction) then ! degree = 1 ! do i=1,N_det ! integer :: degree diff --git a/src/Determinants/create_excitations.irp.f b/src/Determinants/create_excitations.irp.f index a33525c7..a2acc8df 100644 --- a/src/Determinants/create_excitations.irp.f +++ b/src/Determinants/create_excitations.irp.f @@ -34,3 +34,14 @@ subroutine do_mono_excitation(key_in,i_hole,i_particle,ispin,i_ok) i_ok = -1 endif end + +subroutine set_bite_to_integer(i_physical,key,Nint) + use bitmasks + implicit none + integer, intent(in) :: i_physical,Nint + integer(bit_kind), intent(inout) :: key(Nint) + integer :: k,j,i + k = ishft(i_physical-1,-bit_kind_shift)+1 + j = i_physical-ishft(k-1,bit_kind_shift)-1 + key(k) = ibset(key(k),j) +end diff --git a/src/Determinants/davidson.irp.f b/src/Determinants/davidson.irp.f index e59fde4f..0c5610ae 100644 --- a/src/Determinants/davidson.irp.f +++ b/src/Determinants/davidson.irp.f @@ -12,7 +12,7 @@ BEGIN_PROVIDER [ integer, davidson_sze_max ] ! Max number of Davidson sizes END_DOC ASSERT (davidson_sze_max <= davidson_iter_max) - davidson_sze_max = 8*N_states_diag + davidson_sze_max = max(8,2*N_states_diag) END_PROVIDER subroutine davidson_diag(dets_in,u_in,energies,dim_in,sze,N_st,Nint,iunit) @@ -376,7 +376,7 @@ end ! Can be : [ energy | residual | both | wall_time | cpu_time | iterations ] END_DOC davidson_criterion = 'residual' - davidson_threshold = 1.d-9 + davidson_threshold = 1.d-10 END_PROVIDER subroutine davidson_converged(energy,residual,wall,iterations,cpu,N_st,converged) diff --git a/src/Determinants/det_svd.irp.f b/src/Determinants/det_svd.irp.f deleted file mode 100644 index 0a57acf3..00000000 --- a/src/Determinants/det_svd.irp.f +++ /dev/null @@ -1,61 +0,0 @@ -program det_svd - implicit none - BEGIN_DOC -! Computes the SVD of the Alpha x Beta determinant coefficient matrix - END_DOC - integer :: i,j,k - - read_wf = .True. - TOUCH read_wf - - print *, 'SVD matrix before filling' - print *, '=========================' - print *, '' - print *, 'N_det = ', N_det - print *, 'N_det_alpha = ', N_det_alpha_unique - print *, 'N_det_beta = ', N_det_beta_unique - print *, '' - -! do i=1,N_det_alpha_unique -! do j=1,N_det_beta_unique -! print *, i,j,psi_svd_matrix(i,j,:) -! enddo -! enddo - - print *, '' - print *, 'Energy = ', ci_energy - print *, '' - - print *, psi_svd_coefs(1:20,1) - - call generate_all_alpha_beta_det_products - print *, '' - print *, 'Energy = ', ci_energy - print *, '' - - print *, 'SVD matrix after filling' - print *, '========================' - print *, '' - print *, 'N_det = ', N_det - print *, 'N_det_alpha = ', N_det_alpha_unique - print *, 'N_det_beta = ', N_det_beta_unique - print *, '' - print *, '' - call diagonalize_ci - print *, 'Energy = ', ci_energy - - do i=1,N_det_alpha_unique - do j=1,N_det_beta_unique - do k=1,N_states - if (dabs(psi_svd_matrix(i,j,k)) < 1.d-15) then - psi_svd_matrix(i,j,k) = 0.d0 - endif - enddo - enddo - enddo - - print *, '' - print *, psi_svd_coefs(1:20,1) - call save_wavefunction - -end diff --git a/src/Determinants/determinants.irp.f b/src/Determinants/determinants.irp.f index 6834a745..d1c36163 100644 --- a/src/Determinants/determinants.irp.f +++ b/src/Determinants/determinants.irp.f @@ -749,3 +749,91 @@ end +subroutine save_wavefunction_specified(ndet,nstates,psidet,psicoef,ndetsave,index_det_save) + implicit none + BEGIN_DOC +! Save the wave function into the EZFIO file + END_DOC + use bitmasks + integer, intent(in) :: ndet,nstates + integer(bit_kind), intent(in) :: psidet(N_int,2,ndet) + double precision, intent(in) :: psicoef(ndet,nstates) + integer, intent(in) :: index_det_save(ndet) + integer, intent(in) :: ndetsave + integer*8, allocatable :: psi_det_save(:,:,:) + double precision, allocatable :: psi_coef_save(:,:) + integer*8 :: det_8(100) + integer(bit_kind) :: det_bk((100*8)/bit_kind) + integer :: N_int2 + equivalence (det_8, det_bk) + + integer :: i,k + + PROVIDE progress_bar + call start_progress(7,'Saving wfunction',0.d0) + + progress_bar(1) = 1 + progress_value = dble(progress_bar(1)) + call ezfio_set_determinants_N_int(N_int) + progress_bar(1) = 2 + progress_value = dble(progress_bar(1)) + call ezfio_set_determinants_bit_kind(bit_kind) + progress_bar(1) = 3 + progress_value = dble(progress_bar(1)) + call ezfio_set_determinants_N_det(ndetsave) + progress_bar(1) = 4 + progress_value = dble(progress_bar(1)) + call ezfio_set_determinants_n_states(nstates) + progress_bar(1) = 5 + progress_value = dble(progress_bar(1)) + call ezfio_set_determinants_mo_label(mo_label) + + progress_bar(1) = 6 + progress_value = dble(progress_bar(1)) + + N_int2 = (N_int*bit_kind)/8 + allocate (psi_det_save(N_int2,2,ndetsave)) + do i=1,ndetsave + do k=1,N_int + det_bk(k) = psidet(k,1,index_det_save(i)) + enddo + do k=1,N_int2 + psi_det_save(k,1,i) = det_8(k) + enddo + do k=1,N_int + det_bk(k) = psidet(k,2,index_det_save(i)) + enddo + do k=1,N_int2 + psi_det_save(k,2,i) = det_8(k) + enddo + enddo + call ezfio_set_determinants_psi_det(psi_det_save) + deallocate (psi_det_save) + + progress_bar(1) = 7 + progress_value = dble(progress_bar(1)) + allocate (psi_coef_save(ndetsave,nstates)) + double precision :: accu_norm(nstates) + accu_norm = 0.d0 + do k=1,nstates + do i=1,ndetsave + accu_norm(k) = accu_norm(k) + psicoef(index_det_save(i),k) * psicoef(index_det_save(i),k) + psi_coef_save(i,k) = psicoef(index_det_save(i),k) + enddo + enddo + do k = 1, nstates + accu_norm(k) = 1.d0/dsqrt(accu_norm(k)) + enddo + do k=1,nstates + do i=1,ndetsave + psi_coef_save(i,k) = psi_coef_save(i,k) * accu_norm(k) + enddo + enddo + + call ezfio_set_determinants_psi_coef(psi_coef_save) + call write_int(output_determinants,ndet,'Saved determinants') + call stop_progress + deallocate (psi_coef_save) +end + + diff --git a/src/Determinants/occ_pattern.irp.f b/src/Determinants/occ_pattern.irp.f index 8027cf60..aa059870 100644 --- a/src/Determinants/occ_pattern.irp.f +++ b/src/Determinants/occ_pattern.irp.f @@ -292,7 +292,7 @@ subroutine make_s2_eigenfunction endif call occ_pattern_to_dets(psi_occ_pattern(1,1,i),d,s,elec_alpha_num,N_int) do j=1,s - if (.not. is_in_wavefunction( d(1,1,j), N_int, N_det)) then + if (.not. is_in_wavefunction(d(1,1,j), N_int) ) then N_det_new += 1 do k=1,N_int det_buffer(k,1,N_det_new) = d(k,1,j) diff --git a/src/Determinants/slater_rules.irp.f b/src/Determinants/slater_rules.irp.f index a8b394d9..04fd983e 100644 --- a/src/Determinants/slater_rules.irp.f +++ b/src/Determinants/slater_rules.irp.f @@ -488,6 +488,141 @@ end +subroutine i_H_j_phase_out(key_i,key_j,Nint,hij,phase,exc,degree) + use bitmasks + implicit none + BEGIN_DOC + ! Returns where i and j are determinants + END_DOC + integer, intent(in) :: Nint + integer(bit_kind), intent(in) :: key_i(Nint,2), key_j(Nint,2) + double precision, intent(out) :: hij, phase + + integer,intent(out) :: exc(0:2,2,2) + integer,intent(out) :: degree + double precision :: get_mo_bielec_integral + integer :: m,n,p,q + integer :: i,j,k + integer :: occ(Nint*bit_kind_size,2) + double precision :: diag_H_mat_elem + integer :: n_occ_alpha, n_occ_beta + logical :: has_mipi(Nint*bit_kind_size) + double precision :: mipi(Nint*bit_kind_size), miip(Nint*bit_kind_size) + PROVIDE mo_bielec_integrals_in_map mo_integrals_map + + ASSERT (Nint > 0) + ASSERT (Nint == N_int) + ASSERT (sum(popcnt(key_i(:,1))) == elec_alpha_num) + ASSERT (sum(popcnt(key_i(:,2))) == elec_beta_num) + ASSERT (sum(popcnt(key_j(:,1))) == elec_alpha_num) + ASSERT (sum(popcnt(key_j(:,2))) == elec_beta_num) + + hij = 0.d0 + !DEC$ FORCEINLINE + call get_excitation_degree(key_i,key_j,degree,Nint) + select case (degree) + case (2) + call get_double_excitation(key_i,key_j,exc,phase,Nint) + if (exc(0,1,1) == 1) then + ! Mono alpha, mono beta + hij = phase*get_mo_bielec_integral( & + exc(1,1,1), & + exc(1,1,2), & + exc(1,2,1), & + exc(1,2,2) ,mo_integrals_map) + else if (exc(0,1,1) == 2) then + ! Double alpha + hij = phase*(get_mo_bielec_integral( & + exc(1,1,1), & + exc(2,1,1), & + exc(1,2,1), & + exc(2,2,1) ,mo_integrals_map) - & + get_mo_bielec_integral( & + exc(1,1,1), & + exc(2,1,1), & + exc(2,2,1), & + exc(1,2,1) ,mo_integrals_map) ) + else if (exc(0,1,2) == 2) then + ! Double beta + hij = phase*(get_mo_bielec_integral( & + exc(1,1,2), & + exc(2,1,2), & + exc(1,2,2), & + exc(2,2,2) ,mo_integrals_map) - & + get_mo_bielec_integral( & + exc(1,1,2), & + exc(2,1,2), & + exc(2,2,2), & + exc(1,2,2) ,mo_integrals_map) ) + endif + case (1) + call get_mono_excitation(key_i,key_j,exc,phase,Nint) + call bitstring_to_list(key_i(1,1), occ(1,1), n_occ_alpha, Nint) + call bitstring_to_list(key_i(1,2), occ(1,2), n_occ_beta, Nint) + has_mipi = .False. + if (exc(0,1,1) == 1) then + ! Mono alpha + m = exc(1,1,1) + p = exc(1,2,1) + do k = 1, elec_alpha_num + i = occ(k,1) + if (.not.has_mipi(i)) then + mipi(i) = get_mo_bielec_integral(m,i,p,i,mo_integrals_map) + miip(i) = get_mo_bielec_integral(m,i,i,p,mo_integrals_map) + has_mipi(i) = .True. + endif + enddo + do k = 1, elec_beta_num + i = occ(k,2) + if (.not.has_mipi(i)) then + mipi(i) = get_mo_bielec_integral(m,i,p,i,mo_integrals_map) + has_mipi(i) = .True. + endif + enddo + + do k = 1, elec_alpha_num + hij = hij + mipi(occ(k,1)) - miip(occ(k,1)) + enddo + do k = 1, elec_beta_num + hij = hij + mipi(occ(k,2)) + enddo + + else + ! Mono beta + m = exc(1,1,2) + p = exc(1,2,2) + do k = 1, elec_beta_num + i = occ(k,2) + if (.not.has_mipi(i)) then + mipi(i) = get_mo_bielec_integral(m,i,p,i,mo_integrals_map) + miip(i) = get_mo_bielec_integral(m,i,i,p,mo_integrals_map) + has_mipi(i) = .True. + endif + enddo + do k = 1, elec_alpha_num + i = occ(k,1) + if (.not.has_mipi(i)) then + mipi(i) = get_mo_bielec_integral(m,i,p,i,mo_integrals_map) + has_mipi(i) = .True. + endif + enddo + + do k = 1, elec_alpha_num + hij = hij + mipi(occ(k,1)) + enddo + do k = 1, elec_beta_num + hij = hij + mipi(occ(k,2)) - miip(occ(k,2)) + enddo + + endif + hij = phase*(hij + mo_mono_elec_integral(m,p)) + + case (0) + hij = diag_H_mat_elem(key_i,Nint) + end select +end + + subroutine i_H_j_verbose(key_i,key_j,Nint,hij,hmono,hdouble) use bitmasks @@ -825,7 +960,7 @@ subroutine get_excitation_degree_vector(key1,key2,degree,Nint,sze,idx) integer, intent(out) :: degree(sze) integer, intent(out) :: idx(0:sze) - integer :: i,l + integer :: i,l,d ASSERT (Nint > 0) ASSERT (sze > 0) @@ -835,9 +970,12 @@ subroutine get_excitation_degree_vector(key1,key2,degree,Nint,sze,idx) !DIR$ LOOP COUNT (1000) do i=1,sze - degree(l) = ishft(popcnt(xor( key1(1,1,i), key2(1,1))) + & - popcnt(xor( key1(1,2,i), key2(1,2))),-1) - if (degree(l) < 3) then + d = popcnt(xor( key1(1,1,i), key2(1,1))) + & + popcnt(xor( key1(1,2,i), key2(1,2))) + if (d > 4) then + cycle + else + degree(l) = ishft(d,-1) idx(l) = i l = l+1 endif @@ -847,13 +985,16 @@ subroutine get_excitation_degree_vector(key1,key2,degree,Nint,sze,idx) !DIR$ LOOP COUNT (1000) do i=1,sze - degree(l) = ishft(popcnt(xor( key1(1,1,i), key2(1,1))) + & + d = popcnt(xor( key1(1,1,i), key2(1,1))) + & popcnt(xor( key1(1,2,i), key2(1,2))) + & popcnt(xor( key1(2,1,i), key2(2,1))) + & - popcnt(xor( key1(2,2,i), key2(2,2))),-1) - if (degree(l) < 3) then - idx(l) = i - l = l+1 + popcnt(xor( key1(2,2,i), key2(2,2))) + if (d > 4) then + cycle + else + degree(l) = ishft(d,-1) + idx(l) = i + l = l+1 endif enddo @@ -861,15 +1002,18 @@ subroutine get_excitation_degree_vector(key1,key2,degree,Nint,sze,idx) !DIR$ LOOP COUNT (1000) do i=1,sze - degree(l) = ishft( popcnt(xor( key1(1,1,i), key2(1,1))) + & + d = popcnt(xor( key1(1,1,i), key2(1,1))) + & popcnt(xor( key1(1,2,i), key2(1,2))) + & popcnt(xor( key1(2,1,i), key2(2,1))) + & popcnt(xor( key1(2,2,i), key2(2,2))) + & popcnt(xor( key1(3,1,i), key2(3,1))) + & - popcnt(xor( key1(3,2,i), key2(3,2))),-1) - if (degree(l) < 3) then - idx(l) = i - l = l+1 + popcnt(xor( key1(3,2,i), key2(3,2))) + if (d > 4) then + cycle + else + degree(l) = ishft(d,-1) + idx(l) = i + l = l+1 endif enddo @@ -877,16 +1021,18 @@ subroutine get_excitation_degree_vector(key1,key2,degree,Nint,sze,idx) !DIR$ LOOP COUNT (1000) do i=1,sze - degree(l) = 0 + d = 0 !DEC$ LOOP COUNT MIN(4) do l=1,Nint - degree(l) = degree(l)+ popcnt(xor( key1(l,1,i), key2(l,1))) +& - popcnt(xor( key1(l,2,i), key2(l,2))) + d = d + popcnt(xor( key1(l,1,i), key2(l,1))) & + + popcnt(xor( key1(l,2,i), key2(l,2))) enddo - degree(l) = ishft(degree(l),-1) - if (degree(l) < 3) then - idx(l) = i - l = l+1 + if (d > 4) then + cycle + else + degree(l) = ishft(d,-1) + idx(l) = i + l = l+1 endif enddo @@ -1095,13 +1241,9 @@ subroutine H_u_0(v_0,u_0,H_jj,n,keys_tmp,Nint) !$OMP PARALLEL DEFAULT(NONE) & !$OMP PRIVATE(i,hij,j,k,idx,jj,vt) & !$OMP SHARED(n,H_jj,u_0,keys_tmp,Nint,v_0,davidson_threshold) - !$OMP DO SCHEDULE(static) - do i=1,n - v_0(i) = H_jj(i) * u_0(i) - enddo - !$OMP END DO allocate(idx(0:n), vt(n)) Vt = 0.d0 + v_0 = 0.d0 !$OMP DO SCHEDULE(guided) do i=1,n idx(0) = i @@ -1123,6 +1265,9 @@ subroutine H_u_0(v_0,u_0,H_jj,n,keys_tmp,Nint) !$OMP END CRITICAL deallocate(idx,vt) !$OMP END PARALLEL + do i=1,n + v_0(i) += H_jj(i) * u_0(i) + enddo end diff --git a/src/Determinants/spindeterminants.irp.f b/src/Determinants/spindeterminants.irp.f index ad9d9960..5994798d 100644 --- a/src/Determinants/spindeterminants.irp.f +++ b/src/Determinants/spindeterminants.irp.f @@ -151,9 +151,9 @@ integer function get_index_in_psi_det_alpha_unique(key,Nint) integer :: i, ibegin, iend, istep, l integer*8 :: det_ref, det_search integer*8, external :: spin_det_search_key - logical :: is_in_wavefunction + logical :: in_wavefunction - is_in_wavefunction = .False. + in_wavefunction = .False. get_index_in_psi_det_alpha_unique = 0 ibegin = 1 iend = N_det_alpha_unique + 1 @@ -198,15 +198,15 @@ integer function get_index_in_psi_det_alpha_unique(key,Nint) if (key(1) /= psi_det_alpha_unique(1,i)) then continue else - is_in_wavefunction = .True. + in_wavefunction = .True. !DIR$ IVDEP !DIR$ LOOP COUNT MIN(3) do l=2,Nint if (key(l) /= psi_det_alpha_unique(l,i)) then - is_in_wavefunction = .False. + in_wavefunction = .False. endif enddo - if (is_in_wavefunction) then + if (in_wavefunction) then get_index_in_psi_det_alpha_unique = i return endif @@ -233,9 +233,9 @@ integer function get_index_in_psi_det_beta_unique(key,Nint) integer :: i, ibegin, iend, istep, l integer*8 :: det_ref, det_search integer*8, external :: spin_det_search_key - logical :: is_in_wavefunction + logical :: in_wavefunction - is_in_wavefunction = .False. + in_wavefunction = .False. get_index_in_psi_det_beta_unique = 0 ibegin = 1 iend = N_det_beta_unique + 1 @@ -279,15 +279,15 @@ integer function get_index_in_psi_det_beta_unique(key,Nint) if (key(1) /= psi_det_beta_unique(1,i)) then continue else - is_in_wavefunction = .True. + in_wavefunction = .True. !DIR$ IVDEP !DIR$ LOOP COUNT MIN(3) do l=2,Nint if (key(l) /= psi_det_beta_unique(l,i)) then - is_in_wavefunction = .False. + in_wavefunction = .False. endif enddo - if (is_in_wavefunction) then + if (in_wavefunction) then get_index_in_psi_det_beta_unique = i return endif @@ -344,9 +344,9 @@ subroutine write_spindeterminants call ezfio_set_spindeterminants_psi_det_beta(psi_det_beta_unique) deallocate(tmpdet) - call ezfio_set_spindeterminants_psi_coef_matrix_values(psi_svd_matrix_values) - call ezfio_set_spindeterminants_psi_coef_matrix_rows(psi_svd_matrix_rows) - call ezfio_set_spindeterminants_psi_coef_matrix_columns(psi_svd_matrix_columns) + call ezfio_set_spindeterminants_psi_coef_matrix_values(psi_bilinear_matrix_values) + call ezfio_set_spindeterminants_psi_coef_matrix_rows(psi_bilinear_matrix_rows) + call ezfio_set_spindeterminants_psi_coef_matrix_columns(psi_bilinear_matrix_columns) end @@ -357,19 +357,19 @@ end ! ! !==============================================================================! -BEGIN_PROVIDER [ double precision, psi_svd_matrix_values, (N_det,N_states) ] -&BEGIN_PROVIDER [ integer, psi_svd_matrix_rows, (N_det) ] -&BEGIN_PROVIDER [ integer, psi_svd_matrix_columns, (N_det) ] +BEGIN_PROVIDER [ double precision, psi_bilinear_matrix_values, (N_det,N_states) ] +&BEGIN_PROVIDER [ integer, psi_bilinear_matrix_rows, (N_det) ] +&BEGIN_PROVIDER [ integer, psi_bilinear_matrix_columns, (N_det) ] use bitmasks implicit none BEGIN_DOC -! Matrix of wf coefficients. Outer product of alpha and beta determinants +! Sparse coefficient matrix if the wave function is expressed in a bilinear form : +! D_a^t C D_b END_DOC integer :: i,j,k, l integer(bit_kind) :: tmp_det(N_int,2) integer :: idx integer, external :: get_index_in_psi_det_sorted_bit - logical, external :: is_in_wavefunction PROVIDE psi_coef_sorted_bit @@ -383,47 +383,48 @@ BEGIN_PROVIDER [ double precision, psi_svd_matrix_values, (N_det,N_states) ] j = get_index_in_psi_det_beta_unique (psi_det(1,2,k),N_int) do l=1,N_states - psi_svd_matrix_values(k,l) = psi_coef(k,l) + psi_bilinear_matrix_values(k,l) = psi_coef(k,l) enddo - psi_svd_matrix_rows(k) = i - psi_svd_matrix_columns(k) = j + psi_bilinear_matrix_rows(k) = i + psi_bilinear_matrix_columns(k) = j to_sort(k) = N_det_alpha_unique * (j-1) + i iorder(k) = k enddo call isort(to_sort, iorder, N_det) - call iset_order(psi_svd_matrix_rows,iorder,N_det) - call iset_order(psi_svd_matrix_columns,iorder,N_det) - call dset_order(psi_svd_matrix_values,iorder,N_det) + call iset_order(psi_bilinear_matrix_rows,iorder,N_det) + call iset_order(psi_bilinear_matrix_columns,iorder,N_det) + call dset_order(psi_bilinear_matrix_values,iorder,N_det) deallocate(iorder,to_sort) END_PROVIDER -BEGIN_PROVIDER [ double precision, psi_svd_matrix, (N_det_alpha_unique,N_det_beta_unique,N_states) ] +BEGIN_PROVIDER [ double precision, psi_bilinear_matrix, (N_det_alpha_unique,N_det_beta_unique,N_states) ] implicit none BEGIN_DOC -! Matrix of wf coefficients. Outer product of alpha and beta determinants +! Coefficient matrix if the wave function is expressed in a bilinear form : +! D_a^t C D_b END_DOC integer :: i,j,k,istate - psi_svd_matrix = 0.d0 + psi_bilinear_matrix = 0.d0 do k=1,N_det - i = psi_svd_matrix_rows(k) - j = psi_svd_matrix_columns(k) + i = psi_bilinear_matrix_rows(k) + j = psi_bilinear_matrix_columns(k) do istate=1,N_states - psi_svd_matrix(i,j,istate) = psi_svd_matrix_values(k,istate) + psi_bilinear_matrix(i,j,istate) = psi_bilinear_matrix_values(k,istate) enddo enddo END_PROVIDER -subroutine create_wf_of_psi_svd_matrix +subroutine create_wf_of_psi_bilinear_matrix use bitmasks implicit none BEGIN_DOC -! Matrix of wf coefficients. Outer product of alpha and beta determinants +! Generate a wave function containing all possible products +! of alpha and beta determinants END_DOC integer :: i,j,k integer(bit_kind) :: tmp_det(N_int,2) integer :: idx integer, external :: get_index_in_psi_det_sorted_bit - logical, external :: is_in_wavefunction double precision :: norm(N_states) call generate_all_alpha_beta_det_products @@ -439,8 +440,8 @@ subroutine create_wf_of_psi_svd_matrix idx = get_index_in_psi_det_sorted_bit(tmp_det,N_int) if (idx > 0) then do k=1,N_states - psi_coef_sorted_bit(idx,k) = psi_svd_matrix(i,j,k) - norm(k) += psi_svd_matrix(i,j,k) + psi_coef_sorted_bit(idx,k) = psi_bilinear_matrix(i,j,k) + norm(k) += psi_bilinear_matrix(i,j,k) enddo endif enddo @@ -494,7 +495,7 @@ subroutine generate_all_alpha_beta_det_products tmp_det(k,1,l) = psi_det_alpha_unique(k,i) tmp_det(k,2,l) = psi_det_beta_unique (k,j) enddo - if (.not.is_in_wavefunction(tmp_det(1,1,l),N_int,N_det)) then + if (.not.is_in_wavefunction(tmp_det(1,1,l),N_int)) then l = l+1 endif enddo @@ -508,51 +509,4 @@ subroutine generate_all_alpha_beta_det_products SOFT_TOUCH psi_det psi_coef N_det end - BEGIN_PROVIDER [ double precision, psi_svd_alpha, (N_det_alpha_unique,N_det_alpha_unique,N_states) ] -&BEGIN_PROVIDER [ double precision, psi_svd_beta , (N_det_beta_unique,N_det_beta_unique,N_states) ] -&BEGIN_PROVIDER [ double precision, psi_svd_coefs, (N_det_beta_unique,N_states) ] - implicit none - BEGIN_DOC - ! SVD wave function - END_DOC - - integer :: lwork, info, istate - double precision, allocatable :: work(:), tmp(:,:), copy(:,:) - allocate (work(1),tmp(N_det_beta_unique,N_det_beta_unique), & - copy(size(psi_svd_matrix,1),size(psi_svd_matrix,2))) - - do istate = 1,N_states - copy(:,:) = psi_svd_matrix(:,:,istate) - lwork=-1 - call dgesvd('A','A', N_det_alpha_unique, N_det_beta_unique, & - copy, size(copy,1), & - psi_svd_coefs(1,istate), psi_svd_alpha(1,1,istate), & - size(psi_svd_alpha,1), & - tmp, size(psi_svd_beta,2), & - work, lwork, info) - lwork = work(1) - deallocate(work) - allocate(work(lwork)) - call dgesvd('A','A', N_det_alpha_unique, N_det_beta_unique, & - copy, size(copy,1), & - psi_svd_coefs(1,istate), psi_svd_alpha(1,1,istate), & - size(psi_svd_alpha,1), & - tmp, size(psi_svd_beta,2), & - work, lwork, info) - deallocate(work) - if (info /= 0) then - print *, irp_here//': error in det SVD' - stop 1 - endif - integer :: i,j - do j=1,N_det_beta_unique - do i=1,N_det_beta_unique - psi_svd_beta(i,j,istate) = tmp(j,i) - enddo - enddo - deallocate(tmp,copy) - enddo - -END_PROVIDER - diff --git a/src/Ezfio_files/README.rst b/src/Ezfio_files/README.rst new file mode 100644 index 00000000..c97e6268 --- /dev/null +++ b/src/Ezfio_files/README.rst @@ -0,0 +1,172 @@ +================== +Ezfio_files Module +================== + +This modules essentially contains the name of the EZFIO directory in the +``ezfio_filename`` variable. This is read as the first argument of the +command-line, or as the ``QP_INPUT`` environment variable. +Documentation +============= + +.. Do not edit this section. It was auto-generated from the +.. by the `update_README.py` script. + +`ezfio_filename `_ + Name of EZFIO file. It is obtained from the QPACKAGE_INPUT environment + variable if it is set, or as the 1st argument of the command line. + + +`getunitandopen `_ + :f: + file name + .br + :mode: + 'R' : READ, UNFORMATTED + 'W' : WRITE, UNFORMATTED + 'r' : READ, FORMATTED + 'w' : WRITE, FORMATTED + 'a' : APPEND, FORMATTED + 'x' : READ/WRITE, FORMATTED + .br + + +`output_ao_basis `_ + Output file for AO_Basis + + +`output_bitmask `_ + Output file for Bitmask + + +`output_cas_sd `_ + Output file for CAS_SD + + +`output_cis `_ + Output file for CIS + + +`output_cisd `_ + Output file for CISD + + +`output_cisd_selected `_ + Output file for CISD_selected + + +`output_cpu_time_0 `_ + Initial CPU and wall times when printing in the output files + + +`output_determinants `_ + Output file for Determinants + + +`output_electrons `_ + Output file for Electrons + + +`output_ezfio_files `_ + Output file for Ezfio_files + + +`output_full_ci `_ + Output file for Full_CI + + +`output_generators_cas `_ + Output file for Generators_CAS + + +`output_generators_full `_ + Output file for Generators_full + + +`output_hartree_fock `_ + Output file for Hartree_Fock + + +`output_integrals_bielec `_ + Output file for Integrals_Bielec + + +`output_integrals_monoelec `_ + Output file for Integrals_Monoelec + + +`output_mo_basis `_ + Output file for MO_Basis + + +`output_moguess `_ + Output file for MOGuess + + +`output_mrcc_cassd `_ + Output file for MRCC_CASSD + + +`output_mrcc_utils_new `_ + Output file for MRCC_Utils_new + + +`output_nuclei `_ + Output file for Nuclei + + +`output_perturbation `_ + Output file for Perturbation + + +`output_properties `_ + Output file for Properties + + +`output_pseudo `_ + Output file for Pseudo + + +`output_psiref_cas `_ + Output file for Psiref_CAS + + +`output_psiref_utils `_ + Output file for Psiref_Utils + + +`output_qmcchem `_ + Output file for QmcChem + + +`output_selectors_full `_ + Output file for Selectors_full + + +`output_singlerefmethod `_ + Output file for SingleRefMethod + + +`output_utils `_ + Output file for Utils + + +`output_wall_time_0 `_ + Initial CPU and wall times when printing in the output files + + +`write_bool `_ + Write an logical value in output + + +`write_double `_ + Write a double precision value in output + + +`write_int `_ + Write an integer value in output + + +`write_time `_ + Write a time stamp in the output for chronological reconstruction + +