9
1
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-11-12 16:33:37 +01:00

Compare commits

...

8 Commits

7 changed files with 143 additions and 45 deletions

View File

@ -45,6 +45,8 @@ Requirements
- |ZeroMQ| : networking library - |ZeroMQ| : networking library
- `GMP <https://gmplib.org/>`_ : Gnu Multiple Precision Arithmetic Library - `GMP <https://gmplib.org/>`_ : Gnu Multiple Precision Arithmetic Library
- |OCaml| compiler with |OPAM| package manager - |OCaml| compiler with |OPAM| package manager
- `Bubblewrap <https://github.com/projectatomic/bubblewrap>`_ : Sandboxing tool required by Opam
- `libcap https://git.kernel.org/pub/scm/linux/kernel/git/morgan/libcap.git`_ : POSIX capabilities required by Bubblewrap
- |Ninja| : a parallel build system - |Ninja| : a parallel build system
@ -86,6 +88,8 @@ The following packages are supported by the :command:`configure` installer:
* zeromq * zeromq
* f77zmq * f77zmq
* gmp * gmp
* libcap
* bwrap
* ocaml ( :math:`\approx` 10 minutes) * ocaml ( :math:`\approx` 10 minutes)
* ezfio * ezfio
* docopt * docopt
@ -243,6 +247,55 @@ With Debian or Ubuntu, you can use
sudo apt install libgmp-dev sudo apt install libgmp-dev
libcap
------
Libcap is a library for getting and setting POSIX.1e draft 15 capabilities.
* Download the latest version of libcap here:
`<https://git.kernel.org/pub/scm/linux/kernel/git/morgan/libcap.git/snapshot/libcap-2.25.tar.gz>`_
and move it in the :file:`${QP_ROOT}/external` directory
* Extract the archive, go into the :file:`libcap-*/libcap` directory and run
the following command
.. code:: bash
prefix=$QP_ROOT make install
With Debian or Ubuntu, you can use
.. code:: bash
sudo apt install libcap-dev
Bubblewrap
----------
Bubblewrap is an unprivileged sandboxing tool.
* Download Bubblewrap here:
`<https://github.com/projectatomic/bubblewrap/releases/download/v0.3.3/bubblewrap-0.3.3.tar.xz>`_
and move it in the :file:`${QP_ROOT}/external` directory
* Extract the archive, go into the :file:`bubblewrap-*` directory and run
the following commands
.. code:: bash
./configure --prefix=$QP_ROOT && make -j 8
make install-exec-am
With Debian or Ubuntu, you can use
.. code:: bash
sudo apt install bubblewrap
OCaml OCaml
----- -----

44
configure vendored
View File

