10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-06-02 11:25:26 +02:00

Merge pull request #48 from scemama/master

Stochastic CIPSI
This commit is contained in:
Emmanuel Giner 2019-01-07 17:36:27 +01:00 committed by GitHub
commit 45116ad60f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
54 changed files with 2291 additions and 1848 deletions

11
TODO
View File

@ -1,15 +1,14 @@
* Mettre le fichier LIB
* Faire que le slave de Hartree-fock est le calcul des integrales AO en parallele
# Web/doc
* Creer une page web pas trop degueu et la mettre ici : http://lcpq.github.io/quantum_package
* Pour les README.rst des modules, mettre un deuxième saut à la ligne pour la doc en ligne.
* Changer irpf90 pour creer de la doc en format rst
# Exterieur
* Molden format : http://cheminf.cmbi.ru.nl/molden/molden_format.html : read+write
* Molden format : http://cheminf.cmbi.ru.nl/molden/molden_format.html : read+write. Thomas est dessus
* 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)
@ -32,7 +31,6 @@
* Parameters for Hartree-Fock
* Parameters for Davidson
* Running in parallel
* Parameters for selection (Generators)
# Programmers doc:
@ -43,7 +41,4 @@
# EZFIO sans fork
/home/scemama/quantum_package/docs/source/modules/perturbation.rst:216: WARNING
: script pour mettre des :math: dans les commentaires
# Selection stochastique
Refaire les benchmarks

View File

@ -6,7 +6,7 @@ irpf90_entities
tags
Makefile
ao_basis
ao_one_e_integrals
ao_one_e_ints
ao_two_e_erf_ints
ao_two_e_ints
aux_quantities
@ -36,7 +36,7 @@ kohn_sham
kohn_sham_rs
mo_basis
mo_guess
mo_one_e_integrals
mo_one_e_ints
mo_two_e_erf_ints
mo_two_e_ints
mpi

View File

