From dc75f495001a13dd38209a220d7230fb5ad3e450 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 3 Feb 2025 14:05:28 +0100 Subject: [PATCH] Added selected MRCI module --- src/cipsi_utils/pt2_stoch_routines.irp.f | 1 + src/mo_basis/utils.irp.f | 2 +- src/mrci/EZFIO.cfg | 24 +++++++++ src/mrci/NEED | 4 ++ src/mrci/README.rst | 17 +++++++ src/mrci/class.irp.f | 8 +++ src/mrci/mrci.irp.f | 64 ++++++++++++++++++++++++ src/mrci/save_energy.irp.f | 10 ++++ 8 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 src/mrci/EZFIO.cfg create mode 100644 src/mrci/NEED create mode 100644 src/mrci/README.rst create mode 100644 src/mrci/class.irp.f create mode 100644 src/mrci/mrci.irp.f create mode 100644 src/mrci/save_energy.irp.f diff --git a/src/cipsi_utils/pt2_stoch_routines.irp.f b/src/cipsi_utils/pt2_stoch_routines.irp.f index 162ab02c..68a3c9fc 100644 --- a/src/cipsi_utils/pt2_stoch_routines.irp.f +++ b/src/cipsi_utils/pt2_stoch_routines.irp.f @@ -212,6 +212,7 @@ subroutine ZMQ_pt2(E, pt2_data, pt2_data_err, relative_error, N_in) ipos += 1 endif enddo + call write_int(6,pt2_stoch_istate,'State') call write_int(6,sum(pt2_F),'Number of tasks') call write_int(6,ipos,'Number of fragmented tasks') diff --git a/src/mo_basis/utils.irp.f b/src/mo_basis/utils.irp.f index 987c394a..3f83b518 100644 --- a/src/mo_basis/utils.irp.f +++ b/src/mo_basis/utils.irp.f @@ -228,7 +228,7 @@ subroutine mo_as_svd_vectors_of_mo_matrix_eig(matrix,lda,m,n,eig,label) call dgemm('N','N',ao_num,m,m,1.d0,mo_coef_new,size(mo_coef_new,1),U,size(U,1),0.d0,mo_coef,size(mo_coef,1)) do i=1,m - if (eig(i) > 1.d-20) then + if (D(i) > 1.d-20) then eig(i) = D(i) else eig(i) = 0.d0 diff --git a/src/mrci/EZFIO.cfg b/src/mrci/EZFIO.cfg new file mode 100644 index 00000000..c8efd4b9 --- /dev/null +++ b/src/mrci/EZFIO.cfg @@ -0,0 +1,24 @@ +[energy] +type: double precision +doc: Calculated Selected CASSD energy +interface: ezfio +size: (determinants.n_states) + +[energy_pt2] +type: double precision +doc: Calculated CASSD energy + PT2 +interface: ezfio +size: (determinants.n_states) + + +[do_ddci] +type: logical +doc: If true, remove purely inactive double excitations +interface: ezfio,provider,ocaml +default: False + +[do_only_1h1p] +type: logical +doc: If true, do only one hole/one particle excitations +interface: ezfio,provider,ocaml +default: False diff --git a/src/mrci/NEED b/src/mrci/NEED new file mode 100644 index 00000000..ad99293f --- /dev/null +++ b/src/mrci/NEED @@ -0,0 +1,4 @@ +cipsi +generators_cas +selectors_full +davidson_undressed diff --git a/src/mrci/README.rst b/src/mrci/README.rst new file mode 100644 index 00000000..ac3c0139 --- /dev/null +++ b/src/mrci/README.rst @@ -0,0 +1,17 @@ +==== +mrci +==== + + +|CIPSI| algorithm in the multi-reference CI space (CAS + Singles and Doubles). + + +This module is the same as the :ref:`fci` module, except for the choice of the +generator and selector determinants. + +The inactive, active and virtual |MOs| will need to be set with the +:ref:`qp_set_mo_class` program. + +.. seealso:: + + The documentation of the :ref:`fci` module. diff --git a/src/mrci/class.irp.f b/src/mrci/class.irp.f new file mode 100644 index 00000000..271eb930 --- /dev/null +++ b/src/mrci/class.irp.f @@ -0,0 +1,8 @@ +BEGIN_PROVIDER [ logical, do_only_cas ] + implicit none + BEGIN_DOC + ! In the CAS+SD case, always false + END_DOC + do_only_cas = .False. +END_PROVIDER + diff --git a/src/mrci/mrci.irp.f b/src/mrci/mrci.irp.f new file mode 100644 index 00000000..ef4a2454 --- /dev/null +++ b/src/mrci/mrci.irp.f @@ -0,0 +1,64 @@ +program mrci + implicit none + BEGIN_DOC +! Selected CAS+Singles and Doubles with stochastic selection +! and PT2. +! +! This program performs a |CIPSI|-like selected |CI| using a +! stochastic scheme for both the selection of the important Slater +! determinants and the computation of the |PT2| correction. This +! |CIPSI|-like algorithm will be performed for the lowest states of +! the variational space (see :option:`determinants n_states`). The +! program will stop when reaching at least one the two following +! conditions: +! +! * number of Slater determinants > :option:`determinants n_det_max` +! * |PT2| < :option:`perturbation pt2_max` +! +! The following other options can be of interest: +! +! :option:`determinants read_wf` +! When set to |false|, the program starts with a ROHF-like Slater +! determinant as a guess wave function. When set to |true|, the +! program starts with the wave function(s) stored in the |EZFIO| +! directory as guess wave function(s). +! +! :option:`determinants s2_eig` +! When set to |true|, the selection will systematically add all the +! necessary Slater determinants in order to have a pure spin wave +! function with an |S^2| value corresponding to +! :option:`determinants expected_s2`. +! +! For excited states calculations, it is recommended to start with +! :ref:`.cis.` or :ref:`.cisd.` guess wave functions, eventually in +! a restricted set of |MOs|, and to set :option:`determinants s2_eig` +! to |true|. +! + END_DOC + + PROVIDE all_mo_integrals + if (.not.is_zmq_slave) then + PROVIDE psi_det psi_coef + + write(json_unit,json_array_open_fmt) 'fci' + + double precision, allocatable :: Ev(:),PT2(:) + allocate(Ev(N_states), PT2(N_states)) + if (do_pt2) then + call run_stochastic_cipsi(Ev,PT2) + else + call run_cipsi + endif + + write(json_unit,json_dict_uopen_fmt) + write(json_unit,json_dict_close_fmtx) + write(json_unit,json_array_close_fmtx) + call json_close + + else + PROVIDE pt2_min_parallel_tasks + + call run_slave_cipsi + + endif +end diff --git a/src/mrci/save_energy.irp.f b/src/mrci/save_energy.irp.f new file mode 100644 index 00000000..28840b6c --- /dev/null +++ b/src/mrci/save_energy.irp.f @@ -0,0 +1,10 @@ +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_mrci_energy(E(1:N_states)) + call ezfio_set_mrci_energy_pt2(E(1:N_states)+pt2(1:N_states)) +end +