@ -175,7 +175,7 @@ if [[ "${PACKAGES}.x" != ".x" ]] ; then
fi fi
if [[ ${PACKAGES} = all ]] ; then if [[ ${PACKAGES} = all ]] ; then
PACKAGES="zlib ninja irpf90 zeromq f77zmq gmp ocaml ezfio docopt resultsFile bats" PACKAGES="zlib ninja irpf90 zeromq f77zmq gmp libcap bwrap ocaml ezfio docopt resultsFile bats"
fi fi
@ -206,6 +206,32 @@ EOF
make install make install
EOF EOF
elif [[ ${PACKAGE} = libcap ]] ; then
download \
"https://git.kernel.org/pub/scm/linux/kernel/git/morgan/libcap.git/snapshot/libcap-2.25.tar.gz" \
"${QP_ROOT}"/external/libcap.tar.gz
execute << EOF
cd "\${QP_ROOT}"/external
tar --gunzip --extract --file libcap.tar.gz
rm libcap.tar.gz
cd libcap-*/libcap
prefix=$QP_ROOT make install
EOF
elif [[ ${PACKAGE} = bwrap ]] ; then
download \
"https://github.com/projectatomic/bubblewrap/releases/download/v0.3.3/bubblewrap-0.3.3.tar.xz" \
"${QP_ROOT}"/external/bwrap.tar.xz
execute << EOF
cd "\${QP_ROOT}"/external
tar --xz --extract --file bwrap.tar.xz
rm bwrap.tar.xz
cd bubblewrap*
./configure --prefix=$QP_ROOT && make -j 8
make install-exec-am
EOF
elif [[ ${PACKAGE} = irpf90 ]] ; then elif [[ ${PACKAGE} = irpf90 ]] ; then
@ -276,7 +302,7 @@ EOF
rm ${QP_ROOT}/external/opam_installer.sh rm ${QP_ROOT}/external/opam_installer.sh
source ${OPAMROOT}/opam-init/init.sh > /dev/null 2> /dev/null || true source ${OPAMROOT}/opam-init/init.sh > /dev/null 2> /dev/null || true
${QP_ROOT}/bin/opam init --disable-sandboxing --verbose --yes ${QP_ROOT}/bin/opam init --verbose --yes
eval $(${QP_ROOT}/bin/opam env) eval $(${QP_ROOT}/bin/opam env)
opam install -y ${OCAML_PACKAGES} || exit 1 opam install -y ${OCAML_PACKAGES} || exit 1
@ -290,7 +316,7 @@ EOF
| sh \${QP_ROOT}/external/opam_installer.sh | sh \${QP_ROOT}/external/opam_installer.sh
rm \${QP_ROOT}/external/opam_installer.sh rm \${QP_ROOT}/external/opam_installer.sh
source \${OPAMROOT}/opam-init/init.sh > /dev/null 2> /dev/null || true source \${OPAMROOT}/opam-init/init.sh > /dev/null 2> /dev/null || true
\${QP_ROOT}/bin/opam init --disable-sandboxing --verbose --yes \${QP_ROOT}/bin/opam init --verbose --yes
eval \$(\${QP_ROOT}/bin/opam env) eval \$(\${QP_ROOT}/bin/opam env)
opam install -y \${OCAML_PACKAGES} || exit 1 opam install -y \${OCAML_PACKAGES} || exit 1
EOF EOF
@ -399,6 +425,18 @@ if [[ ${ZLIB} = $(not_found) ]] ; then
fail fail
fi fi
BWRAP=$(find_exe bwrap)
if [[ ${BWRAP} = $(not_found) ]] ; then
error "Bubblewrap (bwrap) is not installed."
fail
fi
LIBCAP=$(find_lib -lcap)
if [[ ${LIBCAP} = $(not_found) ]] ; then
error "Libcap (libcap) is not installed."
fail
fi
OPAM=$(find_exe opam) OPAM=$(find_exe opam)
if [[ ${OPAM} = $(not_found) ]] ; then if [[ ${OPAM} = $(not_found) ]] ; then
error "OPAM (ocaml) package manager is not installed." error "OPAM (ocaml) package manager is not installed."

View File

