From 4842d55a630f08b3f451d1479eda12784f12657f Mon Sep 17 00:00:00 2001 From: Kevin Gasperich Date: Fri, 14 May 2021 10:48:02 -0500 Subject: [PATCH 1/4] fixed 1rdm in AO basis to be state-specific instead of average --- src/determinants/density_matrix_cplx.irp.f | 30 ++++++++++++++++++++++ src/tools/save_one_e_dm_cplx.irp.f | 4 +-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/determinants/density_matrix_cplx.irp.f b/src/determinants/density_matrix_cplx.irp.f index e5d74347..e9ec7e0f 100644 --- a/src/determinants/density_matrix_cplx.irp.f +++ b/src/determinants/density_matrix_cplx.irp.f @@ -309,6 +309,36 @@ END_PROVIDER END_PROVIDER + BEGIN_PROVIDER [ complex*16, one_e_dm_ao_alpha_complex_nst, (ao_num,ao_num,N_states) ] +&BEGIN_PROVIDER [ complex*16, one_e_dm_ao_beta_complex_nst, (ao_num,ao_num,N_states) ] + BEGIN_DOC + ! One body density matrix on the |AO| basis : $\rho_{AO}(\alpha), \rho_{AO}(\beta)$. + END_DOC + implicit none + integer :: i,j,k,l,ist + complex*16 :: mo_alpha,mo_beta + + one_e_dm_ao_alpha_complex_nst = (0.d0,0.d0) + one_e_dm_ao_beta_complex_nst = (0.d0,0.d0) + do ist = 1,N_states + do k = 1, ao_num + do l = 1, ao_num + do i = 1, mo_num + do j = 1, mo_num + mo_alpha = one_e_dm_mo_alpha_complex(j,i,ist) + mo_beta = one_e_dm_mo_beta_complex(j,i,ist) + ! if(dabs(dm_mo).le.1.d-10)cycle + one_e_dm_ao_alpha_complex_nst(l,k,ist) += dconjg(mo_coef_complex(k,i)) * mo_coef_complex(l,j) * mo_alpha + one_e_dm_ao_beta_complex_nst(l,k,ist) += dconjg(mo_coef_complex(k,i)) * mo_coef_complex(l,j) * mo_beta + enddo + enddo + enddo + enddo + enddo + +END_PROVIDER + + !============================================! ! ! ! kpts ! diff --git a/src/tools/save_one_e_dm_cplx.irp.f b/src/tools/save_one_e_dm_cplx.irp.f index 3d0e6d6c..fdf00053 100644 --- a/src/tools/save_one_e_dm_cplx.irp.f +++ b/src/tools/save_one_e_dm_cplx.irp.f @@ -22,6 +22,6 @@ subroutine routine_save_one_e_dm_cplx END_DOC call ezfio_set_aux_quantities_data_one_e_dm_alpha_mo_complex(one_e_dm_mo_alpha_complex) call ezfio_set_aux_quantities_data_one_e_dm_beta_mo_complex(one_e_dm_mo_beta_complex) - call ezfio_set_aux_quantities_data_one_e_dm_alpha_ao_complex(one_e_dm_ao_alpha_complex) - call ezfio_set_aux_quantities_data_one_e_dm_beta_ao_complex(one_e_dm_ao_beta_complex) + call ezfio_set_aux_quantities_data_one_e_dm_alpha_ao_complex(one_e_dm_ao_alpha_complex_nst) + call ezfio_set_aux_quantities_data_one_e_dm_beta_ao_complex(one_e_dm_ao_beta_complex_nst) end From f2b81c8f975d713862c37a10d6cd3ca9614764df Mon Sep 17 00:00:00 2001 From: Kevin Gasperich Date: Thu, 27 May 2021 12:33:08 -0500 Subject: [PATCH 2/4] save determinants directory when save_wavefunction_general_complex is called added option to turn this on or off determinants/backup_determinants_dir (default True) tars the determinants directory and moves the tar to ezfio/save/determinants/determinants.nstate.ndet.tar gzip doesn't save any significant space (the large parts are already gzipped) saves one backup per nstate,ndet pair --- scripts/save_current_dets.sh | 41 ++++++++++++++++++++++++ src/determinants/EZFIO.cfg | 5 +++ src/determinants/determinants_cplx.irp.f | 3 ++ 3 files changed, 49 insertions(+) create mode 100755 scripts/save_current_dets.sh diff --git a/scripts/save_current_dets.sh b/scripts/save_current_dets.sh new file mode 100755 index 00000000..252a57e2 --- /dev/null +++ b/scripts/save_current_dets.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# This script is used by the determinants module, and should not be used by users. +# It copies the EZFIO/determinants directory to EZFIO/save/determinants/determinants.n_det + + +if [[ -z ${QP_ROOT} ]] ; then + print "The QP_ROOT environment variable is not set." + print "Please reload the quantum_package.rc file." + exit -1 +fi + +EZFIO="$1" + +if [[ -z "${EZFIO}" ]] ; then + echo "Error in $0" + exit 1 +fi + +NDET=$(head -1 "${EZFIO}/determinants/n_det" | xargs printf "%09d") #xargs trims the result +NSTATE=$(head -1 "${EZFIO}/determinants/n_states" | xargs) #xargs trims the result +DESTINATION="save/determinants/determinants.${NSTATE}.${NDET}.tar" + +cd "${EZFIO}" + +BACKUP="${DESTINATION}.old" +if [[ -f "${BACKUP}" ]] ; then + rm -f "${BACKUP}" +fi + +if [[ -f "${DESTINATION}" ]] ; then + mv "${DESTINATION}" "${BACKUP}" +fi +if [[ ! -d save/determinants ]] ; then + mkdir -p save/determinants +fi + +tar cf ${DESTINATION} determinants +#tar cf dets_tmp.tar determinants +#mv --backup=t dets_tmp.tar ${DESTINATION} + + diff --git a/src/determinants/EZFIO.cfg b/src/determinants/EZFIO.cfg index b03ab374..5d633758 100644 --- a/src/determinants/EZFIO.cfg +++ b/src/determinants/EZFIO.cfg @@ -148,3 +148,8 @@ doc: If |true|, discard any Slater determinants with an interaction smaller than interface: ezfio,provider,ocaml default: False +[backup_determinants_dir] +type: logical +doc: If |true|, make a copy of the existing determinants directory before saving a new wavefunction. +interface: ezfio,provider,ocaml +default: True diff --git a/src/determinants/determinants_cplx.irp.f b/src/determinants/determinants_cplx.irp.f index 76e4d9fc..b0fbbb15 100644 --- a/src/determinants/determinants_cplx.irp.f +++ b/src/determinants/determinants_cplx.irp.f @@ -205,6 +205,9 @@ subroutine save_wavefunction_general_complex(ndet,nstates,psidet,dim_psicoef,psi integer :: i,j,k, ndet_qp_edit if (mpi_master) then + if (backup_determinants_dir) then + call system('$QP_ROOT/scripts/save_current_dets.sh '//trim(ezfio_filename)) + endif ndet_qp_edit = min(ndet,N_det_qp_edit) call ezfio_set_determinants_N_int(N_int) From a9a0c03732b7d9e586f02cd59c1a9175cf479d1e Mon Sep 17 00:00:00 2001 From: Kevin Gasperich Date: Tue, 1 Jun 2021 11:35:49 -0500 Subject: [PATCH 3/4] account for kmesh==None or [] in pyscf pbc converter --- src/utils_complex/MolPyscfToQPkpts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils_complex/MolPyscfToQPkpts.py b/src/utils_complex/MolPyscfToQPkpts.py index 8637651a..45e9644a 100644 --- a/src/utils_complex/MolPyscfToQPkpts.py +++ b/src/utils_complex/MolPyscfToQPkpts.py @@ -133,7 +133,7 @@ def get_supcellPhase(cell, kpts=[], kmesh=[]): from pyscf import lib latt_vec = cell.lattice_vectors() - if len(kmesh)== 0: + if not bool(kmesh): # Guess kmesh scaled_k = cell.get_scaled_kpts(kpts).round(8) kmesh = (len(np.unique(scaled_k[:,0])), From b92a23a85312e05fb607daf774244f73af913162 Mon Sep 17 00:00:00 2001 From: Kevin Gasperich Date: Thu, 14 Apr 2022 19:02:48 -0500 Subject: [PATCH 4/4] use np array directly instead of converting to list --- bin/qp_convert_h5_to_ezfio | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/qp_convert_h5_to_ezfio b/bin/qp_convert_h5_to_ezfio index 274c6131..5a397d3f 100755 --- a/bin/qp_convert_h5_to_ezfio +++ b/bin/qp_convert_h5_to_ezfio @@ -385,7 +385,8 @@ def convert_kpts(filename,qph5path,qmcpack=True): # dfao_im0=qph5['ao_two_e_ints/df_ao_integrals_imag'][()].transpose((3,2,1,0)) # dfao_cmplx0 = np.stack((dfao_re0,dfao_im0),axis=-1).tolist() # ezfio.set_ao_two_e_ints_df_ao_integrals_complex(dfao_cmplx0) - dfao_reim=qph5['ao_two_e_ints/df_ao_integrals'][()].tolist() + #dfao_reim=qph5['ao_two_e_ints/df_ao_integrals'][()].tolist() + dfao_reim=qph5['ao_two_e_ints/df_ao_integrals'][()] ezfio.set_ao_two_e_ints_df_ao_integrals_complex(dfao_reim) ezfio.set_ao_two_e_ints_io_df_ao_integrals('Read')