davidson

Abstract module for Davidson’s diagonalization. It contains everything required for the Davidson algorithm, dressed or not. If a dressing is used, the dressing column should be defined and the davidson_dressed module should be used. If no dressing is required, the davidson module should be used, and it has a default zero dressing vector.

The important providers for that module are:

# psi_energy which is the expectation value over the wave function (psi_det, psi_coef) of the Hamiltonian, dressed or not. It uses the general subroutine u_0_H_u_0. # psi_energy_two_e which is the expectation value over the wave function (psi_det, psi_coef) of the standard two-electrons coulomb operator. It uses the general routine u_0_H_u_0_two_e.

EZFIO parameters

threshold_davidson

Thresholds of Davidson’s algorithm

Default: 1.e-10

n_states_diag

Number of states to consider during the Davdison diagonalization

Default: 4

davidson_sze_max

Number of micro-iterations before re-contracting

Default: 8

state_following

If true, the states are re-ordered to match the input states

Default: False

disk_based_davidson

If true, a memory-mapped file may be used to store the W and S2 vectors if not enough RAM is available

Default: True

distributed_davidson

If true, use the distributed algorithm

Default: True

only_expected_s2

If true, use filter out all vectors with bad \(\widehat{S^2}\) values

Default: True

Providers

ci_eigenvectors

File : davidson/diagonalize_ci.irp.f

double precision, allocatable   :: ci_electronic_energy (N_states_diag)
double precision, allocatable   :: ci_eigenvectors      (N_det,N_states_diag)
double precision, allocatable   :: ci_s2        (N_states_diag)

Eigenvectors/values of the CI matrix

Needs:

Needed by:

ci_electronic_energy

File : davidson/diagonalize_ci.irp.f

double precision, allocatable   :: ci_electronic_energy (N_states_diag)
double precision, allocatable   :: ci_eigenvectors      (N_det,N_states_diag)
double precision, allocatable   :: ci_s2        (N_states_diag)

Eigenvectors/values of the CI matrix

Needs:

Needed by:

ci_energy

File : davidson/diagonalize_ci.irp.f

double precision, allocatable   :: ci_energy    (N_states_diag)

n_states lowest eigenvalues of the CI matrix

Needs:

ci_s2

File : davidson/diagonalize_ci.irp.f

double precision, allocatable   :: ci_electronic_energy (N_states_diag)
double precision, allocatable   :: ci_eigenvectors      (N_det,N_states_diag)
double precision, allocatable   :: ci_s2        (N_states_diag)

Eigenvectors/values of the CI matrix

Needs:

Needed by:

davidson_criterion

File : davidson/parameters.irp.f

character(64)   :: davidson_criterion

Can be : [ energy | residual | both | wall_time | cpu_time | iterations ]

dressed_column_idx

File : davidson/diagonalization_hs2_dressed.irp.f

integer, allocatable    :: dressed_column_idx   (N_states)

Index of the dressed columns

Needs:

  • n_states
n_states_diag

File : davidson/input.irp.f

integer :: n_states_diag

Number of states to consider during the Davdison diagonalization

Needs:

  • n_states

Needed by:

nthreads_davidson

File : davidson/davidson_parallel.irp.f

integer :: nthreads_davidson

Number of threads for Davidson

Needs:

Needed by:

psi_energy

File : davidson/u0_h_u0.irp.f

double precision, allocatable   :: psi_energy   (N_states)
double precision, allocatable   :: psi_s2       (N_states)

psi_energy(i) = \(\langle \Psi_i | H | \Psi_i \rangle\)

psi_s2(i) = \(\langle \Psi_i | S^2 | \Psi_i \rangle\)

Needs:

Needed by:

psi_energy_two_e

File : davidson/u0_wee_u0.irp.f

double precision, allocatable   :: psi_energy_two_e     (N_states)

Energy of the current wave function

Needs:

psi_energy_with_nucl_rep

File : davidson/u0_h_u0.irp.f

double precision, allocatable   :: psi_energy_with_nucl_rep     (N_states)

Energy of the wave function with the nuclear repulsion energy.

Needs:

  • n_states
psi_s2

File : davidson/u0_h_u0.irp.f