@ -5,7 +5,7 @@ subroutine run_cipsi
! stochastic PT2. ! stochastic PT2.
END_DOC END_DOC
integer :: i,j,k integer :: i,j,k
double precision, allocatable :: pt2(:), variance(:), norm(:), rpt2(:) double precision, allocatable :: pt2(:), variance(:), norm(:), rpt2(:), zeros(:)
integer :: n_det_before, to_select integer :: n_det_before, to_select
double precision :: rss double precision :: rss
@ -13,7 +13,7 @@ subroutine run_cipsi
rss = memory_of_double(N_states)*4.d0 rss = memory_of_double(N_states)*4.d0
call check_mem(rss,irp_here) call check_mem(rss,irp_here)
allocate (pt2(N_states), rpt2(N_states), norm(N_states), variance(N_states)) allocate (pt2(N_states), zeros(N_states), rpt2(N_states), norm(N_states), variance(N_states))
double precision :: hf_energy_ref double precision :: hf_energy_ref
logical :: has logical :: has
@ -23,10 +23,11 @@ subroutine run_cipsi
relative_error=PT2_relative_error relative_error=PT2_relative_error
zeros = 0.d0
pt2 = -huge(1.e0) pt2 = -huge(1.e0)
rpt2 = -huge(1.e0) rpt2 = -huge(1.e0)
norm = 0.d0 norm = 0.d0
variance = 0.d0 variance = huge(1.e0)
if (s2_eig) then if (s2_eig) then
call make_s2_eigenfunction call make_s2_eigenfunction
@ -66,6 +67,7 @@ subroutine run_cipsi
do while ( & do while ( &
(N_det < N_det_max) .and. & (N_det < N_det_max) .and. &
(maxval(abs(rpt2(1:N_states))) > pt2_max) .and. & (maxval(abs(rpt2(1:N_states))) > pt2_max) .and. &
(maxval(variance(1:N_states)) > variance_max) .and. &
(correlation_energy_ratio <= correlation_energy_ratio_max) & (correlation_energy_ratio <= correlation_energy_ratio_max) &
) )
write(*,'(A)') '--------------------------------------------------------------------------------' write(*,'(A)') '--------------------------------------------------------------------------------'
@ -83,17 +85,17 @@ subroutine run_cipsi
SOFT_TOUCH threshold_generators SOFT_TOUCH threshold_generators
endif endif
do k=1,N_states
rpt2(k) = pt2(k)/(1.d0 + norm(k))
enddo
correlation_energy_ratio = (psi_energy_with_nucl_rep(1) - hf_energy_ref) / & correlation_energy_ratio = (psi_energy_with_nucl_rep(1) - hf_energy_ref) / &
(psi_energy_with_nucl_rep(1) + pt2(1) - hf_energy_ref) (psi_energy_with_nucl_rep(1) + rpt2(1) - hf_energy_ref)
correlation_energy_ratio = min(1.d0,correlation_energy_ratio) correlation_energy_ratio = min(1.d0,correlation_energy_ratio)
call write_double(6,correlation_energy_ratio, 'Correlation ratio') 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,N_states,psi_s2) call print_summary(psi_energy_with_nucl_rep(1:N_states),pt2,error,variance,norm,N_det,N_occ_pattern,N_states,psi_s2)
do k=1,N_states
rpt2(k) = pt2(k)/(1.d0 + norm(k))
enddo
call save_energy(psi_energy_with_nucl_rep, rpt2) call save_energy(psi_energy_with_nucl_rep, rpt2)
call save_iterations(psi_energy_with_nucl_rep(1:N_states),rpt2,N_det) call save_iterations(psi_energy_with_nucl_rep(1:N_states),rpt2,N_det)
@ -103,7 +105,7 @@ subroutine run_cipsi
if (qp_stop()) exit if (qp_stop()) exit
n_det_before = N_det n_det_before = N_det
to_select = N_det*int(sqrt(dble(N_states)))*selection_factor to_select = int(sqrt(dble(N_states))*dble(N_det)*selection_factor)
to_select = max(N_states_diag, to_select) to_select = max(N_states_diag, to_select)
call ZMQ_selection(to_select, pt2, variance, norm) call ZMQ_selection(to_select, pt2, variance, norm)
@ -113,32 +115,30 @@ subroutine run_cipsi
call diagonalize_CI call diagonalize_CI
call save_wavefunction call save_wavefunction
rpt2(:) = 0.d0 call save_energy(psi_energy_with_nucl_rep, zeros)
call save_energy(psi_energy_with_nucl_rep, rpt2)
if (qp_stop()) exit if (qp_stop()) exit
print *, (N_det < N_det_max)
print *, (maxval(abs(rpt2(1:N_states))) > pt2_max)
print *, (maxval(variance(1:N_states)) > variance_max)
print *, (correlation_energy_ratio <= correlation_energy_ratio_max)
enddo enddo
if (.not.qp_stop()) then if (.not.qp_stop()) then
if (N_det < N_det_max) then if (N_det < N_det_max) then
call diagonalize_CI call diagonalize_CI
call save_wavefunction call save_wavefunction
rpt2(:) = 0.d0 call save_energy(psi_energy_with_nucl_rep, zeros)
call save_energy(psi_energy_with_nucl_rep, rpt2)
endif endif
if (do_pt2) then if (do_pt2) then
pt2 = 0.d0 pt2(:) = 0.d0
variance = 0.d0 variance(:) = 0.d0
norm = 0.d0 norm(:) = 0.d0
threshold_generators = 1d0 threshold_generators = 1d0
SOFT_TOUCH threshold_generators SOFT_TOUCH threshold_generators
call ZMQ_pt2(psi_energy_with_nucl_rep, pt2,relative_error,error,variance, & call ZMQ_pt2(psi_energy_with_nucl_rep, pt2,relative_error,error,variance, &
norm,0) ! Stochastic PT2 norm,0) ! Stochastic PT2
SOFT_TOUCH threshold_generators SOFT_TOUCH threshold_generators
do k=1,N_states
rpt2(k) = pt2(k)/(1.d0 + norm(k))
enddo
call save_energy(psi_energy_with_nucl_rep, pt2)
endif endif
print *, 'N_det = ', N_det print *, 'N_det = ', N_det
print *, 'N_sop = ', N_occ_pattern print *, 'N_sop = ', N_occ_pattern
@ -149,10 +149,9 @@ subroutine run_cipsi
do k=1,N_states do k=1,N_states
rpt2(k) = pt2(k)/(1.d0 + norm(k)) rpt2(k) = pt2(k)/(1.d0 + norm(k))
enddo enddo
call save_energy(psi_energy_with_nucl_rep, rpt2)
call print_summary(psi_energy_with_nucl_rep(1:N_states),pt2,error,variance,norm,N_det,N_occ_pattern,N_states,psi_s2) call print_summary(psi_energy_with_nucl_rep(1:N_states),pt2,error,variance,norm,N_det,N_occ_pattern,N_states,psi_s2)
call save_energy(psi_energy_with_nucl_rep, pt2) call save_energy(psi_energy_with_nucl_rep, rpt2)
call save_iterations(psi_energy_with_nucl_rep(1:N_states),rpt2,N_det) call save_iterations(psi_energy_with_nucl_rep(1:N_states),rpt2,N_det)
call print_extrapolated_energy() call print_extrapolated_energy()
endif endif

