cipsi

CIPSI algorithm.

The run_stochastic_cipsi() and run_cipsi() subroutines start with a single determinant, or with the wave function in the EZFIO database if determinants read_wf is true.

The run_cipsi() subroutine iteratively:

  • Selects the most important determinants from the external space and adds them to the internal space

  • If determinants s2_eig is true, it adds all the necessary determinants to allow the eigenstates of \(\hat H\) to be eigenstates of \(\widehat{S^2}\)

  • Diagonalizes \(\hat H\) in the enlarged internal space

  • Computes the PT2 contribution to the energy stochastically [22] or deterministically, depending on perturbation do_pt2

  • Extrapolates the variational energy by fitting \(E=E_\text{FCI} - \alpha\, E_\text{PT2}\)

The difference between run_stochastic_cipsi() and run_cipsi() is that run_stochastic_cipsi() selects the determinants on the fly with the computation of the stochastic PT2 [22]. 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 [22].

  • If determinants s2_eig is true, it adds all the necessary determinants to allow the eigenstates of \(\hat H\) to be eigenstates of \(\widehat{S^2}\)

  • Extrapolates the variational energy by fitting \(E=E_\text{FCI} - \alpha\, E_\text{PT2}\)

  • Diagonalizes \(\hat 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 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 \(10^{-4}\).

The variational and PT2 energies of the iterations are stored in the EZFIO database, in the iterations module.

Computation of the PT2 energy

At each iteration, the PT2 energy is computed considering the Epstein-Nesbet zeroth-order Hamiltonian:

\[E_{\text{PT2}} = \sum_{ \alpha } \frac{|\langle \Psi_S | \hat{H} | \alpha \rangle|^2} {E - \langle \alpha | \hat{H} | \alpha \rangle}\]

where the \(|\alpha \rangle\) determinants are generated by applying all the single and double excitation operators to all the determinants of the wave function \(\Psi_G\).

When the hybrid-deterministic/stochastic algorithm is chosen (default), \(Psi_G = \Psi_S = \Psi\), the full wavefunction expanded in the internal space. When the deterministic algorithm is chosen (perturbation do_pt2 is set to false), \(Psi_G\) is a truncation of \(|\Psi \rangle\) using determinants threshold_generators, and \(Psi_S\) is a truncation of \(|\Psi \rangle\) using determinants threshold_selectors, and re-weighted by \(1/\langle \Psi_s | \Psi_s \rangle\).

At every iteration, while computing the PT2, the variance of the wave function is also computed:

\[\begin{split}\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.\end{split}\]

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 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 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

\[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.

EZFIO parameters

save_wf_after_selection

If true, saves the wave function after the selection, before the diagonalization

Default: False

seniority_max

Maximum number of allowed open shells. Using -1 selects all determinants

Default: -1

excitation_ref

1: Hartree-Fock determinant, 2:All determinants of the dominant configuration

Default: 1

excitation_max

Maximum number of excitation with respect to the Hartree-Fock determinant. Using -1 selects all determinants

Default: -1

excitation_alpha_max

Maximum number of excitation for alpha determinants with respect to the Hartree-Fock determinant. Using -1 selects all determinants

Default: -1

excitation_beta_max

Maximum number of excitation for beta determinants with respect to the Hartree-Fock determinant. Using -1 selects all determinants

Default: -1

twice_hierarchy_max

Twice the maximum hierarchy parameter (excitation degree plus half the seniority number). Using -1 selects all determinants

Default: -1

Providers

initialize_pt2_e0_denominator

File : cipsi/energy.irp.f

logical :: initialize_pt2_e0_denominator

If true, initialize pt2_E0_denominator

Needed by:

  • pt2_e0_denominator

pt2_e0_denominator

File : cipsi/energy.irp.f

double precision, allocatable   :: pt2_e0_denominator   (N_states)

E0 in the denominator of the PT2

Needs:

  • barycentric_electronic_energy

  • h0_type

  • initialize_pt2_e0_denominator

  • mpi_master

  • n_states

  • nuclear_repulsion

  • psi_coef

  • psi_det_hii

  • psi_energy

Subroutines / functions

bitstring_to_list_in_selection:

File : cipsi/selection.irp.f

subroutine bitstring_to_list_in_selection( string, list, n_elements, Nint)

Gives the indices(+1) of the bits set to 1 in the bit string

Called by:

  • splash_pq()

  • spot_isinwf()

fill_buffer_double:

File : cipsi/selection.irp.f_template_915

subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_diag_tmp, E0, pt2_data, mat, buf)

Needs:

  • c0_weight

  • det_to_configuration

  • do_only_1h1p

  • do_ormas

  • dominant_dets_of_cfgs

  • elec_alpha_num

  • excitation_alpha_max

  • excitation_beta_max

  • excitation_max

  • excitation_ref

  • h0_type

  • hf_bitmask

  • mo_integrals_threshold

  • mo_num

  • n_dominant_dets_of_cfgs

  • n_int

  • n_states

  • pseudo_sym

  • psi_configuration_hii

  • psi_det_generators

  • psi_det_hii

  • selection_weight

  • seniority_max

  • thresh_sym

  • twice_hierarchy_max

  • weight_selection

Called by:

  • select_singles_and_doubles()

Calls:

  • add_to_selection_buffer()

  • apply_hole()

  • apply_holes()

  • apply_particle()

  • apply_particles()

  • configuration_to_dets_size()

  • dsyev()

  • get_excitation_degree()

  • get_excitation_degree_spin()

fill_buffer_single:

File : cipsi/selection.irp.f_template_915

subroutine fill_buffer_single(i_generator, sp, h1, h2, bannedOrb, banned, fock_diag_tmp, E0, pt2_data, mat, buf)

Needs:

  • c0_weight

  • det_to_configuration

  • do_only_1h1p

  • do_ormas

  • dominant_dets_of_cfgs

  • elec_alpha_num

  • excitation_alpha_max

  • excitation_beta_max

  • excitation_max

  • excitation_ref

  • h0_type

  • hf_bitmask

  • mo_integrals_threshold

  • mo_num

  • n_dominant_dets_of_cfgs

  • n_int

  • n_states

  • pseudo_sym

  • psi_configuration_hii

  • psi_det_generators

  • psi_det_hii

  • selection_weight

  • seniority_max

  • thresh_sym

  • twice_hierarchy_max

  • weight_selection

Called by:

  • select_singles()

Calls:

  • add_to_selection_buffer()

  • apply_hole()

  • apply_holes()

  • apply_particle()

  • apply_particles()

  • configuration_to_dets_size()

  • dsyev()

  • get_excitation_degree()

  • get_excitation_degree_spin()

get_d0:

File : cipsi/selection.irp.f

subroutine get_d0(gen, phasemask, bannedOrb, banned, mat, mask, h, p, sp, coefs)

Needs:

  • mo_integrals_map

  • mo_integrals_threshold

  • mo_num

  • n_int

  • n_states

Called by:

  • splash_pq()

Calls:

  • apply_particles()

  • get_mo_two_e_integrals()

  • i_h_j()

get_d0_reference:

File : cipsi/selection_old.irp.f

subroutine get_d0_reference(gen, phasemask, bannedOrb, banned, mat, mask, h, p, sp, coefs)

Needs:

  • mo_num

  • n_int

  • n_states

Calls:

  • apply_particles()

  • i_h_j()

get_d1:

File : cipsi/selection.irp.f

subroutine get_d1(gen, phasemask, bannedOrb, banned, mat, mask, h, p, sp, coefs)

Needs:

  • mo_integrals_map

  • mo_num

  • n_int

  • n_states

Called by:

  • splash_pq()

Calls:

  • apply_particles()

  • get_mo_two_e_integrals()

  • i_h_j()

get_d1_reference:

File : cipsi/selection_old.irp.f

subroutine get_d1_reference(gen, phasemask, bannedOrb, banned, mat, mask, h, p, sp, coefs)

Needs:

  • mo_num

  • n_int

  • n_states

Calls:

  • apply_particles()

  • i_h_j()

get_d2:

File : cipsi/selection.irp.f

subroutine get_d2(gen, phasemask, bannedOrb, banned, mat, mask, h, p, sp, coefs)

Needs:

  • mo_integrals_threshold

  • mo_num

  • n_int

  • n_states

Called by:

  • splash_pq()

get_d2_reference:

File : cipsi/selection_old.irp.f

subroutine get_d2_reference(gen, phasemask, bannedOrb, banned, mat, mask, h, p, sp, coefs)

Needs:

  • mo_num

  • n_int

  • n_states

get_m0:

File : cipsi/selection_singles.irp.f

subroutine get_m0(gen, phasemask, bannedOrb, vect, mask, h, p, sp, coefs)

Needs:

  • mo_num

  • n_int

  • n_states

Called by:

  • splash_p()

Calls:

  • apply_particle()

  • i_h_j()

get_m1:

File : cipsi/selection_singles.irp.f

subroutine get_m1(gen, phasemask, bannedOrb, vect, mask, h, p, sp, coefs)

Needs:

  • mo_num

  • n_int

  • n_states

Called by:

  • splash_p()

Calls:

  • apply_particle()

  • i_h_j()

get_m2:

File : cipsi/selection_singles.irp.f

subroutine get_m2(gen, phasemask, bannedOrb, vect, mask, h, p, sp, coefs)

Needs:

  • mo_num

  • n_int

  • n_states

Called by:

  • splash_p()

get_mask_phase:

File : cipsi/selection.irp.f

subroutine get_mask_phase(det1, pm, Nint)

Called by:

  • splash_p()

  • splash_pq()

get_phase_bi:

File : cipsi/selection.irp.f

double precision function get_phase_bi(phasemask, s1, s2, h1, p1, h2, p2, Nint)
provide_for_selection_slave:

File : cipsi/run_selection_slave.irp.f

subroutine provide_for_selection_slave

Needs:

  • psi_det_sorted

  • psi_det_sorted

  • psi_selectors_coef_transp

Called by:

  • run_selection_slave()

provide_for_zmq_pt2:

File : cipsi/pt2_stoch_routines.irp.f

subroutine provide_for_zmq_pt2

Needs:

  • psi_det_hii

  • psi_det_sorted

  • psi_det_sorted

  • psi_selectors_coef_transp

Called by:

  • run_slave_main()

  • zmq_pt2()

run_cipsi:

File : cipsi/cipsi.irp.f

subroutine run_cipsi

Selected Full Configuration Interaction with deterministic selection and stochastic PT2.

Needs:

  • correlation_energy_ratio_max

  • do_pt2

  • h_apply_buffer_allocated

  • n_det

  • n_det_max

  • n_states

  • n_states_diag

  • psi_coef

  • psi_configuration

  • psi_det

  • psi_det_sorted

  • psi_energy

  • psi_energy_with_nucl_rep

  • pt2_max

  • pt2_relative_error

  • ref_bitmask_energy

  • s2_eig

  • save_wf_after_selection

  • selection_factor

  • threshold_generators

  • variance_max

Calls:

  • check_mem()

  • copy_h_apply_buffer_to_wf()

  • diagonalize_ci()

  • ezfio_get_hartree_fock_energy()

  • ezfio_has_hartree_fock_energy()

  • increment_n_iter()

  • make_s2_eigenfunction()

  • print_extrapolated_energy()

  • print_mol_properties()

  • print_summary()

  • pt2_alloc()

  • pt2_dealloc()

  • save_energy()

  • save_wavefunction()

  • write_cipsi_json()

  • write_double()

  • zmq_pt2()

  • zmq_selection()

Touches:

  • ci_electronic_energy

  • ci_electronic_energy

  • ci_energy

  • ci_electronic_energy

  • psi_configuration

  • n_det

  • c0_weight

  • psi_coef

  • psi_det_sorted_bit

  • psi_configuration

  • psi_det

  • psi_det_size

  • psi_det_sorted_bit

  • psi_energy

  • psi_energy

  • pt2_match_weight

  • pt2_overlap

  • pt2_stoch_istate

  • selection_weight

  • state_average_weight

  • threshold_davidson_pt2

  • threshold_generators

  • variance_match_weight

run_stochastic_cipsi:

File : cipsi/stochastic_cipsi.irp.f

subroutine run_stochastic_cipsi(Ev,PT2)

Selected Full Configuration Interaction with Stochastic selection and PT2.

Needs:

  • correlation_energy_ratio_max

  • distributed_davidson

  • h_apply_buffer_allocated

  • mo_two_e_integrals_in_map

  • n_det

  • n_det_max

  • n_states

  • n_states_diag

  • psi_coef

  • psi_configuration

  • psi_det

  • psi_det_sorted

  • psi_energy

  • psi_energy_with_nucl_rep

  • pt2_max

  • pt2_relative_error

  • ref_bitmask_energy

  • s2_eig

  • save_wf_after_selection

  • selection_factor

  • threshold_generators

  • variance_max

Called by:

  • run_optimization_mos_cipsi()

Calls:

  • check_mem()

  • copy_h_apply_buffer_to_wf()

  • diagonalize_ci()

  • ezfio_get_hartree_fock_energy()

  • ezfio_has_hartree_fock_energy()

  • increment_n_iter()

  • make_s2_eigenfunction()

  • print_extrapolated_energy()

  • print_mol_properties()

  • print_summary()

  • pt2_alloc()

  • pt2_dealloc()

  • save_energy()

  • save_wavefunction()

  • write_cipsi_json()

  • write_double()

  • zmq_pt2()

Touches:

  • ci_electronic_energy

  • ci_electronic_energy

  • ci_energy

  • ci_electronic_energy

  • psi_configuration

  • n_det

  • c0_weight

  • psi_coef

  • psi_det_sorted_bit

  • psi_configuration

  • psi_det

  • psi_det_size

  • psi_det_sorted_bit

  • psi_energy

  • psi_energy

  • pt2_match_weight

  • pt2_overlap

  • pt2_stoch_istate

  • selection_weight

  • state_average_weight

  • threshold_davidson_pt2

  • threshold_generators

  • variance_match_weight

select_connected:

File : cipsi/selection.irp.f

subroutine select_connected(i_generator,E0,pt2_data,b,subset,csubset)

Needs:

  • generators_bitmask

  • mo_num

  • n_int

  • n_states

  • psi_det_generators

Called by:

  • run_pt2_slave_large()

  • run_pt2_slave_small()

  • run_selection_slave()

Calls:

  • build_fock_tmp()

  • select_singles()

  • select_singles_and_doubles()

select_singles:

File : cipsi/selection_singles.irp.f

subroutine select_singles(i_gen,hole_mask,particle_mask,fock_diag_tmp,E0,pt2_data,buf)

Select determinants connected to i_det by H

Needs:

  • mo_num

  • n_det

  • n_det_selectors

  • n_int

  • n_states

  • psi_det_generators

  • psi_det_sorted

  • psi_selectors

  • psi_selectors_coef_transp

Called by:

  • select_connected()

Calls:

  • apply_hole()

  • bitstring_to_list_ab()

  • fill_buffer_single()

  • splash_p()

  • spot_hasbeen()

select_singles_and_doubles:

File : cipsi/selection.irp.f

subroutine select_singles_and_doubles(i_generator, hole_mask, particle_mask, fock_diag_tmp, E0, pt2_data, buf, subset, csubset)

WARNING /!: It is assumed that the generators and selectors are psi_det_sorted

Needs:

  • banned_excitation

  • mo_num

  • n_det

  • n_det_selectors

  • n_int

  • n_states

  • psi_bilinear_matrix_columns_loc

  • psi_bilinear_matrix_values

  • psi_bilinear_matrix_values

  • psi_bilinear_matrix_transp_values

  • psi_bilinear_matrix_transp_values

  • psi_bilinear_matrix_transp_rows_loc

  • psi_bilinear_matrix_transp_values

  • psi_bilinear_matrix_values

  • psi_det_alpha_unique

  • psi_det_beta_unique

  • psi_det_generators

  • psi_det_sorted

  • psi_det_sorted

  • psi_selectors_coef_transp

Called by:

  • select_connected()

Calls:

  • apply_hole()

  • bitstring_to_list_ab()

  • fill_buffer_double()

  • get_excitation_degree_spin()

  • isort_noidx()

  • splash_pq()

  • spot_isinwf()

splash_p:

File : cipsi/selection_singles.irp.f

subroutine splash_p(mask, sp, det, coefs, N_sel, bannedOrb, vect)

Needs:

  • mo_num

  • n_int

  • n_states

  • psi_det_sorted

Called by:

  • select_singles()

Calls:

  • bitstring_to_list()

  • get_m0()

  • get_m1()

  • get_m2()

  • get_mask_phase()

splash_pq:

File : cipsi/selection.irp.f

subroutine splash_pq(mask, sp, det, i_gen, N_sel, bannedOrb, banned, mat, interesting)

Computes the contributions A(r,s) by comparing the external determinant to all the internal determinants det(i). an applying two particles (r,s) to the mask.

Needs:

  • mo_num

  • n_int

  • n_states

  • psi_det_sorted

  • psi_selectors_coef_transp

Called by:

  • select_singles_and_doubles()

Calls:

  • bitstring_to_list_in_selection()

  • get_d0()

  • get_d1()

  • get_d2()

  • get_mask_phase()

spot_hasbeen:

File : cipsi/selection_singles.irp.f

subroutine spot_hasBeen(mask, sp, det, i_gen, N, banned, fullMatch)

Needs:

  • mo_num

  • n_int

Called by:

  • select_singles()

Calls:

  • bitstring_to_list()

spot_isinwf:

File : cipsi/selection.irp.f

subroutine spot_isinwf(mask, det, i_gen, N, banned, fullMatch, interesting)

Identify the determinants in det that are in the internal space. These are the determinants that can be produced by creating two particles on the mask.

Needs:

  • mo_num

  • n_int

Called by:

  • select_singles_and_doubles()

Calls:

  • bitstring_to_list_in_selection()

write_cipsi_json:

File : cipsi/write_cipsi_json.irp.f

subroutine write_cipsi_json(pt2_data, pt2_data_err)

Writes JSON data for CIPSI runs

Needs:

  • energy_iterations

  • json_int_fmt

  • json_unit

  • n_det

  • n_iter

  • n_states

  • nsomomax

  • only_expected_s2

  • psi_configuration

  • psi_energy

  • psi_energy_with_nucl_rep

  • s2_eig

Called by:

  • run_cipsi()

  • run_stochastic_cipsi()

Calls:

  • lock_io()

  • unlock_io()