double precision, allocatable   :: psi_energy   (N_states)
double precision, allocatable   :: psi_s2       (N_states)

psi_energy(i) = \(\langle \Psi_i | H | \Psi_i \rangle\)

psi_s2(i) = \(\langle \Psi_i | S^2 | \Psi_i \rangle\)

Needs:

Needed by:

Subroutines / functions

davidson_collector:()

File : davidson/davidson_parallel.irp.f

subroutine davidson_collector(zmq_to_qp_run_socket, zmq_socket_pull, v0, s0, sze, N_st)

Routine collecting the results of the workers in Davidson’s algorithm.

Needs:

Called by:

  • h_s2_u_0_nstates_zmq()

Calls:

  • davidson_pull_results()
davidson_converged:()

File : davidson/parameters.irp.f

subroutine davidson_converged(energy,residual,wall,iterations,cpu,N_st,converged)

True if the Davidson algorithm is converged

Needs:

  • threshold_davidson

Called by:

  • davidson_diag_hjj_sjj()

Calls:

  • cpu_time()
  • wall_time()
davidson_diag_hjj_sjj:()

File : davidson/diagonalization_hs2_dressed.irp.f

subroutine davidson_diag_hjj_sjj(dets_in,u_in,H_jj,s2_out,energies,dim_in,sze,N_st,N_st_diag_in,Nint,dressing_state,converged)

Davidson diagonalization with specific diagonal elements of the H matrix

H_jj : specific diagonal H matrix elements to diagonalize de Davidson

S2_out : Output : s^2

dets_in : bitmasks corresponding to determinants

u_in : guess coefficients on the various states. Overwritten
on exit

dim_in : leftmost dimension of u_in

sze : Number of determinants

N_st : Number of eigenstates

N_st_diag_in : Number of states in which H is diagonalized. Assumed > sze

Initial guess vectors are not necessarily orthonormal

Needs:

Called by:

  • davidson_diag_hs2()

Calls:

  • c_f_pointer()
  • check_mem()
  • cpu_time()
  • davidson_converged()
  • dgemm()
  • dswap()
  • h_s2_u_0_nstates_openmp()
  • h_s2_u_0_nstates_zmq()
  • lapack_diag()
  • mmap()
  • munmap()
  • normalize()
  • ortho_qr()
  • random_number()
  • resident_memory()
  • sgemm()
  • wall_time()
  • write_double()
  • write_int()
  • write_time()

Touches:

davidson_diag_hs2:()

File : davidson/diagonalization_hs2_dressed.irp.f

subroutine davidson_diag_hs2(dets_in,u_in,s2_out,dim_in,energies,sze,N_st,N_st_diag,Nint,dressing_state,converged)

Davidson diagonalization.

dets_in : bitmasks corresponding to determinants

u_in : guess coefficients on the various states. Overwritten
on exit

dim_in : leftmost dimension of u_in

sze : Number of determinants

N_st : Number of eigenstates

Initial guess vectors are not necessarily orthonormal

Needs:

Called by:

Calls:

  • davidson_diag_hjj_sjj()

Touches:

davidson_pull_results:()

File : davidson/davidson_parallel.irp.f

subroutine davidson_pull_results(zmq_socket_pull, v_t, s_t, imin, imax, task_id)

Pull the results of $H|U rangle$ on the master.

Needs:

Called by:

  • davidson_collector()
davidson_push_results:()

File : davidson/davidson_parallel.irp.f

subroutine davidson_push_results(zmq_socket_push, v_t, s_t, imin, imax, task_id)

Push the results of $H|U rangle$ from a worker to the master.

Needs:

Called by:

  • davidson_slave_work()
davidson_run_slave:()

File : davidson/davidson_parallel.irp.f

subroutine davidson_run_slave(thread,iproc)

Slave routine for Davidson’s diagonalization.

Needs:

Called by:

  • davidson_slave_inproc()
  • davidson_slave_tcp()

Calls:

  • davidson_slave_work()
  • end_zmq_push_socket()
  • end_zmq_to_qp_run_socket()
  • sleep()
davidson_slave_inproc:()

File : davidson/davidson_parallel.irp.f

subroutine davidson_slave_inproc(i)

Called by:

  • h_s2_u_0_nstates_zmq()

