diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..73299cba --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "external/ezfio"] + path = external/ezfio + url = https://gitlab.com/scemama/ezfio.git +[submodule "external/irpf90"] + path = external/irpf90 + url = https://gitlab.com/scemama/irpf90.git diff --git a/.travis.yml b/.travis.yml index 06fd4c96..bec11f5e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,6 @@ addons: # - liblapack-dev # - libblas-dev - wget - - eatmydata env: - OPAMROOT=$HOME/.opam @@ -45,9 +44,9 @@ stages: jobs: include: - stage: configuration - script: eatmydata travis/configuration.sh + script: travis/configuration.sh - stage: compilation - script: eatmydata travis/compilation.sh + script: travis/compilation.sh - stage: testing - script: eatmydata travis/testing.sh + script: travis/testing.sh diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 00000000..4e7cce4b --- /dev/null +++ b/AUTHORS @@ -0,0 +1,20 @@ +# If you contributed to this software, please make a pull request to add your +# name to this list (alphabetical order of the last name) + +- Thomas Applencourt +- Anouar Benali +- Michel Caffarel +- Grégoire David +- Anthony Ferté +- Yann Garniron +- Kevin Gasperich +- Vijay Gopal Chilkuri +- Emmanuel Giner +- Pierre-François Loos +- Jean-Paul Malrieu +- Julien Paquier +- Barthélémy Pradines +- Peter Reinhardt +- Anthony Scemama +- Julien Toulouse +- Mickaël Véril diff --git a/INSTALL.rst b/INSTALL.rst index dd961950..e12142db 100644 --- a/INSTALL.rst +++ b/INSTALL.rst @@ -28,6 +28,12 @@ and need to be installed. When all dependencies have been installed, ( the :command:`configure` will tell you) source the :file:`quantum_package.rc` in order to load all environment variables and compile the |QP|. +Now all the requirements are met, you can compile the programs using + +.. code:: bash + + make + Requirements ============ @@ -48,6 +54,7 @@ Requirements - `Bubblewrap `_ : Sandboxing tool required by Opam - `libcap `_ : POSIX capabilities required by Bubblewrap - |Ninja| : a parallel build system +- |pkg-config| : a tool which returns information about installed libraries When all the dependencies have been installed, go into the :file:`config` @@ -79,7 +86,7 @@ The command is to be used as follows: .. code:: bash - ./configure --install + ./configure --install= The following packages are supported by the :command:`configure` installer: diff --git a/README.md b/README.md index babe44a8..d5496f5e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Quantum Package 2.1 +# Quantum Package 2.2 diff --git a/RELEASE_NOTES.org b/RELEASE_NOTES.org new file mode 100644 index 00000000..f9dbcbb0 --- /dev/null +++ b/RELEASE_NOTES.org @@ -0,0 +1,85 @@ +#+TITLE: Quantum Package Release notes + +* Version 2.2 + +** Changes + + - Python3 replaces Python2 + - Travis CI uses 3 jobs + - Moved Travis scripts into ~travis~ directory + - IRPF90 and EZFIO are now git submodules + - Now basis sets should be downloaded from basis-set-exchange website + - Added ~bse~ in the installable tools + - Documentation in ~src/README.rst~ + - Added two-body reduced density matrix + - Added basis set correction + - Added CAS-based on-top density functional + - Improve PT2 computation for excited-states: Mostly 2x2 + diagonalization, and some (n+1)x(n+1) diagonalizations + - Error bars for stochastic variance and norm of the perturbed wave function + - Improve PT2-matching for excited-states + - Compute the overlap of PT2 excited states + - Renamed SOP into CFG + - Improved parallelism in PT2 by splitting tasks + - Use max in multi-state PT2 instead of sum for the selection weight + - Added seniority + - Added excitation_max + - More tasks for distribueted Davidson + - Random guess vectors in Davidson have zeros to preserve symmetry + - Disk-based Davidson when too much memory is required + - Fixed bug in DIIS + - Fixed bug in molden (Au -> Angs) + +*** User interface + + - Added ~qp_basis~ script to install a basis set from the ~bse~ + command-line tool + - Introduced ~n_det_qp_edit~, ~psi_det_qp_edit~, and + ~psi_coef_qp_edit~ to accelerate the opening of qp_edit with + large wave functions + - Removed ~etc/ninja.rc~ + - Added flag to specify if the AOs are normalized + - Added flag to specify if the primitive Gaussians are normalized + - Added ~lin_dep_cutoff~, the cutoff for linear dependencies + - Davidson convergence threshold can be adapted from PT2 + - In ~density_for_dft~, ~no_core_density~ is now a logical + - Default for ~weight_selection~ has changed from 2 to 1 + - Nullify_small_elements in matrices to keep symmetry + - Default of density functional changed from LDA to PBE + - Added ~no_vvvv_integrals~ flag + - Added ~pt2_min_parallel_tasks~ to control parallelism in PT2 + - Added ~print_energy~ + - Added ~print_hamiltonian~ + - Added input for two body RDM + - Added keyword ~save_wf_after_selection~ + +*** Code + + - Many bug fixes + - Changed electron-nucleus from ~e_n~ to ~n_e~ in names of variables + - Changed ~occ_pattern~ to ~configuration~ + - Replaced ~List.map~ by a tail-recursive version ~Qputils.list_map~ + - Added possible imaginary part in OCaml MO coefficients + - Added ~qp_clean_source_files.sh~ to remove non-ascii characters + - Added flag ~is_periodic~ for periodic systems + - Possibilities to handle complex integrals and complex MOs + - Moved pseuodpotential integrals out of ~ao_one_e_integrals~ + - Removed Schwarz test and added logical functions + ~ao_two_e_integral_zero~ and ~ao_one_e_integral_zero~ + - Introduced type for ~pt2_data~ + - Banned excitations are used with far apart localized MOs + - S_z2_Sz is now included in S2 + - S^2 in single precision + - Added Shank function + - Added utilities for periodic calculations + - Added ~V_ne_psi_energy~ + - Added ~h_core_guess~ routine + - Fixed Laplacians in real space (indices) + - Added LIB file to add extra libs in plugin + + ao_one_e_integral_zero + banned_excitations + + + + diff --git a/TODO b/TODO deleted file mode 100644 index abdb618f..00000000 --- a/TODO +++ /dev/null @@ -1,43 +0,0 @@ -# qpsh - -* Faire que le slave de Hartree-fock est le calcul des integrales AO en parallele - -# Exterieur - -* Un module pour lire les integrales Moleculaires depuis un FCIDUMP -* Un module pour lire des integrales Atomiques (voir module de Mimi pour lire les AO Slater) -* Format Fchk (gaussian) - -# Tests: - -* Extrapolation -* DFT - - -# User doc: - - * Mettre le mp2 comme exercice - * Interfaces : molden/fcidump - -# Programmers doc: - - * Example : Simple Hartree-Fock program from scratch - * Examples : subroutine example_module - -# enleverle psi_det_size for all complicated stuffs with dimension of psi_coef - -# Config file for Cray - -# Documentation de /etc - -Ajouter les symetries dans devel - -IMPORTANT: - -Davidson Diagonalization ------------------------- - - Not enough memory: aborting in davidson_diag_hjj_sjj - - -qp man does not find the programs in external plugins diff --git a/bin/qp_name b/bin/qp_name index d15e16d0..e13b9a5d 100755 --- a/bin/qp_name +++ b/bin/qp_name @@ -30,7 +30,7 @@ try: from docopt import docopt from qp_path import QP_SRC, QP_ROOT except ImportError: - print("source .quantum_package.rc") + print("source quantum_package.rc") raise diff --git a/bin/qp_set_frozen_core b/bin/qp_set_frozen_core index b00797e2..879c71de 100755 --- a/bin/qp_set_frozen_core +++ b/bin/qp_set_frozen_core @@ -49,7 +49,7 @@ import os.path try: import qp_path except ImportError: - print("source .quantum_package.rc") + print("source quantum_package.rc") raise from docopt import docopt diff --git a/bin/qp_set_frozen_large_core b/bin/qp_set_frozen_large_core index 6950b90c..92df4118 100755 --- a/bin/qp_set_frozen_large_core +++ b/bin/qp_set_frozen_large_core @@ -23,7 +23,7 @@ import os.path try: import qp_path except ImportError: - print("source .quantum_package.rc") + print("source quantum_package.rc") raise from docopt import docopt diff --git a/config/gfortran.cfg b/config/gfortran.cfg index f561fcb7..342acae9 100644 --- a/config/gfortran.cfg +++ b/config/gfortran.cfg @@ -10,10 +10,10 @@ # # [COMMON] -FC : gfortran -ffree-line-length-none -I . -fPIC -LAPACK_LIB : -lblas -llapack +FC : gfortran -g -ffree-line-length-none -I . -fPIC +LAPACK_LIB : -lblas -llapack IRPF90 : irpf90 -IRPF90_FLAGS : --ninja --align=32 +IRPF90_FLAGS : --ninja --align=32 --assert # Global options ################ @@ -22,7 +22,7 @@ IRPF90_FLAGS : --ninja --align=32 # 0 : Deactivate # [OPTION] -MODE : OPT ; [ OPT | PROFILE | DEBUG ] : Chooses the section below +MODE : DEBUG ; [ OPT | PROFILE | DEBUG ] : Chooses the section below CACHE : 0 ; Enable cache_compile.py OPENMP : 1 ; Append OpenMP flags @@ -35,7 +35,7 @@ OPENMP : 1 ; Append OpenMP flags # -ffast-math and the Fortran-specific # -fno-protect-parens and -fstack-arrays. [OPT] -FCFLAGS : -Ofast -msse4.2 +FCFLAGS : -Ofast # Profiling flags ################# @@ -51,7 +51,7 @@ FCFLAGS : -Ofast # -g : Extra debugging information # [DEBUG] -FCFLAGS : -fcheck=all -g +FCFLAGS : -g -msse4.2 -fcheck=all -Waliasing -Wampersand -Wconversion -Wsurprising -Wintrinsics-std -Wno-tabs -Wintrinsic-shadow -Wline-truncation -Wreal-q-constant -Wuninitialized -fbacktrace -ffpe-trap=zero,overflow,underflow -finit-real=nan # OpenMP flags ################# diff --git a/config/ifort_avx.cfg b/config/ifort_avx.cfg index f410e3a6..d689050e 100644 --- a/config/ifort_avx.cfg +++ b/config/ifort_avx.cfg @@ -32,7 +32,7 @@ OPENMP : 1 ; Append OpenMP flags # [OPT] FC : -traceback -FCFLAGS : -mavx -O2 -ip -ftz -g +FCFLAGS : -xAVX -O2 -ip -ftz -g # Profiling flags ################# diff --git a/config/ifort_debug.cfg b/config/ifort_debug.cfg index f0f90f34..f2fbf8ce 100644 --- a/config/ifort_debug.cfg +++ b/config/ifort_debug.cfg @@ -54,7 +54,7 @@ FCFLAGS : -msse4.2 -O2 -ip -ftz # [DEBUG] FC : -g -traceback -FCFLAGS : -msse4.2 -C -fpe0 -implicitnone +FCFLAGS : -msse4.2 -check all -debug all -fpe-all=0 -implicitnone # OpenMP flags diff --git a/config/ifort_xHost.cfg b/config/ifort_xHost.cfg new file mode 100644 index 00000000..5d952e54 --- /dev/null +++ b/config/ifort_xHost.cfg @@ -0,0 +1,63 @@ +# Common flags +############## +# +# -mkl=[parallel|sequential] : Use the MKL library +# --ninja : Allow the utilisation of ninja. It is mandatory ! +# --align=32 : Align all provided arrays on a 32-byte boundary +# +[COMMON] +FC : ifort -fpic +LAPACK_LIB : -mkl=parallel +IRPF90 : irpf90 +IRPF90_FLAGS : --ninja --align=64 + +# Global options +################ +# +# 1 : Activate +# 0 : Deactivate +# +[OPTION] +MODE : OPT ; [ OPT | PROFILE | DEBUG ] : Chooses the section below +CACHE : 0 ; Enable cache_compile.py +OPENMP : 1 ; Append OpenMP flags + +# Optimization flags +#################### +# +# -xHost : Compile a binary optimized for the current architecture +# -O2 : O3 not better than O2. +# -ip : Inter-procedural optimizations +# -ftz : Flushes denormal results to zero +# +[OPT] +FC : -traceback +FCFLAGS : -xHost -O2 -ip -ftz -g + +# Profiling flags +################# +# +[PROFILE] +FC : -p -g +FCFLAGS : -xSSE4.2 -O2 -ip -ftz + +# Debugging flags +################# +# +# -traceback : Activate backtrace on runtime +# -fpe0 : All floating point exaceptions +# -C : Checks uninitialized variables, array subscripts, etc... +# -g : Extra debugging information +# -xSSE2 : Valgrind needs a very simple x86 executable +# +[DEBUG] +FC : -g -traceback +FCFLAGS : -xSSE2 -C -fpe0 -implicitnone + +# OpenMP flags +################# +# +[OPENMP] +FC : -qopenmp +IRPF90_FLAGS : --openmp + diff --git a/configure b/configure index 4f930a34..b45bfd27 100755 --- a/configure +++ b/configure @@ -14,17 +14,16 @@ unset CCXX # Force GCC instead of ICC for dependencies export CC=gcc +# Download submodules +git submodule init +git submodule update # /!\ When updating version, update also etc files - -EZFIO_TGZ="EZFIO-v2.0.3.tar.gz" BATS_URL="https://github.com/bats-core/bats-core/archive/v1.1.0.tar.gz" BUBBLE_URL="https://github.com/projectatomic/bubblewrap/releases/download/v0.3.3/bubblewrap-0.3.3.tar.xz" DOCOPT_URL="https://github.com/docopt/docopt/archive/0.6.2.tar.gz" BSE_URL="https://github.com/MolSSI-BSE/basis_set_exchange/archive/v0.8.11.tar.gz" F77ZMQ_URL="https://github.com/scemama/f77_zmq/archive/v4.2.5.tar.gz" -GMP_URL="ftp://ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.bz2" -IRPF90_URL="https://gitlab.com/scemama/irpf90/-/archive/v2.0.0/irpf90-v2.0.0.tar.gz" LIBCAP_URL="https://git.kernel.org/pub/scm/linux/kernel/git/morgan/libcap.git/snapshot/libcap-2.25.tar.gz" NINJA_URL="https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip" OCAML_URL="https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh" @@ -126,13 +125,13 @@ source quantum_package.rc function fail() { echo "You can try to install it using the -i option." echo "Please refer to INSTALL.rst to install the missing dependencies." - exit 1 + exit -1 } function success() { echo "" echo "Configuration successful." - exit 1 + exit 0 } function download() { @@ -178,15 +177,10 @@ function find_dir() { } -# Extract EZFIO if needed -EZFIO=$(find_dir "${QP_ROOT}"/external/ezfio) -if [[ ${EZFIO} = $(not_found) ]] ; then - execute << EOF - cd "\${QP_ROOT}"/external - tar --gunzip --extract --file ${EZFIO_TGZ} - rm -rf ezfio - mv EZFIO ezfio || mv EZFIO-v*/ ezfio -EOF +# Install IRPF90 if needed +IRPF90=$(find_exe irpf90) +if [[ ${IRPF90} = $(not_found) ]] ; then + make -C ${QP_ROOT}/external/irpf90 fi @@ -211,7 +205,7 @@ if [[ "${PACKAGES}.x" != ".x" ]] ; then fi if [[ ${PACKAGES} = all ]] ; then - PACKAGES="zlib ninja irpf90 zeromq f77zmq gmp libcap bwrap ocaml ezfio docopt resultsFile bats" + PACKAGES="zlib ninja irpf90 zeromq f77zmq gmp libcap bwrap ocaml docopt resultsFile bats" fi @@ -228,12 +222,10 @@ EOF elif [[ ${PACKAGE} = gmp ]] ; then - download ${GMP_URL} "${QP_ROOT}"/external/gmp.tar.bz2 execute << EOF cd "\${QP_ROOT}"/external - tar --bzip2 --extract --file gmp.tar.bz2 - rm gmp.tar.bz2 - cd gmp* + tar --bzip2 --extract --file gmp-6.1.2.tar.bz2 + cd gmp-6.1.2 ./configure --prefix=$QP_ROOT && make -j 8 make install EOF @@ -246,7 +238,7 @@ EOF tar --gunzip --extract --file libcap.tar.gz rm libcap.tar.gz cd libcap-*/libcap - prefix=$QP_ROOT make install + prefix=$QP_ROOT make BUILD_GPERF=no install EOF elif [[ ${PACKAGE} = bwrap ]] ; then @@ -263,13 +255,12 @@ EOF elif [[ ${PACKAGE} = irpf90 ]] ; then - # When changing version of irpf90, don't forget to update etc/irpf90.rc - download ${IRPF90_URL} "${QP_ROOT}"/external/irpf90.tar.gz execute << EOF cd "\${QP_ROOT}"/external tar --gunzip --extract --file irpf90.tar.gz rm irpf90.tar.gz - cd irpf90-* + mv irpf90-* irpf90 + cd irpf90 make EOF @@ -328,8 +319,8 @@ EOF rm ${QP_ROOT}/external/opam_installer.sh # source ${OPAMROOT}/opam-init/init.sh > /dev/null 2> /dev/null || true # -# opam switch create ocaml-base-compiler.4.10.0 - opam init --verbose --yes --compiler=4.10.0 --disable-sandboxing +# opam switch create ocaml-base-compiler.4.11.1 + opam init --verbose --yes --compiler=4.11.1 --disable-sandboxing eval $(opam env) opam install -y ${OCAML_PACKAGES} || exit 1 @@ -348,9 +339,9 @@ EOF EOF rm ${QP_ROOT}/external/opam_installer.sh # source ${OPAMROOT}/opam-init/init.sh > /dev/null 2> /dev/null || true -# opam switch create ocaml-base-compiler.4.10.0 || exit 1 +# opam switch create ocaml-base-compiler.4.11.1 || exit 1 - opam init --verbose --yes --compiler=4.10.0 --disable-sandboxing + opam init --verbose --yes --compiler=4.11.1 --disable-sandboxing eval $(opam env) execute << EOF opam install -y \${OCAML_PACKAGES} || exit 1 @@ -410,6 +401,9 @@ EOF rm --recursive --force -- bats-core-1.1.0 \ "\${QP_ROOT}"/external/bats.tar.gz EOF + else + error "${PACKAGE} unknown." + fail fi @@ -425,7 +419,7 @@ fi IRPF90=$(find_exe irpf90) if [[ ${IRPF90} = $(not_found) ]] ; then - error "IRPf90 (irpf90) is not installed." + error "IRPF90 (irpf90) is not installed." fail fi diff --git a/docs/source/auto_generate.py b/docs/source/auto_generate.py index 11029c3b..d767b922 100755 --- a/docs/source/auto_generate.py +++ b/docs/source/auto_generate.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 import os diff --git a/docs/source/conf.py b/docs/source/conf.py index 8d6a023e..21498968 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -24,9 +24,9 @@ copyright = '2019, A. Scemama, E. Giner' author = 'A. Scemama, E. Giner' # The short X.Y version -version = '2.0' +version = '2.1' # The full version, including alpha/beta/rc tags -release = '2.0' +release = '2.1' # -- General configuration --------------------------------------------------- diff --git a/docs/source/index.rst b/docs/source/index.rst index d6f9617c..4231b1f8 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -50,7 +50,6 @@ :hidden: appendix/benchmarks - appendix/research appendix/license appendix/contributors diff --git a/docs/source/modules/ao_basis.rst b/docs/source/modules/ao_basis.rst index 8612f0e9..3e3821d3 100644 --- a/docs/source/modules/ao_basis.rst +++ b/docs/source/modules/ao_basis.rst @@ -118,10 +118,12 @@ Providers * :c:data:`ao_coef` * :c:data:`ao_expo` + * :c:data:`ao_normalized` * :c:data:`ao_num` * :c:data:`ao_power` * :c:data:`ao_prim_num` * :c:data:`ao_prim_num_max` + * :c:data:`primitives_normalized` Needed by: @@ -177,10 +179,12 @@ Providers * :c:data:`ao_coef` * :c:data:`ao_expo` + * :c:data:`ao_normalized` * :c:data:`ao_num` * :c:data:`ao_power` * :c:data:`ao_prim_num` * :c:data:`ao_prim_num_max` + * :c:data:`primitives_normalized` Needed by: @@ -261,10 +265,7 @@ Providers * :c:data:`ao_pseudo_integrals_local` * :c:data:`ao_pseudo_integrals_non_local` * :c:data:`ao_spread_x` - * :c:data:`ao_two_e_integral_alpha` - * :c:data:`ao_two_e_integral_erf_schwartz` * :c:data:`ao_two_e_integral_schwartz` - * :c:data:`ao_two_e_integrals_erf_in_map` * :c:data:`ao_two_e_integrals_in_map` @@ -363,10 +364,7 @@ Providers * :c:data:`ao_pseudo_integrals_local` * :c:data:`ao_pseudo_integrals_non_local` * :c:data:`ao_spread_x` - * :c:data:`ao_two_e_integral_alpha` - * :c:data:`ao_two_e_integral_erf_schwartz` * :c:data:`ao_two_e_integral_schwartz` - * :c:data:`ao_two_e_integrals_erf_in_map` * :c:data:`ao_two_e_integrals_in_map` @@ -853,10 +851,7 @@ Providers * :c:data:`ao_integrals_n_e` * :c:data:`ao_integrals_n_e_per_atom` - * :c:data:`ao_two_e_integral_alpha` - * :c:data:`ao_two_e_integral_erf_schwartz` * :c:data:`ao_two_e_integral_schwartz` - * :c:data:`ao_two_e_integrals_erf_in_map` * :c:data:`ao_two_e_integrals_in_map` * :c:data:`gauleg_t2` @@ -888,10 +883,7 @@ Providers * :c:data:`ao_integrals_n_e` * :c:data:`ao_integrals_n_e_per_atom` - * :c:data:`ao_two_e_integral_alpha` - * :c:data:`ao_two_e_integral_erf_schwartz` * :c:data:`ao_two_e_integral_schwartz` - * :c:data:`ao_two_e_integrals_erf_in_map` * :c:data:`ao_two_e_integrals_in_map` * :c:data:`gauleg_t2` @@ -1088,10 +1080,10 @@ Subroutines / functions :columns: 3 * :c:data:`ao_coef_normalized_ordered_transp` - * :c:data:`ao_power` * :c:data:`ao_expo_ordered_transp` - * :c:data:`ao_prim_num` * :c:data:`ao_nucl` + * :c:data:`ao_power` + * :c:data:`ao_prim_num` * :c:data:`nucl_coord` @@ -1117,14 +1109,14 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`ao_expo_ordered_transp_per_nucl` - * :c:data:`ao_power_ordered_transp_per_nucl` - * :c:data:`nucl_n_aos` - * :c:data:`ao_num` - * :c:data:`ao_prim_num` * :c:data:`ao_coef_normalized_ordered_transp_per_nucl` + * :c:data:`ao_expo_ordered_transp_per_nucl` + * :c:data:`ao_num` + * :c:data:`ao_power_ordered_transp_per_nucl` + * :c:data:`ao_prim_num` * :c:data:`nucl_aos_transposed` * :c:data:`nucl_coord` + * :c:data:`nucl_n_aos` * :c:data:`nucl_num` Called by: @@ -1158,14 +1150,14 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`ao_expo_ordered_transp_per_nucl` - * :c:data:`ao_power_ordered_transp_per_nucl` - * :c:data:`nucl_n_aos` - * :c:data:`ao_num` - * :c:data:`ao_prim_num` * :c:data:`ao_coef_normalized_ordered_transp_per_nucl` + * :c:data:`ao_expo_ordered_transp_per_nucl` + * :c:data:`ao_num` + * :c:data:`ao_power_ordered_transp_per_nucl` + * :c:data:`ao_prim_num` * :c:data:`nucl_aos_transposed` * :c:data:`nucl_coord` + * :c:data:`nucl_n_aos` * :c:data:`nucl_num` Called by: @@ -1195,14 +1187,14 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`ao_expo_ordered_transp_per_nucl` - * :c:data:`ao_power_ordered_transp_per_nucl` - * :c:data:`nucl_n_aos` - * :c:data:`ao_num` - * :c:data:`ao_prim_num` * :c:data:`ao_coef_normalized_ordered_transp_per_nucl` + * :c:data:`ao_expo_ordered_transp_per_nucl` + * :c:data:`ao_num` + * :c:data:`ao_power_ordered_transp_per_nucl` + * :c:data:`ao_prim_num` * :c:data:`nucl_aos_transposed` * :c:data:`nucl_coord` + * :c:data:`nucl_n_aos` * :c:data:`nucl_num` Called by: @@ -1233,6 +1225,6 @@ Subroutines / functions * :c:data:`ao_expo_ordered_transp` * :c:data:`ao_nucl` - * :c:data:`nucl_coord` * :c:data:`ao_power` + * :c:data:`nucl_coord` diff --git a/docs/source/modules/ao_one_e_ints.rst b/docs/source/modules/ao_one_e_ints.rst index ae8bda04..e0ad5873 100644 --- a/docs/source/modules/ao_one_e_ints.rst +++ b/docs/source/modules/ao_one_e_ints.rst @@ -12,12 +12,11 @@ All the one-electron integrals in the |AO| basis are here. The most important providers for usual quantum-chemistry calculation are: -* `ao_kinetic_integral` which are the kinetic operator integrals on the |AO| basis (see :file:`kin_ao_ints.irp.f`) -* `ao_nucl_elec_integral` which are the nuclear-elctron operator integrals on the |AO| basis (see :file:`pot_ao_ints.irp.f`) -* `ao_one_e_integrals` which are the the h_core operator integrals on the |AO| basis (see :file:`ao_mono_ints.irp.f`) +* `ao_kinetic_integrals` which are the kinetic operator integrals on the |AO| basis +* `ao_integrals_n_e` which are the nuclear-elctron operator integrals on the |AO| basis +* `ao_one_e_integrals` which are the the h_core operator integrals on the |AO| basis -Note that you can find other interesting integrals related to the position operator in :file:`spread_dipole_ao.irp.f`. @@ -144,6 +143,7 @@ Providers * :c:data:`ao_cart_to_sphe_coef` * :c:data:`ao_num` + * :c:data:`lin_dep_cutoff` @@ -570,6 +570,8 @@ Providers Nucleus-electron interaction, in the |AO| basis set. :math:`\langle \chi_i | -\sum_A \frac{1}{|r-R_A|} | \chi_j \rangle` + + These integrals also contain the pseudopotential integrals. Needs: @@ -582,11 +584,13 @@ Providers * :c:data:`ao_num` * :c:data:`ao_power` * :c:data:`ao_prim_num` + * :c:data:`ao_pseudo_integrals` + * :c:data:`do_pseudo` * :c:data:`n_pt_max_integrals` * :c:data:`nucl_charge` * :c:data:`nucl_coord` * :c:data:`nucl_num` - * :c:data:`read_ao_integrals_e_n` + * :c:data:`read_ao_integrals_n_e` Needed by: @@ -594,11 +598,33 @@ Providers :columns: 3 * :c:data:`ao_one_e_integrals` - * :c:data:`ao_ortho_canonical_nucl_elec_integrals` - * :c:data:`ao_ortho_lowdin_nucl_elec_integrals` * :c:data:`mo_integrals_n_e` +.. c:var:: ao_integrals_n_e_imag + + + File : :file:`ao_one_e_ints/pot_ao_ints.irp.f` + + .. code:: fortran + + double precision, allocatable :: ao_integrals_n_e_imag (ao_num,ao_num) + + + Nucleus-electron interaction, in the |AO| basis set. + + :math:`\langle \chi_i | -\sum_A \frac{1}{|r-R_A|} | \chi_j \rangle` + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`ao_num` + * :c:data:`read_ao_integrals_n_e` + + + .. c:var:: ao_integrals_n_e_per_atom @@ -669,6 +695,31 @@ Providers * :c:data:`mo_kinetic_integrals` +.. c:var:: ao_kinetic_integrals_imag + + + File : :file:`ao_one_e_ints/kin_ao_ints.irp.f` + + .. code:: fortran + + double precision, allocatable :: ao_kinetic_integrals_imag (ao_num,ao_num) + + + Kinetic energy integrals in the |AO| basis. + + :math:`\langle \chi_i |\hat{T}| \chi_j \rangle` + + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`ao_num` + * :c:data:`read_ao_integrals_kinetic` + + + .. c:var:: ao_one_e_integrals @@ -690,18 +741,8 @@ Providers * :c:data:`ao_integrals_n_e` * :c:data:`ao_kinetic_integrals` * :c:data:`ao_num` - * :c:data:`ao_pseudo_integrals` - * :c:data:`do_pseudo` * :c:data:`read_ao_one_e_integrals` - Needed by: - - .. hlist:: - :columns: 3 - - * :c:data:`fock_matrix_ao_alpha` - * :c:data:`hf_energy` - * :c:data:`scf_energy` .. c:var:: ao_one_e_integrals_diag @@ -725,18 +766,30 @@ Providers * :c:data:`ao_integrals_n_e` * :c:data:`ao_kinetic_integrals` * :c:data:`ao_num` - * :c:data:`ao_pseudo_integrals` - * :c:data:`do_pseudo` * :c:data:`read_ao_one_e_integrals` - Needed by: + + +.. c:var:: ao_one_e_integrals_imag + + + File : :file:`ao_one_e_ints/ao_one_e_ints.irp.f` + + .. code:: fortran + + double precision, allocatable :: ao_one_e_integrals_imag (ao_num,ao_num) + + + One-electron Hamiltonian in the |AO| basis. + + Needs: .. hlist:: :columns: 3 - * :c:data:`fock_matrix_ao_alpha` - * :c:data:`hf_energy` - * :c:data:`scf_energy` + * :c:data:`ao_num` + * :c:data:`read_ao_one_e_integrals` + .. c:var:: ao_ortho_canonical_coef @@ -764,6 +817,8 @@ Providers * :c:data:`ao_cartesian` * :c:data:`ao_num` * :c:data:`ao_overlap` + * :c:data:`lin_dep_cutoff` + * :c:data:`mpi_master` Needed by: @@ -771,7 +826,6 @@ Providers :columns: 3 * :c:data:`ao_ortho_canonical_coef_inv` - * :c:data:`ao_ortho_canonical_nucl_elec_integrals` * :c:data:`ao_ortho_canonical_overlap` * :c:data:`mo_coef` * :c:data:`mo_num` @@ -830,6 +884,8 @@ Providers * :c:data:`ao_cartesian` * :c:data:`ao_num` * :c:data:`ao_overlap` + * :c:data:`lin_dep_cutoff` + * :c:data:`mpi_master` Needed by: @@ -837,7 +893,6 @@ Providers :columns: 3 * :c:data:`ao_ortho_canonical_coef_inv` - * :c:data:`ao_ortho_canonical_nucl_elec_integrals` * :c:data:`ao_ortho_canonical_overlap` * :c:data:`mo_coef` * :c:data:`mo_num` @@ -906,9 +961,7 @@ Providers * :c:data:`ao_cart_to_sphe_overlap` * :c:data:`ao_ortho_canonical_coef` * :c:data:`ao_ortho_canonical_overlap` - * :c:data:`ao_ortho_lowdin_coef` - * :c:data:`ao_ortho_lowdin_overlap` - * :c:data:`fps_spf_matrix_ao` + * :c:data:`ao_overlap_complex` * :c:data:`mo_overlap` * :c:data:`s_half` * :c:data:`s_half_inv` @@ -939,19 +992,69 @@ Providers * :c:data:`ao_expo_ordered_transp` * :c:data:`ao_nucl` * :c:data:`ao_num` + * :c:data:`ao_overlap_complex` * :c:data:`ao_power` * :c:data:`ao_prim_num` + * :c:data:`is_periodic` * :c:data:`nucl_coord` + + +.. c:var:: ao_overlap_complex + + + File : :file:`ao_one_e_ints/ao_overlap.irp.f` + + .. code:: fortran + + complex*16, allocatable :: ao_overlap_complex (ao_num,ao_num) + + + Overlap for complex AOs + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`ao_num` + * :c:data:`ao_overlap` + * :c:data:`ao_overlap_imag` + Needed by: .. hlist:: :columns: 3 - * :c:data:`ao_two_e_integral_alpha` - * :c:data:`mo_two_e_int_erf_jj_from_ao` - * :c:data:`mo_two_e_integral_jj_from_ao` - * :c:data:`mo_two_e_integrals_vv_from_ao` + * :c:data:`ao_overlap_abs` + * :c:data:`s_inv_complex` + + +.. c:var:: ao_overlap_imag + + + File : :file:`ao_one_e_ints/ao_overlap.irp.f` + + .. code:: fortran + + double precision, allocatable :: ao_overlap_imag (ao_num,ao_num) + + + Imaginary part of the overlap + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`ao_num` + + Needed by: + + .. hlist:: + :columns: 3 + + * :c:data:`ao_overlap_complex` .. c:var:: ao_overlap_x @@ -993,9 +1096,7 @@ Providers * :c:data:`ao_cart_to_sphe_overlap` * :c:data:`ao_ortho_canonical_coef` * :c:data:`ao_ortho_canonical_overlap` - * :c:data:`ao_ortho_lowdin_coef` - * :c:data:`ao_ortho_lowdin_overlap` - * :c:data:`fps_spf_matrix_ao` + * :c:data:`ao_overlap_complex` * :c:data:`mo_overlap` * :c:data:`s_half` * :c:data:`s_half_inv` @@ -1042,9 +1143,7 @@ Providers * :c:data:`ao_cart_to_sphe_overlap` * :c:data:`ao_ortho_canonical_coef` * :c:data:`ao_ortho_canonical_overlap` - * :c:data:`ao_ortho_lowdin_coef` - * :c:data:`ao_ortho_lowdin_overlap` - * :c:data:`fps_spf_matrix_ao` + * :c:data:`ao_overlap_complex` * :c:data:`mo_overlap` * :c:data:`s_half` * :c:data:`s_half_inv` @@ -1091,9 +1190,7 @@ Providers * :c:data:`ao_cart_to_sphe_overlap` * :c:data:`ao_ortho_canonical_coef` * :c:data:`ao_ortho_canonical_overlap` - * :c:data:`ao_ortho_lowdin_coef` - * :c:data:`ao_ortho_lowdin_overlap` - * :c:data:`fps_spf_matrix_ao` + * :c:data:`ao_overlap_complex` * :c:data:`mo_overlap` * :c:data:`s_half` * :c:data:`s_half_inv` @@ -1131,7 +1228,7 @@ Providers .. hlist:: :columns: 3 - * :c:data:`ao_one_e_integrals` + * :c:data:`ao_integrals_n_e` * :c:data:`mo_pseudo_integrals` @@ -1688,12 +1785,6 @@ Providers * :c:data:`ao_num` * :c:data:`ao_overlap` - Needed by: - - .. hlist:: - :columns: 3 - - * :c:data:`eigenvalues_fock_matrix_ao` .. c:var:: s_inv @@ -1715,6 +1806,30 @@ Providers * :c:data:`ao_num` * :c:data:`ao_overlap` + * :c:data:`lin_dep_cutoff` + + + +.. c:var:: s_inv_complex + + + File : :file:`ao_one_e_ints/ao_overlap.irp.f` + + .. code:: fortran + + complex*16, allocatable :: s_inv_complex (ao_num,ao_num) + + + Inverse of the overlap matrix + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`ao_num` + * :c:data:`ao_overlap_complex` + * :c:data:`lin_dep_cutoff` @@ -1722,6 +1837,28 @@ Providers Subroutines / functions ----------------------- +.. c:function:: ao_one_e_integral_zero: + + + File : :file:`ao_one_e_ints/screening.irp.f` + + .. code:: fortran + + logical function ao_one_e_integral_zero(i,k) + + + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`ao_integrals_threshold` + * :c:data:`ao_overlap_abs` + * :c:data:`io_ao_integrals_overlap` + * :c:data:`is_periodic` + + .. c:function:: give_all_erf_kl_ao: @@ -1854,12 +1991,12 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_pt_max_integrals` * :c:data:`ao_coef_normalized_ordered_transp` - * :c:data:`ao_power` * :c:data:`ao_expo_ordered_transp` - * :c:data:`ao_prim_num` * :c:data:`ao_nucl` + * :c:data:`ao_power` + * :c:data:`ao_prim_num` + * :c:data:`n_pt_max_integrals` * :c:data:`nucl_coord` @@ -1949,14 +2086,14 @@ Subroutines / functions * :c:func:`overlap_bourrin_deriv_x` -.. c:function:: v_e_n: +.. c:function:: v_n_e: File : :file:`ao_one_e_ints/pot_ao_ints.irp.f` .. code:: fortran - double precision function V_e_n(a_x,a_y,a_z,b_x,b_y,b_z,alpha,beta) + double precision function V_n_e(a_x,a_y,a_z,b_x,b_y,b_z,alpha,beta) Primitve nuclear attraction between the two primitves centered on the same atom. diff --git a/docs/source/modules/ao_two_e_erf_ints.rst b/docs/source/modules/ao_two_e_erf_ints.rst index f6b9108a..facd81c6 100644 --- a/docs/source/modules/ao_two_e_erf_ints.rst +++ b/docs/source/modules/ao_two_e_erf_ints.rst @@ -287,13 +287,13 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_pt_max_integrals` * :c:data:`ao_coef_normalized_ordered_transp` - * :c:data:`ao_power` * :c:data:`ao_expo_ordered_transp` + * :c:data:`ao_nucl` + * :c:data:`ao_power` * :c:data:`ao_prim_num` * :c:data:`mu_erf` - * :c:data:`ao_nucl` + * :c:data:`n_pt_max_integrals` * :c:data:`nucl_coord` Calls: @@ -322,13 +322,13 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_pt_max_integrals` - * :c:data:`ao_integrals_threshold` * :c:data:`ao_coef_normalized_ordered_transp` - * :c:data:`ao_power` * :c:data:`ao_expo_ordered_transp` - * :c:data:`ao_prim_num` + * :c:data:`ao_integrals_threshold` * :c:data:`ao_nucl` + * :c:data:`ao_power` + * :c:data:`ao_prim_num` + * :c:data:`n_pt_max_integrals` * :c:data:`nucl_coord` Calls: @@ -504,9 +504,8 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`ao_overlap_abs` - * :c:data:`ao_num` * :c:data:`ao_integrals_threshold` + * :c:data:`ao_num` * :c:data:`ao_two_e_integral_erf_schwartz` Called by: @@ -541,7 +540,6 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`ao_overlap_abs` * :c:data:`ao_num` * :c:data:`ao_two_e_integral_erf_schwartz` @@ -650,10 +648,9 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`ao_integrals_erf_cache_min` - * :c:data:`ao_overlap_abs` - * :c:data:`ao_integrals_threshold` * :c:data:`ao_integrals_erf_cache` + * :c:data:`ao_integrals_erf_cache_min` + * :c:data:`ao_integrals_threshold` * :c:data:`ao_two_e_integral_erf_schwartz` * :c:data:`ao_two_e_integrals_erf_in_map` @@ -685,7 +682,6 @@ Subroutines / functions :columns: 3 * :c:data:`ao_integrals_erf_map` - * :c:data:`ao_overlap_abs` * :c:data:`ao_integrals_threshold` * :c:data:`ao_two_e_integrals_erf_in_map` @@ -716,7 +712,6 @@ Subroutines / functions :columns: 3 * :c:data:`ao_integrals_erf_map` - * :c:data:`ao_overlap_abs` * :c:data:`ao_integrals_threshold` * :c:data:`ao_two_e_integral_erf_schwartz` * :c:data:`ao_two_e_integrals_erf_in_map` @@ -792,9 +787,9 @@ Subroutines / functions .. hlist:: :columns: 3 + * :c:data:`gauleg_t2` * :c:data:`mu_erf` * :c:data:`n_pt_max_integrals` - * :c:data:`gauleg_t2` Called by: @@ -857,8 +852,8 @@ Subroutines / functions :columns: 3 * :c:data:`ao_integrals_erf_map` - * :c:data:`ezfio_filename` * :c:data:`ao_two_e_integrals_erf_in_map` + * :c:data:`ezfio_filename` Called by: @@ -894,8 +889,8 @@ Subroutines / functions :columns: 3 * :c:data:`ao_integrals_erf_map` - * :c:data:`ezfio_filename` * :c:data:`ao_two_e_integrals_erf_in_map` + * :c:data:`ezfio_filename` Calls: diff --git a/docs/source/modules/ao_two_e_ints.rst b/docs/source/modules/ao_two_e_ints.rst index 4975bd04..bc3a0ebf 100644 --- a/docs/source/modules/ao_two_e_ints.rst +++ b/docs/source/modules/ao_two_e_ints.rst @@ -98,6 +98,7 @@ Providers :columns: 3 * :c:data:`ao_integrals_cache` + * :c:data:`ao_integrals_cache_periodic` .. c:var:: ao_integrals_cache_min @@ -126,6 +127,30 @@ Providers :columns: 3 * :c:data:`ao_integrals_cache` + * :c:data:`ao_integrals_cache_periodic` + + +.. c:var:: ao_integrals_cache_periodic + + + File : :file:`ao_two_e_ints/map_integrals.irp.f` + + .. code:: fortran + + complex*16, allocatable :: ao_integrals_cache_periodic (0:64*64*64*64) + + + Cache of AO integrals for fast access + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`ao_integrals_cache_min` + * :c:data:`ao_integrals_map` + * :c:data:`ao_two_e_integrals_in_map` + .. c:var:: ao_integrals_map @@ -153,9 +178,10 @@ Providers :columns: 3 * :c:data:`ao_integrals_cache` - * :c:data:`ao_two_e_integral_alpha` + * :c:data:`ao_integrals_cache_periodic` * :c:data:`ao_two_e_integrals_in_map` * :c:data:`mo_two_e_integral_jj_from_ao` + * :c:data:`mo_two_e_integrals_in_map` * :c:data:`mo_two_e_integrals_vv_from_ao` @@ -185,14 +211,6 @@ Providers * :c:data:`n_pt_max_integrals` * :c:data:`nucl_coord` - Needed by: - - .. hlist:: - :columns: 3 - - * :c:data:`ao_two_e_integral_alpha` - * :c:data:`mo_two_e_integral_jj_from_ao` - * :c:data:`mo_two_e_integrals_vv_from_ao` .. c:var:: ao_two_e_integrals_in_map @@ -237,9 +255,8 @@ Providers :columns: 3 * :c:data:`ao_integrals_cache` - * :c:data:`ao_two_e_integral_alpha` + * :c:data:`ao_integrals_cache_periodic` * :c:data:`mo_two_e_integral_jj_from_ao` - * :c:data:`mo_two_e_integrals_erf_in_map` * :c:data:`mo_two_e_integrals_in_map` * :c:data:`mo_two_e_integrals_vv_from_ao` @@ -341,7 +358,6 @@ Providers * :c:func:`i_x1_new` * :c:func:`i_x2_new` * :c:func:`integrale_new` - * :c:func:`integrale_new_erf` Calls: @@ -512,6 +528,84 @@ Providers Subroutines / functions ----------------------- +.. c:function:: ao_idx2_sq: + + + File : :file:`ao_two_e_ints/map_integrals.irp.f` + + .. code:: fortran + + subroutine ao_idx2_sq(i,j,ij) + + + + Called by: + + .. hlist:: + :columns: 3 + + * :c:func:`two_e_integrals_index_2fold` + + +.. c:function:: ao_idx2_sq_rev: + + + File : :file:`ao_two_e_ints/map_integrals.irp.f` + + .. code:: fortran + + subroutine ao_idx2_sq_rev(i,k,ik) + + + reverse square compound index + + Called by: + + .. hlist:: + :columns: 3 + + * :c:func:`two_e_integrals_index_reverse_2fold` + + +.. c:function:: ao_idx2_tri_key: + + + File : :file:`ao_two_e_ints/map_integrals.irp.f` + + .. code:: fortran + + subroutine ao_idx2_tri_key(i,j,ij) + + + + Called by: + + .. hlist:: + :columns: 3 + + * :c:func:`two_e_integrals_index_2fold` + + +.. c:function:: ao_idx2_tri_rev_key: + + + File : :file:`ao_two_e_ints/map_integrals.irp.f` + + .. code:: fortran + + subroutine ao_idx2_tri_rev_key(i,k,ik) + + + return i<=k + + Called by: + + .. hlist:: + :columns: 3 + + * :c:func:`two_e_integrals_index_reverse_2fold` + + .. c:function:: ao_l4: @@ -550,12 +644,12 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_pt_max_integrals` * :c:data:`ao_coef_normalized_ordered_transp` - * :c:data:`ao_power` * :c:data:`ao_expo_ordered_transp` - * :c:data:`ao_prim_num` * :c:data:`ao_nucl` + * :c:data:`ao_power` + * :c:data:`ao_prim_num` + * :c:data:`n_pt_max_integrals` * :c:data:`nucl_coord` Calls: @@ -584,13 +678,13 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_pt_max_integrals` - * :c:data:`ao_integrals_threshold` * :c:data:`ao_coef_normalized_ordered_transp` - * :c:data:`ao_power` * :c:data:`ao_expo_ordered_transp` - * :c:data:`ao_prim_num` + * :c:data:`ao_integrals_threshold` * :c:data:`ao_nucl` + * :c:data:`ao_power` + * :c:data:`ao_prim_num` + * :c:data:`n_pt_max_integrals` * :c:data:`nucl_coord` Calls: @@ -601,6 +695,29 @@ Subroutines / functions * :c:func:`give_explicit_poly_and_gaussian` +.. c:function:: ao_two_e_integral_zero: + + + File : :file:`ao_two_e_ints/screening.irp.f` + + .. code:: fortran + + logical function ao_two_e_integral_zero(i,j,k,l) + + + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`ao_integrals_threshold` + * :c:data:`ao_overlap_abs` + * :c:data:`ao_two_e_integral_schwartz` + * :c:data:`is_periodic` + * :c:data:`read_ao_two_e_integrals` + + .. c:function:: ao_two_e_integrals_in_map_collector: @@ -766,10 +883,8 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`ao_overlap_abs` - * :c:data:`ao_num` * :c:data:`ao_integrals_threshold` - * :c:data:`ao_two_e_integral_schwartz` + * :c:data:`ao_num` Called by: @@ -803,9 +918,7 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`ao_overlap_abs` * :c:data:`ao_num` - * :c:data:`ao_two_e_integral_schwartz` Called by: @@ -816,34 +929,6 @@ Subroutines / functions * :c:data:`mo_two_e_integrals_vv_from_ao` -.. c:function:: dump_ao_integrals: - - - File : :file:`ao_two_e_ints/map_integrals.irp.f` - - .. code:: fortran - - subroutine dump_ao_integrals(filename) - - - Save to disk the |AO| integrals - - Needs: - - .. hlist:: - :columns: 3 - - * :c:data:`ao_integrals_map` - * :c:data:`mpi_master` - - Calls: - - .. hlist:: - :columns: 3 - - * :c:func:`ezfio_set_work_empty` - - .. c:function:: eri: @@ -925,9 +1010,6 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`ao_overlap_abs` - * :c:data:`ao_integrals_threshold` - * :c:data:`ao_two_e_integral_schwartz` * :c:data:`ao_integrals_cache` * :c:data:`ao_integrals_cache_min` * :c:data:`ao_two_e_integrals_in_map` @@ -941,6 +1023,37 @@ Subroutines / functions * :c:func:`two_e_integrals_index` +.. c:function:: get_ao_two_e_integral_periodic: + + + File : :file:`ao_two_e_ints/map_integrals.irp.f` + + .. code:: fortran + + complex*16 function get_ao_two_e_integral_periodic(i,j,k,l,map) result(result) + + + Gets one AO bi-electronic integral from the AO map + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`ao_integrals_cache_min` + * :c:data:`ao_integrals_cache_periodic` + * :c:data:`ao_integrals_map` + * :c:data:`ao_two_e_integrals_in_map` + + Calls: + + .. hlist:: + :columns: 3 + + * :c:func:`map_get` + * :c:func:`two_e_integrals_index_2fold` + + .. c:function:: get_ao_two_e_integrals: @@ -961,8 +1074,6 @@ Subroutines / functions :columns: 3 * :c:data:`ao_integrals_map` - * :c:data:`ao_overlap_abs` - * :c:data:`ao_integrals_threshold` * :c:data:`ao_two_e_integrals_in_map` Called by: @@ -994,9 +1105,7 @@ Subroutines / functions :columns: 3 * :c:data:`ao_integrals_map` - * :c:data:`ao_overlap_abs` * :c:data:`ao_integrals_threshold` - * :c:data:`ao_two_e_integral_schwartz` * :c:data:`ao_two_e_integrals_in_map` Called by: @@ -1035,8 +1144,6 @@ Subroutines / functions :columns: 3 * :c:data:`ao_integrals_map` - * :c:data:`ao_overlap_abs` - * :c:data:`ao_two_e_integral_schwartz` * :c:data:`ao_two_e_integrals_in_map` Calls: @@ -1067,8 +1174,6 @@ Subroutines / functions :columns: 3 * :c:data:`ao_integrals_map` - * :c:data:`ao_overlap_abs` - * :c:data:`ao_two_e_integral_schwartz` * :c:data:`ao_two_e_integrals_in_map` Calls: @@ -1080,6 +1185,29 @@ Subroutines / functions * :c:func:`two_e_integrals_index` +.. c:function:: get_ao_two_e_integrals_periodic: + + + File : :file:`ao_two_e_ints/map_integrals.irp.f` + + .. code:: fortran + + subroutine get_ao_two_e_integrals_periodic(j,k,l,sze,out_val) + + + Gets multiple AO bi-electronic integral from the AO map . + All i are retrieved for j,k,l fixed. + physicist convention : + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`ao_integrals_map` + * :c:data:`ao_two_e_integrals_in_map` + + .. c:function:: give_polynom_mult_center_x: @@ -1101,7 +1229,6 @@ Subroutines / functions :columns: 3 * :c:func:`general_primitive_integral` - * :c:func:`general_primitive_integral_erf` Calls: @@ -1141,6 +1268,31 @@ Subroutines / functions * :c:func:`i_x2_pol_mult` +.. c:function:: idx2_tri_int: + + + File : :file:`ao_two_e_ints/map_integrals.irp.f` + + .. code:: fortran + + subroutine idx2_tri_int(i,j,ij) + + + + +.. c:function:: idx2_tri_rev_int: + + + File : :file:`ao_two_e_ints/map_integrals.irp.f` + + .. code:: fortran + + subroutine idx2_tri_rev_int(i,k,ik) + + + return i<=k + + .. c:function:: insert_into_ao_integrals_map: @@ -1195,8 +1347,8 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_pt_max_integrals` * :c:data:`gauleg_t2` + * :c:data:`n_pt_max_integrals` Called by: @@ -1213,35 +1365,6 @@ Subroutines / functions * :c:func:`i_x1_new` -.. c:function:: load_ao_integrals: - - - File : :file:`ao_two_e_ints/map_integrals.irp.f` - - .. code:: fortran - - integer function load_ao_integrals(filename) - - - Read from disk the |AO| integrals - - Needs: - - .. hlist:: - :columns: 3 - - * :c:data:`ao_integrals_map` - - Calls: - - .. hlist:: - :columns: 3 - - * :c:func:`cache_map_reallocate` - * :c:func:`map_deinit` - * :c:func:`map_sort` - - .. c:function:: n_pt_sup: @@ -1275,7 +1398,6 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:func:`ao_two_e_integrals_erf_in_map_slave` * :c:func:`ao_two_e_integrals_in_map_slave` @@ -1290,7 +1412,7 @@ Subroutines / functions Gives a unique index for i,j,k,l using permtuation symmetry. - i <-> k, j <-> l, and (i,k) <-> (j,l) + i <-> k, j <-> l, and (i,k) <-> (j,l) for non-periodic systems Called by: @@ -1298,33 +1420,45 @@ Subroutines / functions :columns: 3 * :c:data:`ao_integrals_cache` - * :c:data:`ao_integrals_erf_cache` - * :c:data:`ao_integrals_erf_map` * :c:data:`ao_integrals_map` - * :c:func:`compute_ao_integrals_erf_jl` + * :c:data:`banned_excitation` * :c:func:`compute_ao_integrals_jl` + * :c:func:`four_idx_novvvv` * :c:func:`get_ao_two_e_integral` - * :c:func:`get_ao_two_e_integral_erf` - * :c:func:`get_ao_two_e_integrals_erf_non_zero` * :c:func:`get_ao_two_e_integrals_non_zero` * :c:func:`get_ao_two_e_integrals_non_zero_jl` * :c:func:`get_ao_two_e_integrals_non_zero_jl_from_list` - * :c:func:`get_mo_two_e_integral_erf` - * :c:func:`get_mo_two_e_integrals_coulomb_ii` - * :c:func:`get_mo_two_e_integrals_erf` - * :c:func:`get_mo_two_e_integrals_erf_coulomb_ii` - * :c:func:`get_mo_two_e_integrals_erf_exch_ii` - * :c:func:`get_mo_two_e_integrals_erf_i1j1` - * :c:func:`get_mo_two_e_integrals_erf_ij` - * :c:func:`get_mo_two_e_integrals_exch_ii` - * :c:func:`get_mo_two_e_integrals_i1j1` - * :c:func:`get_mo_two_e_integrals_ij` * :c:func:`get_two_e_integral` * :c:data:`mo_integrals_cache` - * :c:data:`mo_integrals_erf_cache` - * :c:data:`mo_integrals_erf_map` * :c:data:`mo_integrals_map` - * :c:func:`test` + + +.. c:function:: two_e_integrals_index_2fold: + + + File : :file:`ao_two_e_ints/map_integrals.irp.f` + + .. code:: fortran + + subroutine two_e_integrals_index_2fold(i,j,k,l,i1) + + + + Called by: + + .. hlist:: + :columns: 3 + + * :c:data:`ao_integrals_cache_periodic` + * :c:func:`get_ao_two_e_integral_periodic` + + Calls: + + .. hlist:: + :columns: 3 + + * :c:func:`ao_idx2_sq` + * :c:func:`ao_idx2_tri_key` .. c:function:: two_e_integrals_index_reverse: @@ -1347,11 +1481,23 @@ Subroutines / functions This rule is applied 3 times. First for the symmetry of the pairs (i,k) and (j,l), and then for the symmetry within each pair. - Called by: + +.. c:function:: two_e_integrals_index_reverse_2fold: + + + File : :file:`ao_two_e_ints/map_integrals.irp.f` + + .. code:: fortran + + subroutine two_e_integrals_index_reverse_2fold(i,j,k,l,i1) + + + + Calls: .. hlist:: :columns: 3 - * :c:data:`ao_two_e_integral_alpha` - * :c:func:`test` + * :c:func:`ao_idx2_sq_rev` + * :c:func:`ao_idx2_tri_rev_key` diff --git a/docs/source/modules/becke_numerical_grid.rst b/docs/source/modules/becke_numerical_grid.rst index 7a0c7411..e67c443a 100644 --- a/docs/source/modules/becke_numerical_grid.rst +++ b/docs/source/modules/becke_numerical_grid.rst @@ -128,7 +128,7 @@ Providers .. c:var:: angular_quadrature_points - File : :file:`becke_numerical_grid/grid_becke.irp.f` + File : :file:`becke_numerical_grid/angular_grid_pts.irp.f` .. code:: fortran @@ -224,31 +224,26 @@ Providers :columns: 3 * :c:data:`aos_grad_in_r_array` - * :c:data:`aos_grad_in_r_array_transp` - * :c:data:`aos_grad_in_r_array_transp_xyz` * :c:data:`aos_in_r_array` * :c:data:`aos_lapl_in_r_array` * :c:data:`aos_sr_vc_alpha_lda_w` - * :c:data:`aos_sr_vc_alpha_pbe_w` * :c:data:`aos_sr_vxc_alpha_lda_w` - * :c:data:`aos_sr_vxc_alpha_pbe_w` * :c:data:`aos_vc_alpha_lda_w` * :c:data:`aos_vc_alpha_pbe_w` + * :c:data:`aos_vc_alpha_sr_pbe_w` * :c:data:`aos_vxc_alpha_lda_w` * :c:data:`aos_vxc_alpha_pbe_w` + * :c:data:`aos_vxc_alpha_sr_pbe_w` + * :c:data:`elec_beta_num_grid_becke` * :c:data:`energy_c_lda` - * :c:data:`energy_c_pbe` * :c:data:`energy_c_sr_lda` - * :c:data:`energy_sr_x_lda` - * :c:data:`energy_sr_x_pbe` * :c:data:`energy_x_lda` * :c:data:`energy_x_pbe` * :c:data:`energy_x_sr_lda` * :c:data:`energy_x_sr_pbe` * :c:data:`mos_in_r_array` - * :c:data:`one_e_dm_alpha_at_r` + * :c:data:`mos_in_r_array_omp` * :c:data:`one_e_dm_and_grad_alpha_in_r` - * :c:data:`one_e_dm_no_core_and_grad_alpha_in_r` .. c:var:: final_grid_points_per_atom @@ -361,31 +356,26 @@ Providers :columns: 3 * :c:data:`aos_grad_in_r_array` - * :c:data:`aos_grad_in_r_array_transp` - * :c:data:`aos_grad_in_r_array_transp_xyz` * :c:data:`aos_in_r_array` * :c:data:`aos_lapl_in_r_array` * :c:data:`aos_sr_vc_alpha_lda_w` - * :c:data:`aos_sr_vc_alpha_pbe_w` * :c:data:`aos_sr_vxc_alpha_lda_w` - * :c:data:`aos_sr_vxc_alpha_pbe_w` * :c:data:`aos_vc_alpha_lda_w` * :c:data:`aos_vc_alpha_pbe_w` + * :c:data:`aos_vc_alpha_sr_pbe_w` * :c:data:`aos_vxc_alpha_lda_w` * :c:data:`aos_vxc_alpha_pbe_w` + * :c:data:`aos_vxc_alpha_sr_pbe_w` + * :c:data:`elec_beta_num_grid_becke` * :c:data:`energy_c_lda` - * :c:data:`energy_c_pbe` * :c:data:`energy_c_sr_lda` - * :c:data:`energy_sr_x_lda` - * :c:data:`energy_sr_x_pbe` * :c:data:`energy_x_lda` * :c:data:`energy_x_pbe` * :c:data:`energy_x_sr_lda` * :c:data:`energy_x_sr_pbe` * :c:data:`mos_in_r_array` - * :c:data:`one_e_dm_alpha_at_r` + * :c:data:`mos_in_r_array_omp` * :c:data:`one_e_dm_and_grad_alpha_in_r` - * :c:data:`one_e_dm_no_core_and_grad_alpha_in_r` .. c:var:: final_weight_at_r_vector_per_atom @@ -484,7 +474,6 @@ Providers * :c:data:`final_grid_points` * :c:data:`final_grid_points_per_atom` - * :c:data:`one_e_dm_alpha_in_r` * :c:data:`weight_at_r` @@ -556,31 +545,26 @@ Providers :columns: 3 * :c:data:`aos_grad_in_r_array` - * :c:data:`aos_grad_in_r_array_transp` - * :c:data:`aos_grad_in_r_array_transp_xyz` * :c:data:`aos_in_r_array` * :c:data:`aos_lapl_in_r_array` * :c:data:`aos_sr_vc_alpha_lda_w` - * :c:data:`aos_sr_vc_alpha_pbe_w` * :c:data:`aos_sr_vxc_alpha_lda_w` - * :c:data:`aos_sr_vxc_alpha_pbe_w` * :c:data:`aos_vc_alpha_lda_w` * :c:data:`aos_vc_alpha_pbe_w` + * :c:data:`aos_vc_alpha_sr_pbe_w` * :c:data:`aos_vxc_alpha_lda_w` * :c:data:`aos_vxc_alpha_pbe_w` + * :c:data:`aos_vxc_alpha_sr_pbe_w` + * :c:data:`elec_beta_num_grid_becke` * :c:data:`energy_c_lda` - * :c:data:`energy_c_pbe` * :c:data:`energy_c_sr_lda` - * :c:data:`energy_sr_x_lda` - * :c:data:`energy_sr_x_pbe` * :c:data:`energy_x_lda` * :c:data:`energy_x_pbe` * :c:data:`energy_x_sr_lda` * :c:data:`energy_x_sr_pbe` * :c:data:`mos_in_r_array` - * :c:data:`one_e_dm_alpha_at_r` + * :c:data:`mos_in_r_array_omp` * :c:data:`one_e_dm_and_grad_alpha_in_r` - * :c:data:`one_e_dm_no_core_and_grad_alpha_in_r` .. c:var:: index_final_points_per_atom @@ -690,31 +674,26 @@ Providers :columns: 3 * :c:data:`aos_grad_in_r_array` - * :c:data:`aos_grad_in_r_array_transp` - * :c:data:`aos_grad_in_r_array_transp_xyz` * :c:data:`aos_in_r_array` * :c:data:`aos_lapl_in_r_array` * :c:data:`aos_sr_vc_alpha_lda_w` - * :c:data:`aos_sr_vc_alpha_pbe_w` * :c:data:`aos_sr_vxc_alpha_lda_w` - * :c:data:`aos_sr_vxc_alpha_pbe_w` * :c:data:`aos_vc_alpha_lda_w` * :c:data:`aos_vc_alpha_pbe_w` + * :c:data:`aos_vc_alpha_sr_pbe_w` * :c:data:`aos_vxc_alpha_lda_w` * :c:data:`aos_vxc_alpha_pbe_w` + * :c:data:`aos_vxc_alpha_sr_pbe_w` + * :c:data:`elec_beta_num_grid_becke` * :c:data:`energy_c_lda` - * :c:data:`energy_c_pbe` * :c:data:`energy_c_sr_lda` - * :c:data:`energy_sr_x_lda` - * :c:data:`energy_sr_x_pbe` * :c:data:`energy_x_lda` * :c:data:`energy_x_pbe` * :c:data:`energy_x_sr_lda` * :c:data:`energy_x_sr_pbe` * :c:data:`mos_in_r_array` - * :c:data:`one_e_dm_alpha_at_r` + * :c:data:`mos_in_r_array_omp` * :c:data:`one_e_dm_and_grad_alpha_in_r` - * :c:data:`one_e_dm_no_core_and_grad_alpha_in_r` .. c:var:: m_knowles @@ -765,43 +744,45 @@ Providers .. hlist:: :columns: 3 + * :c:data:`alpha_dens_kin_in_r` * :c:data:`aos_grad_in_r_array` * :c:data:`aos_grad_in_r_array_transp` - * :c:data:`aos_grad_in_r_array_transp_xyz` * :c:data:`aos_in_r_array` + * :c:data:`aos_in_r_array_transp` * :c:data:`aos_lapl_in_r_array` + * :c:data:`aos_lapl_in_r_array_transp` * :c:data:`aos_sr_vc_alpha_lda_w` - * :c:data:`aos_sr_vc_alpha_pbe_w` * :c:data:`aos_sr_vxc_alpha_lda_w` - * :c:data:`aos_sr_vxc_alpha_pbe_w` * :c:data:`aos_vc_alpha_lda_w` * :c:data:`aos_vc_alpha_pbe_w` + * :c:data:`aos_vc_alpha_sr_pbe_w` * :c:data:`aos_vxc_alpha_lda_w` * :c:data:`aos_vxc_alpha_pbe_w` + * :c:data:`aos_vxc_alpha_sr_pbe_w` + * :c:data:`elec_beta_num_grid_becke` * :c:data:`energy_c_lda` - * :c:data:`energy_c_pbe` * :c:data:`energy_c_sr_lda` - * :c:data:`energy_sr_x_lda` - * :c:data:`energy_sr_x_pbe` * :c:data:`energy_x_lda` * :c:data:`energy_x_pbe` * :c:data:`energy_x_sr_lda` * :c:data:`energy_x_sr_pbe` * :c:data:`final_grid_points` + * :c:data:`kinetic_density_generalized` * :c:data:`mos_grad_in_r_array` + * :c:data:`mos_grad_in_r_array_tranp` * :c:data:`mos_in_r_array` + * :c:data:`mos_in_r_array_omp` + * :c:data:`mos_in_r_array_transp` * :c:data:`mos_lapl_in_r_array` - * :c:data:`one_e_dm_alpha_at_r` * :c:data:`one_e_dm_and_grad_alpha_in_r` - * :c:data:`one_e_dm_no_core_and_grad_alpha_in_r` * :c:data:`pot_grad_x_alpha_ao_pbe` + * :c:data:`pot_grad_x_alpha_ao_sr_pbe` * :c:data:`pot_grad_xc_alpha_ao_pbe` + * :c:data:`pot_grad_xc_alpha_ao_sr_pbe` * :c:data:`pot_scal_x_alpha_ao_pbe` + * :c:data:`pot_scal_x_alpha_ao_sr_pbe` * :c:data:`pot_scal_xc_alpha_ao_pbe` - * :c:data:`pot_sr_grad_x_alpha_ao_pbe` - * :c:data:`pot_sr_grad_xc_alpha_ao_pbe` - * :c:data:`pot_sr_scal_x_alpha_ao_pbe` - * :c:data:`pot_sr_scal_xc_alpha_ao_pbe` + * :c:data:`pot_scal_xc_alpha_ao_sr_pbe` * :c:data:`potential_c_alpha_ao_lda` * :c:data:`potential_c_alpha_ao_sr_lda` * :c:data:`potential_x_alpha_ao_lda` @@ -854,6 +835,9 @@ Providers :columns: 3 * :c:data:`grid_type_sgn` + * :c:data:`my_grid_becke` + * :c:data:`my_n_pt_a_grid` + * :c:data:`my_n_pt_r_grid` Needed by: @@ -869,7 +853,6 @@ Providers * :c:data:`n_points_final_grid` * :c:data:`n_points_grid_per_atom` * :c:data:`n_pts_per_atom` - * :c:data:`one_e_dm_alpha_in_r` * :c:data:`weight_at_r` @@ -896,6 +879,9 @@ Providers :columns: 3 * :c:data:`grid_type_sgn` + * :c:data:`my_grid_becke` + * :c:data:`my_n_pt_a_grid` + * :c:data:`my_n_pt_r_grid` Needed by: @@ -911,7 +897,6 @@ Providers * :c:data:`n_points_final_grid` * :c:data:`n_points_grid_per_atom` * :c:data:`n_pts_per_atom` - * :c:data:`one_e_dm_alpha_in_r` * :c:data:`weight_at_r` @@ -1019,7 +1004,7 @@ Providers .. c:var:: weights_angular_points - File : :file:`becke_numerical_grid/grid_becke.irp.f` + File : :file:`becke_numerical_grid/angular_grid_pts.irp.f` .. code:: fortran @@ -1069,10 +1054,10 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`nucl_dist_inv` - * :c:data:`slater_bragg_type_inter_distance_ua` * :c:data:`nucl_coord_transp` + * :c:data:`nucl_dist_inv` * :c:data:`nucl_num` + * :c:data:`slater_bragg_type_inter_distance_ua` .. c:function:: derivative_knowles_function: @@ -1105,11 +1090,11 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_points_final_grid` - * :c:data:`final_weight_at_r` - * :c:data:`n_points_radial_grid` - * :c:data:`grid_points_per_atom` * :c:data:`final_grid_points` + * :c:data:`final_weight_at_r` + * :c:data:`grid_points_per_atom` + * :c:data:`n_points_final_grid` + * :c:data:`n_points_radial_grid` * :c:data:`nucl_coord` * :c:data:`nucl_num` diff --git a/docs/source/modules/cipsi.rst b/docs/source/modules/cipsi.rst index 5415a4e2..501a91dd 100644 --- a/docs/source/modules/cipsi.rst +++ b/docs/source/modules/cipsi.rst @@ -135,6 +135,16 @@ value is stable with the number of points. +EZFIO parameters +---------------- + +.. option:: pert_2rdm + + If true, computes the one- and two-body rdms with perturbation theory + + Default: False + + Providers --------- @@ -201,6 +211,75 @@ Providers * :c:data:`pt2_e0_denominator` +.. c:var:: list_orb_pert_rdm + + + File : :file:`cipsi/pert_rdm_providers.irp.f` + + .. code:: fortran + + integer, allocatable :: list_orb_pert_rdm (n_orb_pert_rdm) + + + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`list_act` + * :c:data:`n_orb_pert_rdm` + + + +.. c:var:: list_orb_reverse_pert_rdm + + + File : :file:`cipsi/pert_rdm_providers.irp.f` + + .. code:: fortran + + integer, allocatable :: list_orb_reverse_pert_rdm (mo_num) + + + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`list_act` + * :c:data:`mo_num` + + + +.. c:var:: n_orb_pert_rdm + + + File : :file:`cipsi/pert_rdm_providers.irp.f` + + .. code:: fortran + + integer :: n_orb_pert_rdm + + + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`n_act_orb` + + Needed by: + + .. hlist:: + :columns: 3 + + * :c:data:`list_orb_pert_rdm` + * :c:data:`pert_2rdm_provider` + + .. c:var:: nthreads_pt2 @@ -223,6 +302,39 @@ Providers +.. c:var:: pert_2rdm_lock + + + File : :file:`cipsi/pert_rdm_providers.irp.f` + + .. code:: fortran + + integer(omp_lock_kind) :: pert_2rdm_lock + + + + + +.. c:var:: pert_2rdm_provider + + + File : :file:`cipsi/pert_rdm_providers.irp.f` + + .. code:: fortran + + double precision, allocatable :: pert_2rdm_provider (n_orb_pert_rdm,n_orb_pert_rdm,n_orb_pert_rdm,n_orb_pert_rdm) + + + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`n_orb_pert_rdm` + + + .. c:var:: pt2_cw @@ -309,6 +421,7 @@ Providers * :c:data:`mpi_master` * :c:data:`n_core_orb` * :c:data:`n_det_generators` + * :c:data:`pt2_min_parallel_tasks` * :c:data:`pt2_n_teeth` * :c:data:`pt2_w` @@ -488,6 +601,7 @@ Providers * :c:data:`mpi_master` * :c:data:`n_core_orb` * :c:data:`n_det_generators` + * :c:data:`pt2_min_parallel_tasks` * :c:data:`pt2_n_teeth` * :c:data:`pt2_w` @@ -525,6 +639,27 @@ Providers * :c:data:`pt2_w` +.. c:var:: pt2_overlap + + + File : :file:`cipsi/energy.irp.f` + + .. code:: fortran + + double precision, allocatable :: pt2_overlap (N_states,N_states) + + + Overlap between the perturbed wave functions + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`n_states` + + + .. c:var:: pt2_r @@ -789,6 +924,7 @@ Subroutines / functions :columns: 3 * :c:func:`fill_buffer_double` + * :c:func:`fill_buffer_double_rdm` * :c:func:`pt2_collector` * :c:func:`selection_collector` @@ -896,7 +1032,7 @@ Subroutines / functions .. code:: fortran - subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_diag_tmp, E0, pt2, variance, norm, mat, buf) + subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_diag_tmp, E0, pt2_data, mat, buf) @@ -905,19 +1041,19 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_occ_pattern_hii` * :c:data:`det_to_occ_pattern` - * :c:data:`selection_weight` - * :c:data:`mo_num` - * :c:data:`n_states` - * :c:data:`weight_selection` - * :c:data:`n_int` - * :c:data:`psi_det_hii` * :c:data:`do_only_1h1p` * :c:data:`h0_type` - * :c:data:`thresh_sym` + * :c:data:`mo_num` + * :c:data:`n_int` + * :c:data:`n_states` * :c:data:`pseudo_sym` * :c:data:`psi_det_generators` + * :c:data:`psi_det_hii` + * :c:data:`psi_occ_pattern_hii` + * :c:data:`selection_weight` + * :c:data:`thresh_sym` + * :c:data:`weight_selection` Called by: @@ -934,6 +1070,59 @@ Subroutines / functions * :c:func:`add_to_selection_buffer` * :c:func:`apply_holes` * :c:func:`apply_particles` + * :c:func:`dsyevd` + + +.. c:function:: fill_buffer_double_rdm: + + + File : :file:`cipsi/pert_rdm_providers.irp.f` + + .. code:: fortran + + subroutine fill_buffer_double_rdm(i_generator, sp, h1, h2, bannedOrb, banned, fock_diag_tmp, E0, pt2_data, mat, buf, psi_det_connection, psi_coef_connection_reverse, n_det_connection) + + + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`det_to_occ_pattern` + * :c:data:`do_only_1h1p` + * :c:data:`h0_type` + * :c:data:`hf_bitmask` + * :c:data:`mo_num` + * :c:data:`n_int` + * :c:data:`n_orb_pert_rdm` + * :c:data:`n_states` + * :c:data:`pert_2rdm_lock` + * :c:data:`pert_2rdm_provider` + * :c:data:`psi_det_generators` + * :c:data:`psi_det_hii` + * :c:data:`psi_occ_pattern_hii` + * :c:data:`selection_weight` + * :c:data:`weight_selection` + + Called by: + + .. hlist:: + :columns: 3 + + * :c:func:`select_singles_and_doubles` + + Calls: + + .. hlist:: + :columns: 3 + + * :c:func:`add_to_selection_buffer` + * :c:func:`apply_holes` + * :c:func:`apply_particles` + * :c:func:`get_excitation_degree` + * :c:func:`give_2rdm_pert_contrib` + * :c:func:`update_keys_values` .. c:function:: get_d0: @@ -952,10 +1141,10 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_states` - * :c:data:`n_int` * :c:data:`mo_integrals_map` * :c:data:`mo_num` + * :c:data:`n_int` + * :c:data:`n_states` Called by: @@ -974,6 +1163,35 @@ Subroutines / functions * :c:func:`i_h_j` +.. c:function:: get_d0_reference: + + + File : :file:`cipsi/selection.irp.f` + + .. code:: fortran + + subroutine get_d0_reference(gen, phasemask, bannedOrb, banned, mat, mask, h, p, sp, coefs) + + + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`mo_num` + * :c:data:`n_int` + * :c:data:`n_states` + + Calls: + + .. hlist:: + :columns: 3 + + * :c:func:`apply_particles` + * :c:func:`i_h_j` + + .. c:function:: get_d1: @@ -990,10 +1208,10 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_states` - * :c:data:`n_int` * :c:data:`mo_integrals_map` * :c:data:`mo_num` + * :c:data:`n_int` + * :c:data:`n_states` Called by: @@ -1012,6 +1230,35 @@ Subroutines / functions * :c:func:`i_h_j` +.. c:function:: get_d1_reference: + + + File : :file:`cipsi/selection.irp.f` + + .. code:: fortran + + subroutine get_d1_reference(gen, phasemask, bannedOrb, banned, mat, mask, h, p, sp, coefs) + + + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`mo_num` + * :c:data:`n_int` + * :c:data:`n_states` + + Calls: + + .. hlist:: + :columns: 3 + + * :c:func:`apply_particles` + * :c:func:`i_h_j` + + .. c:function:: get_d2: @@ -1028,9 +1275,9 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_states` - * :c:data:`n_int` * :c:data:`mo_num` + * :c:data:`n_int` + * :c:data:`n_states` Called by: @@ -1040,6 +1287,27 @@ Subroutines / functions * :c:func:`splash_pq` +.. c:function:: get_d2_reference: + + + File : :file:`cipsi/selection.irp.f` + + .. code:: fortran + + subroutine get_d2_reference(gen, phasemask, bannedOrb, banned, mat, mask, h, p, sp, coefs) + + + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`mo_num` + * :c:data:`n_int` + * :c:data:`n_states` + + .. c:function:: get_mask_phase: @@ -1071,6 +1339,47 @@ Subroutines / functions +.. c:function:: give_2rdm_pert_contrib: + + + File : :file:`cipsi/update_2rdm.irp.f` + + .. code:: fortran + + subroutine give_2rdm_pert_contrib(det,coef,psi_det_connection,psi_coef_connection_reverse,n_det_connection,nkeys,keys,values,sze_buff) + + + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`elec_alpha_num` + * :c:data:`n_int` + * :c:data:`n_orb_pert_rdm` + * :c:data:`n_states` + * :c:data:`pert_2rdm_lock` + * :c:data:`pert_2rdm_provider` + * :c:data:`state_average_weight` + + Called by: + + .. hlist:: + :columns: 3 + + * :c:func:`fill_buffer_double_rdm` + + Calls: + + .. hlist:: + :columns: 3 + + * :c:func:`get_excitation` + * :c:func:`update_buffer_single_exc_rdm` + * :c:func:`update_keys_values` + + .. c:function:: make_selection_buffer_s2: @@ -1212,32 +1521,32 @@ Subroutines / functions .. hlist:: :columns: 3 + * :c:data:`ci_energy` * :c:data:`generators_bitmask` - * :c:data:`selection_weight` - * :c:data:`pt2_stoch_istate` - * :c:data:`psi_selectors` - * :c:data:`psi_det` - * :c:data:`zmq_state` - * :c:data:`psi_coef` - * :c:data:`mpi_master` - * :c:data:`n_det` - * :c:data:`zmq_context` - * :c:data:`n_det_selectors` - * :c:data:`state_average_weight` + * :c:data:`h_apply_buffer_allocated` * :c:data:`mo_num` * :c:data:`mo_two_e_integrals_in_map` - * :c:data:`pt2_e0_denominator` - * :c:data:`ci_energy` - * :c:data:`n_states_diag` - * :c:data:`threshold_generators` - * :c:data:`psi_det_sorted_bit` - * :c:data:`n_states` - * :c:data:`h_apply_buffer_allocated` + * :c:data:`mpi_master` + * :c:data:`n_det` * :c:data:`n_det_generators` - * :c:data:`psi_det_generators` + * :c:data:`n_det_selectors` * :c:data:`n_int` + * :c:data:`n_states` + * :c:data:`n_states_diag` * :c:data:`pseudo_sym` + * :c:data:`psi_coef` * :c:data:`psi_det_generators` + * :c:data:`psi_det` + * :c:data:`psi_det_generators` + * :c:data:`psi_det_sorted_bit` + * :c:data:`psi_selectors` + * :c:data:`pt2_e0_denominator` + * :c:data:`pt2_stoch_istate` + * :c:data:`selection_weight` + * :c:data:`state_average_weight` + * :c:data:`threshold_generators` + * :c:data:`zmq_context` + * :c:data:`zmq_state` Called by: @@ -1247,6 +1556,85 @@ Subroutines / functions * :c:func:`run_slave_cipsi` +.. c:function:: pt2_add: + + + File : :file:`cipsi/pt2_type.irp.f` + + .. code:: fortran + + subroutine pt2_add(p1, w, p2) + + + p1 =! p1 +( w * p2) + + Called by: + + .. hlist:: + :columns: 3 + + * :c:func:`pt2_collector` + * :c:func:`selection_collector` + + +.. c:function:: pt2_add2: + + + File : :file:`cipsi/pt2_type.irp.f` + + .. code:: fortran + + subroutine pt2_add2(p1, w, p2) + + + p1 =! p1 +( w * p2**2) + + Called by: + + .. hlist:: + :columns: 3 + + * :c:func:`pt2_collector` + + +.. c:function:: pt2_addr: + + + File : :file:`cipsi/pt2_type.irp.f` + + .. code:: fortran + + subroutine pt2_addr(p1, a, b, p2) + + + p1 =! p1 +( a / b * p2) + + +.. c:function:: pt2_alloc: + + + File : :file:`cipsi/pt2_type.irp.f` + + .. code:: fortran + + subroutine pt2_alloc(pt2_data,N) + + + + Called by: + + .. hlist:: + :columns: 3 + + * :c:func:`pt2_collector` + * :c:func:`run_cipsi` + * :c:func:`run_pt2_slave_large` + * :c:func:`run_pt2_slave_small` + * :c:func:`run_selection_slave` + * :c:func:`run_stochastic_cipsi` + * :c:func:`selection_collector` + + .. c:function:: pt2_collector: @@ -1254,7 +1642,7 @@ Subroutines / functions .. code:: fortran - subroutine pt2_collector(zmq_socket_pull, E, relative_error, pt2, error, variance, norm, b, N_) + subroutine pt2_collector(zmq_socket_pull, E, relative_error, pt2_data, pt2_data_err, b, N_) @@ -1263,14 +1651,14 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`pt2_j` - * :c:data:`pt2_stoch_istate` + * :c:data:`n_det_generators` * :c:data:`n_states` * :c:data:`pt2_f` - * :c:data:`pt2_w` - * :c:data:`n_det_generators` + * :c:data:`pt2_j` * :c:data:`pt2_n_teeth` + * :c:data:`pt2_stoch_istate` * :c:data:`pt2_u` + * :c:data:`pt2_w` Called by: @@ -1289,12 +1677,61 @@ Subroutines / functions * :c:func:`create_selection_buffer` * :c:func:`delete_selection_buffer` * :c:func:`end_zmq_to_qp_run_socket` + * :c:func:`pt2_add` + * :c:func:`pt2_add2` + * :c:func:`pt2_alloc` + * :c:func:`pt2_dealloc` * :c:func:`pull_pt2_results` * :c:func:`sleep` * :c:func:`sort_selection_buffer` * :c:func:`wall_time` +.. c:function:: pt2_dealloc: + + + File : :file:`cipsi/pt2_type.irp.f` + + .. code:: fortran + + subroutine pt2_dealloc(pt2_data) + + + + Called by: + + .. hlist:: + :columns: 3 + + * :c:func:`pt2_collector` + * :c:func:`run_cipsi` + * :c:func:`run_pt2_slave_large` + * :c:func:`run_pt2_slave_small` + * :c:func:`run_selection_slave` + * :c:func:`run_stochastic_cipsi` + * :c:func:`selection_collector` + + +.. c:function:: pt2_deserialize: + + + File : :file:`cipsi/pt2_type.irp.f` + + .. code:: fortran + + subroutine pt2_deserialize(pt2_data, n, x) + + + + Called by: + + .. hlist:: + :columns: 3 + + * :c:func:`pull_pt2_results` + * :c:func:`pull_selection_results` + + .. c:function:: pt2_find_sample: @@ -1333,6 +1770,26 @@ Subroutines / functions * :c:data:`n_det_generators` +.. c:function:: pt2_serialize: + + + File : :file:`cipsi/pt2_type.irp.f` + + .. code:: fortran + + subroutine pt2_serialize(pt2_data, n, x) + + + + Called by: + + .. hlist:: + :columns: 3 + + * :c:func:`push_pt2_results_async_send` + * :c:func:`push_selection_results` + + .. c:function:: pt2_slave_inproc: @@ -1374,7 +1831,7 @@ Subroutines / functions .. code:: fortran - subroutine pull_pt2_results(zmq_socket_pull, index, pt2, variance, norm, task_id, n_tasks, b) + subroutine pull_pt2_results(zmq_socket_pull, index, pt2_data, task_id, n_tasks, b) @@ -1383,8 +1840,8 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_states` * :c:data:`n_int` + * :c:data:`n_states` Called by: @@ -1393,6 +1850,13 @@ Subroutines / functions * :c:func:`pt2_collector` + Calls: + + .. hlist:: + :columns: 3 + + * :c:func:`pt2_deserialize` + .. c:function:: pull_selection_results: @@ -1401,7 +1865,7 @@ Subroutines / functions .. code:: fortran - subroutine pull_selection_results(zmq_socket_pull, pt2, variance, norm, val, det, N, task_id, ntask) + subroutine pull_selection_results(zmq_socket_pull, pt2_data, val, det, N, task_id, ntasks) @@ -1410,8 +1874,8 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_states` * :c:data:`n_int` + * :c:data:`n_states` Called by: @@ -1420,6 +1884,13 @@ Subroutines / functions * :c:func:`selection_collector` + Calls: + + .. hlist:: + :columns: 3 + + * :c:func:`pt2_deserialize` + .. c:function:: push_pt2_results: @@ -1428,17 +1899,10 @@ Subroutines / functions .. code:: fortran - subroutine push_pt2_results(zmq_socket_push, index, pt2, variance, norm, b, task_id, n_tasks) + subroutine push_pt2_results(zmq_socket_push, index, pt2_data, b, task_id, n_tasks) - Needs: - - .. hlist:: - :columns: 3 - - * :c:data:`n_states` - Called by: .. hlist:: @@ -1482,7 +1946,7 @@ Subroutines / functions .. code:: fortran - subroutine push_pt2_results_async_send(zmq_socket_push, index, pt2, variance, norm, b, task_id, n_tasks, sending) + subroutine push_pt2_results_async_send(zmq_socket_push, index, pt2_data, b, task_id, n_tasks, sending) @@ -1491,8 +1955,8 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_states` * :c:data:`n_int` + * :c:data:`n_states` Called by: @@ -1502,6 +1966,13 @@ Subroutines / functions * :c:func:`push_pt2_results` * :c:func:`run_pt2_slave_large` + Calls: + + .. hlist:: + :columns: 3 + + * :c:func:`pt2_serialize` + .. c:function:: push_selection_results: @@ -1510,7 +1981,7 @@ Subroutines / functions .. code:: fortran - subroutine push_selection_results(zmq_socket_push, pt2, variance, norm, b, task_id, ntask) + subroutine push_selection_results(zmq_socket_push, pt2_data, b, task_id, ntasks) @@ -1519,8 +1990,8 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_states` * :c:data:`n_int` + * :c:data:`n_states` Called by: @@ -1529,6 +2000,13 @@ Subroutines / functions * :c:func:`run_selection_slave` + Calls: + + .. hlist:: + :columns: 3 + + * :c:func:`pt2_serialize` + .. c:function:: remove_duplicates_in_selection_buffer: @@ -1583,26 +2061,26 @@ Subroutines / functions :columns: 3 * :c:data:`correlation_energy_ratio_max` - * :c:data:`n_iter` - * :c:data:`psi_energy_with_nucl_rep` - * :c:data:`selection_factor` - * :c:data:`psi_occ_pattern` - * :c:data:`n_det_max` - * :c:data:`n_states` + * :c:data:`do_pt2` * :c:data:`h_apply_buffer_allocated` * :c:data:`n_det` - * :c:data:`s2_eig` - * :c:data:`variance_max` - * :c:data:`do_pt2` - * :c:data:`psi_energy` - * :c:data:`pt2_relative_error` - * :c:data:`ref_bitmask_energy` - * :c:data:`psi_det` + * :c:data:`n_det_max` + * :c:data:`n_iter` + * :c:data:`n_states` * :c:data:`n_states_diag` * :c:data:`psi_coef` + * :c:data:`psi_det` * :c:data:`psi_det_sorted` + * :c:data:`psi_energy` + * :c:data:`psi_energy_with_nucl_rep` + * :c:data:`psi_occ_pattern` * :c:data:`pt2_max` + * :c:data:`pt2_relative_error` + * :c:data:`ref_bitmask_energy` + * :c:data:`s2_eig` + * :c:data:`selection_factor` * :c:data:`threshold_generators` + * :c:data:`variance_max` Called by: @@ -1617,12 +2095,15 @@ Subroutines / functions :columns: 3 * :c:func:`check_mem` + * :c:func:`copy_h_apply_buffer_to_wf` * :c:func:`diagonalize_ci` * :c:func:`ezfio_get_hartree_fock_energy` * :c:func:`ezfio_has_hartree_fock_energy` * :c:func:`make_s2_eigenfunction` * :c:func:`print_extrapolated_energy` * :c:func:`print_summary` + * :c:func:`pt2_alloc` + * :c:func:`pt2_dealloc` * :c:func:`save_energy` * :c:func:`save_iterations` * :c:func:`save_wavefunction` @@ -1652,8 +2133,11 @@ Subroutines / functions * :c:data:`psi_occ_pattern` * :c:data:`psi_energy` * :c:data:`pt2_match_weight` + * :c:data:`pt2_overlap` * :c:data:`pt2_stoch_istate` + * :c:data:`selection_weight` * :c:data:`state_average_weight` + * :c:data:`threshold_davidson_pt2` * :c:data:`threshold_generators` * :c:data:`variance_match_weight` @@ -1674,11 +2158,7 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_det` * :c:data:`n_states_diag` - * :c:data:`nproc` - * :c:data:`elec_alpha_num` - * :c:data:`mo_num` Called by: @@ -1694,7 +2174,6 @@ Subroutines / functions :columns: 3 * :c:func:`run_pt2_slave_large` - * :c:func:`run_pt2_slave_small` .. c:function:: run_pt2_slave_large: @@ -1713,13 +2192,13 @@ Subroutines / functions .. hlist:: :columns: 3 + * :c:data:`elec_alpha_num` + * :c:data:`global_selection_buffer` + * :c:data:`global_selection_buffer_lock` * :c:data:`mo_num` * :c:data:`n_states` - * :c:data:`pt2_f` - * :c:data:`elec_alpha_num` * :c:data:`n_states_diag` - * :c:data:`global_selection_buffer_lock` - * :c:data:`global_selection_buffer` + * :c:data:`pt2_f` Called by: @@ -1740,6 +2219,8 @@ Subroutines / functions * :c:func:`merge_selection_buffers` * :c:func:`omp_set_lock` * :c:func:`omp_unset_lock` + * :c:func:`pt2_alloc` + * :c:func:`pt2_dealloc` * :c:func:`push_pt2_results_async_recv` * :c:func:`push_pt2_results_async_send` * :c:func:`select_connected` @@ -1764,18 +2245,12 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_states_diag` - * :c:data:`n_states` - * :c:data:`pt2_f` * :c:data:`elec_alpha_num` * :c:data:`mo_num` - - Called by: - - .. hlist:: - :columns: 3 - - * :c:func:`run_pt2_slave` + * :c:data:`n_states` + * :c:data:`n_states_diag` + * :c:data:`nproc` + * :c:data:`pt2_f` Calls: @@ -1786,10 +2261,12 @@ Subroutines / functions * :c:func:`delete_selection_buffer` * :c:func:`end_zmq_push_socket` * :c:func:`end_zmq_to_qp_run_socket` + * :c:func:`pt2_alloc` + * :c:func:`pt2_dealloc` * :c:func:`push_pt2_results` * :c:func:`select_connected` - * :c:func:`sleep` * :c:func:`sort_selection_buffer` + * :c:func:`usleep` * :c:func:`wall_time` @@ -1809,24 +2286,22 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_det_beta_unique` - * :c:data:`psi_bilinear_matrix_values` - * :c:data:`psi_bilinear_matrix_transp_values` - * :c:data:`mo_num` - * :c:data:`psi_det_sorted` - * :c:data:`psi_bilinear_matrix_transp_rows_loc` - * :c:data:`n_states` - * :c:data:`pt2_f` - * :c:data:`elec_alpha_num` - * :c:data:`psi_bilinear_matrix_values` - * :c:data:`weight_selection` - * :c:data:`psi_bilinear_matrix_transp_values` * :c:data:`n_int` - * :c:data:`psi_det_alpha_unique` - * :c:data:`psi_det_sorted` + * :c:data:`n_states` * :c:data:`pseudo_sym` * :c:data:`psi_bilinear_matrix_columns_loc` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_bilinear_matrix_transp_values` + * :c:data:`psi_bilinear_matrix_transp_values` + * :c:data:`psi_bilinear_matrix_transp_rows_loc` + * :c:data:`psi_det_alpha_unique` + * :c:data:`psi_det_beta_unique` + * :c:data:`psi_det_sorted` + * :c:data:`psi_det_sorted` * :c:data:`psi_selectors_coef_transp` + * :c:data:`pt2_f` + * :c:data:`weight_selection` Called by: @@ -1845,10 +2320,12 @@ Subroutines / functions * :c:func:`delete_selection_buffer` * :c:func:`end_zmq_push_socket` * :c:func:`end_zmq_to_qp_run_socket` + * :c:func:`pt2_alloc` + * :c:func:`pt2_dealloc` * :c:func:`push_selection_results` * :c:func:`select_connected` - * :c:func:`sleep` * :c:func:`sort_selection_buffer` + * :c:func:`usleep` .. c:function:: run_slave_cipsi: @@ -1868,8 +2345,8 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`read_wf` * :c:data:`distributed_davidson` + * :c:data:`read_wf` Called by: @@ -1919,31 +2396,31 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`selection_weight` - * :c:data:`pt2_stoch_istate` - * :c:data:`psi_det` - * :c:data:`zmq_state` - * :c:data:`psi_coef` - * :c:data:`mpi_rank` - * :c:data:`mpi_master` - * :c:data:`n_det` - * :c:data:`zmq_context` - * :c:data:`n_det_selectors` - * :c:data:`state_average_weight` - * :c:data:`mo_num` - * :c:data:`nthreads_pt2` - * :c:data:`elec_alpha_num` - * :c:data:`pt2_e0_denominator` - * :c:data:`h0_type` - * :c:data:`qp_max_mem` - * :c:data:`n_states_diag` - * :c:data:`threshold_generators` * :c:data:`det_to_occ_pattern` - * :c:data:`n_states` - * :c:data:`pt2_f` - * :c:data:`n_det_generators` - * :c:data:`n_int` + * :c:data:`elec_alpha_num` * :c:data:`global_selection_buffer` + * :c:data:`h0_type` + * :c:data:`mo_num` + * :c:data:`mpi_master` + * :c:data:`mpi_rank` + * :c:data:`n_det` + * :c:data:`n_det_generators` + * :c:data:`n_det_selectors` + * :c:data:`n_int` + * :c:data:`n_states` + * :c:data:`n_states_diag` + * :c:data:`nthreads_pt2` + * :c:data:`psi_coef` + * :c:data:`psi_det` + * :c:data:`pt2_e0_denominator` + * :c:data:`pt2_f` + * :c:data:`pt2_stoch_istate` + * :c:data:`qp_max_mem` + * :c:data:`selection_weight` + * :c:data:`state_average_weight` + * :c:data:`threshold_generators` + * :c:data:`zmq_context` + * :c:data:`zmq_state` Called by: @@ -1964,7 +2441,7 @@ Subroutines / functions * :c:func:`resident_memory` * :c:func:`run_pt2_slave` * :c:func:`run_selection_slave` - * :c:func:`sleep` + * :c:func:`usleep` * :c:func:`wait_for_states` * :c:func:`wall_time` * :c:func:`write_double` @@ -1999,26 +2476,25 @@ Subroutines / functions :columns: 3 * :c:data:`correlation_energy_ratio_max` - * :c:data:`n_iter` - * :c:data:`psi_energy_with_nucl_rep` - * :c:data:`selection_factor` - * :c:data:`psi_occ_pattern` - * :c:data:`pt2_max` - * :c:data:`n_det_max` - * :c:data:`n_states` * :c:data:`h_apply_buffer_allocated` * :c:data:`n_det` - * :c:data:`s2_eig` - * :c:data:`variance_max` + * :c:data:`n_det_max` + * :c:data:`n_iter` + * :c:data:`n_states` + * :c:data:`n_states_diag` + * :c:data:`psi_coef` + * :c:data:`psi_det` + * :c:data:`psi_det_sorted` * :c:data:`psi_energy` + * :c:data:`psi_energy_with_nucl_rep` + * :c:data:`psi_occ_pattern` + * :c:data:`pt2_max` * :c:data:`pt2_relative_error` * :c:data:`ref_bitmask_energy` - * :c:data:`psi_det` - * :c:data:`n_states_diag` - * :c:data:`n_generators_bitmask` - * :c:data:`psi_det_sorted` - * :c:data:`psi_coef` + * :c:data:`s2_eig` + * :c:data:`selection_factor` * :c:data:`threshold_generators` + * :c:data:`variance_max` Called by: @@ -2040,6 +2516,8 @@ Subroutines / functions * :c:func:`make_s2_eigenfunction` * :c:func:`print_extrapolated_energy` * :c:func:`print_summary` + * :c:func:`pt2_alloc` + * :c:func:`pt2_dealloc` * :c:func:`save_energy` * :c:func:`save_iterations` * :c:func:`save_wavefunction` @@ -2068,8 +2546,11 @@ Subroutines / functions * :c:data:`psi_occ_pattern` * :c:data:`psi_energy` * :c:data:`pt2_match_weight` + * :c:data:`pt2_overlap` * :c:data:`pt2_stoch_istate` + * :c:data:`selection_weight` * :c:data:`state_average_weight` + * :c:data:`threshold_davidson_pt2` * :c:data:`threshold_generators` * :c:data:`variance_match_weight` @@ -2081,7 +2562,7 @@ Subroutines / functions .. code:: fortran - subroutine select_connected(i_generator,E0,pt2,variance,norm,b,subset,csubset) + subroutine select_connected(i_generator,E0,pt2_data,b,subset,csubset) @@ -2092,9 +2573,8 @@ Subroutines / functions * :c:data:`generators_bitmask` * :c:data:`mo_num` - * :c:data:`n_states` * :c:data:`n_int` - * :c:data:`n_generators_bitmask` + * :c:data:`n_states` * :c:data:`psi_det_generators` Called by: @@ -2122,7 +2602,7 @@ Subroutines / functions .. code:: fortran - subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_diag_tmp,E0,pt2,variance,norm,buf,subset,csubset) + subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_diag_tmp,E0,pt2_data,buf,subset,csubset) WARNING /!\ : It is assumed that the generators and selectors are psi_det_sorted @@ -2132,24 +2612,26 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_det_beta_unique` - * :c:data:`psi_bilinear_matrix_values` - * :c:data:`psi_bilinear_matrix_transp_values` + * :c:data:`banned_excitation` * :c:data:`mo_num` - * :c:data:`psi_bilinear_matrix_transp_rows_loc` - * :c:data:`n_states` * :c:data:`n_det` - * :c:data:`psi_bilinear_matrix_transp_values` - * :c:data:`psi_bilinear_matrix_values` * :c:data:`n_det_selectors` + * :c:data:`n_int` + * :c:data:`n_states` + * :c:data:`pert_2rdm` + * :c:data:`psi_bilinear_matrix_columns_loc` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_bilinear_matrix_transp_values` + * :c:data:`psi_bilinear_matrix_transp_values` + * :c:data:`psi_bilinear_matrix_transp_rows_loc` * :c:data:`psi_bilinear_matrix_transp_values` * :c:data:`psi_bilinear_matrix_values` - * :c:data:`n_int` - * :c:data:`psi_det_generators` * :c:data:`psi_det_alpha_unique` + * :c:data:`psi_det_beta_unique` + * :c:data:`psi_det_generators` * :c:data:`psi_det_sorted` * :c:data:`psi_det_sorted` - * :c:data:`psi_bilinear_matrix_columns_loc` * :c:data:`psi_selectors_coef_transp` Called by: @@ -2167,6 +2649,7 @@ Subroutines / functions * :c:func:`apply_hole` * :c:func:`bitstring_to_list_ab` * :c:func:`fill_buffer_double` + * :c:func:`fill_buffer_double_rdm` * :c:func:`get_excitation_degree_spin` * :c:func:`isort` * :c:func:`splash_pq` @@ -2180,7 +2663,7 @@ Subroutines / functions .. code:: fortran - subroutine selection_collector(zmq_socket_pull, b, N, pt2, variance, norm) + subroutine selection_collector(zmq_socket_pull, b, N, pt2_data) @@ -2209,6 +2692,9 @@ Subroutines / functions * :c:func:`create_selection_buffer` * :c:func:`delete_selection_buffer` * :c:func:`end_zmq_to_qp_run_socket` + * :c:func:`pt2_add` + * :c:func:`pt2_alloc` + * :c:func:`pt2_dealloc` * :c:func:`pull_selection_results` * :c:func:`sort_selection_buffer` @@ -2304,11 +2790,11 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_selectors_coef_transp` + * :c:data:`mo_num` + * :c:data:`n_int` * :c:data:`n_states` * :c:data:`psi_det_sorted` - * :c:data:`n_int` - * :c:data:`mo_num` + * :c:data:`psi_selectors_coef_transp` Called by: @@ -2349,8 +2835,8 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_int` * :c:data:`mo_num` + * :c:data:`n_int` Called by: @@ -2383,9 +2869,9 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`pt2_stoch_istate` * :c:data:`n_det_generators` * :c:data:`psi_det_sorted_gen` + * :c:data:`pt2_stoch_istate` Calls: @@ -2395,6 +2881,59 @@ Subroutines / functions * :c:func:`check_mem` +.. c:function:: update_buffer_double_exc_rdm: + + + File : :file:`cipsi/update_2rdm.irp.f` + + .. code:: fortran + + subroutine update_buffer_double_exc_rdm(exc,phase,contrib,nkeys,keys,values,sze_buff) + + + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`list_orb_reverse_pert_rdm` + + +.. c:function:: update_buffer_single_exc_rdm: + + + File : :file:`cipsi/update_2rdm.irp.f` + + .. code:: fortran + + subroutine update_buffer_single_exc_rdm(det1,det2,exc,phase,contrib,nkeys,keys,values,sze_buff) + + + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`list_orb_reverse_pert_rdm` + * :c:data:`n_int` + + Called by: + + .. hlist:: + :columns: 3 + + * :c:func:`give_2rdm_pert_contrib` + + Calls: + + .. hlist:: + :columns: 3 + + * :c:func:`bitstring_to_list_ab` + + .. c:function:: update_pt2_and_variance_weights: @@ -2402,17 +2941,22 @@ Subroutines / functions .. code:: fortran - subroutine update_pt2_and_variance_weights(pt2, variance, norm, N_st) + subroutine update_pt2_and_variance_weights(pt2_data, N_st) - Updates the rPT2- and Variance- matching weights. + Updates the PT2- and Variance- matching weights. Needs: .. hlist:: :columns: 3 + * :c:data:`n_det` + * :c:data:`n_states` * :c:data:`pt2_match_weight` + * :c:data:`pt2_relative_error` + * :c:data:`threshold_davidson` + * :c:data:`threshold_davidson_pt2` * :c:data:`variance_match_weight` Called by: @@ -2429,6 +2973,7 @@ Subroutines / functions :columns: 3 * :c:data:`pt2_match_weight` + * :c:data:`threshold_davidson_pt2` * :c:data:`variance_match_weight` @@ -2439,7 +2984,7 @@ Subroutines / functions .. code:: fortran - subroutine ZMQ_pt2(E, pt2,relative_error, error, variance, norm, N_in) + subroutine ZMQ_pt2(E, pt2_data, pt2_data_err, relative_error, N_in) @@ -2448,48 +2993,48 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_det_sorted` - * :c:data:`selection_weight` - * :c:data:`pt2_stoch_istate` - * :c:data:`psi_selectors` - * :c:data:`psi_bilinear_matrix_values` - * :c:data:`psi_det_alpha_unique` - * :c:data:`pt2_e0_denominator` - * :c:data:`pt2_n_teeth` - * :c:data:`psi_selectors_coef_transp` - * :c:data:`state_average_weight` - * :c:data:`n_det` - * :c:data:`s2_eig` - * :c:data:`psi_det_sorted` - * :c:data:`pt2_j` - * :c:data:`mo_two_e_integrals_in_map` - * :c:data:`psi_bilinear_matrix_transp_values` - * :c:data:`psi_occ_pattern_hii` - * :c:data:`mo_num` - * :c:data:`nthreads_pt2` - * :c:data:`psi_bilinear_matrix_values` - * :c:data:`mo_one_e_integrals` - * :c:data:`elec_alpha_num` - * :c:data:`nproc` - * :c:data:`h0_type` - * :c:data:`qp_max_mem` - * :c:data:`n_generators_bitmask` - * :c:data:`psi_bilinear_matrix_columns_loc` - * :c:data:`threshold_generators` - * :c:data:`psi_det_beta_unique` * :c:data:`det_to_occ_pattern` + * :c:data:`elec_alpha_num` * :c:data:`global_selection_buffer` - * :c:data:`psi_bilinear_matrix_transp_rows_loc` - * :c:data:`n_states` - * :c:data:`pt2_f` + * :c:data:`h0_type` + * :c:data:`mo_num` + * :c:data:`mo_one_e_integrals` + * :c:data:`mo_two_e_integrals_in_map` + * :c:data:`n_det` * :c:data:`n_det_generators` - * :c:data:`psi_bilinear_matrix_transp_values` * :c:data:`n_int` - * :c:data:`psi_det_hii` - * :c:data:`pt2_j` + * :c:data:`n_states` + * :c:data:`nproc` + * :c:data:`nthreads_pt2` * :c:data:`pseudo_sym` - * :c:data:`pt2_w` + * :c:data:`psi_bilinear_matrix_columns_loc` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_bilinear_matrix_transp_values` + * :c:data:`psi_bilinear_matrix_transp_values` + * :c:data:`psi_bilinear_matrix_transp_rows_loc` + * :c:data:`psi_det_alpha_unique` + * :c:data:`psi_det_beta_unique` + * :c:data:`psi_det_hii` + * :c:data:`psi_det_sorted` + * :c:data:`psi_det_sorted` + * :c:data:`psi_occ_pattern_hii` + * :c:data:`psi_selectors` + * :c:data:`psi_selectors_coef_transp` + * :c:data:`pt2_e0_denominator` + * :c:data:`pt2_f` + * :c:data:`pt2_j` + * :c:data:`pt2_n_teeth` + * :c:data:`pt2_overlap` + * :c:data:`pt2_j` + * :c:data:`pt2_stoch_istate` * :c:data:`pt2_u` + * :c:data:`pt2_w` + * :c:data:`qp_max_mem` + * :c:data:`s2_eig` + * :c:data:`selection_weight` + * :c:data:`state_average_weight` + * :c:data:`threshold_generators` Called by: @@ -2526,16 +3071,12 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_det` - * :c:data:`c0_weight` - * :c:data:`psi_coef` - * :c:data:`psi_det_sorted_bit` - * :c:data:`psi_det` - * :c:data:`psi_det_size` - * :c:data:`psi_det_sorted_bit` * :c:data:`pt2_match_weight` + * :c:data:`pt2_overlap` * :c:data:`pt2_stoch_istate` + * :c:data:`selection_weight` * :c:data:`state_average_weight` + * :c:data:`threshold_davidson_pt2` * :c:data:`variance_match_weight` @@ -2546,7 +3087,7 @@ Subroutines / functions .. code:: fortran - subroutine ZMQ_selection(N_in, pt2, variance, norm) + subroutine ZMQ_selection(N_in, pt2_data) @@ -2555,31 +3096,34 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_det_sorted` - * :c:data:`selection_weight` - * :c:data:`psi_selectors` - * :c:data:`psi_bilinear_matrix_values` - * :c:data:`n_det` - * :c:data:`psi_bilinear_matrix_columns_loc` - * :c:data:`n_det_selectors` - * :c:data:`psi_det_alpha_unique` - * :c:data:`psi_bilinear_matrix_transp_values` - * :c:data:`state_average_weight` - * :c:data:`psi_bilinear_matrix_values` - * :c:data:`pt2_e0_denominator` * :c:data:`do_pt2` - * :c:data:`nproc` - * :c:data:`s2_eig` - * :c:data:`threshold_generators` - * :c:data:`psi_det_beta_unique` - * :c:data:`qp_max_mem` - * :c:data:`psi_bilinear_matrix_transp_rows_loc` - * :c:data:`n_states` - * :c:data:`pt2_f` + * :c:data:`elec_alpha_num` + * :c:data:`mo_num` + * :c:data:`n_det` * :c:data:`n_det_generators` - * :c:data:`psi_bilinear_matrix_transp_values` + * :c:data:`n_det_selectors` * :c:data:`n_int` + * :c:data:`n_states` + * :c:data:`nproc` * :c:data:`pseudo_sym` + * :c:data:`psi_bilinear_matrix_columns_loc` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_bilinear_matrix_transp_values` + * :c:data:`psi_bilinear_matrix_transp_values` + * :c:data:`psi_bilinear_matrix_transp_rows_loc` + * :c:data:`psi_det_alpha_unique` + * :c:data:`psi_det_beta_unique` + * :c:data:`psi_det_sorted` + * :c:data:`psi_selectors` + * :c:data:`pt2_e0_denominator` + * :c:data:`pt2_f` + * :c:data:`pt2_overlap` + * :c:data:`qp_max_mem` + * :c:data:`s2_eig` + * :c:data:`selection_weight` + * :c:data:`state_average_weight` + * :c:data:`threshold_generators` Called by: @@ -2594,14 +3138,12 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:func:`copy_h_apply_buffer_to_wf` * :c:func:`create_selection_buffer` * :c:func:`delete_selection_buffer` * :c:func:`end_parallel_job` * :c:func:`fill_h_apply_buffer_no_selection` * :c:func:`make_selection_buffer_s2` * :c:func:`new_parallel_job` - * :c:func:`save_wavefunction` * :c:func:`selection_collector` * :c:func:`selection_slave_inproc` * :c:func:`update_pt2_and_variance_weights` @@ -2612,13 +3154,8 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_det` - * :c:data:`c0_weight` - * :c:data:`psi_coef` - * :c:data:`psi_det_sorted_bit` - * :c:data:`psi_det` - * :c:data:`psi_det_size` - * :c:data:`psi_det_sorted_bit` * :c:data:`pt2_match_weight` + * :c:data:`pt2_overlap` + * :c:data:`threshold_davidson_pt2` * :c:data:`variance_match_weight` diff --git a/docs/source/modules/cis.rst b/docs/source/modules/cis.rst index 151e3bda..3c96a6c6 100644 --- a/docs/source/modules/cis.rst +++ b/docs/source/modules/cis.rst @@ -87,20 +87,19 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_coef` - * :c:data:`n_states` * :c:data:`generators_bitmask` + * :c:data:`h_apply_buffer_allocated` * :c:data:`mo_num` * :c:data:`mo_two_e_integrals_in_map` - * :c:data:`h_apply_buffer_allocated` * :c:data:`n_det` - * :c:data:`s2_eig` * :c:data:`n_det_generators` - * :c:data:`i_bitmask_gen` * :c:data:`n_int` + * :c:data:`n_states` + * :c:data:`psi_coef` + * :c:data:`psi_det_generators` * :c:data:`psi_det` * :c:data:`psi_det_generators` - * :c:data:`psi_det_generators` + * :c:data:`s2_eig` Calls: @@ -147,9 +146,9 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_int` - * :c:data:`n_det` * :c:data:`mo_num` + * :c:data:`n_det` + * :c:data:`n_int` Called by: @@ -185,9 +184,9 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_int` * :c:data:`elec_alpha_num` * :c:data:`mo_num` + * :c:data:`n_int` Called by: @@ -221,9 +220,9 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_int` - * :c:data:`n_det` * :c:data:`mo_num` + * :c:data:`n_det` + * :c:data:`n_int` Called by: @@ -259,9 +258,9 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_int` * :c:data:`elec_alpha_num` * :c:data:`mo_num` + * :c:data:`n_int` Called by: @@ -297,20 +296,19 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_coef` - * :c:data:`n_states` * :c:data:`generators_bitmask` + * :c:data:`h_apply_buffer_allocated` * :c:data:`mo_num` * :c:data:`mo_two_e_integrals_in_map` - * :c:data:`h_apply_buffer_allocated` * :c:data:`n_det` - * :c:data:`s2_eig` * :c:data:`n_det_generators` - * :c:data:`i_bitmask_gen` * :c:data:`n_int` + * :c:data:`n_states` + * :c:data:`psi_coef` + * :c:data:`psi_det_generators` * :c:data:`psi_det` * :c:data:`psi_det_generators` - * :c:data:`psi_det_generators` + * :c:data:`s2_eig` Calls: @@ -357,9 +355,9 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_int` - * :c:data:`n_det` * :c:data:`mo_num` + * :c:data:`n_det` + * :c:data:`n_int` Called by: @@ -395,9 +393,9 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_int` * :c:data:`elec_alpha_num` * :c:data:`mo_num` + * :c:data:`n_int` Called by: @@ -432,9 +430,9 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_int` - * :c:data:`n_det` * :c:data:`mo_num` + * :c:data:`n_det` + * :c:data:`n_int` Called by: @@ -470,9 +468,9 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_int` * :c:data:`elec_alpha_num` * :c:data:`mo_num` + * :c:data:`n_int` Called by: diff --git a/docs/source/modules/cisd.rst b/docs/source/modules/cisd.rst index 94c6408f..b488f3ac 100644 --- a/docs/source/modules/cisd.rst +++ b/docs/source/modules/cisd.rst @@ -80,20 +80,26 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_coef` - * :c:data:`n_states` * :c:data:`generators_bitmask` + * :c:data:`h_apply_buffer_allocated` * :c:data:`mo_num` * :c:data:`mo_two_e_integrals_in_map` - * :c:data:`h_apply_buffer_allocated` * :c:data:`n_det` - * :c:data:`s2_eig` * :c:data:`n_det_generators` - * :c:data:`i_bitmask_gen` * :c:data:`n_int` + * :c:data:`n_states` + * :c:data:`psi_coef` + * :c:data:`psi_det_generators` * :c:data:`psi_det` * :c:data:`psi_det_generators` - * :c:data:`psi_det_generators` + * :c:data:`s2_eig` + + Called by: + + .. hlist:: + :columns: 3 + + * :c:func:`run_cisd` Calls: @@ -140,9 +146,9 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_int` - * :c:data:`n_det` * :c:data:`mo_num` + * :c:data:`n_det` + * :c:data:`n_int` Called by: @@ -178,9 +184,9 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_int` * :c:data:`elec_alpha_num` * :c:data:`mo_num` + * :c:data:`n_int` Called by: @@ -214,9 +220,9 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_int` - * :c:data:`n_det` * :c:data:`mo_num` + * :c:data:`n_det` + * :c:data:`n_int` Called by: @@ -252,9 +258,9 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_int` * :c:data:`elec_alpha_num` * :c:data:`mo_num` + * :c:data:`n_int` Called by: @@ -290,20 +296,26 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_coef` - * :c:data:`n_states` * :c:data:`generators_bitmask` + * :c:data:`h_apply_buffer_allocated` * :c:data:`mo_num` * :c:data:`mo_two_e_integrals_in_map` - * :c:data:`h_apply_buffer_allocated` * :c:data:`n_det` - * :c:data:`s2_eig` * :c:data:`n_det_generators` - * :c:data:`i_bitmask_gen` * :c:data:`n_int` + * :c:data:`n_states` + * :c:data:`psi_coef` + * :c:data:`psi_det_generators` * :c:data:`psi_det` * :c:data:`psi_det_generators` - * :c:data:`psi_det_generators` + * :c:data:`s2_eig` + + Called by: + + .. hlist:: + :columns: 3 + + * :c:func:`run_cisd` Calls: @@ -350,9 +362,9 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_int` - * :c:data:`n_det` * :c:data:`mo_num` + * :c:data:`n_det` + * :c:data:`n_int` Called by: @@ -388,9 +400,9 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_int` * :c:data:`elec_alpha_num` * :c:data:`mo_num` + * :c:data:`n_int` Called by: @@ -425,9 +437,9 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_int` - * :c:data:`n_det` * :c:data:`mo_num` + * :c:data:`n_det` + * :c:data:`n_int` Called by: @@ -463,9 +475,9 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_int` * :c:data:`elec_alpha_num` * :c:data:`mo_num` + * :c:data:`n_int` Called by: @@ -483,3 +495,52 @@ Subroutines / functions * :c:func:`connected_to_hf` * :c:func:`fill_h_apply_buffer_no_selection` + +.. c:function:: run_cisd: + + + File : :file:`cisd_routine.irp.f` + + .. code:: fortran + + subroutine run_cisd + + + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`ci_electronic_energy` + * :c:data:`ci_energy` + * :c:data:`n_det` + * :c:data:`n_states` + * :c:data:`pseudo_sym` + * :c:data:`psi_coef` + + Calls: + + .. hlist:: + :columns: 3 + + * :c:func:`ezfio_set_cisd_energy` + * :c:func:`h_apply_cisd` + * :c:func:`h_apply_cisd_sym` + * :c:func:`save_wavefunction` + + Touches: + + .. hlist:: + :columns: 3 + + * :c:data:`n_det` + * :c:data:`psi_occ_pattern` + * :c:data:`c0_weight` + * :c:data:`psi_coef` + * :c:data:`psi_det_sorted_bit` + * :c:data:`psi_det` + * :c:data:`psi_det_size` + * :c:data:`psi_det_sorted_bit` + * :c:data:`psi_occ_pattern` + diff --git a/docs/source/modules/davidson.rst b/docs/source/modules/davidson.rst index ae06e247..718458bd 100644 --- a/docs/source/modules/davidson.rst +++ b/docs/source/modules/davidson.rst @@ -117,7 +117,6 @@ Providers * :c:data:`psi_det` * :c:data:`s2_eig` * :c:data:`s2_matrix_all_dets` - * :c:data:`s_z` * :c:data:`threshold_davidson` Needed by: @@ -162,7 +161,6 @@ Providers * :c:data:`psi_det` * :c:data:`s2_eig` * :c:data:`s2_matrix_all_dets` - * :c:data:`s_z` * :c:data:`threshold_davidson` Needed by: @@ -234,7 +232,6 @@ Providers * :c:data:`psi_det` * :c:data:`s2_eig` * :c:data:`s2_matrix_all_dets` - * :c:data:`s_z` * :c:data:`threshold_davidson` Needed by: @@ -245,20 +242,6 @@ Providers * :c:data:`ci_energy` -.. c:var:: davidson_criterion - - - File : :file:`davidson/parameters.irp.f` - - .. code:: fortran - - character(64) :: davidson_criterion - - - Can be : [ energy | residual | both | wall_time | cpu_time | iterations ] - - - .. c:var:: diag_algorithm @@ -382,9 +365,9 @@ Providers double precision, allocatable :: psi_s2 (N_states) - psi_energy(i) = :math:`\langle \Psi_i | H | \Psi_i \rangle` + psi_energy(i) = :math:`\langle \Psi_i | H | \Psi_i \rangle` - psi_s2(i) = :math:`\langle \Psi_i | S^2 | \Psi_i \rangle` + psi_s2(i) = :math:`\langle \Psi_i | S^2 | \Psi_i \rangle` Needs: @@ -408,9 +391,7 @@ Providers .. hlist:: :columns: 3 - * :c:data:`psi_energy_two_e` * :c:data:`psi_energy_with_nucl_rep` - * :c:data:`pt2_e0_denominator` .. c:var:: psi_energy_two_e @@ -436,7 +417,6 @@ Providers * :c:data:`psi_coef` * :c:data:`psi_det` * :c:data:`psi_det_size` - * :c:data:`psi_energy` @@ -474,9 +454,9 @@ Providers double precision, allocatable :: psi_s2 (N_states) - psi_energy(i) = :math:`\langle \Psi_i | H | \Psi_i \rangle` + psi_energy(i) = :math:`\langle \Psi_i | H | \Psi_i \rangle` - psi_s2(i) = :math:`\langle \Psi_i | S^2 | \Psi_i \rangle` + psi_s2(i) = :math:`\langle \Psi_i | S^2 | \Psi_i \rangle` Needs: @@ -500,9 +480,28 @@ Providers .. hlist:: :columns: 3 - * :c:data:`psi_energy_two_e` * :c:data:`psi_energy_with_nucl_rep` - * :c:data:`pt2_e0_denominator` + + +.. c:var:: threshold_davidson_pt2 + + + File : :file:`davidson/diagonalization_hs2_dressed.irp.f` + + .. code:: fortran + + double precision :: threshold_davidson_pt2 + + + Threshold of Davidson's algorithm, using PT2 as a guide + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`threshold_davidson` + @@ -543,42 +542,6 @@ Subroutines / functions * :c:func:`davidson_pull_results` -.. c:function:: davidson_converged: - - - File : :file:`davidson/parameters.irp.f` - - .. code:: fortran - - subroutine davidson_converged(energy,residual,wall,iterations,cpu,N_st,converged) - - - True if the Davidson algorithm is converged - - Needs: - - .. hlist:: - :columns: 3 - - * :c:data:`threshold_davidson` - * :c:data:`davidson_criterion` - - Called by: - - .. hlist:: - :columns: 3 - - * :c:func:`davidson_diag_hjj_sjj` - - Calls: - - .. hlist:: - :columns: 3 - - * :c:func:`cpu_time` - * :c:func:`wall_time` - - .. c:function:: davidson_diag_hjj_sjj: @@ -615,28 +578,30 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_bilinear_matrix_order_reverse` - * :c:data:`psi_bilinear_matrix_values` - * :c:data:`nthreads_davidson` - * :c:data:`psi_coef` - * :c:data:`dressed_column_idx` - * :c:data:`expected_s2` - * :c:data:`s_z` - * :c:data:`n_det` - * :c:data:`dressing_column_h` - * :c:data:`ezfio_work_dir` * :c:data:`davidson_sze_max` - * :c:data:`state_following` - * :c:data:`psi_det_alpha_unique` - * :c:data:`nuclear_repulsion` - * :c:data:`nproc` - * :c:data:`qp_max_mem` * :c:data:`disk_based_davidson` - * :c:data:`s2_eig` - * :c:data:`psi_det_beta_unique` - * :c:data:`only_expected_s2` * :c:data:`distributed_davidson` + * :c:data:`dressed_column_idx` + * :c:data:`dressing_column_h` + * :c:data:`expected_s2` + * :c:data:`ezfio_work_dir` + * :c:data:`n_det` * :c:data:`n_int` + * :c:data:`nproc` + * :c:data:`nthreads_davidson` + * :c:data:`nuclear_repulsion` + * :c:data:`only_expected_s2` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_bilinear_matrix_order_reverse` + * :c:data:`psi_coef` + * :c:data:`psi_det_alpha_unique` + * :c:data:`psi_det_beta_unique` + * :c:data:`qp_max_mem` + * :c:data:`s2_eig` + * :c:data:`state_following` + * :c:data:`threshold_davidson` + * :c:data:`threshold_davidson_from_pt2` + * :c:data:`threshold_davidson_pt2` Called by: @@ -652,8 +617,6 @@ Subroutines / functions * :c:func:`c_f_pointer` * :c:func:`check_mem` - * :c:func:`cpu_time` - * :c:func:`davidson_converged` * :c:func:`dgemm` * :c:func:`dswap` * :c:func:`h_s2_u_0_nstates_openmp` @@ -662,11 +625,12 @@ Subroutines / functions * :c:func:`mmap` * :c:func:`munmap` * :c:func:`normalize` + * :c:func:`nullify_small_elements` * :c:func:`ortho_qr` + * :c:func:`ortho_qr_unblocked` * :c:func:`random_number` * :c:func:`resident_memory` * :c:func:`sgemm` - * :c:func:`wall_time` * :c:func:`write_double` * :c:func:`write_int` * :c:func:`write_time` @@ -711,6 +675,7 @@ Subroutines / functions * :c:data:`dressing_column_h` * :c:data:`mo_two_e_integrals_in_map` + * :c:data:`n_int` Called by: @@ -751,8 +716,8 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_states_diag` * :c:data:`n_det` + * :c:data:`n_states_diag` Called by: @@ -779,8 +744,8 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_states_diag` * :c:data:`n_det` + * :c:data:`n_states_diag` .. c:function:: davidson_push_results_async_recv: @@ -820,8 +785,8 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_states_diag` * :c:data:`n_det` + * :c:data:`n_states_diag` Called by: @@ -848,8 +813,8 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_states_diag` * :c:data:`n_det` + * :c:data:`n_states_diag` Called by: @@ -907,13 +872,6 @@ Subroutines / functions - Called by: - - .. hlist:: - :columns: 3 - - * :c:func:`run_slave_main` - Calls: .. hlist:: @@ -938,18 +896,18 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_det_beta_unique` - * :c:data:`mpi_rank` - * :c:data:`psi_bilinear_matrix_order_transp_reverse` - * :c:data:`psi_det_alpha_unique` * :c:data:`mpi_initialized` + * :c:data:`mpi_rank` * :c:data:`n_det` + * :c:data:`n_states_diag` + * :c:data:`nproc` + * :c:data:`psi_bilinear_matrix_columns_loc` + * :c:data:`psi_bilinear_matrix_order_transp_reverse` * :c:data:`psi_bilinear_matrix_transp_values` * :c:data:`psi_bilinear_matrix_values` - * :c:data:`nproc` + * :c:data:`psi_det_alpha_unique` + * :c:data:`psi_det_beta_unique` * :c:data:`ref_bitmask_energy` - * :c:data:`n_states_diag` - * :c:data:`psi_bilinear_matrix_columns_loc` Called by: @@ -986,24 +944,15 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_coef` * :c:data:`ci_electronic_energy` - * :c:data:`n_states` - * :c:data:`n_det` * :c:data:`ci_electronic_energy` - * :c:data:`psi_energy` * :c:data:`ci_energy` * :c:data:`ci_electronic_energy` + * :c:data:`n_det` + * :c:data:`n_states` + * :c:data:`psi_coef` + * :c:data:`psi_energy` * :c:data:`psi_energy` - - Called by: - - .. hlist:: - :columns: 3 - - * :c:func:`remove_small_contributions` - * :c:func:`run_cipsi` - * :c:func:`run_stochastic_cipsi` Touches: @@ -1040,9 +989,9 @@ Subroutines / functions .. hlist:: :columns: 3 + * :c:data:`n_det` * :c:data:`psi_bilinear_matrix_order_reverse` * :c:data:`psi_bilinear_matrix_values` - * :c:data:`n_det` Called by: @@ -1081,9 +1030,9 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`ref_bitmask_energy` * :c:data:`n_det` * :c:data:`n_int` + * :c:data:`ref_bitmask_energy` Called by: @@ -1108,7 +1057,7 @@ Subroutines / functions .. c:function:: h_s2_u_0_nstates_openmp_work_1: - File : :file:`davidson/u0_h_u0.irp.f_template_645` + File : :file:`davidson/u0_h_u0.irp.f_template_708` .. code:: fortran @@ -1124,18 +1073,18 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_det_beta_unique` - * :c:data:`psi_bilinear_matrix_order_transp_reverse` - * :c:data:`psi_det_alpha_unique` - * :c:data:`psi_bilinear_matrix_transp_rows_loc` - * :c:data:`singles_beta_csc` * :c:data:`n_det` - * :c:data:`psi_bilinear_matrix_transp_values` - * :c:data:`nthreads_davidson` - * :c:data:`psi_bilinear_matrix_values` * :c:data:`n_int` - * :c:data:`singles_beta_csc_idx` + * :c:data:`nthreads_davidson` * :c:data:`psi_bilinear_matrix_columns_loc` + * :c:data:`psi_bilinear_matrix_order_transp_reverse` + * :c:data:`psi_bilinear_matrix_transp_rows_loc` + * :c:data:`psi_bilinear_matrix_transp_values` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_det_alpha_unique` + * :c:data:`psi_det_beta_unique` + * :c:data:`singles_beta_csc` + * :c:data:`singles_beta_csc_idx` Called by: @@ -1160,7 +1109,7 @@ Subroutines / functions .. c:function:: h_s2_u_0_nstates_openmp_work_2: - File : :file:`davidson/u0_h_u0.irp.f_template_645` + File : :file:`davidson/u0_h_u0.irp.f_template_708` .. code:: fortran @@ -1176,18 +1125,18 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_det_beta_unique` - * :c:data:`psi_bilinear_matrix_order_transp_reverse` - * :c:data:`psi_det_alpha_unique` - * :c:data:`psi_bilinear_matrix_transp_rows_loc` - * :c:data:`singles_beta_csc` * :c:data:`n_det` - * :c:data:`psi_bilinear_matrix_transp_values` - * :c:data:`nthreads_davidson` - * :c:data:`psi_bilinear_matrix_values` * :c:data:`n_int` - * :c:data:`singles_beta_csc_idx` + * :c:data:`nthreads_davidson` * :c:data:`psi_bilinear_matrix_columns_loc` + * :c:data:`psi_bilinear_matrix_order_transp_reverse` + * :c:data:`psi_bilinear_matrix_transp_rows_loc` + * :c:data:`psi_bilinear_matrix_transp_values` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_det_alpha_unique` + * :c:data:`psi_det_beta_unique` + * :c:data:`singles_beta_csc` + * :c:data:`singles_beta_csc_idx` Called by: @@ -1212,7 +1161,7 @@ Subroutines / functions .. c:function:: h_s2_u_0_nstates_openmp_work_3: - File : :file:`davidson/u0_h_u0.irp.f_template_645` + File : :file:`davidson/u0_h_u0.irp.f_template_708` .. code:: fortran @@ -1228,18 +1177,18 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_det_beta_unique` - * :c:data:`psi_bilinear_matrix_order_transp_reverse` - * :c:data:`psi_det_alpha_unique` - * :c:data:`psi_bilinear_matrix_transp_rows_loc` - * :c:data:`singles_beta_csc` * :c:data:`n_det` - * :c:data:`psi_bilinear_matrix_transp_values` - * :c:data:`nthreads_davidson` - * :c:data:`psi_bilinear_matrix_values` * :c:data:`n_int` - * :c:data:`singles_beta_csc_idx` + * :c:data:`nthreads_davidson` * :c:data:`psi_bilinear_matrix_columns_loc` + * :c:data:`psi_bilinear_matrix_order_transp_reverse` + * :c:data:`psi_bilinear_matrix_transp_rows_loc` + * :c:data:`psi_bilinear_matrix_transp_values` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_det_alpha_unique` + * :c:data:`psi_det_beta_unique` + * :c:data:`singles_beta_csc` + * :c:data:`singles_beta_csc_idx` Called by: @@ -1264,7 +1213,7 @@ Subroutines / functions .. c:function:: h_s2_u_0_nstates_openmp_work_4: - File : :file:`davidson/u0_h_u0.irp.f_template_645` + File : :file:`davidson/u0_h_u0.irp.f_template_708` .. code:: fortran @@ -1280,18 +1229,18 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_det_beta_unique` - * :c:data:`psi_bilinear_matrix_order_transp_reverse` - * :c:data:`psi_det_alpha_unique` - * :c:data:`psi_bilinear_matrix_transp_rows_loc` - * :c:data:`singles_beta_csc` * :c:data:`n_det` - * :c:data:`psi_bilinear_matrix_transp_values` - * :c:data:`nthreads_davidson` - * :c:data:`psi_bilinear_matrix_values` * :c:data:`n_int` - * :c:data:`singles_beta_csc_idx` + * :c:data:`nthreads_davidson` * :c:data:`psi_bilinear_matrix_columns_loc` + * :c:data:`psi_bilinear_matrix_order_transp_reverse` + * :c:data:`psi_bilinear_matrix_transp_rows_loc` + * :c:data:`psi_bilinear_matrix_transp_values` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_det_alpha_unique` + * :c:data:`psi_det_beta_unique` + * :c:data:`singles_beta_csc` + * :c:data:`singles_beta_csc_idx` Called by: @@ -1316,7 +1265,7 @@ Subroutines / functions .. c:function:: h_s2_u_0_nstates_openmp_work_n_int: - File : :file:`davidson/u0_h_u0.irp.f_template_645` + File : :file:`davidson/u0_h_u0.irp.f_template_708` .. code:: fortran @@ -1332,18 +1281,18 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_det_beta_unique` - * :c:data:`psi_bilinear_matrix_order_transp_reverse` - * :c:data:`psi_det_alpha_unique` - * :c:data:`psi_bilinear_matrix_transp_rows_loc` - * :c:data:`singles_beta_csc` * :c:data:`n_det` - * :c:data:`psi_bilinear_matrix_transp_values` - * :c:data:`nthreads_davidson` - * :c:data:`psi_bilinear_matrix_values` * :c:data:`n_int` - * :c:data:`singles_beta_csc_idx` + * :c:data:`nthreads_davidson` * :c:data:`psi_bilinear_matrix_columns_loc` + * :c:data:`psi_bilinear_matrix_order_transp_reverse` + * :c:data:`psi_bilinear_matrix_transp_rows_loc` + * :c:data:`psi_bilinear_matrix_transp_values` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_det_alpha_unique` + * :c:data:`psi_det_beta_unique` + * :c:data:`singles_beta_csc` + * :c:data:`singles_beta_csc_idx` Called by: @@ -1388,17 +1337,18 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_det_beta_unique` - * :c:data:`psi_bilinear_matrix_order_transp_reverse` - * :c:data:`psi_det_alpha_unique` - * :c:data:`psi_bilinear_matrix_order_reverse` * :c:data:`mpi_initialized` * :c:data:`n_det` + * :c:data:`n_states_diag` + * :c:data:`nproc` + * :c:data:`psi_bilinear_matrix_columns_loc` + * :c:data:`psi_bilinear_matrix_order_reverse` + * :c:data:`psi_bilinear_matrix_order_transp_reverse` * :c:data:`psi_bilinear_matrix_transp_values` * :c:data:`psi_bilinear_matrix_values` - * :c:data:`nproc` + * :c:data:`psi_det_alpha_unique` + * :c:data:`psi_det_beta_unique` * :c:data:`ref_bitmask_energy` - * :c:data:`psi_bilinear_matrix_columns_loc` Called by: @@ -1443,9 +1393,9 @@ Subroutines / functions .. hlist:: :columns: 3 + * :c:data:`n_det` * :c:data:`psi_bilinear_matrix_order_reverse` * :c:data:`psi_bilinear_matrix_values` - * :c:data:`n_det` Called by: @@ -1483,9 +1433,9 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`ref_bitmask_energy` * :c:data:`n_det` * :c:data:`n_int` + * :c:data:`ref_bitmask_energy` Called by: @@ -1525,16 +1475,16 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_det_beta_unique` - * :c:data:`psi_bilinear_matrix_order_transp_reverse` - * :c:data:`psi_det_alpha_unique` - * :c:data:`psi_bilinear_matrix_transp_rows_loc` * :c:data:`n_det` - * :c:data:`psi_bilinear_matrix_transp_values` - * :c:data:`nthreads_davidson` - * :c:data:`psi_bilinear_matrix_values` * :c:data:`n_int` + * :c:data:`nthreads_davidson` * :c:data:`psi_bilinear_matrix_columns_loc` + * :c:data:`psi_bilinear_matrix_order_transp_reverse` + * :c:data:`psi_bilinear_matrix_transp_rows_loc` + * :c:data:`psi_bilinear_matrix_transp_values` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_det_alpha_unique` + * :c:data:`psi_det_beta_unique` Called by: @@ -1575,16 +1525,16 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_det_beta_unique` - * :c:data:`psi_bilinear_matrix_order_transp_reverse` - * :c:data:`psi_det_alpha_unique` - * :c:data:`psi_bilinear_matrix_transp_rows_loc` * :c:data:`n_det` - * :c:data:`psi_bilinear_matrix_transp_values` - * :c:data:`nthreads_davidson` - * :c:data:`psi_bilinear_matrix_values` * :c:data:`n_int` + * :c:data:`nthreads_davidson` * :c:data:`psi_bilinear_matrix_columns_loc` + * :c:data:`psi_bilinear_matrix_order_transp_reverse` + * :c:data:`psi_bilinear_matrix_transp_rows_loc` + * :c:data:`psi_bilinear_matrix_transp_values` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_det_alpha_unique` + * :c:data:`psi_det_beta_unique` Called by: @@ -1625,16 +1575,16 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_det_beta_unique` - * :c:data:`psi_bilinear_matrix_order_transp_reverse` - * :c:data:`psi_det_alpha_unique` - * :c:data:`psi_bilinear_matrix_transp_rows_loc` * :c:data:`n_det` - * :c:data:`psi_bilinear_matrix_transp_values` - * :c:data:`nthreads_davidson` - * :c:data:`psi_bilinear_matrix_values` * :c:data:`n_int` + * :c:data:`nthreads_davidson` * :c:data:`psi_bilinear_matrix_columns_loc` + * :c:data:`psi_bilinear_matrix_order_transp_reverse` + * :c:data:`psi_bilinear_matrix_transp_rows_loc` + * :c:data:`psi_bilinear_matrix_transp_values` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_det_alpha_unique` + * :c:data:`psi_det_beta_unique` Called by: @@ -1675,16 +1625,16 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_det_beta_unique` - * :c:data:`psi_bilinear_matrix_order_transp_reverse` - * :c:data:`psi_det_alpha_unique` - * :c:data:`psi_bilinear_matrix_transp_rows_loc` * :c:data:`n_det` - * :c:data:`psi_bilinear_matrix_transp_values` - * :c:data:`nthreads_davidson` - * :c:data:`psi_bilinear_matrix_values` * :c:data:`n_int` + * :c:data:`nthreads_davidson` * :c:data:`psi_bilinear_matrix_columns_loc` + * :c:data:`psi_bilinear_matrix_order_transp_reverse` + * :c:data:`psi_bilinear_matrix_transp_rows_loc` + * :c:data:`psi_bilinear_matrix_transp_values` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_det_alpha_unique` + * :c:data:`psi_det_beta_unique` Called by: @@ -1725,16 +1675,16 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_det_beta_unique` - * :c:data:`psi_bilinear_matrix_order_transp_reverse` - * :c:data:`psi_det_alpha_unique` - * :c:data:`psi_bilinear_matrix_transp_rows_loc` * :c:data:`n_det` - * :c:data:`psi_bilinear_matrix_transp_values` - * :c:data:`nthreads_davidson` - * :c:data:`psi_bilinear_matrix_values` * :c:data:`n_int` + * :c:data:`nthreads_davidson` * :c:data:`psi_bilinear_matrix_columns_loc` + * :c:data:`psi_bilinear_matrix_order_transp_reverse` + * :c:data:`psi_bilinear_matrix_transp_rows_loc` + * :c:data:`psi_bilinear_matrix_transp_values` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_det_alpha_unique` + * :c:data:`psi_det_beta_unique` Called by: @@ -1774,20 +1724,13 @@ Subroutines / functions :columns: 3 * :c:data:`mo_integrals_n_e` - * :c:data:`n_states` - * :c:data:`mo_pseudo_integrals` * :c:data:`mo_kinetic_integrals` * :c:data:`mo_num` + * :c:data:`mo_pseudo_integrals` + * :c:data:`n_states` * :c:data:`nuclear_repulsion` - * :c:data:`psi_energy` * :c:data:`one_e_dm_mo_alpha` - - Called by: - - .. hlist:: - :columns: 3 - - * :c:func:`print_summary` + * :c:data:`psi_energy` .. c:function:: u_0_h_u_0: @@ -1812,11 +1755,11 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`h_matrix_all_dets` - * :c:data:`s2_matrix_all_dets` - * :c:data:`n_states_diag` * :c:data:`distributed_davidson` + * :c:data:`h_matrix_all_dets` * :c:data:`n_det_max_full` + * :c:data:`n_states_diag` + * :c:data:`s2_matrix_all_dets` Called by: @@ -1881,9 +1824,9 @@ Subroutines / functions .. hlist:: :columns: 3 + * :c:data:`mpi_master` * :c:data:`n_states_diag` * :c:data:`zmq_state` - * :c:data:`mpi_master` Touches: diff --git a/docs/source/modules/density_for_dft.rst b/docs/source/modules/density_for_dft.rst index bf293eba..3520c86a 100644 --- a/docs/source/modules/density_for_dft.rst +++ b/docs/source/modules/density_for_dft.rst @@ -146,14 +146,6 @@ Providers * :c:data:`one_e_dm_mo_alpha_for_dft` * :c:data:`one_e_dm_mo_beta_for_dft` - Needed by: - - .. hlist:: - :columns: 3 - - * :c:data:`one_e_dm_alpha_at_r` - * :c:data:`one_e_dm_alpha_in_r` - * :c:data:`one_e_dm_and_grad_alpha_in_r` .. c:var:: one_e_dm_alpha_ao_for_dft_no_core @@ -181,12 +173,64 @@ Providers * :c:data:`one_e_dm_mo_alpha_for_dft_no_core` * :c:data:`one_e_dm_mo_beta_for_dft_no_core` + + +.. c:var:: one_e_dm_average_alpha_mo_for_dft + + + File : :file:`density_for_dft/density_for_dft.irp.f` + + .. code:: fortran + + double precision, allocatable :: one_e_dm_average_alpha_mo_for_dft (mo_num,mo_num) + + + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`mo_num` + * :c:data:`n_states` + * :c:data:`one_e_dm_mo_alpha_for_dft` + * :c:data:`state_average_weight` + Needed by: .. hlist:: :columns: 3 - * :c:data:`one_e_dm_no_core_and_grad_alpha_in_r` + * :c:data:`one_e_dm_average_mo_for_dft` + + +.. c:var:: one_e_dm_average_beta_mo_for_dft + + + File : :file:`density_for_dft/density_for_dft.irp.f` + + .. code:: fortran + + double precision, allocatable :: one_e_dm_average_beta_mo_for_dft (mo_num,mo_num) + + + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`mo_num` + * :c:data:`n_states` + * :c:data:`one_e_dm_mo_beta_for_dft` + * :c:data:`state_average_weight` + + Needed by: + + .. hlist:: + :columns: 3 + + * :c:data:`one_e_dm_average_mo_for_dft` .. c:var:: one_e_dm_average_mo_for_dft @@ -206,16 +250,9 @@ Providers :columns: 3 * :c:data:`mo_num` - * :c:data:`n_states` - * :c:data:`one_e_dm_mo_for_dft` - * :c:data:`state_average_weight` + * :c:data:`one_e_dm_average_alpha_mo_for_dft` + * :c:data:`one_e_dm_average_beta_mo_for_dft` - Needed by: - - .. hlist:: - :columns: 3 - - * :c:data:`short_range_hartree_operator` .. c:var:: one_e_dm_beta_ao_for_dft @@ -246,14 +283,6 @@ Providers * :c:data:`one_e_dm_mo_alpha_for_dft` * :c:data:`one_e_dm_mo_beta_for_dft` - Needed by: - - .. hlist:: - :columns: 3 - - * :c:data:`one_e_dm_alpha_at_r` - * :c:data:`one_e_dm_alpha_in_r` - * :c:data:`one_e_dm_and_grad_alpha_in_r` .. c:var:: one_e_dm_beta_ao_for_dft_no_core @@ -281,12 +310,6 @@ Providers * :c:data:`one_e_dm_mo_alpha_for_dft_no_core` * :c:data:`one_e_dm_mo_beta_for_dft_no_core` - Needed by: - - .. hlist:: - :columns: 3 - - * :c:data:`one_e_dm_no_core_and_grad_alpha_in_r` .. c:var:: one_e_dm_mo_alpha_for_dft @@ -311,7 +334,7 @@ Providers * :c:data:`data_one_e_dm_alpha_mo` * :c:data:`density_for_dft` * :c:data:`elec_alpha_num` - * :c:data:`list_inact` + * :c:data:`list_core` * :c:data:`mo_coef` * :c:data:`mo_num` * :c:data:`n_core_orb` @@ -328,11 +351,9 @@ Providers :columns: 3 * :c:data:`one_e_dm_alpha_ao_for_dft` + * :c:data:`one_e_dm_average_alpha_mo_for_dft` * :c:data:`one_e_dm_mo_alpha_for_dft_no_core` * :c:data:`one_e_dm_mo_for_dft` - * :c:data:`psi_dft_energy_kinetic` - * :c:data:`trace_v_xc` - * :c:data:`trace_v_xc_new` .. c:var:: one_e_dm_mo_alpha_for_dft_no_core @@ -352,7 +373,7 @@ Providers .. hlist:: :columns: 3 - * :c:data:`list_inact` + * :c:data:`list_core` * :c:data:`mo_num` * :c:data:`n_core_orb` * :c:data:`n_states` @@ -388,7 +409,7 @@ Providers * :c:data:`data_one_e_dm_beta_mo` * :c:data:`density_for_dft` * :c:data:`elec_beta_num` - * :c:data:`list_inact` + * :c:data:`list_core` * :c:data:`mo_coef` * :c:data:`mo_num` * :c:data:`n_core_orb` @@ -405,11 +426,9 @@ Providers :columns: 3 * :c:data:`one_e_dm_alpha_ao_for_dft` + * :c:data:`one_e_dm_average_beta_mo_for_dft` * :c:data:`one_e_dm_mo_beta_for_dft_no_core` * :c:data:`one_e_dm_mo_for_dft` - * :c:data:`psi_dft_energy_kinetic` - * :c:data:`trace_v_xc` - * :c:data:`trace_v_xc_new` .. c:var:: one_e_dm_mo_beta_for_dft_no_core @@ -429,7 +448,7 @@ Providers .. hlist:: :columns: 3 - * :c:data:`list_inact` + * :c:data:`list_core` * :c:data:`mo_num` * :c:data:`n_core_orb` * :c:data:`n_states` @@ -464,11 +483,4 @@ Providers * :c:data:`one_e_dm_mo_alpha_for_dft` * :c:data:`one_e_dm_mo_beta_for_dft` - Needed by: - - .. hlist:: - :columns: 3 - - * :c:data:`one_e_dm_average_mo_for_dft` - * :c:data:`short_range_hartree_operator` diff --git a/docs/source/modules/determinants.rst b/docs/source/modules/determinants.rst index bc0f7434..cd548bd8 100644 --- a/docs/source/modules/determinants.rst +++ b/docs/source/modules/determinants.rst @@ -55,6 +55,12 @@ EZFIO parameters Default: False +.. option:: pruning + + If p>0., remove p*Ndet determinants at every iteration + + Default: 0. + .. option:: s2_eig Force the wave function to be an eigenfunction of |S^2| @@ -65,11 +71,11 @@ EZFIO parameters Weight used in the calculation of the one-electron density matrix. 0: 1./(c_0^2), 1: 1/N_states, 2: input state-average weight, 3: 1/(Norm_L3(Psi)) - Default: 1 + Default: 2 .. option:: weight_selection - Weight used in the selection. 0: input state-average weight, 1: 1./(c_0^2), 2: rPT2 matching, 3: variance matching, 4: variance and rPT2 matching, 5: variance minimization and matching + Weight used in the selection. 0: input state-average weight, 1: 1./(c_0^2), 2: rPT2 matching, 3: variance matching, 4: variance and rPT2 matching, 5: variance minimization and matching, 6: CI coefficients Default: 2 @@ -99,6 +105,11 @@ EZFIO parameters Number of determinants in the current wave function +.. option:: n_det_qp_edit + + Number of determinants to print in qp_edit + + .. option:: psi_coef Coefficients of the wave function @@ -109,6 +120,16 @@ EZFIO parameters Determinants of the variational space +.. option:: psi_coef_qp_edit + + Coefficients of the wave function + + +.. option:: psi_det_qp_edit + + Determinants of the variational space + + .. option:: expected_s2 Expected value of |S^2| @@ -221,12 +242,6 @@ Providers * :c:data:`n_states` * :c:data:`psi_coef` - Needed by: - - .. hlist:: - :columns: 3 - - * :c:data:`pt2_e0_denominator` .. c:var:: c0_weight @@ -254,7 +269,6 @@ Providers .. hlist:: :columns: 3 - * :c:data:`selection_weight` * :c:data:`state_average_weight` @@ -344,8 +358,10 @@ Providers .. hlist:: :columns: 3 + * :c:data:`pruned` * :c:data:`psi_occ_pattern_hii` * :c:data:`weight_occ_pattern` + * :c:data:`weight_occ_pattern_average` .. c:var:: diagonal_h_matrix_on_psi_det @@ -365,6 +381,8 @@ Providers .. hlist:: :columns: 3 + * :c:data:`elec_alpha_num` + * :c:data:`elec_beta_num` * :c:data:`elec_num` * :c:data:`n_det` * :c:data:`n_int` @@ -561,6 +579,8 @@ Providers * :c:data:`big_array_coulomb_integrals` * :c:data:`big_array_coulomb_integrals` + * :c:data:`elec_alpha_num` + * :c:data:`elec_beta_num` * :c:data:`mo_integrals_map` * :c:data:`mo_two_e_integrals_in_map` * :c:data:`n_det` @@ -594,6 +614,8 @@ Providers * :c:data:`big_array_coulomb_integrals` * :c:data:`big_array_coulomb_integrals` + * :c:data:`elec_alpha_num` + * :c:data:`elec_beta_num` * :c:data:`mo_integrals_map` * :c:data:`mo_two_e_integrals_in_map` * :c:data:`n_int` @@ -629,10 +651,9 @@ Providers .. hlist:: :columns: 3 - * :c:data:`cas_bitmask` + * :c:data:`act_bitmask` * :c:data:`hf_bitmask` * :c:data:`mpi_master` - * :c:data:`n_cas_bitmask` * :c:data:`n_det` * :c:data:`n_int` * :c:data:`n_states` @@ -744,6 +765,10 @@ Providers .. hlist:: :columns: 3 + * :c:data:`act_2_rdm_aa_mo` + * :c:data:`act_2_rdm_ab_mo` + * :c:data:`act_2_rdm_bb_mo` + * :c:data:`act_2_rdm_spin_trace_mo` * :c:data:`barycentric_electronic_energy` * :c:data:`ci_electronic_energy` * :c:data:`ci_energy` @@ -753,13 +778,12 @@ Providers * :c:data:`diagonal_h_matrix_on_psi_det` * :c:data:`dressed_column_idx` * :c:data:`dressing_column_h` - * :c:data:`extrapolated_energy` * :c:data:`h_apply_buffer_allocated` * :c:data:`h_matrix_all_dets` * :c:data:`max_degree_exc` - * :c:data:`n_det_generators` - * :c:data:`n_det_selectors` + * :c:data:`n_det_qp_edit` * :c:data:`one_e_dm_mo_alpha` + * :c:data:`pruned` * :c:data:`psi_average_norm_contrib` * :c:data:`psi_bilinear_matrix` * :c:data:`psi_bilinear_matrix_columns_loc` @@ -775,7 +799,6 @@ Providers * :c:data:`psi_det_alpha_unique` * :c:data:`psi_det_beta` * :c:data:`psi_det_beta_unique` - * :c:data:`psi_det_generators` * :c:data:`psi_det_hii` * :c:data:`psi_det_sorted` * :c:data:`psi_det_sorted_bit` @@ -786,7 +809,12 @@ Providers * :c:data:`psi_occ_pattern_hii` * :c:data:`s2_matrix_all_dets` * :c:data:`s2_values` + * :c:data:`state_av_act_2_rdm_aa_mo` + * :c:data:`state_av_act_2_rdm_ab_mo` + * :c:data:`state_av_act_2_rdm_bb_mo` + * :c:data:`state_av_act_2_rdm_spin_trace_mo` * :c:data:`weight_occ_pattern` + * :c:data:`weight_occ_pattern_average` .. c:var:: n_det_alpha_unique @@ -822,6 +850,7 @@ Providers * :c:data:`one_e_dm_mo_alpha` * :c:data:`psi_bilinear_matrix` * :c:data:`psi_bilinear_matrix_transp_rows_loc` + * :c:data:`psi_bilinear_matrix_transp_values` * :c:data:`psi_bilinear_matrix_values` * :c:data:`singles_alpha_csc` * :c:data:`singles_alpha_csc_idx` @@ -887,10 +916,9 @@ Providers .. hlist:: :columns: 3 - * :c:data:`cas_bitmask` + * :c:data:`act_bitmask` * :c:data:`hf_bitmask` * :c:data:`mpi_master` - * :c:data:`n_cas_bitmask` * :c:data:`n_det` * :c:data:`n_int` * :c:data:`n_states` @@ -949,6 +977,27 @@ Providers * :c:data:`psi_non_cas_sorted_bit` +.. c:var:: n_det_qp_edit + + + File : :file:`determinants/determinants.irp.f` + + .. code:: fortran + + integer :: n_det_qp_edit + + + Number of determinants to print in qp_edit + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`n_det` + + + .. c:var:: n_double_exc_bitmasks @@ -1005,8 +1054,11 @@ Providers :columns: 3 * :c:data:`det_to_occ_pattern` + * :c:data:`pruned` * :c:data:`psi_occ_pattern_hii` + * :c:data:`psi_occ_pattern_sorted` * :c:data:`weight_occ_pattern` + * :c:data:`weight_occ_pattern_average` .. c:var:: n_single_exc_bitmasks @@ -1158,8 +1210,14 @@ Providers .. hlist:: :columns: 3 + * :c:data:`full_occ_2_rdm_aa_mo` + * :c:data:`full_occ_2_rdm_ab_mo` + * :c:data:`full_occ_2_rdm_bb_mo` + * :c:data:`full_occ_2_rdm_spin_trace_mo` * :c:data:`one_e_dm_dagger_mo_spin_index` * :c:data:`one_e_dm_mo_alpha_average` + * :c:data:`one_e_dm_mo_alpha_for_dft` + * :c:data:`one_e_dm_mo_beta_for_dft` * :c:data:`one_e_dm_mo_diff` * :c:data:`one_e_dm_mo_spin_index` * :c:data:`psi_energy_h_core` @@ -1195,7 +1253,13 @@ Providers * :c:data:`one_e_dm_ao_alpha` * :c:data:`one_e_dm_mo` + * :c:data:`one_e_dm_mo_alpha_for_dft` + * :c:data:`one_e_dm_mo_beta_for_dft` * :c:data:`one_e_spin_density_mo` + * :c:data:`state_av_full_occ_2_rdm_aa_mo` + * :c:data:`state_av_full_occ_2_rdm_ab_mo` + * :c:data:`state_av_full_occ_2_rdm_bb_mo` + * :c:data:`state_av_full_occ_2_rdm_spin_trace_mo` .. c:var:: one_e_dm_mo_beta @@ -1233,8 +1297,14 @@ Providers .. hlist:: :columns: 3 + * :c:data:`full_occ_2_rdm_aa_mo` + * :c:data:`full_occ_2_rdm_ab_mo` + * :c:data:`full_occ_2_rdm_bb_mo` + * :c:data:`full_occ_2_rdm_spin_trace_mo` * :c:data:`one_e_dm_dagger_mo_spin_index` * :c:data:`one_e_dm_mo_alpha_average` + * :c:data:`one_e_dm_mo_alpha_for_dft` + * :c:data:`one_e_dm_mo_beta_for_dft` * :c:data:`one_e_dm_mo_diff` * :c:data:`one_e_dm_mo_spin_index` * :c:data:`psi_energy_h_core` @@ -1270,7 +1340,13 @@ Providers * :c:data:`one_e_dm_ao_alpha` * :c:data:`one_e_dm_mo` + * :c:data:`one_e_dm_mo_alpha_for_dft` + * :c:data:`one_e_dm_mo_beta_for_dft` * :c:data:`one_e_spin_density_mo` + * :c:data:`state_av_full_occ_2_rdm_aa_mo` + * :c:data:`state_av_full_occ_2_rdm_ab_mo` + * :c:data:`state_av_full_occ_2_rdm_bb_mo` + * :c:data:`state_av_full_occ_2_rdm_spin_trace_mo` .. c:var:: one_e_dm_mo_diff @@ -1370,6 +1446,34 @@ Providers * :c:data:`one_e_spin_density_ao` +.. c:var:: pruned + + + File : :file:`determinants/prune_wf.irp.f` + + .. code:: fortran + + logical, allocatable :: pruned (N_det) + + + True if determinant is removed by pruning + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`det_to_occ_pattern` + * :c:data:`n_det` + * :c:data:`pruning` + * :c:data:`psi_average_norm_contrib` + * :c:data:`psi_det_sorted` + * :c:data:`psi_occ_pattern` + * :c:data:`psi_occ_pattern_sorted` + * :c:data:`s2_eig` + + + .. c:var:: psi_average_norm_contrib @@ -1398,6 +1502,7 @@ Providers .. hlist:: :columns: 3 + * :c:data:`pruned` * :c:data:`psi_det_sorted` @@ -1436,11 +1541,7 @@ Providers .. hlist:: :columns: 3 - * :c:data:`n_det_generators` - * :c:data:`n_det_selectors` - * :c:data:`psi_det_generators` - * :c:data:`psi_det_sorted_gen` - * :c:data:`psi_selectors` + * :c:data:`pruned` .. c:var:: psi_bilinear_matrix @@ -1509,12 +1610,20 @@ Providers .. hlist:: :columns: 3 + * :c:data:`act_2_rdm_aa_mo` + * :c:data:`act_2_rdm_ab_mo` + * :c:data:`act_2_rdm_bb_mo` + * :c:data:`act_2_rdm_spin_trace_mo` * :c:data:`det_alpha_norm` * :c:data:`one_e_dm_mo_alpha` * :c:data:`psi_bilinear_matrix` * :c:data:`psi_bilinear_matrix_columns_loc` * :c:data:`psi_bilinear_matrix_order_reverse` * :c:data:`psi_bilinear_matrix_transp_values` + * :c:data:`state_av_act_2_rdm_aa_mo` + * :c:data:`state_av_act_2_rdm_ab_mo` + * :c:data:`state_av_act_2_rdm_bb_mo` + * :c:data:`state_av_act_2_rdm_spin_trace_mo` .. c:var:: psi_bilinear_matrix_columns_loc @@ -1585,12 +1694,20 @@ Providers .. hlist:: :columns: 3 + * :c:data:`act_2_rdm_aa_mo` + * :c:data:`act_2_rdm_ab_mo` + * :c:data:`act_2_rdm_bb_mo` + * :c:data:`act_2_rdm_spin_trace_mo` * :c:data:`det_alpha_norm` * :c:data:`one_e_dm_mo_alpha` * :c:data:`psi_bilinear_matrix` * :c:data:`psi_bilinear_matrix_columns_loc` * :c:data:`psi_bilinear_matrix_order_reverse` * :c:data:`psi_bilinear_matrix_transp_values` + * :c:data:`state_av_act_2_rdm_aa_mo` + * :c:data:`state_av_act_2_rdm_ab_mo` + * :c:data:`state_av_act_2_rdm_bb_mo` + * :c:data:`state_av_act_2_rdm_spin_trace_mo` .. c:var:: psi_bilinear_matrix_order_reverse @@ -1613,6 +1730,19 @@ Providers * :c:data:`n_det` * :c:data:`psi_bilinear_matrix_values` + Needed by: + + .. hlist:: + :columns: 3 + + * :c:data:`act_2_rdm_aa_mo` + * :c:data:`act_2_rdm_ab_mo` + * :c:data:`act_2_rdm_bb_mo` + * :c:data:`act_2_rdm_spin_trace_mo` + * :c:data:`state_av_act_2_rdm_aa_mo` + * :c:data:`state_av_act_2_rdm_ab_mo` + * :c:data:`state_av_act_2_rdm_bb_mo` + * :c:data:`state_av_act_2_rdm_spin_trace_mo` .. c:var:: psi_bilinear_matrix_order_transp_reverse @@ -1677,12 +1807,20 @@ Providers .. hlist:: :columns: 3 + * :c:data:`act_2_rdm_aa_mo` + * :c:data:`act_2_rdm_ab_mo` + * :c:data:`act_2_rdm_bb_mo` + * :c:data:`act_2_rdm_spin_trace_mo` * :c:data:`det_alpha_norm` * :c:data:`one_e_dm_mo_alpha` * :c:data:`psi_bilinear_matrix` * :c:data:`psi_bilinear_matrix_columns_loc` * :c:data:`psi_bilinear_matrix_order_reverse` * :c:data:`psi_bilinear_matrix_transp_values` + * :c:data:`state_av_act_2_rdm_aa_mo` + * :c:data:`state_av_act_2_rdm_ab_mo` + * :c:data:`state_av_act_2_rdm_bb_mo` + * :c:data:`state_av_act_2_rdm_spin_trace_mo` .. c:var:: psi_bilinear_matrix_transp_columns @@ -1714,6 +1852,7 @@ Providers * :c:data:`n_states` * :c:data:`psi_bilinear_matrix_values` * :c:data:`psi_det_sorted_bit` + * :c:data:`psi_det_alpha_unique` * :c:data:`psi_det_beta_unique` Needed by: @@ -1755,6 +1894,7 @@ Providers * :c:data:`n_states` * :c:data:`psi_bilinear_matrix_values` * :c:data:`psi_det_sorted_bit` + * :c:data:`psi_det_alpha_unique` * :c:data:`psi_det_beta_unique` Needed by: @@ -1796,6 +1936,7 @@ Providers * :c:data:`n_states` * :c:data:`psi_bilinear_matrix_values` * :c:data:`psi_det_sorted_bit` + * :c:data:`psi_det_alpha_unique` * :c:data:`psi_det_beta_unique` Needed by: @@ -1860,6 +2001,7 @@ Providers * :c:data:`n_states` * :c:data:`psi_bilinear_matrix_values` * :c:data:`psi_det_sorted_bit` + * :c:data:`psi_det_alpha_unique` * :c:data:`psi_det_beta_unique` Needed by: @@ -1911,12 +2053,20 @@ Providers .. hlist:: :columns: 3 + * :c:data:`act_2_rdm_aa_mo` + * :c:data:`act_2_rdm_ab_mo` + * :c:data:`act_2_rdm_bb_mo` + * :c:data:`act_2_rdm_spin_trace_mo` * :c:data:`det_alpha_norm` * :c:data:`one_e_dm_mo_alpha` * :c:data:`psi_bilinear_matrix` * :c:data:`psi_bilinear_matrix_columns_loc` * :c:data:`psi_bilinear_matrix_order_reverse` * :c:data:`psi_bilinear_matrix_transp_values` + * :c:data:`state_av_act_2_rdm_aa_mo` + * :c:data:`state_av_act_2_rdm_ab_mo` + * :c:data:`state_av_act_2_rdm_bb_mo` + * :c:data:`state_av_act_2_rdm_spin_trace_mo` .. c:var:: psi_cas @@ -1940,10 +2090,9 @@ Providers .. hlist:: :columns: 3 - * :c:data:`cas_bitmask` + * :c:data:`act_bitmask` * :c:data:`hf_bitmask` * :c:data:`mpi_master` - * :c:data:`n_cas_bitmask` * :c:data:`n_det` * :c:data:`n_int` * :c:data:`n_states` @@ -1985,10 +2134,9 @@ Providers .. hlist:: :columns: 3 - * :c:data:`cas_bitmask` + * :c:data:`act_bitmask` * :c:data:`hf_bitmask` * :c:data:`mpi_master` - * :c:data:`n_cas_bitmask` * :c:data:`n_det` * :c:data:`n_int` * :c:data:`n_states` @@ -2138,6 +2286,10 @@ Providers .. hlist:: :columns: 3 + * :c:data:`act_2_rdm_aa_mo` + * :c:data:`act_2_rdm_ab_mo` + * :c:data:`act_2_rdm_bb_mo` + * :c:data:`act_2_rdm_spin_trace_mo` * :c:data:`barycentric_electronic_energy` * :c:data:`c0_weight` * :c:data:`ci_electronic_energy` @@ -2151,9 +2303,13 @@ Providers * :c:data:`psi_energy` * :c:data:`psi_energy_two_e` * :c:data:`psi_non_cas` - * :c:data:`pt2_e0_denominator` * :c:data:`s2_values` + * :c:data:`state_av_act_2_rdm_aa_mo` + * :c:data:`state_av_act_2_rdm_ab_mo` + * :c:data:`state_av_act_2_rdm_bb_mo` + * :c:data:`state_av_act_2_rdm_spin_trace_mo` * :c:data:`weight_occ_pattern` + * :c:data:`weight_occ_pattern_average` .. c:var:: psi_coef_cas_diagonalized @@ -2266,11 +2422,7 @@ Providers .. hlist:: :columns: 3 - * :c:data:`n_det_generators` - * :c:data:`n_det_selectors` - * :c:data:`psi_det_generators` - * :c:data:`psi_det_sorted_gen` - * :c:data:`psi_selectors` + * :c:data:`pruned` .. c:var:: psi_coef_sorted_bit @@ -2427,6 +2579,7 @@ Providers * :c:data:`one_e_dm_mo_alpha` * :c:data:`psi_bilinear_matrix` * :c:data:`psi_bilinear_matrix_transp_rows_loc` + * :c:data:`psi_bilinear_matrix_transp_values` * :c:data:`psi_bilinear_matrix_values` * :c:data:`singles_alpha_csc` * :c:data:`singles_alpha_csc_idx` @@ -2518,6 +2671,8 @@ Providers .. hlist:: :columns: 3 + * :c:data:`elec_alpha_num` + * :c:data:`elec_beta_num` * :c:data:`elec_num` * :c:data:`n_det` * :c:data:`n_int` @@ -2531,7 +2686,6 @@ Providers :columns: 3 * :c:data:`psi_occ_pattern_hii` - * :c:data:`pt2_e0_denominator` .. c:var:: psi_det_size @@ -2568,16 +2722,13 @@ Providers * :c:data:`psi_det_alpha_unique` * :c:data:`psi_det_beta` * :c:data:`psi_det_beta_unique` - * :c:data:`psi_det_generators` * :c:data:`psi_det_sorted` * :c:data:`psi_det_sorted_bit` - * :c:data:`psi_det_sorted_gen` * :c:data:`psi_energy` * :c:data:`psi_energy_two_e` * :c:data:`psi_non_cas` * :c:data:`psi_non_cas_sorted_bit` * :c:data:`psi_occ_pattern` - * :c:data:`psi_selectors_size` * :c:data:`s2_values` @@ -2616,11 +2767,7 @@ Providers .. hlist:: :columns: 3 - * :c:data:`n_det_generators` - * :c:data:`n_det_selectors` - * :c:data:`psi_det_generators` - * :c:data:`psi_det_sorted_gen` - * :c:data:`psi_selectors` + * :c:data:`pruned` .. c:var:: psi_det_sorted_bit @@ -2695,11 +2842,7 @@ Providers .. hlist:: :columns: 3 - * :c:data:`n_det_generators` - * :c:data:`n_det_selectors` - * :c:data:`psi_det_generators` - * :c:data:`psi_det_sorted_gen` - * :c:data:`psi_selectors` + * :c:data:`pruned` .. c:var:: psi_energy_h_core @@ -2897,8 +3040,11 @@ Providers :columns: 3 * :c:data:`det_to_occ_pattern` + * :c:data:`pruned` * :c:data:`psi_occ_pattern_hii` + * :c:data:`psi_occ_pattern_sorted` * :c:data:`weight_occ_pattern` + * :c:data:`weight_occ_pattern_average` .. c:var:: psi_occ_pattern_hii @@ -2927,48 +3073,100 @@ Providers -.. c:var:: ref_bitmask_e_n_energy +.. c:var:: psi_occ_pattern_sorted - File : :file:`determinants/ref_bitmask.irp.f` + File : :file:`determinants/occ_pattern.irp.f` .. code:: fortran - double precision :: ref_bitmask_energy - double precision :: ref_bitmask_one_e_energy - double precision :: ref_bitmask_kinetic_energy - double precision :: ref_bitmask_e_n_energy - double precision :: ref_bitmask_two_e_energy - double precision :: ref_bitmask_energy_ab - double precision :: ref_bitmask_energy_bb - double precision :: ref_bitmask_energy_aa + integer(bit_kind), allocatable :: psi_occ_pattern_sorted (N_int,2,N_occ_pattern) + double precision, allocatable :: weight_occ_pattern_average_sorted (N_occ_pattern) + integer, allocatable :: psi_occ_pattern_sorted_order (N_occ_pattern) + integer, allocatable :: psi_occ_pattern_sorted_order_reverse (N_occ_pattern) - Energy of the reference bitmask used in Slater rules + Occupation patterns sorted by weight Needs: .. hlist:: :columns: 3 - * :c:data:`elec_alpha_num` - * :c:data:`elec_beta_num` - * :c:data:`mo_integrals_n_e` - * :c:data:`mo_kinetic_integrals` - * :c:data:`mo_one_e_integrals` - * :c:data:`mo_two_e_integrals_jj` * :c:data:`n_int` - * :c:data:`ref_bitmask` + * :c:data:`psi_occ_pattern` + * :c:data:`weight_occ_pattern_average` Needed by: .. hlist:: :columns: 3 - * :c:data:`coef_hf_selector` - * :c:data:`diagonal_h_matrix_on_psi_det` - * :c:data:`psi_det_hii` - * :c:data:`psi_selectors_diag_h_mat` + * :c:data:`pruned` + + +.. c:var:: psi_occ_pattern_sorted_order + + + File : :file:`determinants/occ_pattern.irp.f` + + .. code:: fortran + + integer(bit_kind), allocatable :: psi_occ_pattern_sorted (N_int,2,N_occ_pattern) + double precision, allocatable :: weight_occ_pattern_average_sorted (N_occ_pattern) + integer, allocatable :: psi_occ_pattern_sorted_order (N_occ_pattern) + integer, allocatable :: psi_occ_pattern_sorted_order_reverse (N_occ_pattern) + + + Occupation patterns sorted by weight + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`n_int` + * :c:data:`psi_occ_pattern` + * :c:data:`weight_occ_pattern_average` + + Needed by: + + .. hlist:: + :columns: 3 + + * :c:data:`pruned` + + +.. c:var:: psi_occ_pattern_sorted_order_reverse + + + File : :file:`determinants/occ_pattern.irp.f` + + .. code:: fortran + + integer(bit_kind), allocatable :: psi_occ_pattern_sorted (N_int,2,N_occ_pattern) + double precision, allocatable :: weight_occ_pattern_average_sorted (N_occ_pattern) + integer, allocatable :: psi_occ_pattern_sorted_order (N_occ_pattern) + integer, allocatable :: psi_occ_pattern_sorted_order_reverse (N_occ_pattern) + + + Occupation patterns sorted by weight + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`n_int` + * :c:data:`psi_occ_pattern` + * :c:data:`weight_occ_pattern_average` + + Needed by: + + .. hlist:: + :columns: 3 + + * :c:data:`pruned` .. c:var:: ref_bitmask_energy @@ -2981,7 +3179,7 @@ Providers double precision :: ref_bitmask_energy double precision :: ref_bitmask_one_e_energy double precision :: ref_bitmask_kinetic_energy - double precision :: ref_bitmask_e_n_energy + double precision :: ref_bitmask_n_e_energy double precision :: ref_bitmask_two_e_energy double precision :: ref_bitmask_energy_ab double precision :: ref_bitmask_energy_bb @@ -3009,10 +3207,8 @@ Providers .. hlist:: :columns: 3 - * :c:data:`coef_hf_selector` * :c:data:`diagonal_h_matrix_on_psi_det` * :c:data:`psi_det_hii` - * :c:data:`psi_selectors_diag_h_mat` .. c:var:: ref_bitmask_energy_aa @@ -3025,7 +3221,7 @@ Providers double precision :: ref_bitmask_energy double precision :: ref_bitmask_one_e_energy double precision :: ref_bitmask_kinetic_energy - double precision :: ref_bitmask_e_n_energy + double precision :: ref_bitmask_n_e_energy double precision :: ref_bitmask_two_e_energy double precision :: ref_bitmask_energy_ab double precision :: ref_bitmask_energy_bb @@ -3053,10 +3249,8 @@ Providers .. hlist:: :columns: 3 - * :c:data:`coef_hf_selector` * :c:data:`diagonal_h_matrix_on_psi_det` * :c:data:`psi_det_hii` - * :c:data:`psi_selectors_diag_h_mat` .. c:var:: ref_bitmask_energy_ab @@ -3069,7 +3263,7 @@ Providers double precision :: ref_bitmask_energy double precision :: ref_bitmask_one_e_energy double precision :: ref_bitmask_kinetic_energy - double precision :: ref_bitmask_e_n_energy + double precision :: ref_bitmask_n_e_energy double precision :: ref_bitmask_two_e_energy double precision :: ref_bitmask_energy_ab double precision :: ref_bitmask_energy_bb @@ -3097,10 +3291,8 @@ Providers .. hlist:: :columns: 3 - * :c:data:`coef_hf_selector` * :c:data:`diagonal_h_matrix_on_psi_det` * :c:data:`psi_det_hii` - * :c:data:`psi_selectors_diag_h_mat` .. c:var:: ref_bitmask_energy_bb @@ -3113,7 +3305,7 @@ Providers double precision :: ref_bitmask_energy double precision :: ref_bitmask_one_e_energy double precision :: ref_bitmask_kinetic_energy - double precision :: ref_bitmask_e_n_energy + double precision :: ref_bitmask_n_e_energy double precision :: ref_bitmask_two_e_energy double precision :: ref_bitmask_energy_ab double precision :: ref_bitmask_energy_bb @@ -3141,10 +3333,8 @@ Providers .. hlist:: :columns: 3 - * :c:data:`coef_hf_selector` * :c:data:`diagonal_h_matrix_on_psi_det` * :c:data:`psi_det_hii` - * :c:data:`psi_selectors_diag_h_mat` .. c:var:: ref_bitmask_kinetic_energy @@ -3157,7 +3347,49 @@ Providers double precision :: ref_bitmask_energy double precision :: ref_bitmask_one_e_energy double precision :: ref_bitmask_kinetic_energy - double precision :: ref_bitmask_e_n_energy + double precision :: ref_bitmask_n_e_energy + double precision :: ref_bitmask_two_e_energy + double precision :: ref_bitmask_energy_ab + double precision :: ref_bitmask_energy_bb + double precision :: ref_bitmask_energy_aa + + + Energy of the reference bitmask used in Slater rules + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`elec_alpha_num` + * :c:data:`elec_beta_num` + * :c:data:`mo_integrals_n_e` + * :c:data:`mo_kinetic_integrals` + * :c:data:`mo_one_e_integrals` + * :c:data:`mo_two_e_integrals_jj` + * :c:data:`n_int` + * :c:data:`ref_bitmask` + + Needed by: + + .. hlist:: + :columns: 3 + + * :c:data:`diagonal_h_matrix_on_psi_det` + * :c:data:`psi_det_hii` + + +.. c:var:: ref_bitmask_n_e_energy + + + File : :file:`determinants/ref_bitmask.irp.f` + + .. code:: fortran + + double precision :: ref_bitmask_energy + double precision :: ref_bitmask_one_e_energy + double precision :: ref_bitmask_kinetic_energy + double precision :: ref_bitmask_n_e_energy double precision :: ref_bitmask_two_e_energy double precision :: ref_bitmask_energy_ab double precision :: ref_bitmask_energy_bb @@ -3185,10 +3417,8 @@ Providers .. hlist:: :columns: 3 - * :c:data:`coef_hf_selector` * :c:data:`diagonal_h_matrix_on_psi_det` * :c:data:`psi_det_hii` - * :c:data:`psi_selectors_diag_h_mat` .. c:var:: ref_bitmask_one_e_energy @@ -3201,7 +3431,7 @@ Providers double precision :: ref_bitmask_energy double precision :: ref_bitmask_one_e_energy double precision :: ref_bitmask_kinetic_energy - double precision :: ref_bitmask_e_n_energy + double precision :: ref_bitmask_n_e_energy double precision :: ref_bitmask_two_e_energy double precision :: ref_bitmask_energy_ab double precision :: ref_bitmask_energy_bb @@ -3229,10 +3459,8 @@ Providers .. hlist:: :columns: 3 - * :c:data:`coef_hf_selector` * :c:data:`diagonal_h_matrix_on_psi_det` * :c:data:`psi_det_hii` - * :c:data:`psi_selectors_diag_h_mat` .. c:var:: ref_bitmask_two_e_energy @@ -3245,7 +3473,7 @@ Providers double precision :: ref_bitmask_energy double precision :: ref_bitmask_one_e_energy double precision :: ref_bitmask_kinetic_energy - double precision :: ref_bitmask_e_n_energy + double precision :: ref_bitmask_n_e_energy double precision :: ref_bitmask_two_e_energy double precision :: ref_bitmask_energy_ab double precision :: ref_bitmask_energy_bb @@ -3273,10 +3501,8 @@ Providers .. hlist:: :columns: 3 - * :c:data:`coef_hf_selector` * :c:data:`diagonal_h_matrix_on_psi_det` * :c:data:`psi_det_hii` - * :c:data:`psi_selectors_diag_h_mat` .. c:var:: ref_closed_shell_bitmask @@ -3362,7 +3588,6 @@ Providers * :c:data:`psi_coef` * :c:data:`psi_det` * :c:data:`psi_det_size` - * :c:data:`s_z` @@ -3387,13 +3612,6 @@ Providers * :c:data:`elec_alpha_num` * :c:data:`elec_beta_num` - Needed by: - - .. hlist:: - :columns: 3 - - * :c:data:`ci_electronic_energy` - * :c:data:`s2_values` .. c:var:: s_z2_sz @@ -3417,13 +3635,6 @@ Providers * :c:data:`elec_alpha_num` * :c:data:`elec_beta_num` - Needed by: - - .. hlist:: - :columns: 3 - - * :c:data:`ci_electronic_energy` - * :c:data:`s2_values` .. c:var:: single_exc_bitmask @@ -3658,9 +3869,15 @@ Providers :columns: 3 * :c:data:`det_alpha_norm` + * :c:data:`one_e_dm_average_alpha_mo_for_dft` + * :c:data:`one_e_dm_average_beta_mo_for_dft` * :c:data:`one_e_dm_mo_alpha_average` * :c:data:`psi_average_norm_contrib` - * :c:data:`selection_weight` + * :c:data:`state_av_act_2_rdm_aa_mo` + * :c:data:`state_av_act_2_rdm_ab_mo` + * :c:data:`state_av_act_2_rdm_bb_mo` + * :c:data:`state_av_act_2_rdm_spin_trace_mo` + * :c:data:`weight_occ_pattern_average` .. c:var:: weight_occ_pattern @@ -3688,6 +3905,70 @@ Providers +.. c:var:: weight_occ_pattern_average + + + File : :file:`determinants/occ_pattern.irp.f` + + .. code:: fortran + + double precision, allocatable :: weight_occ_pattern_average (N_occ_pattern) + + + State-average weight of the occupation patterns in the wave function + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`det_to_occ_pattern` + * :c:data:`n_det` + * :c:data:`n_states` + * :c:data:`psi_coef` + * :c:data:`psi_occ_pattern` + * :c:data:`state_average_weight` + + Needed by: + + .. hlist:: + :columns: 3 + + * :c:data:`psi_occ_pattern_sorted` + + +.. c:var:: weight_occ_pattern_average_sorted + + + File : :file:`determinants/occ_pattern.irp.f` + + .. code:: fortran + + integer(bit_kind), allocatable :: psi_occ_pattern_sorted (N_int,2,N_occ_pattern) + double precision, allocatable :: weight_occ_pattern_average_sorted (N_occ_pattern) + integer, allocatable :: psi_occ_pattern_sorted_order (N_occ_pattern) + integer, allocatable :: psi_occ_pattern_sorted_order_reverse (N_occ_pattern) + + + Occupation patterns sorted by weight + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`n_int` + * :c:data:`psi_occ_pattern` + * :c:data:`weight_occ_pattern_average` + + Needed by: + + .. hlist:: + :columns: 3 + + * :c:data:`pruned` + + Subroutines / functions ----------------------- @@ -3709,8 +3990,8 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`mo_two_e_integrals_jj` * :c:data:`mo_one_e_integrals` + * :c:data:`mo_two_e_integrals_jj` Called by: @@ -3778,9 +4059,11 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`mo_two_e_integrals_jj` - * :c:data:`mo_one_e_integrals` + * :c:data:`elec_alpha_num` + * :c:data:`elec_beta_num` * :c:data:`mo_num` + * :c:data:`mo_one_e_integrals` + * :c:data:`mo_two_e_integrals_jj` Called by: @@ -3814,6 +4097,8 @@ Subroutines / functions .. hlist:: :columns: 3 + * :c:data:`elec_alpha_num` + * :c:data:`elec_beta_num` * :c:data:`mo_two_e_integrals_jj` Called by: @@ -3854,13 +4139,6 @@ Subroutines / functions - Called by: - - .. hlist:: - :columns: 3 - - * :c:func:`select_singles_and_doubles` - .. c:function:: apply_holes: @@ -3873,13 +4151,6 @@ Subroutines / functions - Called by: - - .. hlist:: - :columns: 3 - - * :c:func:`fill_buffer_double` - .. c:function:: apply_particle: @@ -3904,15 +4175,6 @@ Subroutines / functions - Called by: - - .. hlist:: - :columns: 3 - - * :c:func:`fill_buffer_double` - * :c:func:`get_d0` - * :c:func:`get_d1` - .. c:function:: bitstring_to_list_ab: @@ -3950,8 +4212,15 @@ Subroutines / functions * :c:func:`i_h_j_two_e` * :c:func:`i_h_j_verbose` * :c:data:`one_e_dm_mo_alpha` + * :c:func:`orb_range_diag_to_all_2_rdm_dm_buffer` + * :c:func:`orb_range_diag_to_all_states_2_rdm_dm_buffer` + * :c:func:`orb_range_off_diag_single_to_2_rdm_aa_dm_buffer` + * :c:func:`orb_range_off_diag_single_to_2_rdm_ab_dm_buffer` + * :c:func:`orb_range_off_diag_single_to_2_rdm_bb_dm_buffer` + * :c:func:`orb_range_off_diag_single_to_all_states_aa_dm_buffer` + * :c:func:`orb_range_off_diag_single_to_all_states_ab_dm_buffer` + * :c:func:`orb_range_off_diag_single_to_all_states_bb_dm_buffer` * :c:data:`ref_closed_shell_bitmask` - * :c:func:`select_singles_and_doubles` * :c:func:`single_excitation_wee` @@ -3973,20 +4242,13 @@ Subroutines / functions .. hlist:: :columns: 3 + * :c:data:`elec_alpha_num` * :c:data:`elec_beta_num` * :c:data:`mo_num` * :c:data:`mo_one_e_integrals` - * :c:data:`elec_alpha_num` * :c:data:`mo_two_e_integrals_jj` * :c:data:`n_int` - Called by: - - .. hlist:: - :columns: 3 - - * :c:func:`select_connected` - Calls: .. hlist:: @@ -3996,6 +4258,39 @@ Subroutines / functions * :c:func:`debug_det` +.. c:function:: build_singly_excited_wavefunction: + + + File : :file:`determinants/create_excitations.irp.f` + + .. code:: fortran + + subroutine build_singly_excited_wavefunction(i_hole,i_particle,ispin,det_out,coef_out) + + + Applies the single excitation operator : a^{dager}_(i_particle) a_(i_hole) of + spin = ispin to the current wave function (psi_det, psi_coef) + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`n_det` + * :c:data:`n_int` + * :c:data:`n_states` + * :c:data:`psi_coef` + * :c:data:`psi_det` + + Calls: + + .. hlist:: + :columns: 3 + + * :c:func:`do_single_excitation` + * :c:func:`get_phase` + + .. c:function:: connected_to_hf: @@ -4012,10 +4307,10 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`thresh_sym` - * :c:data:`ref_bitmask` * :c:data:`mo_one_e_integrals` * :c:data:`n_int` + * :c:data:`ref_bitmask` + * :c:data:`thresh_sym` Calls: @@ -4051,6 +4346,13 @@ Subroutines / functions -i : key is the ith determinant of the reference wf keys + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`n_int` + .. c:function:: connected_to_ref_by_single: @@ -4077,6 +4379,13 @@ Subroutines / functions -i : key is the ith determinant of the reference wf keys + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`n_int` + .. c:function:: copy_h_apply_buffer_to_wf: @@ -4096,14 +4405,17 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_coef` - * :c:data:`n_states` + * :c:data:`elec_alpha_num` + * :c:data:`elec_beta_num` * :c:data:`h_apply_buffer_allocated` * :c:data:`n_det` - * :c:data:`psi_det_size` * :c:data:`n_int` + * :c:data:`n_states` * :c:data:`nproc` + * :c:data:`pruned` + * :c:data:`psi_coef` * :c:data:`psi_det` + * :c:data:`psi_det_size` Called by: @@ -4112,8 +4424,6 @@ Subroutines / functions * :c:func:`generate_all_alpha_beta_det_products` * :c:func:`make_s2_eigenfunction` - * :c:func:`run_stochastic_cipsi` - * :c:func:`zmq_selection` Calls: @@ -4155,10 +4465,10 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_det_beta_unique` - * :c:data:`psi_det_alpha_unique` - * :c:data:`psi_bilinear_matrix_values` * :c:data:`n_int` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_det_alpha_unique` + * :c:data:`psi_det_beta_unique` .. c:function:: create_microlist: @@ -4179,18 +4489,6 @@ Subroutines / functions * :c:data:`mo_num` - Called by: - - .. hlist:: - :columns: 3 - - * :c:func:`perturb_buffer_dummy` - * :c:func:`perturb_buffer_epstein_nesbet` - * :c:func:`perturb_buffer_epstein_nesbet_2x2` - * :c:func:`perturb_buffer_epstein_nesbet_2x2_no_ci_diag` - * :c:func:`perturb_buffer_moller_plesset` - * :c:func:`perturb_buffer_qdpt` - Calls: .. hlist:: @@ -4210,24 +4508,6 @@ Subroutines / functions - Called by: - - .. hlist:: - :columns: 3 - - * :c:func:`perturb_buffer_by_mono_dummy` - * :c:func:`perturb_buffer_by_mono_epstein_nesbet` - * :c:func:`perturb_buffer_by_mono_epstein_nesbet_2x2` - * :c:func:`perturb_buffer_by_mono_epstein_nesbet_2x2_no_ci_diag` - * :c:func:`perturb_buffer_by_mono_moller_plesset` - * :c:func:`perturb_buffer_by_mono_qdpt` - * :c:func:`perturb_buffer_dummy` - * :c:func:`perturb_buffer_epstein_nesbet` - * :c:func:`perturb_buffer_epstein_nesbet_2x2` - * :c:func:`perturb_buffer_epstein_nesbet_2x2_no_ci_diag` - * :c:func:`perturb_buffer_moller_plesset` - * :c:func:`perturb_buffer_qdpt` - .. c:function:: create_minilist_find_previous: @@ -4240,24 +4520,6 @@ Subroutines / functions - Called by: - - .. hlist:: - :columns: 3 - - * :c:func:`perturb_buffer_by_mono_dummy` - * :c:func:`perturb_buffer_by_mono_epstein_nesbet` - * :c:func:`perturb_buffer_by_mono_epstein_nesbet_2x2` - * :c:func:`perturb_buffer_by_mono_epstein_nesbet_2x2_no_ci_diag` - * :c:func:`perturb_buffer_by_mono_moller_plesset` - * :c:func:`perturb_buffer_by_mono_qdpt` - * :c:func:`perturb_buffer_dummy` - * :c:func:`perturb_buffer_epstein_nesbet` - * :c:func:`perturb_buffer_epstein_nesbet_2x2` - * :c:func:`perturb_buffer_epstein_nesbet_2x2_no_ci_diag` - * :c:func:`perturb_buffer_moller_plesset` - * :c:func:`perturb_buffer_qdpt` - .. c:function:: create_wf_of_psi_bilinear_matrix: @@ -4277,16 +4539,16 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_coef` - * :c:data:`psi_det_beta_unique` - * :c:data:`psi_det_alpha_unique` - * :c:data:`psi_det_sorted_bit` - * :c:data:`n_states` * :c:data:`n_det` - * :c:data:`psi_bilinear_matrix` * :c:data:`n_int` + * :c:data:`n_states` + * :c:data:`psi_bilinear_matrix` + * :c:data:`psi_coef` * :c:data:`psi_det` + * :c:data:`psi_det_alpha_unique` + * :c:data:`psi_det_beta_unique` * :c:data:`psi_det_sorted` + * :c:data:`psi_det_sorted_bit` Calls: @@ -4332,7 +4594,6 @@ Subroutines / functions * :c:func:`diag_h_mat_elem_fock` * :c:func:`example_determinants` - * :c:func:`pt2_moller_plesset` .. c:function:: decode_exc_spin: @@ -4433,9 +4694,11 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`ref_bitmask_energy` + * :c:data:`elec_alpha_num` + * :c:data:`elec_beta_num` * :c:data:`elec_num` * :c:data:`ref_bitmask` + * :c:data:`ref_bitmask_energy` Calls: @@ -4465,8 +4728,8 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`mo_two_e_integrals_jj` * :c:data:`mo_num` + * :c:data:`mo_two_e_integrals_jj` Calls: @@ -4496,6 +4759,8 @@ Subroutines / functions .. hlist:: :columns: 3 + * :c:data:`elec_alpha_num` + * :c:data:`elec_beta_num` * :c:data:`mo_one_e_integrals` Calls: @@ -4536,9 +4801,11 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`ref_bitmask_energy` + * :c:data:`elec_alpha_num` + * :c:data:`elec_beta_num` * :c:data:`elec_num` * :c:data:`ref_bitmask` + * :c:data:`ref_bitmask_energy` Calls: @@ -4572,7 +4839,7 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`elec_num` + * :c:data:`mo_num` * :c:data:`n_int` Called by: @@ -4580,6 +4847,7 @@ Subroutines / functions .. hlist:: :columns: 3 + * :c:func:`build_singly_excited_wavefunction` * :c:func:`example_determinants` @@ -4600,9 +4868,9 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`ref_bitmask` * :c:data:`elec_alpha_num` * :c:data:`n_int` + * :c:data:`ref_bitmask` Calls: @@ -4670,10 +4938,12 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_states` + * :c:data:`elec_alpha_num` + * :c:data:`elec_beta_num` * :c:data:`h_apply_buffer_allocated` * :c:data:`n_det` * :c:data:`n_int` + * :c:data:`n_states` Called by: @@ -4682,8 +4952,6 @@ Subroutines / functions * :c:func:`generate_all_alpha_beta_det_products` * :c:func:`make_s2_eigenfunction` - * :c:func:`zmq_pt2` - * :c:func:`zmq_selection` Calls: @@ -4741,6 +5009,13 @@ Subroutines / functions idx(0) is the number of determinants that interact with key1 + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`n_int` + Called by: .. hlist:: @@ -4787,13 +5062,13 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_coef` - * :c:data:`psi_det_beta_unique` - * :c:data:`psi_det_alpha_unique` * :c:data:`h_apply_buffer_allocated` * :c:data:`n_det` * :c:data:`n_int` + * :c:data:`psi_coef` * :c:data:`psi_det` + * :c:data:`psi_det_alpha_unique` + * :c:data:`psi_det_beta_unique` Called by: @@ -4884,7 +5159,7 @@ Subroutines / functions .. c:function:: get_all_spin_doubles_2: - File : :file:`determinants/spindeterminants.irp.f_template_1291` + File : :file:`determinants/spindeterminants.irp.f_template_1316` .. code:: fortran @@ -4907,7 +5182,7 @@ Subroutines / functions .. c:function:: get_all_spin_doubles_3: - File : :file:`determinants/spindeterminants.irp.f_template_1291` + File : :file:`determinants/spindeterminants.irp.f_template_1316` .. code:: fortran @@ -4930,7 +5205,7 @@ Subroutines / functions .. c:function:: get_all_spin_doubles_4: - File : :file:`determinants/spindeterminants.irp.f_template_1291` + File : :file:`determinants/spindeterminants.irp.f_template_1316` .. code:: fortran @@ -4953,7 +5228,7 @@ Subroutines / functions .. c:function:: get_all_spin_doubles_n_int: - File : :file:`determinants/spindeterminants.irp.f_template_1291` + File : :file:`determinants/spindeterminants.irp.f_template_1316` .. code:: fortran @@ -5047,12 +5322,14 @@ Subroutines / functions * :c:func:`get_all_spin_singles` * :c:func:`h_s2_u_0_nstates_openmp_work_1` * :c:func:`h_s2_u_0_two_e_nstates_openmp_work_1` + * :c:func:`orb_range_2_rdm_openmp_work_1` + * :c:func:`orb_range_2_rdm_state_av_openmp_work_1` .. c:function:: get_all_spin_singles_2: - File : :file:`determinants/spindeterminants.irp.f_template_1291` + File : :file:`determinants/spindeterminants.irp.f_template_1316` .. code:: fortran @@ -5072,12 +5349,14 @@ Subroutines / functions * :c:func:`get_all_spin_singles` * :c:func:`h_s2_u_0_nstates_openmp_work_2` * :c:func:`h_s2_u_0_two_e_nstates_openmp_work_2` + * :c:func:`orb_range_2_rdm_openmp_work_2` + * :c:func:`orb_range_2_rdm_state_av_openmp_work_2` .. c:function:: get_all_spin_singles_3: - File : :file:`determinants/spindeterminants.irp.f_template_1291` + File : :file:`determinants/spindeterminants.irp.f_template_1316` .. code:: fortran @@ -5097,12 +5376,14 @@ Subroutines / functions * :c:func:`get_all_spin_singles` * :c:func:`h_s2_u_0_nstates_openmp_work_3` * :c:func:`h_s2_u_0_two_e_nstates_openmp_work_3` + * :c:func:`orb_range_2_rdm_openmp_work_3` + * :c:func:`orb_range_2_rdm_state_av_openmp_work_3` .. c:function:: get_all_spin_singles_4: - File : :file:`determinants/spindeterminants.irp.f_template_1291` + File : :file:`determinants/spindeterminants.irp.f_template_1316` .. code:: fortran @@ -5122,6 +5403,8 @@ Subroutines / functions * :c:func:`get_all_spin_singles` * :c:func:`h_s2_u_0_nstates_openmp_work_4` * :c:func:`h_s2_u_0_two_e_nstates_openmp_work_4` + * :c:func:`orb_range_2_rdm_openmp_work_4` + * :c:func:`orb_range_2_rdm_state_av_openmp_work_4` .. c:function:: get_all_spin_singles_and_doubles: @@ -5178,12 +5461,14 @@ Subroutines / functions * :c:func:`get_all_spin_singles_and_doubles` * :c:func:`h_s2_u_0_nstates_openmp_work_1` * :c:func:`h_s2_u_0_two_e_nstates_openmp_work_1` + * :c:func:`orb_range_2_rdm_openmp_work_1` + * :c:func:`orb_range_2_rdm_state_av_openmp_work_1` .. c:function:: get_all_spin_singles_and_doubles_2: - File : :file:`determinants/spindeterminants.irp.f_template_1291` + File : :file:`determinants/spindeterminants.irp.f_template_1316` .. code:: fortran @@ -5205,12 +5490,14 @@ Subroutines / functions * :c:func:`get_all_spin_singles_and_doubles` * :c:func:`h_s2_u_0_nstates_openmp_work_2` * :c:func:`h_s2_u_0_two_e_nstates_openmp_work_2` + * :c:func:`orb_range_2_rdm_openmp_work_2` + * :c:func:`orb_range_2_rdm_state_av_openmp_work_2` .. c:function:: get_all_spin_singles_and_doubles_3: - File : :file:`determinants/spindeterminants.irp.f_template_1291` + File : :file:`determinants/spindeterminants.irp.f_template_1316` .. code:: fortran @@ -5232,12 +5519,14 @@ Subroutines / functions * :c:func:`get_all_spin_singles_and_doubles` * :c:func:`h_s2_u_0_nstates_openmp_work_3` * :c:func:`h_s2_u_0_two_e_nstates_openmp_work_3` + * :c:func:`orb_range_2_rdm_openmp_work_3` + * :c:func:`orb_range_2_rdm_state_av_openmp_work_3` .. c:function:: get_all_spin_singles_and_doubles_4: - File : :file:`determinants/spindeterminants.irp.f_template_1291` + File : :file:`determinants/spindeterminants.irp.f_template_1316` .. code:: fortran @@ -5259,12 +5548,14 @@ Subroutines / functions * :c:func:`get_all_spin_singles_and_doubles` * :c:func:`h_s2_u_0_nstates_openmp_work_4` * :c:func:`h_s2_u_0_two_e_nstates_openmp_work_4` + * :c:func:`orb_range_2_rdm_openmp_work_4` + * :c:func:`orb_range_2_rdm_state_av_openmp_work_4` .. c:function:: get_all_spin_singles_and_doubles_n_int: - File : :file:`determinants/spindeterminants.irp.f_template_1291` + File : :file:`determinants/spindeterminants.irp.f_template_1316` .. code:: fortran @@ -5293,12 +5584,14 @@ Subroutines / functions * :c:func:`get_all_spin_singles_and_doubles` * :c:func:`h_s2_u_0_nstates_openmp_work_n_int` * :c:func:`h_s2_u_0_two_e_nstates_openmp_work_n_int` + * :c:func:`orb_range_2_rdm_openmp_work_n_int` + * :c:func:`orb_range_2_rdm_state_av_openmp_work_n_int` .. c:function:: get_all_spin_singles_n_int: - File : :file:`determinants/spindeterminants.irp.f_template_1291` + File : :file:`determinants/spindeterminants.irp.f_template_1316` .. code:: fortran @@ -5325,6 +5618,8 @@ Subroutines / functions * :c:func:`get_all_spin_singles` * :c:func:`h_s2_u_0_nstates_openmp_work_n_int` * :c:func:`h_s2_u_0_two_e_nstates_openmp_work_n_int` + * :c:func:`orb_range_2_rdm_openmp_work_n_int` + * :c:func:`orb_range_2_rdm_state_av_openmp_work_n_int` .. c:function:: get_double_excitation: @@ -5351,6 +5646,8 @@ Subroutines / functions * :c:func:`i_h_j_s2` * :c:func:`i_h_j_two_e` * :c:func:`i_h_j_verbose` + * :c:func:`orb_range_off_diag_double_to_2_rdm_ab_dm_buffer` + * :c:func:`orb_range_off_diag_double_to_all_states_ab_dm_buffer` .. c:function:: get_double_excitation_spin: @@ -5373,6 +5670,10 @@ Subroutines / functions * :c:func:`get_excitation_spin` * :c:func:`i_h_j_double_spin` + * :c:func:`orb_range_off_diag_double_to_2_rdm_aa_dm_buffer` + * :c:func:`orb_range_off_diag_double_to_2_rdm_bb_dm_buffer` + * :c:func:`orb_range_off_diag_double_to_all_states_aa_dm_buffer` + * :c:func:`orb_range_off_diag_double_to_all_states_bb_dm_buffer` .. c:function:: get_excitation: @@ -5394,7 +5695,6 @@ Subroutines / functions * :c:func:`example_determinants` * :c:func:`get_phase` - * :c:func:`pt2_moller_plesset` Calls: @@ -5424,10 +5724,8 @@ Subroutines / functions :columns: 3 * :c:func:`connected_to_hf` - * :c:data:`degree_max_generators` * :c:func:`diag_h_mat_elem_fock` * :c:func:`example_determinants` - * :c:data:`exc_degree_per_selectors` * :c:func:`get_excitation` * :c:func:`get_s2` * :c:func:`i_h_j` @@ -5437,7 +5735,6 @@ Subroutines / functions * :c:func:`i_h_j_verbose` * :c:data:`max_degree_exc` * :c:data:`psi_non_cas` - * :c:func:`pt2_qdpt` .. c:function:: get_excitation_degree_spin: @@ -5459,7 +5756,6 @@ Subroutines / functions * :c:func:`get_excitation_spin` * :c:data:`one_e_dm_mo_alpha` - * :c:func:`select_singles_and_doubles` .. c:function:: get_excitation_degree_vector: @@ -5631,8 +5927,8 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_det_sorted_bit` * :c:data:`n_det` + * :c:data:`psi_det_sorted_bit` .. c:function:: get_occupation_from_dets: @@ -5652,11 +5948,12 @@ Subroutines / functions .. hlist:: :columns: 3 + * :c:data:`mo_num` + * :c:data:`n_det` + * :c:data:`n_int` + * :c:data:`n_states` * :c:data:`psi_coef` * :c:data:`psi_det` - * :c:data:`n_int` - * :c:data:`n_det` - * :c:data:`mo_num` Calls: @@ -5678,6 +5975,13 @@ Subroutines / functions Returns the phase between key1 and key2. + Called by: + + .. hlist:: + :columns: 3 + + * :c:func:`build_singly_excited_wavefunction` + Calls: .. hlist:: @@ -5764,6 +6068,12 @@ Subroutines / functions * :c:func:`i_h_j_s2` * :c:func:`i_h_j_two_e` * :c:func:`i_h_j_verbose` + * :c:func:`orb_range_off_diag_single_to_2_rdm_aa_dm_buffer` + * :c:func:`orb_range_off_diag_single_to_2_rdm_ab_dm_buffer` + * :c:func:`orb_range_off_diag_single_to_2_rdm_bb_dm_buffer` + * :c:func:`orb_range_off_diag_single_to_all_states_aa_dm_buffer` + * :c:func:`orb_range_off_diag_single_to_all_states_ab_dm_buffer` + * :c:func:`orb_range_off_diag_single_to_all_states_bb_dm_buffer` .. c:function:: get_single_excitation_from_fock: @@ -5782,10 +6092,11 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`ref_closed_shell_bitmask` * :c:data:`big_array_coulomb_integrals` * :c:data:`fock_operator_closed_shell_ref_bitmask` + * :c:data:`mo_num` * :c:data:`n_int` + * :c:data:`ref_closed_shell_bitmask` Called by: @@ -5876,18 +6187,6 @@ Subroutines / functions * :c:data:`mo_num` - Called by: - - .. hlist:: - :columns: 3 - - * :c:func:`perturb_buffer_dummy` - * :c:func:`perturb_buffer_epstein_nesbet` - * :c:func:`perturb_buffer_epstein_nesbet_2x2` - * :c:func:`perturb_buffer_epstein_nesbet_2x2_no_ci_diag` - * :c:func:`perturb_buffer_moller_plesset` - * :c:func:`perturb_buffer_qdpt` - Calls: .. hlist:: @@ -5914,25 +6213,24 @@ Subroutines / functions :columns: 3 * :c:data:`big_array_coulomb_integrals` - * :c:data:`mo_two_e_integrals_in_map` * :c:data:`big_array_coulomb_integrals` + * :c:data:`elec_alpha_num` + * :c:data:`elec_beta_num` * :c:data:`mo_integrals_map` + * :c:data:`mo_two_e_integrals_in_map` + * :c:data:`n_int` Called by: .. hlist:: :columns: 3 - * :c:data:`coef_hf_selector` * :c:func:`connected_to_hf` * :c:func:`example_determinants` - * :c:func:`get_d0` - * :c:func:`get_d1` * :c:data:`h_matrix_all_dets` * :c:data:`h_matrix_cas` * :c:func:`i_h_psi` * :c:func:`i_h_psi_minilist` - * :c:func:`pt2_qdpt` * :c:func:`routine_example_psi_det` Calls: @@ -5966,9 +6264,9 @@ Subroutines / functions :columns: 3 * :c:data:`big_array_coulomb_integrals` - * :c:data:`mo_two_e_integrals_in_map` * :c:data:`big_array_coulomb_integrals` * :c:data:`mo_integrals_map` + * :c:data:`mo_two_e_integrals_in_map` Called by: @@ -6013,8 +6311,8 @@ Subroutines / functions :columns: 3 * :c:data:`big_array_coulomb_integrals` - * :c:data:`mo_two_e_integrals_in_map` * :c:data:`mo_integrals_map` + * :c:data:`mo_two_e_integrals_in_map` Called by: @@ -6116,9 +6414,12 @@ Subroutines / functions :columns: 3 * :c:data:`big_array_coulomb_integrals` - * :c:data:`mo_two_e_integrals_in_map` * :c:data:`big_array_coulomb_integrals` + * :c:data:`elec_alpha_num` + * :c:data:`elec_beta_num` * :c:data:`mo_integrals_map` + * :c:data:`mo_two_e_integrals_in_map` + * :c:data:`n_int` Calls: @@ -6190,11 +6491,14 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`ref_bitmask_energy` * :c:data:`big_array_coulomb_integrals` - * :c:data:`mo_two_e_integrals_in_map` * :c:data:`big_array_coulomb_integrals` + * :c:data:`elec_alpha_num` + * :c:data:`elec_beta_num` * :c:data:`mo_integrals_map` + * :c:data:`mo_two_e_integrals_in_map` + * :c:data:`n_int` + * :c:data:`ref_bitmask_energy` Calls: @@ -6225,11 +6529,12 @@ Subroutines / functions .. hlist:: :columns: 3 + * :c:data:`elec_alpha_num` * :c:data:`elec_beta_num` + * :c:data:`mo_integrals_map` * :c:data:`mo_one_e_integrals` * :c:data:`mo_two_e_integrals_in_map` - * :c:data:`elec_alpha_num` - * :c:data:`mo_integrals_map` + * :c:data:`n_int` Calls: @@ -6259,14 +6564,12 @@ Subroutines / functions The i_H_psi_minilist is much faster but requires to build the minilists. - Called by: + Needs: .. hlist:: :columns: 3 - * :c:func:`pt2_epstein_nesbet_2x2` - * :c:func:`pt2_epstein_nesbet_2x2_no_ci_diag` - * :c:func:`remove_small_contributions` + * :c:data:`n_int` Calls: @@ -6292,15 +6595,12 @@ Subroutines / functions Uses filter_connected_i_H_psi0 to get all the $|J \rangle$ to which $|i \rangle$ is connected. The $|J\rangle$ are searched in short pre-computed lists. - Called by: + Needs: .. hlist:: :columns: 3 - * :c:func:`pt2_dummy` - * :c:func:`pt2_epstein_nesbet` - * :c:func:`pt2_moller_plesset` - * :c:func:`pt2_qdpt` + * :c:data:`n_int` Calls: @@ -6326,6 +6626,13 @@ Subroutines / functions Uses filter_connected_i_H_psi0 to get all the $|J\rangle$ to which $|i\rangle$ is connected. The $|J\rangle$ are searched in short pre-computed lists. + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`n_int` + Calls: .. hlist:: @@ -6388,6 +6695,13 @@ Subroutines / functions Returns |true| if determinant ``key`` is connected to ``keys`` + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`n_int` + .. c:function:: is_connected_to_by_single: @@ -6401,6 +6715,13 @@ Subroutines / functions Returns |true| is ``key`` is connected to ``keys`` by a single excitation. + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`n_int` + .. c:function:: is_in_wavefunction: @@ -6452,21 +6773,13 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_coef` - * :c:data:`psi_occ_pattern` - * :c:data:`psi_occ_pattern` * :c:data:`elec_alpha_num` * :c:data:`n_det` * :c:data:`n_int` + * :c:data:`psi_occ_pattern` + * :c:data:`psi_coef` * :c:data:`psi_det` - - Called by: - - .. hlist:: - :columns: 3 - - * :c:func:`run_cipsi` - * :c:func:`run_stochastic_cipsi` + * :c:data:`psi_occ_pattern` Calls: @@ -6544,7 +6857,17 @@ Subroutines / functions subroutine occ_pattern_to_dets(o,d,sze,n_alpha,Nint) - Generate all possible determinants for a give occ_pattern + Generate all possible determinants for a given occ_pattern + + Input : + o : occupation pattern : (doubly occupied, singly occupied) + sze : Number of produced determinants, computed by `occ_pattern_to_dets_size` + n_alpha : Number of $\alpha$ electrons + Nint : N_int + + Output: + d : determinants + Needs: @@ -6559,7 +6882,6 @@ Subroutines / functions :columns: 3 * :c:func:`make_s2_eigenfunction` - * :c:func:`make_selection_buffer_s2` .. c:function:: occ_pattern_to_dets_size: @@ -6587,33 +6909,6 @@ Subroutines / functions :columns: 3 * :c:func:`make_s2_eigenfunction` - * :c:func:`make_selection_buffer_s2` - - -.. c:function:: pull_pt2: - - - File : :file:`determinants/h_apply.irp.f` - - .. code:: fortran - - subroutine pull_pt2(zmq_socket_pull,pt2,norm_pert,H_pert_diag,i_generator,N_st,n,task_id) - - - Pull |PT2| calculation in the collector - - -.. c:function:: push_pt2: - - - File : :file:`determinants/h_apply.irp.f` - - .. code:: fortran - - subroutine push_pt2(zmq_socket_push,pt2,norm_pert,H_pert_diag,i_generator,N_st,task_id) - - - Push |PT2| calculation to the collector .. c:function:: read_dets: @@ -6645,6 +6940,68 @@ Subroutines / functions * :c:func:`ezfio_get_determinants_psi_det` +.. c:function:: read_spindeterminants: + + + File : :file:`determinants/spindeterminants.irp.f` + + .. code:: fortran + + subroutine read_spindeterminants + + + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`n_det` + * :c:data:`psi_det_alpha_unique` + * :c:data:`psi_det_beta_unique` + * :c:data:`n_states` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_det_alpha_unique` + * :c:data:`psi_det_beta_unique` + + Calls: + + .. hlist:: + :columns: 3 + + * :c:func:`ezfio_get_spindeterminants_n_det` + * :c:func:`ezfio_get_spindeterminants_n_det_alpha` + * :c:func:`ezfio_get_spindeterminants_n_det_beta` + * :c:func:`ezfio_get_spindeterminants_n_states` + * :c:func:`ezfio_get_spindeterminants_psi_coef_matrix_columns` + * :c:func:`ezfio_get_spindeterminants_psi_coef_matrix_rows` + * :c:func:`ezfio_get_spindeterminants_psi_coef_matrix_values` + * :c:func:`ezfio_get_spindeterminants_psi_det_alpha` + * :c:func:`ezfio_get_spindeterminants_psi_det_beta` + * :c:func:`wf_of_psi_bilinear_matrix` + + Touches: + + .. hlist:: + :columns: 3 + + * :c:data:`n_det` + * :c:data:`psi_det_alpha_unique` + * :c:data:`psi_det_beta_unique` + * :c:data:`n_states` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_coef` + * :c:data:`psi_det` + * :c:data:`psi_det_alpha_unique` + * :c:data:`psi_det_beta_unique` + + .. c:function:: remove_duplicates_in_psi_det: @@ -6662,14 +7019,14 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_coef` - * :c:data:`psi_det_sorted_bit` * :c:data:`c0_weight` * :c:data:`n_det` - * :c:data:`psi_det_sorted_bit` * :c:data:`n_int` + * :c:data:`psi_coef` + * :c:data:`psi_det_sorted_bit` * :c:data:`psi_det` * :c:data:`psi_det_sorted` + * :c:data:`psi_det_sorted_bit` Called by: @@ -6709,10 +7066,13 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_states` + * :c:data:`elec_alpha_num` + * :c:data:`elec_beta_num` * :c:data:`h_apply_buffer_allocated` * :c:data:`n_det` * :c:data:`n_int` + * :c:data:`n_states` + * :c:data:`nproc` Called by: @@ -6720,7 +7080,6 @@ Subroutines / functions :columns: 3 * :c:func:`fill_h_apply_buffer_no_selection` - * :c:func:`fill_h_apply_buffer_selection` .. c:function:: routine_example_psi_det: @@ -6740,11 +7099,11 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_coef` - * :c:data:`psi_det` - * :c:data:`n_states` * :c:data:`n_det` * :c:data:`n_int` + * :c:data:`n_states` + * :c:data:`psi_coef` + * :c:data:`psi_det` Called by: @@ -6806,6 +7165,7 @@ Subroutines / functions .. hlist:: :columns: 3 + * :c:data:`n_int` * :c:data:`ref_bitmask_energy` Called by: @@ -6839,18 +7199,22 @@ Subroutines / functions Save natural orbitals, obtained by diagonalization of the one-body density matrix in the |MO| basis - Called by: + Needs: .. hlist:: :columns: 3 - * :c:func:`save_natorb` + * :c:data:`ao_num` + * :c:data:`mo_coef` + * :c:data:`mo_num` Calls: .. hlist:: :columns: 3 + * :c:func:`nullify_small_elements` + * :c:func:`orthonormalize_mos` * :c:func:`save_mos` * :c:func:`set_natural_mos` @@ -6859,6 +7223,7 @@ Subroutines / functions .. hlist:: :columns: 3 + * :c:data:`mo_coef` * :c:data:`mo_occ` @@ -6881,13 +7246,6 @@ Subroutines / functions * :c:data:`n_states` * :c:data:`ref_bitmask` - Called by: - - .. hlist:: - :columns: 3 - - * :c:func:`save_natorb` - Calls: .. hlist:: @@ -6913,20 +7271,11 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`read_wf` + * :c:data:`mpi_master` + * :c:data:`n_det` * :c:data:`n_states` * :c:data:`psi_det_sorted` - * :c:data:`n_det` - * :c:data:`mpi_master` - - Called by: - - .. hlist:: - :columns: 3 - - * :c:func:`run_cipsi` - * :c:func:`run_stochastic_cipsi` - * :c:func:`zmq_selection` + * :c:data:`read_wf` Calls: @@ -6953,9 +7302,10 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`mpi_master` - * :c:data:`n_int` * :c:data:`mo_label` + * :c:data:`mpi_master` + * :c:data:`n_det_qp_edit` + * :c:data:`n_int` Called by: @@ -6975,10 +7325,13 @@ Subroutines / functions * :c:func:`ezfio_set_determinants_bit_kind` * :c:func:`ezfio_set_determinants_mo_label` * :c:func:`ezfio_set_determinants_n_det` + * :c:func:`ezfio_set_determinants_n_det_qp_edit` * :c:func:`ezfio_set_determinants_n_int` * :c:func:`ezfio_set_determinants_n_states` * :c:func:`ezfio_set_determinants_psi_coef` + * :c:func:`ezfio_set_determinants_psi_coef_qp_edit` * :c:func:`ezfio_set_determinants_psi_det` + * :c:func:`ezfio_set_determinants_psi_det_qp_edit` * :c:func:`normalize` * :c:func:`write_int` @@ -7000,8 +7353,10 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_int` * :c:data:`mo_label` + * :c:data:`mpi_master` + * :c:data:`n_det_qp_edit` + * :c:data:`n_int` Calls: @@ -7011,10 +7366,12 @@ Subroutines / functions * :c:func:`ezfio_set_determinants_bit_kind` * :c:func:`ezfio_set_determinants_mo_label` * :c:func:`ezfio_set_determinants_n_det` + * :c:func:`ezfio_set_determinants_n_det_qp_edit` * :c:func:`ezfio_set_determinants_n_int` * :c:func:`ezfio_set_determinants_n_states` * :c:func:`ezfio_set_determinants_psi_coef` * :c:func:`ezfio_set_determinants_psi_det` + * :c:func:`ezfio_set_determinants_psi_det_qp_edit` * :c:func:`write_int` @@ -7035,18 +7392,27 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_states` - * :c:data:`psi_det_sorted` - * :c:data:`n_det` * :c:data:`mpi_master` + * :c:data:`n_det` + * :c:data:`n_states` + * :c:data:`psi_coef` + * :c:data:`psi_det_sorted` Calls: .. hlist:: :columns: 3 + * :c:func:`nullify_small_elements` * :c:func:`save_wavefunction_general` + Touches: + + .. hlist:: + :columns: 3 + + * :c:data:`psi_coef` + .. c:function:: save_wavefunction_unsorted: @@ -7065,11 +7431,11 @@ Subroutines / functions .. hlist:: :columns: 3 + * :c:data:`mpi_master` + * :c:data:`n_det` + * :c:data:`n_states` * :c:data:`psi_coef` * :c:data:`psi_det` - * :c:data:`n_states` - * :c:data:`n_det` - * :c:data:`mpi_master` Calls: @@ -7097,9 +7463,13 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`mo_occ` - * :c:data:`one_e_dm_mo` + * :c:data:`list_core_inact_act` + * :c:data:`list_virt` * :c:data:`mo_num` + * :c:data:`mo_occ` + * :c:data:`n_core_inact_act_orb` + * :c:data:`n_virt_orb` + * :c:data:`one_e_dm_mo` Called by: @@ -7139,10 +7509,10 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`ref_closed_shell_bitmask` - * :c:data:`fock_wee_closed_shell` * :c:data:`big_array_coulomb_integrals` + * :c:data:`fock_wee_closed_shell` * :c:data:`n_int` + * :c:data:`ref_closed_shell_bitmask` Called by: @@ -7324,13 +7694,6 @@ Subroutines / functions n : number of determinants - Needs: - - .. hlist:: - :columns: 3 - - * :c:data:`s_z` - Called by: .. hlist:: @@ -7365,16 +7728,23 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_coef` - * :c:data:`psi_det_beta_unique` - * :c:data:`psi_det_alpha_unique` - * :c:data:`n_states` * :c:data:`n_det` - * :c:data:`psi_bilinear_matrix_values` * :c:data:`n_int` + * :c:data:`n_states` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_coef` * :c:data:`psi_det` + * :c:data:`psi_det_alpha_unique` + * :c:data:`psi_det_beta_unique` * :c:data:`psi_det_sorted` + Called by: + + .. hlist:: + :columns: 3 + + * :c:func:`read_spindeterminants` + Touches: .. hlist:: @@ -7401,12 +7771,12 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_det_beta_unique` - * :c:data:`psi_det_alpha_unique` - * :c:data:`n_states` * :c:data:`n_det` - * :c:data:`psi_bilinear_matrix_values` * :c:data:`n_int` + * :c:data:`n_states` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_det_alpha_unique` + * :c:data:`psi_det_beta_unique` Calls: @@ -7443,9 +7813,9 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`zmq_state` - * :c:data:`n_det` * :c:data:`mpi_master` + * :c:data:`n_det` + * :c:data:`zmq_state` .. c:function:: zmq_get_n_det_alpha_unique: @@ -7465,9 +7835,9 @@ Subroutines / functions .. hlist:: :columns: 3 + * :c:data:`mpi_master` * :c:data:`psi_det_alpha_unique` * :c:data:`zmq_state` - * :c:data:`mpi_master` .. c:function:: zmq_get_n_det_beta_unique: @@ -7487,9 +7857,9 @@ Subroutines / functions .. hlist:: :columns: 3 + * :c:data:`mpi_master` * :c:data:`psi_det_beta_unique` * :c:data:`zmq_state` - * :c:data:`mpi_master` .. c:function:: zmq_get_n_states: @@ -7509,9 +7879,9 @@ Subroutines / functions .. hlist:: :columns: 3 + * :c:data:`mpi_master` * :c:data:`n_states` * :c:data:`zmq_state` - * :c:data:`mpi_master` .. c:function:: zmq_get_psi: @@ -7531,10 +7901,10 @@ Subroutines / functions .. hlist:: :columns: 3 + * :c:data:`n_det` + * :c:data:`n_states` * :c:data:`psi_coef` * :c:data:`psi_det` - * :c:data:`n_states` - * :c:data:`n_det` * :c:data:`psi_det_size` Touches: @@ -7566,19 +7936,19 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_coef` - * :c:data:`psi_det_beta_unique` - * :c:data:`psi_bilinear_matrix_values` - * :c:data:`psi_det_alpha_unique` - * :c:data:`n_states` - * :c:data:`psi_bilinear_matrix_values` - * :c:data:`psi_bilinear_matrix_values` * :c:data:`n_det` * :c:data:`psi_det_alpha_unique` * :c:data:`psi_det_beta_unique` - * :c:data:`psi_det_size` - * :c:data:`psi_det` + * :c:data:`n_states` * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_bilinear_matrix_values` + * :c:data:`psi_coef` + * :c:data:`psi_det` + * :c:data:`psi_det_alpha_unique` + * :c:data:`psi_det_beta_unique` + * :c:data:`psi_det_size` Touches: @@ -7777,9 +8147,9 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`zmq_state` - * :c:data:`psi_det_size` * :c:data:`mpi_master` + * :c:data:`psi_det_size` + * :c:data:`zmq_state` .. c:function:: zmq_get_psi_notouch: @@ -7799,10 +8169,10 @@ Subroutines / functions .. hlist:: :columns: 3 + * :c:data:`n_int` + * :c:data:`n_states` * :c:data:`psi_coef` * :c:data:`psi_det` - * :c:data:`n_states` - * :c:data:`n_int` * :c:data:`psi_det_size` @@ -7823,8 +8193,8 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`zmq_state` * :c:data:`n_det` + * :c:data:`zmq_state` .. c:function:: zmq_put_n_det_alpha_unique: @@ -8093,6 +8463,6 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`zmq_state` * :c:data:`psi_det_size` + * :c:data:`zmq_state` diff --git a/docs/source/modules/dft_keywords.rst b/docs/source/modules/dft_keywords.rst index f1493bda..95e6b9cc 100644 --- a/docs/source/modules/dft_keywords.rst +++ b/docs/source/modules/dft_keywords.rst @@ -107,10 +107,4 @@ Providers * :c:data:`correlation_functional` * :c:data:`exchange_functional` - Needed by: - - .. hlist:: - :columns: 3 - - * :c:data:`ao_potential_alpha_xc` diff --git a/docs/source/modules/electrons.rst b/docs/source/modules/electrons.rst index 5945ef08..416761a9 100644 --- a/docs/source/modules/electrons.rst +++ b/docs/source/modules/electrons.rst @@ -76,7 +76,6 @@ Providers * :c:data:`diagonal_h_matrix_on_psi_det` * :c:data:`psi_det_hii` - * :c:data:`psi_selectors_diag_h_mat` .. c:var:: elec_num_tab @@ -108,5 +107,4 @@ Providers * :c:data:`diagonal_h_matrix_on_psi_det` * :c:data:`psi_det_hii` - * :c:data:`psi_selectors_diag_h_mat` diff --git a/docs/source/modules/fci.rst b/docs/source/modules/fci.rst index 2d2bb639..76f70bc5 100644 --- a/docs/source/modules/fci.rst +++ b/docs/source/modules/fci.rst @@ -97,6 +97,7 @@ Providers .. code:: fortran logical :: do_only_1h1p + logical :: do_only_cas logical :: do_ddci @@ -112,6 +113,23 @@ Providers .. code:: fortran logical :: do_only_1h1p + logical :: do_only_cas + logical :: do_ddci + + + In the FCI case, all those are always false + + + +.. c:var:: do_only_cas + + + File : :file:`fci/class.irp.f` + + .. code:: fortran + + logical :: do_only_1h1p + logical :: do_only_cas logical :: do_ddci diff --git a/docs/source/modules/hartree_fock.rst b/docs/source/modules/hartree_fock.rst index 415c8973..7513caac 100644 --- a/docs/source/modules/hartree_fock.rst +++ b/docs/source/modules/hartree_fock.rst @@ -86,8 +86,10 @@ Providers * :c:data:`ao_two_e_integral_schwartz` * :c:data:`ao_two_e_integrals_in_map` * :c:data:`do_direct_integrals` + * :c:data:`is_periodic` * :c:data:`n_pt_max_integrals` * :c:data:`nucl_coord` + * :c:data:`read_ao_two_e_integrals` * :c:data:`scf_density_matrix_ao_alpha` * :c:data:`scf_density_matrix_ao_beta` @@ -130,8 +132,10 @@ Providers * :c:data:`ao_two_e_integral_schwartz` * :c:data:`ao_two_e_integrals_in_map` * :c:data:`do_direct_integrals` + * :c:data:`is_periodic` * :c:data:`n_pt_max_integrals` * :c:data:`nucl_coord` + * :c:data:`read_ao_two_e_integrals` * :c:data:`scf_density_matrix_ao_alpha` * :c:data:`scf_density_matrix_ao_beta` @@ -339,12 +343,14 @@ Subroutines / functions .. hlist:: :columns: 3 + * :c:data:`ao_num` + * :c:data:`ao_ortho_lowdin_coef` * :c:data:`ezfio_filename` * :c:data:`mo_coef` * :c:data:`mo_guess_type` - * :c:data:`mo_one_e_integrals` - * :c:data:`ao_ortho_lowdin_coef` * :c:data:`mo_label` + * :c:data:`mo_num` + * :c:data:`mo_one_e_integrals` Called by: @@ -361,6 +367,7 @@ Subroutines / functions * :c:func:`ezfio_has_mo_basis_mo_coef` * :c:func:`huckel_guess` * :c:func:`mo_as_eigvectors_of_mo_matrix` + * :c:func:`restore_symmetry` Touches: @@ -372,51 +379,3 @@ Subroutines / functions * :c:data:`mo_coef` * :c:data:`mo_label` - -.. c:function:: run: - - - File : :file:`hartree_fock/scf.irp.f` - - .. code:: fortran - - subroutine run - - - Run SCF calculation - - Needs: - - .. hlist:: - :columns: 3 - - * :c:data:`scf_energy` - * :c:data:`mo_label` - - Called by: - - .. hlist:: - :columns: 3 - - * :c:func:`pt2` - * :c:func:`scf` - - Calls: - - .. hlist:: - :columns: 3 - - * :c:func:`ezfio_set_hartree_fock_energy` - * :c:func:`roothaan_hall_scf` - - Touches: - - .. hlist:: - :columns: 3 - - * :c:data:`fock_matrix_ao_alpha` - * :c:data:`fock_matrix_ao_alpha` - * :c:data:`mo_coef` - * :c:data:`level_shift` - * :c:data:`mo_coef` - diff --git a/docs/source/modules/iterations.rst b/docs/source/modules/iterations.rst index 81adc6a9..2d625419 100644 --- a/docs/source/modules/iterations.rst +++ b/docs/source/modules/iterations.rst @@ -118,10 +118,10 @@ Subroutines / functions :columns: 3 * :c:data:`extrapolated_energy` - * :c:data:`n_states` * :c:data:`n_det` - * :c:data:`pt2_iterations` * :c:data:`n_iter` + * :c:data:`n_states` + * :c:data:`pt2_iterations` Called by: @@ -139,7 +139,7 @@ Subroutines / functions .. code:: fortran - subroutine print_summary(e_,pt2_,error_,variance_,norm_,n_det_,n_occ_pattern_,n_st,s2_) + subroutine print_summary(e_,pt2_data,pt2_data_err,n_det_,n_occ_pattern_,n_st,s2_) Print the extrapolated energy in the output @@ -185,11 +185,11 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_iter` * :c:data:`energy_iterations` + * :c:data:`n_det_iterations` + * :c:data:`n_iter` * :c:data:`n_states` * :c:data:`pt2_iterations` - * :c:data:`n_det_iterations` Called by: diff --git a/docs/source/modules/kohn_sham_rs.rst b/docs/source/modules/kohn_sham_rs.rst index e99f6af5..d32fca3f 100644 --- a/docs/source/modules/kohn_sham_rs.rst +++ b/docs/source/modules/kohn_sham_rs.rst @@ -461,8 +461,8 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`exchange_functional` * :c:data:`correlation_functional` + * :c:data:`exchange_functional` Called by: diff --git a/docs/source/modules/mo_basis.rst b/docs/source/modules/mo_basis.rst index 1c6e3c66..3dde0f19 100644 --- a/docs/source/modules/mo_basis.rst +++ b/docs/source/modules/mo_basis.rst @@ -68,6 +68,49 @@ EZFIO parameters Providers --------- +.. c:var:: mo_class + + + File : :file:`mo_basis/mo_class.irp.f` + + .. code:: fortran + + character*(32), allocatable :: mo_class (mo_num) + + + [ Core | Inactive | Active | Virtual | Deleted ], as defined by :ref:`qp_set_mo_class` + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`ezfio_filename` + * :c:data:`mo_num` + * :c:data:`mpi_master` + * :c:data:`output_wall_time_0` + + Needed by: + + .. hlist:: + :columns: 3 + + * :c:data:`full_ijkl_bitmask` + * :c:data:`list_act` + * :c:data:`list_all_but_del_orb` + * :c:data:`list_core` + * :c:data:`list_del` + * :c:data:`list_inact` + * :c:data:`list_virt` + * :c:data:`mo_two_e_integrals_in_map` + * :c:data:`n_act_orb` + * :c:data:`n_all_but_del_orb` + * :c:data:`n_core_orb` + * :c:data:`n_del_orb` + * :c:data:`n_inact_orb` + * :c:data:`n_virt_orb` + + .. c:var:: mo_coef @@ -100,11 +143,8 @@ Providers .. hlist:: :columns: 3 - * :c:data:`eigenvectors_fock_matrix_mo` - * :c:data:`fock_matrix_mo_alpha` - * :c:data:`fock_matrix_mo_beta` - * :c:data:`fps_spf_matrix_mo` * :c:data:`mo_coef_in_ao_ortho_basis` + * :c:data:`mo_coef_novirt` * :c:data:`mo_coef_transp` * :c:data:`mo_dipole_x` * :c:data:`mo_integrals_n_e` @@ -113,32 +153,34 @@ Providers * :c:data:`mo_overlap` * :c:data:`mo_pseudo_integrals` * :c:data:`mo_spread_x` - * :c:data:`mo_two_e_int_erf_jj_from_ao` * :c:data:`mo_two_e_integral_jj_from_ao` - * :c:data:`mo_two_e_integrals_erf_in_map` * :c:data:`mo_two_e_integrals_in_map` * :c:data:`mo_two_e_integrals_vv_from_ao` + * :c:data:`one_e_dm_alpha_ao_for_dft` + * :c:data:`one_e_dm_alpha_ao_for_dft_no_core` * :c:data:`one_e_dm_ao_alpha` + * :c:data:`one_e_dm_mo_alpha_for_dft` + * :c:data:`one_e_dm_mo_beta_for_dft` * :c:data:`one_e_spin_density_ao` * :c:data:`psi_det` * :c:data:`s_mo_coef` - * :c:data:`scf_density_matrix_ao_alpha` - * :c:data:`scf_density_matrix_ao_beta` -.. c:var:: mo_coef_begin_iteration +.. c:var:: mo_coef_imag - File : :file:`mo_basis/track_orb.irp.f` + File : :file:`mo_basis/mos.irp.f` .. code:: fortran - double precision, allocatable :: mo_coef_begin_iteration (ao_num,mo_num) + double precision, allocatable :: mo_coef_imag (ao_num,mo_num) - Void provider to store the coefficients of the |MO| basis at the beginning of the SCF iteration + Molecular orbital coefficients on |AO| basis set - Usefull to track some orbitals + mo_coef_imag(i,j) = coefficient of the i-th |AO| on the jth |MO| + + mo_label : Label characterizing the |MOs| (local, canonical, natural, etc) Needs: @@ -146,7 +188,9 @@ Providers :columns: 3 * :c:data:`ao_num` + * :c:data:`ezfio_filename` * :c:data:`mo_num` + * :c:data:`mpi_master` @@ -202,9 +246,7 @@ Providers .. hlist:: :columns: 3 - * :c:data:`mo_two_e_int_erf_jj_from_ao` * :c:data:`mo_two_e_integral_jj_from_ao` - * :c:data:`mo_two_e_integrals_erf_in_map` * :c:data:`mo_two_e_integrals_in_map` * :c:data:`mo_two_e_integrals_vv_from_ao` @@ -269,33 +311,31 @@ Providers .. hlist:: :columns: 3 - * :c:data:`ao_ortho_canonical_nucl_elec_integrals` - * :c:data:`ao_ortho_lowdin_nucl_elec_integrals` + * :c:data:`banned_excitation` * :c:data:`big_array_coulomb_integrals` * :c:data:`core_fock_operator` - * :c:data:`core_fock_operator_erf` * :c:data:`data_one_e_dm_alpha_mo` * :c:data:`data_one_e_dm_beta_mo` - * :c:data:`eigenvectors_fock_matrix_mo` - * :c:data:`fock_matrix_ao` - * :c:data:`fock_matrix_mo` - * :c:data:`fock_matrix_mo_alpha` - * :c:data:`fock_matrix_mo_beta` * :c:data:`fock_operator_closed_shell_ref_bitmask` * :c:data:`fock_wee_closed_shell` - * :c:data:`fps_spf_matrix_mo` * :c:data:`full_ijkl_bitmask` - * :c:data:`int_erf_3_index` + * :c:data:`list_act` + * :c:data:`list_all_but_del_orb` + * :c:data:`list_core` + * :c:data:`list_core_inact` + * :c:data:`list_core_inact_act` + * :c:data:`list_del` * :c:data:`list_inact` + * :c:data:`list_inact_act` + * :c:data:`list_virt` * :c:data:`mo_class` * :c:data:`mo_coef` * :c:data:`mo_coef_begin_iteration` + * :c:data:`mo_coef_imag` * :c:data:`mo_coef_in_ao_ortho_basis` * :c:data:`mo_coef_transp` * :c:data:`mo_dipole_x` * :c:data:`mo_integrals_cache_min` - * :c:data:`mo_integrals_erf_cache_min` - * :c:data:`mo_integrals_erf_map` * :c:data:`mo_integrals_map` * :c:data:`mo_integrals_n_e` * :c:data:`mo_integrals_n_e_per_atom` @@ -305,21 +345,34 @@ Providers * :c:data:`mo_overlap` * :c:data:`mo_pseudo_integrals` * :c:data:`mo_spread_x` - * :c:data:`mo_two_e_int_erf_jj` - * :c:data:`mo_two_e_int_erf_jj_from_ao` * :c:data:`mo_two_e_integral_jj_from_ao` - * :c:data:`mo_two_e_integrals_erf_in_map` * :c:data:`mo_two_e_integrals_in_map` * :c:data:`mo_two_e_integrals_jj` * :c:data:`mo_two_e_integrals_vv_from_ao` + * :c:data:`n_act_orb` + * :c:data:`n_all_but_del_orb` * :c:data:`n_core_orb` + * :c:data:`n_del_orb` + * :c:data:`n_inact_orb` * :c:data:`n_int` + * :c:data:`n_virt_orb` + * :c:data:`one_body_dm_mo_alpha_one_det` + * :c:data:`one_e_dm_alpha_ao_for_dft` + * :c:data:`one_e_dm_alpha_ao_for_dft_no_core` * :c:data:`one_e_dm_ao_alpha` + * :c:data:`one_e_dm_average_alpha_mo_for_dft` + * :c:data:`one_e_dm_average_beta_mo_for_dft` + * :c:data:`one_e_dm_average_mo_for_dft` * :c:data:`one_e_dm_dagger_mo_spin_index` * :c:data:`one_e_dm_mo` * :c:data:`one_e_dm_mo_alpha` * :c:data:`one_e_dm_mo_alpha_average` + * :c:data:`one_e_dm_mo_alpha_for_dft` + * :c:data:`one_e_dm_mo_alpha_for_dft_no_core` + * :c:data:`one_e_dm_mo_beta_for_dft` + * :c:data:`one_e_dm_mo_beta_for_dft_no_core` * :c:data:`one_e_dm_mo_diff` + * :c:data:`one_e_dm_mo_for_dft` * :c:data:`one_e_dm_mo_spin_index` * :c:data:`one_e_spin_density_ao` * :c:data:`one_e_spin_density_mo` @@ -408,23 +461,23 @@ Subroutines / functions :columns: 3 * :c:data:`ao_num` - * :c:data:`mo_num` * :c:data:`mo_coef` + * :c:data:`mo_num` Called by: .. hlist:: :columns: 3 - * :c:data:`fock_matrix_mo_alpha` - * :c:data:`fock_matrix_mo_beta` - * :c:data:`fps_spf_matrix_mo` + * :c:func:`four_idx_novvvv` * :c:data:`mo_dipole_x` * :c:data:`mo_integrals_n_e` * :c:data:`mo_integrals_n_e_per_atom` * :c:data:`mo_kinetic_integrals` * :c:data:`mo_pseudo_integrals` * :c:data:`mo_spread_x` + * :c:data:`one_e_dm_mo_alpha_for_dft` + * :c:data:`one_e_dm_mo_beta_for_dft` Calls: @@ -432,6 +485,7 @@ Subroutines / functions :columns: 3 * :c:func:`dgemm` + * :c:func:`restore_symmetry` .. c:function:: give_all_mos_and_grad_and_lapl_at_r: @@ -451,8 +505,8 @@ Subroutines / functions :columns: 3 * :c:data:`ao_num` - * :c:data:`mo_num` * :c:data:`mo_coef` + * :c:data:`mo_num` Calls: @@ -479,8 +533,8 @@ Subroutines / functions :columns: 3 * :c:data:`ao_num` - * :c:data:`mo_num` * :c:data:`mo_coef` + * :c:data:`mo_num` Calls: @@ -507,8 +561,8 @@ Subroutines / functions :columns: 3 * :c:data:`ao_num` - * :c:data:`mo_num` * :c:data:`mo_coef_transp` + * :c:data:`mo_num` Calls: @@ -519,36 +573,6 @@ Subroutines / functions * :c:func:`give_all_aos_at_r` -.. c:function:: initialize_mo_coef_begin_iteration: - - - File : :file:`mo_basis/track_orb.irp.f` - - .. code:: fortran - - subroutine initialize_mo_coef_begin_iteration - - - - Initialize :c:data:`mo_coef_begin_iteration` to the current :c:data:`mo_coef` - - Needs: - - .. hlist:: - :columns: 3 - - * :c:data:`mo_coef_begin_iteration` - * :c:data:`mo_coef` - - Called by: - - .. hlist:: - :columns: 3 - - * :c:func:`damping_scf` - * :c:func:`roothaan_hall_scf` - - .. c:function:: mix_mo_jk: @@ -593,20 +617,10 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`mo_label` * :c:data:`ao_num` - * :c:data:`mo_num` * :c:data:`mo_coef` - - Called by: - - .. hlist:: - :columns: 3 - - * :c:func:`create_guess` - * :c:func:`damping_scf` - * :c:func:`hcore_guess` - * :c:func:`roothaan_hall_scf` + * :c:data:`mo_label` + * :c:data:`mo_num` Calls: @@ -634,10 +648,10 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`mo_label` * :c:data:`ao_num` - * :c:data:`mo_num` * :c:data:`mo_coef` + * :c:data:`mo_label` + * :c:data:`mo_num` Calls: @@ -665,10 +679,10 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`mo_label` * :c:data:`ao_num` - * :c:data:`mo_num` * :c:data:`mo_coef` + * :c:data:`mo_label` + * :c:data:`mo_num` Called by: @@ -687,45 +701,36 @@ Subroutines / functions * :c:func:`write_time` -.. c:function:: reorder_core_orb: +.. c:function:: mo_coef_new_as_svd_vectors_of_mo_matrix_eig: - File : :file:`mo_basis/track_orb.irp.f` + File : :file:`mo_basis/utils.irp.f` .. code:: fortran - subroutine reorder_core_orb + subroutine mo_coef_new_as_svd_vectors_of_mo_matrix_eig(matrix,lda,m,n,mo_coef_before,eig,mo_coef_new) - routines that takes the current :c:data:`mo_coef` and reorder the core orbitals (see :c:data:`list_core` and :c:data:`n_core_orb`) according to the overlap with :c:data:`mo_coef_begin_iteration` + You enter with matrix in the MO basis defined with the mo_coef_before. + + You SVD the matrix and set the eigenvectors as mo_coef_new ordered by increasing singular values Needs: .. hlist:: :columns: 3 - * :c:data:`mo_num` - * :c:data:`mo_coef_begin_iteration` - * :c:data:`mo_coef` - * :c:data:`ao_overlap` - * :c:data:`n_core_orb` * :c:data:`ao_num` - * :c:data:`list_inact` - - Called by: - - .. hlist:: - :columns: 3 - - * :c:func:`damping_scf` - * :c:func:`roothaan_hall_scf` + * :c:data:`mo_num` Calls: .. hlist:: :columns: 3 - * :c:func:`dsort` + * :c:func:`dgemm` + * :c:func:`svd` + * :c:func:`write_time` .. c:function:: save_mos: @@ -744,28 +749,21 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`mo_occ` * :c:data:`ao_md5` - * :c:data:`ezfio_filename` - * :c:data:`mo_num` - * :c:data:`mo_coef` * :c:data:`ao_num` + * :c:data:`ezfio_filename` + * :c:data:`mo_class` + * :c:data:`mo_coef` * :c:data:`mo_label` + * :c:data:`mo_num` + * :c:data:`mo_occ` Called by: .. hlist:: :columns: 3 - * :c:func:`damping_scf` - * :c:func:`hcore_guess` - * :c:func:`huckel_guess` - * :c:func:`roothaan_hall_scf` - * :c:func:`rotate_mos` * :c:func:`save_natural_mos` - * :c:func:`save_ortho_mos` - * :c:func:`sort_by_fock_energies` - * :c:func:`swap_mos` Calls: @@ -773,6 +771,7 @@ Subroutines / functions :columns: 3 * :c:func:`ezfio_set_mo_basis_ao_md5` + * :c:func:`ezfio_set_mo_basis_mo_class` * :c:func:`ezfio_set_mo_basis_mo_coef` * :c:func:`ezfio_set_mo_basis_mo_label` * :c:func:`ezfio_set_mo_basis_mo_num` @@ -780,6 +779,36 @@ Subroutines / functions * :c:func:`system` +.. c:function:: save_mos_no_occ: + + + File : :file:`mo_basis/utils.irp.f` + + .. code:: fortran + + subroutine save_mos_no_occ + + + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`ao_num` + * :c:data:`ezfio_filename` + * :c:data:`mo_coef` + * :c:data:`mo_num` + + Calls: + + .. hlist:: + :columns: 3 + + * :c:func:`ezfio_set_mo_basis_mo_coef` + * :c:func:`system` + + .. c:function:: save_mos_truncated: @@ -796,12 +825,13 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`mo_occ` * :c:data:`ao_md5` - * :c:data:`ezfio_filename` - * :c:data:`mo_coef` * :c:data:`ao_num` + * :c:data:`ezfio_filename` + * :c:data:`mo_class` + * :c:data:`mo_coef` * :c:data:`mo_label` + * :c:data:`mo_occ` Calls: @@ -809,6 +839,7 @@ Subroutines / functions :columns: 3 * :c:func:`ezfio_set_mo_basis_ao_md5` + * :c:func:`ezfio_set_mo_basis_mo_class` * :c:func:`ezfio_set_mo_basis_mo_coef` * :c:func:`ezfio_set_mo_basis_mo_label` * :c:func:`ezfio_set_mo_basis_mo_num` diff --git a/docs/source/modules/mo_one_e_ints.rst b/docs/source/modules/mo_one_e_ints.rst index 68a1f7b3..1b90c675 100644 --- a/docs/source/modules/mo_one_e_ints.rst +++ b/docs/source/modules/mo_one_e_ints.rst @@ -176,7 +176,7 @@ Providers * :c:data:`ao_num` * :c:data:`mo_coef` * :c:data:`mo_num` - * :c:data:`read_mo_integrals_e_n` + * :c:data:`read_mo_integrals_n_e` Needed by: @@ -264,11 +264,9 @@ Providers .. hlist:: :columns: 3 - * :c:data:`do_pseudo` * :c:data:`mo_integrals_n_e` * :c:data:`mo_kinetic_integrals` * :c:data:`mo_num` - * :c:data:`mo_pseudo_integrals` * :c:data:`read_mo_one_e_integrals` Needed by: @@ -277,7 +275,6 @@ Providers :columns: 3 * :c:data:`core_energy` - * :c:data:`core_energy_erf` * :c:data:`fock_operator_closed_shell_ref_bitmask` * :c:data:`psi_energy_h_core` * :c:data:`ref_bitmask_energy` @@ -331,12 +328,6 @@ Providers * :c:data:`mo_num` * :c:data:`read_mo_integrals_pseudo` - Needed by: - - .. hlist:: - :columns: 3 - - * :c:data:`mo_one_e_integrals` .. c:var:: mo_spread_x @@ -445,12 +436,6 @@ Providers * :c:data:`mo_coef` * :c:data:`mo_num` - Needed by: - - .. hlist:: - :columns: 3 - - * :c:data:`fock_matrix_ao` @@ -477,15 +462,8 @@ Subroutines / functions :columns: 3 * :c:data:`ao_num` - * :c:data:`s_mo_coef` * :c:data:`mo_num` - - Called by: - - .. hlist:: - :columns: 3 - - * :c:data:`fock_matrix_ao` + * :c:data:`s_mo_coef` Calls: @@ -513,8 +491,16 @@ Subroutines / functions :columns: 3 * :c:data:`ao_num` - * :c:data:`mo_num` * :c:data:`mo_coef` + * :c:data:`mo_num` + + Called by: + + .. hlist:: + :columns: 3 + + * :c:data:`one_e_dm_alpha_ao_for_dft` + * :c:data:`one_e_dm_alpha_ao_for_dft_no_core` Calls: @@ -540,26 +526,27 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`mo_label` * :c:data:`ao_num` - * :c:data:`mo_overlap` - * :c:data:`mo_num` + * :c:data:`lin_dep_cutoff` * :c:data:`mo_coef` + * :c:data:`mo_num` + * :c:data:`mo_overlap` Called by: .. hlist:: :columns: 3 - * :c:func:`save_ortho_mos` - * :c:func:`scf` + * :c:func:`save_natural_mos` Calls: .. hlist:: :columns: 3 + * :c:func:`nullify_small_elements` * :c:func:`ortho_lowdin` + * :c:func:`restore_symmetry` Touches: @@ -567,5 +554,4 @@ Subroutines / functions :columns: 3 * :c:data:`mo_coef` - * :c:data:`mo_label` diff --git a/docs/source/modules/mo_two_e_erf_ints.rst b/docs/source/modules/mo_two_e_erf_ints.rst index 7e85039b..ca619a9c 100644 --- a/docs/source/modules/mo_two_e_erf_ints.rst +++ b/docs/source/modules/mo_two_e_erf_ints.rst @@ -57,7 +57,7 @@ Providers .. hlist:: :columns: 3 - * :c:data:`list_inact` + * :c:data:`list_core` * :c:data:`mo_one_e_integrals` * :c:data:`mo_two_e_int_erf_jj` * :c:data:`n_core_orb` @@ -82,12 +82,14 @@ Providers .. hlist:: :columns: 3 - * :c:data:`list_inact` + * :c:data:`list_act` + * :c:data:`list_core` * :c:data:`mo_integrals_erf_cache` * :c:data:`mo_integrals_erf_cache_min` * :c:data:`mo_integrals_erf_map` * :c:data:`mo_num` * :c:data:`mo_two_e_integrals_erf_in_map` + * :c:data:`n_act_orb` * :c:data:`n_core_orb` @@ -403,7 +405,6 @@ Providers * :c:data:`ao_integrals_erf_map` * :c:data:`ao_integrals_threshold` * :c:data:`ao_num` - * :c:data:`ao_overlap_abs` * :c:data:`ao_two_e_integral_erf_schwartz` * :c:data:`ao_two_e_integrals_erf_in_map` * :c:data:`do_direct_integrals` @@ -472,7 +473,6 @@ Providers * :c:data:`ao_integrals_erf_map` * :c:data:`ao_integrals_threshold` * :c:data:`ao_num` - * :c:data:`ao_overlap_abs` * :c:data:`ao_two_e_integral_erf_schwartz` * :c:data:`ao_two_e_integrals_erf_in_map` * :c:data:`do_direct_integrals` @@ -506,7 +506,6 @@ Providers * :c:data:`ao_integrals_erf_map` * :c:data:`ao_integrals_threshold` * :c:data:`ao_num` - * :c:data:`ao_overlap_abs` * :c:data:`ao_two_e_integral_erf_schwartz` * :c:data:`ao_two_e_integrals_erf_in_map` * :c:data:`do_direct_integrals` @@ -578,14 +577,14 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`mo_coef` - * :c:data:`mo_integrals_threshold` - * :c:data:`mo_coef_transp` * :c:data:`ao_num` - * :c:data:`n_int` - * :c:data:`mo_num` * :c:data:`ao_two_e_integrals_in_map` + * :c:data:`mo_coef` + * :c:data:`mo_coef_transp` * :c:data:`mo_integrals_erf_map` + * :c:data:`mo_integrals_threshold` + * :c:data:`mo_num` + * :c:data:`n_int` Called by: @@ -796,8 +795,8 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`mo_two_e_integrals_erf_in_map` * :c:data:`mo_integrals_erf_map` + * :c:data:`mo_two_e_integrals_erf_in_map` Calls: @@ -830,8 +829,8 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`mo_two_e_integrals_erf_in_map` * :c:data:`mo_integrals_erf_map` + * :c:data:`mo_two_e_integrals_erf_in_map` Calls: @@ -925,11 +924,11 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`mo_two_e_integrals_erf_in_map` - * :c:data:`mo_two_e_int_erf_jj` - * :c:data:`mo_two_e_int_erf_jj` * :c:data:`mo_integrals_erf_map` * :c:data:`mo_two_e_int_erf_jj` + * :c:data:`mo_two_e_int_erf_jj` + * :c:data:`mo_two_e_int_erf_jj` + * :c:data:`mo_two_e_integrals_erf_in_map` .. c:function:: save_erf_two_e_integrals_mo: @@ -948,9 +947,9 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`mo_two_e_integrals_erf_in_map` * :c:data:`ezfio_filename` * :c:data:`mo_integrals_erf_map` + * :c:data:`mo_two_e_integrals_erf_in_map` Called by: @@ -985,9 +984,9 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`mo_two_e_integrals_erf_in_map` * :c:data:`ezfio_filename` * :c:data:`mo_integrals_erf_map` + * :c:data:`mo_two_e_integrals_erf_in_map` Calls: diff --git a/docs/source/modules/mo_two_e_ints.rst b/docs/source/modules/mo_two_e_ints.rst index bb860e59..a08e3868 100644 --- a/docs/source/modules/mo_two_e_ints.rst +++ b/docs/source/modules/mo_two_e_ints.rst @@ -43,28 +43,40 @@ EZFIO parameters Default: 1.e-15 -.. option:: no_vvvv_integrals - - If `True`, computes all integrals except for the integrals having 4 virtual indices - - Default: False - -.. option:: no_ivvv_integrals - - Can be switched on only if `no_vvvv_integrals` is `True`, then does not compute the integrals with 3 virtual indices and 1 belonging to the core inactive active orbitals - - Default: False - -.. option:: no_vvv_integrals - - Can be switched on only if `no_vvvv_integrals` is `True`, then does not compute the integrals with 3 virtual orbitals - - Default: False - Providers --------- +.. c:var:: banned_excitation + + + File : :file:`mo_two_e_ints/map_integrals.irp.f` + + .. code:: fortran + + logical, allocatable :: banned_excitation (mo_num,mo_num) + + + If true, the excitation is banned in the selection. Useful with local MOs. + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`mo_integrals_map` + * :c:data:`mo_num` + + Needed by: + + .. hlist:: + :columns: 3 + + * :c:data:`big_array_coulomb_integrals` + * :c:data:`core_fock_operator` + * :c:data:`mo_two_e_integrals_jj` + + .. c:var:: big_array_coulomb_integrals @@ -85,6 +97,7 @@ Providers .. hlist:: :columns: 3 + * :c:data:`banned_excitation` * :c:data:`mo_integrals_cache` * :c:data:`mo_integrals_cache_min` * :c:data:`mo_integrals_map` @@ -96,7 +109,6 @@ Providers .. hlist:: :columns: 3 - * :c:data:`coef_hf_selector` * :c:data:`h_matrix_all_dets` * :c:data:`h_matrix_cas` @@ -121,6 +133,7 @@ Providers .. hlist:: :columns: 3 + * :c:data:`banned_excitation` * :c:data:`mo_integrals_cache` * :c:data:`mo_integrals_cache_min` * :c:data:`mo_integrals_map` @@ -132,7 +145,6 @@ Providers .. hlist:: :columns: 3 - * :c:data:`coef_hf_selector` * :c:data:`h_matrix_all_dets` * :c:data:`h_matrix_cas` @@ -154,7 +166,7 @@ Providers .. hlist:: :columns: 3 - * :c:data:`list_inact` + * :c:data:`list_core` * :c:data:`mo_one_e_integrals` * :c:data:`mo_two_e_integrals_jj` * :c:data:`n_core_orb` @@ -179,12 +191,15 @@ Providers .. hlist:: :columns: 3 - * :c:data:`list_inact` + * :c:data:`banned_excitation` + * :c:data:`list_act` + * :c:data:`list_core` * :c:data:`mo_integrals_cache` * :c:data:`mo_integrals_cache_min` * :c:data:`mo_integrals_map` * :c:data:`mo_num` * :c:data:`mo_two_e_integrals_in_map` + * :c:data:`n_act_orb` * :c:data:`n_core_orb` @@ -226,6 +241,30 @@ Providers * :c:func:`map_update` +.. c:var:: mo_coef_novirt + + + File : :file:`mo_two_e_ints/four_idx_novvvv.irp.f` + + .. code:: fortran + + double precision, allocatable :: mo_coef_novirt (ao_num,n_core_inact_act_orb) + + + MO coefficients without virtual MOs + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`ao_num` + * :c:data:`list_core_inact_act` + * :c:data:`mo_coef` + * :c:data:`n_core_inact_act_orb` + + + .. c:var:: mo_integrals_cache @@ -417,8 +456,8 @@ Providers .. hlist:: :columns: 3 + * :c:data:`banned_excitation` * :c:data:`big_array_coulomb_integrals` - * :c:data:`coef_hf_selector` * :c:data:`core_fock_operator` * :c:data:`fock_operator_closed_shell_ref_bitmask` * :c:data:`fock_wee_closed_shell` @@ -453,8 +492,6 @@ Providers * :c:data:`ao_integrals_map` * :c:data:`ao_integrals_threshold` * :c:data:`ao_num` - * :c:data:`ao_overlap_abs` - * :c:data:`ao_two_e_integral_schwartz` * :c:data:`ao_two_e_integrals_in_map` * :c:data:`do_direct_integrals` * :c:data:`mo_coef` @@ -480,12 +517,12 @@ Providers .. hlist:: :columns: 3 + * :c:data:`ao_integrals_map` * :c:data:`ao_num` * :c:data:`ao_two_e_integrals_in_map` - * :c:data:`core_inact_act_bitmask_4` * :c:data:`ezfio_filename` * :c:data:`full_ijkl_bitmask_4` - * :c:data:`list_inact` + * :c:data:`list_core_inact_act` * :c:data:`mo_class` * :c:data:`mo_coef` * :c:data:`mo_coef_transp` @@ -493,9 +530,8 @@ Providers * :c:data:`mo_integrals_threshold` * :c:data:`mo_num` * :c:data:`mpi_master` + * :c:data:`n_core_inact_act_orb` * :c:data:`n_int` - * :c:data:`no_ivvv_integrals` - * :c:data:`no_vvv_integrals` * :c:data:`no_vvvv_integrals` * :c:data:`read_mo_two_e_integrals` @@ -504,9 +540,12 @@ Providers .. hlist:: :columns: 3 + * :c:data:`act_2_rdm_aa_mo` + * :c:data:`act_2_rdm_ab_mo` + * :c:data:`act_2_rdm_bb_mo` + * :c:data:`act_2_rdm_spin_trace_mo` * :c:data:`big_array_coulomb_integrals` * :c:data:`ci_electronic_energy` - * :c:data:`coef_hf_selector` * :c:data:`core_fock_operator` * :c:data:`fock_operator_closed_shell_ref_bitmask` * :c:data:`fock_wee_closed_shell` @@ -537,6 +576,7 @@ Providers .. hlist:: :columns: 3 + * :c:data:`banned_excitation` * :c:data:`mo_integrals_cache` * :c:data:`mo_integrals_cache_min` * :c:data:`mo_integrals_map` @@ -573,6 +613,7 @@ Providers .. hlist:: :columns: 3 + * :c:data:`banned_excitation` * :c:data:`mo_integrals_cache` * :c:data:`mo_integrals_cache_min` * :c:data:`mo_integrals_map` @@ -612,8 +653,6 @@ Providers * :c:data:`ao_integrals_map` * :c:data:`ao_integrals_threshold` * :c:data:`ao_num` - * :c:data:`ao_overlap_abs` - * :c:data:`ao_two_e_integral_schwartz` * :c:data:`ao_two_e_integrals_in_map` * :c:data:`do_direct_integrals` * :c:data:`mo_coef` @@ -643,6 +682,7 @@ Providers .. hlist:: :columns: 3 + * :c:data:`banned_excitation` * :c:data:`mo_integrals_cache` * :c:data:`mo_integrals_cache_min` * :c:data:`mo_integrals_map` @@ -682,8 +722,6 @@ Providers * :c:data:`ao_integrals_map` * :c:data:`ao_integrals_threshold` * :c:data:`ao_num` - * :c:data:`ao_overlap_abs` - * :c:data:`ao_two_e_integral_schwartz` * :c:data:`ao_two_e_integrals_in_map` * :c:data:`do_direct_integrals` * :c:data:`mo_coef` @@ -717,15 +755,13 @@ Providers * :c:data:`ao_integrals_map` * :c:data:`ao_integrals_threshold` * :c:data:`ao_num` - * :c:data:`ao_overlap_abs` - * :c:data:`ao_two_e_integral_schwartz` * :c:data:`ao_two_e_integrals_in_map` * :c:data:`do_direct_integrals` - * :c:data:`list_inact` + * :c:data:`list_virt` * :c:data:`mo_coef` * :c:data:`mo_coef_transp` * :c:data:`mo_num` - * :c:data:`n_core_orb` + * :c:data:`n_virt_orb` @@ -754,15 +790,13 @@ Providers * :c:data:`ao_integrals_map` * :c:data:`ao_integrals_threshold` * :c:data:`ao_num` - * :c:data:`ao_overlap_abs` - * :c:data:`ao_two_e_integral_schwartz` * :c:data:`ao_two_e_integrals_in_map` * :c:data:`do_direct_integrals` - * :c:data:`list_inact` + * :c:data:`list_virt` * :c:data:`mo_coef` * :c:data:`mo_coef_transp` * :c:data:`mo_num` - * :c:data:`n_core_orb` + * :c:data:`n_virt_orb` @@ -791,15 +825,13 @@ Providers * :c:data:`ao_integrals_map` * :c:data:`ao_integrals_threshold` * :c:data:`ao_num` - * :c:data:`ao_overlap_abs` - * :c:data:`ao_two_e_integral_schwartz` * :c:data:`ao_two_e_integrals_in_map` * :c:data:`do_direct_integrals` - * :c:data:`list_inact` + * :c:data:`list_virt` * :c:data:`mo_coef` * :c:data:`mo_coef_transp` * :c:data:`mo_num` - * :c:data:`n_core_orb` + * :c:data:`n_virt_orb` @@ -824,13 +856,13 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`mo_coef` - * :c:data:`mo_integrals_threshold` - * :c:data:`mo_coef_transp` * :c:data:`ao_num` - * :c:data:`mo_integrals_map` - * :c:data:`mo_num` * :c:data:`ao_two_e_integrals_in_map` + * :c:data:`mo_coef` + * :c:data:`mo_coef_transp` + * :c:data:`mo_integrals_map` + * :c:data:`mo_integrals_threshold` + * :c:data:`mo_num` * :c:data:`n_int` Called by: @@ -838,6 +870,7 @@ Subroutines / functions .. hlist:: :columns: 3 + * :c:func:`four_idx_novvvv2` * :c:data:`mo_two_e_integrals_in_map` Calls: @@ -846,7 +879,6 @@ Subroutines / functions :columns: 3 * :c:func:`bitstring_to_list` - * :c:func:`bitstring_to_str` * :c:func:`cpu_time` * :c:func:`get_ao_two_e_integrals` * :c:func:`insert_into_mo_integrals_map` @@ -872,22 +904,15 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`mo_coef` - * :c:data:`mo_integrals_threshold` - * :c:data:`mo_coef_transp` * :c:data:`ao_num` - * :c:data:`mo_integrals_map` - * :c:data:`mo_num` * :c:data:`ao_two_e_integrals_in_map` + * :c:data:`mo_coef` + * :c:data:`mo_coef_transp` + * :c:data:`mo_integrals_map` + * :c:data:`mo_integrals_threshold` + * :c:data:`mo_num` * :c:data:`n_int` - Called by: - - .. hlist:: - :columns: 3 - - * :c:data:`mo_two_e_integrals_in_map` - Calls: .. hlist:: @@ -919,29 +944,21 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`mo_coef` - * :c:data:`mo_integrals_threshold` - * :c:data:`mo_coef_transp` * :c:data:`ao_num` - * :c:data:`mo_integrals_map` - * :c:data:`mo_num` * :c:data:`ao_two_e_integrals_in_map` + * :c:data:`mo_coef` + * :c:data:`mo_coef_transp` + * :c:data:`mo_integrals_map` + * :c:data:`mo_integrals_threshold` + * :c:data:`mo_num` * :c:data:`n_int` - Called by: - - .. hlist:: - :columns: 3 - - * :c:data:`mo_two_e_integrals_in_map` - Calls: .. hlist:: :columns: 3 * :c:func:`bitstring_to_list` - * :c:func:`bitstring_to_str` * :c:func:`cpu_time` * :c:func:`get_ao_two_e_integrals` * :c:func:`insert_into_mo_integrals_map` @@ -950,6 +967,44 @@ Subroutines / functions * :c:func:`wall_time` +.. c:function:: ao_to_mo_novirt: + + + File : :file:`mo_two_e_ints/four_idx_novvvv.irp.f` + + .. code:: fortran + + subroutine ao_to_mo_novirt(A_ao,LDA_ao,A_mo,LDA_mo) + + + Transform A from the |AO| basis to the |MO| basis excluding virtuals + + $C^\dagger.A_{ao}.C$ + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`ao_num` + * :c:data:`mo_coef_novirt` + * :c:data:`n_core_inact_act_orb` + + Called by: + + .. hlist:: + :columns: 3 + + * :c:func:`four_idx_novvvv` + + Calls: + + .. hlist:: + :columns: 3 + + * :c:func:`dgemm` + + .. c:function:: clear_mo_map: @@ -1005,6 +1060,81 @@ Subroutines / functions * :c:func:`ezfio_set_work_empty` +.. c:function:: four_idx_novvvv: + + + File : :file:`mo_two_e_ints/four_idx_novvvv.irp.f` + + .. code:: fortran + + subroutine four_idx_novvvv + + + Retransform MO integrals for next CAS-SCF step + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`ao_integrals_map` + * :c:data:`ao_num` + * :c:data:`list_core_inact_act` + * :c:data:`mo_integrals_map` + * :c:data:`mo_integrals_threshold` + * :c:data:`mo_num` + * :c:data:`n_core_inact_act_orb` + + Called by: + + .. hlist:: + :columns: 3 + + * :c:data:`mo_two_e_integrals_in_map` + + Calls: + + .. hlist:: + :columns: 3 + + * :c:func:`ao_to_mo` + * :c:func:`ao_to_mo_novirt` + * :c:func:`map_append` + * :c:func:`map_shrink` + * :c:func:`map_sort` + * :c:func:`map_unique` + * :c:func:`two_e_integrals_index` + + +.. c:function:: four_idx_novvvv2: + + + File : :file:`mo_two_e_ints/four_idx_novvvv.irp.f` + + .. code:: fortran + + subroutine four_idx_novvvv2 + + + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`core_inact_act_bitmask_4` + * :c:data:`full_ijkl_bitmask_4` + * :c:data:`n_int` + * :c:data:`virt_bitmask` + + Calls: + + .. hlist:: + :columns: 3 + + * :c:func:`add_integrals_to_map` + + .. c:function:: get_mo_map_size: @@ -1043,17 +1173,18 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`mo_two_e_integrals_in_map` + * :c:data:`banned_excitation` * :c:data:`mo_integrals_cache` * :c:data:`mo_integrals_cache_min` + * :c:data:`mo_two_e_integrals_in_map` Called by: .. hlist:: :columns: 3 - * :c:func:`get_d0` - * :c:func:`get_d1` + * :c:func:`get_mo_two_e_integrals_i1j1` + * :c:func:`get_mo_two_e_integrals_ij` Calls: @@ -1092,14 +1223,6 @@ Subroutines / functions * :c:data:`fock_operator_closed_shell_ref_bitmask` * :c:data:`fock_wee_closed_shell` - Calls: - - .. hlist:: - :columns: 3 - - * :c:func:`map_get_many` - * :c:func:`two_e_integrals_index` - .. c:function:: get_mo_two_e_integrals_exch_ii: @@ -1130,14 +1253,6 @@ Subroutines / functions * :c:data:`fock_operator_closed_shell_ref_bitmask` * :c:data:`fock_wee_closed_shell` - Calls: - - .. hlist:: - :columns: 3 - - * :c:func:`map_get_many` - * :c:func:`two_e_integrals_index` - .. c:function:: get_mo_two_e_integrals_i1j1: @@ -1159,18 +1274,13 @@ Subroutines / functions :columns: 3 * :c:data:`mo_two_e_integrals_in_map` - * :c:data:`mo_integrals_map` Calls: .. hlist:: :columns: 3 - * :c:func:`i2radix_sort` - * :c:func:`i8radix_sort` - * :c:func:`iradix_sort` - * :c:func:`map_get_many` - * :c:func:`two_e_integrals_index` + * :c:func:`get_mo_two_e_integrals` .. c:function:: get_mo_two_e_integrals_ij: @@ -1187,24 +1297,12 @@ Subroutines / functions i(1)j(2) 1/r12 k(1)l(2) i, j for k,l fixed. - Needs: - - .. hlist:: - :columns: 3 - - * :c:data:`mo_two_e_integrals_in_map` - * :c:data:`mo_integrals_map` - Calls: .. hlist:: :columns: 3 - * :c:func:`i2radix_sort` - * :c:func:`i8radix_sort` - * :c:func:`iradix_sort` - * :c:func:`map_get_many` - * :c:func:`two_e_integrals_index` + * :c:func:`get_mo_two_e_integrals` .. c:function:: get_two_e_integral: @@ -1224,9 +1322,10 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`mo_two_e_integrals_in_map` + * :c:data:`banned_excitation` * :c:data:`mo_integrals_cache` * :c:data:`mo_integrals_cache_min` + * :c:data:`mo_two_e_integrals_in_map` Calls: @@ -1306,7 +1405,6 @@ Subroutines / functions :columns: 3 * :c:func:`add_integrals_to_map` - * :c:func:`add_integrals_to_map_erf` * :c:func:`add_integrals_to_map_no_exit_34` * :c:func:`add_integrals_to_map_three_indices` diff --git a/docs/source/modules/nuclei.rst b/docs/source/modules/nuclei.rst index 04ff1f5b..24a7a6e6 100644 --- a/docs/source/modules/nuclei.rst +++ b/docs/source/modules/nuclei.rst @@ -38,7 +38,7 @@ EZFIO parameters Nuclear coordinates in the format (:, {x,y,z}) -.. option:: disk_access_nuclear_repulsion +.. option:: io_nuclear_repulsion Read/Write Nuclear Repulsion from/to disk [ Write | Read | None ] @@ -255,10 +255,7 @@ Providers * :c:data:`ao_pseudo_integrals_local` * :c:data:`ao_pseudo_integrals_non_local` * :c:data:`ao_spread_x` - * :c:data:`ao_two_e_integral_alpha` - * :c:data:`ao_two_e_integral_erf_schwartz` * :c:data:`ao_two_e_integral_schwartz` - * :c:data:`ao_two_e_integrals_erf_in_map` * :c:data:`ao_two_e_integrals_in_map` * :c:data:`center_of_mass` * :c:data:`inertia_tensor` @@ -498,7 +495,7 @@ Providers .. hlist:: :columns: 3 - * :c:data:`disk_access_nuclear_repulsion` + * :c:data:`io_nuclear_repulsion` * :c:data:`mpi_master` * :c:data:`nucl_charge` * :c:data:`nucl_coord` @@ -512,11 +509,7 @@ Providers * :c:data:`ci_energy` * :c:data:`core_energy` - * :c:data:`core_energy_erf` - * :c:data:`hf_energy` * :c:data:`psi_energy_with_nucl_rep` - * :c:data:`pt2_e0_denominator` - * :c:data:`scf_energy` .. c:var:: slater_bragg_radii diff --git a/docs/source/modules/perturbation.rst b/docs/source/modules/perturbation.rst index 764b6312..b1124aac 100644 --- a/docs/source/modules/perturbation.rst +++ b/docs/source/modules/perturbation.rst @@ -218,10 +218,12 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`selection_criterion` + * :c:data:`elec_alpha_num` + * :c:data:`elec_beta_num` * :c:data:`h_apply_buffer_allocated` * :c:data:`n_det` * :c:data:`n_int` + * :c:data:`selection_criterion` Calls: @@ -252,11 +254,12 @@ Subroutines / functions :columns: 3 * :c:data:`mo_num` - * :c:data:`psi_selectors` * :c:data:`n_det` - * :c:data:`n_det_selectors` * :c:data:`n_det_generators` + * :c:data:`n_det_selectors` + * :c:data:`n_int` * :c:data:`psi_det_generators` + * :c:data:`psi_selectors` Calls: @@ -287,11 +290,12 @@ Subroutines / functions :columns: 3 * :c:data:`mo_num` - * :c:data:`psi_selectors` * :c:data:`n_det` - * :c:data:`n_det_selectors` * :c:data:`n_det_generators` + * :c:data:`n_det_selectors` + * :c:data:`n_int` * :c:data:`psi_det_generators` + * :c:data:`psi_selectors` Calls: @@ -322,11 +326,12 @@ Subroutines / functions :columns: 3 * :c:data:`mo_num` - * :c:data:`psi_selectors` * :c:data:`n_det` - * :c:data:`n_det_selectors` * :c:data:`n_det_generators` + * :c:data:`n_det_selectors` + * :c:data:`n_int` * :c:data:`psi_det_generators` + * :c:data:`psi_selectors` Calls: @@ -357,11 +362,12 @@ Subroutines / functions :columns: 3 * :c:data:`mo_num` - * :c:data:`psi_selectors` * :c:data:`n_det` - * :c:data:`n_det_selectors` * :c:data:`n_det_generators` + * :c:data:`n_det_selectors` + * :c:data:`n_int` * :c:data:`psi_det_generators` + * :c:data:`psi_selectors` Calls: @@ -392,11 +398,12 @@ Subroutines / functions :columns: 3 * :c:data:`mo_num` - * :c:data:`psi_selectors` * :c:data:`n_det` - * :c:data:`n_det_selectors` * :c:data:`n_det_generators` + * :c:data:`n_det_selectors` + * :c:data:`n_int` * :c:data:`psi_det_generators` + * :c:data:`psi_selectors` Calls: @@ -427,11 +434,12 @@ Subroutines / functions :columns: 3 * :c:data:`mo_num` - * :c:data:`psi_selectors` * :c:data:`n_det` - * :c:data:`n_det_selectors` * :c:data:`n_det_generators` + * :c:data:`n_det_selectors` + * :c:data:`n_int` * :c:data:`psi_det_generators` + * :c:data:`psi_selectors` Calls: @@ -461,11 +469,12 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_det_selectors` - * :c:data:`n_det_generators` - * :c:data:`psi_selectors` - * :c:data:`psi_det_generators` * :c:data:`mo_num` + * :c:data:`n_det_generators` + * :c:data:`n_det_selectors` + * :c:data:`n_int` + * :c:data:`psi_det_generators` + * :c:data:`psi_selectors` Calls: @@ -497,11 +506,12 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_det_selectors` - * :c:data:`n_det_generators` - * :c:data:`psi_selectors` - * :c:data:`psi_det_generators` * :c:data:`mo_num` + * :c:data:`n_det_generators` + * :c:data:`n_det_selectors` + * :c:data:`n_int` + * :c:data:`psi_det_generators` + * :c:data:`psi_selectors` Calls: @@ -533,11 +543,12 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_det_selectors` - * :c:data:`n_det_generators` - * :c:data:`psi_selectors` - * :c:data:`psi_det_generators` * :c:data:`mo_num` + * :c:data:`n_det_generators` + * :c:data:`n_det_selectors` + * :c:data:`n_int` + * :c:data:`psi_det_generators` + * :c:data:`psi_selectors` Calls: @@ -569,11 +580,12 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_det_selectors` - * :c:data:`n_det_generators` - * :c:data:`psi_selectors` - * :c:data:`psi_det_generators` * :c:data:`mo_num` + * :c:data:`n_det_generators` + * :c:data:`n_det_selectors` + * :c:data:`n_int` + * :c:data:`psi_det_generators` + * :c:data:`psi_selectors` Calls: @@ -605,11 +617,12 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_det_selectors` - * :c:data:`n_det_generators` - * :c:data:`psi_selectors` - * :c:data:`psi_det_generators` * :c:data:`mo_num` + * :c:data:`n_det_generators` + * :c:data:`n_det_selectors` + * :c:data:`n_int` + * :c:data:`psi_det_generators` + * :c:data:`psi_selectors` Calls: @@ -641,11 +654,12 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_det_selectors` - * :c:data:`n_det_generators` - * :c:data:`psi_selectors` - * :c:data:`psi_det_generators` * :c:data:`mo_num` + * :c:data:`n_det_generators` + * :c:data:`n_det_selectors` + * :c:data:`n_int` + * :c:data:`psi_det_generators` + * :c:data:`psi_selectors` Calls: @@ -676,11 +690,11 @@ Subroutines / functions .. hlist:: :columns: 3 + * :c:data:`mo_num` * :c:data:`n_det_selectors` - * :c:data:`selection_criterion` * :c:data:`psi_selectors` * :c:data:`psi_selectors_size` - * :c:data:`mo_num` + * :c:data:`selection_criterion` Called by: @@ -721,11 +735,12 @@ Subroutines / functions .. hlist:: :columns: 3 + * :c:data:`mo_num` * :c:data:`n_det_selectors` - * :c:data:`selection_criterion` + * :c:data:`n_int` * :c:data:`psi_selectors` * :c:data:`psi_selectors_size` - * :c:data:`mo_num` + * :c:data:`selection_criterion` Called by: @@ -766,10 +781,11 @@ Subroutines / functions .. hlist:: :columns: 3 + * :c:data:`mo_num` * :c:data:`n_det_selectors` + * :c:data:`n_int` * :c:data:`psi_selectors` * :c:data:`psi_selectors_size` - * :c:data:`mo_num` Called by: @@ -811,11 +827,12 @@ Subroutines / functions .. hlist:: :columns: 3 + * :c:data:`mo_num` * :c:data:`n_det_selectors` + * :c:data:`n_int` + * :c:data:`psi_energy` * :c:data:`psi_selectors` * :c:data:`psi_selectors_size` - * :c:data:`psi_energy` - * :c:data:`mo_num` Called by: @@ -856,12 +873,13 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`ref_bitmask` - * :c:data:`psi_selectors_size` - * :c:data:`psi_selectors` + * :c:data:`fock_matrix_mo` * :c:data:`mo_num` * :c:data:`n_det_selectors` - * :c:data:`fock_matrix_mo` + * :c:data:`n_int` + * :c:data:`psi_selectors` + * :c:data:`psi_selectors_size` + * :c:data:`ref_bitmask` Called by: @@ -902,11 +920,12 @@ Subroutines / functions .. hlist:: :columns: 3 + * :c:data:`mo_num` * :c:data:`n_det_selectors` - * :c:data:`selection_criterion` + * :c:data:`n_int` * :c:data:`psi_selectors` * :c:data:`psi_selectors_size` - * :c:data:`mo_num` + * :c:data:`selection_criterion` Called by: @@ -944,16 +963,16 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`psi_coef` - * :c:data:`selection_criterion` - * :c:data:`n_states` * :c:data:`n_det` - * :c:data:`psi_det_size` * :c:data:`n_det_generators` * :c:data:`n_int` + * :c:data:`n_states` + * :c:data:`psi_coef` * :c:data:`psi_det_sorted` * :c:data:`psi_det` + * :c:data:`psi_det_size` * :c:data:`psi_det_sorted` + * :c:data:`selection_criterion` Calls: diff --git a/docs/source/modules/scf_utils.rst b/docs/source/modules/scf_utils.rst index d32daf5f..e822b9e6 100644 --- a/docs/source/modules/scf_utils.rst +++ b/docs/source/modules/scf_utils.rst @@ -178,9 +178,11 @@ Providers * :c:data:`fock_matrix_mo` * :c:data:`frozen_orb_scf` * :c:data:`level_shift` - * :c:data:`list_inact` + * :c:data:`list_act` + * :c:data:`list_core` * :c:data:`mo_coef` * :c:data:`mo_num` + * :c:data:`n_act_orb` * :c:data:`n_core_orb` @@ -206,8 +208,8 @@ Providers .. hlist:: :columns: 3 - * :c:data:`max_dim_diis` * :c:data:`ao_num` + * :c:data:`max_dim_diis` Called by: @@ -221,8 +223,10 @@ Providers .. hlist:: :columns: 3 + * :c:func:`dgecon` * :c:func:`dgemm` - * :c:func:`dsysvx` + * :c:func:`dgesv` + * :c:func:`dgetrf` .. c:var:: fock_matrix_ao @@ -297,8 +301,10 @@ Providers * :c:data:`fock_matrix_mo_alpha` * :c:data:`fock_matrix_mo_beta` * :c:data:`frozen_orb_scf` - * :c:data:`list_inact` + * :c:data:`list_act` + * :c:data:`list_core` * :c:data:`mo_num` + * :c:data:`n_act_orb` * :c:data:`n_core_orb` Needed by: @@ -346,8 +352,10 @@ Providers * :c:data:`fock_matrix_mo_alpha` * :c:data:`fock_matrix_mo_beta` * :c:data:`frozen_orb_scf` - * :c:data:`list_inact` + * :c:data:`list_act` + * :c:data:`list_core` * :c:data:`mo_num` + * :c:data:`n_act_orb` * :c:data:`n_core_orb` Needed by: @@ -637,18 +645,18 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`mo_coef` - * :c:data:`eigenvectors_fock_matrix_mo` - * :c:data:`scf_energy` - * :c:data:`scf_density_matrix_ao_beta` - * :c:data:`fock_matrix_mo` * :c:data:`ao_num` - * :c:data:`scf_density_matrix_ao_alpha` + * :c:data:`eigenvectors_fock_matrix_mo` * :c:data:`fock_matrix_ao` + * :c:data:`fock_matrix_mo` + * :c:data:`frozen_orb_scf` + * :c:data:`mo_coef` * :c:data:`mo_label` * :c:data:`n_it_scf_max` + * :c:data:`scf_density_matrix_ao_alpha` + * :c:data:`scf_density_matrix_ao_beta` + * :c:data:`scf_energy` * :c:data:`thresh_scf` - * :c:data:`frozen_orb_scf` Calls: @@ -690,14 +698,15 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`ao_one_e_integrals` - * :c:data:`mo_coef` - * :c:data:`eigenvectors_fock_matrix_mo` - * :c:data:`ao_overlap` * :c:data:`ao_num` + * :c:data:`ao_one_e_integrals` + * :c:data:`ao_overlap` * :c:data:`ao_two_e_integral_alpha` + * :c:data:`eigenvectors_fock_matrix_mo` * :c:data:`fock_matrix_ao_alpha` * :c:data:`fock_matrix_ao_alpha` + * :c:data:`mo_coef` + * :c:data:`mo_num` Called by: @@ -711,6 +720,8 @@ Subroutines / functions .. hlist:: :columns: 3 + * :c:func:`orthonormalize_mos` + * :c:func:`restore_symmetry` * :c:func:`save_mos` Touches: @@ -740,34 +751,27 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`max_dim_diis` - * :c:data:`mo_occ` * :c:data:`ao_md5` - * :c:data:`mo_coef` - * :c:data:`level_shift` - * :c:data:`fps_spf_matrix_mo` - * :c:data:`eigenvectors_fock_matrix_mo` - * :c:data:`scf_energy` - * :c:data:`mo_num` - * :c:data:`thresh_scf` - * :c:data:`scf_algorithm` - * :c:data:`fock_matrix_mo` * :c:data:`ao_num` + * :c:data:`eigenvectors_fock_matrix_mo` * :c:data:`fock_matrix_ao` - * :c:data:`mo_label` - * :c:data:`n_it_scf_max` - * :c:data:`threshold_diis_nonzero` - * :c:data:`frozen_orb_scf` * :c:data:`fock_matrix_ao_alpha` * :c:data:`fock_matrix_ao_alpha` + * :c:data:`fock_matrix_mo` * :c:data:`fps_spf_matrix_ao` - - Called by: - - .. hlist:: - :columns: 3 - - * :c:func:`run` + * :c:data:`fps_spf_matrix_mo` + * :c:data:`frozen_orb_scf` + * :c:data:`level_shift` + * :c:data:`max_dim_diis` + * :c:data:`mo_coef` + * :c:data:`mo_label` + * :c:data:`mo_num` + * :c:data:`mo_occ` + * :c:data:`n_it_scf_max` + * :c:data:`scf_algorithm` + * :c:data:`scf_energy` + * :c:data:`thresh_scf` + * :c:data:`threshold_diis_nonzero` Calls: @@ -777,6 +781,8 @@ Subroutines / functions * :c:func:`extrapolate_fock_matrix` * :c:func:`initialize_mo_coef_begin_iteration` * :c:func:`mo_as_eigvectors_of_mo_matrix` + * :c:func:`nullify_small_elements` + * :c:func:`orthonormalize_mos` * :c:func:`reorder_core_orb` * :c:func:`save_mos` * :c:func:`write_double` diff --git a/docs/source/modules/tools.rst b/docs/source/modules/tools.rst index 2ad351c7..31769efe 100644 --- a/docs/source/modules/tools.rst +++ b/docs/source/modules/tools.rst @@ -33,6 +33,76 @@ Programs Subroutines / functions ----------------------- +.. c:function:: print_energy: + + + File : :file:`print_energy.irp.f` + + .. code:: fortran + + subroutine print_energy + + + Prints the energy of the wave function stored in the |EZFIO| directory. + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`n_states` + * :c:data:`read_wf` + + Calls: + + .. hlist:: + :columns: 3 + + * :c:func:`run` + + Touches: + + .. hlist:: + :columns: 3 + + * :c:data:`read_wf` + + +.. c:function:: print_hamiltonian: + + + File : :file:`print_hamiltonian.irp.f` + + .. code:: fortran + + subroutine print_hamiltonian + + + Prints the Hamiltonian matrix defined in the space of determinants + present in the |EZFIO| directory. + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`read_wf` + + Calls: + + .. hlist:: + :columns: 3 + + * :c:func:`run` + + Touches: + + .. hlist:: + :columns: 3 + + * :c:data:`read_wf` + + .. c:function:: routine: @@ -80,8 +150,8 @@ Subroutines / functions .. hlist:: :columns: 3 - * :c:data:`n_states` * :c:data:`ezfio_filename` + * :c:data:`n_states` Called by: @@ -138,3 +208,41 @@ Subroutines / functions * :c:func:`ezfio_set_aux_quantities_data_one_e_dm_beta_ao` * :c:func:`ezfio_set_aux_quantities_data_one_e_dm_beta_mo` + +.. c:function:: run: + + + File : :file:`print_hamiltonian.irp.f` + + .. code:: fortran + + subroutine run + + + + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`n_det` + * :c:data:`n_int` + * :c:data:`psi_det` + + Called by: + + .. hlist:: + :columns: 3 + + * :c:func:`print_energy` + * :c:func:`print_hamiltonian` + * :c:func:`pt2` + * :c:func:`scf` + + Calls: + + .. hlist:: + :columns: 3 + + * :c:func:`i_h_j` + diff --git a/docs/source/programmers_guide/conventions.rst b/docs/source/programmers_guide/conventions.rst index 33fd810a..54524d8b 100644 --- a/docs/source/programmers_guide/conventions.rst +++ b/docs/source/programmers_guide/conventions.rst @@ -29,7 +29,7 @@ be used. In addition, all the shell scripts should be under The exit code of the script should be 0 upon success only. -Bash and Python2 are the only shell scripting language permitted for +Bash and Python3 are the only shell scripting language permitted for executables. @@ -73,11 +73,10 @@ Bash Python ------ -Only Python2 is supported. The reason is that some dependencies use Python2, -and we do not want yet to add an extra dependency to Python3. +Only Python3 is supported. -Python scripts should start with ``#!/usr/bin/env python2`` to mention -explicitly that Python2 has to be used. +Python scripts should start with ``#!/usr/bin/env python3`` to mention +explicitly that Python3 has to be used, possibly from a conda installation. :command:`pylint` should be used to increase the quality of the source code. diff --git a/docs/source/programmers_guide/programming.rst b/docs/source/programmers_guide/programming.rst index cc349990..e2865d99 100644 --- a/docs/source/programmers_guide/programming.rst +++ b/docs/source/programmers_guide/programming.rst @@ -6,7 +6,7 @@ To program in the |qp|, it is required that you are familiar with the |IRPF90| code generator. A GitBook can be found `here `_, and programmers are encouraged to visit this manual. -|IRPF90| make programming very simple. The only information a programmer needs +|IRPF90| makes programming very simple. The only information a programmer needs in order to write a new program is the name of the required |IRPF90| entities which may already exist in other modules. For example, writing a program which prints the Hartree-Fock energy is as simple as: @@ -24,7 +24,7 @@ prints the Hartree-Fock energy is as simple as: The only required information was the existence of a provider for -:command:`hf_energy`. A detailed list of all the providers, subroutines +:command:`HF_energy`. A detailed list of all the providers, subroutines and functions of the |qp| can be found in the appendix of this manual. @@ -32,10 +32,10 @@ and functions of the |qp| can be found in the appendix of this manual. Architecture ============ -As |IRPF90| is used, the programmer doesn't have a full control of the sequence +As |IRPF90| is used, the programmer doesn't have full control of the sequence of instructions in the produced Fortran code. This explains why the input data -is stored in a database rather than in sequential text files. Indeed, the -programmer can't know by advance in which order the files will be read, so a +is stored in a database rather than in sequential text files. Consequently, the +programmer can't know in advance the order in which the files will be read, so a simple random access to persistent data is needed. The |EZFIO| library generator is a practical answer to this problem. @@ -45,10 +45,10 @@ This is done mostly using the command line or scripting. .. important:: - Each command modifies the state of the |EZFIO| database, so running twice the - same program on the same database may have different behaviors because of the + Each command modifies the state of the |EZFIO| database, so running the + same program twice on the same database may have different behavior because of the state of the database. For reproducibility, users are encouraged to run scripts - where a fresg new |EZFIO| database is created at the beginning of the + where a fresh new |EZFIO| database is created at the beginning of the script. This way of running the |qp| makes calculations reproducible. @@ -97,7 +97,7 @@ in the `FCIDUMP` format (see :ref:`fcidump`). All the results are stored in the |EZFIO| directory, so users willing to fetch data such as the |MOs| or the |CI| coefficients should use the |EZFIO| API. -There multiple major ways to do this: +There are multiple major ways to do this: * Write a script in Python or OCaml and use the Python |EZFIO| API. The script :file:`$QP_ROOT/bin/qp_convert_output_to_ezfio` is a good example to understand diff --git a/docs/source/programs/cisd.rst b/docs/source/programs/cisd.rst index 8d3f5ab4..1a61760d 100644 --- a/docs/source/programs/cisd.rst +++ b/docs/source/programs/cisd.rst @@ -22,7 +22,7 @@ cisd * **Ground state calculation**: if even after a :c:func:`cis` calculation, natural orbitals (see :c:func:`save_natorb`) and then :c:func:`scf` optimization, you are not sure to have the lowest scf solution, - do the same strategy with the :c:func:`cisd` executable instead of the :c:func:`cis` exectuable to generate the natural + do the same strategy with the :c:func:`cisd` executable instead of the :c:func:`cis` exectuable to generate the natural orbitals as a guess for the :c:func:`scf`. @@ -57,6 +57,7 @@ cisd .. hlist:: :columns: 3 + * :c:data:`n_states` * :c:data:`read_wf` Calls: diff --git a/docs/source/programs/fci.rst b/docs/source/programs/fci.rst index 5979c28d..daccc0d1 100644 --- a/docs/source/programs/fci.rst +++ b/docs/source/programs/fci.rst @@ -48,10 +48,10 @@ fci .. hlist:: :columns: 3 - * :c:data:`psi_coef` - * :c:data:`is_zmq_slave` * :c:data:`do_pt2` + * :c:data:`is_zmq_slave` * :c:data:`mo_two_e_integrals_in_map` + * :c:data:`psi_coef` * :c:data:`psi_det` Calls: @@ -87,9 +87,11 @@ fci * :c:data:`psi_energy` * :c:data:`pt2_e0_denominator` * :c:data:`pt2_match_weight` + * :c:data:`pt2_overlap` * :c:data:`pt2_stoch_istate` * :c:data:`read_wf` * :c:data:`selection_weight` * :c:data:`state_average_weight` + * :c:data:`threshold_davidson_pt2` * :c:data:`threshold_generators` * :c:data:`variance_match_weight` diff --git a/docs/source/programs/fcidump.rst b/docs/source/programs/fcidump.rst index 4e58a1ff..e98bd2fc 100644 --- a/docs/source/programs/fcidump.rst +++ b/docs/source/programs/fcidump.rst @@ -31,15 +31,16 @@ fcidump .. hlist:: :columns: 3 - * :c:data:`elec_beta_num` - * :c:data:`ezfio_filename` - * :c:data:`core_fock_operator` - * :c:data:`elec_num` - * :c:data:`mo_two_e_integrals_in_map` - * :c:data:`elec_alpha_num` - * :c:data:`mo_one_e_integrals` - * :c:data:`n_core_orb` - * :c:data:`mo_integrals_threshold` - * :c:data:`list_inact` - * :c:data:`mo_integrals_map` * :c:data:`core_energy` + * :c:data:`core_fock_operator` + * :c:data:`elec_alpha_num` + * :c:data:`elec_beta_num` + * :c:data:`elec_num` + * :c:data:`ezfio_filename` + * :c:data:`list_act` + * :c:data:`mo_integrals_map` + * :c:data:`mo_integrals_threshold` + * :c:data:`mo_one_e_integrals` + * :c:data:`mo_two_e_integrals_in_map` + * :c:data:`n_act_orb` + * :c:data:`n_core_orb` diff --git a/docs/source/programs/ks_scf.rst b/docs/source/programs/ks_scf.rst index bb1e9204..208a7425 100644 --- a/docs/source/programs/ks_scf.rst +++ b/docs/source/programs/ks_scf.rst @@ -19,10 +19,10 @@ ks_scf .. hlist:: :columns: 3 - * :c:data:`io_mo_one_e_integrals` - * :c:data:`mu_erf_dft` * :c:data:`density_for_dft` * :c:data:`io_ao_one_e_integrals` + * :c:data:`io_mo_one_e_integrals` + * :c:data:`mu_erf_dft` Calls: diff --git a/docs/source/programs/molden.rst b/docs/source/programs/molden.rst index 9c1f9249..b300b68b 100644 --- a/docs/source/programs/molden.rst +++ b/docs/source/programs/molden.rst @@ -16,21 +16,21 @@ molden .. hlist:: :columns: 3 - * :c:data:`nucl_list_shell_aos` - * :c:data:`mo_occ` - * :c:data:`ezfio_filename` - * :c:data:`mo_coef` * :c:data:`ao_coef` - * :c:data:`ao_power` - * :c:data:`fock_matrix_mo` - * :c:data:`ao_num` - * :c:data:`ao_prim_num` - * :c:data:`mo_num` - * :c:data:`nucl_coord` - * :c:data:`ao_l` - * :c:data:`nucl_charge` * :c:data:`ao_expo` + * :c:data:`ao_l` + * :c:data:`ao_num` + * :c:data:`ao_power` + * :c:data:`ao_prim_num` * :c:data:`element_name` + * :c:data:`ezfio_filename` + * :c:data:`fock_matrix_mo` + * :c:data:`mo_coef` + * :c:data:`mo_num` + * :c:data:`mo_occ` + * :c:data:`nucl_charge` + * :c:data:`nucl_coord` + * :c:data:`nucl_list_shell_aos` * :c:data:`nucl_num` Calls: diff --git a/docs/source/programs/pt2.rst b/docs/source/programs/pt2.rst index 4878bb4d..2df4377d 100644 --- a/docs/source/programs/pt2.rst +++ b/docs/source/programs/pt2.rst @@ -30,8 +30,8 @@ pt2 * :c:data:`is_zmq_slave` * :c:data:`mo_two_e_integrals_in_map` * :c:data:`psi_energy` - * :c:data:`threshold_generators` * :c:data:`read_wf` + * :c:data:`threshold_generators` Calls: @@ -46,12 +46,7 @@ pt2 .. hlist:: :columns: 3 - * :c:data:`fock_matrix_ao_alpha` - * :c:data:`fock_matrix_ao_alpha` - * :c:data:`mo_coef` * :c:data:`distributed_davidson` - * :c:data:`level_shift` - * :c:data:`mo_coef` * :c:data:`pt2_e0_denominator` * :c:data:`pt2_stoch_istate` * :c:data:`read_wf` diff --git a/docs/source/programs/rotate_mos.rst b/docs/source/programs/rotate_mos.rst index e5b4353c..59a92c18 100644 --- a/docs/source/programs/rotate_mos.rst +++ b/docs/source/programs/rotate_mos.rst @@ -19,8 +19,8 @@ rotate_mos :columns: 3 * :c:data:`ao_num` - * :c:data:`mo_num` * :c:data:`mo_coef` + * :c:data:`mo_num` Calls: diff --git a/docs/source/programs/rs_ks_scf.rst b/docs/source/programs/rs_ks_scf.rst index bdf8969d..597a92b8 100644 --- a/docs/source/programs/rs_ks_scf.rst +++ b/docs/source/programs/rs_ks_scf.rst @@ -19,10 +19,10 @@ rs_ks_scf .. hlist:: :columns: 3 - * :c:data:`io_mo_one_e_integrals` - * :c:data:`mu_erf_dft` * :c:data:`density_for_dft` * :c:data:`io_ao_one_e_integrals` + * :c:data:`io_mo_one_e_integrals` + * :c:data:`mu_erf_dft` * :c:data:`read_wf` Calls: diff --git a/docs/source/programs/save_natorb.rst b/docs/source/programs/save_natorb.rst index 852b1583..87dce047 100644 --- a/docs/source/programs/save_natorb.rst +++ b/docs/source/programs/save_natorb.rst @@ -32,8 +32,8 @@ save_natorb .. hlist:: :columns: 3 - * :c:func:`ezfio_set_mo_one_e_ints_io_mo_integrals_e_n` * :c:func:`ezfio_set_mo_one_e_ints_io_mo_integrals_kinetic` + * :c:func:`ezfio_set_mo_one_e_ints_io_mo_integrals_n_e` * :c:func:`ezfio_set_mo_one_e_ints_io_mo_integrals_pseudo` * :c:func:`ezfio_set_mo_one_e_ints_io_mo_one_e_integrals` * :c:func:`ezfio_set_mo_two_e_ints_io_mo_two_e_integrals` @@ -45,5 +45,6 @@ save_natorb .. hlist:: :columns: 3 + * :c:data:`mo_coef` * :c:data:`mo_occ` * :c:data:`read_wf` diff --git a/docs/source/programs/save_ortho_mos.rst b/docs/source/programs/save_ortho_mos.rst index 80cb065d..f8e6eba6 100644 --- a/docs/source/programs/save_ortho_mos.rst +++ b/docs/source/programs/save_ortho_mos.rst @@ -17,6 +17,13 @@ save_ortho_mos Thanks to the Lowdin orthonormalization, the new MOs are the most similar to the guess MOs. + Needs: + + .. hlist:: + :columns: 3 + + * :c:data:`mo_label` + Calls: .. hlist:: diff --git a/docs/source/programs/scf.rst b/docs/source/programs/scf.rst index 0c70d00a..3b8035f7 100644 --- a/docs/source/programs/scf.rst +++ b/docs/source/programs/scf.rst @@ -58,9 +58,5 @@ scf * :c:data:`fock_matrix_ao_alpha` * :c:data:`fock_matrix_ao_alpha` - * :c:data:`fock_matrix_ao_alpha` - * :c:data:`fock_matrix_ao_alpha` - * :c:data:`mo_coef` - * :c:data:`level_shift` * :c:data:`mo_coef` * :c:data:`mo_label` diff --git a/docs/source/programs/sort_by_fock_energies.rst b/docs/source/programs/sort_by_fock_energies.rst index 5d0e0d9f..8b6ccc69 100644 --- a/docs/source/programs/sort_by_fock_energies.rst +++ b/docs/source/programs/sort_by_fock_energies.rst @@ -18,10 +18,10 @@ sort_by_fock_energies .. hlist:: :columns: 3 - * :c:data:`fock_matrix_mo` * :c:data:`ao_num` - * :c:data:`mo_num` + * :c:data:`fock_matrix_mo` * :c:data:`mo_coef` + * :c:data:`mo_num` Calls: diff --git a/docs/source/programs/test.rst b/docs/source/programs/test.rst index 6595f24d..a3ed966a 100644 --- a/docs/source/programs/test.rst +++ b/docs/source/programs/test.rst @@ -10,10 +10,9 @@ test - Calls: + Needs: .. hlist:: :columns: 3 - * :c:func:`two_e_integrals_index` - * :c:func:`two_e_integrals_index_reverse` + * :c:data:`mo_one_e_integrals` diff --git a/docs/source/programs/write_integrals_erf.rst b/docs/source/programs/write_integrals_erf.rst index 43cf853d..e54efbd9 100644 --- a/docs/source/programs/write_integrals_erf.rst +++ b/docs/source/programs/write_integrals_erf.rst @@ -17,8 +17,8 @@ write_integrals_erf .. hlist:: :columns: 3 - * :c:data:`io_mo_two_e_integrals` * :c:data:`io_ao_two_e_integrals` + * :c:data:`io_mo_two_e_integrals` Calls: diff --git a/docs/source/research.bib b/docs/source/research.bib deleted file mode 100644 index c2363074..00000000 --- a/docs/source/research.bib +++ /dev/null @@ -1,493 +0,0 @@ -%%% ARXIV TO BE UPDATED %%% -@article{Loos2020Jan, - author = {Loos, Pierre-François and Scemama, Anthony and Jacquemin, Denis}, - title = {{The Quest For Highly Accurate Excitation Energies: A Computational Perspective}}, - journal = {arXiv}, - year = {2020}, - month = {Jan}, - eprint = {2001.00416}, - url = {https://arxiv.org/abs/2001.00416} -} - -@article{Loos2019Dec, - author = {Loos, Pierre-François and Lipparini, Filippo and Boggio-Pasqua, Martial and Scemama, Anthony and Jacquemin, Denis}, - title = {{A Mountaineering Strategy to Excited States: Highly-Accurate Energies and Benchmarks for Medium Size Molecules}}, - journal = {arXiv}, - year = {2019}, - month = {Dec}, - eprint = {1912.04173}, - url = {https://arxiv.org/abs/1912.04173} -} - -@article{Loos2019Oct, - author = {Loos, Pierre-François and Pradines, Barthélémy and Scemama, Anthony and Giner, Emmanuel and Toulouse, Julien}, - title = {{A Density-Based Basis-Set Incompleteness Correction for GW Methods}}, - journal = {arXiv}, - year = {2019}, - month = {Oct}, - eprint = {1910.12238}, - url = {https://arxiv.org/abs/1910.12238} -} - -%%%% PUBLISHED PAPERS -@article{Hollett2020Jan, - author = {Hollett, Joshua W. and Loos, Pierre-Fran{\c{c}}ois}, - title = {{Capturing static and dynamic correlation with {$\Delta$}NO-MP2 and {$\Delta$}NO-CCSD}}, - journal = {J. Chem. Phys.}, - volume = {152}, - number = {1}, - pages = {014101}, - year = {2020}, - month = {Jan}, - issn = {0021-9606}, - publisher = {American Institute of Physics}, - doi = {10.1063/1.5140669} -} - -@article{Giner2019Oct, - author = {Giner, Emmanuel and Scemama, Anthony and Toulouse, Julien and Loos, Pierre-Fran{\c{c}}ois}, - title = {{Chemically accurate excitation energies with small basis sets}}, - journal = {J. Chem. Phys.}, - volume = {151}, - number = {14}, - pages = {144118}, - year = {2019}, - month = {Oct}, - issn = {0021-9606}, - publisher = {American Institute of Physics}, - doi = {10.1063/1.5122976} -} - - -@article{Burton2019Sep, - author = {Burton, Hugh G. A. and Thom, Alex J. W.}, - title = {{General Approach for Multireference Ground and Excited States Using Nonorthogonal Configuration Interaction}}, - journal = {J. Chem. Theory Comput.}, - volume = {15}, - number = {9}, - pages = {4851--4861}, - year = {2019}, - month = {Sep}, - issn = {1549-9618}, - publisher = {American Chemical Society}, - doi = {10.1021/acs.jctc.9b00441} -} - -@article{Dash_2019, - author = {Dash, Monika and Feldt, Jonas and Moroni, Saverio and Scemama, Anthony and Filippi, Claudia}, - title = {{Excited States with Selected Configuration Interaction-Quantum Monte Carlo: Chemically Accurate Excitation Energies and Geometries}}, - journal = {J. Chem. Theory Comput.}, - volume = {15}, - number = {9}, - pages = {4896--4906}, - year = {2019}, - month = {Sep}, - issn = {1549-9618}, - publisher = {American Chemical Society}, - doi = {10.1021/acs.jctc.9b00476} -} - -@article{Ferte_2019, - doi = {10.1063/1.5082638}, - url = {https://doi.org/10.1063%2F1.5082638}, - year = 2019, - month = {feb}, - publisher = {{AIP} Publishing}, - volume = {150}, - number = {8}, - pages = {084103}, - author = {Anthony Fert{\'{e}} and Emmanuel Giner and Julien Toulouse}, - title = {Range-separated multideterminant density-functional theory with a short-range correlation functional of the on-top pair density}, - journal = {The Journal of Chemical Physics} -} - -@article{Caffarel_2019, - doi = {10.1063/1.5114703}, - url = {https://doi.org/10.1063%2F1.5114703}, - year = 2019, - month = {aug}, - publisher = {{AIP} Publishing}, - volume = {151}, - number = {6}, - pages = {064101}, - author = {Michel Caffarel}, - title = {Evaluating two-electron-repulsion integrals over arbitrary orbitals using zero variance Monte Carlo: Application to full configuration interaction calculations with Slater-type orbitals}, - journal = {The Journal of Chemical Physics} -} - -@article{Loos_2019, - doi = {10.1021/acs.jpclett.9b01176}, - url = {https://doi.org/10.1021%2Facs.jpclett.9b01176}, - year = 2019, - month = {may}, - publisher = {American Chemical Society ({ACS})}, - volume = {10}, - number = {11}, - pages = {2931--2937}, - author = {Pierre-Fran{\c{c}}ois Loos and Barth{\'{e}}l{\'{e}}my Pradines and Anthony Scemama and Julien Toulouse and Emmanuel Giner}, - title = {A Density-Based Basis-Set Correction for Wave Function Theory}, - journal = {The Journal of Physical Chemistry Letters} -} - - -@article{Garniron_2019, - doi = {10.1021/acs.jctc.9b00176}, - url = {https://doi.org/10.1021%2Facs.jctc.9b00176}, - year = 2019, - month = {may}, - publisher = {American Chemical Society ({ACS})}, - author = {Yann Garniron and Thomas Applencourt and Kevin Gasperich and Anouar Benali and Anthony Fert{\'{e}} and Julien Paquier and Barth{\'{e}}l{\'{e}}my Pradines and Roland Assaraf and Peter Reinhardt and Julien Toulouse and Pierrette Barbaresco and Nicolas Renon and Gr{\'{e}}goire David and Jean-Paul Malrieu and Mickaël V{\'{e}}ril and Michel Caffarel and Pierre-Fran{\c{c}}ois Loos and Emmanuel Giner and Anthony Scemama}, - title = {Quantum Package 2.0: An Open-Source Determinant-Driven Suite of Programs}, - journal = {Journal of Chemical Theory and Computation} -} - -@article{Scemama_2019, - doi = {10.1016/j.rechem.2019.100002}, - url = {https://doi.org/10.1016%2Fj.rechem.2019.100002}, - year = 2019, - month = {may}, - publisher = {Elsevier {BV}}, - pages = {100002}, - author = {Anthony Scemama and Michel Caffarel and Anouar Benali and Denis Jacquemin and Pierre-Fran{\c{c}}ois Loos}, - title = {Influence of pseudopotentials on excitation energies from selected configuration interaction and diffusion Monte Carlo}, - journal = {Results in Chemistry} -} - - -@article{Applencourt2018Dec, - author = {Applencourt, Thomas and Gasperich, Kevin and Scemama, Anthony}, - title = {{Spin adaptation with determinant-based selected configuration interaction}}, - journal = {arXiv}, - year = {2018}, - month = {Dec}, - eprint = {1812.06902}, - url = {https://arxiv.org/abs/1812.06902} -} - -@article{Loos2019Mar, - author = {Loos, Pierre-Fran\c{c}ois and Boggio-Pasqua, Martial and Scemama, Anthony and Caffarel, Michel and Jacquemin, Denis}, - title = {{Reference Energies for Double Excitations}}, - journal = {J. Chem. Theory Comput.}, - volume = {15}, - number = {3}, - pages = {1939--1956}, - year = {2019}, - month = {Mar}, - issn = {1549-9618}, - publisher = {American Chemical Society}, - doi = {10.1021/acs.jctc.8b01205} -} - -@article{PinedaFlores2019Feb, - author = {Pineda Flores, Sergio and Neuscamman, Eric}, - title = {{Excited State Specific Multi-Slater Jastrow Wave Functions}}, - journal = {J. Phys. Chem. A}, - volume = {123}, - number = {8}, - pages = {1487--1497}, - year = {2019}, - month = {Feb}, - issn = {1089-5639}, - publisher = {American Chemical Society}, - doi = {10.1021/acs.jpca.8b10671} -} - -@phdthesis{yann_garniron_2019_2558127, - author = {Yann Garniron}, - title = {{Development and parallel implementation of - selected configuration interaction methods}}, - school = {Université de Toulouse}, - year = 2019, - month = feb, - doi = {10.5281/zenodo.2558127}, - url = {https://doi.org/10.5281/zenodo.2558127} -} - -@article{Giner_2018, - doi = {10.1063/1.5052714}, - url = {https://doi.org/10.1063%2F1.5052714}, - year = 2018, - month = {nov}, - publisher = {{AIP} Publishing}, - volume = {149}, - number = {19}, - pages = {194301}, - author = {Emmanuel Giner and Barth{\'{e}}lemy Pradines and Anthony Fert{\'{e}} and Roland Assaraf and Andreas Savin and Julien Toulouse}, - title = {Curing basis-set convergence of wave-function theory using density-functional theory: A systematically improvable approach}, - journal = {The Journal of Chemical Physics} -} - - -@article{Giner2018Oct, - author = {Giner, Emmanuel and Tew, David and Garniron, Yann and Alavi, Ali}, - title = {{Interplay between electronic correlation and metal-ligand delocalization in the spectroscopy of transition metal compounds: case study on a series of planar Cu2+complexes.}}, - journal = {J. Chem. Theory Comput.}, - year = {2018}, - month = {Oct}, - issn = {1549-9618}, - publisher = {American Chemical Society}, - doi = {10.1021/acs.jctc.8b00591} -} - -@article{Loos_2018, - doi = {10.1021/acs.jctc.8b00406}, - url = {https://doi.org/10.1021%2Facs.jctc.8b00406}, - year = 2018, - month = {jul}, - publisher = {American Chemical Society ({ACS})}, - volume = {14}, - number = {8}, - pages = {4360--4379}, - author = {Pierre-Fran{\c{c}}ois Loos and Anthony Scemama and Aymeric Blondel and Yann Garniron and Michel Caffarel and Denis Jacquemin}, - title = {A Mountaineering Strategy to Excited States: Highly Accurate Reference Energies and Benchmarks}, - journal = {Journal of Chemical Theory and Computation} -} -@article{Scemama_2018, - doi = {10.1021/acs.jctc.7b01250}, - url = {https://doi.org/10.1021%2Facs.jctc.7b01250}, - year = 2018, - month = {jan}, - publisher = {American Chemical Society ({ACS})}, - volume = {14}, - number = {3}, - pages = {1395--1402}, - author = {Anthony Scemama and Yann Garniron and Michel Caffarel and Pierre-Fran{\c{c}}ois Loos}, - title = {Deterministic Construction of Nodal Surfaces within Quantum Monte Carlo: The Case of {FeS}}, - journal = {Journal of Chemical Theory and Computation} -} -@article{Scemama_2018.2, - doi = {10.1063/1.5041327}, - url = {https://doi.org/10.1063%2F1.5041327}, - year = 2018, - month = {jul}, - publisher = {{AIP} Publishing}, - volume = {149}, - number = {3}, - pages = {034108}, - author = {Anthony Scemama and Anouar Benali and Denis Jacquemin and Michel Caffarel and Pierre-Fran{\c{c}}ois Loos}, - title = {Excitation energies from diffusion Monte Carlo using selected configuration interaction nodes}, - journal = {The Journal of Chemical Physics} -} -@article{Dash_2018, - doi = {10.1021/acs.jctc.8b00393}, - url = {https://doi.org/10.1021%2Facs.jctc.8b00393}, - year = 2018, - month = {jun}, - publisher = {American Chemical Society ({ACS})}, - volume = {14}, - number = {8}, - pages = {4176--4182}, - author = {Monika Dash and Saverio Moroni and Anthony Scemama and Claudia Filippi}, - title = {Perturbatively Selected Configuration-Interaction Wave Functions for Efficient Geometry Optimization in Quantum Monte Carlo}, - journal = {Journal of Chemical Theory and Computation} -} -@article{Garniron_2018, - doi = {10.1063/1.5044503}, - url = {https://doi.org/10.1063%2F1.5044503}, - year = 2018, - month = {aug}, - publisher = {{AIP} Publishing}, - volume = {149}, - number = {6}, - pages = {064103}, - author = {Yann Garniron and Anthony Scemama and Emmanuel Giner and Michel Caffarel and Pierre-Fran{\c{c}}ois Loos}, - title = {Selected configuration interaction dressed by perturbation}, - journal = {The Journal of Chemical Physics} -} -@article{Giner_2017, - doi = {10.1063/1.4984616}, - url = {https://doi.org/10.1063%2F1.4984616}, - year = 2017, - month = {jun}, - publisher = {{AIP} Publishing}, - volume = {146}, - number = {22}, - pages = {224108}, - author = {Emmanuel Giner and Celestino Angeli and Yann Garniron and Anthony Scemama and Jean-Paul Malrieu}, - title = {A Jeziorski-Monkhorst fully uncontracted multi-reference perturbative treatment. I. Principles, second-order versions, and tests on ground state potential energy curves}, - journal = {The Journal of Chemical Physics} -} -@article{Garniron_2017, - doi = {10.1063/1.4980034}, - url = {https://doi.org/10.1063%2F1.4980034}, - year = 2017, - month = {apr}, - publisher = {{AIP} Publishing}, - volume = {146}, - number = {15}, - pages = {154107}, - author = {Yann Garniron and Emmanuel Giner and Jean-Paul Malrieu and Anthony Scemama}, - title = {Alternative definition of excitation amplitudes in multi-reference state-specific coupled cluster}, - journal = {The Journal of Chemical Physics} -} -@article{Garniron_2017.2, - doi = {10.1063/1.4992127}, - url = {https://doi.org/10.1063%2F1.4992127}, - year = 2017, - month = {jul}, - publisher = {{AIP} Publishing}, - volume = {147}, - number = {3}, - pages = {034101}, - author = {Yann Garniron and Anthony Scemama and Pierre-Fran{\c{c}}ois Loos and Michel Caffarel}, - title = {Hybrid stochastic-deterministic calculation of the second-order perturbative contribution of multireference perturbation theory}, - journal = {The Journal of Chemical Physics} -} -@article{Giner_2017.2, - doi = {10.1016/j.comptc.2017.03.001}, - url = {https://doi.org/10.1016%2Fj.comptc.2017.03.001}, - year = 2017, - month = {sep}, - publisher = {Elsevier {BV}}, - volume = {1116}, - pages = {134--140}, - author = {E. Giner and C. Angeli and A. Scemama and J.-P. Malrieu}, - title = {Orthogonal Valence Bond Hamiltonians incorporating dynamical correlation effects}, - journal = {Computational and Theoretical Chemistry} -} - -@article{Giner_2017.3, -author = {Giner, Emmanuel and Tenti, Lorenzo and Angeli, Celestino and Ferré, Nicolas}, -title = {Computation of the Isotropic Hyperfine Coupling Constant: Efficiency and Insights from a New Approach Based on Wave Function Theory}, -journal = {Journal of Chemical Theory and Computation}, -volume = {13}, -number = {2}, -pages = {475-487}, -year = {2017}, -doi = {10.1021/acs.jctc.6b00827}, -note ={PMID: 28094936}, -URL = {https://doi.org/10.1021/acs.jctc.6b00827}, -eprint = {https://doi.org/10.1021/acs.jctc.6b00827} -} -@article{Giner2016Mar, - author = {Giner, Emmanuel and Angeli, Celestino}, - title = {{Spin density and orbital optimization in open shell systems: A rational and computationally efficient proposal}}, - journal = {J. Chem. Phys.}, - volume = {144}, - number = {10}, - pages = {104104}, - year = {2016}, - month = {Mar}, - issn = {0021-9606}, - publisher = {American Institute of Physics}, - doi = {10.1063/1.4943187} -} -@article{Giner_2016, - doi = {10.1063/1.4940781}, - url = {https://doi.org/10.1063%2F1.4940781}, - year = 2016, - month = {feb}, - publisher = {{AIP} Publishing}, - volume = {144}, - number = {6}, - pages = {064101}, - author = {E. Giner and G. David and A. Scemama and J. P. Malrieu}, - title = {A simple approach to the state-specific {MR}-{CC} using the intermediate Hamiltonian formalism}, - journal = {The Journal of Chemical Physics} -} - -@article{Caffarel_2016, - doi = {10.1063/1.4947093}, - url = {https://doi.org/10.1063%2F1.4947093}, - year = 2016, - month = {apr}, - publisher = {{AIP} Publishing}, - volume = {144}, - number = {15}, - pages = {151103}, - author = {Michel Caffarel and Thomas Applencourt and Emmanuel Giner and Anthony Scemama}, - title = {Communication: Toward an improved control of the fixed-node error in quantum Monte Carlo: The case of the water molecule}, - journal = {The Journal of Chemical Physics} -} -@incollection{Caffarel_2016.2, - doi = {10.1021/bk-2016-1234.ch002}, - url = {https://doi.org/10.1021%2Fbk-2016-1234.ch002}, - year = 2016, - month = {jan}, - publisher = {American Chemical Society}, - pages = {15--46}, - author = {Michel Caffarel and Thomas Applencourt and Emmanuel Giner and Anthony Scemama}, - title = {Using CIPSI Nodes in Diffusion Monte Carlo}, - booktitle = {{ACS} Symposium Series} -} -@article{Giner_2015, - doi = {10.1063/1.4905528}, - url = {https://doi.org/10.1063%2F1.4905528}, - year = 2015, - month = {jan}, - publisher = {{AIP} Publishing}, - volume = {142}, - number = {4}, - pages = {044115}, - author = {Emmanuel Giner and Anthony Scemama and Michel Caffarel}, - title = {Fixed-node diffusion Monte Carlo potential energy curve of the fluorine molecule F2 using selected configuration interaction trial wavefunctions}, - journal = {The Journal of Chemical Physics} -} - -@article{Giner2015Sep, - author = {Giner, Emmanuel and Angeli, Celestino}, - title = {{Metal-ligand delocalization and spin density in the CuCl2 and [CuCl4]2{-} molecules: Some insights from wave function theory}}, - journal = {J. Chem. Phys.}, - volume = {143}, - number = {12}, - pages = {124305}, - year = {2015}, - month = {Sep}, - issn = {0021-9606}, - publisher = {American Institute of Physics}, - doi = {10.1063/1.4931639} -} - -@article{Scemama_2014, - doi = {10.1063/1.4903985}, - url = {https://doi.org/10.1063%2F1.4903985}, - year = 2014, - month = {dec}, - publisher = {{AIP} Publishing}, - volume = {141}, - number = {24}, - pages = {244110}, - author = {A. Scemama and T. Applencourt and E. Giner and M. Caffarel}, - title = {Accurate nonrelativistic ground-state energies of 3d transition metal atoms}, - journal = {The Journal of Chemical Physics} -} -@article{Caffarel_2014, - doi = {10.1021/ct5004252}, - url = {https://doi.org/10.1021%2Fct5004252}, - year = 2014, - month = {nov}, - publisher = {American Chemical Society ({ACS})}, - volume = {10}, - number = {12}, - pages = {5286--5296}, - author = {Michel Caffarel and Emmanuel Giner and Anthony Scemama and Alejandro Ram{\'{\i}}rez-Sol{\'{\i}}s}, - title = {Spin Density Distribution in Open-Shell Transition Metal Systems: A Comparative Post-Hartree-Fock, Density Functional Theory, and Quantum Monte Carlo Study of the CuCl2 Molecule}, - journal = {Journal of Chemical Theory and Computation} -} -@article{Giner_2013, - doi = {10.1139/cjc-2013-0017}, - url = {https://doi.org/10.1139%2Fcjc-2013-0017}, - year = 2013, - month = {sep}, - publisher = {Canadian Science Publishing}, - volume = {91}, - number = {9}, - pages = {879--885}, - author = {Emmanuel Giner and Anthony Scemama and Michel Caffarel}, - title = {Using perturbatively selected configuration interaction in quantum Monte Carlo calculations}, - journal = {Canadian Journal of Chemistry} -} - -@article{Scemama2013Nov, - author = {Scemama, Anthony and Giner, Emmanuel}, - title = {{An efficient implementation of Slater-Condon rules}}, - journal = {arXiv}, - year = {2013}, - month = {Nov}, - eprint = {1311.6244}, - url = {https://arxiv.org/abs/1311.6244} -} - - - - diff --git a/docs/source/users_guide/quickstart.rst b/docs/source/users_guide/quickstart.rst index f0620c5a..e55adcb7 100644 --- a/docs/source/users_guide/quickstart.rst +++ b/docs/source/users_guide/quickstart.rst @@ -128,6 +128,12 @@ and the atomic basis set: ao_two_e_erf_ints density_for_dft electrons mo_two_e_ints scf_utils ao_two_e_ints determinants ezfio nuclei work +If you need to run using an already existing EZFIO database, use + +.. code:: bash + + qp set_file hcn + Run a Hartree-Fock calculation ------------------------------ diff --git a/etc/irpf90.rc b/etc/irpf90.rc index 8016edf6..01a8c8a2 100644 --- a/etc/irpf90.rc +++ b/etc/irpf90.rc @@ -1,7 +1,7 @@ # Configuration of IRPF90 package # Set the path of IRPF90 here: -export IRPF90_PATH=${QP_ROOT}/external/irpf90-v2.0.0 +export IRPF90_PATH=${QP_ROOT}/external/irpf90 export PATH=${PATH}:${IRPF90_PATH}/bin export IRPF90=${IRPF90_PATH}/bin/irpf90 diff --git a/etc/ninja.rc b/etc/ninja.rc deleted file mode 100644 index 0ac28966..00000000 --- a/etc/ninja.rc +++ /dev/null @@ -1,13 +0,0 @@ -# Configuration for the Ninja package - -export NINJA=${QP_ROOT}/bin/ninja - -function ninja () { - if [[ -f ${QP_ROOT}/build.ninja ]] ; then - ${QP_ROOT}/bin/ninja "$@" - else - >&2 echo "Error: build.ninja does not exists. -You need to run ./configure first." - fi - -} diff --git a/etc/paths.rc b/etc/paths.rc index 366286d7..aff62f6e 100644 --- a/etc/paths.rc +++ b/etc/paths.rc @@ -3,7 +3,7 @@ QP_PYTHON= # Load dependencies -for i in ezfio.rc irpf90.rc ninja.rc ocaml.rc +for i in ezfio.rc irpf90.rc ocaml.rc do source $i done diff --git a/etc/qp.rc b/etc/qp.rc index 5b2aa9a6..7661aadf 100644 --- a/etc/qp.rc +++ b/etc/qp.rc @@ -93,7 +93,7 @@ function qp() "prompt") shift - python2 $QP_ROOT/scripts/hello.py + python3 $QP_ROOT/scripts/hello.py function _check_ezfio() { if [[ -d ${EZFIO_FILE} ]] ; then printf "\e[0;32m|${EZFIO_FILE}>\e[m" diff --git a/external/.gitignore b/external/.gitignore index 241e560d..676c79b7 100644 --- a/external/.gitignore +++ b/external/.gitignore @@ -1,2 +1,2 @@ -* +#* diff --git a/external/EZFIO-v2.0.3.tar.gz b/external/EZFIO-v2.0.3.tar.gz deleted file mode 100644 index 6455aaa3..00000000 Binary files a/external/EZFIO-v2.0.3.tar.gz and /dev/null differ diff --git a/external/ezfio b/external/ezfio new file mode 160000 index 00000000..ccee52d0 --- /dev/null +++ b/external/ezfio @@ -0,0 +1 @@ +Subproject commit ccee52d00c2cde1d628b0d34f4a247143747bf36 diff --git a/external/gmp-6.1.2.tar.bz2 b/external/gmp-6.1.2.tar.bz2 new file mode 100644 index 00000000..3b9b275c Binary files /dev/null and b/external/gmp-6.1.2.tar.bz2 differ diff --git a/external/irpf90 b/external/irpf90 new file mode 160000 index 00000000..132a4a16 --- /dev/null +++ b/external/irpf90 @@ -0,0 +1 @@ +Subproject commit 132a4a1661c9878d21dcbf0ac14f7fe9a3b110d0 diff --git a/ocaml/Makefile b/ocaml/Makefile index 978f7e87..40d292fe 100644 --- a/ocaml/Makefile +++ b/ocaml/Makefile @@ -80,7 +80,7 @@ git: ./create_git_sha1.sh ${QP_EZFIO}/Ocaml/ezfio.ml: - $(NINJA) -C ${QP_ROOT}/config ${QP_ROOT}/lib/libezfio_irp.a + ninja -C ${QP_ROOT}/config ${QP_ROOT}/lib/libezfio_irp.a qp_edit.ml: ../scripts/ezfio_interface/qp_edit_template diff --git a/ocaml/qptypes_generator.ml b/ocaml/qptypes_generator.ml index ce99fc78..a5ac22f2 100644 --- a/ocaml/qptypes_generator.ml +++ b/ocaml/qptypes_generator.ml @@ -220,16 +220,16 @@ end = struct type t = | EN | HF - | SOP + | CFG [@@deriving sexp] let to_string = function | EN -> \"EN\" | HF -> \"HF\" - | SOP -> \"SOP\" + | CFG -> \"CFG\" let of_string s = match (String.lowercase_ascii s) with - | \"sop\" -> SOP + | \"cfg\" -> CFG | \"en\" -> EN | \"hf\" -> HF | _ -> raise (Invalid_argument (\"Wrong Perturbation type : \"^s)) diff --git a/scripts/compilation/qp_create_ninja b/scripts/compilation/qp_create_ninja index 3d4e56dc..a132bc9e 100755 --- a/scripts/compilation/qp_create_ninja +++ b/scripts/compilation/qp_create_ninja @@ -38,11 +38,12 @@ def comp_path(path): from qp_path import QP_ROOT, QP_SRC, QP_EZFIO -LIB = " -lz" +LIB = " -lz" EZFIO_LIB = join("$QP_ROOT", "lib", "libezfio_irp.a") ZMQ_LIB = join("$QP_ROOT", "lib", "libf77zmq.a") + " " + join("$QP_ROOT", "lib", "libzmq.a") + " -lstdc++ -lrt -ldl" ROOT_BUILD_NINJA = join("$QP_ROOT", "config", "build.ninja") ROOT_BUILD_NINJA_EXP = join(QP_ROOT, "config", "build.ninja") +ROOT_BUILD_NINJA_EXP_tmp = join(QP_ROOT, "config", "build.ninja.tmp") header = r"""# # _______ _____ # __ __ \___ _______ _________ /____ ________ ___ @@ -57,7 +58,7 @@ header = r"""# # /_/ \__,_/ \___/ /_/|_| \__,_/ _\__, / \___/ # /____/ # -# https://github.com/LCPQ/quantum_package, +# https://github.com/QuantumPackage/qp2, # # Generated automatically by {0} # @@ -107,6 +108,17 @@ def ninja_create_env_variable(pwd_config_file): lib_usr = get_compilation_option(pwd_config_file, "LIB") str_lib = " ".join([lib_lapack, EZFIO_LIB, ZMQ_LIB, LIB, lib_usr]) + + # Read all LIB files in modules + libfile = "LIB" + try: + content = "" + with open(libfile,'r') as f: + content = f.read() + str_lib += " "+content + except IOError: + pass + l_string.append("LIB = {0} ".format(str_lib)) l_string.append("") @@ -149,7 +161,7 @@ def get_l_module_with_ezfio_cfg(): from os import listdir from os.path import isfile - return [real_join(QP_SRC, m) for m in listdir(QP_SRC) + return [real_join(QP_SRC, m) for m in sorted(listdir(QP_SRC)) if isfile(real_join(QP_SRC, m, "EZFIO.cfg"))] @@ -328,13 +340,13 @@ def ninja_symlink_build(path_module, l_symlink): if not l_symlink: return [] - l_folder = [s.destination for s in l_symlink] + l_folder = [s.destination for s in sorted(l_symlink,key=lambda x:x.destination)] l_string = ["build l_symlink_{0} : phony {1}".format(path_module.rel, " ".join(map(comp_path,l_folder))), ""] - for symlink in l_symlink: + for symlink in sorted(l_symlink, key=lambda x: x.source+x.destination): l_string += ["build {0}: build_symlink {1}".format(*list(map(comp_path,(symlink.destination, symlink.source)))), ""] return l_string @@ -360,7 +372,7 @@ def ninja_gitignore_build(path_module, d_binaries, l_symlink): path_gitignore = comp_path(join(path_module.abs, ".gitignore")) - l_b = list(map(comp_path,[i.abs for i in d_binaries[path_module]])) + l_b = sorted(list(map(comp_path,[i.abs for i in d_binaries[path_module]]))) root = "build {0}: build_gitignore {1}".format(path_gitignore, " ".join(l_b)) @@ -389,7 +401,7 @@ def get_l_file_for_module(path_module): l_template = [] - for f in os.listdir(path_module.abs): + for f in sorted(os.listdir(path_module.abs)): if f.lower().endswith(tuple([".template.f", ".include.f"])): l_template.append(join(path_module.abs, f)) elif f.endswith(".irp.f"): @@ -416,7 +428,7 @@ def get_l_file_for_module(path_module): def get_file_dependency(d_info_module): """ - For a module return all the irp.f90 needed files + For a module return all the irp.f90 needed files """ d_irp = defaultdict(dict) @@ -495,10 +507,10 @@ def ninja_irpf90_make_build(path_module, l_needed_molule, d_irp): # D e p e n d a n c y # # ~#~#~#~#~#~#~#~#~#~ # - l_depend = list(map(comp_path,d_irp[path_module]["l_depend"])) - l_src = list(map(comp_path,d_irp[path_module]["l_src"])) - l_obj = list(map(comp_path,d_irp[path_module]["l_obj"])) - l_template = list(map(comp_path,d_irp[path_module]["l_template"])) + l_depend = sorted(list(map(comp_path,d_irp[path_module]["l_depend"]))) + l_src = sorted(list(map(comp_path,d_irp[path_module]["l_src"]))) + l_obj = sorted(list(map(comp_path,d_irp[path_module]["l_obj"]))) + l_template = sorted(list(map(comp_path,d_irp[path_module]["l_template"]))) if l_needed_molule: l_symlink = ["l_symlink_{0}".format(path_module.rel)] @@ -511,7 +523,7 @@ def ninja_irpf90_make_build(path_module, l_needed_molule, d_irp): # N i n j a _ b u i l d # # ~#~#~#~#~#~#~#~#~#~#~ # - l_include_dir = ["-I {0}".format(m.rel) for m in l_needed_molule] + l_include_dir = ["-I {0}".format(m.rel) for m in sorted(l_needed_molule, key=lambda x:x.rel+x.abs) ] l_string = [ "build {0}: build_irpf90.ninja {1}".format(str_creation, str_depend), @@ -642,7 +654,7 @@ def ninja_binaries_build(path_module, l_children, d_binaries): # ~#~#~ # ninja_module_path = join(comp_path(path_module.abs), "IRPF90_temp/build.ninja") - l_abs_bin = list(map(comp_path,[binary.abs for binary in d_binaries[path_module]])) + l_abs_bin = sorted(list(map(comp_path,[binary.abs for binary in d_binaries[path_module]]))) # ~#~#~#~#~#~ # # s t r i n g # @@ -659,8 +671,7 @@ def ninja_binaries_build(path_module, l_children, d_binaries): def ninja_module_build(path_module, d_binaries): - l_abs_bin = list(map(comp_path,[binary.abs for binary in d_binaries[path_module]])) - + l_abs_bin = sorted(list(map(comp_path,[binary.abs for binary in d_binaries[path_module]]))) path_readme = os.path.join(comp_path(path_module.abs), "README.rst") l_string = ["build module_{0}: phony {1}".format(path_module.rel, @@ -711,7 +722,7 @@ def save_subninja_file(path_module): ""] path_ninja_cur = join(path_module.abs, "build.ninja") - + with open(path_ninja_cur, "w") as f: f.write(header) f.write("\n".join(l_string)) @@ -830,14 +841,14 @@ if __name__ == "__main__": dict_root = module_instance.dict_root dict_root_path = dict_module_genelogy_path(dict_root) - l_all_module = list(d_genealogy_path.keys()) + l_all_module = sorted(list(d_genealogy_path.keys())) # ~#~#~#~#~#~#~#~#~#~#~#~#~ # # M o d u l e _ t o _ i r p # # ~#~#~#~#~#~#~#~#~#~#~#~#~ # d_binaries = get_dict_binaries(l_all_module, mode="development") - l_module = list(d_binaries.keys()) + l_module = sorted(list(d_binaries.keys()), key=lambda x: x.rel+x.abs) # ~#~#~#~#~#~#~#~#~#~#~#~ # @@ -851,7 +862,6 @@ if __name__ == "__main__": # ~#~#~#~#~#~#~#~#~#~#~#~ # for module_to_compile in l_module: - if module_to_compile.rel == "dummy": continue @@ -884,6 +894,21 @@ if __name__ == "__main__": # S a v e s # # ~#~#~#~#~ # - with open(ROOT_BUILD_NINJA_EXP, "w+") as f: + with open(ROOT_BUILD_NINJA_EXP_tmp, "w+") as f: f.write(header) f.write("\n".join(l_string)) + + with open(ROOT_BUILD_NINJA_EXP_tmp, "r") as f: + a = f.read() + + try: + with open(ROOT_BUILD_NINJA_EXP, "r") as f: + b = f.read() + except: + b = None + + if a != b: + os.rename(ROOT_BUILD_NINJA_EXP_tmp, ROOT_BUILD_NINJA_EXP) + else: + os.remove(ROOT_BUILD_NINJA_EXP_tmp) + diff --git a/scripts/ezfio_interface/ei_handler.py b/scripts/ezfio_interface/ei_handler.py index 446d60d0..fd514ace 100755 --- a/scripts/ezfio_interface/ei_handler.py +++ b/scripts/ezfio_interface/ei_handler.py @@ -398,7 +398,7 @@ def create_ezfio_stuff(dict_ezfio_cfg, config_or_default="config"): try: (begin, end) = list(map(str.strip, dim.split(":"))) except ValueError: - a_size_raw.append(dim) + a_size_raw.append(dim.strip()) else: if begin[0] == '-': a_size_raw.append("{0}+{1}+1".format(end, begin[1:])) diff --git a/scripts/ezfio_interface/ezfio_generate_provider.py b/scripts/ezfio_interface/ezfio_generate_provider.py index 4b43a88a..6b49955b 100755 --- a/scripts/ezfio_interface/ezfio_generate_provider.py +++ b/scripts/ezfio_interface/ezfio_generate_provider.py @@ -82,6 +82,8 @@ END_PROVIDER mpi_correspondance = {"integer": "MPI_INTEGER", "integer*8": "MPI_INTEGER8", "character*(32)": "MPI_CHARACTER", + "character*(64)": "MPI_CHARACTER", + "character*(256)": "MPI_CHARACTER", "logical": "MPI_LOGICAL", "double precision": "MPI_DOUBLE_PRECISION"} diff --git a/src/ao_one_e_ints/EZFIO.cfg b/src/ao_one_e_ints/EZFIO.cfg index ed9cdc35..8d4fff57 100644 --- a/src/ao_one_e_ints/EZFIO.cfg +++ b/src/ao_one_e_ints/EZFIO.cfg @@ -98,3 +98,11 @@ type: Threshold doc: Remove linear dependencies when the eigenvalues of the overlap matrix are below this value interface: ezfio,provider,ocaml default: 1.e-6 + +[ao_one_e_integrals_threshold] +type: Threshold +doc: If | (p|q) | < `ao_one_e_integrals_threshold` then (p|q) is zero +interface: ezfio,provider,ocaml +default: 1.e-15 +ezfio_name: threshold_ao + diff --git a/src/ao_one_e_ints/ao_ortho_canonical.irp.f b/src/ao_one_e_ints/ao_ortho_canonical.irp.f index 45275a06..668b920d 100644 --- a/src/ao_one_e_ints/ao_ortho_canonical.irp.f +++ b/src/ao_one_e_ints/ao_ortho_canonical.irp.f @@ -137,6 +137,7 @@ END_PROVIDER deallocate(S) endif + END_PROVIDER BEGIN_PROVIDER [double precision, ao_ortho_canonical_overlap, (ao_ortho_canonical_num,ao_ortho_canonical_num)] diff --git a/src/ao_one_e_ints/screening.irp.f b/src/ao_one_e_ints/screening.irp.f index 1bbe3c73..3f436743 100644 --- a/src/ao_one_e_ints/screening.irp.f +++ b/src/ao_one_e_ints/screening.irp.f @@ -4,7 +4,7 @@ logical function ao_one_e_integral_zero(i,k) ao_one_e_integral_zero = .False. if (.not.((io_ao_integrals_overlap/='None').or.is_periodic)) then - if (ao_overlap_abs(i,k) < ao_integrals_threshold) then + if (ao_overlap_abs(i,k) < ao_one_e_integrals_threshold) then ao_one_e_integral_zero = .True. return endif diff --git a/src/ao_two_e_ints/integrals_in_map_slave.irp.f b/src/ao_two_e_ints/integrals_in_map_slave.irp.f index a91bdecb..122fa2ac 100644 --- a/src/ao_two_e_ints/integrals_in_map_slave.irp.f +++ b/src/ao_two_e_ints/integrals_in_map_slave.irp.f @@ -116,7 +116,7 @@ subroutine ao_two_e_integrals_in_map_slave(thread,iproc) exit endif if (task_id == 0) exit - read(task,*) j, l + call sscanf_dd(task, j, l) integer, external :: task_done_to_taskserver call compute_ao_integrals_jl(j,l,n_integrals,buffer_i,buffer_value) if (task_done_to_taskserver(zmq_to_qp_run_socket,worker_id,task_id) == -1) then diff --git a/src/ao_two_e_ints/map_integrals.irp.f b/src/ao_two_e_ints/map_integrals.irp.f index c0ec9695..55b2d5e2 100644 --- a/src/ao_two_e_ints/map_integrals.irp.f +++ b/src/ao_two_e_ints/map_integrals.irp.f @@ -698,81 +698,3 @@ subroutine insert_into_ao_integrals_map(n_integrals,buffer_i, buffer_values) end -!subroutine dump_ao_integrals(filename) -! use map_module -! implicit none -! BEGIN_DOC -! ! Save to disk the |AO| integrals -! END_DOC -! character*(*), intent(in) :: filename -! integer(cache_key_kind), pointer :: key(:) -! real(integral_kind), pointer :: val(:) -! integer*8 :: i,j, n -! if (.not.mpi_master) then -! return -! endif -! call ezfio_set_work_empty(.False.) -! open(unit=66,file=filename,FORM='unformatted') -! write(66) integral_kind, key_kind -! write(66) ao_integrals_map%sorted, ao_integrals_map%map_size, & -! ao_integrals_map%n_elements -! do i=0_8,ao_integrals_map%map_size -! write(66) ao_integrals_map%map(i)%sorted, ao_integrals_map%map(i)%map_size,& -! ao_integrals_map%map(i)%n_elements -! enddo -! do i=0_8,ao_integrals_map%map_size -! key => ao_integrals_map%map(i)%key -! val => ao_integrals_map%map(i)%value -! n = ao_integrals_map%map(i)%n_elements -! write(66) (key(j), j=1,n), (val(j), j=1,n) -! enddo -! close(66) -! -!end - - -!integer function load_ao_integrals(filename) -! implicit none -! BEGIN_DOC -! ! Read from disk the |AO| integrals -! END_DOC -! character*(*), intent(in) :: filename -! integer*8 :: i -! integer(cache_key_kind), pointer :: key(:) -! real(integral_kind), pointer :: val(:) -! integer :: iknd, kknd -! integer*8 :: n, j -! load_ao_integrals = 1 -! open(unit=66,file=filename,FORM='unformatted',STATUS='UNKNOWN') -! read(66,err=98,end=98) iknd, kknd -! if (iknd /= integral_kind) then -! print *, 'Wrong integrals kind in file :', iknd -! stop 1 -! endif -! if (kknd /= key_kind) then -! print *, 'Wrong key kind in file :', kknd -! stop 1 -! endif -! read(66,err=98,end=98) ao_integrals_map%sorted, ao_integrals_map%map_size,& -! ao_integrals_map%n_elements -! do i=0_8, ao_integrals_map%map_size -! read(66,err=99,end=99) ao_integrals_map%map(i)%sorted, & -! ao_integrals_map%map(i)%map_size, ao_integrals_map%map(i)%n_elements -! call cache_map_reallocate(ao_integrals_map%map(i),ao_integrals_map%map(i)%map_size) -! enddo -! do i=0_8, ao_integrals_map%map_size -! key => ao_integrals_map%map(i)%key -! val => ao_integrals_map%map(i)%value -! n = ao_integrals_map%map(i)%n_elements -! read(66,err=99,end=99) (key(j), j=1,n), (val(j), j=1,n) -! enddo -! call map_sort(ao_integrals_map) -! load_ao_integrals = 0 -! return -! 99 continue -! call map_deinit(ao_integrals_map) -! 98 continue -! stop 'Problem reading ao_integrals_map file in work/' -! -!end -! diff --git a/src/ao_two_e_ints/two_e_integrals.irp.f b/src/ao_two_e_ints/two_e_integrals.irp.f index 8c6b3875..8032bd92 100644 --- a/src/ao_two_e_ints/two_e_integrals.irp.f +++ b/src/ao_two_e_ints/two_e_integrals.irp.f @@ -1162,17 +1162,17 @@ subroutine compute_ao_integrals_jl(j,l,n_integrals,buffer_i,buffer_value) ! Parallel client for AO integrals END_DOC - integer, intent(in) :: j,l - integer,intent(out) :: n_integrals - integer(key_kind),intent(out) :: buffer_i(ao_num*ao_num) + integer, intent(in) :: j,l + integer,intent(out) :: n_integrals + integer(key_kind),intent(out) :: buffer_i(ao_num*ao_num) real(integral_kind),intent(out) :: buffer_value(ao_num*ao_num) + logical, external :: ao_two_e_integral_zero - integer :: i,k - double precision :: ao_two_e_integral,cpu_1,cpu_2, wall_1, wall_2 - double precision :: integral, wall_0 - double precision :: thr - integer :: kk, m, j1, i1 - logical, external :: ao_two_e_integral_zero + integer :: i,k + double precision :: ao_two_e_integral,cpu_1,cpu_2, wall_1, wall_2 + double precision :: integral, wall_0 + double precision :: thr + integer :: kk, m, j1, i1 thr = ao_integrals_threshold diff --git a/src/bitmask/bitmasks_routines.irp.f b/src/bitmask/bitmasks_routines.irp.f index 5c4bf347..c34d54dc 100644 --- a/src/bitmask/bitmasks_routines.irp.f +++ b/src/bitmask/bitmasks_routines.irp.f @@ -125,6 +125,41 @@ subroutine bitstring_to_str( output, string, Nint ) output(ibuf:ibuf) = '|' end +subroutine configuration_to_str( output, string, Nint ) + use bitmasks + implicit none + BEGIN_DOC +! Transform the bit string of a configuration to a string for printing + END_DOC + character*(*), intent(out) :: output + integer, intent(in) :: Nint + integer(bit_kind), intent(in) :: string(Nint,2) + + integer :: i, j, ibuf + integer(bit_kind) :: itemp + + ibuf = 1 + output = '' + output(ibuf:ibuf) = '|' + ibuf = ibuf+1 + do i=1,Nint + itemp = 1_bit_kind + do j=1,bit_kind_size + if (iand(itemp,string(i,2)) == itemp) then + output(ibuf:ibuf) = '2' + else if (iand(itemp,string(i,1)) == itemp) then + output(ibuf:ibuf) = '1' + else + output(ibuf:ibuf) = '0' + endif + ibuf = ibuf+1 + itemp = shiftl(itemp,1) + enddo + enddo + output(ibuf:ibuf) = '|' +end + + subroutine bitstring_to_hexa( output, string, Nint ) use bitmasks @@ -166,6 +201,25 @@ subroutine debug_det(string,Nint) end +subroutine debug_cfg(string,Nint) + use bitmasks + implicit none + BEGIN_DOC + ! Subroutine to print the content of a determinant in '+-' notation and + ! hexadecimal representation. + END_DOC + integer, intent(in) :: Nint + integer(bit_kind), intent(in) :: string(Nint,2) + character*(2048) :: output(2) + call bitstring_to_hexa( output(1), string(1,1), Nint ) + call bitstring_to_hexa( output(2), string(1,2), Nint ) + print *, trim(output(1)) , '|', trim(output(2)) + + call configuration_to_str( output(1), string, Nint ) + print *, trim(output(1)) + +end + subroutine print_det(string,Nint) use bitmasks implicit none diff --git a/src/cipsi/EZFIO.cfg b/src/cipsi/EZFIO.cfg index 5110b776..19b45ac1 100644 --- a/src/cipsi/EZFIO.cfg +++ b/src/cipsi/EZFIO.cfg @@ -3,3 +3,40 @@ type: logical doc: If true, computes the one- and two-body rdms with perturbation theory interface: ezfio,provider,ocaml default: False + +[save_wf_after_selection] +type: logical +doc: If true, saves the wave function after the selection, before the diagonalization +interface: ezfio,provider,ocaml +default: False + +[seniority_max] +type: integer +doc: Maximum number of allowed open shells. Using -1 selects all determinants +interface: ezfio,ocaml,provider +default: -1 + +[excitation_ref] +type: integer +doc: 1: Hartree-Fock determinant, 2:All determinants of the dominant configuration +interface: ezfio,ocaml,provider +default: 1 + +[excitation_max] +type: integer +doc: Maximum number of excitation with respect to the Hartree-Fock determinant. Using -1 selects all determinants +interface: ezfio,ocaml,provider +default: -1 + +[excitation_alpha_max] +type: integer +doc: Maximum number of excitation for alpha determinants with respect to the Hartree-Fock determinant. Using -1 selects all determinants +interface: ezfio,ocaml,provider +default: -1 + +[excitation_beta_max] +type: integer +doc: Maximum number of excitation for beta determinants with respect to the Hartree-Fock determinant. Using -1 selects all determinants +interface: ezfio,ocaml,provider +default: -1 + diff --git a/src/cipsi/NEED b/src/cipsi/NEED index c9dc92c0..6c14b4b6 100644 --- a/src/cipsi/NEED +++ b/src/cipsi/NEED @@ -4,3 +4,4 @@ mpi davidson_undressed iterations two_body_rdm +csf diff --git a/src/cipsi/cipsi.irp.f b/src/cipsi/cipsi.irp.f index 34b16ff3..6e715531 100644 --- a/src/cipsi/cipsi.irp.f +++ b/src/cipsi/cipsi.irp.f @@ -102,7 +102,7 @@ subroutine run_cipsi call write_double(6,correlation_energy_ratio, 'Correlation ratio') call print_summary(psi_energy_with_nucl_rep, & - pt2_data, pt2_data_err, N_det,N_occ_pattern,N_states,psi_s2) + pt2_data, pt2_data_err, N_det,N_configuration,N_states,psi_s2) call save_energy(psi_energy_with_nucl_rep, pt2_data % pt2) @@ -114,7 +114,10 @@ subroutine run_cipsi ! Add selected determinants call copy_H_apply_buffer_to_wf() -! call save_wavefunction + + if (save_wf_after_selection) then + call save_wavefunction + endif PROVIDE psi_coef PROVIDE psi_det @@ -144,13 +147,13 @@ subroutine run_cipsi SOFT_TOUCH threshold_generators endif print *, 'N_det = ', N_det - print *, 'N_sop = ', N_occ_pattern + print *, 'N_cfg = ', N_configuration print *, 'N_states = ', N_states print*, 'correlation_ratio = ', correlation_energy_ratio call save_energy(psi_energy_with_nucl_rep, pt2_data % pt2) call print_summary(psi_energy_with_nucl_rep(1:N_states), & - pt2_data, pt2_data_err, N_det,N_occ_pattern,N_states,psi_s2) + pt2_data, pt2_data_err, N_det,N_configuration,N_states,psi_s2) call save_iterations(psi_energy_with_nucl_rep(1:N_states),pt2_data % rpt2,N_det) call print_extrapolated_energy() endif diff --git a/src/cipsi/energy.irp.f b/src/cipsi/energy.irp.f index 1d8c6bf5..1f7cf122 100644 --- a/src/cipsi/energy.irp.f +++ b/src/cipsi/energy.irp.f @@ -22,7 +22,7 @@ BEGIN_PROVIDER [ double precision, pt2_E0_denominator, (N_states) ] enddo else if (h0_type == "Barycentric") then pt2_E0_denominator(1:N_states) = barycentric_electronic_energy(1:N_states) - else if (h0_type == "SOP") then + else if (h0_type == "CFG") then pt2_E0_denominator(1:N_states) = psi_energy(1:N_states) else print *, h0_type, ' not implemented' diff --git a/src/cipsi/pert_rdm_providers.irp.f b/src/cipsi/pert_rdm_providers.irp.f index caea57b2..eca8decc 100644 --- a/src/cipsi/pert_rdm_providers.irp.f +++ b/src/cipsi/pert_rdm_providers.irp.f @@ -71,9 +71,9 @@ subroutine fill_buffer_double_rdm(i_generator, sp, h1, h2, bannedOrb, banned, fo call apply_holes(psi_det_generators(1,1,i_generator), s1, h1, s2, h2, mask, ok, N_int) E_shift = 0.d0 - if (h0_type == 'SOP') then - j = det_to_occ_pattern(i_generator) - E_shift = psi_det_Hii(i_generator) - psi_occ_pattern_Hii(j) + if (h0_type == 'CFG') then + j = det_to_configuration(i_generator) + E_shift = psi_det_Hii(i_generator) - psi_configuration_Hii(j) endif do p1=1,mo_num diff --git a/src/cipsi/pt2_stoch_routines.irp.f b/src/cipsi/pt2_stoch_routines.irp.f index 0966039b..7554c39e 100644 --- a/src/cipsi/pt2_stoch_routines.irp.f +++ b/src/cipsi/pt2_stoch_routines.irp.f @@ -15,7 +15,7 @@ END_PROVIDER pt2_n_tasks_max = min(pt2_n_tasks_max,1+N_det_generators/10000) call write_int(6,pt2_n_tasks_max,'pt2_n_tasks_max') - pt2_F(:) = int(sqrt(float(pt2_n_tasks_max))) + pt2_F(:) = max(int(sqrt(float(pt2_n_tasks_max))),1) do i=1,pt2_n_0(1+pt2_N_teeth/4) pt2_F(i) = pt2_n_tasks_max*pt2_min_parallel_tasks enddo @@ -26,7 +26,6 @@ END_PROVIDER pt2_F(i) = 1 enddo - END_PROVIDER BEGIN_PROVIDER [ integer, pt2_N_teeth ] @@ -134,8 +133,8 @@ subroutine ZMQ_pt2(E, pt2_data, pt2_data_err, relative_error, N_in) PROVIDE psi_bilinear_matrix_transp_order psi_selectors_coef_transp psi_det_sorted PROVIDE psi_det_hii selection_weight pseudo_sym - if (h0_type == 'SOP') then - PROVIDE psi_occ_pattern_hii det_to_occ_pattern + if (h0_type == 'CFG') then + PROVIDE psi_configuration_hii det_to_configuration endif if (N_det <= max(4,N_states) .or. pt2_N_teeth < 2) then @@ -187,7 +186,7 @@ subroutine ZMQ_pt2(E, pt2_data, pt2_data_err, relative_error, N_in) if (zmq_put_ivector(zmq_to_qp_run_socket,1,'pt2_stoch_istate',pt2_stoch_istate,1) == -1) then stop 'Unable to put pt2_stoch_istate on ZMQ server' endif - if (zmq_put_dvector(zmq_to_qp_run_socket,1,'threshold_generators',threshold_generators,1) == -1) then + if (zmq_put_dvector(zmq_to_qp_run_socket,1,'threshold_generators',(/threshold_generators/),1) == -1) then stop 'Unable to put threshold_generators on ZMQ server' endif @@ -352,9 +351,9 @@ subroutine ZMQ_pt2(E, pt2_data, pt2_data_err, relative_error, N_in) state_average_weight(:) = state_average_weight_save(:) TOUCH state_average_weight + call update_pt2_and_variance_weights(pt2_data, N_states) endif - call update_pt2_and_variance_weights(pt2_data, N_states) end subroutine diff --git a/src/cipsi/run_pt2_slave.irp.f b/src/cipsi/run_pt2_slave.irp.f index d3f4d45d..a72d3dbb 100644 --- a/src/cipsi/run_pt2_slave.irp.f +++ b/src/cipsi/run_pt2_slave.irp.f @@ -103,7 +103,7 @@ subroutine run_pt2_slave_small(thread,iproc,energy) if (n_tasks == 0) exit do k=1,n_tasks - read (task(k),*) subset(k), i_generator(k), N + call sscanf_ddd(task(k), subset(k), i_generator(k), N) enddo if (b%N == 0) then ! Only first time @@ -183,9 +183,9 @@ subroutine run_pt2_slave_large(thread,iproc,energy) type(selection_buffer) :: b logical :: done, buffer_ready - type(pt2_type) :: pt2_data(1) + type(pt2_type) :: pt2_data integer :: n_tasks, k, N - integer :: i_generator(1), subset + integer :: i_generator, subset integer :: bsize ! Size of selection buffers logical :: sending @@ -220,7 +220,11 @@ subroutine run_pt2_slave_large(thread,iproc,energy) endif if (n_tasks == 0) exit - read (task,*) subset, i_generator(1), N + call sscanf_ddd(task, subset, i_generator, N) + if( pt2_F(i_generator) <= 0 .or. pt2_F(i_generator) > N_det ) then + print *, irp_here + stop 'bug in selection' + endif if (b%N == 0) then ! Only first time bsize = min(N, (elec_alpha_num * (mo_num-elec_alpha_num))**2) @@ -232,15 +236,10 @@ subroutine run_pt2_slave_large(thread,iproc,energy) double precision :: time0, time1 call wall_time(time0) - call pt2_alloc(pt2_data(1),N_states) + call pt2_alloc(pt2_data,N_states) b%cur = 0 -!double precision :: time2 -!call wall_time(time2) - call select_connected(i_generator(1),energy,pt2_data(1),b,subset,pt2_F(i_generator(1))) -!call wall_time(time1) -!print *, i_generator(1), time1-time2, n_tasks, pt2_F(i_generator(1)) + call select_connected(i_generator,energy,pt2_data,b,subset,pt2_F(i_generator)) call wall_time(time1) -!print *, '-->', i_generator(1), time1-time0, n_tasks integer, external :: tasks_done_to_taskserver if (tasks_done_to_taskserver(zmq_to_qp_run_socket,worker_id,task_id,n_tasks) == -1) then @@ -255,14 +254,14 @@ subroutine run_pt2_slave_large(thread,iproc,energy) call omp_unset_lock(global_selection_buffer_lock) if ( iproc == 1 ) then call omp_set_lock(global_selection_buffer_lock) - call push_pt2_results_async_send(zmq_socket_push, i_generator, pt2_data, global_selection_buffer, task_id, n_tasks,sending) + call push_pt2_results_async_send(zmq_socket_push, (/i_generator/), (/pt2_data/), global_selection_buffer, (/task_id/), 1,sending) global_selection_buffer%cur = 0 call omp_unset_lock(global_selection_buffer_lock) else - call push_pt2_results_async_send(zmq_socket_push, i_generator, pt2_data, b, task_id, n_tasks,sending) + call push_pt2_results_async_send(zmq_socket_push, (/i_generator/), (/pt2_data/), b, (/task_id/), 1,sending) endif - call pt2_dealloc(pt2_data(1)) + call pt2_dealloc(pt2_data) end do call push_pt2_results_async_recv(zmq_socket_push,b%mini,sending) diff --git a/src/cipsi/run_selection_slave.irp.f b/src/cipsi/run_selection_slave.irp.f index c2ba2379..91bd3a38 100644 --- a/src/cipsi/run_selection_slave.irp.f +++ b/src/cipsi/run_selection_slave.irp.f @@ -52,7 +52,7 @@ subroutine run_selection_slave(thread,iproc,energy) ctask = ctask - 1 else integer :: i_generator, N, subset, bsize - read(task,*) subset, i_generator, N + call sscanf_ddd(task, subset, i_generator, N) if(buf%N == 0) then ! Only first time call create_selection_buffer(N, N*2, buf) diff --git a/src/cipsi/selection.irp.f b/src/cipsi/selection.irp.f index fd434c1e..59792ea9 100644 --- a/src/cipsi/selection.irp.f +++ b/src/cipsi/selection.irp.f @@ -1,148 +1,5 @@ use bitmasks -BEGIN_PROVIDER [ double precision, pt2_match_weight, (N_states) ] - implicit none - BEGIN_DOC - ! Weights adjusted along the selection to make the PT2 contributions - ! of each state coincide. - END_DOC - pt2_match_weight(:) = 1.d0 -END_PROVIDER - -BEGIN_PROVIDER [ double precision, variance_match_weight, (N_states) ] - implicit none - BEGIN_DOC - ! Weights adjusted along the selection to make the variances - ! of each state coincide. - END_DOC - variance_match_weight(:) = 1.d0 -END_PROVIDER - -subroutine update_pt2_and_variance_weights(pt2_data, N_st) - implicit none - use selection_types - BEGIN_DOC -! Updates the PT2- and Variance- matching weights. - END_DOC - integer, intent(in) :: N_st - type(pt2_type), intent(in) :: pt2_data - double precision :: pt2(N_st) - double precision :: variance(N_st) - - double precision :: avg, element, dt, x - integer :: k - integer, save :: i_iter=0 - integer, parameter :: i_itermax = 1 - double precision, allocatable, save :: memo_variance(:,:), memo_pt2(:,:) - - pt2(:) = pt2_data % pt2(:) - variance(:) = pt2_data % variance(:) - - if (i_iter == 0) then - allocate(memo_variance(N_st,i_itermax), memo_pt2(N_st,i_itermax)) - memo_pt2(:,:) = 1.d0 - memo_variance(:,:) = 1.d0 - endif - - i_iter = i_iter+1 - if (i_iter > i_itermax) then - i_iter = 1 - endif - - dt = 2.0d0 - - avg = sum(pt2(1:N_st)) / dble(N_st) - 1.d-32 ! Avoid future division by zero - do k=1,N_st - element = exp(dt*(pt2(k)/avg -1.d0)) - element = min(2.0d0 , element) - element = max(0.5d0 , element) - memo_pt2(k,i_iter) = element - pt2_match_weight(k) *= product(memo_pt2(k,:)) - enddo - - avg = sum(variance(1:N_st)) / dble(N_st) + 1.d-32 ! Avoid future division by zero - do k=1,N_st - element = exp(dt*(variance(k)/avg -1.d0)) - element = min(2.0d0 , element) - element = max(0.5d0 , element) - memo_variance(k,i_iter) = element - variance_match_weight(k) *= product(memo_variance(k,:)) - enddo - - if (N_det < 100) then - ! For tiny wave functions, weights are 1.d0 - pt2_match_weight(:) = 1.d0 - variance_match_weight(:) = 1.d0 - endif - - threshold_davidson_pt2 = min(1.d-6, & - max(threshold_davidson, 1.e-1 * PT2_relative_error * minval(abs(pt2(1:N_states)))) ) - - SOFT_TOUCH pt2_match_weight variance_match_weight threshold_davidson_pt2 -end - - -BEGIN_PROVIDER [ double precision, selection_weight, (N_states) ] - implicit none - BEGIN_DOC - ! Weights used in the selection criterion - END_DOC - select case (weight_selection) - - case (0) - print *, 'Using input weights in selection' - selection_weight(1:N_states) = c0_weight(1:N_states) * state_average_weight(1:N_states) - - case (1) - print *, 'Using 1/c_max^2 weight in selection' - selection_weight(1:N_states) = c0_weight(1:N_states) - - case (2) - print *, 'Using pt2-matching weight in selection' - selection_weight(1:N_states) = c0_weight(1:N_states) * pt2_match_weight(1:N_states) - print *, '# PT2 weight ', real(pt2_match_weight(:),4) - - case (3) - print *, 'Using variance-matching weight in selection' - selection_weight(1:N_states) = c0_weight(1:N_states) * variance_match_weight(1:N_states) - print *, '# var weight ', real(variance_match_weight(:),4) - - case (4) - print *, 'Using variance- and pt2-matching weights in selection' - selection_weight(1:N_states) = c0_weight(1:N_states) * sqrt(variance_match_weight(1:N_states) * pt2_match_weight(1:N_states)) - print *, '# PT2 weight ', real(pt2_match_weight(:),4) - print *, '# var weight ', real(variance_match_weight(:),4) - - case (5) - print *, 'Using variance-matching weight in selection' - selection_weight(1:N_states) = c0_weight(1:N_states) * variance_match_weight(1:N_states) - print *, '# var weight ', real(variance_match_weight(:),4) - - case (6) - print *, 'Using CI coefficient-based selection' - selection_weight(1:N_states) = c0_weight(1:N_states) - - case (7) - print *, 'Input weights multiplied by variance- and pt2-matching' - selection_weight(1:N_states) = c0_weight(1:N_states) * sqrt(variance_match_weight(1:N_states) * pt2_match_weight(1:N_states)) * state_average_weight(1:N_states) - print *, '# PT2 weight ', real(pt2_match_weight(:),4) - print *, '# var weight ', real(variance_match_weight(:),4) - - case (8) - print *, 'Input weights multiplied by pt2-matching' - selection_weight(1:N_states) = c0_weight(1:N_states) * pt2_match_weight(1:N_states) * state_average_weight(1:N_states) - print *, '# PT2 weight ', real(pt2_match_weight(:),4) - - case (9) - print *, 'Input weights multiplied by variance-matching' - selection_weight(1:N_states) = c0_weight(1:N_states) * variance_match_weight(1:N_states) * state_average_weight(1:N_states) - print *, '# var weight ', real(variance_match_weight(:),4) - - end select - print *, '# Total weight ', real(selection_weight(:),4) - -END_PROVIDER - subroutine get_mask_phase(det1, pm, Nint) use bitmasks implicit none @@ -151,27 +8,56 @@ subroutine get_mask_phase(det1, pm, Nint) integer(bit_kind), intent(out) :: pm(Nint,2) integer(bit_kind) :: tmp1, tmp2 integer :: i - pm(1:Nint,1:2) = det1(1:Nint,1:2) tmp1 = 0_8 tmp2 = 0_8 - do i=1,Nint - pm(i,1) = ieor(pm(i,1), shiftl(pm(i,1), 1)) - pm(i,2) = ieor(pm(i,2), shiftl(pm(i,2), 1)) - pm(i,1) = ieor(pm(i,1), shiftl(pm(i,1), 2)) - pm(i,2) = ieor(pm(i,2), shiftl(pm(i,2), 2)) - pm(i,1) = ieor(pm(i,1), shiftl(pm(i,1), 4)) - pm(i,2) = ieor(pm(i,2), shiftl(pm(i,2), 4)) - pm(i,1) = ieor(pm(i,1), shiftl(pm(i,1), 8)) - pm(i,2) = ieor(pm(i,2), shiftl(pm(i,2), 8)) - pm(i,1) = ieor(pm(i,1), shiftl(pm(i,1), 16)) - pm(i,2) = ieor(pm(i,2), shiftl(pm(i,2), 16)) - pm(i,1) = ieor(pm(i,1), shiftl(pm(i,1), 32)) - pm(i,2) = ieor(pm(i,2), shiftl(pm(i,2), 32)) - pm(i,1) = ieor(pm(i,1), tmp1) - pm(i,2) = ieor(pm(i,2), tmp2) - if(iand(popcnt(det1(i,1)), 1) == 1) tmp1 = not(tmp1) - if(iand(popcnt(det1(i,2)), 1) == 1) tmp2 = not(tmp2) - end do + select case (Nint) + +BEGIN_TEMPLATE + case ($Nint) + do i=1,$Nint + pm(i,1) = ieor(det1(i,1), shiftl(det1(i,1), 1)) + pm(i,2) = ieor(det1(i,2), shiftl(det1(i,2), 1)) + pm(i,1) = ieor(pm(i,1), shiftl(pm(i,1), 2)) + pm(i,2) = ieor(pm(i,2), shiftl(pm(i,2), 2)) + pm(i,1) = ieor(pm(i,1), shiftl(pm(i,1), 4)) + pm(i,2) = ieor(pm(i,2), shiftl(pm(i,2), 4)) + pm(i,1) = ieor(pm(i,1), shiftl(pm(i,1), 8)) + pm(i,2) = ieor(pm(i,2), shiftl(pm(i,2), 8)) + pm(i,1) = ieor(pm(i,1), shiftl(pm(i,1), 16)) + pm(i,2) = ieor(pm(i,2), shiftl(pm(i,2), 16)) + pm(i,1) = ieor(pm(i,1), shiftl(pm(i,1), 32)) + pm(i,2) = ieor(pm(i,2), shiftl(pm(i,2), 32)) + pm(i,1) = ieor(pm(i,1), tmp1) + pm(i,2) = ieor(pm(i,2), tmp2) + if(iand(popcnt(det1(i,1)), 1) == 1) tmp1 = not(tmp1) + if(iand(popcnt(det1(i,2)), 1) == 1) tmp2 = not(tmp2) + end do +SUBST [ Nint ] +1;; +2;; +3;; +4;; +END_TEMPLATE + case default + do i=1,Nint + pm(i,1) = ieor(det1(i,1), shiftl(det1(i,1), 1)) + pm(i,2) = ieor(det1(i,2), shiftl(det1(i,2), 1)) + pm(i,1) = ieor(pm(i,1), shiftl(pm(i,1), 2)) + pm(i,2) = ieor(pm(i,2), shiftl(pm(i,2), 2)) + pm(i,1) = ieor(pm(i,1), shiftl(pm(i,1), 4)) + pm(i,2) = ieor(pm(i,2), shiftl(pm(i,2), 4)) + pm(i,1) = ieor(pm(i,1), shiftl(pm(i,1), 8)) + pm(i,2) = ieor(pm(i,2), shiftl(pm(i,2), 8)) + pm(i,1) = ieor(pm(i,1), shiftl(pm(i,1), 16)) + pm(i,2) = ieor(pm(i,2), shiftl(pm(i,2), 16)) + pm(i,1) = ieor(pm(i,1), shiftl(pm(i,1), 32)) + pm(i,2) = ieor(pm(i,2), shiftl(pm(i,2), 32)) + pm(i,1) = ieor(pm(i,1), tmp1) + pm(i,2) = ieor(pm(i,2), tmp2) + if(iand(popcnt(det1(i,1)), 1) == 1) tmp1 = not(tmp1) + if(iand(popcnt(det1(i,2)), 1) == 1) tmp2 = not(tmp2) + end do + end select end subroutine @@ -309,15 +195,18 @@ subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_d integer :: l_a, nmax, idx integer, allocatable :: indices(:), exc_degree(:), iorder(:) + double precision, parameter :: norm_thr = 1.d-16 allocate (indices(N_det), & exc_degree(max(N_det_alpha_unique,N_det_beta_unique))) + ! Pre-compute excitation degrees wrt alpha determinants k=1 do i=1,N_det_alpha_unique call get_excitation_degree_spin(psi_det_alpha_unique(1,i), & psi_det_generators(1,1,i_generator), exc_degree(i), N_int) enddo + ! Iterate on 0SD beta, and find alphas 0SDTQ such that exc_degree <= 4 do j=1,N_det_beta_unique call get_excitation_degree_spin(psi_det_beta_unique(1,j), & psi_det_generators(1,2,i_generator), nt, N_int) @@ -326,7 +215,7 @@ subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_d i = psi_bilinear_matrix_rows(l_a) if (nt + exc_degree(i) <= 4) then idx = psi_det_sorted_order(psi_bilinear_matrix_order(l_a)) - if (psi_average_norm_contrib_sorted(idx) > 1.d-20) then + if (psi_average_norm_contrib_sorted(idx) > norm_thr) then indices(k) = idx k=k+1 endif @@ -334,11 +223,14 @@ subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_d enddo enddo + ! Pre-compute excitation degrees wrt beta determinants do i=1,N_det_beta_unique call get_excitation_degree_spin(psi_det_beta_unique(1,i), & psi_det_generators(1,2,i_generator), exc_degree(i), N_int) enddo + ! Iterate on 0S alpha, and find betas TQ such that exc_degree <= 4 + ! Remove also contributions < 1.d-20) do j=1,N_det_alpha_unique call get_excitation_degree_spin(psi_det_alpha_unique(1,j), & psi_det_generators(1,1,i_generator), nt, N_int) @@ -350,7 +242,7 @@ subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_d idx = psi_det_sorted_order( & psi_bilinear_matrix_order( & psi_bilinear_matrix_transp_order(l_a))) - if (psi_average_norm_contrib_sorted(idx) > 1.d-20) then + if (psi_average_norm_contrib_sorted(idx) > norm_thr) then indices(k) = idx k=k+1 endif @@ -587,11 +479,17 @@ subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_d endif do i=1,fullinteresting(0) - fullminilist(1:N_int,1:2,i) = psi_det_sorted(1:N_int,1:2,fullinteresting(i)) + do k=1,N_int + fullminilist(k,1,i) = psi_det_sorted(k,1,fullinteresting(i)) + fullminilist(k,2,i) = psi_det_sorted(k,2,fullinteresting(i)) + enddo enddo do i=1,interesting(0) - minilist(1:N_int,1:2,i) = psi_det_sorted(1:N_int,1:2,interesting(i)) + do k=1,N_int + minilist(k,1,i) = psi_det_sorted(k,1,interesting(i)) + minilist(k,2,i) = psi_det_sorted(k,2,interesting(i)) + enddo enddo do s2=s1,2 @@ -678,12 +576,8 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d double precision :: delta_E, val, Hii, w, tmp, alpha_h_psi double precision, external :: diag_H_mat_elem_fock double precision :: E_shift - - logical, external :: detEq - double precision, allocatable :: values(:) - integer, allocatable :: keys(:,:) - integer :: nkeys double precision :: s_weight(N_states,N_states) + PROVIDE dominant_dets_of_cfgs N_dominant_dets_of_cfgs do jstate=1,N_states do istate=1,N_states s_weight(istate,jstate) = dsqrt(selection_weight(istate)*selection_weight(jstate)) @@ -700,9 +594,9 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d call apply_holes(psi_det_generators(1,1,i_generator), s1, h1, s2, h2, mask, ok, N_int) E_shift = 0.d0 - if (h0_type == 'SOP') then - j = det_to_occ_pattern(i_generator) - E_shift = psi_det_Hii(i_generator) - psi_occ_pattern_Hii(j) + if (h0_type == 'CFG') then + j = det_to_configuration(i_generator) + E_shift = psi_det_Hii(i_generator) - psi_configuration_Hii(j) endif do p1=1,mo_num @@ -735,6 +629,12 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d if(bannedOrb(p2, s2)) cycle if(banned(p1,p2)) cycle + if(pseudo_sym)then + if(dabs(mat(1, p1, p2)).lt.thresh_sym)then + w = 0.d0 + endif + endif + val = maxval(abs(mat(1:N_states, p1, p2))) if( val == 0d0) cycle call apply_particles(mask, s1, p1, s2, p2, det, ok, N_int) @@ -761,14 +661,67 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d if (.not.is_a_1h1p(det)) cycle endif + if (seniority_max >= 0) then + integer :: s + s = 0 + do k=1,N_int + s = s + popcnt(ieor(det(k,1),det(k,2))) + enddo + + if (s > seniority_max) cycle + endif + + + integer :: degree + logical :: do_cycle + if (excitation_max >= 0) then + do_cycle = .True. + if (excitation_ref == 1) then + call get_excitation_degree(HF_bitmask,det(1,1),degree,N_int) + do_cycle = do_cycle .and. (degree > excitation_max) + else if (excitation_ref == 2) then + do k=1,N_dominant_dets_of_cfgs + call get_excitation_degree(dominant_dets_of_cfgs(1,1,k),det(1,1),degree,N_int) + do_cycle = do_cycle .and. (degree > excitation_max) + enddo + endif + if (do_cycle) cycle + endif + + + if (excitation_alpha_max >= 0) then + do_cycle = .True. + if (excitation_ref == 1) then + call get_excitation_degree_spin(HF_bitmask,det(1,1),degree,N_int) + do_cycle = do_cycle .and. (degree > excitation_max) + else if (excitation_ref == 2) then + do k=1,N_dominant_dets_of_cfgs + call get_excitation_degree_spin(dominant_dets_of_cfgs(1,1,k),det(1,1),degree,N_int) + do_cycle = do_cycle .and. (degree > excitation_alpha_max) + enddo + endif + if (do_cycle) cycle + endif + + + if (excitation_beta_max >= 0) then + do_cycle = .True. + if (excitation_ref == 1) then + call get_excitation_degree_spin(HF_bitmask,det(1,2),degree,N_int) + do_cycle = do_cycle .and. (degree > excitation_max) + else if (excitation_ref == 2) then + do k=1,N_dominant_dets_of_cfgs + call get_excitation_degree(dominant_dets_of_cfgs(1,2,k),det(1,2),degree,N_int) + do_cycle = do_cycle .and. (degree > excitation_beta_max) + enddo + endif + if (do_cycle) cycle + endif + Hii = diag_H_mat_elem_fock(psi_det_generators(1,1,i_generator),det,fock_diag_tmp,N_int) w = 0d0 -! integer(bit_kind) :: occ(N_int,2), n -! call occ_pattern_of_det(det,occ,N_int) -! call occ_pattern_to_dets_size(occ,n,elec_alpha_num,N_int) - e_pert = 0.d0 coef = 0.d0 logical :: do_diag @@ -792,11 +745,11 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d endif enddo - do_diag = sum(dabs(coef)) > 0.001d0 + do_diag = sum(dabs(coef)) > 0.001d0 .and. N_states > 1 double precision :: eigvalues(N_states+1) double precision :: work(1+6*(N_states+1)+2*(N_states+1)**2) - integer :: iwork(3+5*(N_states+1)), info, k ,n + integer :: iwork(3+5*(N_states+1)), info, k if (do_diag) then double precision :: pt2_matrix(N_states+1,N_states+1) @@ -822,6 +775,7 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d endif + ! ! Gram-Schmidt using input overlap matrix ! do istate=1,N_states ! do jstate=1,istate-1 @@ -834,12 +788,9 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d alpha_h_psi = mat(istate, p1, p2) - do jstate=1,N_states - pt2_data % overlap(jstate,istate) += coef(jstate) * coef(istate) - enddo - - pt2_data % variance(istate) += alpha_h_psi * alpha_h_psi - pt2_data % pt2(istate) += e_pert(istate) + pt2_data % overlap(:,istate) = pt2_data % overlap(:,istate) + coef(:) * coef(istate) + pt2_data % variance(istate) = pt2_data % variance(istate) + alpha_h_psi * alpha_h_psi + pt2_data % pt2(istate) = pt2_data % pt2(istate) + e_pert(istate) !!!DEBUG ! delta_E = E0(istate) - Hii + E_shift @@ -864,42 +815,44 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d case(5) ! Variance selection -! w = w - alpha_h_psi * alpha_h_psi * s_weight(istate,istate) - w = min(w, - alpha_h_psi * alpha_h_psi * s_weight(istate,istate)) -! do jstate=1,N_states -! if (istate == jstate) cycle -! w = w + dabs(alpha_h_psi*mat(jstate,p1,p2)) * s_weight(istate,jstate) -! enddo + if (h0_type == 'CFG') then + w = min(w, - alpha_h_psi * alpha_h_psi * s_weight(istate,istate)) & + / c0_weight(istate) + else + w = min(w, - alpha_h_psi * alpha_h_psi * s_weight(istate,istate)) + endif case(6) -! w = w - coef(istate) * coef(istate) * s_weight(istate,istate) - w = min(w,- coef(istate) * coef(istate) * s_weight(istate,istate)) -! do jstate=1,N_states -! if (istate == jstate) cycle -! w = w + dabs(coef(istate)*coef(jstate)) * s_weight(istate,jstate) -! enddo + if (h0_type == 'CFG') then + w = min(w,- coef(istate) * coef(istate) * s_weight(istate,istate)) & + / c0_weight(istate) + else + w = min(w,- coef(istate) * coef(istate) * s_weight(istate,istate)) + endif case default ! Energy selection -! w = w + e_pert(istate) * s_weight(istate,istate) - w = min(w, e_pert(istate) * s_weight(istate,istate)) -! do jstate=1,N_states -! if (istate == jstate) cycle -! w = w + dabs(X(istate)*X(jstate)) * s_weight(istate,jstate) -! enddo + if (h0_type == 'CFG') then + w = min(w, e_pert(istate) * s_weight(istate,istate)) / c0_weight(istate) + else + w = min(w, e_pert(istate) * s_weight(istate,istate)) + endif end select end do - if(pseudo_sym)then - if(dabs(mat(1, p1, p2)).lt.thresh_sym)then - w = 0.d0 - endif + integer(bit_kind) :: occ(N_int,2), n + if (h0_type == 'CFG') then + do k=1,N_int + occ(k,1) = ieor(det(k,1),det(k,2)) + occ(k,2) = iand(det(k,1),det(k,2)) + enddo + call configuration_to_dets_size(occ,n,elec_alpha_num,N_int) + n = max(n,1) + w *= dsqrt(dble(n)) endif -! w = dble(n) * w - if(w <= buf%mini) then call add_to_selection_buffer(buf, det, w) end if @@ -1675,7 +1628,7 @@ subroutine get_d0_reference(gen, phasemask, bannedOrb, banned, mat, mask, h, p, phase = get_phase_bi(phasemask, 1, 2, h1, p1, h2, p2, N_int) hij = mo_two_e_integral(p1, p2, h1, h2) * phase end if - mat(:, p1, p2) += coefs(:) * hij + mat(:, p1, p2) = mat(:, p1, p2) + coefs(:) * hij end do end do else ! AA BB @@ -1692,7 +1645,7 @@ subroutine get_d0_reference(gen, phasemask, bannedOrb, banned, mat, mask, h, p, else hij = (mo_two_e_integral(p1, p2, puti, putj) - mo_two_e_integral(p2, p1, puti, putj))* get_phase_bi(phasemask, sp, sp, puti, p1 , putj, p2, N_int) end if - mat(:, puti, putj) += coefs(:) * hij + mat(:, puti, putj) = mat(:, puti, putj) + coefs(:) * hij end do end do end if @@ -1751,18 +1704,18 @@ subroutine get_d1_reference(gen, phasemask, bannedOrb, banned, mat, mask, h, p, do putj=1, hfix-1 if(lbanned(putj, ma) .or. banned(putj, puti,bant)) cycle hij = (mo_two_e_integral(p1, p2, putj, hfix)-mo_two_e_integral(p2,p1,putj,hfix)) * get_phase_bi(phasemask, ma, ma, putj, p1, hfix, p2, N_int) - tmp_row(1:N_states,putj) += hij * coefs(1:N_states) + tmp_row(1:N_states,putj) = tmp_row(1:N_states,putj) + hij * coefs(1:N_states) end do do putj=hfix+1, mo_num if(lbanned(putj, ma) .or. banned(putj, puti,bant)) cycle hij = (mo_two_e_integral(p1, p2, hfix, putj)-mo_two_e_integral(p2,p1,hfix,putj)) * get_phase_bi(phasemask, ma, ma, hfix, p1, putj, p2, N_int) - tmp_row(1:N_states,putj) += hij * coefs(1:N_states) + tmp_row(1:N_states,putj) = tmp_row(1:N_states,putj) + hij * coefs(1:N_states) end do if(ma == 1) then - mat(1:N_states,1:mo_num,puti) += tmp_row(1:N_states,1:mo_num) + mat(1:N_states,1:mo_num,puti) = mat(1:N_states,1:mo_num,puti) + tmp_row(1:N_states,1:mo_num) else - mat(1:N_states,puti,1:mo_num) += tmp_row(1:N_states,1:mo_num) + mat(1:N_states,puti,1:mo_num) = mat(1:N_states,puti,1:mo_num) + tmp_row(1:N_states,1:mo_num) end if end if @@ -1776,22 +1729,22 @@ subroutine get_d1_reference(gen, phasemask, bannedOrb, banned, mat, mask, h, p, putj = p1 if(.not. banned(putj,puti,bant)) then hij = mo_two_e_integral(p2,pfix,hfix,puti) * get_phase_bi(phasemask, ma, mi, hfix, p2, puti, pfix, N_int) - tmp_row(:,puti) += hij * coefs(:) + tmp_row(:,puti) = tmp_row(:,puti) + hij * coefs(:) end if putj = p2 if(.not. banned(putj,puti,bant)) then hij = mo_two_e_integral(p1,pfix,hfix,puti) * get_phase_bi(phasemask, ma, mi, hfix, p1, puti, pfix, N_int) - tmp_row2(:,puti) += hij * coefs(:) + tmp_row2(:,puti) = tmp_row2(:,puti) + hij * coefs(:) end if end do if(mi == 1) then - mat(:,:,p1) += tmp_row(:,:) - mat(:,:,p2) += tmp_row2(:,:) + mat(:,:,p1) = mat(:,:,p1) + tmp_row(:,:) + mat(:,:,p2) = mat(:,:,p2) + tmp_row2(:,:) else - mat(:,p1,:) += tmp_row(:,:) - mat(:,p2,:) += tmp_row2(:,:) + mat(:,p1,:) = mat(:,p1,:) + tmp_row(:,:) + mat(:,p2,:) = mat(:,p2,:) + tmp_row2(:,:) end if else if(p(0,ma) == 3) then @@ -1804,16 +1757,16 @@ subroutine get_d1_reference(gen, phasemask, bannedOrb, banned, mat, mask, h, p, do putj=1,hfix-1 if(lbanned(putj,ma) .or. banned(puti,putj,1)) cycle hij = (mo_two_e_integral(p1, p2, putj, hfix)-mo_two_e_integral(p2,p1,putj,hfix)) * get_phase_bi(phasemask, ma, ma, putj, p1, hfix, p2, N_int) - tmp_row(:,putj) += hij * coefs(:) + tmp_row(:,putj) = tmp_row(:,putj) + hij * coefs(:) end do do putj=hfix+1,mo_num if(lbanned(putj,ma) .or. banned(puti,putj,1)) cycle hij = (mo_two_e_integral(p1, p2, hfix, putj)-mo_two_e_integral(p2,p1,hfix,putj)) * get_phase_bi(phasemask, ma, ma, hfix, p1, putj, p2, N_int) - tmp_row(:,putj) += hij * coefs(:) + tmp_row(:,putj) = tmp_row(:,putj) + hij * coefs(:) end do - mat(:, :puti-1, puti) += tmp_row(:,:puti-1) - mat(:, puti, puti:) += tmp_row(:,puti:) + mat(:, :puti-1, puti) = mat(:, :puti-1, puti) + tmp_row(:,:puti-1) + mat(:, puti, puti:) = mat(:, puti, puti:) + tmp_row(:,puti:) end do else hfix = h(1,mi) @@ -1827,19 +1780,19 @@ subroutine get_d1_reference(gen, phasemask, bannedOrb, banned, mat, mask, h, p, putj = p2 if(.not. banned(puti,putj,1)) then hij = mo_two_e_integral(pfix, p1, hfix, puti) * get_phase_bi(phasemask, mi, ma, hfix, pfix, puti, p1, N_int) - tmp_row(:,puti) += hij * coefs(:) + tmp_row(:,puti) = tmp_row(:,puti) + hij * coefs(:) end if putj = p1 if(.not. banned(puti,putj,1)) then hij = mo_two_e_integral(pfix, p2, hfix, puti) * get_phase_bi(phasemask, mi, ma, hfix, pfix, puti, p2, N_int) - tmp_row2(:,puti) += hij * coefs(:) + tmp_row2(:,puti) = tmp_row2(:,puti) + hij * coefs(:) end if end do - mat(:,:p2-1,p2) += tmp_row(:,:p2-1) - mat(:,p2,p2:) += tmp_row(:,p2:) - mat(:,:p1-1,p1) += tmp_row2(:,:p1-1) - mat(:,p1,p1:) += tmp_row2(:,p1:) + mat(:,:p2-1,p2) = mat(:,:p2-1,p2) + tmp_row(:,:p2-1) + mat(:,p2,p2:) = mat(:,p2,p2:) + tmp_row(:,p2:) + mat(:,:p1-1,p1) = mat(:,:p1-1,p1) + tmp_row2(:,:p1-1) + mat(:,p1,p1:) = mat(:,p1,p1:) + tmp_row2(:,p1:) end if end if deallocate(lbanned) @@ -1862,7 +1815,7 @@ subroutine get_d1_reference(gen, phasemask, bannedOrb, banned, mat, mask, h, p, if(bannedOrb(p1, s1) .or. bannedOrb(p2, s2) .or. banned(p1, p2, 1)) cycle call apply_particles(mask, s1, p1, s2, p2, det, ok, N_int) call i_h_j(gen, det, N_int, hij) - mat(:, p1, p2) += coefs(:) * hij + mat(:, p1, p2) = mat(:, p1, p2) + coefs(:) * hij end do end do end @@ -1915,9 +1868,9 @@ subroutine get_d2_reference(gen, phasemask, bannedOrb, banned, mat, mask, h, p, hij = (mo_two_e_integral(p1, p2, h1, h2) - mo_two_e_integral(p2,p1, h1, h2)) * get_phase_bi(phasemask, ma, ma, h1, p1, h2, p2, N_int) if(ma == 1) then - mat(:, putj, puti) += coefs(:) * hij + mat(:, putj, puti) = mat(:, putj, puti) + coefs(:) * hij else - mat(:, puti, putj) += coefs(:) * hij + mat(:, puti, putj) = mat(:, puti, putj) + coefs(:) * hij end if end do else @@ -1933,7 +1886,7 @@ subroutine get_d2_reference(gen, phasemask, bannedOrb, banned, mat, mask, h, p, p1 = p(turn2(i), 1) hij = mo_two_e_integral(p1, p2, h1, h2) * get_phase_bi(phasemask, 1, 2, h1, p1, h2, p2,N_int) - mat(:, puti, putj) += coefs(:) * hij + mat(:, puti, putj) = mat(:, puti, putj) + coefs(:) * hij end do end do end if @@ -1953,7 +1906,7 @@ subroutine get_d2_reference(gen, phasemask, bannedOrb, banned, mat, mask, h, p, p1 = p(i1, ma) p2 = p(i2, ma) hij = (mo_two_e_integral(p1, p2, h1, h2) - mo_two_e_integral(p2,p1, h1, h2)) * get_phase_bi(phasemask, ma, ma, h1, p1, h2, p2,N_int) - mat(:, puti, putj) += coefs(:) * hij + mat(:, puti, putj) = mat(:, puti, putj) + coefs(:) * hij end do end do else if(tip == 3) then @@ -1967,7 +1920,7 @@ subroutine get_d2_reference(gen, phasemask, bannedOrb, banned, mat, mask, h, p, p2 = p(i, ma) hij = mo_two_e_integral(p1, p2, h1, h2) * get_phase_bi(phasemask, mi, ma, h1, p1, h2, p2,N_int) - mat(:, min(puti, putj), max(puti, putj)) += coefs(:) * hij + mat(:, min(puti, putj), max(puti, putj)) = mat(:, min(puti, putj), max(puti, putj)) + coefs(:) * hij end do else ! tip == 4 puti = p(1, sp) @@ -1978,7 +1931,7 @@ subroutine get_d2_reference(gen, phasemask, bannedOrb, banned, mat, mask, h, p, h1 = h(1, mi) h2 = h(2, mi) hij = (mo_two_e_integral(p1, p2, h1, h2) - mo_two_e_integral(p2,p1, h1, h2)) * get_phase_bi(phasemask, mi, mi, h1, p1, h2, p2,N_int) - mat(:, puti, putj) += coefs(:) * hij + mat(:, puti, putj) = mat(:, puti, putj) + coefs(:) * hij end if end if end if diff --git a/src/cipsi/selection_buffer.irp.f b/src/cipsi/selection_buffer.irp.f index 17b6e9a9..10132086 100644 --- a/src/cipsi/selection_buffer.irp.f +++ b/src/cipsi/selection_buffer.irp.f @@ -175,7 +175,7 @@ subroutine make_selection_buffer_s2(b) ! Sort integer, allocatable :: iorder(:) integer*8, allocatable :: bit_tmp(:) - integer*8, external :: occ_pattern_search_key + integer*8, external :: configuration_search_key integer(bit_kind), allocatable :: tmp_array(:,:,:) logical, allocatable :: duplicate(:) @@ -193,7 +193,7 @@ subroutine make_selection_buffer_s2(b) o(k,2,i) = iand(b%det(k,1,i), b%det(k,2,i)) enddo iorder(i) = i - bit_tmp(i) = occ_pattern_search_key(o(1,1,i),N_int) + bit_tmp(i) = configuration_search_key(o(1,1,i),N_int) enddo deallocate(b%det) @@ -279,7 +279,7 @@ subroutine make_selection_buffer_s2(b) ! Create determinants n_d = 0 do i=1,n_p - call occ_pattern_to_dets_size(o(1,1,i),sze,elec_alpha_num,N_int) + call configuration_to_dets_size(o(1,1,i),sze,elec_alpha_num,N_int) n_d = n_d + sze if (n_d > b%cur) then ! if (n_d - b%cur > b%cur - n_d + sze) then @@ -295,8 +295,8 @@ subroutine make_selection_buffer_s2(b) k=1 do i=1,n_p n=n_d - call occ_pattern_to_dets_size(o(1,1,i),n,elec_alpha_num,N_int) - call occ_pattern_to_dets(o(1,1,i),b%det(1,1,k),n,elec_alpha_num,N_int) + call configuration_to_dets_size(o(1,1,i),n,elec_alpha_num,N_int) + call configuration_to_dets(o(1,1,i),b%det(1,1,k),n,elec_alpha_num,N_int) do j=k,k+n-1 b%val(j) = val(i) enddo diff --git a/src/cipsi/selection_weight.irp.f b/src/cipsi/selection_weight.irp.f new file mode 100644 index 00000000..3c09e59a --- /dev/null +++ b/src/cipsi/selection_weight.irp.f @@ -0,0 +1,134 @@ +BEGIN_PROVIDER [ double precision, pt2_match_weight, (N_states) ] + implicit none + BEGIN_DOC + ! Weights adjusted along the selection to make the PT2 contributions + ! of each state coincide. + END_DOC + pt2_match_weight(:) = 1.d0 +END_PROVIDER + + + +BEGIN_PROVIDER [ double precision, variance_match_weight, (N_states) ] + implicit none + BEGIN_DOC + ! Weights adjusted along the selection to make the variances + ! of each state coincide. + END_DOC + variance_match_weight(:) = 1.d0 +END_PROVIDER + + + +subroutine update_pt2_and_variance_weights(pt2_data, N_st) + implicit none + use selection_types + BEGIN_DOC +! Updates the PT2- and Variance- matching weights. + END_DOC + integer, intent(in) :: N_st + type(pt2_type), intent(in) :: pt2_data + double precision :: pt2(N_st) + double precision :: variance(N_st) + + double precision :: avg, element, dt, x + integer :: k + pt2(:) = pt2_data % pt2(:) + variance(:) = pt2_data % variance(:) + + avg = sum(pt2(1:N_st)) / dble(N_st) + 1.d-32 ! Avoid future division by zero + + dt = 8.d0 !* selection_factor + do k=1,N_st + element = exp(dt*(pt2(k)/avg - 1.d0)) + element = min(2.0d0 , element) + element = max(0.5d0 , element) + pt2_match_weight(k) *= element + enddo + + + avg = sum(variance(1:N_st)) / dble(N_st) + 1.d-32 ! Avoid future division by zero + + do k=1,N_st + element = exp(dt*(variance(k)/avg -1.d0)) + element = min(2.0d0 , element) + element = max(0.5d0 , element) + variance_match_weight(k) *= element + enddo + + if (N_det < 100) then + ! For tiny wave functions, weights are 1.d0 + pt2_match_weight(:) = 1.d0 + variance_match_weight(:) = 1.d0 + endif + + threshold_davidson_pt2 = min(1.d-6, & + max(threshold_davidson, 1.e-1 * PT2_relative_error * minval(abs(pt2(1:N_states)))) ) + + SOFT_TOUCH pt2_match_weight variance_match_weight threshold_davidson_pt2 +end + + + + +BEGIN_PROVIDER [ double precision, selection_weight, (N_states) ] + implicit none + BEGIN_DOC + ! Weights used in the selection criterion + END_DOC + select case (weight_selection) + + case (0) + print *, 'Using input weights in selection' + selection_weight(1:N_states) = c0_weight(1:N_states) * state_average_weight(1:N_states) + + case (1) + print *, 'Using 1/c_max^2 weight in selection' + selection_weight(1:N_states) = c0_weight(1:N_states) + + case (2) + print *, 'Using pt2-matching weight in selection' + selection_weight(1:N_states) = c0_weight(1:N_states) * pt2_match_weight(1:N_states) + print *, '# PT2 weight ', real(pt2_match_weight(:),4) + + case (3) + print *, 'Using variance-matching weight in selection' + selection_weight(1:N_states) = c0_weight(1:N_states) * variance_match_weight(1:N_states) + print *, '# var weight ', real(variance_match_weight(:),4) + + case (4) + print *, 'Using variance- and pt2-matching weights in selection' + selection_weight(1:N_states) = c0_weight(1:N_states) * sqrt(variance_match_weight(1:N_states) * pt2_match_weight(1:N_states)) + print *, '# PT2 weight ', real(pt2_match_weight(:),4) + print *, '# var weight ', real(variance_match_weight(:),4) + + case (5) + print *, 'Using variance-matching weight in selection' + selection_weight(1:N_states) = c0_weight(1:N_states) * variance_match_weight(1:N_states) + print *, '# var weight ', real(variance_match_weight(:),4) + + case (6) + print *, 'Using CI coefficient-based selection' + selection_weight(1:N_states) = c0_weight(1:N_states) + + case (7) + print *, 'Input weights multiplied by variance- and pt2-matching' + selection_weight(1:N_states) = c0_weight(1:N_states) * sqrt(variance_match_weight(1:N_states) * pt2_match_weight(1:N_states)) * state_average_weight(1:N_states) + print *, '# PT2 weight ', real(pt2_match_weight(:),4) + print *, '# var weight ', real(variance_match_weight(:),4) + + case (8) + print *, 'Input weights multiplied by pt2-matching' + selection_weight(1:N_states) = c0_weight(1:N_states) * pt2_match_weight(1:N_states) * state_average_weight(1:N_states) + print *, '# PT2 weight ', real(pt2_match_weight(:),4) + + case (9) + print *, 'Input weights multiplied by variance-matching' + selection_weight(1:N_states) = c0_weight(1:N_states) * variance_match_weight(1:N_states) * state_average_weight(1:N_states) + print *, '# var weight ', real(variance_match_weight(:),4) + + end select + print *, '# Total weight ', real(selection_weight(:),4) + +END_PROVIDER + diff --git a/src/cipsi/slave_cipsi.irp.f b/src/cipsi/slave_cipsi.irp.f index 1dc3e784..510c667b 100644 --- a/src/cipsi/slave_cipsi.irp.f +++ b/src/cipsi/slave_cipsi.irp.f @@ -4,7 +4,7 @@ subroutine run_slave_cipsi ! Helper program for distributed parallelism END_DOC - call omp_set_nested(.false.) + call omp_set_max_active_levels(1) distributed_davidson = .False. read_wf = .False. SOFT_TOUCH read_wf distributed_davidson @@ -100,7 +100,7 @@ subroutine run_slave_main IRP_IF MPI_DEBUG call mpi_print('zmq_get_dvector threshold_generators') IRP_ENDIF - if (zmq_get_dvector(zmq_to_qp_run_socket,1,'threshold_generators',threshold_generators,1) == -1) cycle + if (zmq_get_dvector(zmq_to_qp_run_socket,1,'threshold_generators',(/threshold_generators/),1) == -1) cycle IRP_IF MPI_DEBUG call mpi_print('zmq_get_dvector energy') IRP_ENDIF @@ -122,7 +122,7 @@ subroutine run_slave_main IRP_ENDIF if (zmq_get_dvector(zmq_to_qp_run_socket,1,'selection_weight',selection_weight,N_states) == -1) cycle pt2_e0_denominator(1:N_states) = energy(1:N_states) - TOUCH pt2_e0_denominator state_average_weight threshold_generators selection_weight + TOUCH pt2_e0_denominator state_average_weight threshold_generators selection_weight psi_det psi_coef if (mpi_master) then print *, 'N_det', N_det @@ -171,9 +171,9 @@ subroutine run_slave_main call write_double(6,(t1-t0),'Broadcast time') !--- - call omp_set_nested(.True.) + call omp_set_max_active_levels(8) call davidson_slave_tcp(0) - call omp_set_nested(.False.) + call omp_set_max_active_levels(1) print *, mpi_rank, ': Davidson done' !--- @@ -212,7 +212,7 @@ subroutine run_slave_main IRP_IF MPI_DEBUG call mpi_print('zmq_get_dvector threshold_generators') IRP_ENDIF - if (zmq_get_dvector(zmq_to_qp_run_socket,1,'threshold_generators',threshold_generators,1) == -1) cycle + if (zmq_get_dvector(zmq_to_qp_run_socket,1,'threshold_generators',(/threshold_generators/),1) == -1) cycle IRP_IF MPI_DEBUG call mpi_print('zmq_get_dvector energy') IRP_ENDIF @@ -230,7 +230,8 @@ subroutine run_slave_main IRP_ENDIF if (zmq_get_dvector(zmq_to_qp_run_socket,1,'selection_weight',selection_weight,N_states) == -1) cycle pt2_e0_denominator(1:N_states) = energy(1:N_states) - SOFT_TOUCH pt2_e0_denominator state_average_weight pt2_stoch_istate threshold_generators selection_weight + SOFT_TOUCH pt2_e0_denominator state_average_weight pt2_stoch_istate threshold_generators selection_weight psi_det psi_coef N_det_generators N_det_selectors + call wall_time(t1) call write_double(6,(t1-t0),'Broadcast time') @@ -296,11 +297,17 @@ subroutine run_slave_main print *, 'Number of threads', nproc_target endif - if (h0_type == 'SOP') then - PROVIDE det_to_occ_pattern + if (h0_type == 'CFG') then + PROVIDE det_to_configuration endif - PROVIDE global_selection_buffer + PROVIDE global_selection_buffer pt2_N_teeth pt2_F N_det_generators + PROVIDE psi_bilinear_matrix_columns_loc psi_det_alpha_unique psi_det_beta_unique + PROVIDE psi_bilinear_matrix_rows psi_det_sorted_order psi_bilinear_matrix_order + PROVIDE psi_bilinear_matrix_transp_rows_loc psi_bilinear_matrix_transp_columns + PROVIDE psi_bilinear_matrix_transp_order psi_selectors_coef_transp psi_det_sorted + PROVIDE psi_det_hii selection_weight pseudo_sym pt2_min_parallel_tasks + if (mpi_master) then print *, 'Running PT2' endif diff --git a/src/cipsi/stochastic_cipsi.irp.f b/src/cipsi/stochastic_cipsi.irp.f index c529795e..77c6ed48 100644 --- a/src/cipsi/stochastic_cipsi.irp.f +++ b/src/cipsi/stochastic_cipsi.irp.f @@ -92,7 +92,7 @@ subroutine run_stochastic_cipsi call write_double(6,correlation_energy_ratio, 'Correlation ratio') call print_summary(psi_energy_with_nucl_rep, & - pt2_data, pt2_data_err, N_det,N_occ_pattern,N_states,psi_s2) + pt2_data, pt2_data_err, N_det,N_configuration,N_states,psi_s2) call save_energy(psi_energy_with_nucl_rep, pt2_data % pt2) @@ -104,7 +104,9 @@ subroutine run_stochastic_cipsi ! Add selected determinants call copy_H_apply_buffer_to_wf() -! call save_wavefunction + if (save_wf_after_selection) then + call save_wavefunction + endif PROVIDE psi_coef PROVIDE psi_det @@ -131,7 +133,7 @@ subroutine run_stochastic_cipsi call save_energy(psi_energy_with_nucl_rep, pt2_data % pt2) call print_summary(psi_energy_with_nucl_rep, & - pt2_data , pt2_data_err, N_det, N_occ_pattern, N_states, psi_s2) + pt2_data , pt2_data_err, N_det, N_configuration, N_states, psi_s2) call save_iterations(psi_energy_with_nucl_rep(1:N_states),pt2_data % rpt2,N_det) call print_extrapolated_energy() endif diff --git a/src/cipsi/zmq_selection.irp.f b/src/cipsi/zmq_selection.irp.f index 448b409e..6f222d4f 100644 --- a/src/cipsi/zmq_selection.irp.f +++ b/src/cipsi/zmq_selection.irp.f @@ -48,7 +48,7 @@ subroutine ZMQ_selection(N_in, pt2_data) if (zmq_put_dvector(zmq_to_qp_run_socket,1,'selection_weight',selection_weight,N_states) == -1) then stop 'Unable to put selection_weight on ZMQ server' endif - if (zmq_put_dvector(zmq_to_qp_run_socket,1,'threshold_generators',threshold_generators,1) == -1) then + if (zmq_put_dvector(zmq_to_qp_run_socket,1,'threshold_generators',(/threshold_generators/),1) == -1) then stop 'Unable to put threshold_generators on ZMQ server' endif call create_selection_buffer(N, N*2, b) diff --git a/src/cis/20.cis.bats b/src/cis/20.cis.bats index 6dcb2c52..4f255c7b 100644 --- a/src/cis/20.cis.bats +++ b/src/cis/20.cis.bats @@ -129,7 +129,8 @@ function run() { @test "[Cu(NH3)4]2+" { # 29.7711s 3.45478m [[ -n ${TRAVIS} ]] && skip - run cu_nh3_4_2plus.ezfio -1862.97958709248 -1862.92454796197 -1862.91130872182 + run cu_nh3_4_2plus.ezfio -1862.97958885180 -1862.92457657404 -1862.91134959451 + } @test "SO2" { # 32.092s 1.47785m diff --git a/src/cis/cis.irp.f b/src/cis/cis.irp.f index 816253c5..acec29c2 100644 --- a/src/cis/cis.irp.f +++ b/src/cis/cis.irp.f @@ -79,6 +79,6 @@ subroutine run call ezfio_set_cis_energy(CI_energy) psi_coef = ci_eigenvectors SOFT_TOUCH psi_coef - call save_wavefunction + call save_wavefunction_truncated(1.d-12) end diff --git a/src/cisd/30.cisd.bats b/src/cisd/30.cisd.bats index 44365174..58d996f8 100644 --- a/src/cisd/30.cisd.bats +++ b/src/cisd/30.cisd.bats @@ -110,7 +110,8 @@ function run() { [[ -n $TRAVIS ]] && skip qp set_file cu_nh3_4_2plus.ezfio qp set_mo_class --core="[1-24]" --act="[25-45]" --del="[46-87]" - run -1862.98611018932 -1862.68751252590 + run -1862.98689579931 -1862.6883044626563 + } @test "ClF" { # 30.3225s diff --git a/src/csf/NEED b/src/csf/NEED new file mode 100644 index 00000000..d3d4d2c7 --- /dev/null +++ b/src/csf/NEED @@ -0,0 +1 @@ +determinants diff --git a/src/csf/cfgCI_interface.f90 b/src/csf/cfgCI_interface.f90 new file mode 100644 index 00000000..b701f0ec --- /dev/null +++ b/src/csf/cfgCI_interface.f90 @@ -0,0 +1,63 @@ +module cfunctions + use, intrinsic :: ISO_C_BINDING + interface + subroutine printcfglist(nint, ncfgs, cfglist) bind(C, name='printCFGList') + import C_INT32_T, C_INT64_T + integer(kind=C_INT32_T) :: nint + integer(kind=C_INT32_T) :: ncfgs + integer(kind=C_INT64_T) :: cfglist(nint,2,ncfgs) + end subroutine printcfglist + end interface + interface + subroutine getApqIJMatrixDims(Isomo, Jsomo, MS, rowsout, colsout) & + bind(C, name='getApqIJMatrixDims') + import C_INT32_T, C_INT64_T + integer(kind=C_INT64_T),value,intent(in) :: Isomo ! CSFI + integer(kind=C_INT64_T),value,intent(in) :: Jsomo ! CSFJ + integer(kind=C_INT64_T),value,intent(in) :: MS ! Ms = 2*Spin + integer(kind=C_INT32_T),intent(out):: rowsout + integer(kind=C_INT32_T),intent(out):: colsout + end subroutine getApqIJMatrixDims + end interface + interface + subroutine getApqIJMatrixDriver(Isomo, Jsomo, orbp, orbq, & + MS, NMO, CSFICSFJApqIJ, rowsmax, colsmax) bind(C, name='getApqIJMatrixDriverArrayInp') + import C_INT32_T, C_INT64_T, C_DOUBLE + integer(kind=C_INT64_T),value,intent(in) :: Isomo + integer(kind=C_INT64_T),value,intent(in) :: Jsomo + integer(kind=C_INT32_T),value,intent(in) :: orbp + integer(kind=C_INT32_T),value,intent(in) :: orbq + integer(kind=C_INT64_T),value,intent(in) :: MS + integer(kind=C_INT64_T),value,intent(in) :: NMO + integer(kind=C_INT32_T),intent(in) :: rowsmax + integer(kind=C_INT32_T),intent(in) :: colsmax + real (kind=C_DOUBLE ),intent(out) :: CSFICSFJApqIJ(rowsmax,colsmax) + !integer(kind=C_INT32_T),dimension(rowApqIJ,colApqIJ) :: ApqIJ + end subroutine getApqIJMatrixDriver + end interface + interface + subroutine getCSFtoDETTransformationMatrix(Isomo,& + MS, rowsmax, colsmax, csftodetmatrix) bind(C, name='convertCSFtoDetBasis') + import C_INT32_T, C_INT64_T, C_DOUBLE + integer(kind=C_INT64_T),value,intent(in) :: Isomo + integer(kind=C_INT64_T),value,intent(in) :: MS + integer(kind=C_INT32_T),intent(in) :: rowsmax + integer(kind=C_INT32_T),intent(in) :: colsmax + real (kind=C_DOUBLE ),intent(out) :: csftodetmatrix(rowsmax,colsmax) + end subroutine getCSFtoDETTransformationMatrix + end interface +end module cfunctions + +subroutine f_dgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC) & + bind(C, name='f_dgemm') + use iso_c_binding + implicit none + character, intent(in), value :: TRANSA, TRANSB + integer, intent(in), value :: M,N,K,LDA,LDB,LDC + double precision, intent(in), value :: ALPHA, BETA + double precision, intent(in) :: A(LDA,*), B(LDB,*) + double precision, intent(out) :: C(LDC,*) + call dgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC) +end subroutine + + diff --git a/src/csf/cfgCI_utils.c b/src/csf/cfgCI_utils.c new file mode 100644 index 00000000..23b984a0 --- /dev/null +++ b/src/csf/cfgCI_utils.c @@ -0,0 +1,1763 @@ +#include +#include +#include "tree_utils.h" + +void int_to_bin_digit(int64_t in, int count, int* out) +{ + /* assert: count <= sizeof(int)*CHAR_BIT */ + unsigned int mask = 1U << (count-1); + int i; + for (i = 0; i < count; i++) { + out[i] = (in & mask) ? 1 : 0; + in <<= 1; + } +} + +#include +#include +#include + +double logbinom(double n, double k) { + return lgamma(n+1)-lgamma(n-k+1)-lgamma(k+1); +} +double binom(double n, double k) { + return exp(logbinom(n,k)); +} + +void getncsfs1(int *inpnsomo, int *inpms, int *outncsfs){ + int nsomo = *inpnsomo; + int ms = *inpms; + int nparcoupl = (nsomo + ms)/2; + *outncsfs = binom(nsomo, nparcoupl); +} + +void getncsfs(int NSOMO, int MS, int *outncsfs){ + int nparcoupl = (NSOMO + MS)/2; + int nparcouplp1 = ((NSOMO + MS)/2)+1; + double tmpndets=0.0; + if(NSOMO == 0){ + (*outncsfs) = 1; + return; + } + tmpndets = binom(NSOMO, nparcoupl); + (*outncsfs) = round(tmpndets - binom(NSOMO, nparcouplp1)); +} + +#include + +void getBFIndexList(int NSOMO, int *BF1, int *IdxListBF1){ + int Iidx; + int Jidx; + int BFcopy[NSOMO]; + + int dictidx[2]; + dictidx[0] = -1; + dictidx[1] = 1; + + for(int i = 0; i < NSOMO; i++) + BFcopy[i] = BF1[i]; + + for(int i = 0; i < NSOMO; i++){ + Iidx = i; + if(BFcopy[i] == 0){ + int countN1=0; + for(int j = i+1; j < NSOMO; j++){ + Jidx = j; + countN1 = countN1 + dictidx[BFcopy[j]]; + if(countN1 > 0){ + break; + } + } + BFcopy[Iidx] = -1; + BFcopy[Jidx] = -1; + IdxListBF1[Jidx] = Iidx; + IdxListBF1[Iidx] = Jidx; + } + } + +} + +void getIslands(int NSOMO, int *BF1, int *BF2, int *nislands, int *phasefactor){ + + // Get BF ids + int *IdxListBF1 = malloc(NSOMO * sizeof(int)); + int *IdxListBF2 = malloc(NSOMO * sizeof(int)); + + getBFIndexList(NSOMO, BF1, IdxListBF1); + getBFIndexList(NSOMO, BF2, IdxListBF2); + + int sumids = 0; + int maxcount=0; + *nislands = 0; + *phasefactor = 1; + + int BF1copy[NSOMO]; + for(int i = 0; i < NSOMO; i++) + BF1copy[i] = IdxListBF1[i]; + int BF2copy[NSOMO]; + for(int i = 0; i < NSOMO; i++) + BF2copy[i] = IdxListBF2[i]; + + for(int i = 0; i < NSOMO; i++){ + int thisId = i; + int nextId = BF1copy[i]; + maxcount = 0; + while(BF1copy[thisId] != -1 && maxcount < 20){ + if(maxcount==0) *nislands += 1; + if(maxcount==19) *nislands -= 1; + + maxcount++; + + // First the bra + nextId = BF1copy[thisId]; + BF1copy[thisId] = -1; + BF1copy[nextId] = -1; + + // Get the phase factor bra + if(nextId < thisId) *phasefactor *= -1; + + // Then the ket + thisId = BF2copy[nextId]; + BF2copy[thisId] = -1; + BF2copy[nextId] = -1; + + // Get the phase factor bra + if(nextId < thisId) *phasefactor *= -1; + + } + + for(int j=0;j>= 1; + } + *nsetbits = count; +} + +void generateAllBFs(int64_t Isomo, int64_t MS, Tree *bftree, int *NBF, int *NSOMO){ + getSetBits(Isomo, NSOMO); + buildTreeDriver(bftree, *NSOMO, MS, NBF); +} + +void gramSchmidt(double *overlapMatrix, int rows, int cols, double *orthoMatrix){ + + // vector + double norm = 0.0; + double scalarprod = 0.0; + orthoMatrix[(rows-1)*cols + cols-1] = 1.0; + for(int i = cols-2; i > -1; i--){ orthoMatrix[(rows-1)*cols + i] = 0.0; } + + // Gram-Schmidt loop + for(int i = rows-2; i > -1; i--){ + for(int k = cols-1; k > -1; k--){ orthoMatrix[(i)*cols + k] = 0.0; } + orthoMatrix[i*cols + i] = 1.0; + + // orthogonalization + for(int j = rows-1; j > i; j--){ + // calculate scalar product + scalarprod = 0.0; + for(int k = cols-1;k>=j;k--){ + scalarprod += orthoMatrix[j*cols + k] * overlapMatrix[i*cols + k]; + } + for(int k = cols-1; k >= j; k--){ + orthoMatrix[i*cols + k] -= scalarprod * orthoMatrix[j*cols + k]; + } + } + + // Normalization + norm = 0.0; + for(int j = rows-1; j >= i; j--){ + for(int k=cols-1; k >= i; k--) + norm += orthoMatrix[i*cols + j]*orthoMatrix[i*cols + k]*overlapMatrix[j*cols+k]; + } + norm = sqrt(norm); + for(int j = rows-1; j >= i; j--){ + orthoMatrix[i*cols + j] /= norm; + } + + } + +} + +void get_phase_cfg_to_qp_inpList(int *inpdet, int NSOMO, int *phaseout){ + int nbetas=0; + (*phaseout) = 1; + for(int i=0;i 0){ + mask = (1< 0.0) phaseAll = 1.0; + //} + for(int j=0;j 0) free(overlapMatrixI); + if(rowsI + colsI > 0) free(orthoMatrixI); + if(rowsbftodetI + colsbftodetI > 0) free(bftodetmatrixI); + if(rowsI + colsbftodetI > 0) free(tmpcsftodet); +} + +#define BYTE_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c" +#define BYTE_TO_BINARY(byte) \ + (byte & 0x80 ? '1' : '0'), \ + (byte & 0x40 ? '1' : '0'), \ + (byte & 0x20 ? '1' : '0'), \ + (byte & 0x10 ? '1' : '0'), \ + (byte & 0x08 ? '1' : '0'), \ + (byte & 0x04 ? '1' : '0'), \ + (byte & 0x02 ? '1' : '0'), \ + (byte & 0x01 ? '1' : '0') + +int applyRemoveShftAddSOMOVMO(int idet, int p, int q, int *phase){ + // CSF: 1 1 1 1 0 1 + // DET: 1 0 1 0 1 + // | | + // p q + // p = 4 + // q = 1 + // + // result + // + // CSF: 1 0 1 1 1 1 + // DET: 1 1 0 0 1 + // maskp: + // 0 1 1 1 1 + // maskq: + // 0 0 0 0 1 + // maskpxq: + // 0 1 1 1 0 + // maskqxqi: + // 1 0 0 0 1 + int maskp = (1UL << p)-1; + int maskq = (1UL << q)-1; + int maskpxq = (maskp ^ maskq); + int maskpxqi = ~(maskp ^ maskq); + + // Step 1: remove + // clear bits from p + int outdet = idet; + int occatp = __builtin_popcount(idet & (1UL << (p-1))); + // remove the bit at p + outdet &= ~(1UL << (p-1)); + + // Step 2: shift + if(q > p){ + // start with q + + // calculate the phase + int na, nb; + int tmpdet = outdet & (maskpxq); + na = __builtin_popcount(tmpdet); + nb = __builtin_popcount(maskpxq) - na; + //int nfermions = occatp == 0 ? nb : na; + int nfermions = na+nb; + (*phase) = nfermions % 2 == 0 ? 1 : -1; + + int tmpdetq1 = outdet & maskpxq; + int tmpdetq2 = outdet & maskpxqi; + tmpdetq1 = tmpdetq1 >> 1; + outdet = tmpdetq1 | tmpdetq2; + // put electron at q + outdet = occatp == 0 ? outdet : outdet | (1UL<<(q-1)); + } + else{ + // shift bit to right + maskpxq = maskpxq >> 1; + maskpxqi = ~(maskpxq); + + // calculate the phase + int na, nb; + int tmpdet = outdet & (maskpxq); + na = __builtin_popcount(tmpdet); + nb = __builtin_popcount(maskpxq) - na; + //int nfermions = occatp == 0 ? nb : na; + int nfermions = na+nb; + (*phase) = nfermions % 2 == 0 ? 1 : -1; + + // start with p + // shift middle electrons to right + int tmpdetp1 = outdet & maskpxq; + int tmpdetp2 = outdet & maskpxqi; + tmpdetp1 = tmpdetp1 << 1; + outdet = tmpdetp1 | tmpdetp2; + // put electron at q + outdet = occatp == 0 ? outdet : outdet | (1UL<<(q-1)); + } + + // Done + return(outdet); +} + +int applyRemoveShftAddDOMOSOMO(int idet, int p, int q, int *phase){ + // CSF: 1 2 1 1 1 1 1 1 1 1 + // DET: 1 0 0 1 1 0 0 1 0 + // | | + // p q + // + // result + // + // CSF: 1 1 1 1 1 1 2 1 1 1 + // DET: 1 0 0 0 1 1 0 1 0 + // maskp: + // 0 1 1 1 1 1 1 1 1 + // maskq: + // 0 0 0 0 0 0 1 1 1 1 + int maskp = (1UL << p)-1; + int maskq = (1UL << q)-1; + int maskpxq = (maskp ^ maskq); + int maskpxqi = ~(maskp ^ maskq); + + // Step 1: remove + // clear bits from q + int outdet = idet; + int occatq = __builtin_popcount(idet & (1UL << (q-1))); + outdet &= ~(1UL << (q-1)); + + // Step 2: shift + if(q > p){ + // start with q + + // shift mask between p and q + maskpxq = maskpxq >> 1; + maskpxqi = ~(maskpxq); + // calculate the phase + int na, nb; + int tmpdet = outdet & (maskpxq); + na = __builtin_popcount(tmpdet); + nb = __builtin_popcount(maskpxq) - na; + // spin obb to that at q is moving + //int nfermions = occatq == 0 ? na : nb; + int nfermions = na + nb + 1; + (*phase) = nfermions % 2 == 0 ? 1 : -1; + + int tmpdetq1 = outdet & maskpxq; + int tmpdetq2 = outdet & maskpxqi; + tmpdetq1 = tmpdetq1 << 1; + outdet = tmpdetq1 | tmpdetq2; + + // Step 3: Add bit at p + 1 + outdet = occatq == 1 ? outdet | (1UL<<(p-1)) : outdet; + } + else{ + + // calculate the phase + int na, nb; + int tmpdet = outdet & (maskpxq); + na = __builtin_popcount(tmpdet); + nb = __builtin_popcount(maskpxq) - na; + // spin obb to that at q is moving + //int nfermions = occatq == 0 ? na : nb; + int nfermions = na + nb + 1; + (*phase) = nfermions % 2 == 0 ? 1 : -1; + + // start with p + // shift middle electrons to right + int tmpdetp1 = outdet & maskpxq; + int tmpdetp2 = outdet & maskpxqi; + tmpdetp1 = tmpdetp1 >> 1; + outdet = tmpdetp1 | tmpdetp2; + + // Step 3: Add bit at p + outdet = occatq == 1 ? outdet | (1UL<<(p-1)) : outdet; + } + + // Done + return(outdet); +} + +int applyRemoveShftSOMOSOMO(int idet, int p, int q, int *phase){ + // CSF: 1 1 1 1 1 1 1 1 1 1 + // DET: 1 1 0 0 1 1 0 0 1 0 + // | | + // p q + // + // result + // + // CSF: 1 1 1 1 1 1 1 1 + // DET: 1 0 0 1 1 0 1 0 + // maskp: + // 0 1 1 1 1 1 1 1 1 1 + // maskq: + // 0 0 0 0 0 0 0 1 1 1 + int maskp = (1UL << p)-1; + int maskq = (1UL << q)-1; + int maskpi =~maskp; + int maskqi =~maskq; + + // Step 1: remove + // clear bits from p and q + int outdet = idet; + outdet &= ~(1UL << (p-1)); + outdet &= ~(1UL << (q-1)); + + // calculate the phase + int occatp = idet & (1UL << (p-1)); + int na, nb; + int tmpdet = outdet & (maskp ^ maskq); + na = __builtin_popcount(tmpdet); + nb = abs(p-q)-1 - na; + //int nfermions = occatp == 0 ? nb : na; + + // Step 2: shift + if(q > p){ + int nfermions = occatp == 0 ? na+nb : na+nb+1; + (*phase) = nfermions % 2 == 0 ? 1 : -1; + // start with q + // shift everything left of q + int tmpdetq1 = outdet & maskq; + int tmpdetq2 = outdet & maskqi; + tmpdetq2 = tmpdetq2 >> 1; + outdet = tmpdetq1 | tmpdetq2; + + // shift everything left of p + int tmpdetp1 = outdet & maskp; + int tmpdetp2 = outdet & maskpi; + tmpdetp2 = tmpdetp2 >> 1; + outdet = tmpdetp1 | tmpdetp2; + } + else{ + int nfermions = occatp == 0 ? na+nb+1 : na+nb; + (*phase) = nfermions % 2 == 0 ? 1 : -1; + // start with p + // shift everything left of p + int tmpdetp1 = outdet & maskp; + int tmpdetp2 = outdet & maskpi; + tmpdetp2 = tmpdetp2 >> 1; + outdet = tmpdetp1 | tmpdetp2; + + // shift everything left of q + int tmpdetq1 = outdet & maskq; + int tmpdetq2 = outdet & maskqi; + tmpdetq2 = tmpdetq2 >> 1; + outdet = tmpdetq1 | tmpdetq2; + } + + // Done + return(outdet); +} + +unsigned int shftbit(int num, int p){ + unsigned int maskleft = ~(0 | ((1<> 1; + return(numleft | numright); +}; + +int getphase(int num, int p, int q, int nmo){ + // CSF: 1 1 1 1 1 1 1 1 1 1 + // DET: 1 1 0 0 1 1 0 0 1 0 + // | | + // p q + // | | + // CSF: 1 1 1 1 1 1 1 1 1 1 + // DET: 1 0 0 0 1 1 1 0 1 0 + // + // maskleft: + // 1 1 1 1 1 1 1 0 0 0 + // maskright: + // 0 1 1 1 1 1 1 1 1 1 + int omax = p > q ? p : q; + int omin = p > q ? q : p; + unsigned int maskleft = ~(0 | ((1<<(omin-1))-1)); + unsigned int maskright = ((1<<(omax))-1); + unsigned int maskmo = ((1<SOMO example + + 1 2 1 1 1 + p q + 1 1 1 1 2 + + p = 3 + q = 1 + + in determinant representation: (0->beta,1->alpha) + |I> = 0 0 1 1 + |____| + p q + + |ret> = 0 1 0 1 + A shift of bit at q to pos after p. + + */ + + int maskq = ~((1UL<> 1; + // Now combine with original det + int detout = (idet & maskpq); + // Zero out bits at q + detout &= ~(1UL << (q-1)); + // Set the bit at p + detout |= (1UL << (p-1)); + // Add the shifted bits + detout |= shifted_bits; + + // Now calcaulate the phase + // Find the type of bit at q + int occatq = idet & (1UL << (q-1)); + // calculate number of alpha and beta spins + int na = __builtin_popcount(shifted_bits); + int nb = p - q - na; + // Find the number of fermions to pass + int nfermions = occatq == 0 ? na : nb; + (*phase) = nfermions % 2 == 0 ? 1 : -1; + return(detout); +} + +void calcMEdetpair(int *detlistI, int *detlistJ, int orbI, int orbJ, int Isomo, int Jsomo, int ndetI, int ndetJ, int NMO, double *matelemdetbasis){ + + // Calculation of phase + // The following convention is used + // + // + // The phase is calculated + // assuming all alpha electrons + // are on the left and all beta + // electrons are on the RHS + // of the alphas. + + + int maskI; + int nelecatI; + unsigned int maskleft; + unsigned int maskright; + unsigned int psomo; + unsigned int qsomo; + + + // E(q,p) |I> = cqp |J> + + + int p,q; // The two orbitals p is always > q. + p = orbI >= orbJ ? orbI : orbJ; + q = orbI >= orbJ ? orbJ : orbI; + + // Find the corresponding case + // 1. NdetI > NdetJ (SOMO -> SOMO) + // 2. NdetI < NdetJ (DOMO -> VMO) + // 3. NdetI == NdetJ (SOMO -> VMO and DOMO -> SOMO) + + // Converting the above four cases into int: + int case_type = abs(ndetI - ndetJ) == 0 ? 3 : (ndetI > ndetJ ? 1 : 2); + + switch (case_type){ + case 1: + // SOMO -> SOMO + // Find the orbital ids in model space + maskleft = (0 | ((1<<(p))-1)); + maskright = (0 | ((1<<(q))-1)); + psomo = __builtin_popcount(Isomo & maskleft); + qsomo = q == 1 ? 1 : __builtin_popcount(Isomo & maskright); + p = psomo >= qsomo ? psomo : qsomo; + q = psomo >= qsomo ? qsomo : psomo; + + for(int i=0;i VMO + // Find the orbital ids in model space + maskleft = (0 | ((1<<(p))-1)); + maskright =(0 | ((1<<(q))-1)); + psomo = __builtin_popcount(Jsomo & maskleft); + qsomo = q == 1 ? 1 : __builtin_popcount(Jsomo & maskright); + p = psomo >= qsomo ? psomo : qsomo; + q = psomo >= qsomo ? qsomo : psomo; + + for(int i=0;i VMO or DOMO -> SOMO) + // if Isomo[p] == 1 => SOMO -> VMO + // if Isomo[p] == 0 => DOMO -> SOMO + // Find the orbital ids in model space + maskleft = ((1<<(p))-1); + maskright =((1<<(q))-1); + psomo = __builtin_popcount(Isomo & maskleft); + //qsomo = q == 1 ? 1 : __builtin_popcount(Isomo & maskright); + qsomo = __builtin_popcount(Isomo & maskright); + p = psomo >= qsomo ? psomo : qsomo; + q = psomo >= qsomo ? qsomo : psomo; + + + int noccorbI = (Isomo & (1<<(orbI-1))); + switch (noccorbI){ + case 0: + // Case: DOMO -> SOMO + break; + case 1: + // Case: SOMO -> VMO + break; + default: + printf("Something is wrong in calcMEdetpair\n"); + break; + } + + int tmpidet; + + for(int i=0;i SOMO + // + // I = + // 2 1 1 1 1 + // (10) 0 0 1 1 + // + // | + // \ / + // . + // 0 0 0 1 1 + // + // J = + // 1 1 1 1 2 + // 0 0 1 1 (10) + // + if(nelecalphaatp == 0){ + // Case: DOMO -> SOMO + tmpidet = idet; + int nelecalphaatq = (idet & (1<<(orbJ-1))); + if(nelecalphaatq==0) tmpidet = tmpidet ^ (1<<(orbI-1)); + else tmpidet = tmpidet ^ (0); + idet = shftbit(idet,q); + } + else{ + tmpidet = idet; + idet = shftbit(idet,p); + } + + // Calculate phase + int phase = 1*getphase(tmpidet,orbI,orbJ,NMO); + for(int j=0;j + // + // The phase is calculated + // assuming all alpha electrons + // are on the left and all beta + // electrons are on the RHS + // of the alphas. + + // There are three possibilities + // which need to be separated + // CASE 1. p > q + // CASE 2. p < q + // CASE 3. p == q + + int maskI; + int nelecatI; + int noccorbI; + double phaseI=1.0; + double phaseJ=1.0; + unsigned int maskleft; + unsigned int maskright; + unsigned int psomo; + unsigned int qsomo; + + int p,q; // The two orbitals p is always > q. + + if(orbI > orbJ){ + // CASE 1 : orbI > orbJ + p = orbI; + q = orbJ; + + // Find the corresponding sub case + // 1. NdetI > NdetJ (SOMO -> SOMO) + // 2. NdetI < NdetJ (DOMO -> VMO) + // 3. NdetI == NdetJ (SOMO -> VMO and DOMO -> SOMO) + + // Converting the above four cases into int: + int case_type = abs(ndetI - ndetJ) == 0 ? 3 : (ndetI > ndetJ ? 1 : 2); + p = orbI; + q = orbJ; + + switch (case_type){ + case 1: + // SOMO -> SOMO + // Find the orbital ids in model space + maskleft = (0 | ((1<<(p))-1)); + maskright = (0 | ((1<<(q))-1)); + psomo = __builtin_popcount(Isomo & maskleft); + qsomo = __builtin_popcount(Isomo & maskright); // q has to be atleast 1 + p = psomo; + q = qsomo; + + for(int i=0;i VMO + // Find the orbital ids in model space + // As seen in Jsomo + // Here we apply a^{\dagger}_p a_q |J> + maskleft = (0 | ((1<<(p))-1)); + maskright =(0 | ((1<<(q))-1)); + psomo = __builtin_popcount(Jsomo & maskleft); + qsomo = __builtin_popcount(Jsomo & maskright); // q has to be atleast 1 + p = psomo; + q = qsomo; + + for(int i=0;i VMO or DOMO -> SOMO) + noccorbI = __builtin_popcount(Isomo & (1<<(orbI-1))); + + switch (noccorbI){ + case 0: + // Case: DOMO -> SOMO + // Find the orbital ids in model space + // Ex: + // 2 1 1 1 1 + // p q + // 1 1 1 2 1 + // p = 4 + // q = 2 + // p is from Jsomo + // q is from Isomo + maskleft = ((1<<(p))-1); + maskright =((1<<(q))-1); + psomo = __builtin_popcount(Jsomo & maskleft); + qsomo = __builtin_popcount(Isomo & maskright); + p = psomo; + q = qsomo; + + for(int i=0;i VMO + // Find the orbital ids in model space + // Ex: + // 1 1 1 0 1 + // p q + // 0 1 1 1 1 + // p = 4 + // q = 1 + // p is from Isomo + // q is from Jsomo + maskleft = ((1<<(p))-1); + maskright =((1<<(q))-1); + psomo = __builtin_popcount(Isomo & maskleft); + qsomo = __builtin_popcount(Jsomo & maskright); + p = psomo; + q = qsomo; + + for(int i=0;i orbJ + else if(orbI < orbJ){ + // CASE 2 orbI < orbJ + p = orbI; + q = orbJ; + // Find the corresponding sub case + // 1. NdetI > NdetJ (SOMO -> SOMO) + // 2. NdetI < NdetJ (DOMO -> VMO) + // 3. NdetI == NdetJ (SOMO -> VMO and DOMO -> SOMO) + + // Converting the above four cases into int: + int case_type = abs(ndetI - ndetJ) == 0 ? 3 : (ndetI > ndetJ ? 1 : 2); + + switch (case_type){ + case 1: + // SOMO -> SOMO + // Find the orbital ids in model space + maskleft = (0 | ((1<<(p))-1)); + maskright = (0 | ((1<<(q))-1)); + psomo = __builtin_popcount(Isomo & maskleft); + qsomo = __builtin_popcount(Isomo & maskright); // q has to be atleast 1 + p = psomo; + q = qsomo; + + for(int i=0;i VMO + // Find the orbital ids in model space + // As seen in Jsomo + // Here we apply a^{\dagger}_p a_q |J> + maskleft = (0 | ((1<<(p))-1)); + maskright =(0 | ((1<<(q))-1)); + psomo = __builtin_popcount(Jsomo & maskleft); + qsomo = __builtin_popcount(Jsomo & maskright); // q has to be atleast 1 + p = psomo; + q = qsomo; + + for(int i=0;i VMO or DOMO -> SOMO) + // if Isomo[p] == 1 => SOMO -> VMO + // if Isomo[p] == 0 => DOMO -> SOMO + noccorbI = __builtin_popcount(Isomo & (1<<(orbI-1))); + + switch (noccorbI){ + case 0: + // Case: DOMO -> SOMO + // Find the orbital ids in model space + // Ex: + // 1 1 1 2 1 + // q p + // 2 1 1 1 1 + // p = 1 + // q = 4 + // p is from Jsomo + // q is from Isomo + maskleft = ((1<<(p))-1); + maskright =((1<<(q))-1); + psomo = __builtin_popcount(Jsomo & maskleft); + qsomo = __builtin_popcount(Isomo & maskright); + p = psomo; + q = qsomo; + + for(int i=0;i VMO + // Find the orbital ids in model space + // Ex: + // 0 1 1 1 1 + // q p + // 1 1 1 0 1 + // p = 2 + // q = 4 + // p is from Isomo + // q is from Jsomo + maskleft = ((1<<(p))-1); + maskright =((1<<(q))-1); + psomo = __builtin_popcount(Isomo & maskleft); + qsomo = __builtin_popcount(Jsomo & maskright); + p = psomo; + q = qsomo; + + for(int i=0;i 0.0 || donepq[idxq] > 0.0) continue; + fac *= 2.0; + donepq[idxp] = 1.0; + donepq[idxq] = 1.0; + for(int j = 0; j < npairs; j = j + shft){ + for(int k = 0; k < shft/2; k++){ + detslist[(k+j)*NSOMO + idxp] = 1; + detslist[(k+j)*NSOMO + idxq] = 0; + } + for(int k = shft/2; k < shft; k++){ + detslist[(k+j)*NSOMO + idxp] = 0; + detslist[(k+j)*NSOMO + idxq] = 1; + phaselist[k+j] *=-1; + } + } + shft /= 2; + } + + // Now get the addresses + int inpdet[NSOMO]; + int phase_cfg_to_qp=1; + int addr = -1; + for(int i = 0; i < npairs; i++){ + for(int j = 0; j < NSOMO; j++) + inpdet[j] = detslist[i*NSOMO + j]; + findAddofDetDriver(dettree, NSOMO, inpdet, &addr); + // Calculate the phase for cfg to QP2 conversion + //get_phase_cfg_to_qp_inpList(inpdet, NSOMO, &phase_cfg_to_qp); + //rowvec[addr] = 1.0 * phaselist[i]*phase_cfg_to_qp/sqrt(fac); + rowvec[addr] = 1.0 * phaselist[i]/sqrt(fac); + // Upon transformation from + // SOMO to DET basis, + // all dets have the same phase + // Is this true ? + //rowvec[addr] = 1.0/sqrt(fac); + } + + free(detslist); + free(phaselist); +} + +void convertBFtoDetBasis(int64_t Isomo, int MS, double **bftodetmatrixptr, int *rows, int *cols){ + + int NSOMO=0; + getSetBits(Isomo, &NSOMO); + int ndets = 0; + int NBF = 0; + double dNSOMO = NSOMO*1.0; + double nalpha = (NSOMO + MS)/2.0; + ndets = (int)binom(dNSOMO, nalpha); + + Tree dettree = (Tree){ .rootNode = NULL, .NBF = -1 }; + dettree.rootNode = malloc(sizeof(Node)); + (*dettree.rootNode) = (Node){ .C0 = NULL, .C1 = NULL, .PREV = NULL, .addr = 0, .cpl = -1, .iSOMO = -1}; + + genDetBasis(&dettree, Isomo, MS, &ndets); + + if(ndets == 1){ + // Initialize transformation matrix + NBF = 1; + (*bftodetmatrixptr) = malloc(NBF*ndets*sizeof(double)); + (*rows) = 1; + (*cols) = 1; + + double *bftodetmatrix = (*bftodetmatrixptr); + bftodetmatrix[0] = 1.0; + + } + else{ + + //int addr = -1; + //int inpdet[NSOMO]; + //inpdet[0] = 1; + //inpdet[1] = 1; + //inpdet[2] = 1; + //inpdet[3] = 0; + //inpdet[4] = 0; + //inpdet[5] = 0; + + //findAddofDetDriver(&dettree, NSOMO, inpdet, &addr); + + int detlist[ndets]; + getDetlistDriver(&dettree, NSOMO, detlist); + + // Prepare BFs + Tree bftree = (Tree){ .rootNode = NULL, .NBF = -1 }; + bftree.rootNode = malloc(sizeof(Node)); + (*bftree.rootNode) = (Node){ .C0 = NULL, .C1 = NULL, .PREV = NULL, .addr = 0, .cpl = -1, .iSOMO = -1}; + + generateAllBFs(Isomo, MS, &bftree, &NBF, &NSOMO); + + // Initialize transformation matrix + (*bftodetmatrixptr) = malloc(NBF*ndets*sizeof(double)); + (*rows) = NBF; + (*cols) = ndets; + + double *bftodetmatrix = (*bftodetmatrixptr); + + // Build BF to det matrix + int addI = 0; + int addJ = 0; + double rowvec[ndets]; + for(int i=0;i 1 + +} + + +void convertBFtoDetBasisWithArrayDims(int64_t Isomo, int MS, int rowsmax, int colsmax, int *rows, int *cols, double *bftodetmatrix){ + + int NSOMO=0; + getSetBits(Isomo, &NSOMO); + int ndets = 0; + int NBF = 0; + double dNSOMO = NSOMO*1.0; + double nalpha = (NSOMO + MS)/2.0; + ndets = (int)binom(dNSOMO, nalpha); + + Tree dettree = (Tree){ .rootNode = NULL, .NBF = -1 }; + dettree.rootNode = malloc(sizeof(Node)); + (*dettree.rootNode) = (Node){ .C0 = NULL, .C1 = NULL, .PREV = NULL, .addr = 0, .cpl = -1, .iSOMO = -1}; + + genDetBasis(&dettree, Isomo, MS, &ndets); + + //int addr = -1; + //int inpdet[NSOMO]; + //inpdet[0] = 1; + //inpdet[1] = 1; + //inpdet[2] = 1; + //inpdet[3] = 0; + //inpdet[4] = 0; + //inpdet[5] = 0; + + //findAddofDetDriver(&dettree, NSOMO, inpdet, &addr); + + int detlist[ndets]; + getDetlistDriver(&dettree, NSOMO, detlist); + + // Prepare BFs + Tree bftree = (Tree){ .rootNode = NULL, .NBF = -1 }; + bftree.rootNode = malloc(sizeof(Node)); + (*bftree.rootNode) = (Node){ .C0 = NULL, .C1 = NULL, .PREV = NULL, .addr = 0, .cpl = -1, .iSOMO = -1}; + + generateAllBFs(Isomo, MS, &bftree, &NBF, &NSOMO); + + // Initialize transformation matrix + //(*bftodetmatrixptr) = malloc(NBF*ndets*sizeof(double)); + (*rows) = NBF; + (*cols) = ndets; + + //double *bftodetmatrix = (*bftodetmatrixptr); + + // Build BF to det matrix + int addI = 0; + int addJ = 0; + double rowvec[ndets]; + for(int i=0;i SOMO + ! Type 2 - DOMO -> VMO + ! Type 3 - SOMO -> VMO + ! Type 4 - DOMO -> SOMO + END_DOC + integer(bit_kind),intent(in) :: Ialpha(N_int,2) + integer(bit_kind),intent(in) :: Jcfg(N_int,2) + integer,intent(in) :: p,q + integer,intent(in) :: extype + integer,intent(out) :: pmodel,qmodel + integer*8 :: Isomo + integer*8 :: Idomo + integer*8 :: Jsomo + integer*8 :: Jdomo + integer*8 :: mask + integer*8 :: Isomotmp + integer*8 :: Jsomotmp + integer :: pos0,pos0prev + + ! TODO Flag (print) when model space indices is > 64 + Isomo = Ialpha(1,1) + Idomo = Ialpha(1,2) + Jsomo = Jcfg(1,1) + Jdomo = Jcfg(1,2) + pos0prev = 0 + pmodel = p + qmodel = q + + if(p .EQ. q) then + pmodel = 1 + qmodel = 1 + else + !print *,"input pq=",p,q,"extype=",extype + !call debug_spindet(Isomo,1) + !call debug_spindet(Idomo,1) + !call debug_spindet(Jsomo,1) + !call debug_spindet(Jdomo,1) + select case(extype) + case (1) + ! SOMO -> SOMO + ! remove all domos + !print *,"type -> SOMO -> SOMO" + mask = ISHFT(1_8,p) - 1 + Isomotmp = IAND(Isomo,mask) + pmodel = POPCNT(mask) - POPCNT(XOR(Isomotmp,mask)) + mask = ISHFT(1_8,q) - 1 + Isomotmp = IAND(Isomo,mask) + qmodel = POPCNT(mask) - POPCNT(XOR(Isomotmp,mask)) + case (2) + ! DOMO -> VMO + ! remove all domos except one at p + !print *,"type -> DOMO -> VMO" + mask = ISHFT(1_8,p) - 1 + Jsomotmp = IAND(Jsomo,mask) + pmodel = POPCNT(mask) - POPCNT(XOR(Jsomotmp,mask)) + mask = ISHFT(1_8,q) - 1 + Jsomotmp = IAND(Jsomo,mask) + qmodel = POPCNT(mask) - POPCNT(XOR(Jsomotmp,mask)) + case (3) + ! SOMO -> VMO + !print *,"type -> SOMO -> VMO" + !Isomo = IEOR(Isomo,Jsomo) + mask = ISHFT(1_8,p) - 1 + Isomo = IAND(Isomo,mask) + pmodel = POPCNT(mask) - POPCNT(XOR(Isomo,mask)) + mask = ISHFT(1_8,q) - 1 + Jsomo = IAND(Jsomo,mask) + qmodel = POPCNT(mask) - POPCNT(XOR(Jsomo,mask)) + case (4) + ! DOMO -> SOMO + ! remove all domos except one at p + !print *,"type -> DOMO -> SOMO" + !Isomo = IEOR(Isomo,Jsomo) + mask = ISHFT(1_8,p) - 1 + Jsomo = IAND(Jsomo,mask) + pmodel = POPCNT(mask) - POPCNT(XOR(Jsomo,mask)) + mask = ISHFT(1_8,q) - 1 + Isomo = IAND(Isomo,mask) + qmodel = POPCNT(mask) - POPCNT(XOR(Isomo,mask)) + case default + print *,"something is wrong in convertOrbIdsToModelSpaceIds" + end select + endif + !print *,p,q,"model ids=",pmodel,qmodel +end subroutine convertOrbIdsToModelSpaceIds diff --git a/src/csf/configuration_CI_sigma_helpers.org b/src/csf/configuration_CI_sigma_helpers.org new file mode 100644 index 00000000..ede42b97 --- /dev/null +++ b/src/csf/configuration_CI_sigma_helpers.org @@ -0,0 +1,562 @@ +#+title: Configuration Sigma Vector Helpers +#+author: Vijay Gopal Chilkuri +#+email: vijay.gopal.c@gmail.com + +* Generate the singly excited configurations on-the-fly + +The algorithm is based on the work by Garniron et. al. (see thesis Chap 5). +The basic idea is to generate \(|\alpha\rangle\)'s on-the-fly. + +The algorithm is based on the idea of splitting the list of \(|\alpha\rangle\)'s +into blocks associated with a selected determinant \(|D_I\rangle\). + +** Create a function to return a list of alphas + +Here we create a list of \(|\alpha\rangle\)'s associated with +the input determinant \(|D_I\rangle\). + +#+begin_src f90 :main no :tangle configuration_CI_sigma_helpers.irp.f + subroutine obtain_associated_alphaI(idxI, Icfg, alphasIcfg, NalphaIcfg, factor_alphaI) + implicit none + use bitmasks + BEGIN_DOC + ! Documentation for alphasI + ! Returns the associated alpha's for + ! the input configuration Icfg. + END_DOC + + integer,intent(in) :: idxI ! The id of the Ith CFG + integer(bit_kind),intent(in) :: Icfg(N_int,2) + integer,intent(out) :: NalphaIcfg + real*8 ,intent(out) :: factor_alphaI(*) + integer(bit_kind),intent(out) :: alphasIcfg(N_int,2,*) + logical,dimension(:,:),allocatable :: tableUniqueAlphas + integer :: listholes(mo_num) + integer :: holetype(mo_num) ! 1-> SOMO 2->DOMO + integer :: nholes + integer :: nvmos + integer :: listvmos(mo_num) + integer :: vmotype(mo_num) ! 1 -> VMO 2 -> SOMO + integer*8 :: Idomo + integer*8 :: Isomo + integer*8 :: Jdomo + integer*8 :: Jsomo + integer*8 :: diffSOMO + integer*8 :: diffDOMO + integer :: ndiffSOMO + integer :: ndiffDOMO + integer :: ndiffAll + integer :: i + integer :: j + integer :: k + integer :: hole + integer :: p + integer :: q + integer :: countalphas + logical :: pqAlreadyGenQ + logical :: pqExistsQ + Isomo = iand(reunion_of_act_virt_bitmask(1,1),Icfg(1,1)) + Idomo = iand(reunion_of_act_virt_bitmask(1,1),Icfg(1,2)) + !print*,"Input cfg" + !call debug_spindet(Isomo,1) + !call debug_spindet(Idomo,1) + + !print*,n_act_orb, "monum=",mo_num," n_core=",n_core_orb + + ! find out all pq holes possible + nholes = 0 + ! holes in SOMO + do i = n_core_orb+1,n_core_orb + n_act_orb + if(POPCNT(IAND(Isomo,IBSET(0_8,i-1))) .EQ. 1) then + nholes += 1 + listholes(nholes) = i + holetype(nholes) = 1 + endif + end do + ! holes in DOMO + do i = n_core_orb+1,n_core_orb + n_act_orb + if(POPCNT(IAND(Idomo,IBSET(0_8,i-1))) .EQ. 1) then + nholes += 1 + listholes(nholes) = i + holetype(nholes) = 2 + endif + end do + + ! find vmos + listvmos = -1 + vmotype = -1 + nvmos = 0 + do i = n_core_orb+1,n_core_orb + n_act_orb + !print *,i,IBSET(0,i-1),POPCNT(IAND(Isomo,(IBSET(0_8,i-1)))), POPCNT(IAND(Idomo,(IBSET(0_8,i-1)))) + if(POPCNT(IAND(Isomo,(IBSET(0_8,i-1)))) .EQ. 0 .AND. POPCNT(IAND(Idomo,(IBSET(0_8,i-1)))) .EQ. 0) then + nvmos += 1 + listvmos(nvmos) = i + vmotype(nvmos) = 1 + else if(POPCNT(IAND(Isomo,(IBSET(0_8,i-1)))) .EQ. 1 .AND. POPCNT(IAND(Idomo,(IBSET(0_8,i-1)))) .EQ. 0 ) then + nvmos += 1 + listvmos(nvmos) = i + vmotype(nvmos) = 2 + end if + end do + + !print *,"Nvmo=",nvmos + !print *,listvmos + !print *,vmotype + + allocate(tableUniqueAlphas(mo_num,mo_num)) + tableUniqueAlphas = .FALSE. + + ! Now find the allowed (p,q) excitations + Isomo = iand(reunion_of_act_virt_bitmask(1,1),Icfg(1,1)) + Idomo = iand(reunion_of_act_virt_bitmask(1,1),Icfg(1,2)) + !print *,"Isomo" + !call debug_spindet(Isomo,1) + !call debug_spindet(Idomo,1) + + !print *,"Nholes=",nholes," Nvmos=",nvmos, " idxi=",idxI + !do i = 1,nholes + ! print *,i,"->",listholes(i) + !enddo + !do i = 1,nvmos + ! print *,i,"->",listvmos(i) + !enddo + + ! TODO cfg_seniority_index + do i = 1,nholes + p = listholes(i) + do j = 1,nvmos + q = listvmos(j) + if(p == q) cycle + if(holetype(i) .EQ. 1 .AND. vmotype(j) .EQ. 1) then + ! SOMO -> VMO + Jsomo = IBCLR(Isomo,p-1) + Jsomo = IBSET(Jsomo,q-1) + Jdomo = Idomo + else if(holetype(i) .EQ. 1 .AND. vmotype(j) .EQ. 2) then + ! SOMO -> SOMO + Jsomo = IBCLR(Isomo,p-1) + Jsomo = IBCLR(Jsomo,q-1) + Jdomo = IBSET(Idomo,q-1) + else if(holetype(i) .EQ. 2 .AND. vmotype(j) .EQ. 1) then + ! DOMO -> VMO + Jsomo = IBSET(Isomo,p-1) + Jsomo = IBSET(Jsomo,q-1) + Jdomo = IBCLR(Idomo,p-1) + else if(holetype(i) .EQ. 2 .AND. vmotype(j) .EQ. 2) then + ! DOMO -> SOMO + Jsomo = IBSET(Isomo,p-1) + Jsomo = IBCLR(Jsomo,q-1) + Jdomo = IBCLR(Idomo,p-1) + Jdomo = IBSET(Jdomo,q-1) + else + print*,"Something went wrong in obtain_associated_alphaI" + endif + + + pqAlreadyGenQ = .FALSE. + ! First check if it can be generated before + do k = 1, idxI-1 + diffSOMO = IEOR(Jsomo,iand(reunion_of_act_virt_bitmask(1,1),psi_configuration(1,1,k))) + diffDOMO = IEOR(Jdomo,iand(reunion_of_act_virt_bitmask(1,1),psi_configuration(1,2,k))) + ndiffSOMO = POPCNT(diffSOMO) + ndiffDOMO = POPCNT(diffDOMO) + if(POPCNT(IEOR(diffSOMO,diffDOMO)) .LE. 1 .AND. ndiffDOMO .LT. 3) then + pqAlreadyGenQ = .TRUE. + !print *,i,k,ndiffSOMO,ndiffDOMO + !call debug_spindet(Jsomo,1) + !call debug_spindet(Jdomo,1) + !call debug_spindet(iand(reunion_of_act_virt_bitmask(1,1),psi_configuration(1,1,k)),1) + !call debug_spindet(iand(reunion_of_act_virt_bitmask(1,1),psi_configuration(1,2,k)),1) + EXIT + endif + end do + + if(pqAlreadyGenQ) cycle + + pqExistsQ = .FALSE. + ! now check if this exists in the selected list + do k = idxI, N_configuration + diffSOMO = IEOR(OR(reunion_of_act_virt_bitmask(1,1),Jsomo),psi_configuration(1,1,k)) + diffDOMO = IEOR(OR(reunion_of_act_virt_bitmask(1,1),Jdomo),psi_configuration(1,2,k)) + ndiffSOMO = POPCNT(diffSOMO) + ndiffDOMO = POPCNT(diffDOMO) + if((ndiffSOMO + ndiffDOMO) .EQ. 0) then + pqExistsQ = .TRUE. + EXIT + endif + end do + + if(.NOT. pqExistsQ) then + tableUniqueAlphas(p,q) = .TRUE. + !print *,p,q + !call debug_spindet(Jsomo,1) + !call debug_spindet(Jdomo,1) + endif + end do + end do + + !print *,tableUniqueAlphas(:,:) + + ! prune list of alphas + Isomo = Icfg(1,1) + Idomo = Icfg(1,2) + Jsomo = Icfg(1,1) + Jdomo = Icfg(1,2) + NalphaIcfg = 0 + do i = 1, nholes + p = listholes(i) + do j = 1, nvmos + q = listvmos(j) + if(p .EQ. q) cycle + if(tableUniqueAlphas(p,q)) then + if(holetype(i) .EQ. 1 .AND. vmotype(j) .EQ. 1) then + ! SOMO -> VMO + Jsomo = IBCLR(Isomo,p-1) + Jsomo = IBSET(Jsomo,q-1) + Jdomo = Idomo + else if(holetype(i) .EQ. 1 .AND. vmotype(j) .EQ. 2) then + ! SOMO -> SOMO + Jsomo = IBCLR(Isomo,p-1) + Jsomo = IBCLR(Jsomo,q-1) + Jdomo = IBSET(Idomo,q-1) + else if(holetype(i) .EQ. 2 .AND. vmotype(j) .EQ. 1) then + ! DOMO -> VMO + Jsomo = IBSET(Isomo,p-1) + Jsomo = IBSET(Jsomo,q-1) + Jdomo = IBCLR(Idomo,p-1) + else if(holetype(i) .EQ. 2 .AND. vmotype(j) .EQ. 2) then + ! DOMO -> SOMO + Jsomo = IBSET(Isomo,p-1) + Jsomo = IBCLR(Jsomo,q-1) + Jdomo = IBCLR(Idomo,p-1) + Jdomo = IBSET(Jdomo,q-1) + else + print*,"Something went wrong in obtain_associated_alphaI" + endif + + NalphaIcfg += 1 + !print *,p,q,"|",holetype(i),vmotype(j),NalphaIcfg + !call debug_spindet(Idomo,1) + !call debug_spindet(Jdomo,1) + alphasIcfg(1,1,NalphaIcfg) = Jsomo + alphasIcfg(1,2,NalphaIcfg) = IOR(Jdomo,ISHFT(1_8,n_core_orb)-1) + endif + end do + end do + + end subroutine +#+end_src + +** Given an \(\alpha\) CFG, return all the \(|I\rangle\) CFGs + +Next step is to obtain the connected CFGs \(|I\rangle\) that belong to the selected space +given a RI configuration \(|\alpha\rangle\). + +#+begin_src f90 :main no :tangle ../cfgCI/obtain_I_foralpha.irp.f +subroutine obtain_connected_I_foralpha(idxI, Ialpha, connectedI, idxs_connectedI, nconnectedI, excitationIds, excitationTypes) + implicit none + use bitmasks + BEGIN_DOC + ! Documentation for obtain_connected_I_foralpha + ! This function returns all those selected configurations + ! which are connected to the input configuration + ! Ialpha by a single excitation. + ! + ! The type of excitations are ordered as follows: + ! Type 1 - SOMO -> SOMO + ! Type 2 - DOMO -> VMO + ! Type 3 - SOMO -> VMO + ! Type 4 - DOMO -> SOMO + ! + ! Order of operators + ! \alpha> = a^\dag_p a_q |I> = E_pq |I> + END_DOC + integer ,intent(in) :: idxI + integer(bit_kind),intent(in) :: Ialpha(N_int,2) + integer(bit_kind),intent(out) :: connectedI(N_int,2,*) + integer ,intent(out) :: idxs_connectedI(*) + integer,intent(out) :: nconnectedI + integer,intent(out) :: excitationIds(2,*) + integer,intent(out) :: excitationTypes(*) + integer*8 :: Idomo + integer*8 :: Isomo + integer*8 :: Jdomo + integer*8 :: Jsomo + integer*8 :: IJsomo + integer*8 :: diffSOMO + integer*8 :: diffDOMO + integer :: ndiffSOMO + integer :: ndiffDOMO + integer :: i,j,k,l,p,q,nsomoJ,nsomoalpha,starti,endi,extyp,nholes + integer :: listholes(mo_num) + integer :: holetype(mo_num) + + ! find out all pq holes possible + nholes = 0 + ! holes in SOMO + Isomo = psi_configuration(1,1,idxI) + Idomo = psi_configuration(1,2,idxI) + do i = n_core_orb+1,n_core_orb + n_act_orb + if(POPCNT(IAND(Isomo,IBSET(0_8,i-1))) .EQ. 1) then + nholes += 1 + listholes(nholes) = i + holetype(nholes) = 1 + endif + end do + ! holes in DOMO + do i = n_core_orb+1,n_core_orb + n_act_orb + if(POPCNT(IAND(Idomo,IBSET(0_8,i-1))) .EQ. 1) then + nholes += 1 + listholes(nholes) = i + holetype(nholes) = 2 + endif + end do + + nconnectedI = 0 + + p = 0 + q = 0 + do i=idxI+1,N_configuration + Isomo = Ialpha(1,1) + Idomo = Ialpha(1,2) + Jsomo = psi_configuration(1,1,i) + Jdomo = psi_configuration(1,2,i) + !call debug_spindet(Isomo,1) + !call debug_spindet(Idomo,1) + !print *,"-J--i=",i,Idomo,Jdomo,">",N_configuration + !call debug_spindet(Jsomo,1) + !call debug_spindet(Jdomo,1) + diffSOMO = IEOR(Isomo,Jsomo) + diffDOMO = IEOR(Idomo,Jdomo) + ndiffSOMO = POPCNT(diffSOMO) + ndiffDOMO = POPCNT(diffDOMO) + if((ndiffSOMO + ndiffDOMO) .EQ. 0) cycle + !print *,"-I--i=",i,diffSOMO,diffDOMO!Isomo,Jsomo,ndiffSOMO,ndiffDOMO + !print *,POPCNT(IEOR(diffSOMO,diffDOMO)), ndiffDOMO + if(POPCNT(IEOR(diffSOMO,diffDOMO)) .LE. 1 .AND. ndiffDOMO .LT. 3) then + !call debug_spindet(Isomo,1) + !call debug_spindet(Idomo,1) + !print *,"-J--i=",i,Idomo,Jdomo,">",N_configuration + !call debug_spindet(Jsomo,1) + !call debug_spindet(Jdomo,1) + select case(ndiffDOMO) + case (0) + ! SOMO -> VMO + !print *,"obt SOMO -> VMO" + extyp = 3 + IJsomo = IEOR(Isomo, Jsomo) + p = TRAILZ(IAND(Isomo,IJsomo)) + 1 + IJsomo = IBCLR(IJsomo,p-1) + q = TRAILZ(IJsomo) + 1 + case (1) + ! DOMO -> VMO + ! or + ! SOMO -> SOMO + nsomoJ = POPCNT(Jsomo) + nsomoalpha = POPCNT(Isomo) + if(nsomoJ .GT. nsomoalpha) then + ! DOMO -> VMO + !print *,"obt DOMO -> VMO" + extyp = 2 + p = TRAILZ(IEOR(Idomo,Jdomo)) + 1 + Isomo = IEOR(Isomo, Jsomo) + Isomo = IBCLR(Isomo,p-1) + q = TRAILZ(Isomo) + 1 + else + ! SOMO -> SOMO + !print *,"obt SOMO -> SOMO" + extyp = 1 + q = TRAILZ(IEOR(Idomo,Jdomo)) + 1 + Isomo = IEOR(Isomo, Jsomo) + Isomo = IBCLR(Isomo,q-1) + p = TRAILZ(Isomo) + 1 + end if + case (2) + ! DOMO -> SOMO + !print *,"obt DOMO -> SOMO" + extyp = 4 + IJsomo = IEOR(Isomo, Jsomo) + p = TRAILZ(IAND(Jsomo,IJsomo)) + 1 + IJsomo = IBCLR(IJsomo,p-1) + q = TRAILZ(IJsomo) + 1 + case default + print *,"something went wront in get connectedI" + end select + starti = psi_config_data(i,1) + endi = psi_config_data(i,2) + nconnectedI += 1 + connectedI(:,:,nconnectedI) = psi_configuration(:,:,i) + idxs_connectedI(nconnectedI)=starti + excitationIds(1,nconnectedI)=p + excitationIds(2,nconnectedI)=q + excitationTypes(nconnectedI) = extyp + print *,"------ > output p,q in obt=",p,q + endif + end do + +end subroutine obtain_connected_I_foralpha +#+end_src + +#+begin_src fortran + print *,TRAILZ(8) + print *,IBCLR(8,TRAILZ(9)) + print *,TRAILZ(IBCLR(8,TRAILZ(9))) + +#+end_src + +#+RESULTS: +| 3 | +| 8 | +| 3 | + +** Function to get the NSOMOs (seniority) + +#+begin_src f90 :main no :tangle configuration_CI_sigma_helpers.irp.f + function getNSOMO(Icfg) result(NSOMO) + implicit none + integer(bit_kind),intent(in) :: Icfg(N_int,2) + integer :: NSOMO + integer :: i + NSOMO = 0 + do i = 1,N_int + NSOMO += POPCNT(Icfg(i,1)) + enddo + end function getNSOMO +#+end_src + +** Function to convert p,q to model space ids + +This function converts the real orbital ids \(i,j\) to model +space ids \(p,q\) which depend only on the number of somos. + +#+begin_src f90 :main no :tangle configuration_CI_sigma_helpers.irp.f +subroutine convertOrbIdsToModelSpaceIds(Ialpha, Jcfg, p, q, extype, pmodel, qmodel) + implicit none + BEGIN_DOC + ! This function converts the orbital ids + ! in real space to those used in model space + ! in order to identify the matrices required + ! for the calculation of MEs. + ! + ! The type of excitations are ordered as follows: + ! Type 1 - SOMO -> SOMO + ! Type 2 - DOMO -> VMO + ! Type 3 - SOMO -> VMO + ! Type 4 - DOMO -> SOMO + END_DOC + integer(bit_kind),intent(in) :: Ialpha(N_int,2) + integer(bit_kind),intent(in) :: Jcfg(N_int,2) + integer,intent(in) :: p,q + integer,intent(in) :: extype + integer,intent(out) :: pmodel,qmodel + integer*8 :: Isomo + integer*8 :: Idomo + integer*8 :: Jsomo + integer*8 :: Jdomo + integer*8 :: mask + integer*8 :: Isomotmp + integer*8 :: Jsomotmp + integer :: pos0,pos0prev + + ! TODO Flag (print) when model space indices is > 64 + Isomo = Ialpha(1,1) + Idomo = Ialpha(1,2) + Jsomo = Jcfg(1,1) + Jdomo = Jcfg(1,2) + pos0prev = 0 + pmodel = p + qmodel = q + + if(p .EQ. q) then + pmodel = 1 + qmodel = 1 + else + !print *,"input pq=",p,q,"extype=",extype + !call debug_spindet(Isomo,1) + !call debug_spindet(Idomo,1) + !call debug_spindet(Jsomo,1) + !call debug_spindet(Jdomo,1) + select case(extype) + case (1) + ! SOMO -> SOMO + ! remove all domos + !print *,"type -> SOMO -> SOMO" + mask = ISHFT(1_8,p) - 1 + Isomotmp = IAND(Isomo,mask) + pmodel = POPCNT(mask) - POPCNT(XOR(Isomotmp,mask)) + mask = ISHFT(1_8,q) - 1 + Isomotmp = IAND(Isomo,mask) + qmodel = POPCNT(mask) - POPCNT(XOR(Isomotmp,mask)) + case (2) + ! DOMO -> VMO + ! remove all domos except one at p + !print *,"type -> DOMO -> VMO" + mask = ISHFT(1_8,p) - 1 + Jsomotmp = IAND(Jsomo,mask) + pmodel = POPCNT(mask) - POPCNT(XOR(Jsomotmp,mask)) + mask = ISHFT(1_8,q) - 1 + Jsomotmp = IAND(Jsomo,mask) + qmodel = POPCNT(mask) - POPCNT(XOR(Jsomotmp,mask)) + case (3) + ! SOMO -> VMO + !print *,"type -> SOMO -> VMO" + !Isomo = IEOR(Isomo,Jsomo) + mask = ISHFT(1_8,p) - 1 + Isomo = IAND(Isomo,mask) + pmodel = POPCNT(mask) - POPCNT(XOR(Isomo,mask)) + mask = ISHFT(1_8,q) - 1 + Jsomo = IAND(Jsomo,mask) + qmodel = POPCNT(mask) - POPCNT(XOR(Jsomo,mask)) + case (4) + ! DOMO -> SOMO + ! remove all domos except one at p + !print *,"type -> DOMO -> SOMO" + !Isomo = IEOR(Isomo,Jsomo) + mask = ISHFT(1_8,p) - 1 + Jsomo = IAND(Jsomo,mask) + pmodel = POPCNT(mask) - POPCNT(XOR(Jsomo,mask)) + mask = ISHFT(1_8,q) - 1 + Isomo = IAND(Isomo,mask) + qmodel = POPCNT(mask) - POPCNT(XOR(Isomo,mask)) + case default + print *,"something is wrong in convertOrbIdsToModelSpaceIds" + end select + endif + !print *,p,q,"model ids=",pmodel,qmodel +end subroutine convertOrbIdsToModelSpaceIds +#+end_src + +#+begin_src fortran + integer :: i + integer :: count + integer :: mask + integer :: isomo + count = 0 + mask = ISHFT(1_8,5)-1 + print *,mask + print *,POPCNT(mask) + isomo = 144 + isomo = IAND(isomo,mask) + print *,isomo + print *,XOR(isomo,mask) + print *,POPCNT(mask) - POPCNT(XOR(isomo,mask)) + +#+end_src + +#+RESULTS: +| 31 | +| 5 | +| 16 | +| 15 | +| 1 | + +#+begin_src fortran + print *,IBSET(0_8,4)-1 + print *,POPCNT(IBSET(0_8,4)-1) - POPCNT(IAND(716,IBSET(0_8,4)-1)) + print *,POPCNT(IBSET(0_8,8)-1) - POPCNT(IAND(716,IBSET(0_8,8)-1)) +#+end_src + +#+RESULTS: +| 15 | +| 2 | +| 4 | diff --git a/src/csf/configurations.irp.f b/src/csf/configurations.irp.f new file mode 100644 index 00000000..8e2a513c --- /dev/null +++ b/src/csf/configurations.irp.f @@ -0,0 +1,872 @@ +use bitmasks + +BEGIN_PROVIDER [ integer, spin_multiplicity ] + implicit none + BEGIN_DOC + ! n_alpha - n_beta + 1 + END_DOC + spin_multiplicity = elec_alpha_num - elec_beta_num + 1 +END_PROVIDER + +subroutine configuration_of_det(d,o,Nint) + use bitmasks + implicit none + BEGIN_DOC + ! Transforms a determinant to a configuration + ! + ! occ(:,1) : Single occupations + ! + ! occ(:,2) : Double occupations + ! + END_DOC + integer ,intent(in) :: Nint + integer(bit_kind),intent(in) :: d(Nint,2) + integer(bit_kind),intent(out) :: o(Nint,2) + + integer :: k + + do k=1,Nint + o(k,1) = ieor(d(k,1),d(k,2)) + o(k,2) = iand(d(k,1),d(k,2)) + enddo +end + + +subroutine configuration_to_dets_size(o,sze,n_alpha,Nint) + use bitmasks + implicit none + BEGIN_DOC +! Number of possible determinants for a given configuration + END_DOC + integer ,intent(in) :: Nint, n_alpha + integer(bit_kind),intent(in) :: o(Nint,2) + integer, intent(out) :: sze + integer :: amax,bmax,k + double precision, external :: binom_func + + bmax = 0 + amax = n_alpha + do k=1,Nint + bmax += popcnt( o(k,1) ) + amax -= popcnt( o(k,2) ) + enddo + if (binom_int(bmax, amax) > huge(1)) then + print *, bmax, amax + print *, irp_here, ': Too many determinants to generate' + stop 1 + endif + sze = int(binom_int(bmax, amax),4) +end + + +subroutine configuration_to_dets(o,d,sze,n_alpha,Nint) + use bitmasks + implicit none + BEGIN_DOC + ! Generate all possible determinants for a given configuration + ! + ! Input : + ! o : configuration : (doubly occupied, singly occupied) + ! sze : Number of produced determinants, computed by `configuration_to_dets_size` + ! n_alpha : Number of $\alpha$ electrons + ! Nint : N_int + ! + ! Output: + ! d : determinants + ! + END_DOC + integer ,intent(in) :: Nint + integer ,intent(in) :: n_alpha ! Number of alpha electrons + integer ,intent(inout) :: sze ! Dimension of the output dets + integer(bit_kind),intent(in) :: o(Nint,2) ! Configurations + integer(bit_kind),intent(out) :: d(Nint,2,sze) ! Output determinants + + integer :: i, k, n, ispin, ispin2 + + ! Extract list of singly occupied MOs as (int,pos) pairs + ! ------------------------------------------------------ + + integer :: iint(2*n_alpha), ipos(2*n_alpha) + integer(bit_kind) :: v, t, tt, diff, v_prev + integer :: n_alpha_in_single + + n=0 + n_alpha_in_single = n_alpha + do i=1,Nint + v = o(i,1) + do while(v /= 0_bit_kind) + n = n+1 + iint(n) = i + ipos(n) = trailz(v) + v = iand(v,v-1) + enddo + n_alpha_in_single = n_alpha_in_single - popcnt( o(i,2) ) + enddo + + v = shiftl(1,n_alpha_in_single) - 1 + + ! Initialize first determinant + d(:,1,1) = o(:,2) + d(:,2,1) = o(:,2) + + do k=1,n_alpha_in_single + d(iint(k),1,1) = ibset( d(iint(k),1,1), ipos(k) ) + enddo + + do k=n_alpha_in_single+1,n + d(iint(k),2,1) = ibset( d(iint(k),2,1), ipos(k) ) + enddo + + sze = int(binom_int(n,n_alpha_in_single),4) + + if ( (shiftl(n_alpha_in_single,1) == n).and.n>0 ) then + + ! Time reversal symmetry + d(:,1,2) = d(:,2,1) + d(:,2,2) = d(:,1,1) + + do i=3,sze,2 + ! Generate next permutation with Anderson's algorithm + v_prev = v + t = ior(v,v-1) + tt = t+1 + v = ior(tt, shiftr( and(not(t),tt) - 1, trailz(v)+1) ) + + ! Find what has changed between v_prev and v + diff = ieor(v,v_prev) + + ! Initialize with previous determinant + d(:,1,i) = d(:,1,i-2) + d(:,2,i) = d(:,2,i-2) + + ! Swap bits only where they have changed from v_prev to v + do while (diff /= 0_bit_kind) + k = trailz(diff)+1 + if (btest(v,k-1)) then + d(iint(k),1,i) = ibset( d(iint(k),1,i), ipos(k) ) + d(iint(k),2,i) = ibclr( d(iint(k),2,i), ipos(k) ) + else + d(iint(k),1,i) = ibclr( d(iint(k),1,i), ipos(k) ) + d(iint(k),2,i) = ibset( d(iint(k),2,i), ipos(k) ) + endif + diff = iand(diff,diff-1_bit_kind) + enddo + + ! Time reversal symmetry + d(:,1,i+1) = d(:,2,i) + d(:,2,i+1) = d(:,1,i) + + enddo + + else + + do i=2,sze + ! Generate next permutation with Anderson's algorithm + v_prev = v + t = ior(v,v-1) + tt = t+1 + v = ior(tt, shiftr( and(not(t),tt) - 1, trailz(v)+1) ) + + ! Find what has changed between v_prev and v + diff = ieor(v,v_prev) + + ! Initialize with previous determinant + d(:,1,i) = d(:,1,i-1) + d(:,2,i) = d(:,2,i-1) + + ! Swap bits only where they have changed from v_prev to v + do while (diff /= 0_bit_kind) + k = trailz(diff)+1 + if (btest(v,k-1)) then + d(iint(k),1,i) = ibset( d(iint(k),1,i), ipos(k) ) + d(iint(k),2,i) = ibclr( d(iint(k),2,i), ipos(k) ) + else + d(iint(k),1,i) = ibclr( d(iint(k),1,i), ipos(k) ) + d(iint(k),2,i) = ibset( d(iint(k),2,i), ipos(k) ) + endif + diff = iand(diff,diff-1_bit_kind) + enddo + + enddo + + endif + +end + +subroutine configuration_to_dets_tree_addressing(o,d,sze,n_alpha,Nint) + use bitmasks + implicit none + BEGIN_DOC + ! Generate all possible determinants for a given configuration + ! + ! This function preserves the tree addressing i.e. + ! the time-reversal determinants are at the opposite ends + ! and not one after the other as in the parent function. + ! + ! Input : + ! o : configuration : (doubly occupied, singly occupied) + ! sze : Number of produced determinants, computed by `configuration_to_dets_size` + ! n_alpha : Number of $\alpha$ electrons + ! Nint : N_int + ! + ! Output: + ! d : determinants + ! + END_DOC + integer ,intent(in) :: Nint + integer ,intent(in) :: n_alpha ! Number of alpha electrons + integer ,intent(inout) :: sze ! Dimension of the output dets + integer(bit_kind),intent(in) :: o(Nint,2) ! Configurations + integer(bit_kind),intent(out) :: d(Nint,2,sze) ! Output determinants + + integer :: i, k, n, ispin, ispin2 + + ! Extract list of singly occupied MOs as (int,pos) pairs + ! ------------------------------------------------------ + + integer :: iint(2*n_alpha), ipos(2*n_alpha) + integer(bit_kind) :: v, t, tt, diff, v_prev + integer :: n_alpha_in_single + + n=0 + n_alpha_in_single = n_alpha + do i=1,Nint + v = o(i,1) + do while(v /= 0_bit_kind) + n = n+1 + iint(n) = i + ipos(n) = trailz(v) + v = iand(v,v-1) + enddo + n_alpha_in_single = n_alpha_in_single - popcnt( o(i,2) ) + enddo + + v = shiftl(1,n_alpha_in_single) - 1 + + ! Initialize first determinant + d(:,1,1) = o(:,2) + d(:,2,1) = o(:,2) + + do k=1,n_alpha_in_single + d(iint(k),1,1) = ibset( d(iint(k),1,1), ipos(k) ) + enddo + + do k=n_alpha_in_single+1,n + d(iint(k),2,1) = ibset( d(iint(k),2,1), ipos(k) ) + enddo + + sze = int(binom_int(n,n_alpha_in_single),4) + + if ( (shiftl(n_alpha_in_single,1) == n).and.n>0 ) then + + ! Time reversal symmetry + d(:,1,sze) = d(:,2,1) + d(:,2,sze) = d(:,1,1) + + do i=2,sze/2,1 + ! Generate next permutation with Anderson's algorithm + v_prev = v + t = ior(v,v-1) + tt = t+1 + v = ior(tt, shiftr( and(not(t),tt) - 1, trailz(v)+1) ) + + ! Find what has changed between v_prev and v + diff = ieor(v,v_prev) + + ! Initialize with previous determinant + d(:,1,i) = d(:,1,i-1) + d(:,2,i) = d(:,2,i-1) + + ! Swap bits only where they have changed from v_prev to v + do while (diff /= 0_bit_kind) + k = trailz(diff)+1 + if (btest(v,k-1)) then + d(iint(k),1,i) = ibset( d(iint(k),1,i), ipos(k) ) + d(iint(k),2,i) = ibclr( d(iint(k),2,i), ipos(k) ) + else + d(iint(k),1,i) = ibclr( d(iint(k),1,i), ipos(k) ) + d(iint(k),2,i) = ibset( d(iint(k),2,i), ipos(k) ) + endif + diff = iand(diff,diff-1_bit_kind) + enddo + + ! Time reversal symmetry + d(:,1,sze-i+1) = d(:,2,i) + d(:,2,sze-i+1) = d(:,1,i) + + enddo + + else + + do i=2,sze + ! Generate next permutation with Anderson's algorithm + v_prev = v + t = ior(v,v-1) + tt = t+1 + v = ior(tt, shiftr( and(not(t),tt) - 1, trailz(v)+1) ) + + ! Find what has changed between v_prev and v + diff = ieor(v,v_prev) + + ! Initialize with previous determinant + d(:,1,i) = d(:,1,i-1) + d(:,2,i) = d(:,2,i-1) + + ! Swap bits only where they have changed from v_prev to v + do while (diff /= 0_bit_kind) + k = trailz(diff)+1 + if (btest(v,k-1)) then + d(iint(k),1,i) = ibset( d(iint(k),1,i), ipos(k) ) + d(iint(k),2,i) = ibclr( d(iint(k),2,i), ipos(k) ) + else + d(iint(k),1,i) = ibclr( d(iint(k),1,i), ipos(k) ) + d(iint(k),2,i) = ibset( d(iint(k),2,i), ipos(k) ) + endif + diff = iand(diff,diff-1_bit_kind) + enddo + + enddo + + endif + +end + + + BEGIN_PROVIDER [ integer(bit_kind), psi_configuration, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ integer, N_configuration ] + implicit none + BEGIN_DOC + ! Array of the configurations present in the wave function. + ! + ! psi_configuration(:,1,j) = j-th configuration of the wave function : represents all the single occupations + ! + ! psi_configuration(:,2,j) = j-th configuration of the wave function : represents all the double occupations + ! + ! The occ patterns are sorted by :c:func:`configuration_search_key` + END_DOC + integer :: i,j,k + + ! create + do i = 1, N_det + do k = 1, N_int + psi_configuration(k,1,i) = ieor(psi_det(k,1,i),psi_det(k,2,i)) + psi_configuration(k,2,i) = iand(psi_det(k,1,i),psi_det(k,2,i)) + enddo + enddo + + ! Sort + integer, allocatable :: iorder(:) + integer*8, allocatable :: bit_tmp(:) + integer*8, external :: configuration_search_key + integer(bit_kind), allocatable :: tmp_array(:,:,:) + logical,allocatable :: duplicate(:) + logical :: dup + + + allocate ( iorder(N_det), duplicate(N_det), bit_tmp(N_det), tmp_array(N_int,2,N_det) ) + + do i=1,N_det + iorder(i) = i + bit_tmp(i) = configuration_search_key(psi_configuration(1,1,i),N_int) + enddo + + call i8sort(bit_tmp,iorder,N_det) + + + !$OMP PARALLEL DEFAULT(shared) PRIVATE(i,j,k,dup) + + !$OMP DO + do i=1,N_det + do k=1,N_int + tmp_array(k,1,i) = psi_configuration(k,1,iorder(i)) + tmp_array(k,2,i) = psi_configuration(k,2,iorder(i)) + enddo + duplicate(i) = .False. + enddo + !$OMP END DO + + ! Find duplicates + !$OMP DO + do i=1,N_det-1 + if (duplicate(i)) then + cycle + endif + j = i+1 + do while (bit_tmp(j)==bit_tmp(i)) + if (duplicate(j)) then + j+=1 + if (j>N_det) then + exit + endif + cycle + endif + dup = .True. + do k=1,N_int + dup = dup .and. (tmp_array(k,1,i) == tmp_array(k,1,j)) & + .and. (tmp_array(k,2,i) == tmp_array(k,2,j)) + enddo + if (dup) then + duplicate(j) = .True. + endif + j = j+1 + if (j>N_det) then + exit + endif + enddo + enddo + !$OMP END DO + !$OMP END PARALLEL + + ! Copy filtered result + N_configuration=0 + do i=1,N_det + if (duplicate(i)) then + cycle + endif + N_configuration += 1 + do k=1,N_int + psi_configuration(k,1,N_configuration) = tmp_array(k,1,i) + psi_configuration(k,2,N_configuration) = tmp_array(k,2,i) + enddo + enddo + +!- Check +! print *, 'Checking for duplicates in configuration' +! do i=1,N_configuration +! do j=i+1,N_configuration +! duplicate(1) = .True. +! do k=1,N_int +! if (psi_configuration(k,1,i) /= psi_configuration(k,1,j)) then +! duplicate(1) = .False. +! exit +! endif +! if (psi_configuration(k,2,i) /= psi_configuration(k,2,j)) then +! duplicate(1) = .False. +! exit +! endif +! enddo +! if (duplicate(1)) then +! call debug_det(psi_configuration(1,1,i),N_int) +! call debug_det(psi_configuration(1,1,j),N_int) +! stop 'DUPLICATE' +! endif +! enddo +! enddo +! print *, 'No duplicates' +!- + deallocate(iorder,duplicate,bit_tmp,tmp_array) + +END_PROVIDER + + BEGIN_PROVIDER [ integer, cfg_seniority_index, (0:elec_num) ] +&BEGIN_PROVIDER [ integer, cfg_nsomo_max ] + implicit none + BEGIN_DOC + ! Returns the index in psi_configuration of the first cfg with + ! the requested seniority + ! + ! cfg_nsomo_max : Max number of SOMO in the current wave function + END_DOC + integer :: i, k, s, sold + cfg_seniority_index(:) = -1 + sold = -1 + cfg_nsomo_max = 0 + do i=1,N_configuration + s = 0 + do k=1,N_int + if (psi_configuration(k,1,i) == 0_bit_kind) cycle + s = s + popcnt(psi_configuration(k,1,i)) + enddo + if (s /= sold) then + sold = s + cfg_seniority_index(s) = i + cfg_nsomo_max = s + endif + enddo +END_PROVIDER + +BEGIN_PROVIDER [ integer, det_to_configuration, (N_det) ] + implicit none + BEGIN_DOC + ! Returns the index of the configuration for each determinant + END_DOC + integer :: i,j,k,r,l + integer*8 :: key, key2 + integer(bit_kind) :: occ(N_int,2) + logical :: found + integer*8, allocatable :: bit_tmp(:) + integer*8, external :: configuration_search_key + + allocate(bit_tmp(0:N_configuration)) + bit_tmp(0) = 0 + do i=1,N_configuration + bit_tmp(i) = configuration_search_key(psi_configuration(1,1,i),N_int) + enddo + + !$OMP PARALLEL DO DEFAULT(SHARED) & + !$OMP PRIVATE(i,k,j,r,l,key,found,occ) + do i=1,N_det + do k = 1, N_int + occ(k,1) = ieor(psi_det(k,1,i),psi_det(k,2,i)) + occ(k,2) = iand(psi_det(k,1,i),psi_det(k,2,i)) + enddo + + key = configuration_search_key(occ,N_int) + + ! Binary search + l = 0 + r = N_configuration+1 + j = shiftr(r-l,1) + do while (j>=1) + j = j+l + if (bit_tmp(j) == key) then + do while (bit_tmp(j) == bit_tmp(j-1)) + j = j-1 + enddo + do while (bit_tmp(j) == key) + found = .True. + do k=1,N_int + found = found .and. (psi_configuration(k,1,j) == occ(k,1)) & + .and. (psi_configuration(k,2,j) == occ(k,2)) + enddo + if (found) then + det_to_configuration(i) = j + exit + endif + j = j+1 + enddo + if (found) exit + else if (bit_tmp(j) > key) then + r = j + else + l = j + endif + j = shiftr(r-l,1) + enddo + + enddo + !$OMP END PARALLEL DO + deallocate(bit_tmp) +END_PROVIDER + + +BEGIN_PROVIDER [ double precision, psi_configuration_Hii, (N_configuration) ] + implicit none + BEGIN_DOC + ! $\langle I|H|I \rangle$ where $|I\rangle$ is a configuration. + ! This is the minimum $H_{ii}$, where the $|i\rangle$ are the + ! determinants of $|I\rangle$. + END_DOC + integer :: j, i + + psi_configuration_Hii(:) = huge(1.d0) + do i=1,N_det + j = det_to_configuration(i) + psi_configuration_Hii(j) = min(psi_configuration_Hii(j), psi_det_Hii(i)) + enddo + +END_PROVIDER + + +BEGIN_PROVIDER [ double precision, weight_configuration, (N_configuration,N_states) ] + implicit none + BEGIN_DOC + ! Weight of the configurations in the wave function + END_DOC + integer :: i,j,k + weight_configuration = 0.d0 + do i=1,N_det + j = det_to_configuration(i) + do k=1,N_states + weight_configuration(j,k) += psi_coef(i,k) * psi_coef(i,k) + enddo + enddo +END_PROVIDER + +BEGIN_PROVIDER [ double precision, weight_configuration_average, (N_configuration) ] + implicit none + BEGIN_DOC + ! State-average weight of the configurations in the wave function + END_DOC + integer :: i,j,k + weight_configuration_average(:) = 0.d0 + do i=1,N_det + j = det_to_configuration(i) + do k=1,N_states + weight_configuration_average(j) += psi_coef(i,k) * psi_coef(i,k) * state_average_weight(k) + enddo + enddo +END_PROVIDER + + BEGIN_PROVIDER [ integer(bit_kind), psi_configuration_sorted, (N_int,2,N_configuration) ] +&BEGIN_PROVIDER [ double precision, weight_configuration_average_sorted, (N_configuration) ] +&BEGIN_PROVIDER [ integer, psi_configuration_sorted_order, (N_configuration) ] +&BEGIN_PROVIDER [ integer, psi_configuration_sorted_order_reverse, (N_configuration) ] + implicit none + BEGIN_DOC + ! Configurations sorted by weight + END_DOC + integer :: i,j,k + integer, allocatable :: iorder(:) + allocate ( iorder(N_configuration) ) + do i=1,N_configuration + weight_configuration_average_sorted(i) = -weight_configuration_average(i) + iorder(i) = i + enddo + call dsort(weight_configuration_average_sorted,iorder,N_configuration) + do i=1,N_configuration + do j=1,N_int + psi_configuration_sorted(j,1,i) = psi_configuration(j,1,iorder(i)) + psi_configuration_sorted(j,2,i) = psi_configuration(j,2,iorder(i)) + enddo + psi_configuration_sorted_order(iorder(i)) = i + psi_configuration_sorted_order_reverse(i) = iorder(i) + weight_configuration_average_sorted(i) = -weight_configuration_average_sorted(i) + enddo + + deallocate(iorder) + +END_PROVIDER + + +subroutine make_s2_eigenfunction + implicit none + integer :: i,j,k + integer :: smax, s + integer(bit_kind), allocatable :: d(:,:,:), det_buffer(:,:,:) + integer :: N_det_new, ithread, omp_get_thread_num + integer, parameter :: bufsze = 1000 + logical, external :: is_in_wavefunction + logical :: update + + update=.False. + call write_int(6,N_configuration,'Number of configurations') + + !$OMP PARALLEL DEFAULT(NONE) & + !$OMP SHARED(N_configuration, psi_configuration, elec_alpha_num,N_int,update) & + !$OMP PRIVATE(s,ithread, d, det_buffer, smax, N_det_new,i,j,k) + N_det_new = 0 + call configuration_to_dets_size(psi_configuration(1,1,1),s,elec_alpha_num,N_int) + allocate (d(N_int,2,s+64), det_buffer(N_int,2,bufsze) ) + smax = s + ithread=0 + !$ ithread = omp_get_thread_num() + !$OMP DO SCHEDULE (dynamic,1000) + do i=1,N_configuration + call configuration_to_dets_size(psi_configuration(1,1,i),s,elec_alpha_num,N_int) + s += 1 + if (s > smax) then + deallocate(d) + allocate ( d(N_int,2,s+64) ) + smax = s + endif + call configuration_to_dets(psi_configuration(1,1,i),d,s,elec_alpha_num,N_int) + do j=1,s + if ( is_in_wavefunction(d(1,1,j), N_int) ) then + cycle + endif + update = .true. + N_det_new += 1 + det_buffer(:,:,N_det_new) = d(:,:,j) + if (N_det_new == bufsze) then + call fill_H_apply_buffer_no_selection(bufsze,det_buffer,N_int,ithread) + N_det_new = 0 + endif + enddo + enddo + !$OMP END DO NOWAIT + + if (N_det_new > 0) then + call fill_H_apply_buffer_no_selection(N_det_new,det_buffer,N_int,ithread) + endif + !$OMP BARRIER + deallocate(d,det_buffer) + !$OMP END PARALLEL + + if (update) then + call copy_H_apply_buffer_to_wf + TOUCH N_det psi_coef psi_det psi_configuration N_configuration + endif + call write_time(6) + +end + + + +BEGIN_PROVIDER [ integer, dominant_cfg, (N_states) ] + implicit none + BEGIN_DOC + ! Configuration of the determinants with the largest weight, for each state + END_DOC + integer :: k + dominant_cfg(1) = det_to_configuration(dominant_det(1)) + if (N_det < N_states) then + dominant_cfg(:) = dominant_cfg(1) + else + do k=1,N_states + dominant_cfg(k) = det_to_configuration(dominant_det(k)) + enddo + endif +END_PROVIDER + + +BEGIN_PROVIDER [ integer, N_dominant_dets_of_cfgs ] + implicit none + BEGIN_DOC + ! Number of determinants in all dominant determinants + END_DOC + integer :: k, sze + + N_dominant_dets_of_cfgs = 0 + do k=1,N_states + call configuration_to_dets_size( & + psi_configuration(1,1,dominant_cfg(k)), & + sze, elec_alpha_num, N_int) + N_dominant_dets_of_cfgs += sze + enddo +END_PROVIDER + +BEGIN_PROVIDER [ integer(bit_kind), dominant_dets_of_cfgs, (N_int,2,N_dominant_dets_of_cfgs) ] + implicit none + BEGIN_DOC + ! Configuration of the determinants with the largest weight, for each state + END_DOC + integer :: i,k,sze + i=1 + do k=1,N_states + sze = N_dominant_dets_of_cfgs + call configuration_to_dets( & + psi_configuration(1,1,dominant_cfg(k)), & + dominant_dets_of_cfgs(1,1,i), & + sze,elec_alpha_num,N_int) + i += sze + enddo +END_PROVIDER + +subroutine binary_search_cfg(cfgInp,addcfg) + use bitmasks + implicit none + BEGIN_DOC + ! Documentation for binary_search + ! + ! Does a binary search to find + ! the address of a configuration in a list of + ! configurations. + END_DOC + integer(bit_kind), intent(in) :: cfgInp(N_int,2) + integer , intent(out) :: addcfg + integer :: i,j,k,r,l + integer*8 :: key, key2 + logical :: found + !integer*8, allocatable :: bit_tmp(:) + !integer*8, external :: configuration_search_key + + !allocate(bit_tmp(0:N_configuration)) + !bit_tmp(0) = 0 + do i=1,N_configuration + !bit_tmp(i) = configuration_search_key(psi_configuration(1,1,i),N_int) + found = .True. + do k=1,N_int + found = found .and. (psi_configuration(k,1,i) == cfgInp(k,1)) & + .and. (psi_configuration(k,2,i) == cfgInp(k,2)) + enddo + if (found) then + addcfg = i + exit + endif + enddo + +end subroutine + + BEGIN_PROVIDER [ integer, psi_configuration_to_psi_det, (2,N_configuration) ] +&BEGIN_PROVIDER [ integer, psi_configuration_to_psi_det_data, (N_det) ] + + implicit none + BEGIN_DOC + ! psi_configuration_to_psi_det_data(k) -> i : i is the index of the + ! determinant in psi_det. + ! + ! psi_configuration_to_psi_det(1:2,k) gives the first and last index of the + ! determinants of configuration k in array psi_configuration_to_psi_det_data. + END_DOC + + integer :: i, k, iorder + integer, allocatable :: confs(:) + allocate (confs(N_det)) + + do i=1,N_det + psi_configuration_to_psi_det_data(i) = i + confs(i) = det_to_configuration(i) + enddo + + call isort(confs, psi_configuration_to_psi_det_data, N_det) + k=1 + psi_configuration_to_psi_det(1,1) = 1 + do i=2,N_det + if (confs(i) /= confs(i-1)) then + psi_configuration_to_psi_det(2,k) = i-1 + k = k+1 + psi_configuration_to_psi_det(1,k) = i + endif + enddo + psi_configuration_to_psi_det(2,k) = N_det + + + ! Reorder determinants according to generation + ! -------------------------------------------- + + integer(bit_kind), allocatable :: dets(:,:,:) + integer :: nmax, sze, degree, istart, iend, j + integer, allocatable :: old_order(:) + + + nmax = 1000 + allocate(dets(N_int,2,nmax), old_order(nmax)) + + do k=1,N_configuration + istart = psi_configuration_to_psi_det(1,k) + iend = psi_configuration_to_psi_det(2,k) + + if (iend-istart+1 > nmax) then + nmax = iend-istart+1 + deallocate(dets) + allocate(dets(N_int,2,nmax)) + endif + + sze = nmax + call configuration_to_dets_tree_addressing( & + psi_configuration(1,1,k), & + dets, sze, elec_alpha_num, N_int) + + if (sze /= iend-istart+1) then + print *, 'bug in ', irp_here + stop -1 + endif + + do i=1,sze + old_order(i) = psi_configuration_to_psi_det_data(i-1+istart) + enddo + + do i=1,sze + do j=1,sze + + if (old_order(j) == 0) cycle + + call get_excitation_degree(dets(1,1,i), & + psi_det(1, 1, old_order(j)), degree, N_int) + + if (degree == 0) then + psi_configuration_to_psi_det_data(i-1+istart) = old_order(j) + old_order(j) = 0 + exit + endif + + enddo + enddo + + enddo + + deallocate(dets, old_order) + +END_PROVIDER + diff --git a/src/csf/connected_to_ref.irp.f b/src/csf/connected_to_ref.irp.f new file mode 100644 index 00000000..5362d448 --- /dev/null +++ b/src/csf/connected_to_ref.irp.f @@ -0,0 +1,29 @@ +integer*8 function configuration_search_key(cfg,Nint) + use bitmasks + implicit none + BEGIN_DOC + ! Returns an integer*8 corresponding to a determinant index for searching. + ! The left-most 8 bits contain the number of open shells+1. This ensures that the CSF + ! are packed with the same seniority. + END_DOC + integer, intent(in) :: Nint + integer(bit_kind), intent(in) :: cfg(Nint,2) + integer :: i, n_open_shells + integer*8 :: mask + + i = shiftr(elec_alpha_num, bit_kind_shift)+1 + configuration_search_key = int(shiftr(ior(cfg(i,1),cfg(i,2)),1)+sum(cfg),8) + + mask = int(Z'00FFFFFFFFFFFFFF',8) + configuration_search_key = iand(mask,configuration_search_key) + + n_open_shells = 1 + do i=1,Nint + if (cfg(i,1) == 0_bit_kind) cycle + n_open_shells = n_open_shells + popcnt(cfg(i,1)) + enddo + mask = n_open_shells + mask = shiftl(mask,56) + configuration_search_key = ior (mask,configuration_search_key) + +end diff --git a/src/csf/conversion.irp.f b/src/csf/conversion.irp.f new file mode 100644 index 00000000..fecc6123 --- /dev/null +++ b/src/csf/conversion.irp.f @@ -0,0 +1,148 @@ +subroutine convertWFfromDETtoCSF(N_st,psi_coef_det_in, psi_coef_cfg_out) + use cfunctions + use bitmasks + implicit none + BEGIN_DOC + ! Documentation for DetToCSFTransformationMatrix + ! Provides the matrix of transformatons for the + ! conversion between determinant to CSF basis (in BFs) + END_DOC + integer, intent(in) :: N_st + double precision, intent(in) :: psi_coef_det_in(N_det,N_st) + double precision, intent(out) :: psi_coef_cfg_out(n_CSF,N_st) + integer*8 :: Isomo, Idomo, mask + integer(bit_kind) :: Ialpha(N_int) ,Ibeta(N_int) + integer :: rows, cols, i, j, k + integer :: startdet, enddet + integer :: ndetI + integer :: getNSOMO + double precision,allocatable :: tempBuffer(:,:) + double precision,allocatable :: tempCoeff(:,:) + double precision :: phasedet + integer :: idx + + ! initialization + psi_coef_cfg_out(:,1) = 0.d0 + + integer s, bfIcfg + integer countcsf + countcsf = 0 + phasedet = 1.0d0 + do i = 1,N_configuration + startdet = psi_configuration_to_psi_det(1,i) + enddet = psi_configuration_to_psi_det(2,i) + ndetI = enddet-startdet+1 + + allocate(tempCoeff(ndetI,N_st)) + do j = startdet, enddet + idx = psi_configuration_to_psi_det_data(j) + Ialpha(:) = psi_det(:,1,idx) + Ibeta(:) = psi_det(:,2,idx) + call get_phase_qp_to_cfg(Ialpha, Ibeta, phasedet) + do k=1,N_st + tempCoeff(j-startdet+1,k) = psi_coef_det_in(idx, k)*phasedet + enddo + enddo + + s = 0 + do k=1,N_int + if (psi_configuration(k,1,i) == 0_bit_kind) cycle + s = s + popcnt(psi_configuration(k,1,i)) + enddo + bfIcfg = max(1,nint((binom(s,(s+1)/2)-binom(s,((s+1)/2)+1)))) + + ! perhaps blocking with CFGs of same seniority + ! can be more efficient + allocate(tempBuffer(bfIcfg,ndetI)) + tempBuffer = DetToCSFTransformationMatrix(s,:bfIcfg,:ndetI) + + call dgemm('N','N', bfIcfg, N_st, ndetI, 1.d0, tempBuffer, size(tempBuffer,1),& + tempCoeff, size(tempCoeff,1), 0.d0, psi_coef_cfg_out(countcsf+1,1),& + size(psi_coef_cfg_out,1)) + + deallocate(tempCoeff) + deallocate(tempBuffer) + countcsf += bfIcfg + enddo + +end + + +subroutine convertWFfromCSFtoDET(N_st,psi_coef_cfg_in, psi_coef_det) + implicit none + BEGIN_DOC + ! Documentation for convertCSFtoDET + ! This function converts the wavefunction + ! in CFG basis to DET basis using the + ! transformation matrix provided before. + END_DOC + integer, intent(in) :: N_st + double precision,intent(in) :: psi_coef_cfg_in(n_CSF,N_st) + double precision,intent(out) :: psi_coef_det(N_det,N_st) + double precision :: tmp_psi_coef_det(maxDetDimPerBF,N_st) + integer :: s, bfIcfg + integer :: countcsf + integer(bit_kind) :: Ialpha(N_int), Ibeta(N_int) + integer :: rows, cols, i, j, k + integer :: startdet, enddet + integer :: ndetI + integer :: getNSOMO + double precision,allocatable :: tempBuffer(:,:) + double precision,allocatable :: tempCoeff (:,:) + double precision :: phasedet + integer :: idx + + countcsf = 0 + + do i = 1,N_configuration + startdet = psi_configuration_to_psi_det(1,i) + enddet = psi_configuration_to_psi_det(2,i) + ndetI = enddet-startdet+1 + + s = 0 + do k=1,N_int + if (psi_configuration(k,1,i) == 0_bit_kind) cycle + s = s + popcnt(psi_configuration(k,1,i)) + enddo + bfIcfg = max(1,nint((binom(s,(s+1)/2)-binom(s,((s+1)/2)+1)))) + + allocate(tempCoeff(bfIcfg,N_st)) + + do k=1,N_st + do j = 1,bfIcfg + tempCoeff(j,k) = psi_coef_cfg_in(countcsf+j,k) + enddo + enddo + + countcsf += bfIcfg + ! perhaps blocking with CFGs of same seniority + ! can be more efficient + allocate(tempBuffer(bfIcfg,ndetI)) + tempBuffer = DetToCSFTransformationMatrix(s,:bfIcfg,:ndetI) + + call dgemm('T','N', ndetI, N_st, bfIcfg, 1.d0, tempBuffer, size(tempBuffer,1),& + tempCoeff, size(tempCoeff,1), 0.d0, tmp_psi_coef_det, & + size(tmp_psi_coef_det,1)) + + do j=startdet,enddet + idx = psi_configuration_to_psi_det_data(j) + Ialpha(:) = psi_det(:,1,idx) + Ibeta(:) = psi_det(:,2,idx) + call get_phase_qp_to_cfg(Ialpha, Ibeta, phasedet) + do k=1,N_st + psi_coef_det(idx,k) = tmp_psi_coef_det(j-startdet+1,k) * phasedet + enddo + enddo + + deallocate(tempCoeff) + deallocate(tempBuffer) + enddo + +end + + + + + + + diff --git a/src/csf/create_excitations.irp.f b/src/csf/create_excitations.irp.f new file mode 100644 index 00000000..c1560148 --- /dev/null +++ b/src/csf/create_excitations.irp.f @@ -0,0 +1,279 @@ +subroutine do_single_excitation_cfg(key_in,key_out,i_hole,i_particle,ok) + use bitmasks + implicit none + BEGIN_DOC + ! Applies the single excitation operator to a configuration + ! If the excitation is possible, ok is True + END_DOC + integer, intent(in) :: i_hole,i_particle + integer(bit_kind), intent(in) :: key_in(N_int,2) + logical , intent(out) :: ok + integer :: k,j,i + integer(bit_kind) :: mask + integer(bit_kind) :: key_out(N_int,2) + + ASSERT (i_hole > 0) + ASSERT (i_particle <= mo_num) + + ok = .True. + key_out(:,:) = key_in(:,:) + + ! hole + k = shiftr(i_hole-1,bit_kind_shift)+1 + j = i_hole-shiftl(k-1,bit_kind_shift)-1 + mask = ibset(0_bit_kind,j) + + ! Check if the position j is singly occupied + ! 1 -> 0 (SOMO) + ! 0 0 (DOMO) + if (iand(key_out(k,1),mask) /= 0_bit_kind) then + key_out(k,1) = ibclr(key_out(k,1),j) + + ! Check if the position j is doubly occupied + ! 0 -> 1 (SOMO) + ! 1 0 (DOMO) + else if (iand(key_out(k,2),mask) /= 0_bit_kind) then + key_out(k,1) = ibset(key_out(k,1),j) + key_out(k,2) = ibclr(key_out(k,2),j) + + ! The position j is unoccupied: Not OK + ! 0 -> 0 (SOMO) + ! 0 0 (DOMO) + else + ok =.False. + return + endif + + + ! particle + k = shiftr(i_particle-1,bit_kind_shift)+1 + j = i_particle-shiftl(k-1,bit_kind_shift)-1 + mask = ibset(0_bit_kind,j) + + ! Check if the position j is singly occupied + ! 1 -> 0 (SOMO) + ! 0 1 (DOMO) + if (iand(key_out(k,1),mask) /= 0_bit_kind) then + key_out(k,1) = ibclr(key_out(k,1),j) + key_out(k,2) = ibset(key_out(k,2),j) + + ! Check if the position j is doubly occupied : Not OK + ! 0 -> 1 (SOMO) + ! 1 0 (DOMO) + else if (iand(key_out(k,2),mask) /= 0_bit_kind) then + ok = .False. + return + + ! Position at j is unoccupied + ! 0 -> 0 (SOMO) + ! 0 0 (DOMO) + else + key_out(k,1) = ibset(key_out(k,1),j) + endif + +end + +subroutine do_single_excitation_cfg_with_type(key_in,key_out,i_hole,i_particle,ex_type,ok) + use bitmasks + implicit none + BEGIN_DOC + ! Applies the single excitation operator to a configuration + ! Returns the type of excitation in ex_type + ! where the following convention is used + ! 1 = (SOMO -> SOMO) 1 change in Nsomo + ! 2 = (DOMO -> VMO) 1 change in Nsomo + ! 3 = (SOMO -> VMO) 0 change in Nsomo + ! 4 = (DOMO -> SOMO) 0 change in Nsomo + ! If the excitation is possible, ok is True + END_DOC + integer, intent(in) :: i_hole,i_particle + integer(bit_kind), intent(in) :: key_in(N_int,2) + integer , intent(out) :: ex_type + logical , intent(out) :: ok + integer :: k,j,i + integer(bit_kind) :: mask + integer(bit_kind) :: key_out(N_int,2) + logical :: isholeSOMO + logical :: isparticleSOMO + logical :: isholeDOMO + logical :: isparticleVMO + isholeSOMO = .False. + isholeDOMO = .False. + isparticleSOMO = .False. + isparticleVMO = .False. + + ASSERT (i_hole > 0) + ASSERT (i_particle <= mo_num) + + ok = .True. + key_out(:,:) = key_in(:,:) + + ! hole + k = shiftr(i_hole-1,bit_kind_shift)+1 + j = i_hole-shiftl(k-1,bit_kind_shift)-1 + mask = ibset(0_bit_kind,j) + + ! Check if the position j is singly occupied + ! 1 -> 0 (SOMO) + ! 0 0 (DOMO) + if (iand(key_out(k,1),mask) /= 0_bit_kind) then + key_out(k,1) = ibclr(key_out(k,1),j) + isholeSOMO = .True. + + ! Check if the position j is doubly occupied + ! 0 -> 1 (SOMO) + ! 1 0 (DOMO) + else if (iand(key_out(k,2),mask) /= 0_bit_kind) then + key_out(k,1) = ibset(key_out(k,1),j) + key_out(k,2) = ibclr(key_out(k,2),j) + isholeDOMO = .True. + + ! The position j is unoccupied: Not OK + ! 0 -> 0 (SOMO) + ! 0 0 (DOMO) + else + ok =.False. + return + endif + + + ! particle + k = shiftr(i_particle-1,bit_kind_shift)+1 + j = i_particle-shiftl(k-1,bit_kind_shift)-1 + mask = ibset(0_bit_kind,j) + + ! Check if the position j is singly occupied + ! 1 -> 0 (SOMO) + ! 0 1 (DOMO) + if (iand(key_out(k,1),mask) /= 0_bit_kind) then + key_out(k,1) = ibclr(key_out(k,1),j) + key_out(k,2) = ibset(key_out(k,2),j) + isparticleSOMO = .True. + + ! Check if the position j is doubly occupied : Not OK + ! 0 -> 1 (SOMO) + ! 1 0 (DOMO) + else if (iand(key_out(k,2),mask) /= 0_bit_kind) then + ok = .False. + return + + ! Position at j is unoccupied + ! 0 -> 0 (SOMO) + ! 0 0 (DOMO) + else + key_out(k,1) = ibset(key_out(k,1),j) + isparticleVMO = .True. + endif + + if(isholeSOMO) then + ! two possibilities + ! particle is SOMO or VMO + if(isparticleSOMO) then + ! SOMO -> SOMO + ex_type = 1 + else + ! SOMO -> VMO + ex_type = 3 + endif + else + ! two possibilities + ! particle is SOMO or VMO + if(isparticleSOMO) then + ! DOMO -> SOMO + ex_type = 4 + else + ! DOMO -> VMO + ex_type = 2 + endif + endif + +end + +subroutine generate_all_singles_cfg(cfg,singles,n_singles,Nint) + implicit none + use bitmasks + BEGIN_DOC + ! Generate all single excitation wrt a configuration + ! + ! n_singles : on input, max number of singles : + ! elec_alpha_num * (mo_num - elec_beta_num) + ! on output, number of generated singles + END_DOC + integer, intent(in) :: Nint + integer, intent(inout) :: n_singles + integer(bit_kind), intent(in) :: cfg(Nint,2) + integer(bit_kind), intent(out) :: singles(Nint,2,*) + + integer :: i,k, n_singles_ma, i_hole, i_particle + integer(bit_kind) :: single(Nint,2) + logical :: i_ok + + n_singles = 0 + !TODO + !Make list of Somo and Domo for holes + !Make list of Unocc and Somo for particles + do i_hole = 1, mo_num + do i_particle = 1, mo_num + call do_single_excitation_cfg(cfg,single,i_hole,i_particle,i_ok) + if (i_ok) then + n_singles = n_singles + 1 + do k=1,Nint + singles(k,1,n_singles) = single(k,1) + singles(k,2,n_singles) = single(k,2) + enddo + endif + enddo + enddo +end + +subroutine generate_all_singles_cfg_with_type(cfgInp,singles,idxs_singles,pq_singles,ex_type_singles,n_singles,Nint) + implicit none + use bitmasks + BEGIN_DOC + ! Generate all single excitation wrt a configuration + ! + ! n_singles : on input, max number of singles : + ! elec_alpha_num * (mo_num - elec_beta_num) + ! on output, number of generated singles + ! ex_type_singles : on output contains type of excitations : + ! + END_DOC + integer, intent(in) :: Nint + integer, intent(inout) :: n_singles + integer, intent(out) :: idxs_singles(*) + integer, intent(out) :: ex_type_singles(*) + integer, intent(out) :: pq_singles(2,*) + integer(bit_kind), intent(in) :: cfgInp(Nint,2) + integer(bit_kind), intent(out) :: singles(Nint,2,*) + integer(bit_kind) :: Jdet(Nint,2) + + integer :: i,k, n_singles_ma, i_hole, i_particle, ex_type, addcfg + integer(bit_kind) :: single(Nint,2) + logical :: i_ok + + n_singles = 0 + !TODO + !Make list of Somo and Domo for holes + !Make list of Unocc and Somo for particles + do i_hole = 1+n_core_orb, n_core_orb + n_act_orb + do i_particle = 1+n_core_orb, n_core_orb + n_act_orb + if(i_hole .EQ. i_particle) cycle + addcfg = -1 + call do_single_excitation_cfg_with_type(cfgInp,single,i_hole,i_particle,ex_type,i_ok) + if (i_ok) then + call binary_search_cfg(single,addcfg) + if(addcfg .EQ. -1) cycle + n_singles = n_singles + 1 + do k=1,Nint + singles(k,1,n_singles) = single(k,1) + singles(k,2,n_singles) = single(k,2) + ex_type_singles(n_singles) = ex_type + pq_singles(1,n_singles) = i_hole ! p + pq_singles(2,n_singles) = i_particle ! q + idxs_singles(n_singles) = addcfg + enddo + endif + enddo + enddo +end + diff --git a/src/csf/sigma_vector.irp.f b/src/csf/sigma_vector.irp.f new file mode 100644 index 00000000..265d2384 --- /dev/null +++ b/src/csf/sigma_vector.irp.f @@ -0,0 +1,647 @@ + BEGIN_PROVIDER [ integer, NSOMOMax] + &BEGIN_PROVIDER [ integer, NCSFMax] + &BEGIN_PROVIDER [ integer*8, NMO] + &BEGIN_PROVIDER [ integer, NBFMax] + &BEGIN_PROVIDER [ integer, n_CSF] + &BEGIN_PROVIDER [ integer, maxDetDimPerBF] + implicit none + BEGIN_DOC + ! Documentation for NSOMOMax + ! The maximum number of SOMOs for the current calculation. + ! required for the calculation of prototype arrays. + END_DOC + NSOMOMax = min(elec_num, cfg_nsomo_max + 2) + ! Note that here we need NSOMOMax + 2 sizes + NCSFMax = max(1,nint((binom(NSOMOMax,(NSOMOMax+1)/2)-binom(NSOMOMax,((NSOMOMax+1)/2)+1)))) ! TODO: NCSFs for MS=0 + NBFMax = NCSFMax + maxDetDimPerBF = max(1,nint((binom(NSOMOMax,(NSOMOMax+1)/2)))) + NMO = n_act_orb + integer i,j,k,l + integer startdet,enddet + integer ncfg,ncfgprev + integer NSOMO + integer dimcsfpercfg + integer detDimperBF + real*8 :: coeff + integer MS + integer ncfgpersomo + detDimperBF = 0 + MS = elec_alpha_num-elec_beta_num + ! number of cfgs = number of dets for 0 somos + n_CSF = cfg_seniority_index(0)-1 + ncfgprev = cfg_seniority_index(0) + do i = 0-iand(MS,1)+2, NSOMOMax,2 + if(cfg_seniority_index(i) .EQ. -1)then + ncfgpersomo = N_configuration + 1 + else + ncfgpersomo = cfg_seniority_index(i) + endif + ncfg = ncfgpersomo - ncfgprev + !detDimperBF = max(1,nint((binom(i,(i+1)/2)))) + if (i > 2) then + dimcsfpercfg = max(1,nint((binom(i-2,(i-2+1)/2)-binom(i-2,((i-2+1)/2)+1)))) + else + dimcsfpercfg = 1 + endif + n_CSF += ncfg * dimcsfpercfg + !if(cfg_seniority_index(i+2) == -1) EXIT + !if(detDimperBF > maxDetDimPerBF) maxDetDimPerBF = detDimperBF + ncfgprev = cfg_seniority_index(i) + enddo + END_PROVIDER + + +subroutine get_phase_qp_to_cfg(Ialpha, Ibeta, phaseout) + use bitmasks + implicit none + BEGIN_DOC + ! Documentation for get_phase_qp_to_cfg + ! + ! This function converts from (aaaa)(bbbb) + ! notation to (ab)(ab)(ab)(ab) + ! notation. + ! The cfgCI code works in (ab)(ab)(ab)(ab) + ! notation throughout. + END_DOC + integer(bit_kind),intent(in) :: Ialpha(N_int) + integer(bit_kind),intent(in) :: Ibeta(N_int) + real*8,intent(out) :: phaseout + integer(bit_kind) :: mask, deta(N_int), detb(N_int) + integer :: nbetas + integer :: k + + ! Initialize deta and detb + deta = Ialpha + detb = Ibeta + + ! Find how many alpha electrons there are in all the N_ints + integer :: Na(N_int) + do k=1,N_int + Na(k) = popcnt(deta(k)) + enddo + + integer :: shift, ipos, nperm + phaseout = 1.d0 + do k=1,N_int + + do while(detb(k) /= 0_bit_kind) + ! Find the lowest beta electron and clear it + ipos = trailz(detb(k)) + detb(k) = ibclr(detb(k),ipos) + + ! Create a mask will all MOs higher than the beta electron + mask = not(shiftl(1_bit_kind,ipos + 1) - 1_bit_kind) + + ! Apply the mask to the alpha string to count how many electrons to cross + nperm = popcnt( iand(mask, deta(k)) ) + + ! Count how many alpha electrons are above the beta electron in the other integers + nperm = nperm + sum(Na(k+1:N_int)) + if (iand(nperm,1) == 1) then + phaseout = -phaseout + endif + + enddo + + enddo +end subroutine get_phase_qp_to_cfg + + + + BEGIN_PROVIDER [ integer, AIJpqMatrixDimsList, (0:NSOMOMax,0:NSOMOMax,4,NSOMOMax,NSOMOMax,2)] + &BEGIN_PROVIDER [ integer, rowsmax] + &BEGIN_PROVIDER [ integer, colsmax] + use cfunctions + implicit none + BEGIN_DOC + ! Documentation for AIJpqMatrixList + ! The prototype matrix containing the + ! matrices for each I,J somo pair and orb ids. + END_DOC + integer i,j,k,l + integer*8 Isomo, Jsomo, tmpsomo + Isomo = 0 + Jsomo = 0 + integer rows, cols, nsomoi, nsomoj + rows = -1 + cols = -1 + integer*8 MS + MS = elec_alpha_num-elec_beta_num + integer nsomomin + nsomomin = elec_alpha_num-elec_beta_num + rowsmax = 0 + colsmax = 0 + !allocate(AIJpqMatrixDimsList(NSOMOMax,NSOMOMax,4,NSOMOMax,NSOMOMax,2)) + ! Type + ! 1. SOMO -> SOMO + do i = 2-iand(nsomomin,1), NSOMOMax, 2 + Isomo = ISHFT(1_8,i)-1 + do j = i-2,i-2, 2 + Jsomo = ISHFT(1_8,j)-1 + if(j .GT. NSOMOMax .OR. j .LT. 0) then + cycle + end if + do k = 1,i + do l = 1,i + ! Define Jsomo + if(k.NE.l)then + Jsomo = IBCLR(Isomo, k-1) + Jsomo = IBCLR(Jsomo, l-1) + nsomoi = i + nsomoj = j + else + Isomo = ISHFT(1_8,i)-1 + Jsomo = ISHFT(1_8,i)-1 + nsomoi = i + nsomoj = i + endif + + call getApqIJMatrixDims(Isomo, & + Jsomo, & + MS, & + rows, & + cols) + if(rowsmax .LT. rows) then + rowsmax = rows + end if + if(colsmax .LT. cols) then + colsmax = cols + end if + ! i -> j + AIJpqMatrixDimsList(nsomoi,nsomoj,1,k,l,1) = rows + AIJpqMatrixDimsList(nsomoi,nsomoj,1,k,l,2) = cols + end do + end do + end do + end do + ! Type + ! 2. DOMO -> VMO + do i = 0+iand(nsomomin,1), NSOMOMax, 2 + Isomo = ISHFT(1_8,i)-1 + tmpsomo = ISHFT(1_8,i+2)-1 + do j = i+2,i+2, 2 + Jsomo = ISHFT(1_8,j)-1 + if(j .GT. NSOMOMax .OR. j .LT. 0) then + cycle + end if + do k = 1,j + do l = 1,j + if(k .NE. l) then + Isomo = IBCLR(tmpsomo,k-1) + Isomo = IBCLR(Isomo,l-1) + + ! Define Jsomo + Jsomo = ISHFT(1_8,j)-1; + nsomoi = i + nsomoj = j + else + Isomo = ISHFT(1_8,j)-1 + Isomo = IBCLR(Isomo,1-1) + Isomo = IBCLR(Isomo,j-1) + Jsomo = ISHFT(1_8,j)-1 + Isomo = ISHFT(1_8,j)-1 + nsomoi = j + nsomoj = j + endif + + call getApqIJMatrixDims(Isomo, & + Jsomo, & + MS, & + rows, & + cols) + if(rowsmax .LT. rows) then + rowsmax = rows + end if + if(colsmax .LT. cols) then + colsmax = cols + end if + ! i -> j + AIJpqMatrixDimsList(nsomoi,nsomoj,2,k,l,1) = rows + AIJpqMatrixDimsList(nsomoi,nsomoj,2,k,l,2) = cols + end do + end do + end do + end do + ! Type + ! 3. SOMO -> VMO + !print *,"Doing SOMO->VMO" + do i = 2-iand(nsomomin,1), NSOMOMax, 2 + Isomo = ISHFT(1_8,i)-1 + do j = i,i, 2 + Jsomo = ISHFT(1_8,j)-1 + if(j .GT. NSOMOMax .OR. j .LE. 0) then + cycle + end if + do k = 1,i + do l = 1,i + if(k .NE. l) then + Isomo = ISHFT(1_8,i+1)-1 + Isomo = IBCLR(Isomo,l-1) + Jsomo = ISHFT(1_8,j+1)-1 + Jsomo = IBCLR(Jsomo,k-1) + else + Isomo = ISHFT(1_8,i)-1 + Jsomo = ISHFT(1_8,j)-1 + endif + call getApqIJMatrixDims(Isomo, & + Jsomo, & + MS, & + rows, & + cols) + if(rowsmax .LT. rows) then + rowsmax = rows + end if + if(colsmax .LT. cols) then + colsmax = cols + end if + ! i -> j + AIJpqMatrixDimsList(i,j,3,k,l,1) = rows + AIJpqMatrixDimsList(i,j,3,k,l,2) = cols + end do + end do + end do + end do + ! Type + ! 4. DOMO -> VMO + !print *,"Doing DOMO->SOMO" + do i = 2-iand(nsomomin,1), NSOMOMax, 2 + do j = i,i, 2 + if(j .GT. NSOMOMax .OR. j .LE. 0) then + cycle + end if + do k = 1,i + do l = 1,i + if(k .NE. l) then + Isomo = ISHFT(1_8,i+1)-1 + Isomo = IBCLR(Isomo,k+1-1) + Jsomo = ISHFT(1_8,j+1)-1 + Jsomo = IBCLR(Jsomo,l-1) + else + Isomo = ISHFT(1_8,i)-1 + Jsomo = ISHFT(1_8,j)-1 + endif + call getApqIJMatrixDims(Isomo, & + Jsomo, & + MS, & + rows, & + cols) + if(rowsmax .LT. rows) then + rowsmax = rows + end if + if(colsmax .LT. cols) then + colsmax = cols + end if + ! i -> j + AIJpqMatrixDimsList(i,j,4,k,l,1) = rows + AIJpqMatrixDimsList(i,j,4,k,l,2) = cols + end do + end do + end do + end do + END_PROVIDER + + BEGIN_PROVIDER [ real*8, AIJpqContainer, (0:NSOMOMax,0:NSOMOMax,4,NSOMOMax,NSOMOMax,NBFMax,NBFMax)] + use cfunctions + implicit none + BEGIN_DOC + ! Documentation for AIJpqMatrixList + ! The prototype matrix containing the + ! matrices for each I,J somo pair and orb ids. + ! + ! Due to the different types of excitations which + ! include DOMOs and VMOs two prototype DOMOs and two + ! prototype VMOs are needed. Therefore + ! the 4th and 5th dimensions are NSOMOMax+4 and NSOMOMax+4 + ! respectively. + ! + ! The type of excitations are ordered as follows: + ! Type 1 - SOMO -> SOMO + ! Type 2 - DOMO -> VMO + ! Type 3 - SOMO -> VMO + ! Type 4 - DOMO -> SOMO + END_DOC + integer i,j,k,l, orbp, orbq, ri, ci + orbp = 0 + orbq = 0 + integer*8 Isomo, Jsomo, tmpsomo + Isomo = 0 + Jsomo = 0 + integer rows, cols, nsomoi, nsomoj + rows = -1 + cols = -1 + integer*8 MS + MS = 0 + touch AIJpqMatrixDimsList + real*8,dimension(:,:),allocatable :: meMatrix + integer maxdim + !maxdim = max(rowsmax,colsmax) + ! allocate matrix + !allocate(AIJpqMatrixDimsList(NSOMOMax,NSOMOMax,4,NSOMOMax,NSOMOMax,2)) + ! Type + ! 1. SOMO -> SOMO + do i = 2, NSOMOMax, 2 + Isomo = ISHFT(1_8,i)-1 + do j = i-2,i-2, 2 + if(j .GT. NSOMOMax .OR. j .LT. 0) cycle + do k = 1,i + do l = 1,i + + ! Define Jsomo + if(k .NE. l) then + Jsomo = IBCLR(Isomo, k-1) + Jsomo = IBCLR(Jsomo, l-1) + nsomoi = i + nsomoj = j + else + Isomo = ISHFT(1_8,i)-1 + Jsomo = ISHFT(1_8,i)-1 + nsomoi = i + nsomoj = i + endif + + AIJpqContainer(nsomoi,nsomoj,1,k,l,:,:) = 0.0d0 + call getApqIJMatrixDims(Isomo, & + Jsomo, & + MS, & + rows, & + cols) + + orbp = k + orbq = l + allocate(meMatrix(rows,cols)) + meMatrix = 0.0d0 + ! fill matrix + call getApqIJMatrixDriver(Isomo, & + Jsomo, & + orbp, & + orbq, & + MS, & + NMO, & + meMatrix, & + rows, & + cols) + ! i -> j + do ri = 1,rows + do ci = 1,cols + AIJpqContainer(nsomoi,nsomoj,1,k,l,ri,ci) = meMatrix(ri, ci) + end do + end do + deallocate(meMatrix) + end do + end do + end do + end do + ! Type + ! 2. DOMO -> VMO + do i = 0, NSOMOMax, 2 + Isomo = ISHFT(1_8,i)-1 + tmpsomo = ISHFT(1_8,i+2)-1 + do j = i+2,i+2, 2 + if(j .GT. NSOMOMax .OR. j .LE. 0) cycle + Jsomo = ISHFT(1_8,j)-1 + do k = 1,j + do l = 1,j + if(k .NE. l) then + Isomo = IBCLR(tmpsomo,k-1) + Isomo = IBCLR(Isomo,l-1) + ! Define Jsomo + Jsomo = ISHFT(1_8,j)-1; + nsomoi = i + nsomoj = j + else + Isomo = ISHFT(1_8,j)-1 + Isomo = IBCLR(Isomo,1-1) + Isomo = IBCLR(Isomo,j-1) + Jsomo = ISHFT(1_8,j)-1 + Isomo = ISHFT(1_8,j)-1 + nsomoi = j + nsomoj = j + endif + + AIJpqContainer(nsomoi,nsomoj,2,k,l,:,:) = 0.0d0 + call getApqIJMatrixDims(Isomo, & + Jsomo, & + MS, & + rows, & + cols) + + orbp = k + orbq = l + allocate(meMatrix(rows,cols)) + meMatrix = 0.0d0 + ! fill matrix + call getApqIJMatrixDriver(Isomo, & + Jsomo, & + orbp, & + orbq, & + MS, & + NMO, & + meMatrix, & + rows, & + cols) + ! i -> j + do ri = 1,rows + do ci = 1,cols + AIJpqContainer(nsomoi,nsomoj,2,k,l,ri,ci) = meMatrix(ri, ci) + end do + end do + deallocate(meMatrix) + end do + end do + end do + end do + ! Type + ! 3. SOMO -> VMO + do i = 2, NSOMOMax, 2 + Isomo = ISHFT(1_8,i)-1 + do j = i,i, 2 + Jsomo = ISHFT(1_8,j)-1 + if(j .GT. NSOMOMax .OR. j .LE. 0) cycle + do k = 1,i + do l = 1,i + if(k .NE. l) then + Isomo = ISHFT(1_8,i+1)-1 + Isomo = IBCLR(Isomo,l-1) + Jsomo = ISHFT(1_8,j+1)-1 + Jsomo = IBCLR(Jsomo,k-1) + else + Isomo = ISHFT(1_8,i)-1 + Jsomo = ISHFT(1_8,j)-1 + endif + + AIJpqContainer(i,j,3,k,l,:,:) = 0.0d0 + call getApqIJMatrixDims(Isomo, & + Jsomo, & + MS, & + rows, & + cols) + + orbp = k + orbq = l + allocate(meMatrix(rows,cols)) + meMatrix = 0.0d0 + ! fill matrix + call getApqIJMatrixDriver(Isomo, & + Jsomo, & + orbp, & + orbq, & + MS, & + NMO, & + meMatrix, & + rows, & + cols) + ! i -> j + do ri = 1,rows + do ci = 1,cols + AIJpqContainer(i,j,3,k,l,ri,ci) = meMatrix(ri, ci) + end do + end do + deallocate(meMatrix) + end do + end do + end do + end do + ! Type + ! 4. DOMO -> SOMO + do i = 2, NSOMOMax, 2 + Isomo = ISHFT(1_8,i)-1 + do j = i,i, 2 + Jsomo = ISHFT(1_8,i)-1 + if(j .GT. NSOMOMax .OR. j .LE. 0) cycle + do k = 1,i + do l = 1,i + if(k .NE. l) then + Isomo = ISHFT(1_8,i+1)-1 + Isomo = IBCLR(Isomo,k-1) + Jsomo = ISHFT(1_8,j+1)-1 + Jsomo = IBCLR(Jsomo,l+1-1) + else + Isomo = ISHFT(1_8,i)-1 + Jsomo = ISHFT(1_8,j)-1 + endif + + AIJpqContainer(i,j,4,k,l,:,:) = 0.0d0 + call getApqIJMatrixDims(Isomo, & + Jsomo, & + MS, & + rows, & + cols) + + orbp = k + orbq = l + + allocate(meMatrix(rows,cols)) + meMatrix = 0.0d0 + ! fill matrix + call getApqIJMatrixDriver(Isomo, & + Jsomo, & + orbp, & + orbq, & + MS, & + NMO, & + meMatrix, & + rows, & + cols) + ! i -> j + do ri = 1,rows + do ci = 1,cols + AIJpqContainer(i,j,4,k,l,ri,ci) = meMatrix(ri, ci) + end do + end do + deallocate(meMatrix) + end do + end do + end do + end do + END_PROVIDER + + +!!!!!! + + BEGIN_PROVIDER [ real*8, DetToCSFTransformationMatrix, (0:NSOMOMax,NBFMax,maxDetDimPerBF)] + &BEGIN_PROVIDER [ real*8, psi_coef_config, (n_CSF)] + &BEGIN_PROVIDER [ integer, psi_config_data, (N_configuration,2)] + use cfunctions + use bitmasks + implicit none + BEGIN_DOC + ! Documentation for DetToCSFTransformationMatrix + ! Provides the matrix of transformatons for the + ! conversion between determinant to CSF basis (in BFs) + END_DOC + integer(bit_kind) :: mask(N_int), Ialpha(N_int),Ibeta(N_int) + integer :: rows, cols, i, j, k + integer :: startdet, enddet + integer*8 MS, Isomo, Idomo + integer ndetI + integer :: getNSOMO + real*8,dimension(:,:),allocatable :: tempBuffer + real*8,dimension(:),allocatable :: tempCoeff + real*8 :: norm_det1, phasedet + norm_det1 = 0.d0 + MS = elec_alpha_num - elec_beta_num + ! initialization + psi_coef_config = 0.d0 + DetToCSFTransformationMatrix(0,:,:) = 1.d0 + do i = 2-iand(elec_alpha_num-elec_beta_num,1), NSOMOMax,2 + Isomo = IBSET(0_8, i) - 1_8 + ! rows = Ncsfs + ! cols = Ndets + bfIcfg = max(1,nint((binom(i,(i+1)/2)-binom(i,((i+1)/2)+1)))) + ndetI = max(1,nint((binom(i,(i+1)/2)))) + + allocate(tempBuffer(bfIcfg,ndetI)) + call getCSFtoDETTransformationMatrix(Isomo, MS, NBFMax, maxDetDimPerBF, tempBuffer) + DetToCSFTransformationMatrix(i,1:bfIcfg,1:ndetI) = tempBuffer(1:bfIcfg,1:ndetI) + deallocate(tempBuffer) + enddo + + integer s, bfIcfg + integer countcsf + countcsf = 0 + integer countdet + countdet = 0 + integer idx + integer istate + istate = 1 + phasedet = 1.0d0 + do i = 1,N_configuration + startdet = psi_configuration_to_psi_det(1,i) + enddet = psi_configuration_to_psi_det(2,i) + ndetI = enddet-startdet+1 + + allocate(tempCoeff(ndetI)) + countdet = 1 + do j = startdet, enddet + idx = psi_configuration_to_psi_det_data(j) + Ialpha(:) = psi_det(:,1,idx) + Ibeta(:) = psi_det(:,2,idx) + call get_phase_qp_to_cfg(Ialpha, Ibeta, phasedet) + tempCoeff(countdet) = psi_coef(idx, istate)*phasedet + norm_det1 += tempCoeff(countdet)*tempCoeff(countdet) + countdet += 1 + enddo + + s = 0 + do k=1,N_int + if (psi_configuration(k,1,i) == 0_bit_kind) cycle + s = s + popcnt(psi_configuration(k,1,i)) + enddo + bfIcfg = max(1,nint((binom(s,(s+1)/2)-binom(s,((s+1)/2)+1)))) + + ! perhaps blocking with CFGs of same seniority + ! can be more efficient + allocate(tempBuffer(bfIcfg,ndetI)) + tempBuffer = DetToCSFTransformationMatrix(s,:bfIcfg,:ndetI) + + call dgemm('N','N', bfIcfg, 1, ndetI, 1.d0, tempBuffer, size(tempBuffer,1), tempCoeff, size(tempCoeff,1), 0.d0, psi_coef_config(countcsf+1), size(psi_coef_config,1)) + !call dgemv('N', NBFMax, maxDetDimPerBF, 1.d0, tempBuffer, size(tempBuffer,1), tempCoeff, 1, 0.d0, psi_coef_config(countcsf), 1) + + deallocate(tempCoeff) + deallocate(tempBuffer) + psi_config_data(i,1) = countcsf + 1 + countcsf += bfIcfg + psi_config_data(i,2) = countcsf + enddo + + END_PROVIDER diff --git a/src/csf/tree_utils.c b/src/csf/tree_utils.c new file mode 100644 index 00000000..019fdaa9 --- /dev/null +++ b/src/csf/tree_utils.c @@ -0,0 +1,306 @@ +#include "tree_utils.h" + +void buildTree(Tree *bftree, + Node **inode, + int isomo, + int izeros, + int icpl, + int NSOMOMax, + int MSmax){ + + // Find the maximum parallel couplings 0 + // the maximum anti-parallel couplings 1 + int zeromax = MSmax + (NSOMOMax-MSmax)/2; + int onemax = NSOMOMax - zeromax; + + // Exit condition + if(isomo > NSOMOMax || icpl < 0 || izeros > zeromax ) return; + + // If we find a valid BF assign its address + if(isomo == NSOMOMax){ + (*inode)->addr = bftree->rootNode->addr; + bftree->rootNode->addr += 1; + return; + } + + // Call 0 branch + if(((*inode)->C0) == NULL && izeros+1 <= zeromax){ + ((*inode)->C0) = malloc(sizeof(Node)); + (*(*inode)->C0) = (Node){ .C0 = NULL, .C1 = NULL, .PREV = *inode, .addr = -1, .cpl = 0, .iSOMO = isomo }; + buildTree(bftree, &(*inode)->C0, isomo+1, izeros+1, icpl+1, NSOMOMax, MSmax); + } + else buildTree(bftree, &(*inode)->C0, isomo+1, izeros+1, icpl+1, NSOMOMax, MSmax); + + // Call 1 branch + if(((*inode)->C1) == NULL && icpl-1 >= 0){ + ((*inode)->C1) = malloc(sizeof(Node)); + (*(*inode)->C1) = (Node){ .C0 = NULL, .C1 = NULL, .PREV = *inode, .addr = -1, .cpl = 1, .iSOMO = isomo }; + buildTree(bftree, &(*inode)->C1, isomo+1, izeros+0, icpl-1, NSOMOMax, MSmax); + } + else buildTree(bftree, &(*inode)->C1, isomo+1, izeros+0, icpl-1, NSOMOMax, MSmax); + + return; +} + +void buildTreeDriver(Tree *bftree, int NSOMO, int MS, int *NBF){ + int isomo = 0; // counts the total number of SOMO's + int izeros= 0; // Counts the total number of parallel coupings (i.e. 0's) + int icpl = 0; // keep track of the ith ms (cannot be -ve) + int addr = 0; // Counts the total BF's + + buildTree(bftree, &(bftree->rootNode), isomo, izeros, icpl, NSOMO, MS); + + *NBF = bftree->rootNode->addr; +} + + +void getIthBF(Node *inode, int isomo, bool foundBF, int NSOMOMax, int getaddr, int *vecBF){ + // Exit condition + if(foundBF) return; + if(isomo > NSOMOMax) return; + if(inode == NULL) return; + + if(isomo == NSOMOMax){ + if(inode->addr == getaddr){ + for(int i = NSOMOMax-1; i > -1; i--){ + vecBF[i] = inode->cpl; + inode = inode->PREV; + } + foundBF = true; + return; + } + } + + // Recurse to C0 + if(inode->C0 != NULL){ + getIthBF(inode->C0, isomo+1, foundBF, NSOMOMax, getaddr, vecBF); + } + // Recurse to C1 + if(inode->C1 != NULL){ + getIthBF(inode->C1, isomo+1, foundBF, NSOMOMax, getaddr, vecBF); + } + + return; +} + +void getIthBFDriver(Tree *bftree, int NSOMOMax, int getaddr, int *vecBF){ + int isomo = 0; + bool foundBF = false; + getIthBF((bftree->rootNode), isomo, foundBF, NSOMOMax, getaddr, vecBF); +} + +void genDets(Tree *dettree, + Node **inode, + int isomo, + int izeros, + int icpl, + int NSOMOMax, + int MSmax){ + + // Find the maximum parallel couplings 0 + // the maximum anti-parallel couplings 1 + int zeromax = MSmax + (NSOMOMax-MSmax)/2; + int onemax = NSOMOMax - zeromax; + + // Exit condition + if(isomo > NSOMOMax || izeros > zeromax || abs(icpl) > onemax) return; + + // If we find a valid BF assign its address + if(isomo == NSOMOMax){ + (*inode)->addr = dettree->rootNode->addr; + dettree->rootNode->addr += 1; + return; + } + + // Call 0 branch + if(((*inode)->C0) == NULL && izeros+1 <= zeromax){ + ((*inode)->C0) = malloc(sizeof(Node)); + (*(*inode)->C0) = (Node){ .C0 = NULL, .C1 = NULL, .PREV = *inode, .addr = -1, .cpl = 0, .iSOMO = isomo }; + genDets(dettree, &(*inode)->C0, isomo+1, izeros+1, icpl+0, NSOMOMax, MSmax); + } + else genDets(dettree, &(*inode)->C0, isomo+1, izeros+1, icpl+0, NSOMOMax, MSmax); + + // Call 1 branch + if(((*inode)->C1) == NULL && abs(icpl+1) <= onemax){ + ((*inode)->C1) = malloc(sizeof(Node)); + (*(*inode)->C1) = (Node){ .C0 = NULL, .C1 = NULL, .PREV = *inode, .addr = -1, .cpl = 1, .iSOMO = isomo }; + genDets(dettree, &(*inode)->C1, isomo+1, izeros+0, icpl+1, NSOMOMax, MSmax); + } + else genDets(dettree, &(*inode)->C1, isomo+1, izeros+0, icpl+1, NSOMOMax, MSmax); + + return; +} + +void genDetsDriver(Tree *dettree, int NSOMO, int MS, int *Ndets){ + int isomo = 0; // counts the total number of SOMO's + int izeros= 0; // Counts the total number of parallel coupings (i.e. 0's) + int icpl = 0; // keep track of the ith ms (cannot be -ve) + int addr = 0; // Counts the total BF's + + genDets(dettree, &(dettree->rootNode), isomo, izeros, icpl, NSOMO, MS); + + *Ndets = dettree->rootNode->addr; +} + +void getIthDet(Node *inode, int isomo, bool foundBF, int NSOMOMax, int getaddr, int *vecBF){ + // Exit condition + if(foundBF) return; + if(isomo > NSOMOMax) return; + if(inode == NULL) return; + + if(isomo == NSOMOMax){ + if(inode->addr == getaddr){ + for(int i = NSOMOMax-1; i > -1; i--){ + vecBF[i] = inode->cpl; + inode = inode->PREV; + } + foundBF = true; + return; + } + } + + // Recurse to C0 + if(inode->C0 != NULL){ + getIthDet(inode->C0, isomo+1, foundBF, NSOMOMax, getaddr, vecBF); + } + // Recurse to C1 + if(inode->C1 != NULL){ + getIthDet(inode->C1, isomo+1, foundBF, NSOMOMax, getaddr, vecBF); + } + + return; +} + +void getIthDetDriver(Tree *dettree, int NSOMOMax, int getaddr, int *vecBF){ + int isomo = 0; + bool foundBF = false; + getIthDet((dettree->rootNode), isomo, foundBF, NSOMOMax, getaddr, vecBF); +} + +void findAddofDet(Node *inode, int isomo, bool foundDet, int NSOMOMax, int *inpdet, int *addr){ + // Exit condition + if(foundDet) return; + if(isomo == NSOMOMax){ + foundDet = true; + *addr = inode->addr; + return; + } + + // Recurse to C0 + if(inpdet[isomo] == 0){ + if(inode->C0 != NULL){ + findAddofDet(inode->C0, isomo+1, foundDet, NSOMOMax, inpdet, addr); + } + else{ + *addr = -1; + return; + } + } + else{ + // Recurse to C1 + if(inode->C1 != NULL){ + findAddofDet(inode->C1, isomo+1, foundDet, NSOMOMax, inpdet, addr); + } + else{ + *addr = -1; + return; + } + } + + return; +} + +void findAddofDetDriver(Tree *dettree, int NSOMOMax, int *inpdet, int *addr){ + *addr = -1; + int isomo = 0; + bool foundDet = false; + findAddofDet((dettree->rootNode), isomo, foundDet, NSOMOMax, inpdet, addr); +} + +void getDetlist(Node *inode, int isomo, int NSOMOMax, int *vecBF, int *detlist){ + // Exit condition + if(isomo > NSOMOMax) return; + if(inode == NULL) return; + + if(isomo == NSOMOMax){ + int idet=0; + for(int k=0;kaddr]=idet; + return; + } + + + // Recurse to C0 + if(inode->C0 != NULL){ + vecBF[isomo] = 0; + getDetlist(inode->C0, isomo+1, NSOMOMax, vecBF, detlist); + } + // Recurse to C1 + if(inode->C1 != NULL){ + vecBF[isomo] = 1; + getDetlist(inode->C1, isomo+1, NSOMOMax, vecBF, detlist); + } + + return; +} + +void getDetlistDriver(Tree *dettree, int NSOMOMax, int *detlist){ + int isomo = 0; + int vecBF[NSOMOMax]; + if(dettree->rootNode->addr > 1) getDetlist((dettree->rootNode), isomo, NSOMOMax, vecBF, detlist); +} + +void genDetBasis(Tree *dettree, int Isomo, int MS, int *ndets){ + + int NSOMO=0; + getSetBits(Isomo, &NSOMO); + genDetsDriver(dettree, NSOMO, MS, ndets); + +} + +void callBlasMatxMat(double *A, int rowA, int colA, double *B, int rowB, int colB, double *C, bool transA, bool transB){ + int m = rowA; + int k = colA; + int n = colB; + double alpha = 1.0; + double beta = 0.0; + int val = 0; + + if (transA) val |= 0x1; + if (transB) val |= 0x2; + + switch (val) { + case 0: // notransA, notransB + m = rowA; + n = colB; + k = colA; + f_dgemm('N', 'N', n, m, k, alpha, B, n, A, k, beta, C, n); + break; + case 1: // transA, notransB + m = colA; + n = colB; + k = rowA; + f_dgemm('N', 'T', n, m, k, alpha, B, n, A, colA, beta, C, n); + break; + case 2: // notransA, transB + //m = rowA; + //n = rowB; + //k = colB; + m = rowA; + n = rowB; + k = colA; + f_dgemm('T', 'N', n, m, k, alpha, B, colB, A, k, beta, C, n); + break; + case 3: // transA, transB + m = colA; + n = rowB; + k = rowA; + f_dgemm('T', 'T', n, m, k, alpha, B, colB, A, colA, beta, C, n); + break; + default: + printf("Impossible !!!!\n"); + break; + } +} diff --git a/src/csf/tree_utils.h b/src/csf/tree_utils.h new file mode 100644 index 00000000..5a788149 --- /dev/null +++ b/src/csf/tree_utils.h @@ -0,0 +1,91 @@ +#ifndef TREE_UTILS_H +#define TREE_UTILS_H +#include +#include +#include +#include +#include + +typedef struct bin_node Node; +typedef struct bin_tree Tree; +struct bin_node { + Node *C0; + Node *C1; + Node *PREV; + int addr; + int cpl; + int iSOMO; +}; + +struct bin_tree { + Node *rootNode; + int NBF; +}; + +void f_dgemm(const char transb, const char transa, const int n, const int m, const int k, + const double alpha, const double* B, const int ldb, const double* A, + const int lda, const double beta, double* C, const int ldc); + + + +#define MAX_SOMO 32 + +void buildTreeDriver(Tree *bftree, int NSOMO, int MS, int *NBF); + +void buildTree(Tree *bftree, Node **inode, int isomo, int izeros, int icpl, int NSOMOMax, int MSmax); + +void printTreeDriver(Tree *bftree, int NSOMOMax); +void printTree(Node *bftree, int isomo, int NSOMOMax, int *vecBF); + +void getIthBF(Node *node, int isomo, bool foundBF, int NSOMOMax, int getaddr, int *vecBF); +void getIthBFDriver(Tree *bftree, int NSOMOMax, int getaddr, int *vecBF); + +void getBFIndexList(int NSOMO, int *BF1, int *IdxListBF1); +void getIslands(int NSOMO, int *BF1, int *BF2, int *nislands, int *phasefactor); + +void generateAllBFs(int64_t Isomo, int64_t MS, Tree *bftree, int *NBF, int *NSOMO); +void getSetBits(int64_t n, int *nsetbits); +void getOverlapMatrix(int64_t Isomo, int64_t MS, double **overlapMatrixptr, int *rows, int *cols, int *NSOMOout); +void getOverlapMatrix_withDet(double *bftodetmatrixI, int rowsbftodetI, int colsbftodetI, int64_t Isomo, int64_t MS, double **overlapMatrixI, int *rowsI, int *colsI, int *NSOMO); +void gramSchmidt(double *overlapMatrix, int rows, int cols, double *orthoMatrix); + + +void calculateMETypeSOMOSOMO(int *BF1, int *BF2, int moi, int moj, double *factor, int *phasefactor); +void getOneElMETypeSOMOSOMO(int64_t Isomo, int64_t Jsomos, int moi, int moj, int MS, double **oneElMatrixElementsptr, int *rows, int *cols); + +/*********************** + +Determinant Tree utils +***********************/ + + +void genDets(Tree *dettree, + Node **inode, + int isomo, + int izeros, + int icpl, + int NSOMOMax, + int MSmax); +void genDetsDriver(Tree *dettree, int NSOMO, int MS, int *Ndets); + +void getIthDet(Node *inode, int isomo, bool foundBF, int NSOMOMax, int getaddr, int *vecBF); +void getIthDetDriver(Tree *dettree, int NSOMOMax, int getaddr, int *vecBF); +void getDetlistDriver(Tree *dettree, int NSOMOMax, int *detlist); +void findAddofDet(Node *inode, int isomo, bool foundDet, int NSOMOMax, int *inpdet, int *addr); +void findAddofDetDriver(Tree *dettree, int NSOMOMax, int *inpdet, int *addr); + + +/************************/ + +void genDetBasis(Tree *dettree, int Isomo, int MS, int *ndets); +void getbftodetfunction(Tree *dettree, int NSOMO, int MS, int *BF1, double *rowvec); +void convertBFtoDetBasis(int64_t Isomo, int MS, double **bftodetmatrixptr, int *rows, int *cols); + +// Misc utils +void int_to_bin_digit(int64_t in, int count, int* out); +void printRealMatrix(double *orthoMatrix, int rows, int cols); +void callBlasMatxMat(double *A, int rowA, int colA, double *B, int rowB, int colB, double *C, bool transA, bool transB); +void get_phase_cfg_to_qp_inpList(int *inpdet, int NSOMO, int *phaseout); +void get_phase_cfg_to_qp_inpInt(int inpdet, double *phaseout); + +#endif diff --git a/src/davidson/NEED b/src/davidson/NEED index d3d4d2c7..bfe31bd0 100644 --- a/src/davidson/NEED +++ b/src/davidson/NEED @@ -1 +1 @@ -determinants +csf diff --git a/src/davidson/davidson_parallel.irp.f b/src/davidson/davidson_parallel.irp.f index aed81063..8fd023da 100644 --- a/src/davidson/davidson_parallel.irp.f +++ b/src/davidson/davidson_parallel.irp.f @@ -270,10 +270,12 @@ subroutine davidson_push_results_async_recv(zmq_socket_push,sending) ! Activate is zmq_socket_push is a REQ IRP_IF ZMQ_PUSH IRP_ELSE - character*(2) :: ok + character*(256) :: ok rc = f77_zmq_recv( zmq_socket_push, ok, 2, 0) if ((rc /= 2).and.(ok(1:2)/='ok')) then print *, irp_here, ': f77_zmq_recv( zmq_socket_push, ok, 2, 0)' + print *, rc + print *, ok stop -1 endif IRP_ENDIF @@ -329,6 +331,7 @@ end subroutine + subroutine davidson_collector(zmq_to_qp_run_socket, zmq_socket_pull, v0, s0, sze, N_st) use f77_zmq implicit none @@ -377,7 +380,6 @@ end subroutine - subroutine H_S2_u_0_nstates_zmq(v_0,s_0,u_0,N_st,sze) use omp_lib use bitmasks @@ -428,7 +430,7 @@ subroutine H_S2_u_0_nstates_zmq(v_0,s_0,u_0,N_st,sze) integer :: istep, imin, imax, ishift, ipos integer, external :: add_task_to_taskserver - integer, parameter :: tasksize=10000 + integer, parameter :: tasksize=20000 character*(100000) :: task istep=1 ishift=0 @@ -438,7 +440,7 @@ subroutine H_S2_u_0_nstates_zmq(v_0,s_0,u_0,N_st,sze) ipos=1 do imin=1,N_det,tasksize imax = min(N_det,imin-1+tasksize) - if (imin==1) then + if (imin<=N_det/2) then istep = 2 else istep = 1 @@ -505,7 +507,9 @@ subroutine H_S2_u_0_nstates_zmq(v_0,s_0,u_0,N_st,sze) print *, irp_here, ': Failed in zmq_set_running' endif - call omp_set_nested(.True.) + + call omp_set_max_active_levels(5) + !$OMP PARALLEL DEFAULT(shared) NUM_THREADS(2) PRIVATE(ithread) ithread = omp_get_thread_num() if (ithread == 0 ) then @@ -538,6 +542,10 @@ subroutine H_S2_u_0_nstates_zmq(v_0,s_0,u_0,N_st,sze) end + + + + BEGIN_PROVIDER [ integer, nthreads_davidson ] implicit none BEGIN_DOC diff --git a/src/davidson/davidson_parallel_csf.irp.f b/src/davidson/davidson_parallel_csf.irp.f new file mode 100644 index 00000000..fe651b1d --- /dev/null +++ b/src/davidson/davidson_parallel_csf.irp.f @@ -0,0 +1,495 @@ +use bitmasks +use f77_zmq + + +subroutine davidson_csf_slave_inproc(i) + implicit none + integer, intent(in) :: i + + call davidson_csf_run_slave(1,i) +end + + +subroutine davidson_csf_slave_tcp(i) + implicit none + integer, intent(in) :: i + call davidson_csf_run_slave(0,i) +end + + + +subroutine davidson_csf_run_slave(thread,iproc) + use f77_zmq + implicit none + BEGIN_DOC +! Slave routine for Davidson's diagonalization. + END_DOC + + integer, intent(in) :: thread, iproc + + integer :: worker_id, task_id, blockb + integer(ZMQ_PTR),external :: new_zmq_to_qp_run_socket + integer(ZMQ_PTR) :: zmq_to_qp_run_socket + + integer(ZMQ_PTR), external :: new_zmq_push_socket + integer(ZMQ_PTR) :: zmq_socket_push + + integer, external :: connect_to_taskserver + integer :: doexit, send, receive + + zmq_to_qp_run_socket = new_zmq_to_qp_run_socket() + + doexit = 0 + if (connect_to_taskserver(zmq_to_qp_run_socket,worker_id,thread) == -1) then + doexit=1 + endif + IRP_IF MPI + include 'mpif.h' + integer :: ierr + send = doexit + call MPI_AllReduce(send, receive, 1, MPI_INTEGER, MPI_SUM, MPI_COMM_WORLD, ierr) + if (ierr /= MPI_SUCCESS) then + doexit=1 + endif + doexit = receive + IRP_ENDIF + if (doexit>0) then + call end_zmq_to_qp_run_socket(zmq_to_qp_run_socket) + return + endif + + zmq_socket_push = new_zmq_push_socket(thread) + + call davidson_csf_slave_work(zmq_to_qp_run_socket, zmq_socket_push, N_states_diag, N_det, worker_id) + + integer, external :: disconnect_from_taskserver + if (disconnect_from_taskserver(zmq_to_qp_run_socket,worker_id) == -1) then + call sleep(1) + if (disconnect_from_taskserver(zmq_to_qp_run_socket,worker_id) == -1) then + print *, irp_here, ': disconnect failed' + continue + endif + endif + + call end_zmq_to_qp_run_socket(zmq_to_qp_run_socket) + call end_zmq_push_socket(zmq_socket_push) + +end subroutine + + + +subroutine davidson_csf_slave_work(zmq_to_qp_run_socket, zmq_socket_push, N_st, sze, worker_id) + use f77_zmq + implicit none + + integer(ZMQ_PTR),intent(in) :: zmq_to_qp_run_socket + integer(ZMQ_PTR),intent(in) :: zmq_socket_push + integer,intent(in) :: worker_id, N_st, sze + integer :: task_id + character*(512) :: msg + integer :: imin, imax, ishift, istep + + integer, allocatable :: psi_det_read(:,:,:) + double precision, allocatable :: v_t(:,:), u_t(:,:) + + !DIR$ ATTRIBUTES ALIGN : $IRP_ALIGN :: u_t, v_t + + ! Get wave function (u_t) + ! ----------------------- + + integer :: rc, ni, nj + integer*8 :: rc8 + integer :: N_states_read, N_det_read, psi_det_size_read + integer :: N_det_selectors_read, N_det_generators_read + + integer, external :: zmq_get_dvector + integer, external :: zmq_get_dmatrix + + PROVIDE psi_det_beta_unique psi_bilinear_matrix_order_transp_reverse psi_det_alpha_unique + PROVIDE psi_bilinear_matrix_transp_values psi_bilinear_matrix_values psi_bilinear_matrix_columns_loc + PROVIDE ref_bitmask_energy nproc + PROVIDE mpi_initialized + + allocate(u_t(N_st,N_det)) + + ! Warning : dimensions are modified for efficiency, It is OK since we get the + ! full matrix + if (size(u_t,kind=8) < 8388608_8) then + ni = size(u_t) + nj = 1 + else + ni = 8388608 + nj = int(size(u_t,kind=8)/8388608_8,4) + 1 + endif + + do while (zmq_get_dmatrix(zmq_to_qp_run_socket, worker_id, 'u_t', u_t, ni, nj, size(u_t,kind=8)) == -1) + print *, 'mpi_rank, N_states_diag, N_det' + print *, mpi_rank, N_states_diag, N_det + stop 'u_t' + enddo + + IRP_IF MPI + include 'mpif.h' + integer :: ierr + + call broadcast_chunks_double(u_t,size(u_t,kind=8)) + + IRP_ENDIF + + ! Run tasks + ! --------- + + logical :: sending + sending=.False. + + allocate(v_t(N_st,N_det)) + do + integer, external :: get_task_from_taskserver + integer, external :: task_done_to_taskserver + if (get_task_from_taskserver(zmq_to_qp_run_socket,worker_id, task_id, msg) == -1) then + exit + endif + if(task_id == 0) exit + read (msg,*) imin, imax, ishift, istep + integer :: k + do k=imin,imax + v_t(:,k) = 0.d0 + enddo + call H_u_0_nstates_openmp_work(v_t,u_t,N_st,N_det,imin,imax,ishift,istep) + if (task_done_to_taskserver(zmq_to_qp_run_socket,worker_id,task_id) == -1) then + print *, irp_here, 'Unable to send task_done' + endif + call davidson_push_results_async_recv(zmq_socket_push, sending) + call davidson_csf_push_results_async_send(zmq_socket_push, v_t, imin, imax, task_id, sending) + end do + deallocate(u_t,v_t) + call davidson_push_results_async_recv(zmq_socket_push, sending) + +end subroutine + + + +subroutine davidson_csf_push_results(zmq_socket_push, v_t, imin, imax, task_id) + use f77_zmq + implicit none + BEGIN_DOC +! Push the results of $H | U \rangle$ from a worker to the master. + END_DOC + + integer(ZMQ_PTR) ,intent(in) :: zmq_socket_push + integer ,intent(in) :: task_id, imin, imax + double precision ,intent(in) :: v_t(N_states_diag,N_det) + integer :: rc, sz + integer*8 :: rc8 + + sz = (imax-imin+1)*N_states_diag + + rc = f77_zmq_send( zmq_socket_push, task_id, 4, ZMQ_SNDMORE) + if(rc /= 4) stop 'davidson_csf_push_results failed to push task_id' + + rc = f77_zmq_send( zmq_socket_push, imin, 4, ZMQ_SNDMORE) + if(rc /= 4) stop 'davidson_csf_push_results failed to push imin' + + rc = f77_zmq_send( zmq_socket_push, imax, 4, ZMQ_SNDMORE) + if(rc /= 4) stop 'davidson_csf_push_results failed to push imax' + + rc8 = f77_zmq_send8( zmq_socket_push, v_t(1,imin), 8_8*sz, 0) + if(rc8 /= 8_8*sz) stop 'davidson_csf_push_results failed to push vt' + +! Activate is zmq_socket_push is a REQ +IRP_IF ZMQ_PUSH +IRP_ELSE + character*(2) :: ok + rc = f77_zmq_recv( zmq_socket_push, ok, 2, 0) + if ((rc /= 2).and.(ok(1:2)/='ok')) then + print *, irp_here, ': f77_zmq_recv( zmq_socket_push, ok, 2, 0)' + stop -1 + endif +IRP_ENDIF + +end subroutine + +subroutine davidson_csf_push_results_async_send(zmq_socket_push, v_t, imin, imax, task_id,sending) + use f77_zmq + implicit none + BEGIN_DOC +! Push the results of $H | U \rangle$ from a worker to the master. + END_DOC + + integer(ZMQ_PTR) ,intent(in) :: zmq_socket_push + integer ,intent(in) :: task_id, imin, imax + double precision ,intent(in) :: v_t(N_states_diag,N_det) + logical ,intent(inout) :: sending + integer :: rc, sz + integer*8 :: rc8 + + if (sending) then + print *, irp_here, ': sending=true' + stop -1 + endif + sending = .True. + + sz = (imax-imin+1)*N_states_diag + + rc = f77_zmq_send( zmq_socket_push, task_id, 4, ZMQ_SNDMORE) + if(rc /= 4) stop 'davidson_csf_push_results failed to push task_id' + + rc = f77_zmq_send( zmq_socket_push, imin, 4, ZMQ_SNDMORE) + if(rc /= 4) stop 'davidson_csf_push_results failed to push imin' + + rc = f77_zmq_send( zmq_socket_push, imax, 4, ZMQ_SNDMORE) + if(rc /= 4) stop 'davidson_csf_push_results failed to push imax' + + rc8 = f77_zmq_send8( zmq_socket_push, v_t(1,imin), 8_8*sz, 0) + if(rc8 /= 8_8*sz) stop 'davidson_csf_push_results failed to push vt' + + +end subroutine + + + + +subroutine davidson_csf_pull_results(zmq_socket_pull, v_t, imin, imax, task_id) + use f77_zmq + implicit none + BEGIN_DOC +! Pull the results of $H | U \rangle$ on the master. + END_DOC + + integer(ZMQ_PTR) ,intent(in) :: zmq_socket_pull + integer ,intent(out) :: task_id, imin, imax + double precision ,intent(out) :: v_t(N_states_diag,N_det) + + integer :: rc, sz + integer*8 :: rc8 + + rc = f77_zmq_recv( zmq_socket_pull, task_id, 4, 0) + if(rc /= 4) stop 'davidson_csf_pull_results failed to pull task_id' + + rc = f77_zmq_recv( zmq_socket_pull, imin, 4, 0) + if(rc /= 4) stop 'davidson_csf_pull_results failed to pull imin' + + rc = f77_zmq_recv( zmq_socket_pull, imax, 4, 0) + if(rc /= 4) stop 'davidson_csf_pull_results failed to pull imax' + + sz = (imax-imin+1)*N_states_diag + + rc8 = f77_zmq_recv8( zmq_socket_pull, v_t(1,imin), 8_8*sz, 0) + if(rc8 /= 8*sz) stop 'davidson_csf_pull_results failed to pull v_t' + +! Activate if zmq_socket_pull is a REP +IRP_IF ZMQ_PUSH +IRP_ELSE + rc = f77_zmq_send( zmq_socket_pull, 'ok', 2, 0) + if (rc /= 2) then + print *, irp_here, ' : f77_zmq_send (zmq_socket_pull,...' + stop -1 + endif +IRP_ENDIF + +end subroutine + + + + +subroutine davidson_csf_collector(zmq_to_qp_run_socket, zmq_socket_pull, v0, sze, N_st) + use f77_zmq + implicit none + BEGIN_DOC +! Routine collecting the results of the workers in Davidson's algorithm. + END_DOC + + integer(ZMQ_PTR), intent(in) :: zmq_socket_pull + integer, intent(in) :: sze, N_st + integer(ZMQ_PTR), intent(in) :: zmq_to_qp_run_socket + + double precision ,intent(inout) :: v0(sze, N_st) + + integer :: more, task_id, imin, imax + + double precision, allocatable :: v_t(:,:) + logical :: sending + integer :: i,j + integer, external :: zmq_delete_task_async_send + integer, external :: zmq_delete_task_async_recv + + allocate(v_t(N_st,N_det)) + v0 = 0.d0 + more = 1 + sending = .False. + do while (more == 1) + call davidson_csf_pull_results(zmq_socket_pull, v_t, imin, imax, task_id) + if (zmq_delete_task_async_send(zmq_to_qp_run_socket,task_id,sending) == -1) then + stop 'davidson: Unable to delete task (send)' + endif + do j=1,N_st + do i=imin,imax + v0(i,j) = v0(i,j) + v_t(j,i) + enddo + enddo + if (zmq_delete_task_async_recv(zmq_to_qp_run_socket,more,sending) == -1) then + stop 'davidson: Unable to delete task (recv)' + endif + end do + deallocate(v_t) + +end subroutine + + + + + +subroutine H_u_0_nstates_zmq(v_0,u_0,N_st,sze) + use omp_lib + use bitmasks + use f77_zmq + implicit none + BEGIN_DOC + ! Computes $v_0 = H | u_0\rangle$ + ! + ! n : number of determinants + ! + ! H_jj : array of $\langle j | H | j \rangle$ + END_DOC + integer, intent(in) :: N_st, sze + double precision, intent(out) :: v_0(sze,N_st) + double precision, intent(inout):: u_0(sze,N_st) + integer :: i,j,k + integer :: ithread + double precision, allocatable :: u_t(:,:) + !DIR$ ATTRIBUTES ALIGN : $IRP_ALIGN :: u_t + integer(ZMQ_PTR) :: zmq_to_qp_run_socket, zmq_socket_pull + PROVIDE psi_det_beta_unique psi_bilinear_matrix_order_transp_reverse psi_det_alpha_unique + PROVIDE psi_bilinear_matrix_transp_values psi_bilinear_matrix_values psi_bilinear_matrix_columns_loc + PROVIDE ref_bitmask_energy nproc + PROVIDE mpi_initialized + + call new_parallel_job(zmq_to_qp_run_socket,zmq_socket_pull,'davidson') + +! integer :: N_states_diag_save +! N_states_diag_save = N_states_diag +! N_states_diag = N_st + if (zmq_put_N_states_diag(zmq_to_qp_run_socket, 1) == -1) then + stop 'Unable to put N_states_diag on ZMQ server' + endif + + if (zmq_put_psi(zmq_to_qp_run_socket,1) == -1) then + stop 'Unable to put psi on ZMQ server' + endif + energy = 0.d0 + if (zmq_put_dvector(zmq_to_qp_run_socket,1,'energy',energy,size(energy)) == -1) then + stop 'Unable to put energy on ZMQ server' + endif + + + ! Create tasks + ! ============ + + integer :: istep, imin, imax, ishift, ipos + integer, external :: add_task_to_taskserver + integer, parameter :: tasksize=20000 + character*(100000) :: task + istep=1 + ishift=0 + imin=1 + + + ipos=1 + do imin=1,N_det,tasksize + imax = min(N_det,imin-1+tasksize) + if (imin==1) then + istep = 2 + else + istep = 1 + endif + do ishift=0,istep-1 + write(task(ipos:ipos+50),'(4(I11,1X),1X,1A)') imin, imax, ishift, istep, '|' + ipos = ipos+50 + if (ipos > 100000-50) then + if (add_task_to_taskserver(zmq_to_qp_run_socket,trim(task(1:ipos))) == -1) then + stop 'Unable to add task' + endif + ipos=1 + endif + enddo + enddo + + if (ipos > 1) then + if (add_task_to_taskserver(zmq_to_qp_run_socket,trim(task(1:ipos))) == -1) then + stop 'Unable to add task' + endif + ipos=1 + endif + + allocate(u_t(N_st,N_det)) + do k=1,N_st + call dset_order(u_0(1,k),psi_bilinear_matrix_order,N_det) + enddo + + call dtranspose( & + u_0, & + size(u_0, 1), & + u_t, & + size(u_t, 1), & + N_det, N_st) + + + ASSERT (N_st == N_states_diag) + ASSERT (sze >= N_det) + + integer :: rc, ni, nj + integer*8 :: rc8 + double precision :: energy(N_st) + + integer, external :: zmq_put_dvector, zmq_put_psi, zmq_put_N_states_diag + integer, external :: zmq_put_dmatrix + + if (size(u_t) < 8388608) then + ni = size(u_t) + nj = 1 + else + ni = 8388608 + nj = size(u_t)/8388608 + 1 + endif + ! Warning : dimensions are modified for efficiency, It is OK since we get the + ! full matrix + if (zmq_put_dmatrix(zmq_to_qp_run_socket, 1, 'u_t', u_t, ni, nj, size(u_t,kind=8)) == -1) then + stop 'Unable to put u_t on ZMQ server' + endif + + deallocate(u_t) + + integer, external :: zmq_set_running + if (zmq_set_running(zmq_to_qp_run_socket) == -1) then + print *, irp_here, ': Failed in zmq_set_running' + endif + + call omp_set_max_active_levels(4) + !$OMP PARALLEL DEFAULT(shared) NUM_THREADS(2) PRIVATE(ithread) + ithread = omp_get_thread_num() + if (ithread == 0 ) then + call davidson_csf_collector(zmq_to_qp_run_socket, zmq_socket_pull, v_0, N_det, N_st) + else + call davidson_csf_slave_inproc(1) + endif + !$OMP END PARALLEL + call end_parallel_job(zmq_to_qp_run_socket, zmq_socket_pull, 'davidson') + + !$OMP PARALLEL + !$OMP SINGLE + do k=1,N_st + !$OMP TASK DEFAULT(SHARED) FIRSTPRIVATE(k,N_det) + call dset_order(v_0(1,k),psi_bilinear_matrix_order_reverse,N_det) + !$OMP END TASK + !$OMP TASK DEFAULT(SHARED) FIRSTPRIVATE(k,N_det) + call dset_order(u_0(1,k),psi_bilinear_matrix_order_reverse,N_det) + !$OMP END TASK + enddo + !$OMP END SINGLE + !$OMP TASKWAIT + !$OMP END PARALLEL + +! N_states_diag = N_states_diag_save +! SOFT_TOUCH N_states_diag +end + diff --git a/src/davidson/davidson_parallel_nos2.irp.f b/src/davidson/davidson_parallel_nos2.irp.f new file mode 100644 index 00000000..84cbe3af --- /dev/null +++ b/src/davidson/davidson_parallel_nos2.irp.f @@ -0,0 +1,495 @@ +use bitmasks +use f77_zmq + + +subroutine davidson_nos2_slave_inproc(i) + implicit none + integer, intent(in) :: i + + call davidson_nos2_run_slave(1,i) +end + + +subroutine davidson_nos2_slave_tcp(i) + implicit none + integer, intent(in) :: i + call davidson_nos2_run_slave(0,i) +end + + + +subroutine davidson_nos2_run_slave(thread,iproc) + use f77_zmq + implicit none + BEGIN_DOC +! Slave routine for Davidson's diagonalization. + END_DOC + + integer, intent(in) :: thread, iproc + + integer :: worker_id, task_id, blockb + integer(ZMQ_PTR),external :: new_zmq_to_qp_run_socket + integer(ZMQ_PTR) :: zmq_to_qp_run_socket + + integer(ZMQ_PTR), external :: new_zmq_push_socket + integer(ZMQ_PTR) :: zmq_socket_push + + integer, external :: connect_to_taskserver + integer :: doexit, send, receive + + zmq_to_qp_run_socket = new_zmq_to_qp_run_socket() + + doexit = 0 + if (connect_to_taskserver(zmq_to_qp_run_socket,worker_id,thread) == -1) then + doexit=1 + endif + IRP_IF MPI + include 'mpif.h' + integer :: ierr + send = doexit + call MPI_AllReduce(send, receive, 1, MPI_INTEGER, MPI_SUM, MPI_COMM_WORLD, ierr) + if (ierr /= MPI_SUCCESS) then + doexit=1 + endif + doexit = receive + IRP_ENDIF + if (doexit>0) then + call end_zmq_to_qp_run_socket(zmq_to_qp_run_socket) + return + endif + + zmq_socket_push = new_zmq_push_socket(thread) + + call davidson_nos2_slave_work(zmq_to_qp_run_socket, zmq_socket_push, N_states_diag, N_det, worker_id) + + integer, external :: disconnect_from_taskserver + if (disconnect_from_taskserver(zmq_to_qp_run_socket,worker_id) == -1) then + call sleep(1) + if (disconnect_from_taskserver(zmq_to_qp_run_socket,worker_id) == -1) then + print *, irp_here, ': disconnect failed' + continue + endif + endif + + call end_zmq_to_qp_run_socket(zmq_to_qp_run_socket) + call end_zmq_push_socket(zmq_socket_push) + +end subroutine + + + +subroutine davidson_nos2_slave_work(zmq_to_qp_run_socket, zmq_socket_push, N_st, sze, worker_id) + use f77_zmq + implicit none + + integer(ZMQ_PTR),intent(in) :: zmq_to_qp_run_socket + integer(ZMQ_PTR),intent(in) :: zmq_socket_push + integer,intent(in) :: worker_id, N_st, sze + integer :: task_id + character*(512) :: msg + integer :: imin, imax, ishift, istep + + integer, allocatable :: psi_det_read(:,:,:) + double precision, allocatable :: v_t(:,:), u_t(:,:) + + !DIR$ ATTRIBUTES ALIGN : $IRP_ALIGN :: u_t, v_t + + ! Get wave function (u_t) + ! ----------------------- + + integer :: rc, ni, nj + integer*8 :: rc8 + integer :: N_states_read, N_det_read, psi_det_size_read + integer :: N_det_selectors_read, N_det_generators_read + + integer, external :: zmq_get_dvector + integer, external :: zmq_get_dmatrix + + PROVIDE psi_det_beta_unique psi_bilinear_matrix_order_transp_reverse psi_det_alpha_unique + PROVIDE psi_bilinear_matrix_transp_values psi_bilinear_matrix_values psi_bilinear_matrix_columns_loc + PROVIDE ref_bitmask_energy nproc + PROVIDE mpi_initialized + + allocate(u_t(N_st,N_det)) + + ! Warning : dimensions are modified for efficiency, It is OK since we get the + ! full matrix + if (size(u_t,kind=8) < 8388608_8) then + ni = size(u_t) + nj = 1 + else + ni = 8388608 + nj = int(size(u_t,kind=8)/8388608_8,4) + 1 + endif + + do while (zmq_get_dmatrix(zmq_to_qp_run_socket, worker_id, 'u_t', u_t, ni, nj, size(u_t,kind=8)) == -1) + print *, 'mpi_rank, N_states_diag, N_det' + print *, mpi_rank, N_states_diag, N_det + stop 'u_t' + enddo + + IRP_IF MPI + include 'mpif.h' + integer :: ierr + + call broadcast_chunks_double(u_t,size(u_t,kind=8)) + + IRP_ENDIF + + ! Run tasks + ! --------- + + logical :: sending + sending=.False. + + allocate(v_t(N_st,N_det)) + do + integer, external :: get_task_from_taskserver + integer, external :: task_done_to_taskserver + if (get_task_from_taskserver(zmq_to_qp_run_socket,worker_id, task_id, msg) == -1) then + exit + endif + if(task_id == 0) exit + read (msg,*) imin, imax, ishift, istep + integer :: k + do k=imin,imax + v_t(:,k) = 0.d0 + enddo + call H_u_0_nstates_openmp_work(v_t,u_t,N_st,N_det,imin,imax,ishift,istep) + if (task_done_to_taskserver(zmq_to_qp_run_socket,worker_id,task_id) == -1) then + print *, irp_here, 'Unable to send task_done' + endif + call davidson_push_results_async_recv(zmq_socket_push, sending) + call davidson_nos2_push_results_async_send(zmq_socket_push, v_t, imin, imax, task_id, sending) + end do + deallocate(u_t,v_t) + call davidson_push_results_async_recv(zmq_socket_push, sending) + +end subroutine + + + +subroutine davidson_nos2_push_results(zmq_socket_push, v_t, imin, imax, task_id) + use f77_zmq + implicit none + BEGIN_DOC +! Push the results of $H | U \rangle$ from a worker to the master. + END_DOC + + integer(ZMQ_PTR) ,intent(in) :: zmq_socket_push + integer ,intent(in) :: task_id, imin, imax + double precision ,intent(in) :: v_t(N_states_diag,N_det) + integer :: rc, sz + integer*8 :: rc8 + + sz = (imax-imin+1)*N_states_diag + + rc = f77_zmq_send( zmq_socket_push, task_id, 4, ZMQ_SNDMORE) + if(rc /= 4) stop 'davidson_nos2_push_results failed to push task_id' + + rc = f77_zmq_send( zmq_socket_push, imin, 4, ZMQ_SNDMORE) + if(rc /= 4) stop 'davidson_nos2_push_results failed to push imin' + + rc = f77_zmq_send( zmq_socket_push, imax, 4, ZMQ_SNDMORE) + if(rc /= 4) stop 'davidson_nos2_push_results failed to push imax' + + rc8 = f77_zmq_send8( zmq_socket_push, v_t(1,imin), 8_8*sz, 0) + if(rc8 /= 8_8*sz) stop 'davidson_nos2_push_results failed to push vt' + +! Activate is zmq_socket_push is a REQ +IRP_IF ZMQ_PUSH +IRP_ELSE + character*(2) :: ok + rc = f77_zmq_recv( zmq_socket_push, ok, 2, 0) + if ((rc /= 2).and.(ok(1:2)/='ok')) then + print *, irp_here, ': f77_zmq_recv( zmq_socket_push, ok, 2, 0)' + stop -1 + endif +IRP_ENDIF + +end subroutine + +subroutine davidson_nos2_push_results_async_send(zmq_socket_push, v_t, imin, imax, task_id,sending) + use f77_zmq + implicit none + BEGIN_DOC +! Push the results of $H | U \rangle$ from a worker to the master. + END_DOC + + integer(ZMQ_PTR) ,intent(in) :: zmq_socket_push + integer ,intent(in) :: task_id, imin, imax + double precision ,intent(in) :: v_t(N_states_diag,N_det) + logical ,intent(inout) :: sending + integer :: rc, sz + integer*8 :: rc8 + + if (sending) then + print *, irp_here, ': sending=true' + stop -1 + endif + sending = .True. + + sz = (imax-imin+1)*N_states_diag + + rc = f77_zmq_send( zmq_socket_push, task_id, 4, ZMQ_SNDMORE) + if(rc /= 4) stop 'davidson_nos2_push_results failed to push task_id' + + rc = f77_zmq_send( zmq_socket_push, imin, 4, ZMQ_SNDMORE) + if(rc /= 4) stop 'davidson_nos2_push_results failed to push imin' + + rc = f77_zmq_send( zmq_socket_push, imax, 4, ZMQ_SNDMORE) + if(rc /= 4) stop 'davidson_nos2_push_results failed to push imax' + + rc8 = f77_zmq_send8( zmq_socket_push, v_t(1,imin), 8_8*sz, 0) + if(rc8 /= 8_8*sz) stop 'davidson_nos2_push_results failed to push vt' + + +end subroutine + + + + +subroutine davidson_nos2_pull_results(zmq_socket_pull, v_t, imin, imax, task_id) + use f77_zmq + implicit none + BEGIN_DOC +! Pull the results of $H | U \rangle$ on the master. + END_DOC + + integer(ZMQ_PTR) ,intent(in) :: zmq_socket_pull + integer ,intent(out) :: task_id, imin, imax + double precision ,intent(out) :: v_t(N_states_diag,N_det) + + integer :: rc, sz + integer*8 :: rc8 + + rc = f77_zmq_recv( zmq_socket_pull, task_id, 4, 0) + if(rc /= 4) stop 'davidson_nos2_pull_results failed to pull task_id' + + rc = f77_zmq_recv( zmq_socket_pull, imin, 4, 0) + if(rc /= 4) stop 'davidson_nos2_pull_results failed to pull imin' + + rc = f77_zmq_recv( zmq_socket_pull, imax, 4, 0) + if(rc /= 4) stop 'davidson_nos2_pull_results failed to pull imax' + + sz = (imax-imin+1)*N_states_diag + + rc8 = f77_zmq_recv8( zmq_socket_pull, v_t(1,imin), 8_8*sz, 0) + if(rc8 /= 8*sz) stop 'davidson_nos2_pull_results failed to pull v_t' + +! Activate if zmq_socket_pull is a REP +IRP_IF ZMQ_PUSH +IRP_ELSE + rc = f77_zmq_send( zmq_socket_pull, 'ok', 2, 0) + if (rc /= 2) then + print *, irp_here, ' : f77_zmq_send (zmq_socket_pull,...' + stop -1 + endif +IRP_ENDIF + +end subroutine + + + + +subroutine davidson_nos2_collector(zmq_to_qp_run_socket, zmq_socket_pull, v0, sze, N_st) + use f77_zmq + implicit none + BEGIN_DOC +! Routine collecting the results of the workers in Davidson's algorithm. + END_DOC + + integer(ZMQ_PTR), intent(in) :: zmq_socket_pull + integer, intent(in) :: sze, N_st + integer(ZMQ_PTR), intent(in) :: zmq_to_qp_run_socket + + double precision ,intent(inout) :: v0(sze, N_st) + + integer :: more, task_id, imin, imax + + double precision, allocatable :: v_t(:,:) + logical :: sending + integer :: i,j + integer, external :: zmq_delete_task_async_send + integer, external :: zmq_delete_task_async_recv + + allocate(v_t(N_st,N_det)) + v0 = 0.d0 + more = 1 + sending = .False. + do while (more == 1) + call davidson_nos2_pull_results(zmq_socket_pull, v_t, imin, imax, task_id) + if (zmq_delete_task_async_send(zmq_to_qp_run_socket,task_id,sending) == -1) then + stop 'davidson: Unable to delete task (send)' + endif + do j=1,N_st + do i=imin,imax + v0(i,j) = v0(i,j) + v_t(j,i) + enddo + enddo + if (zmq_delete_task_async_recv(zmq_to_qp_run_socket,more,sending) == -1) then + stop 'davidson: Unable to delete task (recv)' + endif + end do + deallocate(v_t) + +end subroutine + + + + + +subroutine H_u_0_nstates_zmq(v_0,u_0,N_st,sze) + use omp_lib + use bitmasks + use f77_zmq + implicit none + BEGIN_DOC + ! Computes $v_0 = H | u_0\rangle$ + ! + ! n : number of determinants + ! + ! H_jj : array of $\langle j | H | j \rangle$ + END_DOC + integer, intent(in) :: N_st, sze + double precision, intent(out) :: v_0(sze,N_st) + double precision, intent(inout):: u_0(sze,N_st) + integer :: i,j,k + integer :: ithread + double precision, allocatable :: u_t(:,:) + !DIR$ ATTRIBUTES ALIGN : $IRP_ALIGN :: u_t + integer(ZMQ_PTR) :: zmq_to_qp_run_socket, zmq_socket_pull + PROVIDE psi_det_beta_unique psi_bilinear_matrix_order_transp_reverse psi_det_alpha_unique + PROVIDE psi_bilinear_matrix_transp_values psi_bilinear_matrix_values psi_bilinear_matrix_columns_loc + PROVIDE ref_bitmask_energy nproc + PROVIDE mpi_initialized + + call new_parallel_job(zmq_to_qp_run_socket,zmq_socket_pull,'davidson') + +! integer :: N_states_diag_save +! N_states_diag_save = N_states_diag +! N_states_diag = N_st + if (zmq_put_N_states_diag(zmq_to_qp_run_socket, 1) == -1) then + stop 'Unable to put N_states_diag on ZMQ server' + endif + + if (zmq_put_psi(zmq_to_qp_run_socket,1) == -1) then + stop 'Unable to put psi on ZMQ server' + endif + energy = 0.d0 + if (zmq_put_dvector(zmq_to_qp_run_socket,1,'energy',energy,size(energy)) == -1) then + stop 'Unable to put energy on ZMQ server' + endif + + + ! Create tasks + ! ============ + + integer :: istep, imin, imax, ishift, ipos + integer, external :: add_task_to_taskserver + integer, parameter :: tasksize=20000 + character*(100000) :: task + istep=1 + ishift=0 + imin=1 + + + ipos=1 + do imin=1,N_det,tasksize + imax = min(N_det,imin-1+tasksize) + if (imin==1) then + istep = 2 + else + istep = 1 + endif + do ishift=0,istep-1 + write(task(ipos:ipos+50),'(4(I11,1X),1X,1A)') imin, imax, ishift, istep, '|' + ipos = ipos+50 + if (ipos > 100000-50) then + if (add_task_to_taskserver(zmq_to_qp_run_socket,trim(task(1:ipos))) == -1) then + stop 'Unable to add task' + endif + ipos=1 + endif + enddo + enddo + + if (ipos > 1) then + if (add_task_to_taskserver(zmq_to_qp_run_socket,trim(task(1:ipos))) == -1) then + stop 'Unable to add task' + endif + ipos=1 + endif + + allocate(u_t(N_st,N_det)) + do k=1,N_st + call dset_order(u_0(1,k),psi_bilinear_matrix_order,N_det) + enddo + + call dtranspose( & + u_0, & + size(u_0, 1), & + u_t, & + size(u_t, 1), & + N_det, N_st) + + + ASSERT (N_st == N_states_diag) + ASSERT (sze >= N_det) + + integer :: rc, ni, nj + integer*8 :: rc8 + double precision :: energy(N_st) + + integer, external :: zmq_put_dvector, zmq_put_psi, zmq_put_N_states_diag + integer, external :: zmq_put_dmatrix + + if (size(u_t) < 8388608) then + ni = size(u_t) + nj = 1 + else + ni = 8388608 + nj = size(u_t)/8388608 + 1 + endif + ! Warning : dimensions are modified for efficiency, It is OK since we get the + ! full matrix + if (zmq_put_dmatrix(zmq_to_qp_run_socket, 1, 'u_t', u_t, ni, nj, size(u_t,kind=8)) == -1) then + stop 'Unable to put u_t on ZMQ server' + endif + + deallocate(u_t) + + integer, external :: zmq_set_running + if (zmq_set_running(zmq_to_qp_run_socket) == -1) then + print *, irp_here, ': Failed in zmq_set_running' + endif + + call omp_set_max_active_levels(4) + !$OMP PARALLEL DEFAULT(shared) NUM_THREADS(2) PRIVATE(ithread) + ithread = omp_get_thread_num() + if (ithread == 0 ) then + call davidson_nos2_collector(zmq_to_qp_run_socket, zmq_socket_pull, v_0, N_det, N_st) + else + call davidson_nos2_slave_inproc(1) + endif + !$OMP END PARALLEL + call end_parallel_job(zmq_to_qp_run_socket, zmq_socket_pull, 'davidson') + + !$OMP PARALLEL + !$OMP SINGLE + do k=1,N_st + !$OMP TASK DEFAULT(SHARED) FIRSTPRIVATE(k,N_det) + call dset_order(v_0(1,k),psi_bilinear_matrix_order_reverse,N_det) + !$OMP END TASK + !$OMP TASK DEFAULT(SHARED) FIRSTPRIVATE(k,N_det) + call dset_order(u_0(1,k),psi_bilinear_matrix_order_reverse,N_det) + !$OMP END TASK + enddo + !$OMP END SINGLE + !$OMP TASKWAIT + !$OMP END PARALLEL + +! N_states_diag = N_states_diag_save +! SOFT_TOUCH N_states_diag +end + diff --git a/src/davidson/diagonalization_h_dressed.irp.f b/src/davidson/diagonalization_h_dressed.irp.f new file mode 100644 index 00000000..26853df9 --- /dev/null +++ b/src/davidson/diagonalization_h_dressed.irp.f @@ -0,0 +1,556 @@ +subroutine davidson_diag_h(dets_in,u_in,dim_in,energies,sze,N_st,N_st_diag,Nint,dressing_state,converged) + 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 + ! + ! Initial guess vectors are not necessarily orthonormal + END_DOC + integer, intent(in) :: dim_in, sze, N_st, N_st_diag, Nint + integer(bit_kind), intent(in) :: dets_in(Nint,2,sze) + double precision, intent(inout) :: u_in(dim_in,N_st_diag) + double precision, intent(out) :: energies(N_st_diag) + integer, intent(in) :: dressing_state + logical, intent(out) :: converged + double precision, allocatable :: H_jj(:) + + double precision, external :: diag_H_mat_elem, diag_S_mat_elem + integer :: i,k + ASSERT (N_st > 0) + ASSERT (sze > 0) + ASSERT (Nint > 0) + ASSERT (Nint == N_int) + PROVIDE mo_two_e_integrals_in_map + allocate(H_jj(sze)) + + H_jj(1) = diag_h_mat_elem(dets_in(1,1,1),Nint) + !$OMP PARALLEL DEFAULT(NONE) & + !$OMP SHARED(sze,H_jj, dets_in,Nint) & + !$OMP PRIVATE(i) + !$OMP DO SCHEDULE(static) + do i=2,sze + H_jj(i) = diag_H_mat_elem(dets_in(1,1,i),Nint) + enddo + !$OMP END DO + !$OMP END PARALLEL + + if (dressing_state > 0) then + do k=1,N_st + do i=1,sze + H_jj(i) += u_in(i,k) * dressing_column_h(i,k) + enddo + enddo + endif + + call davidson_diag_hjj(dets_in,u_in,H_jj,energies,dim_in,sze,N_st,N_st_diag,Nint,dressing_state,converged) + deallocate (H_jj) +end + + +subroutine davidson_diag_hjj(dets_in,u_in,H_jj,energies,dim_in,sze,N_st,N_st_diag_in,Nint,dressing_state,converged) + use bitmasks + use mmap_module + 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 + ! + ! N_st_diag_in : Number of states in which H is diagonalized. Assumed > sze + ! + ! Initial guess vectors are not necessarily orthonormal + END_DOC + integer, intent(in) :: dim_in, sze, N_st, N_st_diag_in, Nint + integer(bit_kind), intent(in) :: dets_in(Nint,2,sze) + double precision, intent(in) :: H_jj(sze) + integer, intent(in) :: dressing_state + double precision, intent(inout) :: u_in(dim_in,N_st_diag_in) + double precision, intent(out) :: energies(N_st_diag_in) + + integer :: iter, N_st_diag + integer :: i,j,k,l,m + logical, intent(inout) :: converged + + double precision, external :: u_dot_v, u_dot_u + + integer :: k_pairs, kl + + integer :: iter2, itertot + double precision, allocatable :: y(:,:), h(:,:), lambda(:) + double precision, allocatable :: s_tmp(:,:) + double precision :: diag_h_mat_elem + double precision, allocatable :: residual_norm(:) + character*(16384) :: write_buffer + double precision :: to_print(2,N_st) + double precision :: cpu, wall + integer :: shift, shift2, itermax, istate + double precision :: r1, r2, alpha + logical :: state_ok(N_st_diag_in*davidson_sze_max) + integer :: nproc_target + integer :: order(N_st_diag_in) + double precision :: cmax + double precision, allocatable :: U(:,:), overlap(:,:) + double precision, pointer :: W(:,:) + logical :: disk_based + double precision :: energy_shift(N_st_diag_in*davidson_sze_max) + + include 'constants.include.F' + + N_st_diag = N_st_diag_in + !DIR$ ATTRIBUTES ALIGN : $IRP_ALIGN :: U, W, y, h, lambda + if (N_st_diag*3 > sze) then + print *, 'error in Davidson :' + print *, 'Increase n_det_max_full to ', N_st_diag*3 + stop -1 + endif + + itermax = max(2,min(davidson_sze_max, sze/N_st_diag))+1 + itertot = 0 + + if (state_following) then + allocate(overlap(N_st_diag*itermax, N_st_diag*itermax)) + else + allocate(overlap(1,1)) ! avoid 'if' for deallocate + endif + overlap = 0.d0 + + PROVIDE nuclear_repulsion expected_s2 psi_bilinear_matrix_order psi_bilinear_matrix_order_reverse threshold_davidson_pt2 threshold_davidson_from_pt2 + + call write_time(6) + write(6,'(A)') '' + write(6,'(A)') 'Davidson Diagonalization' + write(6,'(A)') '------------------------' + write(6,'(A)') '' + + ! Find max number of cores to fit in memory + ! ----------------------------------------- + + nproc_target = nproc + double precision :: rss + integer :: maxab + maxab = max(N_det_alpha_unique, N_det_beta_unique)+1 + + m=1 + disk_based = .False. + call resident_memory(rss) + do + r1 = 8.d0 * &! bytes + ( dble(sze)*(N_st_diag*itermax) &! U + + 1.0d0*dble(sze*m)*(N_st_diag*itermax) &! W + + 3.0d0*(N_st_diag*itermax)**2 &! h,y,s_tmp + + 1.d0*(N_st_diag*itermax) &! lambda + + 1.d0*(N_st_diag) &! residual_norm + ! In H_u_0_nstates_zmq + + 2.d0*(N_st_diag*N_det) &! u_t, v_t, on collector + + 2.d0*(N_st_diag*N_det) &! u_t, v_t, on slave + + 0.5d0*maxab &! idx0 in H_u_0_nstates_openmp_work_* + + nproc_target * &! In OMP section + ( 1.d0*(N_int*maxab) &! buffer + + 3.5d0*(maxab) ) &! singles_a, singles_b, doubles, idx + ) / 1024.d0**3 + + if (nproc_target == 0) then + call check_mem(r1,irp_here) + nproc_target = 1 + exit + endif + + if (r1+rss < qp_max_mem) then + exit + endif + + if (itermax > 4) then + itermax = itermax - 1 + else if (m==1.and.disk_based_davidson) then + m=0 + disk_based = .True. + itermax = 6 + else + nproc_target = nproc_target - 1 + endif + + enddo + nthreads_davidson = nproc_target + TOUCH nthreads_davidson + call write_int(6,N_st,'Number of states') + call write_int(6,N_st_diag,'Number of states in diagonalization') + call write_int(6,sze,'Number of determinants') + call write_int(6,nproc_target,'Number of threads for diagonalization') + call write_double(6, r1, 'Memory(Gb)') + if (disk_based) then + print *, 'Using swap space to reduce RAM' + endif + + !--------------- + + write(6,'(A)') '' + write_buffer = '=====' + do i=1,N_st + write_buffer = trim(write_buffer)//' ================ ===========' + enddo + write(6,'(A)') write_buffer(1:6+41*N_st) + write_buffer = 'Iter' + do i=1,N_st + write_buffer = trim(write_buffer)//' Energy Residual ' + enddo + write(6,'(A)') write_buffer(1:6+41*N_st) + write_buffer = '=====' + do i=1,N_st + write_buffer = trim(write_buffer)//' ================ ===========' + enddo + write(6,'(A)') write_buffer(1:6+41*N_st) + + + if (disk_based) then + ! Create memory-mapped files for W and S + type(c_ptr) :: ptr_w, ptr_s + integer :: fd_s, fd_w + call mmap(trim(ezfio_work_dir)//'davidson_w', (/int(sze,8),int(N_st_diag*itermax,8)/),& + 8, fd_w, .False., ptr_w) + call c_f_pointer(ptr_w, w, (/sze,N_st_diag*itermax/)) + else + allocate(W(sze,N_st_diag*itermax)) + endif + + allocate( & + ! Large + U(sze,N_st_diag*itermax), & + + ! Small + h(N_st_diag*itermax,N_st_diag*itermax), & + y(N_st_diag*itermax,N_st_diag*itermax), & + s_tmp(N_st_diag*itermax,N_st_diag*itermax), & + residual_norm(N_st_diag), & + lambda(N_st_diag*itermax)) + + h = 0.d0 + U = 0.d0 + y = 0.d0 + s_tmp = 0.d0 + + + ASSERT (N_st > 0) + ASSERT (N_st_diag >= N_st) + ASSERT (sze > 0) + ASSERT (Nint > 0) + ASSERT (Nint == N_int) + + ! Davidson iterations + ! =================== + + converged = .False. + + do k=N_st+1,N_st_diag + do i=1,sze + call random_number(r1) + call random_number(r2) + r1 = dsqrt(-2.d0*dlog(r1)) + r2 = dtwo_pi*r2 + u_in(i,k) = r1*dcos(r2) * u_in(i,k-N_st) + enddo + u_in(k,k) = u_in(k,k) + 10.d0 + enddo + do k=1,N_st_diag + call normalize(u_in(1,k),sze) + enddo + + do k=1,N_st_diag + do i=1,sze + U(i,k) = u_in(i,k) + enddo + enddo + + + do while (.not.converged) + itertot = itertot+1 + if (itertot == 8) then + exit + endif + + do iter=1,itermax-1 + + shift = N_st_diag*(iter-1) + shift2 = N_st_diag*iter + + if ((iter > 1).or.(itertot == 1)) then + ! Compute |W_k> = \sum_i |i> + ! ----------------------------------- + + if ((sze > 100000).and.distributed_davidson) then + call H_u_0_nstates_zmq (W(1,shift+1),U(1,shift+1),N_st_diag,sze) + else + call H_u_0_nstates_openmp(W(1,shift+1),U(1,shift+1),N_st_diag,sze) + endif + else + ! Already computed in update below + continue + endif + + if (dressing_state > 0) then + + if (N_st == 1) then + + l = dressed_column_idx(1) + double precision :: f + f = 1.0d0/psi_coef(l,1) + do istate=1,N_st_diag + do i=1,sze + W(i,shift+istate) += dressing_column_h(i,1) *f * U(l,shift+istate) + W(l,shift+istate) += dressing_column_h(i,1) *f * U(i,shift+istate) + enddo + + enddo + + else + + call dgemm('T','N', N_st, N_st_diag, sze, 1.d0, & + psi_coef, size(psi_coef,1), & + U(1,shift+1), size(U,1), 0.d0, s_tmp, size(s_tmp,1)) + + call dgemm('N','N', sze, N_st_diag, N_st, 1.0d0, & + dressing_column_h, size(dressing_column_h,1), s_tmp, size(s_tmp,1), & + 1.d0, W(1,shift+1), size(W,1)) + + + call dgemm('T','N', N_st, N_st_diag, sze, 1.d0, & + dressing_column_h, size(dressing_column_h,1), & + U(1,shift+1), size(U,1), 0.d0, s_tmp, size(s_tmp,1)) + + call dgemm('N','N', sze, N_st_diag, N_st, 1.0d0, & + psi_coef, size(psi_coef,1), s_tmp, size(s_tmp,1), & + 1.d0, W(1,shift+1), size(W,1)) + + endif + endif + + ! Compute h_kl = = + ! ------------------------------------------- + + call dgemm('T','N', shift2, shift2, sze, & + 1.d0, U, size(U,1), W, size(W,1), & + 0.d0, h, size(h,1)) + call dgemm('T','N', shift2, shift2, sze, & + 1.d0, U, size(U,1), U, size(U,1), & + 0.d0, s_tmp, size(s_tmp,1)) + + ! Diagonalize h + ! --------------- + + integer :: lwork, info + double precision, allocatable :: work(:) + + y = h + lwork = -1 + allocate(work(1)) + call dsygv(1,'V','U',shift2,y,size(y,1), & + s_tmp,size(s_tmp,1), lambda, work,lwork,info) + lwork = int(work(1)) + deallocate(work) + allocate(work(lwork)) + call dsygv(1,'V','U',shift2,y,size(y,1), & + s_tmp,size(s_tmp,1), lambda, work,lwork,info) + deallocate(work) + if (info /= 0) then + stop 'DSYGV Diagonalization failed' + endif + + ! Compute Energy for each eigenvector + ! ----------------------------------- + + call dgemm('N','N',shift2,shift2,shift2, & + 1.d0, h, size(h,1), y, size(y,1), & + 0.d0, s_tmp, size(s_tmp,1)) + + call dgemm('T','N',shift2,shift2,shift2, & + 1.d0, y, size(y,1), s_tmp, size(s_tmp,1), & + 0.d0, h, size(h,1)) + + do k=1,shift2 + lambda(k) = h(k,k) + enddo + + if (state_following) then + + overlap = -1.d0 + do k=1,shift2 + do i=1,shift2 + overlap(k,i) = dabs(y(k,i)) + enddo + enddo + do k=1,N_st + cmax = -1.d0 + do i=1,N_st + if (overlap(i,k) > cmax) then + cmax = overlap(i,k) + order(k) = i + endif + enddo + do i=1,N_st_diag + overlap(order(k),i) = -1.d0 + enddo + enddo + overlap = y + do k=1,N_st + l = order(k) + if (k /= l) then + y(1:shift2,k) = overlap(1:shift2,l) + endif + enddo + do k=1,N_st + overlap(k,1) = lambda(k) + enddo + + endif + + + ! Express eigenvectors of h in the determinant basis + ! -------------------------------------------------- + + call dgemm('N','N', sze, N_st_diag, shift2, & + 1.d0, U, size(U,1), y, size(y,1), 0.d0, U(1,shift2+1), size(U,1)) + call dgemm('N','N', sze, N_st_diag, shift2, & + 1.d0, W, size(W,1), y, size(y,1), 0.d0, W(1,shift2+1), size(W,1)) + + ! Compute residual vector and davidson step + ! ----------------------------------------- + + !$OMP PARALLEL DO DEFAULT(SHARED) PRIVATE(i,k) + do k=1,N_st_diag + do i=1,sze + U(i,shift2+k) = & + (lambda(k) * U(i,shift2+k) - W(i,shift2+k) ) & + /max(H_jj(i) - lambda (k),1.d-2) + enddo + + if (k <= N_st) then + residual_norm(k) = u_dot_u(U(1,shift2+k),sze) + to_print(1,k) = lambda(k) + nuclear_repulsion + to_print(2,k) = residual_norm(k) + endif + enddo + !$OMP END PARALLEL DO + + + if ((itertot>1).and.(iter == 1)) then + !don't print + continue + else + write(*,'(1X,I3,1X,100(1X,F16.10,1X,E11.3))') iter-1, to_print(1:2,1:N_st) + endif + + ! Check convergence + if (iter > 1) then + if (threshold_davidson_from_pt2) then + converged = dabs(maxval(residual_norm(1:N_st))) < threshold_davidson_pt2 + else + converged = dabs(maxval(residual_norm(1:N_st))) < threshold_davidson + endif + endif + + do k=1,N_st + if (residual_norm(k) > 1.d8) then + print *, 'Davidson failed' + stop -1 + endif + enddo + if (converged) then + exit + endif + + logical, external :: qp_stop + if (qp_stop()) then + converged = .True. + exit + endif + + + enddo + + ! Re-contract U and update W + ! -------------------------------- + + call dgemm('N','N', sze, N_st_diag, shift2, 1.d0, & + W, size(W,1), y, size(y,1), 0.d0, u_in, size(u_in,1)) + do k=1,N_st_diag + do i=1,sze + W(i,k) = u_in(i,k) + enddo + enddo + + call dgemm('N','N', sze, N_st_diag, shift2, 1.d0, & + U, size(U,1), y, size(y,1), 0.d0, u_in, size(u_in,1)) + + do k=1,N_st_diag + do i=1,sze + U(i,k) = u_in(i,k) + enddo + enddo + + enddo + + + call nullify_small_elements(sze,N_st_diag,U,size(U,1),threshold_davidson_pt2) + do k=1,N_st_diag + do i=1,sze + u_in(i,k) = U(i,k) + enddo + enddo + + do k=1,N_st_diag + energies(k) = lambda(k) + enddo + write_buffer = '======' + do i=1,N_st + write_buffer = trim(write_buffer)//' ================ ===========' + enddo + write(6,'(A)') trim(write_buffer) + write(6,'(A)') '' + call write_time(6) + + if (disk_based)then + ! Remove temp files + integer, external :: getUnitAndOpen + call munmap( (/int(sze,8),int(N_st_diag*itermax,8)/), 8, fd_w, ptr_w ) + fd_w = getUnitAndOpen(trim(ezfio_work_dir)//'davidson_w','r') + close(fd_w,status='delete') + else + deallocate(W) + endif + + deallocate ( & + residual_norm, & + U, overlap, & + h, y, s_tmp, & + lambda & + ) + FREE nthreads_davidson +end + + + + + + + diff --git a/src/davidson/diagonalization_hcsf_dressed.irp.f b/src/davidson/diagonalization_hcsf_dressed.irp.f new file mode 100644 index 00000000..2a83cc28 --- /dev/null +++ b/src/davidson/diagonalization_hcsf_dressed.irp.f @@ -0,0 +1,566 @@ +subroutine davidson_diag_h_csf(dets_in,u_in,dim_in,energies,sze,sze_csf,N_st,N_st_diag,Nint,dressing_state,converged) + 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 + ! + END_DOC + integer, intent(in) :: dim_in, sze, sze_csf, N_st, N_st_diag, Nint + integer(bit_kind), intent(in) :: dets_in(Nint,2,sze) + double precision, intent(inout) :: u_in(dim_in,N_st_diag) + double precision, intent(out) :: energies(N_st_diag) + integer, intent(in) :: dressing_state + logical, intent(out) :: converged + double precision, allocatable :: H_jj(:) + + double precision, external :: diag_H_mat_elem, diag_S_mat_elem + integer :: i,k + ASSERT (N_st > 0) + ASSERT (sze > 0) + ASSERT (Nint > 0) + ASSERT (Nint == N_int) + PROVIDE mo_two_e_integrals_in_map + allocate(H_jj(sze)) + + H_jj(1) = diag_h_mat_elem(dets_in(1,1,1),Nint) + !$OMP PARALLEL DEFAULT(NONE) & + !$OMP SHARED(sze,H_jj, dets_in,Nint) & + !$OMP PRIVATE(i) + !$OMP DO SCHEDULE(static) + do i=2,sze + H_jj(i) = diag_H_mat_elem(dets_in(1,1,i),Nint) + enddo + !$OMP END DO + !$OMP END PARALLEL + + if (dressing_state > 0) then + do k=1,N_st + do i=1,sze + H_jj(i) += u_in(i,k) * dressing_column_h(i,k) + enddo + enddo + endif + + call davidson_diag_csf_hjj(dets_in,u_in,H_jj,energies,dim_in,sze,sze_csf,N_st,N_st_diag,Nint,dressing_state,converged) + deallocate(H_jj) +end + + +subroutine davidson_diag_csf_hjj(dets_in,u_in,H_jj,energies,dim_in,sze,sze_csf,N_st,N_st_diag_in,Nint,dressing_state,converged) + use bitmasks + use mmap_module + 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 + ! + ! N_st_diag_in : Number of states in which H is diagonalized. Assumed > sze + ! + END_DOC + integer, intent(in) :: dim_in, sze, sze_csf, N_st, N_st_diag_in, Nint + integer(bit_kind), intent(in) :: dets_in(Nint,2,sze) + double precision, intent(in) :: H_jj(sze) + integer, intent(in) :: dressing_state + double precision, intent(inout) :: u_in(dim_in,N_st_diag_in) + double precision, intent(out) :: energies(N_st_diag_in) + + integer :: iter, N_st_diag + integer :: i,j,k,l,m + logical, intent(inout) :: converged + + double precision, external :: u_dot_v, u_dot_u + + integer :: k_pairs, kl + + integer :: iter2, itertot + double precision, allocatable :: y(:,:), h(:,:), lambda(:) + double precision, allocatable :: s_tmp(:,:) + double precision :: diag_h_mat_elem + double precision, allocatable :: residual_norm(:) + character*(16384) :: write_buffer + double precision :: to_print(2,N_st) + double precision :: cpu, wall + integer :: shift, shift2, itermax, istate + double precision :: r1, r2, alpha + logical :: state_ok(N_st_diag_in*davidson_sze_max) + integer :: nproc_target + integer :: order(N_st_diag_in) + double precision :: cmax + double precision, allocatable :: U(:,:), U_csf(:,:), overlap(:,:) + double precision, pointer :: W(:,:), W_csf(:,:) + logical :: disk_based + double precision :: energy_shift(N_st_diag_in*davidson_sze_max) + + include 'constants.include.F' + + N_st_diag = N_st_diag_in + !DIR$ ATTRIBUTES ALIGN : $IRP_ALIGN :: U, W, y, h, lambda + if (N_st_diag*3 > sze) then + print *, 'error in Davidson :' + print *, 'Increase n_det_max_full to ', N_st_diag*3 + stop -1 + endif + + itermax = max(2,min(davidson_sze_max, sze/N_st_diag))+1 + itertot = 0 + + if (state_following) then + allocate(overlap(N_st_diag*itermax, N_st_diag*itermax)) + else + allocate(overlap(1,1)) ! avoid 'if' for deallocate + endif + overlap = 0.d0 + + PROVIDE nuclear_repulsion expected_s2 psi_bilinear_matrix_order psi_bilinear_matrix_order_reverse threshold_davidson_pt2 threshold_davidson_from_pt2 + + call write_time(6) + write(6,'(A)') '' + write(6,'(A)') 'Davidson Diagonalization' + write(6,'(A)') '------------------------' + write(6,'(A)') '' + + ! Find max number of cores to fit in memory + ! ----------------------------------------- + + nproc_target = nproc + double precision :: rss + integer :: maxab + maxab = max(N_det_alpha_unique, N_det_beta_unique)+1 + + m=1 + disk_based = .False. + call resident_memory(rss) + do + r1 = 8.d0 * &! bytes + ( dble(sze)*(N_st_diag) &! U + + dble(sze_csf)*(N_st_diag*itermax) &! U_csf + + dble(sze)*(N_st_diag) &! W + + dble(sze_csf)*(N_st_diag*itermax) &! W_csf + + 3.0d0*(N_st_diag*itermax)**2 &! h,y,s_tmp + + 1.d0*(N_st_diag*itermax) &! lambda + + 1.d0*(N_st_diag) &! residual_norm + ! In H_u_0_nstates_zmq + + 2.d0*(N_st_diag*N_det) &! u_t, v_t, on collector + + 2.d0*(N_st_diag*N_det) &! u_t, v_t, on slave + + 0.5d0*maxab &! idx0 in H_u_0_nstates_openmp_work_* + + nproc_target * &! In OMP section + ( 1.d0*(N_int*maxab) &! buffer + + 3.5d0*(maxab) ) &! singles_a, singles_b, doubles, idx + ) / 1024.d0**3 + + if (nproc_target == 0) then + call check_mem(r1,irp_here) + nproc_target = 1 + exit + endif + + if (r1+rss < qp_max_mem) then + exit + endif + + if (itermax > 4) then + itermax = itermax - 1 + else if (m==1.and.disk_based_davidson) then + m=0 + disk_based = .True. + itermax = 6 + else + nproc_target = nproc_target - 1 + endif + + enddo + nthreads_davidson = nproc_target + TOUCH nthreads_davidson + call write_int(6,N_st,'Number of states') + call write_int(6,N_st_diag,'Number of states in diagonalization') + call write_int(6,sze,'Number of determinants') + call write_int(6,nproc_target,'Number of threads for diagonalization') + call write_double(6, r1, 'Memory(Gb)') + if (disk_based) then + print *, 'Using swap space to reduce RAM' + endif + + !--------------- + + write(6,'(A)') '' + write_buffer = '=====' + do i=1,N_st + write_buffer = trim(write_buffer)//' ================ ===========' + enddo + write(6,'(A)') write_buffer(1:6+41*N_st) + write_buffer = 'Iter' + do i=1,N_st + write_buffer = trim(write_buffer)//' Energy Residual ' + enddo + write(6,'(A)') write_buffer(1:6+41*N_st) + write_buffer = '=====' + do i=1,N_st + write_buffer = trim(write_buffer)//' ================ ===========' + enddo + write(6,'(A)') write_buffer(1:6+41*N_st) + + + if (disk_based) then + ! Create memory-mapped files for W and S + type(c_ptr) :: ptr_w, ptr_s + integer :: fd_s, fd_w + call mmap(trim(ezfio_work_dir)//'davidson_w', (/int(sze,8),int(N_st_diag*itermax,8)/),& + 8, fd_w, .False., ptr_w) + call c_f_pointer(ptr_w, W_csf, (/sze_csf,N_st_diag*itermax/)) + else + allocate(W(sze,N_st_diag),W_csf(sze_csf,N_st_diag*itermax)) + endif + + allocate( & + ! Large + U(sze,N_st_diag), & + U_csf(sze_csf,N_st_diag*itermax), & + + ! Small + h(N_st_diag*itermax,N_st_diag*itermax), & + y(N_st_diag*itermax,N_st_diag*itermax), & + s_tmp(N_st_diag*itermax,N_st_diag*itermax), & + residual_norm(N_st_diag), & + lambda(N_st_diag*itermax)) + + h = 0.d0 + U = 0.d0 + y = 0.d0 + s_tmp = 0.d0 + + + ASSERT (N_st > 0) + ASSERT (N_st_diag >= N_st) + ASSERT (sze > 0) + ASSERT (Nint > 0) + ASSERT (Nint == N_int) + + ! Davidson iterations + ! =================== + + converged = .False. + + do k=N_st+1,N_st_diag + do i=1,sze + call random_number(r1) + call random_number(r2) + r1 = dsqrt(-2.d0*dlog(r1)) + r2 = dtwo_pi*r2 + u_in(i,k) = r1*dcos(r2) * u_in(i,k-N_st) + enddo + u_in(k,k) = u_in(k,k) + 10.d0 + enddo + do k=1,N_st_diag + call normalize(u_in(1,k),sze) + enddo + + do k=1,N_st_diag + do i=1,sze + U(i,k) = u_in(i,k) + enddo + enddo + + ! Make random verctors eigenstates of S2 + call convertWFfromDETtoCSF(N_st_diag,U(1,1),U_csf(1,1)) + call convertWFfromCSFtoDET(N_st_diag,U_csf(1,1),U(1,1)) + + do while (.not.converged) + itertot = itertot+1 + if (itertot == 8) then + exit + endif + + do iter=1,itermax-1 + + shift = N_st_diag*(iter-1) + shift2 = N_st_diag*iter + + if ((iter > 1).or.(itertot == 1)) then + ! Compute |W_k> = \sum_i |i> + ! ----------------------------------- + + call convertWFfromCSFtoDET(N_st_diag,U_csf(1,shift+1),U) + if ((sze > 100000).and.distributed_davidson) then + call H_u_0_nstates_zmq (W,U,N_st_diag,sze) + else + call H_u_0_nstates_openmp(W,U,N_st_diag,sze) + endif + else + ! Already computed in update below + continue + endif + + if (dressing_state > 0) then + + if (N_st == 1) then + + l = dressed_column_idx(1) + double precision :: f + f = 1.0d0/psi_coef(l,1) + do istate=1,N_st_diag + do i=1,sze + W(i,istate) += dressing_column_h(i,1) *f * U(l,istate) + W(l,istate) += dressing_column_h(i,1) *f * U(i,istate) + enddo + + enddo + + else + + call dgemm('T','N', N_st, N_st_diag, sze, 1.d0, & + psi_coef, size(psi_coef,1), & + U(1,1), size(U,1), 0.d0, s_tmp, size(s_tmp,1)) + + call dgemm('N','N', sze, N_st_diag, N_st, 1.0d0, & + dressing_column_h, size(dressing_column_h,1), s_tmp, size(s_tmp,1), & + 1.d0, W(1,1), size(W,1)) + + + call dgemm('T','N', N_st, N_st_diag, sze, 1.d0, & + dressing_column_h, size(dressing_column_h,1), & + U(1,1), size(U,1), 0.d0, s_tmp, size(s_tmp,1)) + + call dgemm('N','N', sze, N_st_diag, N_st, 1.0d0, & + psi_coef, size(psi_coef,1), s_tmp, size(s_tmp,1), & + 1.d0, W(1,1), size(W,1)) + + endif + endif + + call convertWFfromDETtoCSF(N_st_diag,W,W_csf(1,shift+1)) + + ! Compute h_kl = = + ! ------------------------------------------- + + call dgemm('T','N', shift2, shift2, sze_csf, & + 1.d0, U_csf, size(U_csf,1), W_csf, size(W_csf,1), & + 0.d0, h, size(h,1)) + call dgemm('T','N', shift2, shift2, sze_csf, & + 1.d0, U_csf, size(U_csf,1), U_csf, size(U_csf,1), & + 0.d0, s_tmp, size(s_tmp,1)) + + ! Diagonalize h + ! --------------- + + integer :: lwork, info + double precision, allocatable :: work(:) + + y = h + lwork = -1 + allocate(work(1)) + call dsygv(1,'V','U',shift2,y,size(y,1), & + s_tmp,size(s_tmp,1), lambda, work,lwork,info) + lwork = int(work(1)) + deallocate(work) + allocate(work(lwork)) + call dsygv(1,'V','U',shift2,y,size(y,1), & + s_tmp,size(s_tmp,1), lambda, work,lwork,info) + deallocate(work) + if (info /= 0) then + stop 'DSYGV Diagonalization failed' + endif + + ! Compute Energy for each eigenvector + ! ----------------------------------- + + call dgemm('N','N',shift2,shift2,shift2, & + 1.d0, h, size(h,1), y, size(y,1), & + 0.d0, s_tmp, size(s_tmp,1)) + + call dgemm('T','N',shift2,shift2,shift2, & + 1.d0, y, size(y,1), s_tmp, size(s_tmp,1), & + 0.d0, h, size(h,1)) + + do k=1,shift2 + lambda(k) = h(k,k) + enddo + + if (state_following) then + + overlap = -1.d0 + do i=1,shift2 + do k=1,shift2 + overlap(k,i) = dabs(y(k,i)) + enddo + enddo + do k=1,N_st + cmax = -1.d0 + do i=1,N_st + if (overlap(i,k) > cmax) then + cmax = overlap(i,k) + order(k) = i + endif + enddo + do i=1,N_st_diag + overlap(order(k),i) = -1.d0 + enddo + enddo + overlap = y + do k=1,N_st + l = order(k) + if (k /= l) then + y(1:shift2,k) = overlap(1:shift2,l) + endif + enddo + do k=1,N_st + overlap(k,1) = lambda(k) + enddo + + endif + + + ! Express eigenvectors of h in the csf basis + ! ------------------------------------------ + + call dgemm('N','N', sze_csf, N_st_diag, shift2, & + 1.d0, U_csf, size(U_csf,1), y, size(y,1), 0.d0, U_csf(1,shift2+1), size(U_csf,1)) + call convertWFfromCSFtoDET(N_st_diag,U_csf(1,shift2+1),U) + + call dgemm('N','N', sze_csf, N_st_diag, shift2, & + 1.d0, W_csf, size(W_csf,1), y, size(y,1), 0.d0, W_csf(1,shift2+1), size(W_csf,1)) + call convertWFfromCSFtoDET(N_st_diag,W_csf(1,shift2+1),W) + + ! Compute residual vector and davidson step + ! ----------------------------------------- + + !$OMP PARALLEL DO DEFAULT(SHARED) PRIVATE(i,k) + do k=1,N_st_diag + do i=1,sze + U(i,k) = (lambda(k) * U(i,k) - W(i,k) ) & + /max(H_jj(i) - lambda (k),1.d-2) + enddo + enddo + !$OMP END PARALLEL DO + + do k=1,N_st + residual_norm(k) = u_dot_u(U(1,k),sze) + to_print(1,k) = lambda(k) + nuclear_repulsion + to_print(2,k) = residual_norm(k) + enddo + call convertWFfromDETtoCSF(N_st_diag,U,U_csf(1,shift2+1)) + + if ((itertot>1).and.(iter == 1)) then + !don't print + continue + else + write(*,'(1X,I3,1X,100(1X,F16.10,1X,E11.3))') iter-1, to_print(1:2,1:N_st) + endif + + ! Check convergence + if (iter > 1) then + if (threshold_davidson_from_pt2) then + converged = dabs(maxval(residual_norm(1:N_st))) < threshold_davidson_pt2 + else + converged = dabs(maxval(residual_norm(1:N_st))) < threshold_davidson + endif + endif + + do k=1,N_st + if (residual_norm(k) > 1.d8) then + print *, 'Davidson failed' + stop -1 + endif + enddo + if (converged) then + exit + endif + + logical, external :: qp_stop + if (qp_stop()) then + converged = .True. + exit + endif + + + enddo + + ! Re-contract U and update W + ! -------------------------------- + + call dgemm('N','N', sze_csf, N_st_diag, shift2, 1.d0, & + W_csf, size(W_csf,1), y, size(y,1), 0.d0, u_in, size(u_in,1)) + do k=1,N_st_diag + do i=1,sze_csf + W_csf(i,k) = u_in(i,k) + enddo + enddo + call convertWFfromCSFtoDET(N_st_diag,W_csf,W) + + call dgemm('N','N', sze_csf, N_st_diag, shift2, 1.d0, & + U_csf, size(U_csf,1), y, size(y,1), 0.d0, u_in, size(u_in,1)) + do k=1,N_st_diag + do i=1,sze_csf + U_csf(i,k) = u_in(i,k) + enddo + enddo + call convertWFfromCSFtoDET(N_st_diag,U_csf,U) + + enddo + + + call nullify_small_elements(sze,N_st_diag,U,size(U,1),threshold_davidson_pt2) + do k=1,N_st_diag + do i=1,sze + u_in(i,k) = U(i,k) + enddo + enddo + + do k=1,N_st_diag + energies(k) = lambda(k) + enddo + write_buffer = '======' + do i=1,N_st + write_buffer = trim(write_buffer)//' ================ ===========' + enddo + write(6,'(A)') trim(write_buffer) + write(6,'(A)') '' + call write_time(6) + + if (disk_based)then + ! Remove temp files + integer, external :: getUnitAndOpen + call munmap( (/int(sze,8),int(N_st_diag*itermax,8)/), 8, fd_w, ptr_w ) + fd_w = getUnitAndOpen(trim(ezfio_work_dir)//'davidson_w','r') + close(fd_w,status='delete') + else + deallocate(W, W_csf) + endif + + deallocate ( & + residual_norm, & + U, U_csf, overlap, & + h, y, s_tmp, & + lambda & + ) + FREE nthreads_davidson +end + + + + + + + diff --git a/src/davidson/diagonalization_hs2_dressed.irp.f b/src/davidson/diagonalization_hs2_dressed.irp.f index bd339367..1a27a75e 100644 --- a/src/davidson/diagonalization_hs2_dressed.irp.f +++ b/src/davidson/diagonalization_hs2_dressed.irp.f @@ -318,14 +318,14 @@ subroutine davidson_diag_hjj_sjj(dets_in,u_in,H_jj,s2_out,energies,dim_in,sze,N_ converged = .False. do k=N_st+1,N_st_diag - u_in(k,k) = 10.d0 do i=1,sze - call random_number(r1) - call random_number(r2) - r1 = dsqrt(-2.d0*dlog(r1)) - r2 = dtwo_pi*r2 - u_in(i,k) = r1*dcos(r2) + call random_number(r1) + call random_number(r2) + r1 = dsqrt(-2.d0*dlog(r1)) + r2 = dtwo_pi*r2 + u_in(i,k) = r1*dcos(r2) * u_in(i,k-N_st) enddo + u_in(k,k) = u_in(k,k) + 10.d0 enddo do k=1,N_st_diag call normalize(u_in(1,k),sze) @@ -353,14 +353,6 @@ subroutine davidson_diag_hjj_sjj(dets_in,u_in,H_jj,s2_out,energies,dim_in,sze,N_ ! Compute |W_k> = \sum_i |i> ! ----------------------------------- - if (disk_based) then - call ortho_qr_unblocked(U,size(U,1),sze,shift2) - call ortho_qr_unblocked(U,size(U,1),sze,shift2) - else - call ortho_qr(U,size(U,1),sze,shift2) - call ortho_qr(U,size(U,1),sze,shift2) - endif - if ((sze > 100000).and.distributed_davidson) then call H_S2_u_0_nstates_zmq (W(1,shift+1),S_d,U(1,shift+1),N_st_diag,sze) else @@ -443,6 +435,9 @@ subroutine davidson_diag_hjj_sjj(dets_in,u_in,H_jj,s2_out,energies,dim_in,sze,N_ call dgemm('T','N', shift2, shift2, sze, & 1.d0, U, size(U,1), W, size(W,1), & 0.d0, h, size(h_p,1)) + call dgemm('T','N', shift2, shift2, sze, & + 1.d0, U, size(U,1), U, size(U,1), & + 0.d0, s_tmp, size(s_tmp,1)) ! Penalty method ! -------------- @@ -467,7 +462,23 @@ subroutine davidson_diag_hjj_sjj(dets_in,u_in,H_jj,s2_out,energies,dim_in,sze,N_ ! Diagonalize h_p ! --------------- - call lapack_diag(lambda,y,h_p,size(h_p,1),shift2) + integer :: lwork, info + double precision, allocatable :: work(:) + + y = h + lwork = -1 + allocate(work(1)) + call dsygv(1,'V','U',shift2,y,size(y,1), & + s_tmp,size(s_tmp,1), lambda, work,lwork,info) + lwork = int(work(1)) + deallocate(work) + allocate(work(lwork)) + call dsygv(1,'V','U',shift2,y,size(y,1), & + s_tmp,size(s_tmp,1), lambda, work,lwork,info) + deallocate(work) + if (info /= 0) then + stop 'DSYGV Diagonalization failed' + endif ! Compute Energy for each eigenvector ! ----------------------------------- @@ -616,7 +627,7 @@ subroutine davidson_diag_hjj_sjj(dets_in,u_in,H_jj,s2_out,energies,dim_in,sze,N_ endif do k=1,N_st - if (residual_norm(k) > 1.e8) then + if (residual_norm(k) > 1.d8) then print *, 'Davidson failed' stop -1 endif @@ -655,38 +666,23 @@ subroutine davidson_diag_hjj_sjj(dets_in,u_in,H_jj,s2_out,energies,dim_in,sze,N_ call dgemm('N','N', sze, N_st_diag, shift2, 1.d0, & U, size(U,1), y, size(y,1), 0.d0, u_in, size(u_in,1)) + do k=1,N_st_diag do i=1,sze U(i,k) = u_in(i,k) enddo enddo - if (disk_based) then - call ortho_qr_unblocked(U,size(U,1),sze,N_st_diag) - call ortho_qr_unblocked(U,size(U,1),sze,N_st_diag) - else - call ortho_qr(U,size(U,1),sze,N_st_diag) - call ortho_qr(U,size(U,1),sze,N_st_diag) - endif - do j=1,N_st_diag - k=1 - do while ((k N_states_diag_save) then N_states_diag = N_states_diag_save @@ -110,6 +144,7 @@ END_PROVIDER H_prime(j,j) = H_prime(j,j) - alpha*expected_s2 enddo call lapack_diag(eigenvalues,eigenvectors,H_prime,size(H_prime,1),N_det) + call nullify_small_elements(N_det,N_det,eigenvectors,size(eigenvectors,1),1.d-12) CI_electronic_energy(:) = 0.d0 i_state = 0 allocate (s2_eigvalues(N_det)) diff --git a/src/davidson/u0_h_u0.irp.f b/src/davidson/u0_h_u0.irp.f index 302b8423..3f5113db 100644 --- a/src/davidson/u0_h_u0.irp.f +++ b/src/davidson/u0_h_u0.irp.f @@ -1,72 +1,43 @@ - BEGIN_PROVIDER [ double precision, psi_energy, (N_states) ] -&BEGIN_PROVIDER [ double precision, psi_s2, (N_states) ] - implicit none - BEGIN_DOC -! psi_energy(i) = $\langle \Psi_i | H | \Psi_i \rangle$ -! -! psi_s2(i) = $\langle \Psi_i | S^2 | \Psi_i \rangle$ - END_DOC - call u_0_H_u_0(psi_energy,psi_s2,psi_coef,N_det,psi_det,N_int,N_states,psi_det_size) - integer :: i - do i=N_det+1,N_states - psi_energy(i) = 0.d0 - psi_s2(i) = 0.d0 - enddo -END_PROVIDER - -BEGIN_PROVIDER [ double precision, psi_energy_with_nucl_rep, (N_states) ] - implicit none - BEGIN_DOC - ! Energy of the wave function with the nuclear repulsion energy. - END_DOC - psi_energy_with_nucl_rep(1:N_states) = psi_energy(1:N_states) + nuclear_repulsion -END_PROVIDER - - -subroutine u_0_H_u_0(e_0,s_0,u_0,n,keys_tmp,Nint,N_st,sze) +subroutine u_0_H_u_0(e_0,u_0,n,keys_tmp,Nint,N_st,sze) use bitmasks implicit none BEGIN_DOC ! Computes $E_0 = \frac{\langle u_0 | H | u_0 \rangle}{\langle u_0 | u_0 \rangle}$ ! - ! and $S_0 = \frac{\langle u_0 | S^2 | u_0 \rangle}{\langle u_0 | u_0 \rangle}$ - ! ! n : number of determinants ! END_DOC integer, intent(in) :: n,Nint, N_st, sze - double precision, intent(out) :: e_0(N_st),s_0(N_st) + double precision, intent(out) :: e_0(N_st) double precision, intent(inout) :: u_0(sze,N_st) integer(bit_kind),intent(in) :: keys_tmp(Nint,2,n) - double precision, allocatable :: v_0(:,:), s_vec(:,:), u_1(:,:) + double precision, allocatable :: v_0(:,:), u_1(:,:) double precision :: u_dot_u,u_dot_v,diag_H_mat_elem integer :: i,j, istate if ((n > 100000).and.distributed_davidson) then - allocate (v_0(n,N_states_diag),s_vec(n,N_states_diag), u_1(n,N_states_diag)) + allocate (v_0(n,N_states_diag), u_1(n,N_states_diag)) u_1(:,:) = 0.d0 u_1(1:n,1:N_st) = u_0(1:n,1:N_st) - call H_S2_u_0_nstates_zmq(v_0,s_vec,u_1,N_states_diag,n) + call H_u_0_nstates_zmq(v_0,u_1,N_states_diag,n) else if (n < n_det_max_full) then - allocate (v_0(n,N_st),s_vec(n,N_st), u_1(n,N_st)) + allocate (v_0(n,N_st), u_1(n,N_st)) v_0(:,:) = 0.d0 u_1(:,:) = 0.d0 - s_vec(:,:) = 0.d0 u_1(1:n,1:N_st) = u_0(1:n,1:N_st) do istate = 1,N_st do j=1,n do i=1,n v_0(i,istate) = v_0(i,istate) + h_matrix_all_dets(i,j) * u_0(j,istate) - s_vec(i,istate) = s_vec(i,istate) + S2_matrix_all_dets(i,j) * u_0(j,istate) enddo enddo enddo else - allocate (v_0(n,N_st),s_vec(n,N_st),u_1(n,N_st)) + allocate (v_0(n,N_st),u_1(n,N_st)) u_1(:,:) = 0.d0 u_1(1:n,1:N_st) = u_0(1:n,1:N_st) - call H_S2_u_0_nstates_openmp(v_0,s_vec,u_1,N_st,n) + call H_u_0_nstates_openmp(v_0,u_1,N_st,n) endif u_0(1:n,1:N_st) = u_1(1:n,1:N_st) deallocate(u_1) @@ -76,42 +47,39 @@ subroutine u_0_H_u_0(e_0,s_0,u_0,n,keys_tmp,Nint,N_st,sze) norm = u_dot_u(u_0(1,i),n) if (norm /= 0.d0) then e_0(i) = u_dot_v(v_0(1,i),u_0(1,i),n) - s_0(i) = u_dot_v(s_vec(1,i),u_0(1,i),n) else e_0(i) = 0.d0 - s_0(i) = 0.d0 endif enddo !$OMP END PARALLEL DO - deallocate (s_vec, v_0) + deallocate (v_0) end -subroutine H_S2_u_0_nstates_openmp(v_0,s_0,u_0,N_st,sze) +subroutine H_u_0_nstates_openmp(v_0,u_0,N_st,sze) use bitmasks implicit none BEGIN_DOC - ! Computes $v_0 = H | u_0\rangle$ and $s_0 = S^2 | u_0\rangle$. + ! Computes $v_0 = H | u_0\rangle$. ! ! Assumes that the determinants are in psi_det ! ! istart, iend, ishift, istep are used in ZMQ parallelization. END_DOC integer, intent(in) :: N_st,sze - double precision, intent(inout) :: v_0(sze,N_st), s_0(sze,N_st), u_0(sze,N_st) + double precision, intent(inout) :: v_0(sze,N_st), u_0(sze,N_st) integer :: k - double precision, allocatable :: u_t(:,:), v_t(:,:), s_t(:,:) + double precision, allocatable :: u_t(:,:), v_t(:,:) !DIR$ ATTRIBUTES ALIGN : $IRP_ALIGN :: u_t - allocate(u_t(N_st,N_det),v_t(N_st,N_det),s_t(N_st,N_det)) + allocate(u_t(N_st,N_det),v_t(N_st,N_det)) do k=1,N_st call dset_order(u_0(1,k),psi_bilinear_matrix_order,N_det) enddo v_t = 0.d0 - s_t = 0.d0 call dtranspose( & u_0, & size(u_0, 1), & @@ -119,7 +87,7 @@ subroutine H_S2_u_0_nstates_openmp(v_0,s_0,u_0,N_st,sze) size(u_t, 1), & N_det, N_st) - call H_S2_u_0_nstates_openmp_work(v_t,s_t,u_t,N_st,sze,1,N_det,0,1) + call H_u_0_nstates_openmp_work(v_t,u_t,N_st,sze,1,N_det,0,1) deallocate(u_t) call dtranspose( & @@ -128,66 +96,59 @@ subroutine H_S2_u_0_nstates_openmp(v_0,s_0,u_0,N_st,sze) v_0, & size(v_0, 1), & N_st, N_det) - call dtranspose( & - s_t, & - size(s_t, 1), & - s_0, & - size(s_0, 1), & - N_st, N_det) - deallocate(v_t,s_t) + deallocate(v_t) do k=1,N_st call dset_order(v_0(1,k),psi_bilinear_matrix_order_reverse,N_det) - call dset_order(s_0(1,k),psi_bilinear_matrix_order_reverse,N_det) call dset_order(u_0(1,k),psi_bilinear_matrix_order_reverse,N_det) enddo end -subroutine H_S2_u_0_nstates_openmp_work(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep) +subroutine H_u_0_nstates_openmp_work(v_t,u_t,N_st,sze,istart,iend,ishift,istep) use bitmasks implicit none BEGIN_DOC - ! Computes $v_t = H | u_t\rangle$ and $s_t = S^2 | u_t\rangle$ + ! Computes $v_t = H | u_t\rangle$ ! ! Default should be 1,N_det,0,1 END_DOC integer, intent(in) :: N_st,sze,istart,iend,ishift,istep double precision, intent(in) :: u_t(N_st,N_det) - double precision, intent(out) :: v_t(N_st,sze), s_t(N_st,sze) + double precision, intent(out) :: v_t(N_st,sze) PROVIDE ref_bitmask_energy N_int select case (N_int) case (1) - call H_S2_u_0_nstates_openmp_work_1(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep) + call H_u_0_nstates_openmp_work_1(v_t,u_t,N_st,sze,istart,iend,ishift,istep) case (2) - call H_S2_u_0_nstates_openmp_work_2(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep) + call H_u_0_nstates_openmp_work_2(v_t,u_t,N_st,sze,istart,iend,ishift,istep) case (3) - call H_S2_u_0_nstates_openmp_work_3(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep) + call H_u_0_nstates_openmp_work_3(v_t,u_t,N_st,sze,istart,iend,ishift,istep) case (4) - call H_S2_u_0_nstates_openmp_work_4(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep) + call H_u_0_nstates_openmp_work_4(v_t,u_t,N_st,sze,istart,iend,ishift,istep) case default - call H_S2_u_0_nstates_openmp_work_N_int(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep) + call H_u_0_nstates_openmp_work_N_int(v_t,u_t,N_st,sze,istart,iend,ishift,istep) end select end BEGIN_TEMPLATE -subroutine H_S2_u_0_nstates_openmp_work_$N_int(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep) +subroutine H_u_0_nstates_openmp_work_$N_int(v_t,u_t,N_st,sze,istart,iend,ishift,istep) use bitmasks implicit none BEGIN_DOC - ! Computes $v_t = H | u_t \\rangle$ and $s_t = S^2 | u_t\\rangle$ + ! Computes $v_t = H | u_t \\rangle$ ! ! Default should be 1,N_det,0,1 END_DOC integer, intent(in) :: N_st,sze,istart,iend,ishift,istep double precision, intent(in) :: u_t(N_st,N_det) - double precision, intent(out) :: v_t(N_st,sze), s_t(N_st,sze) + double precision, intent(out) :: v_t(N_st,sze) - double precision :: hij, sij + double precision :: hij integer :: i,j,k,l,kk integer :: k_a, k_b, l_a, l_b, m_a, m_b integer :: istate @@ -211,6 +172,7 @@ subroutine H_S2_u_0_nstates_openmp_work_$N_int(v_t,s_t,u_t,N_st,sze,istart,iend, double precision :: rss, mem, ratio double precision, allocatable :: utl(:,:) integer, parameter :: block_size=128 + logical :: u_is_sparse ! call resident_memory(rss) ! mem = dble(singles_beta_csc_size) / 1024.d0**3 @@ -222,6 +184,7 @@ subroutine H_S2_u_0_nstates_openmp_work_$N_int(v_t,s_t,u_t,N_st,sze,istart,iend, ! endif compute_singles=.True. + maxab = max(N_det_alpha_unique, N_det_beta_unique)+1 allocate(idx0(maxab)) @@ -244,14 +207,14 @@ compute_singles=.True. !$OMP psi_bilinear_matrix_order_transp_reverse, & !$OMP psi_bilinear_matrix_columns_loc, & !$OMP psi_bilinear_matrix_transp_rows_loc, & - !$OMP istart, iend, istep, irp_here, v_t, s_t, & + !$OMP istart, iend, istep, irp_here, v_t, & !$OMP ishift, idx0, u_t, maxab, compute_singles, & !$OMP singles_alpha_csc,singles_alpha_csc_idx, & !$OMP singles_beta_csc,singles_beta_csc_idx) & !$OMP PRIVATE(krow, kcol, tmp_det, spindet, k_a, k_b, i, & - !$OMP lcol, lrow, l_a, l_b, utl, kk, & - !$OMP buffer, doubles, n_doubles, & - !$OMP tmp_det2, hij, sij, idx, l, kcol_prev, & + !$OMP lcol, lrow, l_a, l_b, utl, kk, u_is_sparse, & + !$OMP buffer, doubles, n_doubles, umax, & + !$OMP tmp_det2, hij, idx, l, kcol_prev, & !$OMP singles_a, n_singles_a, singles_b, ratio, & !$OMP n_singles_b, k8, last_found,left,right,right_max) @@ -266,6 +229,22 @@ compute_singles=.True. kcol_prev=-1 + ! Check if u has multiple zeros + kk=1 ! Avoid division by zero + !$OMP DO + do k=1,N_det + umax = 0.d0 + do l=1,N_st + umax = max(umax, dabs(u_t(l,k))) + enddo + if (umax < 1.d-20) then + !$OMP ATOMIC + kk = kk+1 + endif + enddo + !$OMP END DO + u_is_sparse = N_det / kk < 20 ! 5% + ASSERT (iend <= N_det) ASSERT (istart > 0) ASSERT (istep > 0) @@ -399,18 +378,33 @@ compute_singles=.True. ! Loop over alpha singles ! ----------------------- + double precision :: umax + !DIR$ LOOP COUNT avg(1000) do k = 1,n_singles_a,block_size + umax = 0.d0 ! Prefetch u_t(:,l_a) - do kk=0,block_size-1 - if (k+kk > n_singles_a) exit - l_a = singles_a(k+kk) - ASSERT (l_a <= N_det) + if (u_is_sparse) then + do kk=0,block_size-1 + if (k+kk > n_singles_a) exit + l_a = singles_a(k+kk) + ASSERT (l_a <= N_det) - do l=1,N_st - utl(l,kk+1) = u_t(l,l_a) + do l=1,N_st + utl(l,kk+1) = u_t(l,l_a) + umax = max(umax, dabs(utl(l,kk+1))) + enddo enddo - enddo + else + do kk=0,block_size-1 + if (k+kk > n_singles_a) exit + l_a = singles_a(k+kk) + ASSERT (l_a <= N_det) + utl(:,kk+1) = u_t(:,l_a) + enddo + umax = 1.d0 + endif + if (umax < 1.d-20) cycle do kk=0,block_size-1 if (k+kk > n_singles_a) exit @@ -420,11 +414,9 @@ compute_singles=.True. tmp_det2(1:$N_int,1) = psi_det_alpha_unique(1:$N_int, lrow) call i_H_j_double_alpha_beta(tmp_det,tmp_det2,$N_int,hij) - call get_s2(tmp_det,tmp_det2,$N_int,sij) !DIR$ LOOP COUNT AVG(4) do l=1,N_st v_t(l,k_a) = v_t(l,k_a) + hij * utl(l,kk+1) - s_t(l,k_a) = s_t(l,k_a) + sij * utl(l,kk+1) enddo enddo enddo @@ -490,16 +482,29 @@ compute_singles=.True. tmp_det2(1:$N_int,2) = psi_det_beta_unique (1:$N_int, kcol) !DIR$ LOOP COUNT avg(1000) do i=1,n_singles_a,block_size + umax = 0.d0 ! Prefetch u_t(:,l_a) - do kk=0,block_size-1 - if (i+kk > n_singles_a) exit - l_a = singles_a(i+kk) - ASSERT (l_a <= N_det) + if (u_is_sparse) then + do kk=0,block_size-1 + if (i+kk > n_singles_a) exit + l_a = singles_a(i+kk) + ASSERT (l_a <= N_det) - do l=1,N_st - utl(l,kk+1) = u_t(l,l_a) + do l=1,N_st + utl(l,kk+1) = u_t(l,l_a) + umax = max(umax, dabs(utl(l,kk+1))) + enddo enddo - enddo + else + do kk=0,block_size-1 + if (i+kk > n_singles_a) exit + l_a = singles_a(i+kk) + ASSERT (l_a <= N_det) + utl(:,kk+1) = u_t(:,l_a) + enddo + umax = 1.d0 + endif + if (umax < 1.d-20) cycle do kk=0,block_size-1 if (i+kk > n_singles_a) exit @@ -513,7 +518,6 @@ compute_singles=.True. !DIR$ LOOP COUNT AVG(4) do l=1,N_st v_t(l,k_a) = v_t(l,k_a) + hij * utl(l,kk+1) - ! single => sij = 0 enddo enddo enddo @@ -524,16 +528,29 @@ compute_singles=.True. !DIR$ LOOP COUNT avg(50000) do i=1,n_doubles,block_size + umax = 0.d0 ! Prefetch u_t(:,l_a) - do kk=0,block_size-1 - if (i+kk > n_doubles) exit - l_a = doubles(i+kk) - ASSERT (l_a <= N_det) + if (u_is_sparse) then + do kk=0,block_size-1 + if (i+kk > n_doubles) exit + l_a = doubles(i+kk) + ASSERT (l_a <= N_det) - do l=1,N_st - utl(l,kk+1) = u_t(l,l_a) + do l=1,N_st + utl(l,kk+1) = u_t(l,l_a) + umax = max(umax, dabs(utl(l,kk+1))) + enddo enddo - enddo + else + do kk=0,block_size-1 + if (i+kk > n_doubles) exit + l_a = doubles(i+kk) + ASSERT (l_a <= N_det) + utl(:,kk+1) = u_t(:,l_a) + enddo + umax = 1.d0 + endif + if (umax < 1.d-20) cycle do kk=0,block_size-1 if (i+kk > n_doubles) exit @@ -545,7 +562,6 @@ compute_singles=.True. !DIR$ LOOP COUNT AVG(4) do l=1,N_st v_t(l,k_a) = v_t(l,k_a) + hij * utl(l,kk+1) - ! same spin => sij = 0 enddo enddo enddo @@ -599,18 +615,32 @@ compute_singles=.True. tmp_det2(1:$N_int,1) = psi_det_alpha_unique(1:$N_int, krow) !DIR$ LOOP COUNT avg(1000) do i=1,n_singles_b,block_size - do kk=0,block_size-1 - if (i+kk > n_singles_b) exit - l_b = singles_b(i+kk) - ASSERT (l_b <= N_det) + umax = 0.d0 + if (u_is_sparse) then + do kk=0,block_size-1 + if (i+kk > n_singles_b) exit + l_b = singles_b(i+kk) + l_a = psi_bilinear_matrix_transp_order(l_b) + ASSERT (l_b <= N_det) + ASSERT (l_a <= N_det) - l_a = psi_bilinear_matrix_transp_order(l_b) - ASSERT (l_a <= N_det) - - do l=1,N_st - utl(l,kk+1) = u_t(l,l_a) + do l=1,N_st + utl(l,kk+1) = u_t(l,l_a) + umax = max(umax, dabs(utl(l,kk+1))) + enddo enddo - enddo + else + do kk=0,block_size-1 + if (i+kk > n_singles_b) exit + l_b = singles_b(i+kk) + l_a = psi_bilinear_matrix_transp_order(l_b) + ASSERT (l_b <= N_det) + ASSERT (l_a <= N_det) + utl(:,kk+1) = u_t(:,l_a) + enddo + umax = 1.d0 + endif + if (umax < 1.d-20) cycle do kk=0,block_size-1 if (i+kk > n_singles_b) exit @@ -624,7 +654,6 @@ compute_singles=.True. !DIR$ LOOP COUNT AVG(4) do l=1,N_st v_t(l,k_a) = v_t(l,k_a) + hij * utl(l,kk+1) - ! single => sij = 0 enddo enddo enddo @@ -634,17 +663,31 @@ compute_singles=.True. !DIR$ LOOP COUNT avg(50000) do i=1,n_doubles,block_size - do kk=0,block_size-1 - if (i+kk > n_doubles) exit - l_b = doubles(i+kk) - ASSERT (l_b <= N_det) - l_a = psi_bilinear_matrix_transp_order(l_b) - ASSERT (l_a <= N_det) - - do l=1,N_st - utl(l,kk+1) = u_t(l,l_a) + umax = 0.d0 + if (u_is_sparse) then + do kk=0,block_size-1 + if (i+kk > n_doubles) exit + l_b = doubles(i+kk) + l_a = psi_bilinear_matrix_transp_order(l_b) + ASSERT (l_b <= N_det) + ASSERT (l_a <= N_det) + do l=1,N_st + utl(l,kk+1) = u_t(l,l_a) + umax = max(umax, dabs(utl(l,kk+1))) + enddo enddo - enddo + else + do kk=0,block_size-1 + if (i+kk > n_doubles) exit + l_b = doubles(i+kk) + l_a = psi_bilinear_matrix_transp_order(l_b) + ASSERT (l_b <= N_det) + ASSERT (l_a <= N_det) + utl(:,kk+1) = u_t(:,l_a) + enddo + umax = 1.d0 + endif + if (umax < 1.d-20) cycle do kk=0,block_size-1 if (i+kk > n_doubles) exit @@ -658,7 +701,6 @@ compute_singles=.True. !DIR$ LOOP COUNT AVG(4) do l=1,N_st v_t(l,k_a) = v_t(l,k_a) + hij * utl(l,kk+1) - ! same spin => sij = 0 enddo enddo enddo @@ -671,6 +713,16 @@ compute_singles=.True. ! Initial determinant is at k_a in alpha-major representation ! ----------------------------------------------------------------------- + if (u_is_sparse) then + umax = 0.d0 + do l=1,N_st + umax = max(umax, dabs(u_t(l,k_a))) + enddo + else + umax = 1.d0 + endif + if (umax < 1.d-20) cycle + krow = psi_bilinear_matrix_rows(k_a) ASSERT (krow <= N_det_alpha_unique) @@ -680,14 +732,12 @@ compute_singles=.True. tmp_det(1:$N_int,1) = psi_det_alpha_unique(1:$N_int, krow) tmp_det(1:$N_int,2) = psi_det_beta_unique (1:$N_int, kcol) - double precision, external :: diag_H_mat_elem, diag_S_mat_elem + double precision, external :: diag_H_mat_elem hij = diag_H_mat_elem(tmp_det,$N_int) - sij = diag_S_mat_elem(tmp_det,$N_int) !DIR$ LOOP COUNT AVG(4) do l=1,N_st v_t(l,k_a) = v_t(l,k_a) + hij * u_t(l,k_a) - s_t(l,k_a) = s_t(l,k_a) + sij * u_t(l,k_a) enddo end do diff --git a/src/davidson/u0_hs2_u0.irp.f b/src/davidson/u0_hs2_u0.irp.f new file mode 100644 index 00000000..96c266c2 --- /dev/null +++ b/src/davidson/u0_hs2_u0.irp.f @@ -0,0 +1,807 @@ + BEGIN_PROVIDER [ double precision, psi_energy, (N_states) ] +&BEGIN_PROVIDER [ double precision, psi_s2, (N_states) ] + implicit none + BEGIN_DOC +! psi_energy(i) = $\langle \Psi_i | H | \Psi_i \rangle$ +! +! psi_s2(i) = $\langle \Psi_i | S^2 | \Psi_i \rangle$ + END_DOC + call u_0_HS2_u_0(psi_energy,psi_s2,psi_coef,N_det,psi_det,N_int,N_states,psi_det_size) + integer :: i + do i=N_det+1,N_states + psi_energy(i) = 0.d0 + psi_s2(i) = 0.d0 + enddo +END_PROVIDER + +BEGIN_PROVIDER [ double precision, psi_energy_with_nucl_rep, (N_states) ] + implicit none + BEGIN_DOC + ! Energy of the wave function with the nuclear repulsion energy. + END_DOC + psi_energy_with_nucl_rep(1:N_states) = psi_energy(1:N_states) + nuclear_repulsion +END_PROVIDER + + +subroutine u_0_HS2_u_0(e_0,s_0,u_0,n,keys_tmp,Nint,N_st,sze) + use bitmasks + implicit none + BEGIN_DOC + ! Computes $E_0 = \frac{\langle u_0 | H | u_0 \rangle}{\langle u_0 | u_0 \rangle}$ + ! + ! and $S_0 = \frac{\langle u_0 | S^2 | u_0 \rangle}{\langle u_0 | u_0 \rangle}$ + ! + ! n : number of determinants + ! + END_DOC + integer, intent(in) :: n,Nint, N_st, sze + double precision, intent(out) :: e_0(N_st),s_0(N_st) + double precision, intent(inout) :: u_0(sze,N_st) + integer(bit_kind),intent(in) :: keys_tmp(Nint,2,n) + + double precision, allocatable :: v_0(:,:), s_vec(:,:), u_1(:,:) + double precision :: u_dot_u,u_dot_v,diag_H_mat_elem + integer :: i,j, istate + + if ((n > 100000).and.distributed_davidson) then + allocate (v_0(n,N_states_diag),s_vec(n,N_states_diag), u_1(n,N_states_diag)) + u_1(:,:) = 0.d0 + u_1(1:n,1:N_st) = u_0(1:n,1:N_st) + call H_S2_u_0_nstates_zmq(v_0,s_vec,u_1,N_states_diag,n) + else if (n < n_det_max_full) then + allocate (v_0(n,N_st),s_vec(n,N_st), u_1(n,N_st)) + v_0(:,:) = 0.d0 + u_1(:,:) = 0.d0 + s_vec(:,:) = 0.d0 + u_1(1:n,1:N_st) = u_0(1:n,1:N_st) + do istate = 1,N_st + do j=1,n + do i=1,n + v_0(i,istate) = v_0(i,istate) + h_matrix_all_dets(i,j) * u_0(j,istate) + s_vec(i,istate) = s_vec(i,istate) + S2_matrix_all_dets(i,j) * u_0(j,istate) + enddo + enddo + enddo + else + allocate (v_0(n,N_st),s_vec(n,N_st),u_1(n,N_st)) + u_1(:,:) = 0.d0 + u_1(1:n,1:N_st) = u_0(1:n,1:N_st) + call H_S2_u_0_nstates_openmp(v_0,s_vec,u_1,N_st,n) + endif + u_0(1:n,1:N_st) = u_1(1:n,1:N_st) + deallocate(u_1) + double precision :: norm + !$OMP PARALLEL DO PRIVATE(i,norm) DEFAULT(SHARED) + do i=1,N_st + norm = u_dot_u(u_0(1,i),n) + if (norm /= 0.d0) then + e_0(i) = u_dot_v(v_0(1,i),u_0(1,i),n) + s_0(i) = u_dot_v(s_vec(1,i),u_0(1,i),n) + else + e_0(i) = 0.d0 + s_0(i) = 0.d0 + endif + enddo + !$OMP END PARALLEL DO + deallocate (s_vec, v_0) +end + + + + + +subroutine H_S2_u_0_nstates_openmp(v_0,s_0,u_0,N_st,sze) + use bitmasks + implicit none + BEGIN_DOC + ! Computes $v_0 = H | u_0\rangle$ and $s_0 = S^2 | u_0\rangle$. + ! + ! Assumes that the determinants are in psi_det + ! + ! istart, iend, ishift, istep are used in ZMQ parallelization. + END_DOC + integer, intent(in) :: N_st,sze + double precision, intent(inout) :: v_0(sze,N_st), s_0(sze,N_st), u_0(sze,N_st) + integer :: k + double precision, allocatable :: u_t(:,:), v_t(:,:), s_t(:,:) + !DIR$ ATTRIBUTES ALIGN : $IRP_ALIGN :: u_t + allocate(u_t(N_st,N_det),v_t(N_st,N_det),s_t(N_st,N_det)) + + do k=1,N_st + call dset_order(u_0(1,k),psi_bilinear_matrix_order,N_det) + enddo + v_t = 0.d0 + s_t = 0.d0 + call dtranspose( & + u_0, & + size(u_0, 1), & + u_t, & + size(u_t, 1), & + N_det, N_st) + + call H_S2_u_0_nstates_openmp_work(v_t,s_t,u_t,N_st,sze,1,N_det,0,1) + deallocate(u_t) + + call dtranspose( & + v_t, & + size(v_t, 1), & + v_0, & + size(v_0, 1), & + N_st, N_det) + call dtranspose( & + s_t, & + size(s_t, 1), & + s_0, & + size(s_0, 1), & + N_st, N_det) + deallocate(v_t,s_t) + + do k=1,N_st + call dset_order(v_0(1,k),psi_bilinear_matrix_order_reverse,N_det) + call dset_order(s_0(1,k),psi_bilinear_matrix_order_reverse,N_det) + call dset_order(u_0(1,k),psi_bilinear_matrix_order_reverse,N_det) + enddo + +end + + +subroutine H_S2_u_0_nstates_openmp_work(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep) + use bitmasks + implicit none + BEGIN_DOC + ! Computes $v_t = H | u_t\rangle$ and $s_t = S^2 | u_t\rangle$ + ! + ! Default should be 1,N_det,0,1 + END_DOC + integer, intent(in) :: N_st,sze,istart,iend,ishift,istep + double precision, intent(in) :: u_t(N_st,N_det) + double precision, intent(out) :: v_t(N_st,sze), s_t(N_st,sze) + + + PROVIDE ref_bitmask_energy N_int + + select case (N_int) + case (1) + call H_S2_u_0_nstates_openmp_work_1(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep) + case (2) + call H_S2_u_0_nstates_openmp_work_2(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep) + case (3) + call H_S2_u_0_nstates_openmp_work_3(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep) + case (4) + call H_S2_u_0_nstates_openmp_work_4(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep) + case default + call H_S2_u_0_nstates_openmp_work_N_int(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep) + end select +end +BEGIN_TEMPLATE + +subroutine H_S2_u_0_nstates_openmp_work_$N_int(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep) + use bitmasks + implicit none + BEGIN_DOC + ! Computes $v_t = H | u_t \\rangle$ and $s_t = S^2 | u_t\\rangle$ + ! + ! Default should be 1,N_det,0,1 + END_DOC + integer, intent(in) :: N_st,sze,istart,iend,ishift,istep + double precision, intent(in) :: u_t(N_st,N_det) + double precision, intent(out) :: v_t(N_st,sze), s_t(N_st,sze) + + double precision :: hij, sij + integer :: i,j,k,l,kk + integer :: k_a, k_b, l_a, l_b, m_a, m_b + integer :: istate + integer :: krow, kcol, krow_b, kcol_b + integer :: lrow, lcol + integer :: mrow, mcol + integer(bit_kind) :: spindet($N_int) + integer(bit_kind) :: tmp_det($N_int,2) + integer(bit_kind) :: tmp_det2($N_int,2) + integer(bit_kind) :: tmp_det3($N_int,2) + integer(bit_kind), allocatable :: buffer(:,:) + integer :: n_doubles + integer, allocatable :: doubles(:) + integer, allocatable :: singles_a(:) + integer, allocatable :: singles_b(:) + integer, allocatable :: idx(:), idx0(:) + integer :: maxab, n_singles_a, n_singles_b, kcol_prev + integer*8 :: k8 + logical :: compute_singles + integer*8 :: last_found, left, right, right_max + double precision :: rss, mem, ratio + double precision, allocatable :: utl(:,:) + integer, parameter :: block_size=128 + logical :: u_is_sparse + +! call resident_memory(rss) +! mem = dble(singles_beta_csc_size) / 1024.d0**3 +! +! compute_singles = (mem+rss > qp_max_mem) +! +! if (.not.compute_singles) then +! provide singles_beta_csc +! endif +compute_singles=.True. + + + maxab = max(N_det_alpha_unique, N_det_beta_unique)+1 + allocate(idx0(maxab)) + + do i=1,maxab + idx0(i) = i + enddo + + ! Prepare the array of all alpha single excitations + ! ------------------------------------------------- + + PROVIDE N_int nthreads_davidson + !$OMP PARALLEL DEFAULT(SHARED) NUM_THREADS(nthreads_davidson) & + !$OMP SHARED(psi_bilinear_matrix_rows, N_det, & + !$OMP psi_bilinear_matrix_columns, & + !$OMP psi_det_alpha_unique, psi_det_beta_unique, & + !$OMP n_det_alpha_unique, n_det_beta_unique, N_int, & + !$OMP psi_bilinear_matrix_transp_rows, & + !$OMP psi_bilinear_matrix_transp_columns, & + !$OMP psi_bilinear_matrix_transp_order, N_st, & + !$OMP psi_bilinear_matrix_order_transp_reverse, & + !$OMP psi_bilinear_matrix_columns_loc, & + !$OMP psi_bilinear_matrix_transp_rows_loc, & + !$OMP istart, iend, istep, irp_here, v_t, s_t, & + !$OMP ishift, idx0, u_t, maxab, compute_singles, & + !$OMP singles_alpha_csc,singles_alpha_csc_idx, & + !$OMP singles_beta_csc,singles_beta_csc_idx) & + !$OMP PRIVATE(krow, kcol, tmp_det, spindet, k_a, k_b, i, & + !$OMP lcol, lrow, l_a, l_b, utl, kk, u_is_sparse, & + !$OMP buffer, doubles, n_doubles, umax, & + !$OMP tmp_det2, hij, sij, idx, l, kcol_prev, & + !$OMP singles_a, n_singles_a, singles_b, ratio, & + !$OMP n_singles_b, k8, last_found,left,right,right_max) + + ! Alpha/Beta double excitations + ! ============================= + + allocate( buffer($N_int,maxab), & + singles_a(maxab), & + singles_b(maxab), & + doubles(maxab), & + idx(maxab), utl(N_st,block_size)) + + kcol_prev=-1 + + ! Check if u has multiple zeros + kk=1 ! Avoid division by zero + !$OMP DO + do k=1,N_det + umax = 0.d0 + do l=1,N_st + umax = max(umax, dabs(u_t(l,k))) + enddo + if (umax < 1.d-20) then + !$OMP ATOMIC + kk = kk+1 + endif + enddo + !$OMP END DO + u_is_sparse = N_det / kk < 20 ! 5% + + ASSERT (iend <= N_det) + ASSERT (istart > 0) + ASSERT (istep > 0) + + !$OMP DO SCHEDULE(guided,64) + do k_a=istart+ishift,iend,istep + + krow = psi_bilinear_matrix_rows(k_a) + ASSERT (krow <= N_det_alpha_unique) + + kcol = psi_bilinear_matrix_columns(k_a) + ASSERT (kcol <= N_det_beta_unique) + + tmp_det(1:$N_int,1) = psi_det_alpha_unique(1:$N_int, krow) + + if (kcol /= kcol_prev) then + tmp_det(1:$N_int,2) = psi_det_beta_unique (1:$N_int, kcol) + if (compute_singles) then + call get_all_spin_singles_$N_int( & + psi_det_beta_unique, idx0, & + tmp_det(1,2), N_det_beta_unique, & + singles_b, n_singles_b) + else + n_singles_b = 0 + !DIR$ LOOP COUNT avg(1000) + do k8=singles_beta_csc_idx(kcol),singles_beta_csc_idx(kcol+1)-1 + n_singles_b = n_singles_b+1 + singles_b(n_singles_b) = singles_beta_csc(k8) + enddo + endif + endif + kcol_prev = kcol + + ! Loop over singly excited beta columns + ! ------------------------------------- + + !DIR$ LOOP COUNT avg(1000) + do i=1,n_singles_b + lcol = singles_b(i) + + tmp_det2(1:$N_int,2) = psi_det_beta_unique(1:$N_int, lcol) + +!--- +! if (compute_singles) then + + l_a = psi_bilinear_matrix_columns_loc(lcol) + ASSERT (l_a <= N_det) + + !DIR$ UNROLL(8) + !DIR$ LOOP COUNT avg(50000) + do j=1,psi_bilinear_matrix_columns_loc(lcol+1) - psi_bilinear_matrix_columns_loc(lcol) + lrow = psi_bilinear_matrix_rows(l_a) + ASSERT (lrow <= N_det_alpha_unique) + + buffer(1:$N_int,j) = psi_det_alpha_unique(1:$N_int, lrow) ! hot spot + + ASSERT (l_a <= N_det) + idx(j) = l_a + l_a = l_a+1 + enddo + j = j-1 + + call get_all_spin_singles_$N_int( & + buffer, idx, tmp_det(1,1), j, & + singles_a, n_singles_a ) + +!----- +! else +! +! ! Search for singles +! +!call cpu_time(time0) +! ! Right boundary +! l_a = psi_bilinear_matrix_columns_loc(lcol+1)-1 +! ASSERT (l_a <= N_det) +! do j=1,psi_bilinear_matrix_columns_loc(lcol+1) - psi_bilinear_matrix_columns_loc(lcol) +! lrow = psi_bilinear_matrix_rows(l_a) +! ASSERT (lrow <= N_det_alpha_unique) +! +! left = singles_alpha_csc_idx(krow) +! right_max = -1_8 +! right = singles_alpha_csc_idx(krow+1) +! do while (right-left>0_8) +! k8 = shiftr(right+left,1) +! if (singles_alpha_csc(k8) > lrow) then +! right = k8 +! else if (singles_alpha_csc(k8) < lrow) then +! left = k8 + 1_8 +! else +! right_max = k8+1_8 +! exit +! endif +! enddo +! if (right_max > 0_8) exit +! l_a = l_a-1 +! enddo +! if (right_max < 0_8) right_max = singles_alpha_csc_idx(krow) +! +! ! Search +! n_singles_a = 0 +! l_a = psi_bilinear_matrix_columns_loc(lcol) +! ASSERT (l_a <= N_det) +! +! last_found = singles_alpha_csc_idx(krow) +! do j=1,psi_bilinear_matrix_columns_loc(lcol+1) - psi_bilinear_matrix_columns_loc(lcol) +! lrow = psi_bilinear_matrix_rows(l_a) +! ASSERT (lrow <= N_det_alpha_unique) +! +! left = last_found +! right = right_max +! do while (right-left>0_8) +! k8 = shiftr(right+left,1) +! if (singles_alpha_csc(k8) > lrow) then +! right = k8 +! else if (singles_alpha_csc(k8) < lrow) then +! left = k8 + 1_8 +! else +! n_singles_a += 1 +! singles_a(n_singles_a) = l_a +! last_found = k8+1_8 +! exit +! endif +! enddo +! l_a = l_a+1 +! enddo +! j = j-1 +! +! endif +!----- + + ! Loop over alpha singles + ! ----------------------- + + double precision :: umax + + !DIR$ LOOP COUNT avg(1000) + do k = 1,n_singles_a,block_size + umax = 0.d0 + ! Prefetch u_t(:,l_a) + if (u_is_sparse) then + do kk=0,block_size-1 + if (k+kk > n_singles_a) exit + l_a = singles_a(k+kk) + ASSERT (l_a <= N_det) + + do l=1,N_st + utl(l,kk+1) = u_t(l,l_a) + umax = max(umax, dabs(utl(l,kk+1))) + enddo + enddo + else + do kk=0,block_size-1 + if (k+kk > n_singles_a) exit + l_a = singles_a(k+kk) + ASSERT (l_a <= N_det) + utl(:,kk+1) = u_t(:,l_a) + enddo + umax = 1.d0 + endif + if (umax < 1.d-20) cycle + + do kk=0,block_size-1 + if (k+kk > n_singles_a) exit + l_a = singles_a(k+kk) + lrow = psi_bilinear_matrix_rows(l_a) + ASSERT (lrow <= N_det_alpha_unique) + + tmp_det2(1:$N_int,1) = psi_det_alpha_unique(1:$N_int, lrow) + call i_H_j_double_alpha_beta(tmp_det,tmp_det2,$N_int,hij) + call get_s2(tmp_det,tmp_det2,$N_int,sij) + !DIR$ LOOP COUNT AVG(4) + do l=1,N_st + v_t(l,k_a) = v_t(l,k_a) + hij * utl(l,kk+1) + s_t(l,k_a) = s_t(l,k_a) + sij * utl(l,kk+1) + enddo + enddo + enddo + + enddo + + enddo + !$OMP END DO + + !$OMP DO SCHEDULE(guided,64) + do k_a=istart+ishift,iend,istep + + + ! Single and double alpha excitations + ! =================================== + + + ! Initial determinant is at k_a in alpha-major representation + ! ----------------------------------------------------------------------- + + krow = psi_bilinear_matrix_rows(k_a) + ASSERT (krow <= N_det_alpha_unique) + + kcol = psi_bilinear_matrix_columns(k_a) + ASSERT (kcol <= N_det_beta_unique) + + tmp_det(1:$N_int,1) = psi_det_alpha_unique(1:$N_int, krow) + tmp_det(1:$N_int,2) = psi_det_beta_unique (1:$N_int, kcol) + + ! Initial determinant is at k_b in beta-major representation + ! ---------------------------------------------------------------------- + + k_b = psi_bilinear_matrix_order_transp_reverse(k_a) + ASSERT (k_b <= N_det) + + spindet(1:$N_int) = tmp_det(1:$N_int,1) + + ! Loop inside the beta column to gather all the connected alphas + lcol = psi_bilinear_matrix_columns(k_a) + l_a = psi_bilinear_matrix_columns_loc(lcol) + + !DIR$ LOOP COUNT avg(200000) + do i=1,N_det_alpha_unique + if (l_a > N_det) exit + lcol = psi_bilinear_matrix_columns(l_a) + if (lcol /= kcol) exit + lrow = psi_bilinear_matrix_rows(l_a) + ASSERT (lrow <= N_det_alpha_unique) + + buffer(1:$N_int,i) = psi_det_alpha_unique(1:$N_int, lrow) ! Hot spot + idx(i) = l_a + l_a = l_a+1 + enddo + i = i-1 + + call get_all_spin_singles_and_doubles_$N_int( & + buffer, idx, spindet, i, & + singles_a, doubles, n_singles_a, n_doubles ) + + ! Compute Hij for all alpha singles + ! ---------------------------------- + + tmp_det2(1:$N_int,2) = psi_det_beta_unique (1:$N_int, kcol) + !DIR$ LOOP COUNT avg(1000) + do i=1,n_singles_a,block_size + umax = 0.d0 + ! Prefetch u_t(:,l_a) + if (u_is_sparse) then + do kk=0,block_size-1 + if (i+kk > n_singles_a) exit + l_a = singles_a(i+kk) + ASSERT (l_a <= N_det) + + do l=1,N_st + utl(l,kk+1) = u_t(l,l_a) + umax = max(umax, dabs(utl(l,kk+1))) + enddo + enddo + else + do kk=0,block_size-1 + if (i+kk > n_singles_a) exit + l_a = singles_a(i+kk) + ASSERT (l_a <= N_det) + utl(:,kk+1) = u_t(:,l_a) + enddo + umax = 1.d0 + endif + if (umax < 1.d-20) cycle + + do kk=0,block_size-1 + if (i+kk > n_singles_a) exit + l_a = singles_a(i+kk) + lrow = psi_bilinear_matrix_rows(l_a) + ASSERT (lrow <= N_det_alpha_unique) + + tmp_det2(1:$N_int,1) = psi_det_alpha_unique(1:$N_int, lrow) + call i_h_j_single_spin( tmp_det, tmp_det2, $N_int, 1, hij) + + !DIR$ LOOP COUNT AVG(4) + do l=1,N_st + v_t(l,k_a) = v_t(l,k_a) + hij * utl(l,kk+1) + ! single => sij = 0 + enddo + enddo + enddo + + + ! Compute Hij for all alpha doubles + ! ---------------------------------- + + !DIR$ LOOP COUNT avg(50000) + do i=1,n_doubles,block_size + umax = 0.d0 + ! Prefetch u_t(:,l_a) + if (u_is_sparse) then + do kk=0,block_size-1 + if (i+kk > n_doubles) exit + l_a = doubles(i+kk) + ASSERT (l_a <= N_det) + + do l=1,N_st + utl(l,kk+1) = u_t(l,l_a) + umax = max(umax, dabs(utl(l,kk+1))) + enddo + enddo + else + do kk=0,block_size-1 + if (i+kk > n_doubles) exit + l_a = doubles(i+kk) + ASSERT (l_a <= N_det) + utl(:,kk+1) = u_t(:,l_a) + enddo + umax = 1.d0 + endif + if (umax < 1.d-20) cycle + + do kk=0,block_size-1 + if (i+kk > n_doubles) exit + l_a = doubles(i+kk) + lrow = psi_bilinear_matrix_rows(l_a) + ASSERT (lrow <= N_det_alpha_unique) + + call i_H_j_double_spin( tmp_det(1,1), psi_det_alpha_unique(1, lrow), $N_int, hij) + !DIR$ LOOP COUNT AVG(4) + do l=1,N_st + v_t(l,k_a) = v_t(l,k_a) + hij * utl(l,kk+1) + ! same spin => sij = 0 + enddo + enddo + enddo + + + ! Single and double beta excitations + ! ================================== + + + ! Initial determinant is at k_a in alpha-major representation + ! ----------------------------------------------------------------------- + + krow = psi_bilinear_matrix_rows(k_a) + kcol = psi_bilinear_matrix_columns(k_a) + + tmp_det(1:$N_int,1) = psi_det_alpha_unique(1:$N_int, krow) + tmp_det(1:$N_int,2) = psi_det_beta_unique (1:$N_int, kcol) + + spindet(1:$N_int) = tmp_det(1:$N_int,2) + + ! Initial determinant is at k_b in beta-major representation + ! ----------------------------------------------------------------------- + + k_b = psi_bilinear_matrix_order_transp_reverse(k_a) + ASSERT (k_b <= N_det) + + ! Loop inside the alpha row to gather all the connected betas + lrow = psi_bilinear_matrix_transp_rows(k_b) + l_b = psi_bilinear_matrix_transp_rows_loc(lrow) + !DIR$ LOOP COUNT avg(200000) + do i=1,N_det_beta_unique + if (l_b > N_det) exit + lrow = psi_bilinear_matrix_transp_rows(l_b) + if (lrow /= krow) exit + lcol = psi_bilinear_matrix_transp_columns(l_b) + ASSERT (lcol <= N_det_beta_unique) + + buffer(1:$N_int,i) = psi_det_beta_unique(1:$N_int, lcol) + idx(i) = l_b + l_b = l_b+1 + enddo + i = i-1 + + call get_all_spin_singles_and_doubles_$N_int( & + buffer, idx, spindet, i, & + singles_b, doubles, n_singles_b, n_doubles ) + + ! Compute Hij for all beta singles + ! ---------------------------------- + + tmp_det2(1:$N_int,1) = psi_det_alpha_unique(1:$N_int, krow) + !DIR$ LOOP COUNT avg(1000) + do i=1,n_singles_b,block_size + umax = 0.d0 + if (u_is_sparse) then + do kk=0,block_size-1 + if (i+kk > n_singles_b) exit + l_b = singles_b(i+kk) + l_a = psi_bilinear_matrix_transp_order(l_b) + ASSERT (l_b <= N_det) + ASSERT (l_a <= N_det) + + do l=1,N_st + utl(l,kk+1) = u_t(l,l_a) + umax = max(umax, dabs(utl(l,kk+1))) + enddo + enddo + else + do kk=0,block_size-1 + if (i+kk > n_singles_b) exit + l_b = singles_b(i+kk) + l_a = psi_bilinear_matrix_transp_order(l_b) + ASSERT (l_b <= N_det) + ASSERT (l_a <= N_det) + utl(:,kk+1) = u_t(:,l_a) + enddo + umax = 1.d0 + endif + if (umax < 1.d-20) cycle + + do kk=0,block_size-1 + if (i+kk > n_singles_b) exit + l_b = singles_b(i+kk) + l_a = psi_bilinear_matrix_transp_order(l_b) + lcol = psi_bilinear_matrix_transp_columns(l_b) + ASSERT (lcol <= N_det_beta_unique) + + tmp_det2(1:$N_int,2) = psi_det_beta_unique (1:$N_int, lcol) + call i_h_j_single_spin( tmp_det, tmp_det2, $N_int, 2, hij) + !DIR$ LOOP COUNT AVG(4) + do l=1,N_st + v_t(l,k_a) = v_t(l,k_a) + hij * utl(l,kk+1) + ! single => sij = 0 + enddo + enddo + enddo + + ! Compute Hij for all beta doubles + ! ---------------------------------- + + !DIR$ LOOP COUNT avg(50000) + do i=1,n_doubles,block_size + umax = 0.d0 + if (u_is_sparse) then + do kk=0,block_size-1 + if (i+kk > n_doubles) exit + l_b = doubles(i+kk) + l_a = psi_bilinear_matrix_transp_order(l_b) + ASSERT (l_b <= N_det) + ASSERT (l_a <= N_det) + do l=1,N_st + utl(l,kk+1) = u_t(l,l_a) + umax = max(umax, dabs(utl(l,kk+1))) + enddo + enddo + else + do kk=0,block_size-1 + if (i+kk > n_doubles) exit + l_b = doubles(i+kk) + l_a = psi_bilinear_matrix_transp_order(l_b) + ASSERT (l_b <= N_det) + ASSERT (l_a <= N_det) + utl(:,kk+1) = u_t(:,l_a) + enddo + umax = 1.d0 + endif + if (umax < 1.d-20) cycle + + do kk=0,block_size-1 + if (i+kk > n_doubles) exit + l_b = doubles(i+kk) + l_a = psi_bilinear_matrix_transp_order(l_b) + lcol = psi_bilinear_matrix_transp_columns(l_b) + ASSERT (lcol <= N_det_beta_unique) + + call i_H_j_double_spin( tmp_det(1,2), psi_det_beta_unique(1, lcol), $N_int, hij) + + !DIR$ LOOP COUNT AVG(4) + do l=1,N_st + v_t(l,k_a) = v_t(l,k_a) + hij * utl(l,kk+1) + ! same spin => sij = 0 + enddo + enddo + enddo + + + ! Diagonal contribution + ! ===================== + + + ! Initial determinant is at k_a in alpha-major representation + ! ----------------------------------------------------------------------- + + if (u_is_sparse) then + umax = 0.d0 + do l=1,N_st + umax = max(umax, dabs(u_t(l,k_a))) + enddo + else + umax = 1.d0 + endif + if (umax < 1.d-20) cycle + + krow = psi_bilinear_matrix_rows(k_a) + ASSERT (krow <= N_det_alpha_unique) + + kcol = psi_bilinear_matrix_columns(k_a) + ASSERT (kcol <= N_det_beta_unique) + + tmp_det(1:$N_int,1) = psi_det_alpha_unique(1:$N_int, krow) + tmp_det(1:$N_int,2) = psi_det_beta_unique (1:$N_int, kcol) + + double precision, external :: diag_H_mat_elem, diag_S_mat_elem + + hij = diag_H_mat_elem(tmp_det,$N_int) + sij = diag_S_mat_elem(tmp_det,$N_int) + !DIR$ LOOP COUNT AVG(4) + do l=1,N_st + v_t(l,k_a) = v_t(l,k_a) + hij * u_t(l,k_a) + s_t(l,k_a) = s_t(l,k_a) + sij * u_t(l,k_a) + enddo + + end do + !$OMP END DO + deallocate(buffer, singles_a, singles_b, doubles, idx, utl) + !$OMP END PARALLEL + +end + +SUBST [ N_int ] + +1;; +2;; +3;; +4;; +N_int;; + +END_TEMPLATE + + diff --git a/src/determinants/connected_to_ref.irp.f b/src/determinants/connected_to_ref.irp.f index 086f19d1..e81eb5b0 100644 --- a/src/determinants/connected_to_ref.irp.f +++ b/src/determinants/connected_to_ref.irp.f @@ -12,19 +12,6 @@ integer*8 function det_search_key(det,Nint) end -integer*8 function occ_pattern_search_key(det,Nint) - use bitmasks - implicit none - BEGIN_DOC -! Return an integer*8 corresponding to a determinant index for searching - END_DOC - integer, intent(in) :: Nint - integer(bit_kind), intent(in) :: det(Nint,2) - integer :: i - i = shiftr(elec_alpha_num, bit_kind_shift)+1 - occ_pattern_search_key = int(shiftr(ior(det(i,1),det(i,2)),1)+sum(det),8) -end - logical function is_in_wavefunction(key,Nint) @@ -45,6 +32,7 @@ integer function get_index_in_psi_det_sorted_bit(key,Nint) use bitmasks BEGIN_DOC ! Returns the index of the determinant in the ``psi_det_sorted_bit`` array +! using a binary search END_DOC implicit none @@ -111,13 +99,11 @@ integer function get_index_in_psi_det_sorted_bit(key,Nint) enddo if (in_wavefunction) then get_index_in_psi_det_sorted_bit = i -! exit return endif endif i += 1 if (i > N_det) then -! exit return endif diff --git a/src/determinants/create_excitations.irp.f b/src/determinants/create_excitations.irp.f index cec87901..a597116b 100644 --- a/src/determinants/create_excitations.irp.f +++ b/src/determinants/create_excitations.irp.f @@ -24,7 +24,7 @@ subroutine do_single_excitation(key_in,i_hole,i_particle,ispin,i_ok) ! check whether position j is occupied if (iand(key_in(k,ispin),mask) /= 0_bit_kind) then key_in(k,ispin) = ibclr(key_in(k,ispin),j) - else + else i_ok= -1 return end if @@ -35,7 +35,7 @@ subroutine do_single_excitation(key_in,i_hole,i_particle,ispin,i_ok) mask = ibset(0_bit_kind,j) if (iand(key_in(k,ispin),mask) == 0_bit_kind) then key_in(k,ispin) = ibset(key_in(k,ispin),j) - else + else i_ok= -1 return end if @@ -99,11 +99,11 @@ logical function is_spin_flip_possible(key_in,i_flip,ispin) other_spin(1) = 2 other_spin(2) = 1 if(popcnt(iand(key_tmp(k,1),key_in(k,ispin))) == 1 .and. popcnt(iand(key_tmp(k,1),key_in(k,other_spin(ispin)))) == 0 )then - ! There is a spin "ispin" in the orbital i_flip AND There is no electron of opposit spin in the same orbital "i_flip" + ! There is a spin "ispin" in the orbital i_flip AND + ! There is no electron of opposit spin in the same orbital "i_flip" is_spin_flip_possible = .True. return else return endif end - diff --git a/src/determinants/density_matrix.irp.f b/src/determinants/density_matrix.irp.f index e69a1803..7c4a7fec 100644 --- a/src/determinants/density_matrix.irp.f +++ b/src/determinants/density_matrix.irp.f @@ -280,6 +280,8 @@ subroutine save_natural_mos ! the |MO| basis END_DOC call set_natural_mos + call nullify_small_elements(ao_num,mo_num,mo_coef,size(mo_coef,1),1.d-10) + call orthonormalize_mos call save_mos end diff --git a/src/determinants/determinants.irp.f b/src/determinants/determinants.irp.f index 71ee3d89..2a6057de 100644 --- a/src/determinants/determinants.irp.f +++ b/src/determinants/determinants.irp.f @@ -256,6 +256,26 @@ BEGIN_PROVIDER [ double precision, psi_average_norm_contrib, (psi_det_size) ] enddo END_PROVIDER +BEGIN_PROVIDER [ integer, dominant_det, (N_states) ] + implicit none + BEGIN_DOC + ! Determinant with the largest weight, for each state + END_DOC + integer :: i, k + double precision :: wmax, c + do k=1,N_states + wmax = 0.d0 + do i=1,N_det + c = psi_coef(i,k)*psi_coef(i,k) + if (c > wmax) then + dominant_det(k) = i + wmax = c + endif + enddo + enddo + +END_PROVIDER + !==============================================================================! @@ -459,10 +479,12 @@ subroutine save_wavefunction_truncated(thr) ! Save the wave function into the |EZFIO| file END_DOC integer :: N_det_save,i + call nullify_small_elements(N_det,N_states,psi_coef,size(psi_coef,1),thr) + TOUCH psi_coef N_det_save = N_det do i=1,N_det if (psi_average_norm_contrib_sorted(i) < thr) then - N_det_save = i + N_det_save = i-1 exit endif enddo diff --git a/src/determinants/h_apply.template.f b/src/determinants/h_apply.template.f index abdd6862..a6f9dadd 100644 --- a/src/determinants/h_apply.template.f +++ b/src/determinants/h_apply.template.f @@ -243,7 +243,7 @@ subroutine $subroutine_diexcOrg(key_in,key_mask,hole_1,particl_1,hole_2, particl ! Build array of the non-zero integrals of second excitation $filter_integrals - if (ispin == 1) then + if (ispin == 1) then integer :: jjj i=0 diff --git a/src/determinants/occ_pattern.irp.f b/src/determinants/occ_pattern.irp.f deleted file mode 100644 index d4d8c42b..00000000 --- a/src/determinants/occ_pattern.irp.f +++ /dev/null @@ -1,521 +0,0 @@ -use bitmasks -subroutine occ_pattern_of_det(d,o,Nint) - use bitmasks - implicit none - BEGIN_DOC - ! Transforms a determinant to an occupation pattern - ! - ! occ(:,1) : Single occupations - ! - ! occ(:,2) : Double occupations - ! - END_DOC - integer ,intent(in) :: Nint - integer(bit_kind),intent(in) :: d(Nint,2) - integer(bit_kind),intent(out) :: o(Nint,2) - - integer :: k - - do k=1,Nint - o(k,1) = ieor(d(k,1),d(k,2)) - o(k,2) = iand(d(k,1),d(k,2)) - enddo -end - - -subroutine occ_pattern_to_dets_size(o,sze,n_alpha,Nint) - use bitmasks - implicit none - BEGIN_DOC -! Number of possible determinants for a given occ_pattern - END_DOC - integer ,intent(in) :: Nint, n_alpha - integer(bit_kind),intent(in) :: o(Nint,2) - integer, intent(out) :: sze - integer :: amax,bmax,k - double precision, external :: binom_func - - bmax = 0 - amax = n_alpha - do k=1,Nint - bmax += popcnt( o(k,1) ) - amax -= popcnt( o(k,2) ) - enddo - if (binom_int(bmax, amax) > huge(1)) then - print *, irp_here, ': Too many determinants to generate' - stop 1 - endif - sze = int(binom_int(bmax, amax),4) -end - - -subroutine occ_pattern_to_dets(o,d,sze,n_alpha,Nint) - use bitmasks - implicit none - BEGIN_DOC - ! Generate all possible determinants for a given occ_pattern - ! - ! Input : - ! o : occupation pattern : (doubly occupied, singly occupied) - ! sze : Number of produced determinants, computed by `occ_pattern_to_dets_size` - ! n_alpha : Number of $\alpha$ electrons - ! Nint : N_int - ! - ! Output: - ! d : determinants - ! - END_DOC - integer ,intent(in) :: Nint - integer ,intent(in) :: n_alpha ! Number of alpha electrons - integer ,intent(inout) :: sze ! Dimension of the output dets - integer(bit_kind),intent(in) :: o(Nint,2) ! Occ patters - integer(bit_kind),intent(out) :: d(Nint,2,sze) ! Output determinants - - integer :: i, k, n, ispin, ispin2 - - ! Extract list of singly occupied MOs as (int,pos) pairs - ! ------------------------------------------------------ - - integer :: iint(2*n_alpha), ipos(2*n_alpha) - integer(bit_kind) :: v, t, tt, diff, v_prev - integer :: n_alpha_in_single - - n=0 - n_alpha_in_single = n_alpha - do i=1,Nint - v = o(i,1) - do while(v /= 0_bit_kind) - n = n+1 - iint(n) = i - ipos(n) = trailz(v) - v = iand(v,v-1) - enddo - n_alpha_in_single = n_alpha_in_single - popcnt( o(i,2) ) - enddo - - v = shiftl(1,n_alpha_in_single) - 1 - - ! Initialize first determinant - d(:,1,1) = o(:,2) - d(:,2,1) = o(:,2) - - do k=1,n_alpha_in_single - d(iint(k),1,1) = ibset( d(iint(k),1,1), ipos(k) ) - enddo - - do k=n_alpha_in_single+1,n - d(iint(k),2,1) = ibset( d(iint(k),2,1), ipos(k) ) - enddo - - sze = int(binom_int(n,n_alpha_in_single),4) - - if ( (shiftl(n_alpha_in_single,1) == n).and.n>0 ) then - - ! Time reversal symmetry - d(:,1,2) = d(:,2,1) - d(:,2,2) = d(:,1,1) - - do i=3,sze,2 - ! Generate next permutation with Anderson's algorithm - v_prev = v - t = ior(v,v-1) - tt = t+1 - v = ior(tt, shiftr( and(not(t),tt) - 1, trailz(v)+1) ) - - ! Find what has changed between v_prev and v - diff = ieor(v,v_prev) - - ! Initialize with previous determinant - d(:,1,i) = d(:,1,i-2) - d(:,2,i) = d(:,2,i-2) - - ! Swap bits only where they have changed from v_prev to v - do while (diff /= 0_bit_kind) - k = trailz(diff)+1 - if (btest(v,k-1)) then - d(iint(k),1,i) = ibset( d(iint(k),1,i), ipos(k) ) - d(iint(k),2,i) = ibclr( d(iint(k),2,i), ipos(k) ) - else - d(iint(k),1,i) = ibclr( d(iint(k),1,i), ipos(k) ) - d(iint(k),2,i) = ibset( d(iint(k),2,i), ipos(k) ) - endif - diff = iand(diff,diff-1_bit_kind) - enddo - - ! Time reversal symmetry - d(:,1,i+1) = d(:,2,i) - d(:,2,i+1) = d(:,1,i) - - enddo - - else - - do i=2,sze - ! Generate next permutation with Anderson's algorithm - v_prev = v - t = ior(v,v-1) - tt = t+1 - v = ior(tt, shiftr( and(not(t),tt) - 1, trailz(v)+1) ) - - ! Find what has changed between v_prev and v - diff = ieor(v,v_prev) - - ! Initialize with previous determinant - d(:,1,i) = d(:,1,i-1) - d(:,2,i) = d(:,2,i-1) - - ! Swap bits only where they have changed from v_prev to v - do while (diff /= 0_bit_kind) - k = trailz(diff)+1 - if (btest(v,k-1)) then - d(iint(k),1,i) = ibset( d(iint(k),1,i), ipos(k) ) - d(iint(k),2,i) = ibclr( d(iint(k),2,i), ipos(k) ) - else - d(iint(k),1,i) = ibclr( d(iint(k),1,i), ipos(k) ) - d(iint(k),2,i) = ibset( d(iint(k),2,i), ipos(k) ) - endif - diff = iand(diff,diff-1_bit_kind) - enddo - - enddo - - endif - -end - - - BEGIN_PROVIDER [ integer(bit_kind), psi_occ_pattern, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ integer, N_occ_pattern ] - implicit none - BEGIN_DOC - ! Array of the occ_patterns present in the wave function. - ! - ! psi_occ_pattern(:,1,j) = j-th occ_pattern of the wave function : represents all the single occupations - ! - ! psi_occ_pattern(:,2,j) = j-th occ_pattern of the wave function : represents all the double occupations - ! - ! The occ patterns are sorted by :c:func:`occ_pattern_search_key` - END_DOC - integer :: i,j,k - - ! create - do i = 1, N_det - do k = 1, N_int - psi_occ_pattern(k,1,i) = ieor(psi_det(k,1,i),psi_det(k,2,i)) - psi_occ_pattern(k,2,i) = iand(psi_det(k,1,i),psi_det(k,2,i)) - enddo - enddo - - ! Sort - integer, allocatable :: iorder(:) - integer*8, allocatable :: bit_tmp(:) - integer*8, external :: occ_pattern_search_key - integer(bit_kind), allocatable :: tmp_array(:,:,:) - logical,allocatable :: duplicate(:) - logical :: dup - - - allocate ( iorder(N_det), duplicate(N_det), bit_tmp(N_det), tmp_array(N_int,2,N_det) ) - - do i=1,N_det - iorder(i) = i - bit_tmp(i) = occ_pattern_search_key(psi_occ_pattern(1,1,i),N_int) - enddo - - call i8sort(bit_tmp,iorder,N_det) - - - !$OMP PARALLEL DEFAULT(shared) PRIVATE(i,j,k,dup) - - !$OMP DO - do i=1,N_det - do k=1,N_int - tmp_array(k,1,i) = psi_occ_pattern(k,1,iorder(i)) - tmp_array(k,2,i) = psi_occ_pattern(k,2,iorder(i)) - enddo - duplicate(i) = .False. - enddo - !$OMP END DO - - ! Find duplicates - !$OMP DO - do i=1,N_det-1 - if (duplicate(i)) then - cycle - endif - j = i+1 - do while (bit_tmp(j)==bit_tmp(i)) - if (duplicate(j)) then - j+=1 - if (j>N_det) then - exit - endif - cycle - endif - dup = .True. - do k=1,N_int - if ( (tmp_array(k,1,i) /= tmp_array(k,1,j)) & - .or. (tmp_array(k,2,i) /= tmp_array(k,2,j)) ) then - dup = .False. - exit - endif - enddo - if (dup) then - duplicate(j) = .True. - endif - j+=1 - if (j>N_det) then - exit - endif - enddo - enddo - !$OMP END DO - !$OMP END PARALLEL - - ! Copy filtered result - N_occ_pattern=0 - do i=1,N_det - if (duplicate(i)) then - cycle - endif - N_occ_pattern += 1 - do k=1,N_int - psi_occ_pattern(k,1,N_occ_pattern) = tmp_array(k,1,i) - psi_occ_pattern(k,2,N_occ_pattern) = tmp_array(k,2,i) - enddo - enddo - -!- Check -! print *, 'Checking for duplicates in occ pattern' -! do i=1,N_occ_pattern -! do j=i+1,N_occ_pattern -! duplicate(1) = .True. -! do k=1,N_int -! if (psi_occ_pattern(k,1,i) /= psi_occ_pattern(k,1,j)) then -! duplicate(1) = .False. -! exit -! endif -! if (psi_occ_pattern(k,2,i) /= psi_occ_pattern(k,2,j)) then -! duplicate(1) = .False. -! exit -! endif -! enddo -! if (duplicate(1)) then -! call debug_det(psi_occ_pattern(1,1,i),N_int) -! call debug_det(psi_occ_pattern(1,1,j),N_int) -! stop 'DUPLICATE' -! endif -! enddo -! enddo -! print *, 'No duplicates' -!- - deallocate(iorder,duplicate,bit_tmp,tmp_array) - -END_PROVIDER - -BEGIN_PROVIDER [ integer, det_to_occ_pattern, (N_det) ] - implicit none - BEGIN_DOC - ! Returns the index of the occupation pattern for each determinant - END_DOC - integer :: i,j,k,r,l - integer*8 :: key - integer(bit_kind) :: occ(N_int,2) - logical :: found - integer*8, allocatable :: bit_tmp(:) - integer*8, external :: occ_pattern_search_key - - allocate(bit_tmp(N_occ_pattern)) - do i=1,N_occ_pattern - bit_tmp(i) = occ_pattern_search_key(psi_occ_pattern(1,1,i),N_int) - enddo - - !$OMP PARALLEL DO DEFAULT(SHARED) & - !$OMP PRIVATE(i,k,j,r,l,key,found,occ) - do i=1,N_det - do k = 1, N_int - occ(k,1) = ieor(psi_det(k,1,i),psi_det(k,2,i)) - occ(k,2) = iand(psi_det(k,1,i),psi_det(k,2,i)) - enddo - - key = occ_pattern_search_key(occ,N_int) - - ! TODO: Binary search - l = 1 - r = N_occ_pattern -! do while(r-l > 32) -! j = shiftr(r+l,1) -! if (bit_tmp(j) < key) then -! l = j -! else -! r = j -! endif -! enddo - do j=l,r - found = .True. - do k=1,N_int - if ( (occ(k,1) /= psi_occ_pattern(k,1,j)) & - .or. (occ(k,2) /= psi_occ_pattern(k,2,j)) ) then - found = .False. - exit - endif - enddo - if (found) then - det_to_occ_pattern(i) = j - exit - endif - enddo - - if (.not.found) then - print *, '3 bug in ', irp_here - stop -1 - endif - enddo - !$OMP END PARALLEL DO - deallocate(bit_tmp) -END_PROVIDER - - -BEGIN_PROVIDER [ double precision, psi_occ_pattern_Hii, (N_occ_pattern) ] - implicit none - BEGIN_DOC - ! $\langle I|H|I \rangle$ where $|I\rangle$ is an occupation pattern. - ! This is the minimum $H_{ii}$, where the $|i\rangle$ are the - ! determinants of $|I\rangle$. - END_DOC - integer :: j, i - - psi_occ_pattern_Hii(:) = huge(1.d0) - do i=1,N_det - j = det_to_occ_pattern(i) - psi_occ_pattern_Hii(j) = min(psi_occ_pattern_Hii(j), psi_det_Hii(i)) - enddo - -END_PROVIDER - - -BEGIN_PROVIDER [ double precision, weight_occ_pattern, (N_occ_pattern,N_states) ] - implicit none - BEGIN_DOC - ! Weight of the occupation patterns in the wave function - END_DOC - integer :: i,j,k - weight_occ_pattern = 0.d0 - do i=1,N_det - j = det_to_occ_pattern(i) - do k=1,N_states - weight_occ_pattern(j,k) += psi_coef(i,k) * psi_coef(i,k) - enddo - enddo -END_PROVIDER - -BEGIN_PROVIDER [ double precision, weight_occ_pattern_average, (N_occ_pattern) ] - implicit none - BEGIN_DOC - ! State-average weight of the occupation patterns in the wave function - END_DOC - integer :: i,j,k - weight_occ_pattern_average(:) = 0.d0 - do i=1,N_det - j = det_to_occ_pattern(i) - do k=1,N_states - weight_occ_pattern_average(j) += psi_coef(i,k) * psi_coef(i,k) * state_average_weight(k) - enddo - enddo -END_PROVIDER - - BEGIN_PROVIDER [ integer(bit_kind), psi_occ_pattern_sorted, (N_int,2,N_occ_pattern) ] -&BEGIN_PROVIDER [ double precision, weight_occ_pattern_average_sorted, (N_occ_pattern) ] -&BEGIN_PROVIDER [ integer, psi_occ_pattern_sorted_order, (N_occ_pattern) ] -&BEGIN_PROVIDER [ integer, psi_occ_pattern_sorted_order_reverse, (N_occ_pattern) ] - implicit none - BEGIN_DOC - ! Occupation patterns sorted by weight - END_DOC - integer :: i,j,k - integer, allocatable :: iorder(:) - allocate ( iorder(N_occ_pattern) ) - do i=1,N_occ_pattern - weight_occ_pattern_average_sorted(i) = -weight_occ_pattern_average(i) - iorder(i) = i - enddo - call dsort(weight_occ_pattern_average_sorted,iorder,N_occ_pattern) - do i=1,N_occ_pattern - do j=1,N_int - psi_occ_pattern_sorted(j,1,i) = psi_occ_pattern(j,1,iorder(i)) - psi_occ_pattern_sorted(j,2,i) = psi_occ_pattern(j,2,iorder(i)) - enddo - psi_occ_pattern_sorted_order(iorder(i)) = i - psi_occ_pattern_sorted_order_reverse(i) = iorder(i) - weight_occ_pattern_average_sorted(i) = -weight_occ_pattern_average_sorted(i) - enddo - - deallocate(iorder) - -END_PROVIDER - - -subroutine make_s2_eigenfunction - implicit none - integer :: i,j,k - integer :: smax, s - integer(bit_kind), allocatable :: d(:,:,:), det_buffer(:,:,:) - integer :: N_det_new, ithread, omp_get_thread_num - integer, parameter :: bufsze = 1000 - logical, external :: is_in_wavefunction - logical :: update - - update=.False. - call write_int(6,N_occ_pattern,'Number of occupation patterns') - - !$OMP PARALLEL DEFAULT(NONE) & - !$OMP SHARED(N_occ_pattern, psi_occ_pattern, elec_alpha_num,N_int,update) & - !$OMP PRIVATE(s,ithread, d, det_buffer, smax, N_det_new,i,j,k) - N_det_new = 0 - call occ_pattern_to_dets_size(psi_occ_pattern(1,1,1),s,elec_alpha_num,N_int) - allocate (d(N_int,2,s+64), det_buffer(N_int,2,bufsze) ) - smax = s - ithread=0 - !$ ithread = omp_get_thread_num() - !$OMP DO SCHEDULE (dynamic,1000) - do i=1,N_occ_pattern - call occ_pattern_to_dets_size(psi_occ_pattern(1,1,i),s,elec_alpha_num,N_int) - s += 1 - if (s > smax) then - deallocate(d) - allocate ( d(N_int,2,s+64) ) - smax = s - endif - call occ_pattern_to_dets(psi_occ_pattern(1,1,i),d,s,elec_alpha_num,N_int) - do j=1,s - if ( is_in_wavefunction(d(1,1,j), N_int) ) then - cycle - endif - update = .true. - N_det_new += 1 - det_buffer(:,:,N_det_new) = d(:,:,j) - if (N_det_new == bufsze) then - call fill_H_apply_buffer_no_selection(bufsze,det_buffer,N_int,ithread) - N_det_new = 0 - endif - enddo - enddo - !$OMP END DO NOWAIT - - if (N_det_new > 0) then - call fill_H_apply_buffer_no_selection(N_det_new,det_buffer,N_int,ithread) - endif - !$OMP BARRIER - deallocate(d,det_buffer) - !$OMP END PARALLEL - - if (update) then - call copy_H_apply_buffer_to_wf - TOUCH N_det psi_coef psi_det psi_occ_pattern N_occ_pattern - endif - call write_time(6) - -end - - - diff --git a/src/determinants/prune_wf.irp.f b/src/determinants/prune_wf.irp.f index 7399945f..697bd6d8 100644 --- a/src/determinants/prune_wf.irp.f +++ b/src/determinants/prune_wf.irp.f @@ -10,19 +10,19 @@ BEGIN_PROVIDER [ logical, pruned, (N_det) ] return endif - integer :: i,j,k,ndet_new,nsop_max + integer :: i,j,k,ndet_new,ncfg_max double precision :: thr - if (s2_eig) then - - nsop_max = max(1,int ( dble(N_occ_pattern) * (1.d0 - pruning) + 0.5d0 )) - - do i=1,N_det - k = det_to_occ_pattern(i) - pruned(i) = psi_occ_pattern_sorted_order_reverse(k) > nsop_max - enddo - - else +! if (s2_eig) then +! +! ncfg_max = max(1,int ( dble(N_configuration) * (1.d0 - pruning) + 0.5d0 )) +! +! do i=1,N_det +! k = det_to_configuration(i) +! pruned(i) = psi_configuration_sorted_order_reverse(k) > ncfg_max +! enddo +! +! else ndet_new = max(1,int( dble(N_det) * (1.d0 - pruning) + 0.5d0 )) thr = psi_average_norm_contrib_sorted(ndet_new) @@ -30,6 +30,6 @@ BEGIN_PROVIDER [ logical, pruned, (N_det) ] pruned(i) = psi_average_norm_contrib(i) < thr enddo - endif +! endif END_PROVIDER diff --git a/src/determinants/slater_rules.irp.f b/src/determinants/slater_rules.irp.f index ea8e0284..04cf861f 100644 --- a/src/determinants/slater_rules.irp.f +++ b/src/determinants/slater_rules.irp.f @@ -77,6 +77,16 @@ subroutine get_excitation(det1,det2,exc,degree,phase,Nint) ! exc(1,1,1) = first hole alpha ! exc(1,2,2) = first particle beta ! exc(1,1,2) = first hole beta + ! E_pq : T^alpha_pq + T^beta_pq + ! T^alpha_pq : exc(0,1,1) = 1 + ! exc(0,2,1) = 1 + ! exc(1,1,1) = q + ! exc(1,2,1) = p + + ! T^alpha_pq : exc(0,1,2) = 1 + ! exc(0,2,2) = 1 + ! exc(1,1,2) = q + ! exc(1,2,2) = p ASSERT (Nint > 0) diff --git a/src/determinants/spindeterminants.irp.f b/src/determinants/spindeterminants.irp.f index 232c9e2b..dea4a566 100644 --- a/src/determinants/spindeterminants.irp.f +++ b/src/determinants/spindeterminants.irp.f @@ -674,6 +674,19 @@ subroutine create_wf_of_psi_bilinear_matrix(truncate) ! of $\alpha$ and $\beta$ determinants END_DOC logical, intent(in) :: truncate + + call generate_all_alpha_beta_det_products + call update_wf_of_psi_bilinear_matrix(truncate) + +end + +subroutine update_wf_of_psi_bilinear_matrix(truncate) + use bitmasks + implicit none + BEGIN_DOC + ! Updates a wave function when psi_bilinear_matrix was modified + END_DOC + logical, intent(in) :: truncate integer :: i,j,k integer(bit_kind) :: tmp_det(N_int,2) integer :: idx @@ -681,7 +694,6 @@ subroutine create_wf_of_psi_bilinear_matrix(truncate) double precision :: norm(N_states) PROVIDE psi_bilinear_matrix - call generate_all_alpha_beta_det_products norm = 0.d0 !$OMP PARALLEL DO DEFAULT(NONE) & !$OMP PRIVATE(i,j,k,idx,tmp_det) & @@ -717,7 +729,7 @@ subroutine create_wf_of_psi_bilinear_matrix(truncate) enddo psi_det = psi_det_sorted_bit psi_coef = psi_coef_sorted_bit - TOUCH psi_det psi_coef + TOUCH psi_det psi_coef N_det_beta_unique N_det_alpha_unique psi_det_beta_unique psi_det_alpha_unique psi_det = psi_det_sorted psi_coef = psi_coef_sorted norm(1) = 0.d0 @@ -733,7 +745,7 @@ subroutine create_wf_of_psi_bilinear_matrix(truncate) endif enddo N_det = min(i,N_det) - SOFT_TOUCH psi_det psi_coef N_det + SOFT_TOUCH psi_det psi_coef N_det N_det_beta_unique N_det_alpha_unique psi_det_beta_unique psi_det_alpha_unique end @@ -773,7 +785,7 @@ subroutine generate_all_alpha_beta_det_products deallocate(tmp_det) !$OMP END PARALLEL call copy_H_apply_buffer_to_wf - SOFT_TOUCH psi_det psi_coef N_det + SOFT_TOUCH psi_det psi_coef N_det N_det_beta_unique N_det_alpha_unique psi_det_alpha_unique psi_det_beta_unique end @@ -1063,19 +1075,17 @@ subroutine get_all_spin_singles_and_doubles_1(buffer, idx, spindet, size_buffer, integer :: i include 'utils/constants.include.F' integer :: degree - + integer :: add_double(0:64) = (/ 0, 0, 0, 0, 1, (0, i=1,60) /) + integer :: add_single(0:64) = (/ 0, 0, 1, 0, 0, (0, i=1,60) /) n_singles = 1 n_doubles = 1 do i=1,size_buffer degree = popcnt( xor( spindet, buffer(i) ) ) - if ( degree == 4 ) then - doubles(n_doubles) = idx(i) - n_doubles = n_doubles+1 - else if ( degree == 2 ) then - singles(n_singles) = idx(i) - n_singles = n_singles+1 - endif + doubles(n_doubles) = idx(i) + singles(n_singles) = idx(i) + n_doubles = n_doubles+add_double(degree) + n_singles = n_singles+add_single(degree) enddo n_singles = n_singles-1 n_doubles = n_doubles-1 @@ -1101,15 +1111,14 @@ subroutine get_all_spin_singles_1(buffer, idx, spindet, size_buffer, singles, n_ integer :: i integer(bit_kind) :: v integer :: degree + integer :: add_single(0:64) = (/ 0, 0, 1, 0, 0, (0, i=1,60) /) include 'utils/constants.include.F' n_singles = 1 do i=1,size_buffer degree = popcnt(xor( spindet, buffer(i) )) - if (degree == 2) then - singles(n_singles) = idx(i) - n_singles = n_singles+1 - endif + singles(n_singles) = idx(i) + n_singles = n_singles+add_single(degree) enddo n_singles = n_singles-1 @@ -1133,14 +1142,13 @@ subroutine get_all_spin_doubles_1(buffer, idx, spindet, size_buffer, doubles, n_ integer :: i include 'utils/constants.include.F' integer :: degree + integer :: add_double(0:64) = (/ 0, 0, 0, 0, 1, (0, i=1,60) /) n_doubles = 1 do i=1,size_buffer degree = popcnt(xor( spindet, buffer(i) )) - if ( degree == 4 ) then - doubles(n_doubles) = idx(i) - n_doubles = n_doubles+1 - endif + doubles(n_doubles) = idx(i) + n_doubles = n_doubles+add_double(degree) enddo n_doubles = n_doubles-1 @@ -1181,16 +1189,10 @@ subroutine get_all_spin_singles_and_doubles_$N_int(buffer, idx, spindet, size_bu xorvec(k) = xor( spindet(k), buffer(k,i) ) enddo - if (xorvec(1) /= 0_8) then - degree = popcnt(xorvec(1)) - else - degree = 0 - endif + degree = 0 - do k=2,$N_int - if ( (degree <= 4).and.(xorvec(k) /= 0_8) ) then + do k=1,$N_int degree = degree + popcnt(xorvec(k)) - endif enddo if ( degree == 4 ) then @@ -1235,23 +1237,19 @@ subroutine get_all_spin_singles_$N_int(buffer, idx, spindet, size_buffer, single xorvec(k) = xor( spindet(k), buffer(k,i) ) enddo - if (xorvec(1) /= 0_8) then - degree = popcnt(xorvec(1)) - else - degree = 0 - endif + degree = 0 - do k=2,$N_int - if ( (degree <= 2).and.(xorvec(k) /= 0_8) ) then + do k=1,$N_int degree = degree + popcnt(xorvec(k)) - endif enddo - if ( degree == 2 ) then - singles(n_singles) = idx(i) - n_singles = n_singles+1 + if ( degree /= 2 ) then + cycle endif + singles(n_singles) = idx(i) + n_singles = n_singles+1 + enddo n_singles = n_singles-1 @@ -1284,23 +1282,19 @@ subroutine get_all_spin_doubles_$N_int(buffer, idx, spindet, size_buffer, double xorvec(k) = xor( spindet(k), buffer(k,i) ) enddo - if (xorvec(1) /= 0_8) then - degree = popcnt(xorvec(1)) - else - degree = 0 - endif + degree = 0 - do k=2,$N_int - if ( (degree <= 4).and.(xorvec(k) /= 0_8) ) then + do k=1,$N_int degree = degree + popcnt(xorvec(k)) - endif enddo - if ( degree == 4 ) then - doubles(n_doubles) = idx(i) - n_doubles = n_doubles+1 + if ( degree /= 4 ) then + cycle endif + doubles(n_doubles) = idx(i) + n_doubles = n_doubles+1 + enddo n_doubles = n_doubles-1 diff --git a/src/dressing/alpha_factory.irp.f b/src/dressing/alpha_factory.irp.f index 92af94d6..5eeeb1a6 100644 --- a/src/dressing/alpha_factory.irp.f +++ b/src/dressing/alpha_factory.irp.f @@ -14,9 +14,7 @@ subroutine alpha_callback(delta_ij_loc, i_generator, subset, csubset, iproc) integer(bit_kind) :: hole_mask(N_int,2), particle_mask(N_int,2) - do l=1,N_generators_bitmask - call generate_singles_and_doubles(delta_ij_loc,i_generator,l,subset,csubset,iproc) - enddo + call generate_singles_and_doubles(delta_ij_loc,i_generator,subset,csubset,iproc) end subroutine @@ -34,7 +32,7 @@ BEGIN_PROVIDER [ integer, psi_from_sorted_gen, (N_det) ] END_PROVIDER -subroutine generate_singles_and_doubles(delta_ij_loc, i_generator, bitmask_index, subset, csubset, iproc) +subroutine generate_singles_and_doubles(delta_ij_loc, i_generator, subset, csubset, iproc) use bitmasks implicit none BEGIN_DOC @@ -42,7 +40,7 @@ subroutine generate_singles_and_doubles(delta_ij_loc, i_generator, bitmask_index END_DOC double precision,intent(inout) :: delta_ij_loc(N_states,N_det,2) - integer, intent(in) :: i_generator, subset, csubset, bitmask_index + integer, intent(in) :: i_generator, subset, csubset integer, intent(in) :: iproc @@ -78,10 +76,10 @@ subroutine generate_singles_and_doubles(delta_ij_loc, i_generator, bitmask_index ! Masks adapted for MRCC do k=1,N_int - hole (k,1) = iand(psi_det_generators(k,1,i_generator), ior(generators_bitmask(k,1,s_hole,bitmask_index),generators_bitmask(k,1,s_part,bitmask_index) ) ) - hole (k,2) = iand(psi_det_generators(k,2,i_generator), ior(generators_bitmask(k,2,s_hole,bitmask_index),generators_bitmask(k,2,s_part,bitmask_index) ) ) - particle(k,1) = iand(not(psi_det_generators(k,1,i_generator)), ior(generators_bitmask(k,1,s_part,bitmask_index),generators_bitmask(k,1,s_hole,bitmask_index)) ) - particle(k,2) = iand(not(psi_det_generators(k,2,i_generator)), ior(generators_bitmask(k,2,s_part,bitmask_index),generators_bitmask(k,2,s_hole,bitmask_index)) ) + hole (k,1) = iand(psi_det_generators(k,1,i_generator), ior(generators_bitmask(k,1,s_hole),generators_bitmask(k,1,s_part) ) ) + hole (k,2) = iand(psi_det_generators(k,2,i_generator), ior(generators_bitmask(k,2,s_hole),generators_bitmask(k,2,s_part) ) ) + particle(k,1) = iand(not(psi_det_generators(k,1,i_generator)), ior(generators_bitmask(k,1,s_part),generators_bitmask(k,1,s_hole)) ) + particle(k,2) = iand(not(psi_det_generators(k,2,i_generator)), ior(generators_bitmask(k,2,s_part),generators_bitmask(k,2,s_hole)) ) enddo integer :: N_holes(2), N_particles(2) diff --git a/src/dressing/dress_slave.irp.f b/src/dressing/dress_slave.irp.f index 7401d0ba..04e4f01b 100644 --- a/src/dressing/dress_slave.irp.f +++ b/src/dressing/dress_slave.irp.f @@ -50,14 +50,19 @@ subroutine run_wf ! Dress ! --------- if (zmq_get_psi(zmq_to_qp_run_socket,1) == -1) cycle + if (zmq_get_dvector(zmq_to_qp_run_socket,1,'threshold_generators',threshold_generators,1) == -1) cycle + if (zmq_get_dvector(zmq_to_qp_run_socket,1,'energy',energy,N_states) == -1) cycle if (zmq_get_N_det_generators (zmq_to_qp_run_socket, 1) == -1) cycle if (zmq_get_N_det_selectors(zmq_to_qp_run_socket, 1) == -1) cycle if (zmq_get_dvector(zmq_to_qp_run_socket,1,'state_average_weight',state_average_weight,N_states) == -1) cycle + if (zmq_get_dvector(zmq_to_qp_run_socket,1,'selection_weight',selection_weight,N_states) == -1) cycle if (zmq_get_dvector(zmq_to_qp_run_socket,1,'energy',energy,N_states) == -1) cycle if (zmq_get_dvector(zmq_to_qp_run_socket,1,'dress_stoch_istate',tmp,1) == -1) cycle dress_stoch_istate = int(tmp) + pt2_e0_denominator(1:N_states) = energy(1:N_states) psi_energy(1:N_states) = energy(1:N_states) - TOUCH psi_energy dress_stoch_istate state_average_weight + TOUCH pt2_e0_denominator dress_stoch_istate state_average_weight threshold_generators selection_weight + PROVIDE psi_bilinear_matrix_columns_loc psi_det_alpha_unique psi_det_beta_unique PROVIDE psi_bilinear_matrix_rows psi_det_sorted_gen_order psi_bilinear_matrix_order diff --git a/src/dressing/selection_weight.irp.f b/src/dressing/selection_weight.irp.f new file mode 100644 index 00000000..24e2ace0 --- /dev/null +++ b/src/dressing/selection_weight.irp.f @@ -0,0 +1,150 @@ +BEGIN_PROVIDER [ double precision, pt2_match_weight, (N_states) ] + implicit none + BEGIN_DOC + ! Weights adjusted along the selection to make the PT2 contributions + ! of each state coincide. + END_DOC + pt2_match_weight(:) = 1.d0 +END_PROVIDER + + + +BEGIN_PROVIDER [ double precision, variance_match_weight, (N_states) ] + implicit none + BEGIN_DOC + ! Weights adjusted along the selection to make the variances + ! of each state coincide. + END_DOC + variance_match_weight(:) = 1.d0 +END_PROVIDER + + + +subroutine update_pt2_and_variance_weights(pt2_data, N_st) + implicit none + use selection_types + BEGIN_DOC +! Updates the PT2- and Variance- matching weights. + END_DOC + integer, intent(in) :: N_st + type(pt2_type), intent(in) :: pt2_data + double precision :: pt2(N_st) + double precision :: variance(N_st) + + double precision :: avg, element, dt, x + integer :: k + integer, save :: i_iter=0 + integer, parameter :: i_itermax = 1 + double precision, allocatable, save :: memo_variance(:,:), memo_pt2(:,:) + + pt2(:) = pt2_data % pt2(:) + variance(:) = pt2_data % variance(:) + + if (i_iter == 0) then + allocate(memo_variance(N_st,i_itermax), memo_pt2(N_st,i_itermax)) + memo_pt2(:,:) = 1.d0 + memo_variance(:,:) = 1.d0 + endif + + i_iter = i_iter+1 + if (i_iter > i_itermax) then + i_iter = 1 + endif + + dt = 2.0d0 + + avg = sum(pt2(1:N_st)) / dble(N_st) - 1.d-32 ! Avoid future division by zero + do k=1,N_st + element = exp(dt*(pt2(k)/avg -1.d0)) + element = min(2.0d0 , element) + element = max(0.5d0 , element) + memo_pt2(k,i_iter) = element + pt2_match_weight(k) *= product(memo_pt2(k,:)) + enddo + + + avg = sum(variance(1:N_st)) / dble(N_st) + 1.d-32 ! Avoid future division by zero + do k=1,N_st + element = exp(dt*(variance(k)/avg -1.d0)) + element = min(2.0d0 , element) + element = max(0.5d0 , element) + memo_variance(k,i_iter) = element + variance_match_weight(k) *= product(memo_variance(k,:)) + enddo + + if (N_det < 100) then + ! For tiny wave functions, weights are 1.d0 + pt2_match_weight(:) = 1.d0 + variance_match_weight(:) = 1.d0 + endif + + threshold_davidson_pt2 = min(1.d-6, & + max(threshold_davidson, 1.e-1 * PT2_relative_error * minval(abs(pt2(1:N_states)))) ) + + SOFT_TOUCH pt2_match_weight variance_match_weight threshold_davidson_pt2 +end + + + + +BEGIN_PROVIDER [ double precision, selection_weight, (N_states) ] + implicit none + BEGIN_DOC + ! Weights used in the selection criterion + END_DOC + select case (weight_selection) + + case (0) + print *, 'Using input weights in selection' + selection_weight(1:N_states) = c0_weight(1:N_states) * state_average_weight(1:N_states) + + case (1) + print *, 'Using 1/c_max^2 weight in selection' + selection_weight(1:N_states) = c0_weight(1:N_states) + + case (2) + print *, 'Using pt2-matching weight in selection' + selection_weight(1:N_states) = c0_weight(1:N_states) * pt2_match_weight(1:N_states) + print *, '# PT2 weight ', real(pt2_match_weight(:),4) + + case (3) + print *, 'Using variance-matching weight in selection' + selection_weight(1:N_states) = c0_weight(1:N_states) * variance_match_weight(1:N_states) + print *, '# var weight ', real(variance_match_weight(:),4) + + case (4) + print *, 'Using variance- and pt2-matching weights in selection' + selection_weight(1:N_states) = c0_weight(1:N_states) * sqrt(variance_match_weight(1:N_states) * pt2_match_weight(1:N_states)) + print *, '# PT2 weight ', real(pt2_match_weight(:),4) + print *, '# var weight ', real(variance_match_weight(:),4) + + case (5) + print *, 'Using variance-matching weight in selection' + selection_weight(1:N_states) = c0_weight(1:N_states) * variance_match_weight(1:N_states) + print *, '# var weight ', real(variance_match_weight(:),4) + + case (6) + print *, 'Using CI coefficient-based selection' + selection_weight(1:N_states) = c0_weight(1:N_states) + + case (7) + print *, 'Input weights multiplied by variance- and pt2-matching' + selection_weight(1:N_states) = c0_weight(1:N_states) * sqrt(variance_match_weight(1:N_states) * pt2_match_weight(1:N_states)) * state_average_weight(1:N_states) + print *, '# PT2 weight ', real(pt2_match_weight(:),4) + print *, '# var weight ', real(variance_match_weight(:),4) + + case (8) + print *, 'Input weights multiplied by pt2-matching' + selection_weight(1:N_states) = c0_weight(1:N_states) * pt2_match_weight(1:N_states) * state_average_weight(1:N_states) + print *, '# PT2 weight ', real(pt2_match_weight(:),4) + + case (9) + print *, 'Input weights multiplied by variance-matching' + selection_weight(1:N_states) = c0_weight(1:N_states) * variance_match_weight(1:N_states) * state_average_weight(1:N_states) + print *, '# var weight ', real(variance_match_weight(:),4) + + end select + print *, '# Total weight ', real(selection_weight(:),4) + +END_PROVIDER + diff --git a/src/ezfio_files/output.irp.f b/src/ezfio_files/output.irp.f index 5526fae2..48512f92 100644 --- a/src/ezfio_files/output.irp.f +++ b/src/ezfio_files/output.irp.f @@ -22,10 +22,11 @@ subroutine write_time(iunit) write(6,*) call print_memory_usage() call cpu_time(ct) + ct = ct - output_cpu_time_0 call wall_time(wt) + wt = wt - output_wall_time_0 write(6,'(A,F14.6,A,F14.6,A)') & - '.. >>>>> [ WALL TIME: ', wt-output_wall_time_0, & - ' s ] [ CPU TIME: ', ct-output_cpu_time_0, ' s ] <<<<< ..' + '.. >>>>> [ WALL TIME: ', wt, ' s ] [ CPU TIME: ', ct, ' s ] <<<<< ..' write(6,*) end diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index 89effe4f..f2c78067 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -12,7 +12,7 @@ function run() { qp set determinants n_states 1 qp set davidson threshold_davidson 1.e-10 qp set davidson n_states_diag 8 - qp run fci + qp run fci energy1="$(ezfio get fci energy | tr '[]' ' ' | cut -d ',' -f 1)" eq $energy1 $1 $thresh } @@ -26,12 +26,12 @@ function run_stoch() { qp set determinants n_states 1 qp set davidson threshold_davidson 1.e-10 qp set davidson n_states_diag 1 - qp run fci + qp run fci energy1="$(ezfio get fci energy_pt2 | tr '[]' ' ' | cut -d ',' -f 1)" eq $energy1 $1 $thresh } -@test "B-B" { +@test "B-B" { qp set_file b2_stretched.ezfio qp set determinants n_det_max 10000 qp set_frozen_core @@ -53,7 +53,7 @@ function run_stoch() { @test "DHNO" { # 11.4721s qp set_file dhno.ezfio - qp set_mo_class --core="[1-7]" --act="[8-64]" + qp set_mo_class --core="[1-7]" --act="[8-64]" run -130.459020029816 3.e-4 100000 } @@ -71,7 +71,7 @@ function run_stoch() { @test "HBO" { # 13.3144s [[ -n $TRAVIS ]] && skip qp set_file hbo.ezfio - run -100.21375705105 1.e-3 100000 + run -100.212560384678 1.e-3 100000 } @test "H2O" { # 11.3727s @@ -89,7 +89,7 @@ function run_stoch() { @test "SO" { # 13.4952s [[ -n $TRAVIS ]] && skip qp set_file so.ezfio - run -26.0137894714319 1.e-3 100000 + run -26.0096209515081 1.e-3 100000 } @test "H2S" { # 13.6745s @@ -98,7 +98,7 @@ function run_stoch() { run -398.859168655255 3.e-4 100000 } -@test "OH" { # 13.865s +@test "OH" { # 13.865s [[ -n $TRAVIS ]] && skip qp set_file oh.ezfio run -75.6121856748294 3.e-4 100000 @@ -132,13 +132,13 @@ function run_stoch() { @test "ClF" { # 16.8864s [[ -n $TRAVIS ]] && skip qp set_file clf.ezfio - run -559.1707464173 3.e-4 100000 + run -559.169313755572 3.e-4 100000 } @test "SO2" { # 17.5645s [[ -n $TRAVIS ]] && skip qp set_file so2.ezfio - qp set_mo_class --core="[1-8]" --act="[9-87]" + qp set_mo_class --core="[1-8]" --act="[9-87]" run -41.5746738713298 3.e-4 100000 } @@ -146,14 +146,14 @@ function run_stoch() { [[ -n $TRAVIS ]] && skip qp set_file c2h2.ezfio qp set_mo_class --act="[1-30]" --del="[31-36]" - run -12.3671816782954 3.e-4 100000 + run -12.3685464085969 3.e-4 100000 } @test "N2" { # 18.0198s [[ -n $TRAVIS ]] && skip qp set_file n2.ezfio qp set_mo_class --core="[1,2]" --act="[3-40]" --del="[41-60]" - run -109.28858440086 3.e-4 100000 + run -109.28681540699360 3.e-4 100000 } @test "N2H4" { # 18.5006s @@ -167,7 +167,7 @@ function run_stoch() { [[ -n $TRAVIS ]] && skip qp set_file co2.ezfio qp set_mo_class --core="[1,2]" --act="[3-30]" --del="[31-42]" - run -187.96924172901 3.e-4 100000 + run -187.968547952413 3.e-4 100000 } @@ -175,7 +175,7 @@ function run_stoch() { [[ -n $TRAVIS ]] && skip qp set_file cu_nh3_4_2plus.ezfio qp set_mo_class --core="[1-24]" --act="[25-45]" --del="[46-87]" - run -1862.97568806589 3.e-04 100000 + run -1862.9869374387192 3.e-04 100000 } @test "HCN" { # 20.3273s diff --git a/src/fci/EZFIO.cfg b/src/fci/EZFIO.cfg index d5526673..d897428a 100644 --- a/src/fci/EZFIO.cfg +++ b/src/fci/EZFIO.cfg @@ -10,4 +10,3 @@ doc: Calculated |FCI| energy + |PT2| interface: ezfio size: (determinants.n_states) - diff --git a/src/fci/fci.irp.f b/src/fci/fci.irp.f index 5c747081..9d9c0b7d 100644 --- a/src/fci/fci.irp.f +++ b/src/fci/fci.irp.f @@ -46,7 +46,7 @@ program fci endif else - PROVIDE mo_two_e_integrals_in_map + PROVIDE mo_two_e_integrals_in_map pt2_min_parallel_tasks call run_slave_cipsi diff --git a/src/fci/pt2.irp.f b/src/fci/pt2.irp.f index eb11e28c..1c9f9dcd 100644 --- a/src/fci/pt2.irp.f +++ b/src/fci/pt2.irp.f @@ -1,3 +1,4 @@ +! -*- mode: f90 -*- program pt2 implicit none BEGIN_DOC @@ -15,51 +16,51 @@ program pt2 ! END_DOC if (.not. is_zmq_slave) then - read_wf = .True. - threshold_generators = 1.d0 - SOFT_TOUCH read_wf threshold_generators - PROVIDE mo_two_e_integrals_in_map - PROVIDE psi_energy - call run + read_wf = .True. + threshold_generators = 1.d0 + SOFT_TOUCH read_wf threshold_generators + PROVIDE mo_two_e_integrals_in_map + PROVIDE psi_energy + call run else - call run_slave_cipsi + call run_slave_cipsi endif -end +end program pt2 subroutine run implicit none use selection_types integer :: i,j,k logical, external :: detEq - + type(pt2_type) :: pt2_data, pt2_data_err integer :: degree integer :: n_det_before, to_select double precision :: threshold_davidson_in - + double precision :: relative_error double precision, allocatable :: E_CI_before(:) - + allocate ( E_CI_before(N_states)) call pt2_alloc(pt2_data, N_states) call pt2_alloc(pt2_data_err, N_states) - + E_CI_before(:) = psi_energy(:) + nuclear_repulsion relative_error=PT2_relative_error - + if (do_pt2) then - call ZMQ_pt2(psi_energy_with_nucl_rep, pt2_data, pt2_data_err, relative_error, 0) ! Stochastic PT2 + call ZMQ_pt2(psi_energy_with_nucl_rep, pt2_data, pt2_data_err, relative_error, 0) ! Stochastic PT2 else - call ZMQ_selection(0, pt2_data) + call ZMQ_selection(0, pt2_data) endif call print_summary(psi_energy_with_nucl_rep(1:N_states), & - pt2_data, pt2_data_err, N_det,N_occ_pattern,N_states,psi_s2) - + pt2_data, pt2_data_err, N_det,N_configuration,N_states,psi_s2) + call save_energy(E_CI_before, pt2_data % pt2) call pt2_dealloc(pt2_data) call pt2_dealloc(pt2_data_err) deallocate(E_CI_before) -end +end subroutine run diff --git a/src/hartree_fock/10.hf.bats b/src/hartree_fock/10.hf.bats index 54845685..65117b76 100644 --- a/src/hartree_fock/10.hf.bats +++ b/src/hartree_fock/10.hf.bats @@ -11,9 +11,8 @@ function run() { qp edit --check qp reset --mos qp set scf_utils n_it_scf_max 50 - qp set ao_one_e_ints lin_dep_cutoff 1.e-50 qp run scf -# qp set_frozen_core +# qp set_frozen_core energy="$(ezfio get hartree_fock energy)" eq $energy $2 $thresh } @@ -49,7 +48,7 @@ function run() { } @test "HBO" { # 0.805600 1.4543s - run hbo.ezfio -100.018582259096 + run hbo.ezfio -100.018582259096 } @test "H2S" { # 1.655600 4.21402s @@ -101,7 +100,7 @@ function run() { } @test "DHNO" { # 12.856700 16.5908s - run dhno.ezfio -130.427877782432 + run dhno.ezfio -130.427877782432 } @test "NH3" { # 13.632200 34.7981s diff --git a/src/hartree_fock/scf.irp.f b/src/hartree_fock/scf.irp.f index 6ebb1b80..3226073d 100644 --- a/src/hartree_fock/scf.irp.f +++ b/src/hartree_fock/scf.irp.f @@ -1,34 +1,34 @@ program scf BEGIN_DOC -! +! ! The :ref:`scf` program performs *Restricted* Hartree-Fock ! calculations (the spatial part of the |MOs| is common for alpha and beta ! spinorbitals). -! +! ! It performs the following actions: -! +! ! #. Compute/Read all the one- and two-electron integrals, and store them ! in memory ! #. Check in the |EZFIO| database if there is a set of |MOs|. ! If there is, it will read them as initial guess. Otherwise, it will ! create a guess. ! #. Perform the |SCF| iterations -! +! ! For the keywords related to the |SCF| procedure, see the ``scf_utils`` ! directory where you will find all options. -! +! ! At each iteration, the |MOs| are saved in the |EZFIO| database. Hence, ! if the calculation crashes for any unexpected reason, the calculation ! can be restarted by running again the |SCF| with the same |EZFIO| ! database. -! +! ! To start again a fresh |SCF| calculation, the |MOs| can be reset by ! running the :ref:`qp_reset` command. -! -! The `DIIS`_ algorithm is implemented, as well as the `level-shifting`_ +! +! The `DIIS`_ algorithm is implemented, as well as the `level-shifting`_ ! method. If the |SCF| does not converge, try again with a higher value of ! :option:`level_shift`. -! +! ! .. _DIIS: https://en.wikipedia.org/w/index.php?title=DIIS ! .. _level-shifting: https://doi.org/10.1002/qua.560070407 ! @@ -47,21 +47,24 @@ subroutine create_guess PROVIDE ezfio_filename call ezfio_has_mo_basis_mo_coef(exists) if (.not.exists) then + mo_label = 'Guess' if (mo_guess_type == "HCore") then mo_coef = ao_ortho_lowdin_coef + call restore_symmetry(ao_num,mo_num,mo_coef,size(mo_coef,1),1.d-10) TOUCH mo_coef - mo_label = 'Guess' call mo_as_eigvectors_of_mo_matrix(mo_one_e_integrals, & size(mo_one_e_integrals,1), & size(mo_one_e_integrals,2), & mo_label,1,.false.) - SOFT_TOUCH mo_coef mo_label + call restore_symmetry(ao_num,mo_num,mo_coef,size(mo_coef,1),1.d-10) + SOFT_TOUCH mo_coef else if (mo_guess_type == "Huckel") then call huckel_guess else print *, 'Unrecognized MO guess type : '//mo_guess_type stop 1 endif + SOFT_TOUCH mo_label endif end @@ -76,7 +79,7 @@ subroutine run integer :: i_it, i, j, k - mo_label = "Orthonormalized" + mo_label = 'Orthonormalized' call Roothaan_Hall_SCF call ezfio_set_hartree_fock_energy(SCF_energy) diff --git a/src/iterations/print_summary.irp.f b/src/iterations/print_summary.irp.f index d04d8a93..641ee209 100644 --- a/src/iterations/print_summary.irp.f +++ b/src/iterations/print_summary.irp.f @@ -1,11 +1,11 @@ -subroutine print_summary(e_,pt2_data,pt2_data_err,n_det_,n_occ_pattern_,n_st,s2_) +subroutine print_summary(e_,pt2_data,pt2_data_err,n_det_,n_configuration_,n_st,s2_) use selection_types implicit none BEGIN_DOC ! Print the extrapolated energy in the output END_DOC - integer, intent(in) :: n_det_, n_occ_pattern_, n_st + integer, intent(in) :: n_det_, n_configuration_, n_st double precision, intent(in) :: e_(n_st), s2_(n_st) type(pt2_type) , intent(in) :: pt2_data, pt2_data_err integer :: i, k @@ -57,7 +57,10 @@ subroutine print_summary(e_,pt2_data,pt2_data_err,n_det_,n_occ_pattern_,n_st,s2_ print *, 'N_det = ', N_det_ print *, 'N_states = ', n_st if (s2_eig) then - print *, 'N_sop = ', N_occ_pattern_ + print *, 'N_cfg = ', N_configuration_ + if (only_expected_s2) then + print *, 'N_csf = ', N_csf + endif endif print *, '' diff --git a/src/mo_basis/EZFIO.cfg b/src/mo_basis/EZFIO.cfg index 874af46a..81ffba5c 100644 --- a/src/mo_basis/EZFIO.cfg +++ b/src/mo_basis/EZFIO.cfg @@ -36,4 +36,3 @@ size: (mo_basis.mo_num) type: character*(32) doc: MD5 checksum characterizing the |AO| basis set. interface: ezfio - diff --git a/src/mo_basis/mos.irp.f b/src/mo_basis/mos.irp.f index 73d33901..57ebb533 100644 --- a/src/mo_basis/mos.irp.f +++ b/src/mo_basis/mos.irp.f @@ -277,6 +277,7 @@ subroutine ao_to_mo(A_ao,LDA_ao,A_mo,LDA_mo) T, ao_num, & 0.d0, A_mo, size(A_mo,1)) + call restore_symmetry(mo_num,mo_num,A_mo,size(A_mo,1),1.d-12) deallocate(T) end diff --git a/src/mo_guess/h_core_guess_routine.irp.f b/src/mo_guess/h_core_guess_routine.irp.f index 246dfef2..cbf23a9a 100644 --- a/src/mo_guess/h_core_guess_routine.irp.f +++ b/src/mo_guess/h_core_guess_routine.irp.f @@ -4,10 +4,11 @@ subroutine hcore_guess END_DOC implicit none character*(64) :: label - label = "Guess" + label = 'Guess' call mo_as_eigvectors_of_mo_matrix(mo_one_e_integrals, & size(mo_one_e_integrals,1), & size(mo_one_e_integrals,2),label,1,.false.) + call nullify_small_elements(ao_num, mo_num, mo_coef, size(mo_coef,1), 1.d-12 ) call save_mos TOUCH mo_coef mo_label end diff --git a/src/mo_one_e_ints/EZFIO.cfg b/src/mo_one_e_ints/EZFIO.cfg index d58b3da1..ca4dabf4 100644 --- a/src/mo_one_e_ints/EZFIO.cfg +++ b/src/mo_one_e_ints/EZFIO.cfg @@ -47,3 +47,10 @@ type: Disk_access doc: Read/Write |MO| one-electron integrals from/to disk [ Write | Read | None ] interface: ezfio,provider,ocaml default: None + + +[restore_symm] +type: logical +doc: If true, try to find symmetry in the MO coefficient matrices +interface: ezfio,provider,ocaml +default: True diff --git a/src/mo_one_e_ints/mo_one_e_ints.irp.f b/src/mo_one_e_ints/mo_one_e_ints.irp.f index a6a614ab..926ac7bd 100644 --- a/src/mo_one_e_ints/mo_one_e_ints.irp.f +++ b/src/mo_one_e_ints/mo_one_e_ints.irp.f @@ -18,5 +18,6 @@ BEGIN_PROVIDER [ double precision, mo_one_e_integrals,(mo_num,mo_num)] call ezfio_set_mo_one_e_ints_mo_one_e_integrals(mo_one_e_integrals) print *, 'MO one-e integrals written to disk' ENDIF + call nullify_small_elements(mo_num,mo_num,mo_one_e_integrals,size(mo_one_e_integrals,1),1.d-10) END_PROVIDER diff --git a/src/mo_one_e_ints/orthonormalize.irp.f b/src/mo_one_e_ints/orthonormalize.irp.f index 3a5d5488..69d6c73d 100644 --- a/src/mo_one_e_ints/orthonormalize.irp.f +++ b/src/mo_one_e_ints/orthonormalize.irp.f @@ -1,11 +1,10 @@ subroutine orthonormalize_mos implicit none - integer :: m,p,s + integer :: m,p,s,i m = size(mo_coef,1) p = size(mo_overlap,1) call ortho_lowdin(mo_overlap,p,mo_num,mo_coef,m,ao_num,lin_dep_cutoff) - mo_label = 'Orthonormalized' - SOFT_TOUCH mo_coef mo_label + SOFT_TOUCH mo_coef end diff --git a/src/mo_one_e_ints/pot_mo_pseudo_ints.irp.f b/src/mo_one_e_ints/pot_mo_pseudo_ints.irp.f index 179b33ed..f4c1012d 100644 --- a/src/mo_one_e_ints/pot_mo_pseudo_ints.irp.f +++ b/src/mo_one_e_ints/pot_mo_pseudo_ints.irp.f @@ -26,3 +26,43 @@ BEGIN_PROVIDER [double precision, mo_pseudo_integrals, (mo_num,mo_num)] END_PROVIDER +BEGIN_PROVIDER [double precision, mo_pseudo_integrals_local, (mo_num,mo_num)] + implicit none + BEGIN_DOC + ! Pseudopotential integrals in |MO| basis + END_DOC + + if (do_pseudo) then + call ao_to_mo( & + ao_pseudo_integrals_local, & + size(ao_pseudo_integrals_local,1), & + mo_pseudo_integrals_local, & + size(mo_pseudo_integrals_local,1) & + ) + else + mo_pseudo_integrals_local = 0.d0 + endif + +END_PROVIDER + + +BEGIN_PROVIDER [double precision, mo_pseudo_integrals_non_local, (mo_num,mo_num)] + implicit none + BEGIN_DOC + ! Pseudopotential integrals in |MO| basis + END_DOC + + if (do_pseudo) then + call ao_to_mo( & + ao_pseudo_integrals_non_local, & + size(ao_pseudo_integrals_non_local,1), & + mo_pseudo_integrals_non_local, & + size(mo_pseudo_integrals_non_local,1) & + ) + else + mo_pseudo_integrals_non_local = 0.d0 + endif + +END_PROVIDER + + diff --git a/src/mo_two_e_ints/core_quantities.irp.f b/src/mo_two_e_ints/core_quantities.irp.f index 1cc50cb1..b764a1a6 100644 --- a/src/mo_two_e_ints/core_quantities.irp.f +++ b/src/mo_two_e_ints/core_quantities.irp.f @@ -36,3 +36,26 @@ BEGIN_PROVIDER [double precision, core_fock_operator, (mo_num,mo_num)] enddo enddo END_PROVIDER + +BEGIN_PROVIDER [ double precision, h_core_ri, (mo_num, mo_num) ] + implicit none + BEGIN_DOC + ! Core Hamiltonian with 3-index exchange integrals: + ! + ! $\tilde{h}{pq} = h_{pq} - \frac{1}{2}\sum_{k} g(pk,kq)$ + END_DOC + + integer :: i,j, k + + do j=1,mo_num + do i=1,mo_num + h_core_ri(i,j) = mo_one_e_integrals(i,j) + enddo + do k=1,mo_num + do i=1,mo_num + h_core_ri(i,j) = h_core_ri(i,j) - 0.5 * big_array_exchange_integrals(k,i,j) + enddo + enddo + enddo +END_PROVIDER + diff --git a/src/mo_two_e_ints/integrals_3_index.irp.f b/src/mo_two_e_ints/integrals_3_index.irp.f index 73e31182..4ffb0134 100644 --- a/src/mo_two_e_ints/integrals_3_index.irp.f +++ b/src/mo_two_e_ints/integrals_3_index.irp.f @@ -2,9 +2,9 @@ &BEGIN_PROVIDER [double precision, big_array_exchange_integrals,(mo_num,mo_num, mo_num)] implicit none BEGIN_DOC - ! big_array_coulomb_integrals(i,j) = = (ii|jj) + ! big_array_coulomb_integrals(j,i,k) = = (ik|jj) ! - ! big_array_exchange_integrals(i,j) = = (ij|ij) + ! big_array_exchange_integrals(i,j,k) = = (ij|kj) END_DOC integer :: i,j,k,l double precision :: get_two_e_integral diff --git a/src/mo_two_e_ints/map_integrals.irp.f b/src/mo_two_e_ints/map_integrals.irp.f index 2221e0c9..8756ee47 100644 --- a/src/mo_two_e_ints/map_integrals.irp.f +++ b/src/mo_two_e_ints/map_integrals.irp.f @@ -99,9 +99,15 @@ double precision function get_two_e_integral(i,j,k,l,map) type(map_type), intent(inout) :: map real(integral_kind) :: tmp PROVIDE mo_two_e_integrals_in_map mo_integrals_cache - if (banned_excitation(i,k) .or. banned_excitation(j,l)) then - get_two_e_integral = 0.d0 - return + if (use_banned_excitation) then + if (banned_excitation(i,k)) then + get_two_e_integral = 0.d0 + return + endif + if (banned_excitation(j,l)) then + get_two_e_integral = 0.d0 + return + endif endif ii = l-mo_integrals_cache_min ii = ior(ii, k-mo_integrals_cache_min) @@ -282,26 +288,34 @@ subroutine get_mo_two_e_integrals_exch_ii(k,l,sze,out_val,map) end -BEGIN_PROVIDER [ logical, banned_excitation, (mo_num,mo_num) ] + BEGIN_PROVIDER [ logical, banned_excitation, (mo_num,mo_num) ] +&BEGIN_PROVIDER [ logical, use_banned_excitation ] implicit none use map_module BEGIN_DOC ! If true, the excitation is banned in the selection. Useful with local MOs. END_DOC banned_excitation = .False. - integer :: i,j + integer :: i,j, icount integer(key_kind) :: idx double precision :: tmp -! double precision :: buffer(mo_num) + + icount = 1 ! Avoid division by zero do j=1,mo_num do i=1,j-1 call two_e_integrals_index(i,j,j,i,idx) !DIR$ FORCEINLINE call map_get(mo_integrals_map,idx,tmp) - banned_excitation(i,j) = dabs(tmp) < 1.d-15 + banned_excitation(i,j) = dabs(tmp) < 1.d-14 banned_excitation(j,i) = banned_excitation(i,j) + if (banned_excitation(i,j)) icount = icount+2 enddo enddo + use_banned_excitation = (mo_num*mo_num) / icount <= 100 !1% + if (use_banned_excitation) then + print *, 'Using sparsity of exchange integrals' + endif + END_PROVIDER diff --git a/src/perturbation/EZFIO.cfg b/src/perturbation/EZFIO.cfg index f4bd8e65..5571f3bc 100644 --- a/src/perturbation/EZFIO.cfg +++ b/src/perturbation/EZFIO.cfg @@ -36,6 +36,6 @@ default: 1.00 [h0_type] type: character*(32) -doc: Type of denominator in PT2. [EN | SOP | HF] +doc: Type of denominator in PT2. [EN | CFG | HF] interface: ezfio,provider,ocaml default: EN diff --git a/src/scf_utils/EZFIO.cfg b/src/scf_utils/EZFIO.cfg index 694590ec..7b950b14 100644 --- a/src/scf_utils/EZFIO.cfg +++ b/src/scf_utils/EZFIO.cfg @@ -51,7 +51,6 @@ doc: If true, leave untouched all the orbitals defined as core and optimize all interface: ezfio,provider,ocaml default: False - [no_oa_or_av_opt] type: logical doc: If true, you set to zero all Fock elements between the orbital set to active and all the other orbitals diff --git a/src/scf_utils/huckel.irp.f b/src/scf_utils/huckel.irp.f index 2d110e69..f6d4c190 100644 --- a/src/scf_utils/huckel.irp.f +++ b/src/scf_utils/huckel.irp.f @@ -15,9 +15,10 @@ subroutine huckel_guess A = 0.d0 do j=1,ao_num do i=1,ao_num - A(i,j) = c * ao_overlap(i,j) * (ao_one_e_integrals_diag(i) + ao_one_e_integrals_diag(j)) + A(i,j) = c * ao_overlap(i,j) * & + (ao_one_e_integrals_diag(i) + ao_one_e_integrals_diag(j) ) enddo - A(j,j) = ao_one_e_integrals_diag(j) + ao_two_e_integral_alpha(j,j) + A(j,j) = ao_one_e_integrals_diag(j) + ao_two_e_integral_alpha(j,j) enddo Fock_matrix_ao_alpha(1:ao_num,1:ao_num) = A(1:ao_num,1:ao_num) @@ -25,6 +26,8 @@ subroutine huckel_guess TOUCH Fock_matrix_ao_alpha Fock_matrix_ao_beta mo_coef = eigenvectors_fock_matrix_mo + call restore_symmetry(ao_num,mo_num,mo_coef,size(mo_coef,1),1.d-10) + call orthonormalize_mos SOFT_TOUCH mo_coef call save_mos deallocate(A) diff --git a/src/scf_utils/roothaan_hall_scf.irp.f b/src/scf_utils/roothaan_hall_scf.irp.f index dc44e262..3b9eaeb4 100644 --- a/src/scf_utils/roothaan_hall_scf.irp.f +++ b/src/scf_utils/roothaan_hall_scf.irp.f @@ -23,6 +23,10 @@ END_DOC error_matrix_DIIS(ao_num,ao_num,max_dim_DIIS) & ) + Fock_matrix_DIIS = 0.d0 + error_matrix_DIIS = 0.d0 + mo_coef_save = 0.d0 + call write_time(6) print*,'Energy of the guess = ',SCF_energy @@ -62,7 +66,7 @@ END_DOC dim_DIIS = min(dim_DIIS+1,max_dim_DIIS) - if (scf_algorithm == 'DIIS') then + if ( (scf_algorithm == 'DIIS').and.(dabs(Delta_energy_SCF) > 1.d-6) ) then ! Store Fock and error matrices at each iteration do j=1,ao_num @@ -153,7 +157,7 @@ END_DOC enddo if (iteration_SCF < n_it_SCF_max) then - mo_label = "Canonical" + mo_label = 'Canonical' endif ! ! End of Main SCF loop @@ -164,7 +168,10 @@ END_DOC write(6,*) if(.not.frozen_orb_scf)then - call mo_as_eigvectors_of_mo_matrix(Fock_matrix_mo,size(Fock_matrix_mo,1),size(Fock_matrix_mo,2),mo_label,1,.true.) + call mo_as_eigvectors_of_mo_matrix(Fock_matrix_mo,size(Fock_matrix_mo,1), & + size(Fock_matrix_mo,2),mo_label,1,.true.) + call restore_symmetry(ao_num, mo_num, mo_coef, size(mo_coef,1), 1.d-10) + call orthonormalize_mos call save_mos endif @@ -195,7 +202,7 @@ END_DOC double precision,allocatable :: C_vector_DIIS(:) double precision,allocatable :: scratch(:,:) - integer :: i,j,k,i_DIIS,j_DIIS + integer :: i,j,k,l,i_DIIS,j_DIIS double precision :: rcond, ferr, berr integer, allocatable :: iwork(:) integer :: lwork @@ -211,28 +218,22 @@ END_DOC scratch(ao_num,ao_num) & ) -! Compute the matrices B and X + ! Compute the matrices B and X B_matrix_DIIS(:,:) = 0.d0 do j=1,dim_DIIS j_DIIS = min(dim_DIIS,mod(iteration_SCF-j,max_dim_DIIS)+1) - do i=1,dim_DIIS + do i=1,dim_DIIS i_DIIS = min(dim_DIIS,mod(iteration_SCF-i,max_dim_DIIS)+1) -! Compute product of two errors vectors - - call dgemm('N','N',ao_num,ao_num,ao_num, & - 1.d0, & - error_matrix_DIIS(1,1,i_DIIS),size(error_matrix_DIIS,1), & - error_matrix_DIIS(1,1,j_DIIS),size(error_matrix_DIIS,1), & - 0.d0, & - scratch,size(scratch,1)) - -! Compute Trace - - do k=1,ao_num - B_matrix_DIIS(i,j) = B_matrix_DIIS(i,j) + scratch(k,k) + ! Compute product of two errors vectors + do l=1,ao_num + do k=1,ao_num + B_matrix_DIIS(i,j) = B_matrix_DIIS(i,j) + & + error_matrix_DIIS(k,l,i_DIIS) * error_matrix_DIIS(k,l,j_DIIS) + enddo enddo + enddo enddo @@ -305,6 +306,7 @@ END_DOC do k=1,dim_DIIS if (dabs(X_vector_DIIS(k)) < 1.d-10) cycle do i=1,ao_num + ! FPE here Fock_matrix_AO_(i,j) = Fock_matrix_AO_(i,j) + & X_vector_DIIS(k)*Fock_matrix_DIIS(i,j,dim_DIIS-k+1) enddo diff --git a/src/tools/print_energy.irp.f b/src/tools/print_energy.irp.f index f78dffc8..4fe1572c 100644 --- a/src/tools/print_energy.irp.f +++ b/src/tools/print_energy.irp.f @@ -14,24 +14,5 @@ end subroutine run implicit none - integer :: i,j - double precision :: i_H_psi_array(N_states) - double precision :: E(N_states) - double precision :: norm(N_states) - - E(1:N_states) = nuclear_repulsion - norm(1:N_states) = 0.d0 - do i=1,N_det - call i_H_psi(psi_det(1,1,i), psi_det, psi_coef, N_int, N_det, & - size(psi_coef,1), N_states, i_H_psi_array) - do j=1,N_states - norm(j) += psi_coef(i,j)*psi_coef(i,j) - E(j) += i_H_psi_array(j) * psi_coef(i,j) - enddo - enddo - - print *, 'Energy:' - do i=1,N_states - print *, E(i)/norm(i) - enddo + print *, psi_energy + nuclear_repulsion end diff --git a/src/tools/save_ortho_mos.irp.f b/src/tools/save_ortho_mos.irp.f index 6d998102..cb7a2d55 100644 --- a/src/tools/save_ortho_mos.irp.f +++ b/src/tools/save_ortho_mos.irp.f @@ -10,5 +10,7 @@ program save_ortho_mos ! Thanks to the Lowdin orthonormalization, the new MOs are the most similar to the guess MOs. END_DOC call orthonormalize_mos + mo_label = 'Orthonormalized' + SOFT_TOUCH mo_label call save_mos end diff --git a/src/two_body_rdm/example.irp.f b/src/two_body_rdm/example.irp.f index 4400613c..e9cbd1a2 100644 --- a/src/two_body_rdm/example.irp.f +++ b/src/two_body_rdm/example.irp.f @@ -284,3 +284,4 @@ subroutine routine_full_mos print*,'wee_tot_st_av_3 = ',wee_tot_st_av_3 end + diff --git a/src/two_body_rdm/two_e_dm_mo.irp.f b/src/two_body_rdm/two_e_dm_mo.irp.f new file mode 100644 index 00000000..19e8d75e --- /dev/null +++ b/src/two_body_rdm/two_e_dm_mo.irp.f @@ -0,0 +1,40 @@ +BEGIN_PROVIDER [double precision, two_e_dm_mo, (mo_num,mo_num,mo_num,mo_num)] + implicit none + BEGIN_DOC + ! two_e_dm_bb_mo(i,j,k,l,istate) = STATE SPECIFIC physicist notation for 2RDM of beta/beta electrons + ! + ! + ! + ! WHERE ALL ORBITALS (i,j,k,l) BELONGS TO ALL OCCUPIED ORBITALS : core, inactive and active + ! + ! THE NORMALIZATION (i.e. sum of diagonal elements) IS SET TO N_{elec} * (N_{elec} - 1)/2 + ! + ! !!!!! WARNING !!!!! ALL SLATER DETERMINANTS IN PSI_DET MUST BELONG TO AN ACTIVE SPACE DEFINED BY "list_act" + ! + ! !!!!! WARNING !!!!! IF "no_core_density" then all elements involving at least one CORE MO is set to zero + ! The two-electron energy of each state can be computed as: + ! + ! \sum_{i,j,k,l = 1, n_core_inact_act_orb} two_e_dm_mo(i,j,k,l,istate) * < ii jj | kk ll > + ! + ! with ii = list_core_inact_act(i), jj = list_core_inact_act(j), kk = list_core_inact_act(k), ll = list_core_inact_act(l) + END_DOC + two_e_dm_mo = 0.d0 + integer :: i,j,k,l,iorb,jorb,korb,lorb,istate + + do l=1,mo_num + lorb = list_core_inact_act(l) + do k=1,mo_num + korb = list_core_inact_act(k) + do j=1,mo_num + jorb = list_core_inact_act(j) + do i=1,mo_num + iorb = list_core_inact_act(i) + two_e_dm_mo(iorb,jorb,korb,lorb) = state_av_full_occ_2_rdm_spin_trace_mo(i,j,k,l) + enddo + enddo + enddo + enddo + two_e_dm_mo(:,:,:,:) = two_e_dm_mo(:,:,:,:) * 2.d0 + + END_PROVIDER + diff --git a/src/utils/c_funcs.c b/src/utils/c_funcs.c index 5b7035fb..16b53256 100644 --- a/src/utils/c_funcs.c +++ b/src/utils/c_funcs.c @@ -1,6 +1,40 @@ #include +#include +#include void usleep_c(int s) { usleep((useconds_t) s); } + +void sscanf_ssds_c(const char* str, char* s1, char* s2, int* i, char* s3) +{ + sscanf(str, "%s %s %d %s", s1, s2, i, s3); + s1[strlen(s1)] = ' '; + s2[strlen(s2)] = ' '; + s3[strlen(s3)] = ' '; +} + +void sscanf_dd_c(const char* str, int* i1, int* i2) +{ + sscanf(str, "%d %d", i1, i2); +} + +void sscanf_ddd_c(const char* str, int* i1, int* i2, int* i3) +{ + sscanf(str, "%d %d %d", i1, i2, i3); +} + +void sscanf_ss_c(const char* str, char* s1, char* s2) +{ + sscanf(str, "%s %s", s1, s2); + s1[strlen(s1)] = ' '; + s2[strlen(s2)] = ' '; +} + +void sscanf_sd_c(const char* str, char* s1, int* i) +{ + sscanf(str, "%s %d", s1, i); + s1[strlen(s1)] = ' '; +} + diff --git a/src/utils/c_functions.f90 b/src/utils/c_functions.f90 index 425aafd6..65d4ad62 100644 --- a/src/utils/c_functions.f90 +++ b/src/utils/c_functions.f90 @@ -2,20 +2,133 @@ module c_functions use iso_c_binding interface - subroutine usleep_c(us) bind (C,name="usleep_c") - use iso_c_binding - integer(c_int), value :: us - end subroutine usleep_c + subroutine usleep_c(us) bind (C,name="usleep_c") + use iso_c_binding + integer(c_int), value :: us + end subroutine usleep_c end interface -end module + interface + integer(c_int) function atoi_c(a) bind (C,name="atoi") + use iso_c_binding + character(kind=c_char), intent(in) :: a(*) + end function atoi_c + end interface -subroutine usleep(us) + interface + subroutine sscanf_ss_c(str,s1, s2) bind (C) + use iso_c_binding + character(kind=c_char), intent(in ) :: str(*) + character(kind=c_char), intent(out) :: s1(*),s2(*) + end subroutine sscanf_ss_c + end interface + + interface + subroutine sscanf_ssds_c(str, s1, s2, i, s3) bind (C) + use iso_c_binding + character(kind=c_char), intent(in ) :: str(*) + character(kind=c_char), intent(out) :: s1(*),s2(*),s3(*) + integer(kind=c_int) , intent(out) :: i + end subroutine sscanf_ssds_c + end interface + + interface + subroutine sscanf_dd_c(str, i1, i2) bind (C) + use iso_c_binding + character(kind=c_char), intent(in ) :: str(*) + integer(kind=c_int) , intent(out) :: i1, i2 + end subroutine sscanf_dd_c + end interface + + interface + subroutine sscanf_ddd_c(str, i1, i2, i3) bind (C) + use iso_c_binding + character(kind=c_char), intent(in ) :: str(*) + integer(kind=c_int) , intent(out) :: i1, i2, i3 + end subroutine sscanf_ddd_c + end interface + + interface + subroutine sscanf_sd_c(str,s1, i) bind (C) + use iso_c_binding + character(kind=c_char), intent(in ) :: str(*) + character(kind=c_char), intent(out) :: s1(*) + integer(kind=c_int) , intent(out) :: i + end subroutine sscanf_sd_c + end interface + +contains + + integer function atoi(a) + implicit none + character(len=*), intent(in) :: a + atoi = atoi_c(trim(a)//c_null_char) + end function atoi + +end module c_functions + +subroutine sscanf_ss(str, s1,s2) use c_functions use iso_c_binding implicit none + character(*), intent(in) :: str + character(*), intent(out) :: s1,s2 + s1 = ' ' + s2 = ' ' + call sscanf_ss_c(trim(str)//c_null_char, s1, s2) +end subroutine sscanf_ss + +subroutine sscanf_sd(str, s1,i) + use c_functions + use iso_c_binding + implicit none + character(*), intent(in) :: str + character(*), intent(out) :: s1 + integer, intent(out) :: i + s1 = ' ' + call sscanf_sd_c(trim(str)//c_null_char, s1, i) +end subroutine sscanf_sd + +subroutine sscanf_ssds(str, s1,s2,i,s3) + use c_functions + use iso_c_binding + implicit none + character(*), intent(in) :: str + character(*), intent(out) :: s1,s2,s3 + integer, intent(out) :: i + s1 = ' ' + s2 = ' ' + s3 = ' ' + call sscanf_ssds_c(trim(str)//c_null_char, s1, s2, i, s3) +end subroutine sscanf_ssds + +subroutine sscanf_dd(str, i1,i2) + use c_functions + use iso_c_binding + implicit none + character(*), intent(in) :: str + integer, intent(out) :: i1, i2 + call sscanf_dd_c(trim(str)//c_null_char, i1, i2) +end subroutine sscanf_dd + +subroutine sscanf_ddd(str, i1,i2,i3) + use c_functions + use iso_c_binding + implicit none + character(*), intent(in) :: str + integer, intent(out) :: i1, i2, i3 + call sscanf_ddd_c(trim(str)//c_null_char, i1, i2, i3) +end subroutine sscanf_ddd + + +subroutine usleep(us) + use iso_c_binding + use c_functions + implicit none integer, intent(in) :: us integer(c_int) :: u u = us call usleep_c(u) -end +end subroutine usleep + + diff --git a/src/utils/integration.irp.f b/src/utils/integration.irp.f index da8120a1..5fe7438b 100644 --- a/src/utils/integration.irp.f +++ b/src/utils/integration.irp.f @@ -455,7 +455,7 @@ double precision function rint(n,rho) else u_inv=1.d0/dsqrt(rho) u=rho*u_inv - rint=0.5d0*u_inv*sqpi*erf(u) + rint=0.5d0*u_inv*sqpi*derf(u) endif return endif @@ -471,7 +471,7 @@ double precision function rint(n,rho) endif u=rho*u_inv two_rho_inv = 0.5d0*u_inv*u_inv - val0=0.5d0*u_inv*sqpi*erf(u) + val0=0.5d0*u_inv*sqpi*derf(u) rint=(val0-v)*two_rho_inv do k=2,n rint=(rint*dfloat(k+k-1)-v)*two_rho_inv @@ -504,7 +504,7 @@ double precision function rint_sum(n_pt_out,rho,d1) else u_inv=1.d0/dsqrt(rho) u=rho*u_inv - rint_sum=0.5d0*u_inv*sqpi*erf(u) *d1(0) + rint_sum=0.5d0*u_inv*sqpi*derf(u) *d1(0) endif do i=2,n_pt_out,2 @@ -523,7 +523,7 @@ double precision function rint_sum(n_pt_out,rho,d1) u_inv=1.d0/dsqrt(rho) u=rho*u_inv two_rho_inv = 0.5d0*u_inv*u_inv - val0=0.5d0*u_inv*sqpi*erf(u) + val0=0.5d0*u_inv*sqpi*derf(u) rint_sum=val0*d1(0) rint_tmp=(val0-v)*two_rho_inv di = 3.d0 diff --git a/src/utils/linear_algebra.irp.f b/src/utils/linear_algebra.irp.f index deb4f4ca..5b2f9067 100644 --- a/src/utils/linear_algebra.irp.f +++ b/src/utils/linear_algebra.irp.f @@ -5,7 +5,67 @@ subroutine svd(A,LDA,U,LDU,D,Vt,LDVt,m,n) ! ! LDx : leftmost dimension of x ! - ! Dimsneion of A is m x n + ! Dimension of A is m x n + ! + END_DOC + + integer, intent(in) :: LDA, LDU, LDVt, m, n + double precision, intent(in) :: A(LDA,n) + double precision, intent(out) :: U(LDU,min(m,n)) + double precision,intent(out) :: Vt(LDVt,n) + double precision,intent(out) :: D(min(m,n)) + double precision,allocatable :: work(:) + integer :: info, lwork, i, j, k + + double precision,allocatable :: A_tmp(:,:) + allocate (A_tmp(LDA,n)) + do k=1,n + do i=1,m + A_tmp(i,k) = A(i,k) + enddo + enddo + + ! Find optimal size for temp arrays + allocate(work(1)) + lwork = -1 + call dgesvd('S','S', m, n, A_tmp, LDA, & + D, U, LDU, Vt, LDVt, work, lwork, info) + ! /!\ int(WORK(1)) becomes negative when WORK(1) > 2147483648 + lwork = max(int(work(1)), 10*MIN(M,N)) + deallocate(work) + + allocate(work(lwork)) + call dgesvd('S','S', m, n, A_tmp, LDA, & + D, U, LDU, Vt, LDVt, work, lwork, info) + deallocate(A_tmp,work) + + if (info /= 0) then + print *, info, ': SVD failed' + stop + endif + + do j=1,min(m,n) + do i=1,m + if (dabs(U(i,j)) < 1.d-14) U(i,j) = 0.d0 + enddo + enddo + + do j=1,n + do i=1,n + if (dabs(Vt(i,j)) < 1.d-14) Vt(i,j) = 0.d0 + enddo + enddo + +end + +subroutine svd_symm(A,LDA,U,LDU,D,Vt,LDVt,m,n) + implicit none + BEGIN_DOC + ! Compute A = U.D.Vt + ! + ! LDx : leftmost dimension of x + ! + ! Dimension of A is m x n ! END_DOC @@ -24,22 +84,134 @@ subroutine svd(A,LDA,U,LDU,D,Vt,LDVt,m,n) ! Find optimal size for temp arrays allocate(work(1)) lwork = -1 - call dgesvd('S','S', m, n, A_tmp, LDA, & + call dgesvd('A','A', m, n, A_tmp, LDA, & D, U, LDU, Vt, LDVt, work, lwork, info) ! /!\ int(WORK(1)) becomes negative when WORK(1) > 2147483648 lwork = max(int(work(1)), 5*MIN(M,N)) deallocate(work) allocate(work(lwork)) - call dgesvd('S','S', m, n, A_tmp, LDA, & + call dgesvd('A','A', m, n, A_tmp, LDA, & D, U, LDU, Vt, LDVt, work, lwork, info) - deallocate(work,A_tmp) + deallocate(A_tmp,work) if (info /= 0) then print *, info, ': SVD failed' stop endif + ! Iterative refinement + ! -------------------- + ! https://doi.org/10.1016/j.cam.2019.112512 + + integer :: iter + double precision,allocatable :: R(:,:), S(:,:), T(:,:) + double precision,allocatable :: sigma(:), F(:,:), G(:,:) + double precision :: alpha, beta, x, thresh + + allocate (R(m,m), S(n,n), T(m,n), sigma(m), F(m,m), G(n,n), A_tmp(m,n)) + sigma = 0.d0 + R = 0.d0 + S = 0.d0 + T = 0.d0 + F = 0.d0 + G = 0.d0 + + thresh = 1.d-8 + call restore_symmetry(m,m,U,size(U,1),thresh) + call restore_symmetry(n,n,Vt,size(Vt,1),thresh) + + do iter=1,4 + do k=1,n + A_tmp(1:m,k) = D(k) * U(1:m,k) + enddo + + call dgemm('N','N',m,n,n,1.d0,A_tmp,size(A_tmp,1), & + Vt,size(Vt,1),0.d0,R,size(R,1)) + + print *, maxval(dabs(R(1:m,1:n) - A(1:m,1:n))) + + + call dgemm('T','N',m,m,m,-1.d0,U,size(U,1), & + U,size(U,1),0.d0,R,size(R,1)) + do i=1,m + R(i,i) = R(i,i) + 1.d0 + enddo + + call dgemm('N','T',n,n,n,-1.d0,Vt,size(Vt,1), & + Vt,size(Vt,1),0.d0,S,size(S,1)) + do i=1,n + S(i,i) = S(i,i) + 1.d0 + enddo + + + call dgemm('T','N',m,n,m,1.d0,U,size(U,1), & + A,size(A,1),0.d0,A_tmp,size(A_tmp,1)) + + call dgemm('N','T',m,n,n,1.d0,A_tmp,size(A_tmp,1), & + Vt,size(Vt,1),0.d0,T,size(T,1)) + + + do i=1,n + sigma(i) = T(i,i)/(1.d0 - (R(i,i)+S(i,i))*0.5d0) + F(i,i) = 0.5d0*R(i,i) + G(i,i) = 0.5d0*S(i,i) + enddo + + do j=1,n + do i=1,n + if (i == j) cycle + alpha = T(i,j) + sigma(j) * R(i,j) + beta = T(i,j) + sigma(j) * S(i,j) + x = 1.d0 / (sigma(j)*sigma(j) - sigma(i)*sigma(i)) + F(i,j) = (alpha * sigma(j) + beta * sigma(i)) * x + G(i,j) = (alpha * sigma(i) + beta * sigma(j)) * x + enddo + enddo + + do i=1,n + x = 1.d0/sigma(i) + do j=n+1,m + F(i,j) = -T(j,i) * x + enddo + enddo + + do i=n+1,m + do j=1,n + F(i,j) = R(i,j) - F(j,i) + enddo + enddo + + do i=n+1,m + do j=n+1,m + F(i,j) = R(i,j)*0.5d0 + enddo + enddo + + D(1:min(n,m)) = sigma(1:min(n,m)) + call dgemm('N','N',m,m,m,1.d0,U,size(U,1),F,size(F,1), & + 0.d0, A_tmp, size(A_tmp,1)) + do j=1,m + do i=1,m + U(i,j) = U(i,j) + A_tmp(i,j) + enddo + enddo + + call dgemm('T','N',n,n,n,1.d0,G,size(G,1),Vt,size(Vt,1), & + 0.d0, A_tmp, size(A_tmp,1)) + do j=1,n + do i=1,n + Vt(i,j) = Vt(i,j) + A_tmp(i,j) + enddo + enddo + + thresh = 0.01d0 * thresh + call restore_symmetry(m,m,U,size(U,1),thresh) + call restore_symmetry(n,n,Vt,size(Vt,1),thresh) + + enddo + + deallocate(A_tmp,R,S,F,G,sigma) end subroutine eigSVD(A,LDA,U,LDU,D,Vt,LDVt,m,n) @@ -951,7 +1123,12 @@ subroutine ortho_svd(A,LDA,m,n) double precision, allocatable :: U(:,:), D(:), Vt(:,:) allocate(U(m,n), D(n), Vt(n,n)) call SVD(A,LDA,U,size(U,1),D,Vt,size(Vt,1),m,n) - A(1:m,1:n) = U(1:m,1:n) + integer :: i,j + do j=1,n + do i=1,m + A(i,j) = U(i,j) + enddo + enddo deallocate(U,D, Vt) end @@ -1367,3 +1544,108 @@ subroutine lapack_diag(eigvalues,eigvectors,H,nmax,n) deallocate(A,eigenvalues) end +subroutine nullify_small_elements(m,n,A,LDA,thresh) + implicit none + integer, intent(in) :: m,n,LDA + double precision, intent(inout) :: A(LDA,n) + double precision, intent(in) :: thresh + integer :: i,j + double precision :: amax + + ! Find max value + amax = 0.d0 + do j=1,n + do i=1,m + amax = max(dabs(A(i,j)), amax) + enddo + enddo + if (amax == 0.d0) return + amax = 1.d0/amax + + ! Remove tiny elements + do j=1,n + do i=1,m + if ( dabs(A(i,j) * amax) < thresh ) then + A(i,j) = 0.d0 + endif + enddo + enddo + +end + +subroutine restore_symmetry(m,n,A,LDA,thresh) + implicit none + BEGIN_DOC +! Tries to find the matrix elements that are the same, and sets them +! to the average value. +! If restore_symm is False, only nullify small elements + END_DOC + integer, intent(in) :: m,n,LDA + double precision, intent(inout) :: A(LDA,n) + double precision, intent(in) :: thresh + integer :: i,j,k,l + logical, allocatable :: done(:,:) + double precision :: f, g, count, thresh2 + thresh2 = dsqrt(thresh) + call nullify_small_elements(m,n,A,LDA,thresh) + + if (.not.restore_symm) then + return + endif + + ! TODO: Costs O(n^4), but can be improved to (2 n^2 * log(n)): + ! - copy all values in a 1D array + ! - sort 1D array + ! - average nearby elements + ! - for all elements, find matching value in the sorted 1D array + + allocate(done(m,n)) + + do j=1,n + do i=1,m + done(i,j) = A(i,j) == 0.d0 + enddo + enddo + + do j=1,n + do i=1,m + if ( done(i,j) ) cycle + done(i,j) = .True. + count = 1.d0 + f = 1.d0/A(i,j) + do l=1,n + do k=1,m + if ( done(k,l) ) cycle + g = f * A(k,l) + if ( dabs(dabs(g) - 1.d0) < thresh2 ) then + count = count + 1.d0 + if (g>0.d0) then + A(i,j) = A(i,j) + A(k,l) + else + A(i,j) = A(i,j) - A(k,l) + end if + endif + enddo + enddo + if (count > 1.d0) then + A(i,j) = A(i,j) / count + do l=1,n + do k=1,m + if ( done(k,l) ) cycle + g = f * A(k,l) + if ( dabs(dabs(g) - 1.d0) < thresh2 ) then + done(k,l) = .True. + if (g>0.d0) then + A(k,l) = A(i,j) + else + A(k,l) = -A(i,j) + end if + endif + enddo + enddo + endif + + enddo + enddo + +end diff --git a/src/zmq/utils.irp.f b/src/zmq/utils.irp.f index 07e3a88f..93dbd16a 100644 --- a/src/zmq/utils.irp.f +++ b/src/zmq/utils.irp.f @@ -16,6 +16,7 @@ END_PROVIDER BEGIN_PROVIDER [ character*(128), qp_run_address ] &BEGIN_PROVIDER [ integer, zmq_port_start ] use f77_zmq + use c_functions implicit none BEGIN_DOC ! Address of the qp_run socket @@ -32,14 +33,15 @@ END_PROVIDER do i=len(buffer),1,-1 if ( buffer(i:i) == ':') then qp_run_address = trim(buffer(1:i-1)) - read(buffer(i+1:), *, err=10,end=10) zmq_port_start + zmq_port_start = atoi(buffer(i+1:)) exit endif enddo - return - 10 continue - print *, irp_here, ': Error in read' - stop -1 + + if (zmq_port_start == 0) then + print *, irp_here, ': zmq_port_start is 0' + stop -1 + endif END_PROVIDER BEGIN_PROVIDER [ character*(128), zmq_socket_pull_tcp_address ] @@ -84,6 +86,7 @@ end subroutine switch_qp_run_to_master use f77_zmq + use c_functions implicit none BEGIN_DOC ! Address of the master qp_run socket @@ -102,16 +105,17 @@ subroutine switch_qp_run_to_master do i=len(buffer),1,-1 if ( buffer(i:i) == ':') then qp_run_address = trim(buffer(1:i-1)) - read(buffer(i+1:), *, end=10, err=10) zmq_port_start + zmq_port_start = atoi(buffer(i+1:)) exit endif enddo call reset_zmq_addresses return - 10 continue - print *, irp_here, ': Error in read' - stop -1 + if (zmq_port_start == 0) then + print *, irp_here, ': zmq_port_start is 0' + stop -1 + endif end @@ -650,12 +654,17 @@ integer function connect_to_taskserver(zmq_to_qp_run_socket,worker_id,thread) rc = f77_zmq_recv(zmq_to_qp_run_socket, message, 510, 0) message = trim(message(1:rc)) if(message(1:5) == "error") then - go to 10 + connect_to_taskserver = -1 + return end if - read(message,*, end=10, err=10) reply, state, worker_id, address + + call sscanf_ssds(message, reply, state, worker_id, address) + if (trim(reply) /= 'connect_reply') then - go to 10 + connect_to_taskserver = -1 + return endif + if (trim(state) /= zmq_state) then integer, external :: disconnect_from_taskserver_state if (disconnect_from_taskserver_state(zmq_to_qp_run_socket, worker_id, state) == -1) then @@ -663,13 +672,8 @@ integer function connect_to_taskserver(zmq_to_qp_run_socket,worker_id,thread) continue endif connect_to_taskserver = -1 - return endif - return - 10 continue -! print *, irp_here//': '//trim(message) - connect_to_taskserver = -1 end integer function disconnect_from_taskserver(zmq_to_qp_run_socket, worker_id) @@ -681,7 +685,7 @@ integer function disconnect_from_taskserver(zmq_to_qp_run_socket, worker_id) integer(ZMQ_PTR), intent(in) :: zmq_to_qp_run_socket integer, intent(in) :: worker_id integer, external :: disconnect_from_taskserver_state - disconnect_from_taskserver = disconnect_from_taskserver_state(zmq_to_qp_run_socket, worker_id, zmq_state(1:128)) + disconnect_from_taskserver = disconnect_from_taskserver_state(zmq_to_qp_run_socket, worker_id, zmq_state) end integer function disconnect_from_taskserver_state(zmq_to_qp_run_socket, worker_id, state) @@ -692,16 +696,17 @@ integer function disconnect_from_taskserver_state(zmq_to_qp_run_socket, worker_i END_DOC integer(ZMQ_PTR), intent(in) :: zmq_to_qp_run_socket integer, intent(in) :: worker_id + character*(128), intent(in) :: state integer :: rc, sze character*(512) :: message, reply - character*(128) :: state + character*(128) :: state_tmp - disconnect_from_taskserver_state = 0 + disconnect_from_taskserver_state = -1 write(message,*) 'disconnect '//trim(state), worker_id - sze = len(trim(message)) + sze = min(510,len(trim(message))) rc = f77_zmq_send(zmq_to_qp_run_socket, trim(message), sze, 0) if (rc /= sze) then @@ -710,23 +715,22 @@ integer function disconnect_from_taskserver_state(zmq_to_qp_run_socket, worker_i endif rc = f77_zmq_recv(zmq_to_qp_run_socket, message, 510, 0) + if (rc <= 0) then + disconnect_from_taskserver_state = -3 + return + endif + rc = min(510,rc) message = trim(message(1:rc)) - read(message,*, end=10, err=10) reply, state - if ((trim(reply) == 'disconnect_reply').and.(trim(state) == trim(zmq_state))) then - return - endif - if (trim(message) == 'error Wrong state') then - disconnect_from_taskserver_state = -1 - return - else if (trim(message) == 'error No job is running') then - disconnect_from_taskserver_state = -1 + call sscanf_ss(message, reply, state_tmp) + + if (trim(state_tmp) /= trim(state)) then return endif - return - 10 continue - disconnect_from_taskserver_state = -1 + if ((trim(reply) == 'disconnect_reply')) then + disconnect_from_taskserver_state = 0 + endif end integer function add_task_to_taskserver(zmq_to_qp_run_socket,task) @@ -892,7 +896,7 @@ integer function get_task_from_taskserver(zmq_to_qp_run_socket,worker_id,task_id character*(1024) :: message character*(64) :: reply - integer :: rc, sze + integer :: rc, sze, i get_task_from_taskserver = 0 @@ -905,43 +909,41 @@ integer function get_task_from_taskserver(zmq_to_qp_run_socket,worker_id,task_id return endif - message = repeat(' ',512) + task_id = 0 + message = ' ' rc = f77_zmq_recv(zmq_to_qp_run_socket, message, 1024, 0) - rc = min(1024,rc) - read(message(1:rc),*, end=10, err=10) reply - if (trim(reply) == 'get_task_reply') then - read(message(1:rc),*, end=10, err=10) reply, task_id + i = 1 + do while (message(i:i) /= ' ') + i = i+1 + enddo + reply = message(1:i-1) + if (reply == 'get_task_reply') then + call sscanf_sd(message, reply, task_id) rc = 15 - do while (message(rc:rc) == ' ') + do while (rc < 1024 .and. message(rc:rc) == ' ') rc += 1 enddo - do while (message(rc:rc) /= ' ') + do while (rc < 1024 .and. message(rc:rc) /= ' ') rc += 1 enddo rc += 1 task = message(rc:) else if (trim(reply) == 'terminate') then - task_id = 0 task = 'terminate' else if (trim(message) == 'error No job is running') then - task_id = 0 task = 'terminate' else if (trim(message) == 'error Wrong state') then - task_id = 0 task = 'terminate' else get_task_from_taskserver = -1 return endif - return - - 10 continue - get_task_from_taskserver = -1 end integer function get_tasks_from_taskserver(zmq_to_qp_run_socket,worker_id,task_id,task,n_tasks) + use c_functions use f77_zmq implicit none BEGIN_DOC @@ -959,7 +961,7 @@ integer function get_tasks_from_taskserver(zmq_to_qp_run_socket,worker_id,task_i get_tasks_from_taskserver = 0 - write(message,*) 'get_tasks '//trim(zmq_state), worker_id, n_tasks + write(message,'(A,A,X,I10,I10)') 'get_tasks ', trim(zmq_state), worker_id, n_tasks sze = len(trim(message)) rc = f77_zmq_send(zmq_to_qp_run_socket, message, sze, 0) @@ -970,8 +972,10 @@ integer function get_tasks_from_taskserver(zmq_to_qp_run_socket,worker_id,task_i message = repeat(' ',1024) rc = f77_zmq_recv(zmq_to_qp_run_socket, message, 1024, 0) - rc = min(1024,rc) - read(message(1:rc),*, end=10, err=10) reply + if (rc <= 0) then + get_tasks_from_taskserver = -1 + return + endif if (trim(message) == 'get_tasks_reply ok') then continue else if (trim(message) == 'terminate') then @@ -989,18 +993,22 @@ integer function get_tasks_from_taskserver(zmq_to_qp_run_socket,worker_id,task_i do i=1,n_tasks message = repeat(' ',512) rc = f77_zmq_recv(zmq_to_qp_run_socket, message, 1024, 0) + if (rc <= 0) then + get_tasks_from_taskserver = -1 + return + endif rc = min(1024,rc) - read(message(1:rc),*, end=10, err=10) task_id(i) + task_id(i) = atoi(message(1:rc)) if (task_id(i) == 0) then task(i) = 'terminate' n_tasks = i exit endif rc = 1 - do while (message(rc:rc) == ' ') + do while (rc < 1024 .and. message(rc:rc) == ' ') rc += 1 enddo - do while (message(rc:rc) /= ' ') + do while (rc < 1024 .and. message(rc:rc) /= ' ') rc += 1 enddo rc += 1 @@ -1226,8 +1234,8 @@ integer function zmq_delete_tasks_async_recv(zmq_to_qp_run_socket,more,sending) integer :: rc character*(64) :: reply - if (.not.sending) return zmq_delete_tasks_async_recv = 0 + if (.not.sending) return reply = '' rc = f77_zmq_recv(zmq_to_qp_run_socket,reply,64,0) diff --git a/travis/compilation.sh b/travis/compilation.sh index 1aa26dda..071b4872 100755 --- a/travis/compilation.sh +++ b/travis/compilation.sh @@ -8,7 +8,7 @@ tar -zxf $HOME/cache/config.tgz # Configure QP2 cd qp2 source ./quantum_package.rc -ninja -j 1 -v +ninja -j 1 -v || exit -1 # Create cache cd .. diff --git a/travis/configuration.sh b/travis/configuration.sh index fa52e793..7b3f5423 100755 --- a/travis/configuration.sh +++ b/travis/configuration.sh @@ -2,7 +2,7 @@ # Stage 1 # Configure QP2 -./configure --install all --config ./config/travis.cfg +./configure --install all --config ./config/travis.cfg || exit -1 # Create cache cd ../ diff --git a/travis/testing.sh b/travis/testing.sh index b2122f5c..f67bd106 100755 --- a/travis/testing.sh +++ b/travis/testing.sh @@ -8,7 +8,7 @@ tar -zxf $HOME/cache/compil.tgz # Configure QP2 cd qp2 source ./quantum_package.rc -qp_test -a && rm $HOME/cache/compil.tgz +exec qp_test -a && rm $HOME/cache/compil.tgz