View File

@ -182,6 +182,9 @@ subroutine ZMQ_pt2(E, pt2,relative_error, error, variance, norm, N_in)
if (zmq_put_dvector(zmq_to_qp_run_socket,1,'state_average_weight',state_average_weight,N_states) == -1) then if (zmq_put_dvector(zmq_to_qp_run_socket,1,'state_average_weight',state_average_weight,N_states) == -1) then
stop 'Unable to put state_average_weight on ZMQ server' stop 'Unable to put state_average_weight on ZMQ server'
endif endif
if (zmq_put_dvector(zmq_to_qp_run_socket,1,'selection_weight',selection_weight,N_states) == -1) then
stop 'Unable to put selection_weight on ZMQ server'
endif
if (zmq_put_ivector(zmq_to_qp_run_socket,1,'pt2_stoch_istate',pt2_stoch_istate,1) == -1) then if (zmq_put_ivector(zmq_to_qp_run_socket,1,'pt2_stoch_istate',pt2_stoch_istate,1) == -1) then
stop 'Unable to put pt2_stoch_istate on ZMQ server' stop 'Unable to put pt2_stoch_istate on ZMQ server'
endif endif

View File

@ -220,8 +220,12 @@ subroutine run_slave_main
call mpi_print('zmq_get_dvector state_average_weight') call mpi_print('zmq_get_dvector state_average_weight')
IRP_ENDIF IRP_ENDIF
if (zmq_get_dvector(zmq_to_qp_run_socket,1,'state_average_weight',state_average_weight,N_states) == -1) cycle if (zmq_get_dvector(zmq_to_qp_run_socket,1,'state_average_weight',state_average_weight,N_states) == -1) cycle
IRP_IF MPI_DEBUG
call mpi_print('zmq_get_dvector selection_weight')
IRP_ENDIF
if (zmq_get_dvector(zmq_to_qp_run_socket,1,'selection_weight',selection_weight,N_states) == -1) cycle
pt2_e0_denominator(1:N_states) = energy(1:N_states) pt2_e0_denominator(1:N_states) = energy(1:N_states)
SOFT_TOUCH pt2_e0_denominator state_average_weight pt2_stoch_istate threshold_generators SOFT_TOUCH pt2_e0_denominator state_average_weight pt2_stoch_istate threshold_generators selection_weight
call wall_time(t1) call wall_time(t1)
call write_double(6,(t1-t0),'Broadcast time') call write_double(6,(t1-t0),'Broadcast time')