Calls:

  • davidson_run_slave()
davidson_slave_tcp:()

File : davidson/davidson_parallel.irp.f

subroutine davidson_slave_tcp(i)

Called by:

  • run_slave_main()

Calls:

  • davidson_run_slave()
davidson_slave_work:()

File : davidson/davidson_parallel.irp.f

subroutine davidson_slave_work(zmq_to_qp_run_socket, zmq_socket_push, N_st, sze, worker_id)

Needs:

Called by:

  • davidson_run_slave()

Calls:

  • davidson_push_results()
  • h_s2_u_0_nstates_openmp_work()
  • sleep()
diagonalize_ci:()

File : davidson/diagonalize_ci.irp.f

subroutine diagonalize_CI

Replace the coefficients of the CI states by the coefficients of the eigenstates of the CI matrix.

Needs:

Called by:

  • remove_small_contributions()
  • run_cipsi()
  • run_stochastic_cipsi()

Touches:

h_s2_u_0_nstates_openmp:()

File : davidson/u0_h_u0.irp.f

subroutine H_S2_u_0_nstates_openmp(v_0,s_0,u_0,N_st,sze)

Computes $v_0 = H|u_0rangle$ and $s_0 = S^2 |u_0rangle$.

Assumes that the determinants are in psi_det

istart, iend, ishift, istep are used in ZMQ parallelization.

Needs:

Called by:

  • davidson_diag_hjj_sjj()
  • u_0_h_u_0()

Calls:

  • dset_order()
  • dtranspose()
  • h_s2_u_0_nstates_openmp_work()
h_s2_u_0_nstates_openmp_work:()

File : davidson/u0_h_u0.irp.f

subroutine H_S2_u_0_nstates_openmp_work(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep)

Computes $v_t = H|u_trangle$ and $s_t = S^2 |u_trangle$

Default should be 1,N_det,0,1

Needs:

Called by:

  • davidson_slave_work()
  • h_s2_u_0_nstates_openmp()

Calls:

  • h_s2_u_0_nstates_openmp_work_1()
  • h_s2_u_0_nstates_openmp_work_2()
  • h_s2_u_0_nstates_openmp_work_3()
  • h_s2_u_0_nstates_openmp_work_4()
  • h_s2_u_0_nstates_openmp_work_n_int()
h_s2_u_0_nstates_openmp_work_1:()

File : davidson/u0_h_u0.irp.f_template_631

subroutine H_S2_u_0_nstates_openmp_work_1(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep)

Computes $v_t = H|u_t

angle$ and $s_t = S^2 |u_t angle$

Default should be 1,N_det,0,1

Needs:

Called by:

  • h_s2_u_0_nstates_openmp_work()

Calls:

  • get_all_spin_singles_1()
  • get_all_spin_singles_and_doubles_1()
  • get_s2()
  • i_h_j_double_alpha_beta()
  • i_h_j_double_spin()
  • i_h_j_mono_spin()
h_s2_u_0_nstates_openmp_work_2:()

File : davidson/u0_h_u0.irp.f_template_631

subroutine H_S2_u_0_nstates_openmp_work_2(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep)

Computes $v_t = H|u_t

angle$ and $s_t = S^2 |u_t angle$

Default should be 1,N_det,0,1

Needs:

Called by:

  • h_s2_u_0_nstates_openmp_work()

Calls:

  • get_all_spin_singles_2()
  • get_all_spin_singles_and_doubles_2()
  • get_s2()
  • i_h_j_double_alpha_beta()
  • i_h_j_double_spin()
  • i_h_j_mono_spin()
h_s2_u_0_nstates_openmp_work_3:()

File : davidson/u0_h_u0.irp.f_template_631

subroutine H_S2_u_0_nstates_openmp_work_3(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep)

Computes $v_t = H|u_t

angle$ and $s_t = S^2 |u_t angle$

Default should be 1,N_det,0,1

Needs:

Called by:

  • h_s2_u_0_nstates_openmp_work()

Calls:

  • get_all_spin_singles_3()
  • get_all_spin_singles_and_doubles_3()
  • get_s2()
  • i_h_j_double_alpha_beta()
  • i_h_j_double_spin()
  • i_h_j_mono_spin()