@ -3,3 +3,4 @@ default:
make -C ../ html
clean:
make -C ../ clean
rm modules/*.rst

View File

@ -39,6 +39,7 @@
.. |OPAM| replace:: `OPAM`_
.. |Python| replace:: `Python`_
.. |qp| replace:: *Quantum Package*
.. |resultsFile| replace:: `resultsFile`_
.. |SLURM| replace:: `SLURM`_
.. |ZeroMQ| replace:: `ZeroMQ`_

View File

@ -0,0 +1,978 @@
.. _cipsi:
.. program:: cipsi
.. default-role:: option
=====
cipsi
=====
|CIPSI| algorithm.
The :c:func:`run_stochastic_cipsi` and :c:func:`run_cipsi` subroutines start with a single
determinant, or with the wave function in the |EZFIO| database if
:option:`determinants read_wf` is |true|.
The :c:func:`run_cipsi` subroutine iteratively:
* Selects the most important determinants from the external space and adds them to the
internal space
* If :option:`determinants s2_eig` is |true|, it adds all the necessary
determinants to allow the eigenstates of |H| to be eigenstates of |S^2|
* Diagonalizes |H| in the enlarged internal space
* Computes the |PT2| contribution to the energy stochastically :cite:`Garniron_2017.2`
or deterministically, depending on :option:`perturbation do_pt2`
* Extrapolates the variational energy by fitting
:math:`E=E_\text{FCI} - \alpha\, E_\text{PT2}`
The difference between :c:func:`run_stochastic_cipsi` and :c:func:`run_cipsi` is that
:c:func:`run_stochastic_cipsi` selects the determinants on the fly with the computation
of the stochastic |PT2| :cite:`Garniron_2017.2`. Hence, it is a semi-stochastic selection. It
* Selects the most important determinants from the external space and adds them to the
internal space, on the fly with the computation of the PT2 with the stochastic algorithm
presented in :cite:`Garniron_2017.2`.
* If :option:`determinants s2_eig` is |true|, it adds all the necessary
determinants to allow the eigenstates of |H| to be eigenstates of |S^2|
* Extrapolates the variational energy by fitting
:math:`E=E_\text{FCI} - \alpha\, E_\text{PT2}`
* Diagonalizes |H| in the enlarged internal space
The number of selected determinants at each iteration will be such that the
size of the wave function will double at every iteration. If :option:`determinants
s2_eig` is |true|, then the number of selected determinants will be 1.5x the
current number, and then all the additional determinants will be added.
By default, the program will stop when more than one million determinants have
been selected, or when the |PT2| energy is below :math:`10^{-4}`.
The variational and |PT2| energies of the iterations are stored in the
|EZFIO| database, in the :ref:`iterations` module.
Computation of the |PT2| energy
-------------------------------
At each iteration, the |PT2| energy is computed considering the Epstein-Nesbet
zeroth-order Hamiltonian:
.. math::
E_{\text{PT2}} = \sum_{ \alpha }
\frac{|\langle \Psi_S | \hat{H} | \alpha \rangle|^2}
{E - \langle \alpha | \hat{H} | \alpha \rangle}
where the |kalpha| determinants are generated by applying all the single and
double excitation operators to all the determinants of the wave function
:math:`\Psi_G`.
When the hybrid-deterministic/stochastic algorithm is chosen
(default), :math:`Psi_G = \Psi_S = \Psi`, the full wavefunction expanded in the
internal space.
When the deterministic algorithm is chosen (:option:`perturbation do_pt2`
is set to |false|), :math:`Psi_G` is a truncation of |Psi| using
:option:`determinants threshold_generators`, and :math:`Psi_S` is a truncation
of |Psi| using :option:`determinants threshold_selectors`, and re-weighted
by :math:`1/\langle \Psi_s | \Psi_s \rangle`.
At every iteration, while computing the |PT2|, the variance of the wave
function is also computed:
.. math::
\sigma^2 & = \langle \Psi | \hat{H}^2 | \Psi \rangle -
\langle \Psi | \hat{H} | \Psi \rangle^2 \\
& = \sum_{i \in \text{FCI}}
\langle \Psi | \hat{H} | i \rangle
\langle i | \hat{H} | \Psi \rangle -
\langle \Psi | \hat{H} | \Psi \rangle^2 \\
& = \sum_{ \alpha }
\langle |\Psi | \hat{H} | \alpha \rangle|^2.
The expression of the variance is the same as the expression of the |PT2|, with
a denominator of 1. It measures how far the wave function is from the |FCI|
solution. Note that the absence of denominator in the Heat-Bath selected |CI|
method is selection method by minimization of the variance, whereas |CIPSI| is
a selection method by minimization of the energy.
If :option:`perturbation do_pt2` is set to |false|, then the stochastic
|PT2| is not computed, and an approximate value is obtained from the |CIPSI|
selection. The calculation is faster, but the extrapolated |FCI| value is
less accurate. This way of running the code should be used when the only
goal is to generate a wave function, as for using |CIPSI| wave functions as
trial wave functions of |QMC| calculations for example.
The :command:`PT2` program reads the wave function of the |EZFIO| database
and computes the energy and the |PT2| contribution.
State-averaging
---------------
Extrapolated |FCI| energy
-------------------------
An estimate of the |FCI| energy is computed by extrapolating
.. math::
E=E_\text{FCI} - \alpha\, E_\text{PT2}
This extrapolation is done for all the requested states, and excitation
energies are printed as energy differences between the extrapolated
energies of the excited states and the extrapolated energy of the ground
state.
The extrapolations are given considering the 2 last points, the 3 last points, ...,
the 7 last points. The extrapolated value should be chosen such that the extrpolated
value is stable with the number of points.
Providers
---------
.. c:var:: initialize_pt2_e0_denominator
.. code:: text
logical :: initialize_pt2_e0_denominator
File: :file:`energy.irp.f`
If true, initialize pt2_E0_denominator
.. c:var:: pt2_collector
.. code:: text
subroutine pt2_collector(zmq_socket_pull, E, relative_error, pt2, error, &
variance, norm, b, N_)
File: :file:`pt2_stoch_routines.irp.f`
.. c:var:: pt2_cw
.. code:: text
double precision, allocatable :: pt2_w (N_det_generators)
double precision, allocatable :: pt2_cw (0:N_det_generators)
double precision :: pt2_w_t
double precision :: pt2_u_0
integer, allocatable :: pt2_n_0 (pt2_N_teeth+1)
File: :file:`pt2_stoch_routines.irp.f`
.. c:var:: pt2_e0_denominator
.. code:: text
double precision, allocatable :: pt2_e0_denominator (N_states)
File: :file:`energy.irp.f`
E0 in the denominator of the PT2
.. c:var:: pt2_f
.. code:: text
integer, allocatable :: pt2_f (N_det_generators)
integer :: pt2_n_tasks_max
File: :file:`pt2_stoch_routines.irp.f`
.. c:var:: pt2_j
.. code:: text
integer, allocatable :: pt2_j (N_det_generators)
integer, allocatable :: pt2_r (N_det_generators)
File: :file:`pt2_stoch_routines.irp.f`
.. c:var:: pt2_mindetinfirstteeth
.. code:: text
integer :: pt2_n_teeth
integer :: pt2_mindetinfirstteeth
File: :file:`pt2_stoch_routines.irp.f`
.. c:var:: pt2_n_0
.. code:: text
double precision, allocatable :: pt2_w (N_det_generators)
double precision, allocatable :: pt2_cw (0:N_det_generators)
double precision :: pt2_w_t
double precision :: pt2_u_0
integer, allocatable :: pt2_n_0 (pt2_N_teeth+1)
File: :file:`pt2_stoch_routines.irp.f`
.. c:var:: pt2_n_tasks
.. code:: text
integer :: pt2_n_tasks
File: :file:`pt2_stoch_routines.irp.f`
Number of parallel tasks for the Monte Carlo
.. c:var:: pt2_n_tasks_max
.. code:: text
integer, allocatable :: pt2_f (N_det_generators)
integer :: pt2_n_tasks_max
File: :file:`pt2_stoch_routines.irp.f`
.. c:var:: pt2_n_teeth
.. code:: text
integer :: pt2_n_teeth
integer :: pt2_mindetinfirstteeth
File: :file:`pt2_stoch_routines.irp.f`
.. c:var:: pt2_r
.. code:: text
integer, allocatable :: pt2_j (N_det_generators)
integer, allocatable :: pt2_r (N_det_generators)
File: :file:`pt2_stoch_routines.irp.f`
.. c:var:: pt2_stoch_istate
.. code:: text
integer :: pt2_stoch_istate
File: :file:`pt2_stoch_routines.irp.f`
State for stochatsic PT2
.. c:var:: pt2_u
.. code:: text
double precision, allocatable :: pt2_u (N_det_generators)
File: :file:`pt2_stoch_routines.irp.f`
.. c:var:: pt2_u_0
.. code:: text
double precision, allocatable :: pt2_w (N_det_generators)
double precision, allocatable :: pt2_cw (0:N_det_generators)
double precision :: pt2_w_t
double precision :: pt2_u_0
integer, allocatable :: pt2_n_0 (pt2_N_teeth+1)
File: :file:`pt2_stoch_routines.irp.f`
.. c:var:: pt2_w
.. code:: text
double precision, allocatable :: pt2_w (N_det_generators)
double precision, allocatable :: pt2_cw (0:N_det_generators)
double precision :: pt2_w_t
double precision :: pt2_u_0
integer, allocatable :: pt2_n_0 (pt2_N_teeth+1)
File: :file:`pt2_stoch_routines.irp.f`
.. c:var:: pt2_w_t
.. code:: text
double precision, allocatable :: pt2_w (N_det_generators)
double precision, allocatable :: pt2_cw (0:N_det_generators)
double precision :: pt2_w_t
double precision :: pt2_u_0
integer, allocatable :: pt2_n_0 (pt2_N_teeth+1)
File: :file:`pt2_stoch_routines.irp.f`
.. c:var:: selection_weight
.. code:: text
double precision, allocatable :: selection_weight (N_states)
File: :file:`selection.irp.f`
Weights in the state-average calculation of the density matrix
Subroutines / functions
-----------------------
.. c:function:: add_to_selection_buffer
.. code:: text
subroutine add_to_selection_buffer(b, det, val)
File: :file:`selection_buffer.irp.f`
.. c:function:: bitstring_to_list_in_selection
.. code:: text
subroutine bitstring_to_list_in_selection( string, list, n_elements, Nint)
File: :file:`selection.irp.f`
Gives the inidices(+1) of the bits set to 1 in the bit string
.. c:function:: create_selection_buffer
.. code:: text
subroutine create_selection_buffer(N, siz_, res)
File: :file:`selection_buffer.irp.f`
.. c:function:: delete_selection_buffer
.. code:: text
subroutine delete_selection_buffer(b)
File: :file:`selection_buffer.irp.f`
.. c:function:: fill_buffer_double
.. code:: text
subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_diag_tmp, E0, pt2, variance, norm, mat, buf)
File: :file:`selection.irp.f`
.. c:function:: get_d0
.. code:: text
subroutine get_d0(gen, phasemask, bannedOrb, banned, mat, mask, h, p, sp, coefs)
File: :file:`selection.irp.f`
.. c:function:: get_d1
.. code:: text
subroutine get_d1(gen, phasemask, bannedOrb, banned, mat, mask, h, p, sp, coefs)
File: :file:`selection.irp.f`
.. c:function:: get_d2
.. code:: text
subroutine get_d2(gen, phasemask, bannedOrb, banned, mat, mask, h, p, sp, coefs)
File: :file:`selection.irp.f`
.. c:function:: get_m0
.. code:: text
subroutine get_m0(gen, phasemask, bannedOrb, vect, mask, h, p, sp, coefs)
File: :file:`selection.irp.f`
.. c:function:: get_m1
.. code:: text
subroutine get_m1(gen, phasemask, bannedOrb, vect, mask, h, p, sp, coefs)
File: :file:`selection.irp.f`
.. c:function:: get_m2
.. code:: text
subroutine get_m2(gen, phasemask, bannedOrb, vect, mask, h, p, sp, coefs)
File: :file:`selection.irp.f`
.. c:function:: get_mask_phase
.. code:: text
subroutine get_mask_phase(det1, pm, Nint)
File: :file:`selection.irp.f`
.. c:function:: get_phase_bi
.. code:: text
double precision function get_phase_bi(phasemask, s1, s2, h1, p1, h2, p2, Nint)
File: :file:`selection.irp.f`
.. c:function:: make_selection_buffer_s2
.. code:: text
subroutine make_selection_buffer_s2(b)
File: :file:`selection_buffer.irp.f`
.. c:function:: merge_selection_buffers
.. code:: text
subroutine merge_selection_buffers(b1, b2)
File: :file:`selection_buffer.irp.f`
Merges the selection buffers b1 and b2 into b2
.. c:function:: past_d1
.. code:: text
subroutine past_d1(bannedOrb, p)
File: :file:`selection.irp.f`
.. c:function:: past_d2
.. code:: text
subroutine past_d2(banned, p, sp)
File: :file:`selection.irp.f`
.. c:function:: provide_everything
.. code:: text
subroutine provide_everything
File: :file:`slave_cipsi.irp.f`
.. c:function:: pt2_find_sample
.. code:: text
integer function pt2_find_sample(v, w)
File: :file:`pt2_stoch_routines.irp.f`
.. c:function:: pt2_find_sample_lr
.. code:: text
integer function pt2_find_sample_lr(v, w, l_in, r_in)
File: :file:`pt2_stoch_routines.irp.f`
.. c:function:: pt2_slave_inproc
.. code:: text
subroutine pt2_slave_inproc(i)
File: :file:`pt2_stoch_routines.irp.f`
.. c:function:: pull_pt2_results
.. code:: text
subroutine pull_pt2_results(zmq_socket_pull, index, pt2, variance, norm, task_id, n_tasks, b)
File: :file:`run_pt2_slave.irp.f`
.. c:function:: pull_selection_results
.. code:: text
subroutine pull_selection_results(zmq_socket_pull, pt2, variance, norm, val, det, N, task_id, ntask)
File: :file:`run_selection_slave.irp.f`
.. c:function:: push_pt2_results
.. code:: text
subroutine push_pt2_results(zmq_socket_push, index, pt2, variance, norm, b, task_id, n_tasks)
File: :file:`run_pt2_slave.irp.f`
.. c:function:: push_selection_results
.. code:: text
subroutine push_selection_results(zmq_socket_push, pt2, variance, norm, b, task_id, ntask)
File: :file:`run_selection_slave.irp.f`
.. c:function:: run_cipsi
.. code:: text
subroutine run_cipsi
File: :file:`cipsi.irp.f`
Selected Full Configuration Interaction with deterministic selection and stochastic PT2.
.. c:function:: run_pt2_slave
.. code:: text
subroutine run_pt2_slave(thread,iproc,energy)
File: :file:`run_pt2_slave.irp.f`
.. c:function:: run_selection_slave
.. code:: text
subroutine run_selection_slave(thread,iproc,energy)
File: :file:`run_selection_slave.irp.f`
.. c:function:: run_slave_cipsi
.. code:: text
subroutine run_slave_cipsi
File: :file:`slave_cipsi.irp.f`
Helper program for distributed parallelism
.. c:function:: run_slave_main
.. code:: text
subroutine run_slave_main
File: :file:`slave_cipsi.irp.f`
.. c:function:: run_stochastic_cipsi
.. code:: text
subroutine run_stochastic_cipsi
File: :file:`stochastic_cipsi.irp.f`
Selected Full Configuration Interaction with Stochastic selection and PT2.
.. c:function:: select_connected
.. code:: text
subroutine select_connected(i_generator,E0,pt2,variance,norm,b,subset,csubset)
File: :file:`selection.irp.f`
.. c:function:: select_singles_and_doubles
.. code:: text
subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_diag_tmp,E0,pt2,variance,norm,buf,subset,csubset)
File: :file:`selection.irp.f`
WARNING /!\ : It is assumed that the generators and selectors are psi_det_sorted
.. c:function:: selection_collector
.. code:: text
subroutine selection_collector(zmq_socket_pull, b, N, pt2, variance, norm)
File: :file:`zmq_selection.irp.f`
.. c:function:: selection_slave_inproc
.. code:: text
subroutine selection_slave_inproc(i)
File: :file:`zmq_selection.irp.f`
.. c:function:: sort_selection_buffer
.. code:: text
subroutine sort_selection_buffer(b)
File: :file:`selection_buffer.irp.f`
.. c:function:: splash_pq
.. code:: text
subroutine splash_pq(mask, sp, det, i_gen, N_sel, bannedOrb, banned, mat, interesting)
File: :file:`selection.irp.f`
.. c:function:: spot_isinwf
.. code:: text
subroutine spot_isinwf(mask, det, i_gen, N, banned, fullMatch, interesting)
File: :file:`selection.irp.f`
.. c:function:: testteethbuilding
.. code:: text
logical function testTeethBuilding(minF, N)
File: :file:`pt2_stoch_routines.irp.f`
.. c:function:: zmq_pt2
.. code:: text
subroutine ZMQ_pt2(E, pt2,relative_error, error, variance, norm, N_in)
File: :file:`pt2_stoch_routines.irp.f`
.. c:function:: zmq_selection
.. code:: text
subroutine ZMQ_selection(N_in, pt2, variance, norm)
File: :file:`zmq_selection.irp.f`

View File

@ -8,113 +8,16 @@
fci
===
Selected Full Configuration Interaction.
|CIPSI| algorithm in the full configuration interaction space.
The :command:`FCI` program starts with a single determinant, or with the wave
function in the |EZFIO| database if :option:`determinants read_wf` is |true|.
Then, it will iteratively:
* :command:`fci` performs the |CIPSI| calculation,
* :command:`pt2` computes the |PT2| contribution using the wave function stored in the |EZFIO|
database.
* Select the most important determinants from the external space and add them to the
internal space
* If :option:`determinants s2_eig` is |true|, add all the necessary
determinants to allow the eigenstates of |H| to be eigenstates of |S^2|
* Diagonalize |H| in the enlarged internal space
* Compute (stochastically) the second-order perturbative contribution to the energy
* Extrapolate the variational energy by fitting
:math:`E=E_\text{FCI} - \alpha\, E_\text{PT2}`
.. seealso::
The documentation of the :ref:`cipsi` module.
The number of selected determinants at each iteration will be such that the
size of the wave function will double at every iteration. If :option:`determinants
s2_eig` is |true|, then the number of selected determinants will be 1.5x the
current number, and then all the additional determinants will be added.
By default, the program will stop when more than one million determinants have
been selected, or when the |PT2| energy is below :math:`10^{-4}`.
The variational and |PT2| energies of the iterations are stored in the
|EZFIO| database, in the :ref:`iterations` module.
Computation of the |PT2| energy
-------------------------------
At each iteration, the |PT2| energy is computed considering the Epstein-Nesbet
zeroth-order Hamiltonian:
.. math::
E_{\text{PT2}} = \sum_{ \alpha }
\frac{|\langle \Psi_S | \hat{H} | \alpha \rangle|^2}
{E - \langle \alpha | \hat{H} | \alpha \rangle}
where the |kalpha| determinants are generated by applying all the single and
double excitation operators to all the determinants of the wave function
:math:`\Psi_G`.
When the hybrid-deterministic/stochastic algorithm is chosen
(default), :math:`Psi_G = \Psi_S = \Psi`, the full wavefunction expanded in the
internal space.
When the deterministic algorithm is chosen (:option:`perturbation do_pt2`
is set to |false|), :math:`Psi_G` is a truncation of |Psi| using
:option:`determinants threshold_generators`, and :math:`Psi_S` is a truncation
of |Psi| using :option:`determinants threshold_selectors`, and re-weighted
by :math:`1/\langle \Psi_s | \Psi_s \rangle`.
At every iteration, while computing the |PT2|, the variance of the wave
function is also computed:
.. math::
\sigma^2 & = \langle \Psi | \hat{H}^2 | \Psi \rangle -
\langle \Psi | \hat{H} | \Psi \rangle^2 \\
& = \sum_{i \in \text{FCI}}
\langle \Psi | \hat{H} | i \rangle
\langle i | \hat{H} | \Psi \rangle -
\langle \Psi | \hat{H} | \Psi \rangle^2 \\
& = \sum_{ \alpha }
\langle |\Psi | \hat{H} | \alpha \rangle|^2.
The expression of the variance is the same as the expression of the |PT2|, with
a denominator of 1. It measures how far the wave function is from the |FCI|
solution. Note that the absence of denominator in the Heat-Bath selected |CI|
method is selection method by minimization of the variance, whereas |CIPSI| is
a selection method by minimization of the energy.
If :option:`perturbation do_pt2` is set to |false|, then the stochastic
|PT2| is not computed, and an approximate value is obtained from the |CIPSI|
selection. The calculation is faster, but the extrapolated |FCI| value is
less accurate. This way of running the code should be used when the only
goal is to generate a wave function, as for using |CIPSI| wave functions as
trial wave functions of |QMC| calculations for example.
The :command:`PT2` program reads the wave function of the |EZFIO| database
and computes the energy and the |PT2| contribution.
State-averaging
---------------
Extrapolated |FCI| energy
-------------------------
An estimate of the |FCI| energy is computed by extrapolating
.. math::
E=E_\text{FCI} - \alpha\, E_\text{PT2}
This extrapolation is done for all the requested states, and excitation
energies are printed as energy differences between the extrapolated
energies of the excited states and the extrapolated energy of the ground
state.
The extrapolations are given considering the 2 last points, the 3 last points, ...,
the 7 last points. The extrapolated value should be chosen such that the extrpolated
value is stable with the number of points.
@ -133,305 +36,11 @@ EZFIO parameters
Providers
---------
.. c:var:: initialize_pt2_e0_denominator
.. code:: text
logical :: initialize_pt2_e0_denominator
File: :file:`energy.irp.f`
If true, initialize pt2_E0_denominator
.. c:var:: pt2_cw
.. code:: text
double precision, allocatable :: pt2_w (N_det_generators)
double precision, allocatable :: pt2_cw (0:N_det_generators)
double precision :: pt2_w_t
double precision :: pt2_u_0
integer, allocatable :: pt2_n_0 (pt2_N_teeth+1)
File: :file:`pt2_stoch_routines.irp.f`
.. c:var:: pt2_e0_denominator
.. code:: text
double precision, allocatable :: pt2_e0_denominator (N_states)
File: :file:`energy.irp.f`
E0 in the denominator of the PT2
.. c:var:: pt2_f
.. code:: text
integer, allocatable :: pt2_f (N_det_generators)
integer :: pt2_n_tasks_max
File: :file:`pt2_stoch_routines.irp.f`
.. c:var:: pt2_j
.. code:: text
integer, allocatable :: pt2_j (N_det_generators)
integer, allocatable :: pt2_r (N_det_generators)
File: :file:`pt2_stoch_routines.irp.f`
.. c:var:: pt2_mindetinfirstteeth
.. code:: text
integer :: pt2_n_teeth
integer :: pt2_mindetinfirstteeth
File: :file:`pt2_stoch_routines.irp.f`
.. c:var:: pt2_n_0
.. code:: text
double precision, allocatable :: pt2_w (N_det_generators)
double precision, allocatable :: pt2_cw (0:N_det_generators)
double precision :: pt2_w_t
double precision :: pt2_u_0
integer, allocatable :: pt2_n_0 (pt2_N_teeth+1)
File: :file:`pt2_stoch_routines.irp.f`
.. c:var:: pt2_n_tasks
.. code:: text
integer :: pt2_n_tasks
File: :file:`pt2_stoch_routines.irp.f`
Number of parallel tasks for the Monte Carlo
.. c:var:: pt2_n_tasks_max
.. code:: text
integer, allocatable :: pt2_f (N_det_generators)
integer :: pt2_n_tasks_max
File: :file:`pt2_stoch_routines.irp.f`
.. c:var:: pt2_n_teeth
.. code:: text
integer :: pt2_n_teeth
integer :: pt2_mindetinfirstteeth
File: :file:`pt2_stoch_routines.irp.f`
.. c:var:: pt2_r
.. code:: text
integer, allocatable :: pt2_j (N_det_generators)
integer, allocatable :: pt2_r (N_det_generators)
File: :file:`pt2_stoch_routines.irp.f`
.. c:var:: pt2_stoch_istate
.. code:: text
integer :: pt2_stoch_istate
File: :file:`pt2_stoch_routines.irp.f`
State for stochatsic PT2
.. c:var:: pt2_u
.. code:: text
double precision, allocatable :: pt2_u (N_det_generators)
File: :file:`pt2_stoch_routines.irp.f`
.. c:var:: pt2_u_0
.. code:: text
double precision, allocatable :: pt2_w (N_det_generators)
double precision, allocatable :: pt2_cw (0:N_det_generators)
double precision :: pt2_w_t
double precision :: pt2_u_0
integer, allocatable :: pt2_n_0 (pt2_N_teeth+1)
File: :file:`pt2_stoch_routines.irp.f`
.. c:var:: pt2_w
.. code:: text
double precision, allocatable :: pt2_w (N_det_generators)
double precision, allocatable :: pt2_cw (0:N_det_generators)
double precision :: pt2_w_t
double precision :: pt2_u_0
integer, allocatable :: pt2_n_0 (pt2_N_teeth+1)
File: :file:`pt2_stoch_routines.irp.f`
.. c:var:: pt2_w_t
.. code:: text
double precision, allocatable :: pt2_w (N_det_generators)
double precision, allocatable :: pt2_cw (0:N_det_generators)
double precision :: pt2_w_t
double precision :: pt2_u_0
integer, allocatable :: pt2_n_0 (pt2_N_teeth+1)
File: :file:`pt2_stoch_routines.irp.f`
Subroutines / functions
-----------------------
.. c:function:: add_to_selection_buffer
.. code:: text
subroutine add_to_selection_buffer(b, det, val)
File: :file:`selection_buffer.irp.f`
.. c:function:: bitstring_to_list_in_selection
.. code:: text
subroutine bitstring_to_list_in_selection( string, list, n_elements, Nint)
File: :file:`selection.irp.f`
Gives the inidices(+1) of the bits set to 1 in the bit string
.. c:function:: create_selection_buffer
.. code:: text
subroutine create_selection_buffer(N, siz_, res)
File: :file:`selection_buffer.irp.f`
.. c:function:: delete_selection_buffer
.. code:: text
subroutine delete_selection_buffer(b)
File: :file:`selection_buffer.irp.f`
.. c:function:: fci
.. code:: text
@ -440,189 +49,7 @@ Subroutines / functions
File: :file:`fci.irp.f`
Selected Full Configuration Interaction.
.. c:function:: fill_buffer_double
.. code:: text
subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_diag_tmp, E0, pt2, variance, norm, mat, buf)
File: :file:`selection.irp.f`
.. c:function:: get_d0
.. code:: text
subroutine get_d0(gen, phasemask, bannedOrb, banned, mat, mask, h, p, sp, coefs)
File: :file:`selection.irp.f`
.. c:function:: get_d1
.. code:: text
subroutine get_d1(gen, phasemask, bannedOrb, banned, mat, mask, h, p, sp, coefs)
File: :file:`selection.irp.f`
.. c:function:: get_d2
.. code:: text
subroutine get_d2(gen, phasemask, bannedOrb, banned, mat, mask, h, p, sp, coefs)
File: :file:`selection.irp.f`
.. c:function:: get_m0
.. code:: text
subroutine get_m0(gen, phasemask, bannedOrb, vect, mask, h, p, sp, coefs)
File: :file:`selection.irp.f`
.. c:function:: get_m1
.. code:: text
subroutine get_m1(gen, phasemask, bannedOrb, vect, mask, h, p, sp, coefs)
File: :file:`selection.irp.f`
.. c:function:: get_m2
.. code:: text
subroutine get_m2(gen, phasemask, bannedOrb, vect, mask, h, p, sp, coefs)
File: :file:`selection.irp.f`
.. c:function:: get_mask_phase
.. code:: text
subroutine get_mask_phase(det1, pm, Nint)
File: :file:`selection.irp.f`
.. c:function:: get_phase_bi
.. code:: text
double precision function get_phase_bi(phasemask, s1, s2, h1, p1, h2, p2, Nint)
File: :file:`selection.irp.f`
.. c:function:: make_selection_buffer_s2
.. code:: text
subroutine make_selection_buffer_s2(b)
File: :file:`selection_buffer.irp.f`
.. c:function:: merge_selection_buffers
.. code:: text
subroutine merge_selection_buffers(b1, b2)
File: :file:`selection_buffer.irp.f`
Merges the selection buffers b1 and b2 into b2
.. c:function:: past_d1
.. code:: text
subroutine past_d1(bannedOrb, p)
File: :file:`selection.irp.f`
.. c:function:: past_d2
.. code:: text
subroutine past_d2(banned, p, sp)
File: :file:`selection.irp.f`
Selected Full Configuration Interaction with stochastic selection and PT2.
@ -642,280 +69,14 @@ Subroutines / functions
.. c:function:: pt2_collector
.. c:function:: save_energy
.. code:: text
subroutine pt2_collector(zmq_socket_pull, E, relative_error, pt2, error, variance, norm)
subroutine save_energy(E,pt2)
File: :file:`pt2_stoch_routines.irp.f`
File: :file:`save_energy.irp.f`
.. c:function:: pt2_find_sample
.. code:: text
integer function pt2_find_sample(v, w)
File: :file:`pt2_stoch_routines.irp.f`
.. c:function:: pt2_find_sample_lr
.. code:: text
integer function pt2_find_sample_lr(v, w, l_in, r_in)
File: :file:`pt2_stoch_routines.irp.f`
.. c:function:: pt2_slave_inproc
.. code:: text
subroutine pt2_slave_inproc(i)
File: :file:`pt2_stoch_routines.irp.f`
.. c:function:: pull_pt2_results
.. code:: text
subroutine pull_pt2_results(zmq_socket_pull, index, pt2, variance, norm, task_id, n_tasks)
File: :file:`run_pt2_slave.irp.f`
.. c:function:: pull_selection_results
.. code:: text
subroutine pull_selection_results(zmq_socket_pull, pt2, variance, norm, val, det, N, task_id, ntask)
File: :file:`run_selection_slave.irp.f`
.. c:function:: push_pt2_results
.. code:: text
subroutine push_pt2_results(zmq_socket_push, index, pt2, variance, norm, task_id, n_tasks)
File: :file:`run_pt2_slave.irp.f`
.. c:function:: push_selection_results
.. code:: text
subroutine push_selection_results(zmq_socket_push, pt2, variance, norm, b, task_id, ntask)
File: :file:`run_selection_slave.irp.f`
.. c:function:: run_pt2_slave
.. code:: text
subroutine run_pt2_slave(thread,iproc,energy)
File: :file:`run_pt2_slave.irp.f`
.. c:function:: run_selection_slave
.. code:: text
subroutine run_selection_slave(thread,iproc,energy)
File: :file:`run_selection_slave.irp.f`
.. c:function:: select_connected
.. code:: text
subroutine select_connected(i_generator,E0,pt2,variance,norm,b,subset,csubset)
File: :file:`selection.irp.f`
.. c:function:: select_singles_and_doubles
.. code:: text
subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_diag_tmp,E0,pt2,variance,norm,buf,subset,csubset)
File: :file:`selection.irp.f`
WARNING /!\ : It is assumed that the generators and selectors are psi_det_sorted
.. c:function:: selection_collector
.. code:: text
subroutine selection_collector(zmq_socket_pull, b, N, pt2, variance, norm)
File: :file:`zmq_selection.irp.f`
.. c:function:: selection_slave_inproc
.. code:: text
subroutine selection_slave_inproc(i)
File: :file:`zmq_selection.irp.f`
.. c:function:: sort_selection_buffer
.. code:: text
subroutine sort_selection_buffer(b)
File: :file:`selection_buffer.irp.f`
.. c:function:: splash_pq
.. code:: text
subroutine splash_pq(mask, sp, det, i_gen, N_sel, bannedOrb, banned, mat, interesting)
File: :file:`selection.irp.f`
.. c:function:: spot_isinwf
.. code:: text
subroutine spot_isinwf(mask, det, i_gen, N, banned, fullMatch, interesting)
File: :file:`selection.irp.f`
.. c:function:: testteethbuilding
.. code:: text
logical function testTeethBuilding(minF, N)
File: :file:`pt2_stoch_routines.irp.f`
.. c:function:: zmq_pt2
.. code:: text
subroutine ZMQ_pt2(E, pt2,relative_error, error, variance, norm)
File: :file:`pt2_stoch_routines.irp.f`
.. c:function:: zmq_selection
.. code:: text
subroutine ZMQ_selection(N_in, pt2, variance, norm)
File: :file:`zmq_selection.irp.f`
Saves the energy in |EZFIO|.

View File

@ -63,79 +63,6 @@ Providers
---------
.. c:var:: ao_two_e_integral_alpha
.. code:: text
double precision, allocatable :: ao_two_e_integral_alpha (ao_num,ao_num)
double precision, allocatable :: ao_two_e_integral_beta (ao_num,ao_num)
File: :file:`fock_matrix_hf.irp.f`
Alpha Fock matrix in AO basis set
.. c:var:: ao_two_e_integral_beta
.. code:: text
double precision, allocatable :: ao_two_e_integral_alpha (ao_num,ao_num)
double precision, allocatable :: ao_two_e_integral_beta (ao_num,ao_num)
File: :file:`fock_matrix_hf.irp.f`
Alpha Fock matrix in AO basis set
.. c:var:: extra_e_contrib_density
.. code:: text
double precision :: extra_e_contrib_density
File: :file:`hf_energy.irp.f`
Extra contribution to the SCF energy coming from the density.
For a Hartree-Fock calculation: extra_e_contrib_density = 0
For a Kohn-Sham or Range-separated Kohn-Sham: the exchange/correlation - trace of the V_xc potential
.. c:var:: fock_matrix_ao_alpha
.. code:: text
double precision, allocatable :: fock_matrix_ao_alpha (ao_num,ao_num)
double precision, allocatable :: fock_matrix_ao_beta (ao_num,ao_num)
File: :file:`fock_matrix_hf.irp.f`
Alpha Fock matrix in AO basis set
.. c:var:: fock_matrix_ao_beta
.. code:: text
double precision, allocatable :: fock_matrix_ao_alpha (ao_num,ao_num)
double precision, allocatable :: fock_matrix_ao_beta (ao_num,ao_num)
File: :file:`fock_matrix_hf.irp.f`
Alpha Fock matrix in AO basis set
.. c:var:: hf_energy
.. code:: text
@ -186,34 +113,6 @@ Subroutines / functions
.. c:function:: create_guess
.. code:: text
subroutine create_guess
File: :file:`scf.irp.f`
Create a MO guess if no MOs are present in the EZFIO directory
.. c:function:: run
.. code:: text
subroutine run
File: :file:`scf.irp.f`
Run SCF calculation
.. c:function:: scf
.. code:: text

View File

@ -77,7 +77,7 @@ Subroutines / functions
.. code:: text
subroutine print_extrapolated_energy(e_,pt2_)
subroutine print_extrapolated_energy
File: :file:`print_extrapolation.irp.f`
@ -91,7 +91,7 @@ Subroutines / functions
.. code:: text
subroutine print_summary(e_,pt2_,error_,variance_,norm_)
subroutine print_summary(e_,pt2_,error_,variance_,norm_,n_det_,n_occ_pattern_)
File: :file:`print_summary.irp.f`

View File

@ -52,6 +52,178 @@ Providers
---------
.. c:var:: ao_potential_alpha_xc
.. code:: text
double precision, allocatable :: ao_potential_alpha_xc (ao_num,ao_num)
double precision, allocatable :: ao_potential_beta_xc (ao_num,ao_num)
File: :file:`pot_functionals.irp.f`
.. c:var:: ao_potential_beta_xc
.. code:: text
double precision, allocatable :: ao_potential_alpha_xc (ao_num,ao_num)
double precision, allocatable :: ao_potential_beta_xc (ao_num,ao_num)
File: :file:`pot_functionals.irp.f`
.. c:var:: ao_two_e_integral_alpha
.. code:: text
double precision, allocatable :: ao_two_e_integral_alpha (ao_num,ao_num)
double precision, allocatable :: ao_two_e_integral_beta (ao_num,ao_num)
File: :file:`fock_matrix_ks.irp.f`
Alpha Fock matrix in ao basis set
.. c:var:: ao_two_e_integral_beta
.. code:: text
double precision, allocatable :: ao_two_e_integral_alpha (ao_num,ao_num)
double precision, allocatable :: ao_two_e_integral_beta (ao_num,ao_num)
File: :file:`fock_matrix_ks.irp.f`
Alpha Fock matrix in ao basis set
.. c:var:: e_correlation_dft
.. code:: text
double precision :: e_correlation_dft
File: :file:`pot_functionals.irp.f`
.. c:var:: e_exchange_dft
.. code:: text
double precision :: e_exchange_dft
File: :file:`pot_functionals.irp.f`
.. c:var:: extra_e_contrib_density
.. code:: text
double precision :: extra_e_contrib_density
File: :file:`ks_enery.irp.f`
Extra contribution to the SCF energy coming from the density.
For a Hartree-Fock calculation: extra_e_contrib_density = 0
For a Kohn-Sham or Range-separated Kohn-Sham: the exchange/correlation - 1/2 trace of the V_xc potential
.. c:var:: fock_matrix_alpha_no_xc_ao
.. code:: text
double precision, allocatable :: fock_matrix_alpha_no_xc_ao (ao_num,ao_num)
double precision, allocatable :: fock_matrix_beta_no_xc_ao (ao_num,ao_num)
File: :file:`fock_matrix_ks.irp.f`
Mono electronic an Coulomb matrix in ao basis set
.. c:var:: fock_matrix_ao_alpha
.. code:: text
double precision, allocatable :: fock_matrix_ao_alpha (ao_num,ao_num)
double precision, allocatable :: fock_matrix_ao_beta (ao_num,ao_num)
File: :file:`fock_matrix_ks.irp.f`
Alpha Fock matrix in ao basis set
.. c:var:: fock_matrix_ao_beta
.. code:: text
double precision, allocatable :: fock_matrix_ao_alpha (ao_num,ao_num)
double precision, allocatable :: fock_matrix_ao_beta (ao_num,ao_num)
File: :file:`fock_matrix_ks.irp.f`
Alpha Fock matrix in ao basis set
.. c:var:: fock_matrix_beta_no_xc_ao
.. code:: text
double precision, allocatable :: fock_matrix_alpha_no_xc_ao (ao_num,ao_num)
double precision, allocatable :: fock_matrix_beta_no_xc_ao (ao_num,ao_num)
File: :file:`fock_matrix_ks.irp.f`
Mono electronic an Coulomb matrix in ao basis set
.. c:var:: fock_matrix_energy
.. code:: text
double precision :: ks_energy
double precision :: two_electron_energy
double precision :: one_electron_energy
double precision :: fock_matrix_energy
double precision :: trace_potential_xc
File: :file:`ks_enery.irp.f`
Kohn-Sham energy containing the nuclear repulsion energy, and the various components of this quantity.
.. c:var:: ks_energy
.. code:: text
@ -69,11 +241,104 @@ Providers
.. c:var:: one_electron_energy
.. code:: text
double precision :: ks_energy
double precision :: two_electron_energy
double precision :: one_electron_energy
double precision :: fock_matrix_energy
double precision :: trace_potential_xc
File: :file:`ks_enery.irp.f`
Kohn-Sham energy containing the nuclear repulsion energy, and the various components of this quantity.
.. c:var:: trace_potential_xc
.. code:: text
double precision :: ks_energy
double precision :: two_electron_energy
double precision :: one_electron_energy
double precision :: fock_matrix_energy
double precision :: trace_potential_xc
File: :file:`ks_enery.irp.f`
Kohn-Sham energy containing the nuclear repulsion energy, and the various components of this quantity.
.. c:var:: two_electron_energy
.. code:: text
double precision :: ks_energy
double precision :: two_electron_energy
double precision :: one_electron_energy
double precision :: fock_matrix_energy
double precision :: trace_potential_xc
File: :file:`ks_enery.irp.f`
Kohn-Sham energy containing the nuclear repulsion energy, and the various components of this quantity.
Subroutines / functions
-----------------------
.. c:function:: check_coherence_functional
.. code:: text
subroutine check_coherence_functional
File: :file:`ks_scf.irp.f`
.. c:function:: create_guess
.. code:: text
subroutine create_guess
File: :file:`ks_scf.irp.f`
Create a MO guess if no MOs are present in the EZFIO directory
.. c:function:: run
.. code:: text
subroutine run
File: :file:`ks_scf.irp.f`
Run SCF calculation
.. c:function:: srs_ks_cf
.. code:: text

View File

@ -60,122 +60,6 @@ Providers
---------
.. c:var:: ao_potential_alpha_xc
.. code:: text
double precision, allocatable :: ao_potential_alpha_xc (ao_num,ao_num)
double precision, allocatable :: ao_potential_beta_xc (ao_num,ao_num)
File: :file:`pot_functionals.irp.f`
.. c:var:: ao_potential_beta_xc
.. code:: text
double precision, allocatable :: ao_potential_alpha_xc (ao_num,ao_num)
double precision, allocatable :: ao_potential_beta_xc (ao_num,ao_num)
File: :file:`pot_functionals.irp.f`
.. c:var:: e_correlation_dft
.. code:: text
double precision :: e_correlation_dft
File: :file:`pot_functionals.irp.f`
.. c:var:: e_exchange_dft
.. code:: text
double precision :: e_exchange_dft
File: :file:`pot_functionals.irp.f`
.. c:var:: fock_matrix_alpha_no_xc_ao
.. code:: text
double precision, allocatable :: fock_matrix_alpha_no_xc_ao (ao_num,ao_num)
double precision, allocatable :: fock_matrix_beta_no_xc_ao (ao_num,ao_num)
File: :file:`fock_matrix_rs_ks.irp.f`
Mono electronic an Coulomb matrix in AO basis set
.. c:var:: fock_matrix_beta_no_xc_ao
.. code:: text
double precision, allocatable :: fock_matrix_alpha_no_xc_ao (ao_num,ao_num)
double precision, allocatable :: fock_matrix_beta_no_xc_ao (ao_num,ao_num)
File: :file:`fock_matrix_rs_ks.irp.f`
Mono electronic an Coulomb matrix in AO basis set
.. c:var:: fock_matrix_energy
.. code:: text
double precision :: rs_ks_energy
double precision :: two_electron_energy
double precision :: one_electron_energy
double precision :: fock_matrix_energy
double precision :: trace_potential_xc
File: :file:`rs_ks_energy.irp.f`
Range-separated Kohn-Sham energy containing the nuclear repulsion energy, and the various components of this quantity.
.. c:var:: one_electron_energy
.. code:: text
double precision :: rs_ks_energy
double precision :: two_electron_energy
double precision :: one_electron_energy
double precision :: fock_matrix_energy
double precision :: trace_potential_xc
File: :file:`rs_ks_energy.irp.f`
Range-separated Kohn-Sham energy containing the nuclear repulsion energy, and the various components of this quantity.
.. c:var:: rs_ks_energy
.. code:: text
@ -193,59 +77,11 @@ Providers
.. c:var:: trace_potential_xc
.. code:: text
double precision :: rs_ks_energy
double precision :: two_electron_energy
double precision :: one_electron_energy
double precision :: fock_matrix_energy
double precision :: trace_potential_xc
File: :file:`rs_ks_energy.irp.f`
Range-separated Kohn-Sham energy containing the nuclear repulsion energy, and the various components of this quantity.
.. c:var:: two_electron_energy
.. code:: text
double precision :: rs_ks_energy
double precision :: two_electron_energy
double precision :: one_electron_energy
double precision :: fock_matrix_energy
double precision :: trace_potential_xc
File: :file:`rs_ks_energy.irp.f`
Range-separated Kohn-Sham energy containing the nuclear repulsion energy, and the various components of this quantity.
Subroutines / functions
-----------------------
.. c:function:: check_coherence_functional
.. code:: text
subroutine check_coherence_functional
File: :file:`rs_ks_scf.irp.f`
.. c:function:: rs_ks_scf
.. code:: text

View File

@ -245,6 +245,20 @@ Subroutines / functions
.. c:function:: perturb_buffer_by_mono_epstein_nesbet_2x2_no_ci_diag
.. code:: text
subroutine perturb_buffer_by_mono_epstein_nesbet_2x2_no_ci_diag(i_generator,buffer,buffer_size,e_2_pert_buffer,coef_pert_buffer,sum_e_2_pert,sum_norm_pert,sum_H_pert_diag,N_st,Nint,key_mask,fock_diag_tmp,electronic_energy)
File: :file:`perturbation.irp.f_shell_13`
Applly pertubration ``epstein_nesbet_2x2_no_ci_diag`` to the buffer of determinants generated in the H_apply routine.
.. c:function:: perturb_buffer_by_mono_h_core
.. code:: text
@ -343,6 +357,20 @@ Subroutines / functions
.. c:function:: perturb_buffer_epstein_nesbet_2x2_no_ci_diag
.. code:: text
subroutine perturb_buffer_epstein_nesbet_2x2_no_ci_diag(i_generator,buffer,buffer_size,e_2_pert_buffer,coef_pert_buffer,sum_e_2_pert,sum_norm_pert,sum_H_pert_diag,N_st,Nint,key_mask,fock_diag_tmp,electronic_energy)
File: :file:`perturbation.irp.f_shell_13`
Applly pertubration ``epstein_nesbet_2x2_no_ci_diag`` to the buffer of determinants generated in the H_apply routine.
.. c:function:: perturb_buffer_h_core
.. code:: text
@ -405,7 +433,7 @@ Subroutines / functions
subroutine pt2_dummy (electronic_energy,det_ref,det_pert,fock_diag_tmp,c_pert,e_2_pert,H_pert_diag,Nint,ndet,N_st,minilist,idx_minilist,N_minilist)
File: :file:`pt2_equations.irp.f_template_309`
File: :file:`pt2_equations.irp.f_template_360`
Dummy perturbation to add all connected determinants.
@ -419,7 +447,7 @@ Subroutines / functions
subroutine pt2_epstein_nesbet (electronic_energy,det_ref,det_pert,fock_diag_tmp,c_pert,e_2_pert,H_pert_diag,Nint,ndet,N_st,minilist,idx_minilist,N_minilist)
File: :file:`pt2_equations.irp.f_template_309`
File: :file:`pt2_equations.irp.f_template_360`
Compute the standard Epstein-Nesbet perturbative first order coefficient and second order energetic contribution for the various N_st states.
@ -439,7 +467,7 @@ Subroutines / functions
subroutine pt2_epstein_nesbet_2x2 (electronic_energy,det_ref,det_pert,fock_diag_tmp,c_pert,e_2_pert,H_pert_diag,Nint,ndet,N_st,minilist,idx_minilist,N_minilist)
File: :file:`pt2_equations.irp.f_template_309`
File: :file:`pt2_equations.irp.f_template_360`
Computes the Epstein-Nesbet 2x2 diagonalization coefficient and energetic contribution for the various N_st states.
@ -453,6 +481,28 @@ Subroutines / functions
.. c:function:: pt2_epstein_nesbet_2x2_no_ci_diag
.. code:: text
subroutine pt2_epstein_nesbet_2x2_no_ci_diag(electronic_energy,det_ref,det_pert,fock_diag_tmp,c_pert,e_2_pert,H_pert_diag,Nint,ndet,N_st,minilist,idx_minilist,N_minilist)
File: :file:`pt2_equations.irp.f_template_360`
compute the Epstein-Nesbet 2x2 diagonalization coefficient and energetic contribution
for the various N_st states.
e_2_pert(i) = 0.5 * (( <det_pert|H|det_pert> - E(i) ) - sqrt( ( <det_pert|H|det_pert> - E(i)) ^2 + 4 <psi(i)|H|det_pert>^2 )
c_pert(i) = e_2_pert(i)/ <psi(i)|H|det_pert>
.. c:function:: pt2_h_core
.. code:: text
@ -481,7 +531,7 @@ Subroutines / functions
subroutine pt2_moller_plesset (electronic_energy,det_ref,det_pert,fock_diag_tmp,c_pert,e_2_pert,H_pert_diag,Nint,ndet,N_st,minilist,idx_minilist,N_minilist)
File: :file:`pt2_equations.irp.f_template_309`
File: :file:`pt2_equations.irp.f_template_360`
Computes the standard Moller-Plesset perturbative first order coefficient and second order energetic contribution for the various N_st states.
@ -501,7 +551,7 @@ Subroutines / functions
subroutine pt2_moller_plesset_general (electronic_energy,det_ref,det_pert,fock_diag_tmp,c_pert,e_2_pert,H_pert_diag,Nint,ndet,N_st,minilist,idx_minilist,N_minilist)
File: :file:`pt2_equations.irp.f_template_309`
File: :file:`pt2_equations.irp.f_template_360`
Computes the standard Moller-Plesset perturbative first order coefficient and second order energetic contribution for the various N_st states.
@ -521,7 +571,7 @@ Subroutines / functions
subroutine pt2_qdpt (electronic_energy,det_ref,det_pert,fock_diag_tmp,c_pert,e_2_pert,H_pert_diag,Nint,ndet,N_st,minilist,idx_minilist,N_minilist)
File: :file:`pt2_equations.irp.f_template_309`
File: :file:`pt2_equations.irp.f_template_360`
Computes the QDPT first order coefficient and second order energetic contribution for the various N_st states.

View File

@ -1,73 +0,0 @@
.. _slave:
.. program:: slave
.. default-role:: option
=====
slave
=====
Slave processes for distributed parallelism.
Subroutines / functions
-----------------------
.. c:function:: provide_everything
.. code:: text
subroutine provide_everything
File: :file:`slave_cipsi.irp.f`
.. c:function:: qp_ao_ints
.. code:: text
subroutine qp_ao_ints
File: :file:`slave_eri.irp.f`
Slave for electron repulsion integrals
.. c:function:: run_wf
.. code:: text
subroutine run_wf
File: :file:`slave_cipsi.irp.f`
.. c:function:: slave
.. code:: text
subroutine slave
File: :file:`slave_cipsi.irp.f`
Helper program for distributed parallelism

View File

@ -73,6 +73,20 @@ Subroutines / functions
.. c:function:: print_e_conv
.. code:: text
subroutine print_e_conv
File: :file:`print_e_conv.irp.f`
program that prints in a human readable format the convergence of the CIPSI algorithm
.. c:function:: print_wf
.. code:: text

View File

@ -18,6 +18,19 @@ Providers
---------
.. c:var:: is_zmq_slave
.. code:: text
logical :: is_zmq_slave
File: :file:`utils.irp.f`
If |true|, the current process is a |ZeroMQ| slave.
.. c:var:: qp_run_address
.. code:: text

View File

@ -311,6 +311,7 @@ Index of Providers
* :c:data:`io_mo_two_e_integrals_erf`
* :c:data:`iradix_sort`
* :c:data:`iradix_sort_big`
* :c:data:`is_zmq_slave`
* :c:data:`ks_energy`
* :c:data:`l_to_charater`
* :c:data:`level_shift`
@ -590,6 +591,7 @@ Index of Providers
* :c:data:`psi_selectors_coef_transp`
* :c:data:`psi_selectors_diag_h_mat`
* :c:data:`psi_selectors_size`
* :c:data:`pt2_collector`
* :c:data:`pt2_cw`
* :c:data:`pt2_e0_denominator`
* :c:data:`pt2_f`
@ -660,6 +662,7 @@ Index of Providers
* :c:data:`selection_criterion`
* :c:data:`selection_criterion_factor`
* :c:data:`selection_criterion_min`
* :c:data:`selection_weight`
* :c:data:`shifting_constant`
* :c:data:`short_range_hartree`
* :c:data:`short_range_hartree_operator`
@ -1175,14 +1178,12 @@ Index of Subroutines/Functions
* :c:func:`print_generators_bitmasks_particles`
* :c:func:`print_generators_bitmasks_particles_for_one_generator`
* :c:func:`print_memory_usage`
* :c:func:`print_r2`
* :c:func:`print_spindet`
* :c:func:`print_summary`
* :c:func:`print_wf`
* :c:func:`provide_all_mo_integrals_erf`
* :c:func:`provide_everything`
* :c:func:`pt2`
* :c:func:`pt2_collector`
* :c:func:`pt2_dummy`
* :c:func:`pt2_epstein_nesbet`
* :c:func:`pt2_epstein_nesbet_2x2`
@ -1201,7 +1202,6 @@ Index of Subroutines/Functions
* :c:func:`push_pt2`
* :c:func:`push_pt2_results`
* :c:func:`push_selection_results`
* :c:func:`qp_ao_ints`
* :c:func:`qrpa`
* :c:func:`qrpad`
* :c:func:`qrpadd`
@ -1232,12 +1232,16 @@ Index of Subroutines/Functions
* :c:func:`routine_example_psi_det`
* :c:func:`rs_ks_scf`
* :c:func:`run`
* :c:func:`run_cipsi`
* :c:func:`run_pt2_slave`
* :c:func:`run_selection_slave`
* :c:func:`run_wf`
* :c:func:`run_slave_cipsi`
* :c:func:`run_slave_main`
* :c:func:`run_stochastic_cipsi`
* :c:func:`s2_u_0`
* :c:func:`s2_u_0_nstates`
* :c:func:`sabpartial`
* :c:func:`save_energy`
* :c:func:`save_erf_two_e_integrals_ao`
* :c:func:`save_erf_two_e_integrals_mo`
* :c:func:`save_erf_two_e_ints_ao_into_ints_ao`
@ -1266,7 +1270,6 @@ Index of Subroutines/Functions
* :c:func:`set_natural_mos`
* :c:func:`set_order`
* :c:func:`set_order_big`
* :c:func:`slave`
* :c:func:`sort`
* :c:func:`sort_dets_ab`
* :c:func:`sort_dets_ab_v`

View File

@ -11,7 +11,7 @@ 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:
.. code:: irpf90
.. code:: fortran
program print_hf_energy
implicit none

View File

@ -25,15 +25,15 @@ Usage
List all the available plugins.
.. option:: list -i
.. option:: -i
List all the *installed* plugins.
.. option:: list -u
.. option:: -u
List all the *uninstalled* plugins.
.. option:: list -q
.. option:: -q
List all the downloaded repositories.
@ -53,12 +53,12 @@ Usage
Uninstall the plugin ``plugin_name``.
.. option:: create -n <plugin_name>
.. option:: -n <plugin_name>
Create a new plugin named ``plugin_name`` in local repository.
Create a new plugin named ``plugin_name`` (in local repository by default).
.. option:: create -n <plugin_name> -r <repository>
.. option:: -r <repository>
Create a new plugin named ``plugin_name`` in the specified repository.
Specify in which repository the new plugin will be created.

View File

@ -23,7 +23,7 @@ import shutil
try:
from docopt import docopt
from qp_path import QP_SRC, QP_ROOT, QP_PLUGINS
from qp_path import QP_SRC, QP_ROOT, QP_PLUGINS, QP_EZFIO
except ImportError:
print "source .quantum_package.rc"
raise
@ -205,6 +205,10 @@ if __name__ == '__main__':
if arguments['--all']:
l_module = [f for f in os.listdir(QP_SRC)
if os.path.isdir(os.path.join(QP_SRC, f))]
# Remove all produced ezfio_config files
for filename in os.listdir( os.path.join(QP_EZFIO, "config") ):
os.remove( os.path.join(QP_EZFIO, "config", filename) )
elif not arguments['<module_name>']:
dir_ = os.getcwd()

View File

@ -78,7 +78,7 @@ then
sleep 1
done
echo "Starting slaves"
mpiexec.hydra -n $((${SLURM_NTASKS}-1)) -hosts "$SLAVE_NODES" qp_run -slave slave_cipsi $INPUT > $INPUT.slaves.out
mpiexec.hydra -n $((${SLURM_NTASKS}-1)) -hosts "$SLAVE_NODES" qp_run -slave $PROG $INPUT > $INPUT.slaves.out
fi
wait

View File

@ -78,7 +78,7 @@ then
sleep 1
done
echo "Starting slaves"
srun -n $((${SLURM_NTASKS}-1)) qp_run -slave slave_cipsi $INPUT > $INPUT.slaves.out
srun -n $((${SLURM_NTASKS}-1)) qp_run -slave $PROG $INPUT > $INPUT.slaves.out
fi
wait

5
src/cipsi/NEED Normal file
View File

@ -0,0 +1,5 @@
perturbation
zmq
mpi
davidson_undressed
iterations

128
src/cipsi/README.rst Normal file
View File

@ -0,0 +1,128 @@
=====
cipsi
=====
|CIPSI| algorithm.
The :c:func:`run_stochastic_cipsi` and :c:func:`run_cipsi` subroutines start with a single
determinant, or with the wave function in the |EZFIO| database if
:option:`determinants read_wf` is |true|.
The :c:func:`run_cipsi` subroutine iteratively:
* Selects the most important determinants from the external space and adds them to the
internal space
* If :option:`determinants s2_eig` is |true|, it adds all the necessary
determinants to allow the eigenstates of |H| to be eigenstates of |S^2|
* Diagonalizes |H| in the enlarged internal space
* Computes the |PT2| contribution to the energy stochastically :cite:`Garniron_2017.2`
or deterministically, depending on :option:`perturbation do_pt2`
* Extrapolates the variational energy by fitting
:math:`E=E_\text{FCI} - \alpha\, E_\text{PT2}`
The difference between :c:func:`run_stochastic_cipsi` and :c:func:`run_cipsi` is that
:c:func:`run_stochastic_cipsi` selects the determinants on the fly with the computation
of the stochastic |PT2| :cite:`Garniron_2017.2`. Hence, it is a semi-stochastic selection. It
* Selects the most important determinants from the external space and adds them to the
internal space, on the fly with the computation of the PT2 with the stochastic algorithm
presented in :cite:`Garniron_2017.2`.
* If :option:`determinants s2_eig` is |true|, it adds all the necessary
determinants to allow the eigenstates of |H| to be eigenstates of |S^2|
* Extrapolates the variational energy by fitting
:math:`E=E_\text{FCI} - \alpha\, E_\text{PT2}`
* Diagonalizes |H| in the enlarged internal space
The number of selected determinants at each iteration will be such that the
size of the wave function will double at every iteration. If :option:`determinants
s2_eig` is |true|, then the number of selected determinants will be 1.5x the
current number, and then all the additional determinants will be added.
By default, the program will stop when more than one million determinants have
been selected, or when the |PT2| energy is below :math:`10^{-4}`.
The variational and |PT2| energies of the iterations are stored in the
|EZFIO| database, in the :ref:`iterations` module.
Computation of the |PT2| energy
-------------------------------
At each iteration, the |PT2| energy is computed considering the Epstein-Nesbet
zeroth-order Hamiltonian:
.. math::
E_{\text{PT2}} = \sum_{ \alpha }
\frac{|\langle \Psi_S | \hat{H} | \alpha \rangle|^2}
{E - \langle \alpha | \hat{H} | \alpha \rangle}
where the |kalpha| determinants are generated by applying all the single and
double excitation operators to all the determinants of the wave function
:math:`\Psi_G`.
When the hybrid-deterministic/stochastic algorithm is chosen
(default), :math:`Psi_G = \Psi_S = \Psi`, the full wavefunction expanded in the
internal space.
When the deterministic algorithm is chosen (:option:`perturbation do_pt2`
is set to |false|), :math:`Psi_G` is a truncation of |Psi| using
:option:`determinants threshold_generators`, and :math:`Psi_S` is a truncation
of |Psi| using :option:`determinants threshold_selectors`, and re-weighted
by :math:`1/\langle \Psi_s | \Psi_s \rangle`.
At every iteration, while computing the |PT2|, the variance of the wave
function is also computed:
.. math::
\sigma^2 & = \langle \Psi | \hat{H}^2 | \Psi \rangle -
\langle \Psi | \hat{H} | \Psi \rangle^2 \\
& = \sum_{i \in \text{FCI}}
\langle \Psi | \hat{H} | i \rangle
\langle i | \hat{H} | \Psi \rangle -
\langle \Psi | \hat{H} | \Psi \rangle^2 \\
& = \sum_{ \alpha }
\langle |\Psi | \hat{H} | \alpha \rangle|^2.
The expression of the variance is the same as the expression of the |PT2|, with
a denominator of 1. It measures how far the wave function is from the |FCI|
solution. Note that the absence of denominator in the Heat-Bath selected |CI|
method is selection method by minimization of the variance, whereas |CIPSI| is
a selection method by minimization of the energy.
If :option:`perturbation do_pt2` is set to |false|, then the stochastic
|PT2| is not computed, and an approximate value is obtained from the |CIPSI|
selection. The calculation is faster, but the extrapolated |FCI| value is
less accurate. This way of running the code should be used when the only
goal is to generate a wave function, as for using |CIPSI| wave functions as
trial wave functions of |QMC| calculations for example.
The :command:`PT2` program reads the wave function of the |EZFIO| database
and computes the energy and the |PT2| contribution.
State-averaging
---------------
Extrapolated |FCI| energy
-------------------------
An estimate of the |FCI| energy is computed by extrapolating
.. math::
E=E_\text{FCI} - \alpha\, E_\text{PT2}
This extrapolation is done for all the requested states, and excitation
energies are printed as energy differences between the extrapolated
energies of the excited states and the extrapolated energy of the ground
state.
The extrapolations are given considering the 2 last points, the 3 last points, ...,
the 7 last points. The extrapolated value should be chosen such that the extrpolated
value is stable with the number of points.

147
src/cipsi/cipsi.irp.f Normal file
View File

@ -0,0 +1,147 @@
subroutine run_cipsi
implicit none
BEGIN_DOC
! Selected Full Configuration Interaction with deterministic selection and
! stochastic PT2.
END_DOC
integer :: i,j,k
double precision, allocatable :: pt2(:), variance(:), norm(:), rpt2(:)
integer :: n_det_before, to_select
double precision :: rss
double precision, external :: memory_of_double
rss = memory_of_double(N_states)*4.d0
call check_mem(rss,irp_here)
allocate (pt2(N_states), rpt2(N_states), norm(N_states), variance(N_states))
double precision :: hf_energy_ref
logical :: has
double precision :: relative_error
PROVIDE H_apply_buffer_allocated
relative_error=PT2_relative_error
pt2 = -huge(1.e0)
rpt2 = -huge(1.e0)
norm = 0.d0
variance = 0.d0
if (s2_eig) then
call make_s2_eigenfunction
endif
call diagonalize_CI
call save_wavefunction
call ezfio_has_hartree_fock_energy(has)
if (has) then
call ezfio_get_hartree_fock_energy(hf_energy_ref)
else
hf_energy_ref = ref_bitmask_energy
endif
if (N_det > N_det_max) then
psi_det = psi_det_sorted
psi_coef = psi_coef_sorted
N_det = N_det_max
soft_touch N_det psi_det psi_coef
call diagonalize_CI
call save_wavefunction
endif
n_det_before = 0
double precision :: correlation_energy_ratio
double precision :: threshold_generators_save
threshold_generators_save = threshold_generators
double precision :: error(N_states)
correlation_energy_ratio = 0.d0
do while ( &
(N_det < N_det_max) .and. &
(maxval(abs(pt2(1:N_states))) > pt2_max) .and. &
(correlation_energy_ratio <= correlation_energy_ratio_max) &
)
write(*,'(A)') '--------------------------------------------------------------------------------'
if (do_pt2) then
pt2 = 0.d0
variance = 0.d0
norm = 0.d0
threshold_generators = 1.d0
SOFT_TOUCH threshold_generators
call ZMQ_pt2(psi_energy_with_nucl_rep,pt2,relative_error,error, variance, &
norm, 0) ! Stochastic PT2
threshold_generators = threshold_generators_save
SOFT_TOUCH threshold_generators
endif
correlation_energy_ratio = (psi_energy_with_nucl_rep(1) - hf_energy_ref) / &
(psi_energy_with_nucl_rep(1) + pt2(1) - hf_energy_ref)
correlation_energy_ratio = min(1.d0,correlation_energy_ratio)
call save_energy(psi_energy_with_nucl_rep, pt2)
call write_double(6,correlation_energy_ratio, 'Correlation ratio')
call print_summary(psi_energy_with_nucl_rep(1:N_states),pt2,error,variance,norm,N_det,N_occ_pattern)
do k=1,N_states
rpt2(:) = pt2(:)/(1.d0 + norm(k))
enddo
call save_iterations(psi_energy_with_nucl_rep(1:N_states),rpt2,N_det)
call print_extrapolated_energy()
N_iter += 1
n_det_before = N_det
to_select = N_det
to_select = max(N_states_diag, to_select)
! to_select = min(to_select, N_det_max-n_det_before)
call ZMQ_selection(to_select, pt2, variance, norm)
PROVIDE psi_coef
PROVIDE psi_det
PROVIDE psi_det_sorted
call diagonalize_CI
call save_wavefunction
rpt2(:) = 0.d0
call save_energy(psi_energy_with_nucl_rep, rpt2)
enddo
if (N_det < N_det_max) then
call diagonalize_CI
call save_wavefunction
rpt2(:) = 0.d0
call save_energy(psi_energy_with_nucl_rep, rpt2)
endif
if (do_pt2) then
pt2 = 0.d0
variance = 0.d0
norm = 0.d0
threshold_generators = 1d0
SOFT_TOUCH threshold_generators
call ZMQ_pt2(psi_energy_with_nucl_rep, pt2,relative_error,error,variance, &
norm,0) ! Stochastic PT2
SOFT_TOUCH threshold_generators
call save_energy(psi_energy_with_nucl_rep, pt2)
endif
print *, 'N_det = ', N_det
print *, 'N_sop = ', N_occ_pattern
print *, 'N_states = ', N_states
print*, 'correlation_ratio = ', correlation_energy_ratio
do k=1,N_states
rpt2(:) = pt2(:)/(1.d0 + norm(k))
enddo
call print_summary(psi_energy_with_nucl_rep(1:N_states),pt2,error,variance,norm,N_det,N_occ_pattern)
call save_iterations(psi_energy_with_nucl_rep(1:N_states),rpt2,N_det)
call print_extrapolated_energy()
end

View File

@ -95,34 +95,42 @@ end function
subroutine ZMQ_pt2(E, pt2,relative_error, error, variance, norm)
subroutine ZMQ_pt2(E, pt2,relative_error, error, variance, norm, N_in)
use f77_zmq
use selection_types
implicit none
integer(ZMQ_PTR) :: zmq_to_qp_run_socket, zmq_socket_pull
integer, intent(in) :: N_in
integer, external :: omp_get_thread_num
double precision, intent(in) :: relative_error, E(N_states)
double precision, intent(out) :: pt2(N_states),error(N_states)
double precision, intent(out) :: variance(N_states),norm(N_states)
integer :: i
integer :: i, N
double precision, external :: omp_get_wtime
double precision :: state_average_weight_save(N_states), w(N_states,4)
integer(ZMQ_PTR), external :: new_zmq_to_qp_run_socket
type(selection_buffer) :: b
if (N_det < max(10,N_states)) then
pt2=0.d0
variance=0.d0
norm=0.d0
call ZMQ_selection(0, pt2, variance, norm)
call ZMQ_selection(N_in, pt2, variance, norm)
error(:) = 0.d0
else
N = max(N_in,1)
state_average_weight_save(:) = state_average_weight(:)
call create_selection_buffer(N, N*2, b)
ASSERT (associated(b%det))
ASSERT (associated(b%val))
do pt2_stoch_istate=1,N_states
state_average_weight(:) = 0.d0
state_average_weight(pt2_stoch_istate) = 1.d0
@ -159,9 +167,8 @@ subroutine ZMQ_pt2(E, pt2,relative_error, error, variance, norm)
endif
integer, external :: add_task_to_taskserver
character(400000) :: task
character(300000) :: task
integer :: j,k,ipos,ifirst
ifirst=0
@ -178,9 +185,9 @@ subroutine ZMQ_pt2(E, pt2,relative_error, error, variance, norm)
ipos=1
do i= 1, N_det_generators
do j=1,pt2_F(pt2_J(i))
write(task(ipos:ipos+20),'(I9,1X,I9,''|'')') j, pt2_J(i)
ipos += 20
if (ipos > 400000-20) then
write(task(ipos:ipos+30),'(I9,1X,I9,1X,I9,''|'')') j, pt2_J(i), N
ipos += 30
if (ipos > 300000-30) then
if (add_task_to_taskserver(zmq_to_qp_run_socket,trim(task(1:ipos))) == -1) then
stop 'Unable to add task to task server'
endif
@ -199,7 +206,7 @@ subroutine ZMQ_pt2(E, pt2,relative_error, error, variance, norm)
stop 'Unable to add task to task server'
endif
endif
integer, external :: zmq_set_running
if (zmq_set_running(zmq_to_qp_run_socket) == -1) then
print *, irp_here, ': Failed in zmq_set_running'
@ -228,7 +235,7 @@ subroutine ZMQ_pt2(E, pt2,relative_error, error, variance, norm)
i = omp_get_thread_num()
if (i==0) then
call pt2_collector(zmq_socket_pull, E(pt2_stoch_istate),relative_error, w(1,1), w(1,2), w(1,3), w(1,4))
call pt2_collector(zmq_socket_pull, E(pt2_stoch_istate),relative_error, w(1,1), w(1,2), w(1,3), w(1,4), b, N)
pt2(pt2_stoch_istate) = w(pt2_stoch_istate,1)
error(pt2_stoch_istate) = w(pt2_stoch_istate,2)
variance(pt2_stoch_istate) = w(pt2_stoch_istate,3)
@ -243,9 +250,18 @@ subroutine ZMQ_pt2(E, pt2,relative_error, error, variance, norm)
print '(A)', '========== ================= =========== =============== =============== ================='
enddo
! call omp_set_nested(.false.)
FREE pt2_stoch_istate
if (N_in > 0) then
if (s2_eig) then
call make_selection_buffer_s2(b)
endif
call fill_H_apply_buffer_no_selection(b%cur,b%det,N_int,0)
call copy_H_apply_buffer_to_wf()
call save_wavefunction
endif
call delete_selection_buffer(b)
state_average_weight(:) = state_average_weight_save(:)
TOUCH state_average_weight
endif
@ -264,7 +280,8 @@ subroutine pt2_slave_inproc(i)
end
subroutine pt2_collector(zmq_socket_pull, E, relative_error, pt2, error, variance, norm)
subroutine pt2_collector(zmq_socket_pull, E, relative_error, pt2, error, &
variance, norm, b, N_)
use f77_zmq
use selection_types
use bitmasks
@ -272,9 +289,11 @@ subroutine pt2_collector(zmq_socket_pull, E, relative_error, pt2, error, varianc
integer(ZMQ_PTR), intent(in) :: zmq_socket_pull
double precision, intent(in) :: relative_error, E
double precision, intent(in) :: relative_error, E
double precision, intent(out) :: pt2(N_states), error(N_states)
double precision, intent(out) :: variance(N_states), norm(N_states)
type(selection_buffer), intent(inout) :: b
integer, intent(in) :: N_
double precision, allocatable :: eI(:,:), eI_task(:,:), S(:), S2(:)
@ -297,6 +316,7 @@ subroutine pt2_collector(zmq_socket_pull, E, relative_error, pt2, error, varianc
integer, allocatable :: f(:)
logical, allocatable :: d(:)
logical :: do_exit
type(selection_buffer) :: b2
double precision :: rss
@ -319,6 +339,8 @@ subroutine pt2_collector(zmq_socket_pull, E, relative_error, pt2, error, varianc
zmq_to_qp_run_socket = new_zmq_to_qp_run_socket()
call create_selection_buffer(N_, N_*2, b2)
pt2(:) = -huge(1.)
error(:) = huge(1.)
@ -417,7 +439,7 @@ subroutine pt2_collector(zmq_socket_pull, E, relative_error, pt2, error, varianc
else if(more == 0) then
exit
else
call pull_pt2_results(zmq_socket_pull, index, eI_task, vI_task, nI_task, task_id, n_tasks)
call pull_pt2_results(zmq_socket_pull, index, eI_task, vI_task, nI_task, task_id, n_tasks, b2)
if (zmq_delete_tasks(zmq_to_qp_run_socket,zmq_socket_pull,task_id,n_tasks,more) == -1) then
stop 'Unable to delete tasks'
endif
@ -427,9 +449,16 @@ subroutine pt2_collector(zmq_socket_pull, E, relative_error, pt2, error, varianc
nI(:, index(i)) += nI_task(:,i)
f(index(i)) -= 1
end do
do i=1, b2%cur
call add_to_selection_buffer(b, b2%det(1,1,i), b2%val(i))
if (b2%val(i) > b%mini) exit
end do
end if
end do
call delete_selection_buffer(b2)
call sort_selection_buffer(b)
call end_zmq_to_qp_run_socket(zmq_to_qp_run_socket)
end subroutine

View File

@ -18,11 +18,11 @@ subroutine run_pt2_slave(thread,iproc,energy)
integer(ZMQ_PTR), external :: new_zmq_push_socket
integer(ZMQ_PTR) :: zmq_socket_push
type(selection_buffer) :: buf
logical :: done
type(selection_buffer) :: b, b2
logical :: done, buffer_ready
double precision,allocatable :: pt2(:,:), variance(:,:), norm(:,:)
integer :: n_tasks, k
integer :: n_tasks, k, N
integer, allocatable :: i_generator(:), subset(:)
double precision :: rss
@ -46,9 +46,9 @@ subroutine run_pt2_slave(thread,iproc,energy)
zmq_socket_push = new_zmq_push_socket(thread)
buf%N = 0
b%N = 0
buffer_ready = .False.
n_tasks = 1
call create_selection_buffer(0, 0, buf)
done = .False.
n_tasks = 1
@ -62,12 +62,22 @@ subroutine run_pt2_slave(thread,iproc,energy)
exit
endif
done = task_id(n_tasks) == 0
if (done) n_tasks = n_tasks-1
if (done) then
n_tasks = n_tasks-1
endif
if (n_tasks == 0) exit
do k=1,n_tasks
read (task(k),*) subset(k), i_generator(k)
read (task(k),*) subset(k), i_generator(k), N
enddo
if (b%N == 0) then
! Only first time
call create_selection_buffer(N, N*2, b)
call create_selection_buffer(N, N*2, b2)
buffer_ready = .True.
else
ASSERT (N == b%N)
endif
double precision :: time0, time1
call wall_time(time0)
@ -75,10 +85,10 @@ subroutine run_pt2_slave(thread,iproc,energy)
pt2(:,k) = 0.d0
variance(:,k) = 0.d0
norm(:,k) = 0.d0
buf%cur = 0
b%cur = 0
!double precision :: time2
!call wall_time(time2)
call select_connected(i_generator(k),energy,pt2(1,k),variance(1,k),norm(1,k),buf,subset(k),pt2_F(i_generator(k)))
call select_connected(i_generator(k),energy,pt2(1,k),variance(1,k),norm(1,k),b,subset(k),pt2_F(i_generator(k)))
!call wall_time(time1)
!print *, i_generator(1), time1-time2, n_tasks, pt2_F(i_generator(1))
enddo
@ -89,7 +99,11 @@ subroutine run_pt2_slave(thread,iproc,energy)
if (tasks_done_to_taskserver(zmq_to_qp_run_socket,worker_id,task_id,n_tasks) == -1) then
done = .true.
endif
call push_pt2_results(zmq_socket_push, i_generator, pt2, variance, norm, task_id, n_tasks)
call sort_selection_buffer(b)
call merge_selection_buffers(b,b2)
call push_pt2_results(zmq_socket_push, i_generator, pt2, variance, norm, b, task_id, n_tasks)
b%mini = b2%mini
b%cur=0
! Try to adjust n_tasks around nproc/8 seconds per job
n_tasks = min(2*n_tasks,int( dble(n_tasks * nproc/8) / (time1 - time0 + 1.d0)))
@ -104,11 +118,14 @@ subroutine run_pt2_slave(thread,iproc,energy)
call end_zmq_push_socket(zmq_socket_push,thread)
call end_zmq_to_qp_run_socket(zmq_to_qp_run_socket)
call delete_selection_buffer(buf)
if (buffer_ready) then
call delete_selection_buffer(b)
call delete_selection_buffer(b2)
endif
end subroutine
subroutine push_pt2_results(zmq_socket_push, index, pt2, variance, norm, task_id, n_tasks)
subroutine push_pt2_results(zmq_socket_push, index, pt2, variance, norm, b, task_id, n_tasks)
use f77_zmq
use selection_types
implicit none
@ -118,45 +135,80 @@ subroutine push_pt2_results(zmq_socket_push, index, pt2, variance, norm, task_id
double precision, intent(in) :: variance(N_states,n_tasks)
double precision, intent(in) :: norm(N_states,n_tasks)
integer, intent(in) :: n_tasks, index(n_tasks), task_id(n_tasks)
type(selection_buffer), intent(inout) :: b
integer :: rc
rc = f77_zmq_send( zmq_socket_push, n_tasks, 4, ZMQ_SNDMORE)
if (rc == -1) then
return
else if(rc /= 4) then
stop 'push'
endif
if(rc /= 4) stop 'push'
rc = f77_zmq_send( zmq_socket_push, index, 4*n_tasks, ZMQ_SNDMORE)
if (rc == -1) then
return
else if(rc /= 4*n_tasks) then
stop 'push'
endif
if(rc /= 4*n_tasks) stop 'push'
rc = f77_zmq_send( zmq_socket_push, pt2, 8*N_states*n_tasks, ZMQ_SNDMORE)
if (rc == -1) then
return
else if(rc /= 8*N_states*n_tasks) then
stop 'push'
endif
if(rc /= 8*N_states*n_tasks) stop 'push'
rc = f77_zmq_send( zmq_socket_push, variance, 8*N_states*n_tasks, ZMQ_SNDMORE)
if (rc == -1) then
return
else if(rc /= 8*N_states*n_tasks) then
stop 'push'
endif
if(rc /= 8*N_states*n_tasks) stop 'push'
rc = f77_zmq_send( zmq_socket_push, norm, 8*N_states*n_tasks, ZMQ_SNDMORE)
if (rc == -1) then
return
else if(rc /= 8*N_states*n_tasks) then
stop 'push'
endif
if(rc /= 8*N_states*n_tasks) stop 'push'
rc = f77_zmq_send( zmq_socket_push, task_id, n_tasks*4, 0)
rc = f77_zmq_send( zmq_socket_push, task_id, n_tasks*4, ZMQ_SNDMORE)
if (rc == -1) then
return
else if(rc /= 4*n_tasks) then
stop 'push'
endif
if(rc /= 4*n_tasks) stop 'push'
rc = f77_zmq_send( zmq_socket_push, b%cur, 4, ZMQ_SNDMORE)
if (rc == -1) then
return
else if(rc /= 4) then
stop 'push'
endif
rc = f77_zmq_send( zmq_socket_push, b%val, 8*b%cur, ZMQ_SNDMORE)
if (rc == -1) then
return
else if(rc /= 8*b%cur) then
stop 'push'
endif
rc = f77_zmq_send( zmq_socket_push, b%det, bit_kind*N_int*2*b%cur, 0)
if (rc == -1) then
return
else if(rc /= N_int*2*8*b%cur) then
stop 'push'
endif
! Activate is zmq_socket_push is a REQ
IRP_IF ZMQ_PUSH
@ -165,8 +217,7 @@ IRP_ELSE
rc = f77_zmq_recv( zmq_socket_push, ok, 2, 0)
if (rc == -1) then
return
endif
if ((rc /= 2).and.(ok(1:2) /= 'ok')) then
else if ((rc /= 2).and.(ok(1:2) /= 'ok')) then
print *, irp_here//': error in receiving ok'
stop -1
endif
@ -175,7 +226,7 @@ IRP_ENDIF
end subroutine
subroutine pull_pt2_results(zmq_socket_pull, index, pt2, variance, norm, task_id, n_tasks)
subroutine pull_pt2_results(zmq_socket_pull, index, pt2, variance, norm, task_id, n_tasks, b)
use f77_zmq
use selection_types
implicit none
@ -183,6 +234,7 @@ subroutine pull_pt2_results(zmq_socket_pull, index, pt2, variance, norm, task_id
double precision, intent(inout) :: pt2(N_states,*)
double precision, intent(inout) :: variance(N_states,*)
double precision, intent(inout) :: norm(N_states,*)
type(selection_buffer), intent(inout) :: b
integer, intent(out) :: index(*)
integer, intent(out) :: n_tasks, task_id(*)
integer :: rc, rn, i
@ -191,43 +243,74 @@ subroutine pull_pt2_results(zmq_socket_pull, index, pt2, variance, norm, task_id
if (rc == -1) then
n_tasks = 1
task_id(1) = 0
else if(rc /= 4) then
stop 'pull'
endif
if(rc /= 4) stop 'pull'
rc = f77_zmq_recv( zmq_socket_pull, index, 4*n_tasks, 0)
if (rc == -1) then
n_tasks = 1
task_id(1) = 0
else if(rc /= 4*n_tasks) then
stop 'pull'
endif
if(rc /= 4*n_tasks) stop 'pull'
rc = f77_zmq_recv( zmq_socket_pull, pt2, N_states*8*n_tasks, 0)
if (rc == -1) then
n_tasks = 1
task_id(1) = 0
else if(rc /= 8*N_states*n_tasks) then
stop 'pull'
endif
if(rc /= 8*N_states*n_tasks) stop 'pull'
rc = f77_zmq_recv( zmq_socket_pull, variance, N_states*8*n_tasks, 0)
if (rc == -1) then
n_tasks = 1
task_id(1) = 0
else if(rc /= 8*N_states*n_tasks) then
stop 'pull'
endif
if(rc /= 8*N_states*n_tasks) stop 'pull'
rc = f77_zmq_recv( zmq_socket_pull, norm, N_states*8*n_tasks, 0)
if (rc == -1) then
n_tasks = 1
task_id(1) = 0
else if(rc /= 8*N_states*n_tasks) then
stop 'pull'
endif
if(rc /= 8*N_states*n_tasks) stop 'pull'
rc = f77_zmq_recv( zmq_socket_pull, task_id, n_tasks*4, 0)
if (rc == -1) then
n_tasks = 1
task_id(1) = 0
else if(rc /= 4*n_tasks) then
stop 'pull'
endif
if(rc /= 4*n_tasks) stop 'pull'
rc = f77_zmq_recv( zmq_socket_pull, b%cur, 4, 0)
if (rc == -1) then
n_tasks = 1
task_id(1) = 0
else if(rc /= 4) then
stop 'pull'
endif
rc = f77_zmq_recv( zmq_socket_pull, b%val, 8*b%cur, 0)
if (rc == -1) then
n_tasks = 1
task_id(1) = 0
else if(rc /= 8*b%cur) then
stop 'pull'
endif
rc = f77_zmq_recv( zmq_socket_pull, b%det, bit_kind*N_int*2*b%cur, 0)
if (rc == -1) then
n_tasks = 1
task_id(1) = 0
else if(rc /= N_int*2*8*b%cur) then
stop 'pull'
endif
! Activate is zmq_socket_pull is a REP
IRP_IF ZMQ_PUSH
@ -236,8 +319,7 @@ IRP_ELSE
if (rc == -1) then
n_tasks = 1
task_id(1) = 0
endif
if (rc /= 2) then
else if (rc /= 2) then
print *, irp_here//': error in sending ok'
stop -1
endif

View File

@ -1,5 +1,27 @@
use bitmasks
BEGIN_PROVIDER [ double precision, selection_weight, (N_states) ]
implicit none
BEGIN_DOC
! Weights in the state-average calculation of the density matrix
END_DOC
logical :: exists
selection_weight(:) = 1.d0
if (used_weight == 0) then
selection_weight(:) = c0_weight(:)
else if (used_weight == 1) then
selection_weight(:) = 1./N_states
else
call ezfio_has_determinants_state_average_weight(exists)
if (exists) then
call ezfio_get_determinants_state_average_weight(selection_weight)
endif
endif
selection_weight(:) = selection_weight(:)+1.d-31
selection_weight(:) = selection_weight(:)/(sum(selection_weight(:)))
END_PROVIDER
subroutine get_mask_phase(det1, pm, Nint)
use bitmasks
@ -719,9 +741,9 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d
norm(istate) = norm(istate) + coef * coef
if (h0_type == "Variance") then
sum_e_pert = sum_e_pert - alpha_h_psi * alpha_h_psi * state_average_weight(istate)
sum_e_pert = sum_e_pert - alpha_h_psi * alpha_h_psi * selection_weight(istate)
else
sum_e_pert = sum_e_pert + e_pert * state_average_weight(istate)
sum_e_pert = sum_e_pert + e_pert * selection_weight(istate)
endif
end do

View File

@ -1,4 +1,4 @@
program slave
subroutine run_slave_cipsi
implicit none
BEGIN_DOC
! Helper program for distributed parallelism
@ -10,7 +10,7 @@ program slave
SOFT_TOUCH read_wf distributed_davidson
call provide_everything
call switch_qp_run_to_master
call run_wf
call run_slave_main
end
subroutine provide_everything
@ -20,7 +20,7 @@ subroutine provide_everything
PROVIDE N_det_selectors pt2_stoch_istate N_det
end
subroutine run_wf
subroutine run_slave_main
use f77_zmq
implicit none

View File

@ -0,0 +1,130 @@
subroutine run_stochastic_cipsi
implicit none
BEGIN_DOC
! Selected Full Configuration Interaction with Stochastic selection and PT2.
END_DOC
integer :: i,j,k
double precision, allocatable :: pt2(:), variance(:), norm(:), rpt2(:)
integer :: N_det_before, N_occ_pattern_before, to_select
double precision :: rss
double precision, external :: memory_of_double
threshold_generators = 1.d0
SOFT_TOUCH threshold_generators
rss = memory_of_double(N_states)*4.d0
call check_mem(rss,irp_here)
allocate (pt2(N_states), rpt2(N_states), norm(N_states), variance(N_states))
double precision :: hf_energy_ref
logical :: has
double precision :: relative_error
PROVIDE H_apply_buffer_allocated
relative_error=PT2_relative_error
pt2 = -huge(1.e0)
rpt2 = -huge(1.e0)
norm = 0.d0
variance = 0.d0
if (s2_eig) then
call make_s2_eigenfunction
endif
call diagonalize_CI
call save_wavefunction
call ezfio_has_hartree_fock_energy(has)
if (has) then
call ezfio_get_hartree_fock_energy(hf_energy_ref)
else
hf_energy_ref = ref_bitmask_energy
endif
if (N_det > N_det_max) then
psi_det = psi_det_sorted
psi_coef = psi_coef_sorted
N_det = N_det_max
soft_touch N_det psi_det psi_coef
call diagonalize_CI
call save_wavefunction
endif
N_det_before = 0
N_occ_pattern_before = 0
double precision :: correlation_energy_ratio
double precision :: error(N_states)
correlation_energy_ratio = 0.d0
do while ( &
(N_det < N_det_max) .and. &
(maxval(abs(pt2(1:N_states))) > pt2_max) .and. &
(correlation_energy_ratio <= correlation_energy_ratio_max) &
)
write(*,'(A)') '--------------------------------------------------------------------------------'
N_det_before = N_det
N_occ_pattern_before = N_occ_pattern
to_select = N_det
to_select = max(N_states_diag, to_select)
pt2 = 0.d0
variance = 0.d0
norm = 0.d0
call ZMQ_pt2(psi_energy_with_nucl_rep,pt2,relative_error,error, variance, &
norm, to_select) ! Stochastic PT2
correlation_energy_ratio = (psi_energy_with_nucl_rep(1) - hf_energy_ref) / &
(psi_energy_with_nucl_rep(1) + pt2(1) - hf_energy_ref)
correlation_energy_ratio = min(1.d0,correlation_energy_ratio)
call save_energy(psi_energy_with_nucl_rep, pt2)
call write_double(6,correlation_energy_ratio, 'Correlation ratio')
call print_summary(psi_energy_with_nucl_rep(1:N_states),pt2,error,variance,norm,N_det_before,N_occ_pattern_before)
do k=1,N_states
rpt2(:) = pt2(:)/(1.d0 + norm(k))
enddo
call save_iterations(psi_energy_with_nucl_rep(1:N_states),rpt2,N_det_before)
call print_extrapolated_energy()
N_iter += 1
PROVIDE psi_coef
PROVIDE psi_det
PROVIDE psi_det_sorted
call diagonalize_CI
call save_wavefunction
rpt2(:) = 0.d0
call save_energy(psi_energy_with_nucl_rep, rpt2)
enddo
if (N_det < N_det_max) then
call diagonalize_CI
call save_wavefunction
rpt2(:) = 0.d0
call save_energy(psi_energy_with_nucl_rep, rpt2)
endif
pt2 = 0.d0
variance = 0.d0
norm = 0.d0
call ZMQ_pt2(psi_energy_with_nucl_rep, pt2,relative_error,error,variance, &
norm,0) ! Stochastic PT2
call save_energy(psi_energy_with_nucl_rep, pt2)
do k=1,N_states
rpt2(:) = pt2(:)/(1.d0 + norm(k))
enddo
call print_summary(psi_energy_with_nucl_rep(1:N_states),pt2,error,variance,norm,N_det,N_occ_pattern)
call save_iterations(psi_energy_with_nucl_rep(1:N_states),rpt2,N_det)
call print_extrapolated_energy()
end

View File

@ -150,7 +150,7 @@ subroutine selection_collector(zmq_socket_pull, b, N, pt2, variance, norm)
integer(ZMQ_PTR), intent(in) :: zmq_socket_pull
type(selection_buffer), intent(inout) :: b
integer, intent(in) :: N
integer, intent(in) :: N
double precision, intent(inout) :: pt2(N_states)
double precision, intent(inout) :: variance(N_states)
double precision, intent(inout) :: norm(N_states)

View File

@ -3,7 +3,7 @@
source $QP_ROOT/tests/bats/common.bats.sh
function run() {
thresh=1.e-6
thresh=1.e-5
test_exe cis || skip
qp_edit -c $1
ezfio set_file $1
@ -20,97 +20,102 @@ function run() {
eq $energy3 $4 $thresh
}
@test "HBO" {
run hbo.ezfio -100.018582259097 -99.7127500068768 -99.6982683641297
}
@test "H2O" {
run h2o.ezfio -76.02702187043107 -75.6854407466997 -75.61967556334928
}
@test "[Cu(NH3)4]2+" {
run cu_nh3_4_2plus.ezfio -1862.97958709248 -1862.92454796197 -1862.91130872182
}
@test "C2H2" {
run c2h2.ezfio -12.1214401949634 -11.8824874421211 -11.8682310791620
}
@test "ClO" {
run clo.ezfio -534.263560525680 -534.256601571199 -534.062020844428
}
@test "DHNO" {
run dhno.ezfio -130.4472288472718 -130.3571808164850 -130.2196257046987
}
@test "H3COH" {
run h3coh.ezfio -114.986503059639 -114.649121836046 -114.578365912794
}
@test "HCN" {
run hcn.ezfio -92.8871750003811 -92.6250263755063 -92.6089719143274
}
@test "N2" {
run n2.ezfio -108.983489785305 -108.670192549322 -108.649653940027
}
@test "SiH2_3B1" {
@test "SiH2_3B1" { # 1.23281s
run sih2_3b1.ezfio -289.969297318489 -289.766898643192 -289.737521023380
}
@test "SO" {
run so.ezfio -25.7502263243068 -25.5862810638724 -25.5829361589673
@test "HBO" { # 1.31404s
run hbo.ezfio -100.018582259097 -99.7127500068768 -99.6982683641297
}
@test "CH4" {
run ch4.ezfio -40.1996180778616 -39.7936150141939 -39.7936150141734
}
@test "CO2" {
run co2.ezfio -187.650710886151 -187.300746249524 -187.291641359067
}
@test "F2" {
run f2.ezfio -198.764357823385 -198.575548537096 -198.575548537096
}
@test "HCO" {
@test "HCO" { # 1.33255s
run hco.ezfio -113.0940242141341 -113.0023623703527 -112.8947302999338
}
@test "NH3" {
run nh3.ezfio -56.21783428981829 -55.91997684191139 -55.84753645754046
@test "H2O" { # 1.39318s
run h2o.ezfio -76.02702187043107 -75.6854407466997 -75.61967556334928
}
@test "SiH3" {
run sih3.ezfio -5.45916474249436 -5.23512810272682 -5.23512806272007
@test "H3COH" { # 1.40257s
run h3coh.ezfio -114.986503059639 -114.649121836046 -114.578365912794
}
@test "ClF" {
run clf.ezfio -558.844257066356 -558.664418728406 -558.664418728405
}
@test "H2O2" {
run h2o2.ezfio -150.780660847001 -150.546208866263 -150.483274551717
}
@test "H2S" {
@test "H2S" { # 1.44228s
run h2s.ezfio -398.694413042222 -398.447164835271 -398.412784774083
}
@test "N2H4" {
run n2h4.ezfio -111.179991667947 -110.894116344878 -110.855788839735
@test "ClF" { # 1.63289s
run clf.ezfio -558.844257066356 -558.664418728406 -558.664418728405
}
@test "OH" {
@test "ClO" { # 1.65582s
run clo.ezfio -534.263560525680 -534.256601571199 -534.062020844428
}
@test "SO" { # 1.9667s
run so.ezfio -25.7502263243068 -25.5862810638724 -25.5829361589673
}
@test "OH" { # 2.201s
run oh.ezfio -75.4314648243896 -75.4254639668256 -75.2707675632313
}
@test "SO2" {
@test "H2O2" { # 2.27079s
run h2o2.ezfio -150.780660847001 -150.546208866263 -150.483274551717
}
@test "CO2" { # 2.86928s
run co2.ezfio -187.650710886151 -187.300746249524 -187.291641359067
}
@test "C2H2" { # 3.00666s
run c2h2.ezfio -12.1214401949634 -11.8824874421211 -11.8682310791620
}
@test "HCN" { # 4.21678s
run hcn.ezfio -92.8871750003811 -92.6250263755063 -92.6089719143274
}
@test "N2H4" { # 4.81968s
run n2h4.ezfio -111.179991667947 -110.894116344878 -110.855788839735
}
@test "SiH3" { # 5.72801s
run sih3.ezfio -5.45916474249436 -5.23512810272682 -5.23512806272007
}
@test "N2" { # 6.11313s
run n2.ezfio -108.983489785305 -108.670192549322 -108.649653940027
}
@test "DHNO" { # 6.42976s
run dhno.ezfio -130.4472288472718 -130.3571808164850 -130.2196257046987
}
@test "CH4" { # 6.4969s
run ch4.ezfio -40.1996180778616 -39.7936150141939 -39.7936150141734
}
@test "F2" { # 10.4758s
run f2.ezfio -198.764357823385 -198.575548537096 -198.575548537096
}
@test "NH3" { # 14.2066s
[[ -n ${TRAVIS} ]] && skip
run nh3.ezfio -56.21783428981829 -55.91997684191139 -55.84753645754046
}
@test "[Cu(NH3)4]2+" { # 29.7711s
[[ -n ${TRAVIS} ]] && skip
run cu_nh3_4_2plus.ezfio -1862.97958709248 -1862.92454796197 -1862.91130872182
}
@test "SO2" { # 32.092s
[[ -n ${TRAVIS} ]] && skip
run so2.ezfio -41.5580019075645 -41.38232986913486 -41.35512503680323
}

View File

@ -18,108 +18,126 @@ function run() {
}
@test "HBO" {
run hbo.ezfio -100.2019254455993 -99.79484127741013
}
@test "H2O" {
run h2o.ezfio -76.22975602077072 -75.80609108747208
}
@test "[Cu(NH3)4]2+" {
qp_set_mo_class cu_nh3_4_2plus.ezfio -core "[1-24]" -act "[25-45]" -del "[46-87]"
run cu_nh3_4_2plus.ezfio -1862.9868140855440 -1862.9868140855440
}
@test "C2H2" {
qp_set_mo_class c2h2.ezfio -act "[1-30]" -del "[31-36]"
run c2h2.ezfio -12.3566731164213 -11.9495394759914
}
@test "ClO" {
run clo.ezfio -534.5404021326773 -534.3818725793897
}
@test "DHNO" {
qp_set_mo_class dhno.ezfio -core "[1-7]" -act "[8-64]"
run dhno.ezfio -130.458814562403 -130.356308303681
}
@test "H3COH" {
run h3coh.ezfio -115.204958752377 -114.755913828245
}
@test "HCN" {
qp_set_mo_class hcn.ezfio -core "[1,2]" -act "[3-40]" -del "[41-55]"
run hcn.ezfio -93.0776334511721 -92.6684633795506
}
@test "N2" {
qp_set_mo_class n2.ezfio -core "[1,2]" -act "[3-40]" -del "[41-60]"
run n2.ezfio -109.275693633982 -108.757794570948
}
@test "SiH2_3B1" {
@test "SiH2_3B1" { # 1.53842s
run sih2_3b1.ezfio -290.015949171697 -289.805036176618
}
@test "SO" {
run so.ezfio -26.0131812819785 -25.7053111980226
@test "HBO" { # 4.42968s
run hbo.ezfio -100.2019254455993 -99.79484127741013
}
@test "CH4" {
qp_set_mo_class ch4.ezfio -core "[1]" -act "[2-30]" -del "[31-59]"
run ch4.ezfio -40.2403962667047 -39.8433221754964
}
@test "CO2" {
qp_set_mo_class co2.ezfio -core "[1,2]" -act "[3-30]" -del "[31-42]"
run co2.ezfio -187.959378390998 -187.432502050556
}
@test "F2" {
qp_set_mo_class f2.ezfio -core "[1,2]" -act "[3-30]" -del "[31-62]"
run f2.ezfio -199.056829527539 -198.731828008346
}
@test "HCO" {
@test "HCO" { # 6.6077s
run hco.ezfio -113.288687359997 -113.122945162967
}
@test "NH3" {
qp_set_mo_class nh3.ezfio -core "[1-4]" -act "[5-72]"
run nh3.ezfio -56.2447484835843 -55.9521689975716
@test "H2O" { # 7.0651s
run h2o.ezfio -76.22975602077072 -75.80609108747208
}
@test "SiH3" {
run sih3.ezfio -5.57096611856522 -5.30950347928823
}
@test "ClF" {
run clf.ezfio -559.162476603880 -558.792395927088
}
@test "H2O2" {
qp_set_mo_class h2o2.ezfio -core "[1-2]" -act "[3-24]" -del "[25-38]"
run h2o2.ezfio -151.003775695363 -150.650247854914
}
@test "H2S" {
@test "H2S" { # 7.42152s
run h2s.ezfio -398.853701416768 -398.519020035337
}
@test "N2H4" {
@test "N2H4" { # 15.8394s
qp_set_mo_class n2h4.ezfio -core "[1-2]" -act "[3-24]" -del "[25-48]"
run n2h4.ezfio -111.366247464687 -110.990795989548
}
@test "OH" {
@test "H2O2" { # 16.3164s
qp_set_mo_class h2o2.ezfio -core "[1-2]" -act "[3-24]" -del "[25-38]"
run h2o2.ezfio -151.003775695363 -150.650247854914
}
@test "OH" { # 18.2159s
run oh.ezfio -75.6087472926588 -75.5370393736601
}
@test "SO2" {
@test "CH4" { # 19.821s
[[ -n $TRAVIS ]] && skip
qp_set_mo_class ch4.ezfio -core "[1]" -act "[2-30]" -del "[31-59]"
run ch4.ezfio -40.2403962667047 -39.8433221754964
}
@test "SiH3" { # 20.2202s
[[ -n $TRAVIS ]] && skip
run sih3.ezfio -5.57096611856522 -5.30950347928823
}
@test "NH3" { # 20.6771s
[[ -n $TRAVIS ]] && skip
qp_set_mo_class nh3.ezfio -core "[1-4]" -act "[5-72]"
run nh3.ezfio -56.2447484835843 -55.9521689975716
}
@test "DHNO" { # 24.7077s
[[ -n $TRAVIS ]] && skip
qp_set_mo_class dhno.ezfio -core "[1-7]" -act "[8-64]"
run dhno.ezfio -130.458814562403 -130.356308303681
}
@test "H3COH" { # 24.7248s
[[ -n $TRAVIS ]] && skip
run h3coh.ezfio -115.204958752377 -114.755913828245
}
@test "[Cu(NH3)4]2+" { # 29.9956s
[[ -n $TRAVIS ]] && skip
qp_set_mo_class cu_nh3_4_2plus.ezfio -core "[1-24]" -act "[25-45]" -del "[46-87]"
run cu_nh3_4_2plus.ezfio -1862.98659549315 -1862.68813764356
}
@test "ClF" { # 30.3225s
[[ -n $TRAVIS ]] && skip
run clf.ezfio -559.162476603880 -558.792395927088
}
@test "C2H2" { # 35.3324s
[[ -n $TRAVIS ]] && skip
qp_set_mo_class c2h2.ezfio -act "[1-30]" -del "[31-36]"
run c2h2.ezfio -12.3566731164213 -11.9495394759914
}
@test "ClO" { # 37.6949s
[[ -n $TRAVIS ]] && skip
run clo.ezfio -534.5404021326773 -534.3818725793897
}
@test "F2" { # 45.2078s
[[ -n $TRAVIS ]] && skip
qp_set_mo_class f2.ezfio -core "[1,2]" -act "[3-30]" -del "[31-62]"
run f2.ezfio -199.056829527539 -198.731828008346
}
@test "SO2" { # 47.6922s
[[ -n $TRAVIS ]] && skip
qp_set_mo_class so2.ezfio -core "[1-8]" -act "[9-87]"
run so2.ezfio -41.5746738710350 -41.3800467740750
}
@test "SO" { # 51.2476s
[[ -n $TRAVIS ]] && skip
run so.ezfio -26.0131812819785 -25.7053111980226
}
@test "CO2" { # 95.3736s
[[ -n $TRAVIS ]] && skip
qp_set_mo_class co2.ezfio -core "[1,2]" -act "[3-30]" -del "[31-42]"
run co2.ezfio -187.959378390998 -187.432502050556
}
@test "N2" { # 133.1814
[[ -n $TRAVIS ]] && skip
qp_set_mo_class n2.ezfio -core "[1,2]" -act "[3-40]" -del "[41-60]"
run n2.ezfio -109.275693633982 -108.757794570948
}
@test "HCN" { # 133.8696s
[[ -n $TRAVIS ]] && skip
qp_set_mo_class hcn.ezfio -core "[1,2]" -act "[3-40]" -del "[41-55]"
run hcn.ezfio -93.0776334511721 -92.6684633795506
}

View File

@ -5,6 +5,7 @@ ao_two_e_ints
aux_quantities
becke_numerical_grid
bitmask
cipsi
cis
cisd
davidson
@ -41,7 +42,6 @@ selectors_cassd
selectors_full
selectors_utils
single_ref_method
slave
tools
utils
zmq

View File

@ -1,7 +1,3 @@
perturbation
cipsi
selectors_full
generators_full
zmq
mpi
davidson_undressed
iterations

View File

@ -2,111 +2,14 @@
fci
===
Selected Full Configuration Interaction.
|CIPSI| algorithm in the full configuration interaction space.
The :command:`FCI` program starts with a single determinant, or with the wave
function in the |EZFIO| database if :option:`determinants read_wf` is |true|.
Then, it will iteratively:
* :command:`fci` performs the |CIPSI| calculation,
* :command:`pt2` computes the |PT2| contribution using the wave function stored in the |EZFIO|
database.
* Select the most important determinants from the external space and add them to the
internal space
* If :option:`determinants s2_eig` is |true|, add all the necessary
determinants to allow the eigenstates of |H| to be eigenstates of |S^2|
* Diagonalize |H| in the enlarged internal space
* Compute (stochastically) the second-order perturbative contribution to the energy
* Extrapolate the variational energy by fitting
:math:`E=E_\text{FCI} - \alpha\, E_\text{PT2}`
.. seealso::
The documentation of the :ref:`cipsi` module.
The number of selected determinants at each iteration will be such that the
size of the wave function will double at every iteration. If :option:`determinants
s2_eig` is |true|, then the number of selected determinants will be 1.5x the
current number, and then all the additional determinants will be added.
By default, the program will stop when more than one million determinants have
been selected, or when the |PT2| energy is below :math:`10^{-4}`.
The variational and |PT2| energies of the iterations are stored in the
|EZFIO| database, in the :ref:`iterations` module.
Computation of the |PT2| energy
-------------------------------
At each iteration, the |PT2| energy is computed considering the Epstein-Nesbet
zeroth-order Hamiltonian:
.. math::
E_{\text{PT2}} = \sum_{ \alpha }
\frac{|\langle \Psi_S | \hat{H} | \alpha \rangle|^2}
{E - \langle \alpha | \hat{H} | \alpha \rangle}
where the |kalpha| determinants are generated by applying all the single and
double excitation operators to all the determinants of the wave function
:math:`\Psi_G`.
When the hybrid-deterministic/stochastic algorithm is chosen
(default), :math:`Psi_G = \Psi_S = \Psi`, the full wavefunction expanded in the
internal space.
When the deterministic algorithm is chosen (:option:`perturbation do_pt2`
is set to |false|), :math:`Psi_G` is a truncation of |Psi| using
:option:`determinants threshold_generators`, and :math:`Psi_S` is a truncation
of |Psi| using :option:`determinants threshold_selectors`, and re-weighted
by :math:`1/\langle \Psi_s | \Psi_s \rangle`.
At every iteration, while computing the |PT2|, the variance of the wave
function is also computed:
.. math::
\sigma^2 & = \langle \Psi | \hat{H}^2 | \Psi \rangle -
\langle \Psi | \hat{H} | \Psi \rangle^2 \\
& = \sum_{i \in \text{FCI}}
\langle \Psi | \hat{H} | i \rangle
\langle i | \hat{H} | \Psi \rangle -
\langle \Psi | \hat{H} | \Psi \rangle^2 \\
& = \sum_{ \alpha }
\langle |\Psi | \hat{H} | \alpha \rangle|^2.
The expression of the variance is the same as the expression of the |PT2|, with
a denominator of 1. It measures how far the wave function is from the |FCI|
solution. Note that the absence of denominator in the Heat-Bath selected |CI|
method is selection method by minimization of the variance, whereas |CIPSI| is
a selection method by minimization of the energy.
If :option:`perturbation do_pt2` is set to |false|, then the stochastic
|PT2| is not computed, and an approximate value is obtained from the |CIPSI|
selection. The calculation is faster, but the extrapolated |FCI| value is
less accurate. This way of running the code should be used when the only
goal is to generate a wave function, as for using |CIPSI| wave functions as
trial wave functions of |QMC| calculations for example.
The :command:`PT2` program reads the wave function of the |EZFIO| database
and computes the energy and the |PT2| contribution.
State-averaging
---------------
Extrapolated |FCI| energy
-------------------------
An estimate of the |FCI| energy is computed by extrapolating
.. math::
E=E_\text{FCI} - \alpha\, E_\text{PT2}
This extrapolation is done for all the requested states, and excitation
energies are printed as energy differences between the extrapolated
energies of the excited states and the extrapolated energy of the ground
state.
The extrapolations are given considering the 2 last points, the 3 last points, ...,
the 7 last points. The extrapolated value should be chosen such that the extrpolated
value is stable with the number of points.

View File

@ -1,145 +1,20 @@
program fci
implicit none
BEGIN_DOC
! Selected Full Configuration Interaction.
! Selected Full Configuration Interaction with stochastic selection and PT2.
END_DOC
integer :: i,j,k
double precision, allocatable :: pt2(:), variance(:), norm(:), rpt2(:)
integer :: n_det_before, to_select
double precision :: rss
double precision, external :: memory_of_double
rss = memory_of_double(N_states)*4.d0
call check_mem(rss,irp_here)
allocate (pt2(N_states), rpt2(N_states), norm(N_states), variance(N_states))
double precision :: hf_energy_ref
logical :: has
double precision :: relative_error
PROVIDE H_apply_buffer_allocated
relative_error=PT2_relative_error
pt2 = -huge(1.e0)
rpt2 = -huge(1.e0)
norm = 0.d0
variance = 0.d0
if (s2_eig) then
call make_s2_eigenfunction
endif
call diagonalize_CI
call save_wavefunction
call ezfio_has_hartree_fock_energy(has)
if (has) then
call ezfio_get_hartree_fock_energy(hf_energy_ref)
else
hf_energy_ref = ref_bitmask_energy
endif
if (N_det > N_det_max) then
psi_det = psi_det_sorted
psi_coef = psi_coef_sorted
N_det = N_det_max
soft_touch N_det psi_det psi_coef
call diagonalize_CI
call save_wavefunction
endif
n_det_before = 0
double precision :: correlation_energy_ratio
double precision :: threshold_generators_save
threshold_generators_save = threshold_generators
double precision :: error(N_states)
correlation_energy_ratio = 0.d0
do while ( &
(N_det < N_det_max) .and. &
(maxval(abs(pt2(1:N_states))) > pt2_max) .and. &
(correlation_energy_ratio <= correlation_energy_ratio_max) &
)
write(*,'(A)') '--------------------------------------------------------------------------------'
if (.not.is_zmq_slave) then
if (do_pt2) then
pt2 = 0.d0
variance = 0.d0
norm = 0.d0
threshold_generators = 1.d0
SOFT_TOUCH threshold_generators
call ZMQ_pt2(psi_energy_with_nucl_rep,pt2,relative_error,error, variance, norm) ! Stochastic PT2
threshold_generators = threshold_generators_save
SOFT_TOUCH threshold_generators
call run_stochastic_cipsi
else
call run_cipsi
endif
else
correlation_energy_ratio = (psi_energy_with_nucl_rep(1) - hf_energy_ref) / &
(psi_energy_with_nucl_rep(1) + pt2(1) - hf_energy_ref)
correlation_energy_ratio = min(1.d0,correlation_energy_ratio)
call run_slave_cipsi
call ezfio_set_fci_energy_pt2(psi_energy_with_nucl_rep+pt2)
call write_double(6,correlation_energy_ratio, 'Correlation ratio')
call print_summary(psi_energy_with_nucl_rep(1:N_states),pt2,error,variance,norm)
do k=1,N_states
rpt2(:) = pt2(:)/(1.d0 + norm(k))
enddo
call save_iterations(psi_energy_with_nucl_rep(1:N_states),rpt2,N_det)
call print_extrapolated_energy(psi_energy_with_nucl_rep(1:N_states),rpt2)
N_iter += 1
n_det_before = N_det
to_select = N_det
to_select = max(N_states_diag, to_select)
! to_select = min(to_select, N_det_max-n_det_before)
call ZMQ_selection(to_select, pt2, variance, norm)
PROVIDE psi_coef
PROVIDE psi_det
PROVIDE psi_det_sorted
call diagonalize_CI
call save_wavefunction
call ezfio_set_fci_energy(psi_energy_with_nucl_rep(1:N_states))
enddo
if (N_det < N_det_max) then
call diagonalize_CI
call save_wavefunction
call ezfio_set_fci_energy(psi_energy_with_nucl_rep(1:N_states))
call ezfio_set_fci_energy_pt2(psi_energy_with_nucl_rep(1:N_states)+pt2)
endif
if (do_pt2) then
pt2 = 0.d0
variance = 0.d0
norm = 0.d0
threshold_generators = 1d0
SOFT_TOUCH threshold_generators
call ZMQ_pt2(psi_energy_with_nucl_rep, pt2,relative_error,error,variance,norm) ! Stochastic PT2
threshold_generators = threshold_generators_save
SOFT_TOUCH threshold_generators
call ezfio_set_fci_energy(psi_energy_with_nucl_rep(1:N_states))
call ezfio_set_fci_energy_pt2(psi_energy_with_nucl_rep(1:N_states)+pt2)
endif
print *, 'N_det = ', N_det
print *, 'N_sop = ', N_occ_pattern
print *, 'N_states = ', N_states
print*, 'correlation_ratio = ', correlation_energy_ratio
do k=1,N_states
rpt2(:) = pt2(:)/(1.d0 + norm(k))
enddo
call print_summary(psi_energy_with_nucl_rep(1:N_states),pt2,error,variance,norm)
call save_iterations(psi_energy_with_nucl_rep(1:N_states),rpt2,N_det)
call print_extrapolated_energy(psi_energy_with_nucl_rep(1:N_states),rpt2)
end

View File

@ -4,12 +4,16 @@ program pt2
! Second order perturbative correction to the wave function contained in the
! EZFIO directory.
END_DOC
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
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
else
call run_slave_cipsi
endif
end
subroutine run
@ -29,15 +33,14 @@ subroutine run
E_CI_before(:) = psi_energy(:) + nuclear_repulsion
relative_error=PT2_relative_error
call ZMQ_pt2(psi_energy_with_nucl_rep,pt2,relative_error,error, variance, norm) ! Stochastic PT2
call ZMQ_pt2(psi_energy_with_nucl_rep,pt2,relative_error,error, variance, &
norm,0) ! Stochastic PT2
do k=1,N_states
rpt2(:) = pt2(:)/(1.d0 + norm(k))
enddo
call print_summary(psi_energy_with_nucl_rep(1:N_states),pt2,error,variance,norm)
call ezfio_set_fci_energy(E_CI_before)
call ezfio_set_fci_energy_pt2(E_CI_before+pt2)
call print_summary(psi_energy_with_nucl_rep(1:N_states),pt2,error,variance,norm,N_det,N_occ_pattern)
call save_energy(E_CI_before,pt2)
end

View File

@ -0,0 +1,9 @@
subroutine save_energy(E,pt2)
implicit none
BEGIN_DOC
! Saves the energy in |EZFIO|.
END_DOC
double precision, intent(in) :: E(N_states), pt2(N_states)
call ezfio_set_fci_energy(E(1:N_states))
call ezfio_set_fci_energy_pt2(E(1:N_states)+pt2(1:N_states))
end

View File

@ -15,98 +15,100 @@ function run() {
}
@test "SiH2_3B1" { # 0.539000
run sih2_3b1.ezfio -289.9654718650881
}
@test "HBO" {
@test "SO" { # 0.539000
run so.ezfio -25.71752633718843
}
@test "HCO" { # 0.636700
run hco.ezfio -113.0862778269114
}
@test "HBO" { # 0.805600
run hbo.ezfio -100.018582259096
}
@test "H2O" {
@test "H2S" { # 1.655600
run h2s.ezfio -398.6944130421982
}
@test "H3COH" { # 1.751000
run h3coh.ezfio -114.9865030596373
}
@test "H2O" { # 1.811100
run h2o.ezfio -0.760270218692179E+02
}
@test "[Cu(NH3)4]2+" {
@test "H2O2" { # 2.217000
run h2o2.ezfio -150.7806608469964
}
@test "ClF" { # 2.797000
run clf.ezfio -558.8442570663570
}
@test "CO2" { # 2.811100
run co2.ezfio -187.6507108861204
}
@test "N2H4" { # 4.054600
run n2h4.ezfio -111.1799916679009
}
@test "ClO" { # 4.927400
run clo.ezfio -534.2496714154559
}
@test "F2" { # 5.070800
run f2.ezfio -198.7643578233773
}
@test "CH4" { # 5.994000
run ch4.ezfio -40.19961807784367
}
@test "HCN" { # 7.792500
run hcn.ezfio -92.88717500035233
}
@test "N2" { # 8.648100
run n2.ezfio -108.9834897852979
}
@test "DHNO" { # 12.856700
run dhno.ezfio -130.4278777822
}
@test "NH3" { # 13.632200
run nh3.ezfio -56.21783428976567
}
@test "C2H2" { # 19.599000
run c2h2.ezfio -12.12144019495306
}
@test "SiH3" { # 20.316100
run sih3.ezfio -5.455398769158780
}
@test "OH" { # 32.042200
run oh.ezfio -75.42025413469165
}
@test "[Cu(NH3)4]2+" { # 59.610100
[[ -n $TRAVIS ]] && skip
ezfio set_file cu_nh3_4_2plus.ezfio
ezfio set scf_utils thresh_scf 1.e-10
run cu_nh3_4_2plus.ezfio -1862.97590388214
}
@test "C2H2" {
run c2h2.ezfio -12.12144019495306
}
@test "ClO" {
run clo.ezfio -534.2496714154559
}
@test "DHNO" {
run dhno.ezfio -130.4278777822
}
@test "H3COH" {
run h3coh.ezfio -114.9865030596373
}
@test "HCN" {
run hcn.ezfio -92.88717500035233
}
@test "N2" {
run n2.ezfio -108.9834897852979
}
@test "SiH2_3B1" {
run sih2_3b1.ezfio -289.9654718650881
}
@test "SO" {
run so.ezfio -25.71752633718843
}
@test "CH4" {
run ch4.ezfio -40.19961807784367
}
@test "CO2" {
run co2.ezfio -187.6507108861204
}
@test "F2" {
run f2.ezfio -198.7643578233773
}
@test "HCO" {
run hco.ezfio -113.0862778269114
}
@test "NH3" {
run nh3.ezfio -56.21783428976567
}
@test "SiH3" {
run sih3.ezfio -5.455398769158780
}
@test "ClF" {
run clf.ezfio -558.8442570663570
}
@test "H2O2" {
run h2o2.ezfio -150.7806608469964
}
@test "H2S" {
run h2s.ezfio -398.6944130421982
}
@test "N2H4" {
run n2h4.ezfio -111.1799916679009
}
@test "OH" {
run oh.ezfio -75.42025413469165
}
@test "SO2" {
@test "SO2" { # 71.894900
[[ -n $TRAVIS ]] && skip
run so2.ezfio -41.55800190733211
}

View File

@ -34,7 +34,7 @@
ao_two_e_integral_beta_tmp = 0.d0
q = ao_num*ao_num*ao_num*ao_num
!$OMP DO SCHEDULE(static,1)
!$OMP DO SCHEDULE(static,64)
do p=1_8,q
call two_e_integrals_index_reverse(kk,ii,ll,jj,p)
if ( (kk(1)>ao_num).or. &
@ -90,8 +90,6 @@
!$OMP END DO NOWAIT
!$OMP CRITICAL
ao_two_e_integral_alpha += ao_two_e_integral_alpha_tmp
!$OMP END CRITICAL
!$OMP CRITICAL
ao_two_e_integral_beta += ao_two_e_integral_beta_tmp
!$OMP END CRITICAL
deallocate(keys,values,ao_two_e_integral_alpha_tmp,ao_two_e_integral_beta_tmp)
@ -143,13 +141,9 @@
enddo
enddo
enddo
!$OMP END DO
!$OMP BARRIER
!$OMP END DO NOWAIT
!$OMP CRITICAL
ao_two_e_integral_alpha += ao_two_e_integral_alpha_tmp
!$OMP END CRITICAL
!$OMP BARRIER
!$OMP CRITICAL
ao_two_e_integral_beta += ao_two_e_integral_beta_tmp
!$OMP END CRITICAL
deallocate(keys,values,ao_two_e_integral_alpha_tmp,ao_two_e_integral_beta_tmp)

View File

@ -1,10 +1,9 @@
subroutine print_extrapolated_energy(e_,pt2_)
subroutine print_extrapolated_energy
implicit none
BEGIN_DOC
! Print the extrapolated energy in the output
END_DOC
double precision, intent(in) :: e_(N_states), pt2_(N_states)
integer :: i,k
if (N_iter< 2) then

View File

@ -1,10 +1,11 @@
subroutine print_summary(e_,pt2_,error_,variance_,norm_)
subroutine print_summary(e_,pt2_,error_,variance_,norm_,n_det_,n_occ_pattern_)
implicit none
BEGIN_DOC
! Print the extrapolated energy in the output
END_DOC
double precision, intent(in) :: e_(N_states), pt2_(N_states), variance_(N_states), norm_(N_states), error_(N_states)
integer, intent(in) :: n_det_, n_occ_pattern_
integer :: i, k
integer :: N_states_p
character*(9) :: pt2_string
@ -17,14 +18,14 @@ subroutine print_summary(e_,pt2_,error_,variance_,norm_)
pt2_string = '(approx)'
endif
N_states_p = min(N_det,N_states)
N_states_p = min(N_det_,N_states)
do i=1,N_states_p
f(i) = 1.d0/(1.d0+norm_(i))
enddo
print *, ''
print '(A,I12)', 'Summary at N_det = ', N_det
print '(A,I12)', 'Summary at N_det = ', N_det_
print '(A)', '-----------------------------------'
print *, ''
@ -55,10 +56,10 @@ subroutine print_summary(e_,pt2_,error_,variance_,norm_)
write(*,fmt)
print *, ''
print *, 'N_det = ', N_det
print *, 'N_det = ', N_det_
print *, 'N_states = ', N_states
if (s2_eig) then
print *, 'N_sop = ', N_occ_pattern
print *, 'N_sop = ', N_occ_pattern_
endif
print *, ''

View File

@ -19,7 +19,6 @@ function run() {
}
@test "H3COH" {
run h3coh.ezfio short_range_PBE -115.50238225208
}
@ -36,3 +35,4 @@ function run() {
run sih2_3b1.ezfio short_range_LDA -289.4398733527755
}

View File

@ -35,7 +35,7 @@
ao_two_e_integral_beta_tmp = 0.d0
q = ao_num*ao_num*ao_num*ao_num
!$OMP DO SCHEDULE(dynamic)
!$OMP DO SCHEDULE(static,64)
do p=1_8,q
call two_e_integrals_index_reverse(kk,ii,ll,jj,p)
if ( (kk(1)>ao_num).or. &
@ -91,8 +91,6 @@
!$OMP END DO NOWAIT
!$OMP CRITICAL
ao_two_e_integral_alpha += ao_two_e_integral_alpha_tmp
!$OMP END CRITICAL
!$OMP CRITICAL
ao_two_e_integral_beta += ao_two_e_integral_beta_tmp
!$OMP END CRITICAL
deallocate(keys,values,ao_two_e_integral_alpha_tmp,ao_two_e_integral_beta_tmp)
@ -111,7 +109,7 @@
integer(key_kind), allocatable :: keys_erf(:)
double precision, allocatable :: values_erf(:)
!$OMP PARALLEL DEFAULT(NONE) &
!$OMP PARALLEL DEFAULT(NONE) if (ao_num > 100) &
!$OMP PRIVATE(i,j,l,k1,k,integral,ii,jj,kk,ll,i8,keys,values,n_elements_max, &
!$OMP n_elements,ao_two_e_integral_alpha_tmp,ao_two_e_integral_beta_tmp)&
!$OMP SHARED(ao_num,SCF_density_matrix_ao_alpha,SCF_density_matrix_ao_beta,&
@ -124,7 +122,7 @@
ao_two_e_integral_alpha_tmp = 0.d0
ao_two_e_integral_beta_tmp = 0.d0
!$OMP DO SCHEDULE(dynamic,64)
!$OMP DO SCHEDULE(static,1)
!DIR$ NOVECTOR
do i8=0_8,ao_integrals_map%map_size
n_elements = n_elements_max
@ -147,16 +145,14 @@
enddo
enddo
!$OMP END DO NOWAIT
!$OMP CRITICAL
!$OMP CRITICAL
ao_two_e_integral_alpha += ao_two_e_integral_alpha_tmp
!$OMP END CRITICAL
!$OMP CRITICAL
ao_two_e_integral_beta += ao_two_e_integral_beta_tmp
!$OMP END CRITICAL
deallocate(keys,values,ao_two_e_integral_alpha_tmp,ao_two_e_integral_beta_tmp)
!$OMP END PARALLEL
!$OMP PARALLEL DEFAULT(NONE) &
!$OMP PARALLEL DEFAULT(NONE) if (ao_num > 100) &
!$OMP PRIVATE(i,j,l,k1,k,integral_erf,ii,jj,kk,ll,i8,keys_erf,values_erf,n_elements_max_erf, &
!$OMP n_elements_erf,ao_two_e_integral_alpha_tmp,ao_two_e_integral_beta_tmp)&
!$OMP SHARED(ao_num,SCF_density_matrix_ao_alpha,SCF_density_matrix_ao_beta,&
@ -170,7 +166,7 @@
ao_two_e_integral_alpha_tmp = 0.d0
ao_two_e_integral_beta_tmp = 0.d0
!$OMP DO SCHEDULE(dynamic,64)
!$OMP DO SCHEDULE(static,1)
!DIR$ NOVECTOR
do i8=0_8,ao_integrals_erf_map%map_size
n_elements_erf = n_elements_max_erf
@ -197,8 +193,6 @@
!$OMP END DO NOWAIT
!$OMP CRITICAL
ao_two_e_integral_alpha = ao_two_e_integral_alpha + ao_two_e_integral_alpha_tmp
!$OMP END CRITICAL
!$OMP CRITICAL
ao_two_e_integral_beta = ao_two_e_integral_beta + ao_two_e_integral_beta_tmp
!$OMP END CRITICAL
deallocate(ao_two_e_integral_alpha_tmp,ao_two_e_integral_beta_tmp)

View File

@ -289,7 +289,7 @@ END_DOC
! Compute extrapolated Fock matrix
!$OMP PARALLEL DO PRIVATE(i,j,k) DEFAULT(SHARED)
!$OMP PARALLEL DO PRIVATE(i,j,k) DEFAULT(SHARED) if (ao_num > 200)
do j=1,ao_num
do i=1,ao_num
Fock_matrix_AO_(i,j) = 0.d0

View File

@ -1,2 +0,0 @@
fci
mpi

View File

@ -1,6 +0,0 @@
=====
slave
=====
Slave processes for distributed parallelism.

View File

@ -1,50 +0,0 @@
program qp_ao_ints
use omp_lib
implicit none
IRP_IF MPI
include 'mpif.h'
IRP_ENDIF
integer :: ierr
BEGIN_DOC
! Slave for electron repulsion integrals
END_DOC
integer :: i
PROVIDE zmq_context mpi_master zmq_state zmq_context
call switch_qp_run_to_master
zmq_context = f77_zmq_ctx_new ()
! Set the state of the ZMQ
zmq_state = 'ao_integrals'
! Provide everything needed
double precision :: integral, ao_two_e_integral
integral = ao_two_e_integral(1,1,1,1)
do
call wait_for_state('ao_integrals',zmq_state)
if (zmq_state(1:7) == 'Stopped') then
exit
endif
!$OMP PARALLEL DEFAULT(PRIVATE) PRIVATE(i)
i = omp_get_thread_num()
call ao_two_e_integrals_in_map_slave_tcp(i)
!$OMP END PARALLEL
IRP_IF MPI
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
if (ierr /= MPI_SUCCESS) then
print *, irp_here, 'error in barrier'
endif
IRP_ENDIF
enddo
IRP_IF MPI
call MPI_finalize(i)
IRP_ENDIF
print *, 'Done'
end

View File

@ -91,8 +91,8 @@ subroutine switch_qp_run_to_master
END_DOC
character*(128) :: buffer
call getenv('QP_RUN_ADDRESS_MASTER',buffer)
if (trim(buffer) == '') then
print *, 'This run should be started with the qp_run command'
if (.not.is_zmq_slave) then
print *, 'This run should be started with "qp_run -slave"'
stop -1
endif
qp_run_address = adjustl(buffer)
@ -1283,3 +1283,14 @@ subroutine wait_for_states(state_wait,state,n)
end
BEGIN_PROVIDER [ logical, is_zmq_slave ]
implicit none
BEGIN_DOC
! If |true|, the current process is a |ZeroMQ| slave.
END_DOC
character*(128) :: buffer
call getenv('QP_RUN_ADDRESS_MASTER',buffer)
is_zmq_slave = (trim(buffer) /= '')
END_PROVIDER

1
tests/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
work