View File

@ -4,7 +4,7 @@ subroutine run_stochastic_cipsi
! Selected Full Configuration Interaction with Stochastic selection and PT2. ! Selected Full Configuration Interaction with Stochastic selection and PT2.
END_DOC END_DOC
integer :: i,j,k integer :: i,j,k
double precision, allocatable :: pt2(:), variance(:), norm(:), rpt2(:) double precision, allocatable :: pt2(:), variance(:), norm(:), rpt2(:), zeros(:)
integer :: to_select integer :: to_select
logical, external :: qp_stop logical, external :: qp_stop
@ -18,7 +18,7 @@ subroutine run_stochastic_cipsi
rss = memory_of_double(N_states)*4.d0 rss = memory_of_double(N_states)*4.d0
call check_mem(rss,irp_here) call check_mem(rss,irp_here)
allocate (pt2(N_states), rpt2(N_states), norm(N_states), variance(N_states)) allocate (pt2(N_states), zeros(N_states), rpt2(N_states), norm(N_states), variance(N_states))
double precision :: hf_energy_ref double precision :: hf_energy_ref
logical :: has logical :: has
@ -26,6 +26,7 @@ subroutine run_stochastic_cipsi
relative_error=PT2_relative_error relative_error=PT2_relative_error
zeros = 0.d0
pt2 = -huge(1.e0) pt2 = -huge(1.e0)
rpt2 = -huge(1.e0) rpt2 = -huge(1.e0)
norm = 0.d0 norm = 0.d0
@ -63,14 +64,14 @@ subroutine run_stochastic_cipsi
do while ( & do while ( &
(N_det < N_det_max) .and. & (N_det < N_det_max) .and. &
(maxval(abs(pt2(1:N_states))) > pt2_max) .and. & (maxval(abs(rpt2(1:N_states))) > pt2_max) .and. &
(maxval(abs(variance(1:N_states))) > variance_max) .and. & (maxval(abs(variance(1:N_states))) > variance_max) .and. &
(correlation_energy_ratio <= correlation_energy_ratio_max) & (correlation_energy_ratio <= correlation_energy_ratio_max) &
) )
write(*,'(A)') '--------------------------------------------------------------------------------' write(*,'(A)') '--------------------------------------------------------------------------------'
to_select = N_det*int(sqrt(dble(N_states)))*selection_factor to_select = int(sqrt(dble(N_states))*dble(N_det)*selection_factor)
to_select = max(N_states_diag, to_select) to_select = max(N_states_diag, to_select)
pt2 = 0.d0 pt2 = 0.d0
@ -79,17 +80,17 @@ subroutine run_stochastic_cipsi
call ZMQ_pt2(psi_energy_with_nucl_rep,pt2,relative_error,error, variance, & call ZMQ_pt2(psi_energy_with_nucl_rep,pt2,relative_error,error, variance, &
norm, to_select) ! Stochastic PT2 and selection norm, to_select) ! Stochastic PT2 and selection
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, rpt2)
call write_double(6,correlation_energy_ratio, 'Correlation ratio')
call print_summary(psi_energy_with_nucl_rep,pt2,error,variance,norm,N_det,N_occ_pattern,N_states,psi_s2)
do k=1,N_states do k=1,N_states
rpt2(k) = pt2(k)/(1.d0 + norm(k)) rpt2(k) = pt2(k)/(1.d0 + norm(k))
enddo enddo
correlation_energy_ratio = (psi_energy_with_nucl_rep(1) - hf_energy_ref) / &
(psi_energy_with_nucl_rep(1) + rpt2(1) - hf_energy_ref)
correlation_energy_ratio = min(1.d0,correlation_energy_ratio)
call write_double(6,correlation_energy_ratio, 'Correlation ratio')
call print_summary(psi_energy_with_nucl_rep,pt2,error,variance,norm,N_det,N_occ_pattern,N_states,psi_s2)
call save_energy(psi_energy_with_nucl_rep, rpt2) call save_energy(psi_energy_with_nucl_rep, rpt2)
call save_iterations(psi_energy_with_nucl_rep(1:N_states),rpt2,N_det) call save_iterations(psi_energy_with_nucl_rep(1:N_states),rpt2,N_det)
@ -108,8 +109,7 @@ subroutine run_stochastic_cipsi
call diagonalize_CI call diagonalize_CI
call save_wavefunction call save_wavefunction
rpt2(:) = 0.d0 call save_energy(psi_energy_with_nucl_rep, zeros)
call save_energy(psi_energy_with_nucl_rep, rpt2)
if (qp_stop()) exit if (qp_stop()) exit
enddo enddo
@ -117,20 +117,18 @@ subroutine run_stochastic_cipsi
if (N_det < N_det_max) then if (N_det < N_det_max) then
call diagonalize_CI call diagonalize_CI
call save_wavefunction call save_wavefunction
rpt2(:) = 0.d0 call save_energy(psi_energy_with_nucl_rep, zeros)
call save_energy(psi_energy_with_nucl_rep, rpt2)
endif endif
pt2 = 0.d0 pt2(:) = 0.d0
variance = 0.d0 variance(:) = 0.d0
norm = 0.d0 norm(:) = 0.d0
call ZMQ_pt2(psi_energy_with_nucl_rep, pt2,relative_error,error,variance, & call ZMQ_pt2(psi_energy_with_nucl_rep, pt2,relative_error,error,variance, &
norm,0) ! Stochastic PT2 norm,0) ! Stochastic PT2
do k=1,N_states do k=1,N_states
rpt2(k) = pt2(k)/(1.d0 + norm(k)) rpt2(k) = pt2(k)/(1.d0 + norm(k))
enddo enddo
call save_energy(psi_energy_with_nucl_rep, rpt2)
call save_energy(psi_energy_with_nucl_rep, rpt2) call save_energy(psi_energy_with_nucl_rep, rpt2)
call print_summary(psi_energy_with_nucl_rep(1:N_states),pt2,error,variance,norm,N_det,N_occ_pattern,N_states,psi_s2) call print_summary(psi_energy_with_nucl_rep(1:N_states),pt2,error,variance,norm,N_det,N_occ_pattern,N_states,psi_s2)

View File

@ -46,6 +46,9 @@ subroutine ZMQ_selection(N_in, pt2, variance, norm)
if (zmq_put_dvector(zmq_to_qp_run_socket,1,'state_average_weight',state_average_weight,N_states) == -1) then if (zmq_put_dvector(zmq_to_qp_run_socket,1,'state_average_weight',state_average_weight,N_states) == -1) then
stop 'Unable to put state_average_weight on ZMQ server' stop 'Unable to put state_average_weight on ZMQ server'
endif endif
if (zmq_put_dvector(zmq_to_qp_run_socket,1,'selection_weight',selection_weight,N_states) == -1) then
stop 'Unable to put selection_weight on ZMQ server'
endif
if (zmq_put_dvector(zmq_to_qp_run_socket,1,'threshold_generators',threshold_generators,1) == -1) then if (zmq_put_dvector(zmq_to_qp_run_socket,1,'threshold_generators',threshold_generators,1) == -1) then
stop 'Unable to put threshold_generators on ZMQ server' stop 'Unable to put threshold_generators on ZMQ server'
endif endif