h_s2_u_0_nstates_openmp_work_4:()

File : davidson/u0_h_u0.irp.f_template_631

subroutine H_S2_u_0_nstates_openmp_work_4(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep)

Computes $v_t = H|u_t

angle$ and $s_t = S^2 |u_t angle$

Default should be 1,N_det,0,1

Needs:

Called by:

  • h_s2_u_0_nstates_openmp_work()

Calls:

  • get_all_spin_singles_4()
  • get_all_spin_singles_and_doubles_4()
  • get_s2()
  • i_h_j_double_alpha_beta()
  • i_h_j_double_spin()
  • i_h_j_mono_spin()
h_s2_u_0_nstates_openmp_work_n_int:()

File : davidson/u0_h_u0.irp.f_template_631

subroutine H_S2_u_0_nstates_openmp_work_N_int(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep)

Computes $v_t = H|u_t

angle$ and $s_t = S^2 |u_t angle$

Default should be 1,N_det,0,1

Needs:

Called by:

  • h_s2_u_0_nstates_openmp_work()

Calls:

  • get_all_spin_singles_and_doubles_n_int()
  • get_all_spin_singles_n_int()
  • get_s2()
  • i_h_j_double_alpha_beta()
  • i_h_j_double_spin()
  • i_h_j_mono_spin()
h_s2_u_0_nstates_zmq:()

File : davidson/davidson_parallel.irp.f

subroutine H_S2_u_0_nstates_zmq(v_0,s_0,u_0,N_st,sze)

Computes $v_0 = H|u_0rangle$ and $s_0 = S^2 |u_0rangle$

n : number of determinants

H_jj : array of $langle j|H|j rangle$

S2_jj : array of $langle j|S^2|j rangle$

Needs:

Called by:

  • davidson_diag_hjj_sjj()
  • u_0_h_u_0()

Calls:

  • davidson_collector()
  • davidson_slave_inproc()
  • dset_order()
  • dtranspose()
  • end_parallel_job()
  • new_parallel_job()
  • omp_set_nested()

Touches:

h_s2_u_0_two_e_nstates_openmp:()

File : davidson/u0_wee_u0.irp.f

subroutine H_S2_u_0_two_e_nstates_openmp(v_0,s_0,u_0,N_st,sze)

Computes $v_0 = H|u_0rangle$ and $s_0 = S^2 |u_0rangle$

Assumes that the determinants are in psi_det

istart, iend, ishift, istep are used in ZMQ parallelization.

Needs:

Called by:

  • u_0_h_u_0_two_e()

Calls:

  • dset_order()
  • dtranspose()
  • h_s2_u_0_two_e_nstates_openmp_work()
h_s2_u_0_two_e_nstates_openmp_work:()

File : davidson/u0_wee_u0.irp.f

subroutine H_S2_u_0_two_e_nstates_openmp_work(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep)

Computes $v_t = H|u_trangle$ and $s_t = S^2 |u_trangle$

Default should be 1,N_det,0,1

Needs:

Called by:

  • h_s2_u_0_two_e_nstates_openmp()

Calls:

  • h_s2_u_0_two_e_nstates_openmp_work_1()
  • h_s2_u_0_two_e_nstates_openmp_work_2()
  • h_s2_u_0_two_e_nstates_openmp_work_3()
  • h_s2_u_0_two_e_nstates_openmp_work_4()
  • h_s2_u_0_two_e_nstates_openmp_work_n_int()
h_s2_u_0_two_e_nstates_openmp_work_1:()

File : davidson/u0_wee_u0.irp.f_template_457

subroutine H_S2_u_0_two_e_nstates_openmp_work_1(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep)

Computes $v_t = H|u_t

angle$ and $s_t = S^2 |u_t angle$

Default should be 1,N_det,0,1

Needs:

Called by:

  • h_s2_u_0_two_e_nstates_openmp_work()

Calls:

  • get_all_spin_singles_1()
  • get_all_spin_singles_and_doubles_1()
  • get_s2()
  • i_h_j_double_alpha_beta()
  • i_h_j_double_spin()
  • i_wee_j_mono()
h_s2_u_0_two_e_nstates_openmp_work_2:()

File : davidson/u0_wee_u0.irp.f_template_457

subroutine H_S2_u_0_two_e_nstates_openmp_work_2(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep)

Computes $v_t = H|u_t

angle$ and $s_t = S^2 |u_t angle$

Default should be 1,N_det,0,1

Needs:

Called by:

  • h_s2_u_0_two_e_nstates_openmp_work()

Calls:

  • get_all_spin_singles_2()
  • get_all_spin_singles_and_doubles_2()
  • get_s2()
  • i_h_j_double_alpha_beta()
  • i_h_j_double_spin()
  • i_wee_j_mono()
h_s2_u_0_two_e_nstates_openmp_work_3:()

File : davidson/u0_wee_u0.irp.f_template_457

subroutine H_S2_u_0_two_e_nstates_openmp_work_3(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep)

Computes $v_t = H|u_t

angle$ and $s_t = S^2 |u_t angle$

Default should be 1,N_det,0,1

Needs:

Called by:

  • h_s2_u_0_two_e_nstates_openmp_work()

Calls:

  • get_all_spin_singles_3()
  • get_all_spin_singles_and_doubles_3()
  • get_s2()
  • i_h_j_double_alpha_beta()
  • i_h_j_double_spin()
  • i_wee_j_mono()
h_s2_u_0_two_e_nstates_openmp_work_4:()

File : davidson/u0_wee_u0.irp.f_template_457

subroutine H_S2_u_0_two_e_nstates_openmp_work_4(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep)

Computes $v_t = H|u_t

angle$ and $s_t = S^2 |u_t angle$

Default should be 1,N_det,0,1

Needs:

Called by:

  • h_s2_u_0_two_e_nstates_openmp_work()

Calls:

  • get_all_spin_singles_4()
  • get_all_spin_singles_and_doubles_4()
  • get_s2()
  • i_h_j_double_alpha_beta()
  • i_h_j_double_spin()
  • i_wee_j_mono()
h_s2_u_0_two_e_nstates_openmp_work_n_int:()

File : davidson/u0_wee_u0.irp.f_template_457

subroutine H_S2_u_0_two_e_nstates_openmp_work_N_int(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep)

Computes $v_t = H|u_t

angle$ and $s_t = S^2 |u_t angle$

Default should be 1,N_det,0,1

Needs:

Called by:

  • h_s2_u_0_two_e_nstates_openmp_work()

Calls:

  • get_all_spin_singles_and_doubles_n_int()
  • get_all_spin_singles_n_int()
  • get_s2()
  • i_h_j_double_alpha_beta()
  • i_h_j_double_spin()
  • i_wee_j_mono()
u_0_h_u_0:()

File : davidson/u0_h_u0.irp.f

subroutine u_0_H_u_0(e_0,s_0,u_0,n,keys_tmp,Nint,N_st,sze)

Computes $E_0 = frac{langle u_0|H|u_0 rangle}{langle u_0|u_0 rangle}$

and $S_0 = frac{langle u_0|S^2|u_0 rangle}{langle u_0|u_0 rangle}$

n : number of determinants

Needs:

  • n_states
  • distributed_davidson

Called by:

Calls:

  • h_s2_u_0_nstates_openmp()
  • h_s2_u_0_nstates_zmq()

Touches:

u_0_h_u_0_two_e:()

File : davidson/u0_wee_u0.irp.f

subroutine u_0_H_u_0_two_e(e_0,u_0,n,keys_tmp,Nint,N_st,sze)

Computes $E_0 = frac{ langle u_0|H|u_0rangle}{langle u_0|u_0 rangle}$.

n : number of determinants

Called by:

Calls:

  • h_s2_u_0_two_e_nstates_openmp()
zmq_get_n_states_diag:()

File : davidson/davidson_parallel.irp.f

integer function zmq_get_N_states_diag(zmq_to_qp_run_socket, worker_id)

Get N_states_diag from the qp_run scheduler

Needs:

Touches:

zmq_put_n_states_diag:()

File : davidson/davidson_parallel.irp.f

integer function zmq_put_N_states_diag(zmq_to_qp_run_socket,worker_id)

Put N_states_diag on the qp_run scheduler

Needs: