From 644aa334dc8557b1796cf395687d63f988fe9ab2 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 21 Apr 2022 13:39:01 +0200 Subject: [PATCH 01/19] Update test values --- src/fci/40.fci.bats | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index 1a0c5507..b8528e97 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -71,7 +71,7 @@ function run_stoch() { @test "HBO" { # 13.3144s [[ -n $TRAVIS ]] && skip qp set_file hbo.ezfio - run -100.214099486337 1.e-3 100000 + run -100.213 1.e-3 100000 } @test "H2O" { # 11.3727s @@ -89,7 +89,7 @@ function run_stoch() { @test "SO" { # 13.4952s [[ -n $TRAVIS ]] && skip qp set_file so.ezfio - run -26.0176563764039 1.e-3 100000 + run -26.014 5.e-3 100000 } @test "H2S" { # 13.6745s @@ -119,7 +119,7 @@ function run_stoch() { @test "SiH3" { # 15.99s [[ -n $TRAVIS ]] && skip qp set_file sih3.ezfio - run -5.57241217753818 5.e-4 100000 + run -5.572 1.e-3 100000 } @test "CH4" { # 16.1612s @@ -153,7 +153,7 @@ function run_stoch() { [[ -n $TRAVIS ]] && skip qp set_file n2.ezfio qp set_mo_class --core="[1,2]" --act="[3-40]" --del="[41-60]" - run -109.287917088107 1.5e-3 100000 + run -109.288 2.e-3 100000 } @test "N2H4" { # 18.5006s From 1d5f8400aa8d7e7bcf89eaca052b63904f78fa54 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 21 Apr 2022 13:42:10 +0200 Subject: [PATCH 02/19] Update test values --- src/fci/40.fci.bats | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index b8528e97..d890d586 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -42,7 +42,7 @@ function run_stoch() { [[ -n $TRAVIS ]] && skip qp set_file f2.ezfio qp set_frozen_core - run_stoch -199.304922384814 3.e-4 100000 + run_stoch -199.304922384814 3.e-3 100000 } @test "NH3" { # 10.6657s @@ -89,7 +89,7 @@ function run_stoch() { @test "SO" { # 13.4952s [[ -n $TRAVIS ]] && skip qp set_file so.ezfio - run -26.014 5.e-3 100000 + run -26.015 3.e-3 100000 } @test "H2S" { # 13.6745s @@ -146,7 +146,7 @@ function run_stoch() { [[ -n $TRAVIS ]] && skip qp set_file c2h2.ezfio qp set_mo_class --act="[1-30]" --del="[31-36]" - run -12.3685464085969 2.e-3 100000 + run -12.367 3.e-3 100000 } @test "N2" { # 18.0198s @@ -182,6 +182,6 @@ function run_stoch() { [[ -n $TRAVIS ]] && skip qp set_file hcn.ezfio qp set_mo_class --core="[1,2]" --act="[3-40]" --del="[41-55]" - run -93.0777619629755 1.e-3 100000 + run -93.078 2.e-3 100000 } From 4ccaa8f695a4928be80bb214dd063a7b7e9d28a9 Mon Sep 17 00:00:00 2001 From: v1j4y Date: Mon, 6 Jun 2022 13:41:29 +0200 Subject: [PATCH 03/19] Open-Shell CSF: Fix bug in getbftodetfunction. --- src/csf/cfgCI_utils.c | 50 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/src/csf/cfgCI_utils.c b/src/csf/cfgCI_utils.c index 23b984a0..63172d14 100644 --- a/src/csf/cfgCI_utils.c +++ b/src/csf/cfgCI_utils.c @@ -68,10 +68,16 @@ void getBFIndexList(int NSOMO, int *BF1, int *IdxListBF1){ break; } } - BFcopy[Iidx] = -1; - BFcopy[Jidx] = -1; - IdxListBF1[Jidx] = Iidx; - IdxListBF1[Iidx] = Jidx; + if(countN1 <= 0){ + BFcopy[Iidx] = -1; + IdxListBF1[Iidx] = Iidx; + } + else{ + BFcopy[Iidx] = -1; + BFcopy[Jidx] = -1; + IdxListBF1[Jidx] = Iidx; + IdxListBF1[Iidx] = Jidx; + } } } @@ -1297,16 +1303,21 @@ void getbftodetfunction(Tree *dettree, int NSOMO, int MS, int *BF1, double *rowv double fac = 1.0; for(int i = 0; i < NSOMO; i++) donepq[i] = 0.0; + for(int i=0;i 0.0 || donepq[idxq] > 0.0) continue; + if(donepq[idxp] > 0.0 || donepq[idxq] > 0.0 || idxp == idxq) continue; fac *= 2.0; donepq[idxp] = 1.0; donepq[idxq] = 1.0; for(int j = 0; j < npairs; j = j + shft){ + printf("i=%d j=%d (%d,%d)\n",i,j,idxp,idxq); for(int k = 0; k < shft/2; k++){ detslist[(k+j)*NSOMO + idxp] = 1; detslist[(k+j)*NSOMO + idxq] = 0; @@ -1319,15 +1330,26 @@ void getbftodetfunction(Tree *dettree, int NSOMO, int MS, int *BF1, double *rowv } shft /= 2; } + for(int i=0;i Date: Mon, 6 Jun 2022 14:08:34 +0200 Subject: [PATCH 04/19] Open-Shell CSF: Fix bug in build csftree. --- src/csf/cfgCI_utils.c | 34 +++++----------------------------- src/csf/tree_utils.c | 26 +++++++++++++++----------- 2 files changed, 20 insertions(+), 40 deletions(-) diff --git a/src/csf/cfgCI_utils.c b/src/csf/cfgCI_utils.c index 63172d14..91e7360a 100644 --- a/src/csf/cfgCI_utils.c +++ b/src/csf/cfgCI_utils.c @@ -1317,7 +1317,6 @@ void getbftodetfunction(Tree *dettree, int NSOMO, int MS, int *BF1, double *rowv donepq[idxp] = 1.0; donepq[idxq] = 1.0; for(int j = 0; j < npairs; j = j + shft){ - printf("i=%d j=%d (%d,%d)\n",i,j,idxp,idxq); for(int k = 0; k < shft/2; k++){ detslist[(k+j)*NSOMO + idxp] = 1; detslist[(k+j)*NSOMO + idxq] = 0; @@ -1330,14 +1329,7 @@ void getbftodetfunction(Tree *dettree, int NSOMO, int MS, int *BF1, double *rowv } shft /= 2; } - for(int i=0;i NSOMOMax || icpl < 0 || izeros > zeromax ) return; // If we find a valid BF assign its address - if(isomo == NSOMOMax){ + if(isomo == NSOMOMax && icpl == MSmax){ (*inode)->addr = bftree->rootNode->addr; bftree->rootNode->addr += 1; return; } // Call 0 branch - if(((*inode)->C0) == NULL && izeros+1 <= zeromax){ - ((*inode)->C0) = malloc(sizeof(Node)); - (*(*inode)->C0) = (Node){ .C0 = NULL, .C1 = NULL, .PREV = *inode, .addr = -1, .cpl = 0, .iSOMO = isomo }; - buildTree(bftree, &(*inode)->C0, isomo+1, izeros+1, icpl+1, NSOMOMax, MSmax); + if(izeros+1 <= zeromax){ + if(((*inode)->C0) == NULL){ + ((*inode)->C0) = malloc(sizeof(Node)); + (*(*inode)->C0) = (Node){ .C0 = NULL, .C1 = NULL, .PREV = *inode, .addr = -1, .cpl = 0, .iSOMO = isomo }; + buildTree(bftree, &(*inode)->C0, isomo+1, izeros+1, icpl+1, NSOMOMax, MSmax); + } + else buildTree(bftree, &(*inode)->C0, isomo+1, izeros+1, icpl+1, NSOMOMax, MSmax); } - else buildTree(bftree, &(*inode)->C0, isomo+1, izeros+1, icpl+1, NSOMOMax, MSmax); // Call 1 branch - if(((*inode)->C1) == NULL && icpl-1 >= 0){ - ((*inode)->C1) = malloc(sizeof(Node)); - (*(*inode)->C1) = (Node){ .C0 = NULL, .C1 = NULL, .PREV = *inode, .addr = -1, .cpl = 1, .iSOMO = isomo }; - buildTree(bftree, &(*inode)->C1, isomo+1, izeros+0, icpl-1, NSOMOMax, MSmax); + if(icpl-1 >=0){ + if(((*inode)->C1) == NULL){ + ((*inode)->C1) = malloc(sizeof(Node)); + (*(*inode)->C1) = (Node){ .C0 = NULL, .C1 = NULL, .PREV = *inode, .addr = -1, .cpl = 1, .iSOMO = isomo }; + buildTree(bftree, &(*inode)->C1, isomo+1, izeros+0, icpl-1, NSOMOMax, MSmax); + } + else buildTree(bftree, &(*inode)->C1, isomo+1, izeros+0, icpl-1, NSOMOMax, MSmax); } - else buildTree(bftree, &(*inode)->C1, isomo+1, izeros+0, icpl-1, NSOMOMax, MSmax); return; } From e06ab2fd05d46a8f8be6c86f23e3870615287b8d Mon Sep 17 00:00:00 2001 From: v1j4y Date: Mon, 6 Jun 2022 15:23:25 +0200 Subject: [PATCH 05/19] Open-Shell CSF: Fix bug in convertCSFtoDetBasis. --- src/csf/cfgCI_utils.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/csf/cfgCI_utils.c b/src/csf/cfgCI_utils.c index 91e7360a..746de04e 100644 --- a/src/csf/cfgCI_utils.c +++ b/src/csf/cfgCI_utils.c @@ -334,10 +334,21 @@ void convertCSFtoDetBasis(int64_t Isomo, int MS, int rowsmax, int colsmax, doubl Get Overlap ************************************/ // Fill matrix + + int rowsbftodetI, colsbftodetI; + + /*********************************** + Get BFtoDeterminant Matrix + ************************************/ + + printf("In convertcsftodet\n"); + convertBFtoDetBasis(Isomo, MS, &bftodetmatrixI, &rowsbftodetI, &colsbftodetI); + int rowsI = 0; int colsI = 0; - getOverlapMatrix(Isomo, MS, &overlapMatrixI, &rowsI, &colsI, &NSOMO); + //getOverlapMatrix(Isomo, MS, &overlapMatrixI, &rowsI, &colsI, &NSOMO); + getOverlapMatrix_withDet(bftodetmatrixI, rowsbftodetI, colsbftodetI, Isomo, MS, &overlapMatrixI, &rowsI, &colsI, &NSOMO); /*********************************** @@ -348,14 +359,6 @@ void convertCSFtoDetBasis(int64_t Isomo, int MS, int rowsmax, int colsmax, doubl gramSchmidt(overlapMatrixI, rowsI, colsI, orthoMatrixI); - /*********************************** - Get BFtoDeterminant Matrix - ************************************/ - - int rowsbftodetI, colsbftodetI; - - convertBFtoDetBasis(Isomo, MS, &bftodetmatrixI, &rowsbftodetI, &colsbftodetI); - /*********************************** Get Final CSF to Det Matrix ************************************/ @@ -1305,7 +1308,7 @@ void getbftodetfunction(Tree *dettree, int NSOMO, int MS, int *BF1, double *rowv donepq[i] = 0.0; for(int i=0;i Date: Fri, 10 Jun 2022 12:11:08 +0200 Subject: [PATCH 06/19] Fixed max memory detection --- external/qp2-dependencies | 2 +- src/mo_two_e_ints/mo_bi_integrals.irp.f | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/external/qp2-dependencies b/external/qp2-dependencies index 242151e0..bc856147 160000 --- a/external/qp2-dependencies +++ b/external/qp2-dependencies @@ -1 +1 @@ -Subproject commit 242151e03d1d6bf042387226431d82d35845686a +Subproject commit bc856147f6e626a6616b20344e5b8e3f30f44a92 diff --git a/src/mo_two_e_ints/mo_bi_integrals.irp.f b/src/mo_two_e_ints/mo_bi_integrals.irp.f index c03b363d..6f4c5c17 100644 --- a/src/mo_two_e_ints/mo_bi_integrals.irp.f +++ b/src/mo_two_e_ints/mo_bi_integrals.irp.f @@ -53,7 +53,7 @@ BEGIN_PROVIDER [ logical, mo_two_e_integrals_in_map ] ! call four_idx_novvvv call four_idx_novvvv_old else - if (ao_num*ao_num*ao_num*ao_num*32.d-9 < dble(qp_max_mem)) then + if (32.d-9*dble(ao_num)**4 < dble(qp_max_mem)) then call four_idx_dgemm else call add_integrals_to_map(full_ijkl_bitmask_4) @@ -130,7 +130,6 @@ subroutine four_idx_dgemm real(integral_kind), allocatable :: buffer_value(:) size_buffer = min(ao_num*ao_num*ao_num,16000000) - print *, 'Storing' !$OMP PARALLEL DEFAULT(SHARED) PRIVATE(i,j,k,l,buffer_value,buffer_i,n_integrals) allocate ( buffer_i(size_buffer), buffer_value(size_buffer) ) @@ -164,7 +163,6 @@ subroutine four_idx_dgemm deallocate (a1) - print *, 'Unique' call map_unique(mo_integrals_map) integer*8 :: get_mo_map_size, mo_map_size From 31572fddc3b8de11008e214e29b602d9f0ff5c8d Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 10 Jun 2022 14:28:37 +0200 Subject: [PATCH 07/19] Prepared CFG H.Psi for Vijay --- src/davidson/diagonalize_ci.irp.f | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/davidson/diagonalize_ci.irp.f b/src/davidson/diagonalize_ci.irp.f index 46ad8f78..6930cc07 100644 --- a/src/davidson/diagonalize_ci.irp.f +++ b/src/davidson/diagonalize_ci.irp.f @@ -1,3 +1,13 @@ +BEGIN_PROVIDER [ character*(3), sigma_vector_algorithm ] + implicit none + BEGIN_DOC + ! If 'det', use in Davidson + ! + ! If 'cfg', use in Davidson + END_DOC + sigma_vector_algorithm = 'det' +END_PROVIDER + BEGIN_PROVIDER [ double precision, CI_energy, (N_states_diag) ] implicit none BEGIN_DOC @@ -61,9 +71,18 @@ END_PROVIDER if (diag_algorithm == "Davidson") then if (do_csf) then - call davidson_diag_H_csf(psi_det,CI_eigenvectors, & - size(CI_eigenvectors,1),CI_electronic_energy, & - N_det,N_csf,min(N_det,N_states),min(N_det,N_states_diag),N_int,0,converged) + if (sigma_vector_algorithm == 'det') then + call davidson_diag_H_csf(psi_det,CI_eigenvectors, & + size(CI_eigenvectors,1),CI_electronic_energy, & + N_det,N_csf,min(N_det,N_states),min(N_det,N_states_diag),N_int,0,converged) +! else if (sigma_vector_algorithm == 'cfg') then +! call davidson_diag_H_csf(psi_det,CI_eigenvectors, & +! size(CI_eigenvectors,1),CI_electronic_energy, & +! N_det,N_csf,min(N_det,N_states),min(N_det,N_states_diag),N_int,0,converged) +! else +! print *, irp_here +! stop 'bug' + endif else call davidson_diag_HS2(psi_det,CI_eigenvectors, CI_s2, & size(CI_eigenvectors,1),CI_electronic_energy, & From cc7943f3936a64dbe3ac9449d293a7144f793324 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 14 Jun 2022 16:19:14 +0200 Subject: [PATCH 08/19] Update qp2-dependencies --- external/qp2-dependencies | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/qp2-dependencies b/external/qp2-dependencies index bc856147..242151e0 160000 --- a/external/qp2-dependencies +++ b/external/qp2-dependencies @@ -1 +1 @@ -Subproject commit bc856147f6e626a6616b20344e5b8e3f30f44a92 +Subproject commit 242151e03d1d6bf042387226431d82d35845686a From f093592124457451eeb0b6817488b4591cf9295f Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 14 Jun 2022 18:10:32 +0200 Subject: [PATCH 09/19] Update guess in CISD --- src/cisd/cisd.irp.f | 37 ++++++++++++++++--- .../diagonalization_hcsf_dressed.irp.f | 19 +++------- src/determinants/determinants.irp.f | 4 +- 3 files changed, 38 insertions(+), 22 deletions(-) diff --git a/src/cisd/cisd.irp.f b/src/cisd/cisd.irp.f index 5f167686..3e1e8d97 100644 --- a/src/cisd/cisd.irp.f +++ b/src/cisd/cisd.irp.f @@ -47,6 +47,37 @@ program cisd PROVIDE N_states read_wf = .False. SOFT_TOUCH read_wf + + integer :: i,k + + if(pseudo_sym)then + call H_apply_cisd_sym + else + call H_apply_cisd + endif + double precision :: r1, r2 + double precision, allocatable :: U_csf(:,:) + + allocate(U_csf(N_csf,N_states)) + U_csf = 0.d0 + U_csf(1,1) = 1.d0 + do k=2,N_states + do i=1,N_csf + call random_number(r1) + call random_number(r2) + r1 = dsqrt(-2.d0*dlog(r1)) + r2 = dacos(-1.d0)*2.d0*r2 + U_csf(i,k) = r1*dcos(r2) + enddo + U_csf(k,k) = U_csf(k,k) +100.d0 + enddo + do k=1,N_states + call normalize(U_csf(1,k),N_csf) + enddo + call convertWFfromCSFtoDET(N_states,U_csf(1,1),psi_coef(1,1)) + deallocate(U_csf) + SOFT_TOUCH psi_coef + call run end @@ -56,13 +87,7 @@ subroutine run double precision :: cisdq(N_states), delta_e double precision,external :: diag_h_mat_elem - if(pseudo_sym)then - call H_apply_cisd_sym - else - call H_apply_cisd - endif psi_coef = ci_eigenvectors - SOFT_TOUCH psi_coef call save_wavefunction_truncated(save_threshold) call ezfio_set_cisd_energy(CI_energy) diff --git a/src/davidson/diagonalization_hcsf_dressed.irp.f b/src/davidson/diagonalization_hcsf_dressed.irp.f index 0c3c6f92..5f8aa4c9 100644 --- a/src/davidson/diagonalization_hcsf_dressed.irp.f +++ b/src/davidson/diagonalization_hcsf_dressed.irp.f @@ -263,29 +263,20 @@ subroutine davidson_diag_csf_hjj(dets_in,u_in,H_jj,energies,dim_in,sze,sze_csf,N ! =================== converged = .False. - + call convertWFfromDETtoCSF(N_st_diag,u_in(1,1),U_csf(1,1)) do k=N_st+1,N_st_diag - do i=1,sze + do i=1,sze_csf call random_number(r1) call random_number(r2) r1 = dsqrt(-2.d0*dlog(r1)) r2 = dtwo_pi*r2 - u_in(i,k) = r1*dcos(r2) * u_in(i,k-N_st) + U_csf(i,k) = r1*dcos(r2) * u_csf(i,k-N_st) enddo - u_in(k,k) = u_in(k,k) + 10.d0 + U_csf(k,k) = u_csf(k,k) + 10.d0 enddo do k=1,N_st_diag - call normalize(u_in(1,k),sze) + call normalize(U_csf(1,k),sze_csf) enddo - - do k=1,N_st_diag - do i=1,sze - U(i,k) = u_in(i,k) - enddo - enddo - - ! Make random verctors eigenstates of S2 - call convertWFfromDETtoCSF(N_st_diag,U(1,1),U_csf(1,1)) call convertWFfromCSFtoDET(N_st_diag,U_csf(1,1),U(1,1)) do while (.not.converged) diff --git a/src/determinants/determinants.irp.f b/src/determinants/determinants.irp.f index 4b317025..e1c14bfe 100644 --- a/src/determinants/determinants.irp.f +++ b/src/determinants/determinants.irp.f @@ -77,7 +77,7 @@ BEGIN_PROVIDER [ integer, psi_det_size ] END_DOC PROVIDE ezfio_filename logical :: exists - psi_det_size = 1 + psi_det_size = N_states PROVIDE mpi_master if (read_wf) then if (mpi_master) then @@ -85,7 +85,7 @@ BEGIN_PROVIDER [ integer, psi_det_size ] if (exists) then call ezfio_get_determinants_n_det(psi_det_size) else - psi_det_size = 1 + psi_det_size = N_states endif call write_int(6,psi_det_size,'Dimension of the psi arrays') endif From d11b7365cbd6c47718e84b908a5226dfb95d2f47 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 14 Jun 2022 18:15:53 +0200 Subject: [PATCH 10/19] Update itermax with CSF --- src/davidson/diagonalization_hcsf_dressed.irp.f | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/davidson/diagonalization_hcsf_dressed.irp.f b/src/davidson/diagonalization_hcsf_dressed.irp.f index 5f8aa4c9..7aaaa842 100644 --- a/src/davidson/diagonalization_hcsf_dressed.irp.f +++ b/src/davidson/diagonalization_hcsf_dressed.irp.f @@ -124,7 +124,7 @@ subroutine davidson_diag_csf_hjj(dets_in,u_in,H_jj,energies,dim_in,sze,sze_csf,N stop -1 endif - itermax = max(2,min(davidson_sze_max, sze/N_st_diag))+1 + itermax = max(2,min(davidson_sze_max, sze_csf/N_st_diag))+1 itertot = 0 if (state_following) then From bd719b72af00f249e14bb2718142f4026ae22cc4 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 16 Jun 2022 17:15:28 +0200 Subject: [PATCH 11/19] Update README.md New logo and European funding in readme --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b8141b88..24d6277e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Quantum Package 2.2 - + + [![DOI](https://zenodo.org/badge/167513335.svg)](https://zenodo.org/badge/latestdoi/167513335) @@ -44,9 +45,19 @@ https://arxiv.org/abs/1902.08154 # Credits +* [TREX Center of Excellence](https://trex-coe.eu) +* [ERC PTEROSOR](https://lcpq.github.io/PTEROSOR) * [CNRS](http://www.cnrs.fr) * [Laboratoire de Chimie et Physique Quantiques](http://lcpq.ups-tlse.fr) * [Laboratoire de Chimie Théorique](http://www.lct.jussieu.fr) * [Argonne Leadership Computing Facility](http://alcf.anl.gov) * [CALMIP](https://www.calmip.univ-toulouse.fr) + +------------------------------ + + + +[TREX: Targeting Real Chemical Accuracy at the Exascale](https://trex-coe.eu) project has received funding from the European Union’s Horizon 2020 - Research and Innovation program - under grant agreement no. 952165. The content of this document does not represent the opinion of the European Union, and the European Union is not responsible for any use that might be made of such content. + +[PTEROSOR](https://lcpq.github.io/PTEROSOR) project has received funding from the European Research Council (ERC) under the European Union’s Horizon 2020 research and innovation programme (Grant agreement No. 863481). From a0949cba45749d1e43a28273a1a9bdb05c2d1ab1 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sat, 18 Jun 2022 11:39:36 +0200 Subject: [PATCH 12/19] Better error handling on ocaml --- etc/qp.rc | 2 -- external/qp2-dependencies | 2 +- ocaml/Command_line.ml | 19 +++++++++++-------- ocaml/Command_line.mli | 2 ++ ocaml/qp_create_ezfio.ml | 11 ++++++++--- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/etc/qp.rc b/etc/qp.rc index c56661c7..064ca3f7 100644 --- a/etc/qp.rc +++ b/etc/qp.rc @@ -80,8 +80,6 @@ function qp() if [[ -d $NAME ]] ; then [[ -d $EZFIO_FILE ]] && ezfio unset_file ezfio set_file $NAME - else - qp_create_ezfio -h | more fi unset _ARGS ;; diff --git a/external/qp2-dependencies b/external/qp2-dependencies index 242151e0..90ee61f5 160000 --- a/external/qp2-dependencies +++ b/external/qp2-dependencies @@ -1 +1 @@ -Subproject commit 242151e03d1d6bf042387226431d82d35845686a +Subproject commit 90ee61f5041c7c94a0c605625a264860292813a0 diff --git a/ocaml/Command_line.ml b/ocaml/Command_line.ml index 1dd57892..602315c6 100644 --- a/ocaml/Command_line.ml +++ b/ocaml/Command_line.ml @@ -1,3 +1,5 @@ +exception Error of string + type short_opt = char type long_opt = string type optional = Mandatory | Optional @@ -181,15 +183,16 @@ let set_specs specs_in = Getopt.parse_cmdline cmd_specs (fun x -> anon_args := !anon_args @ [x]); if show_help () then - (help () ; exit 0); + help () + else + (* Check that all mandatory arguments are set *) + List.filter (fun x -> x.short <> ' ' && x.opt = Mandatory) !specs + |> List.iter (fun x -> + match get x.long with + | Some _ -> () + | None -> raise (Error ("--"^x.long^" option is missing.")) + ) - (* Check that all mandatory arguments are set *) - List.filter (fun x -> x.short <> ' ' && x.opt = Mandatory) !specs - |> List.iter (fun x -> - match get x.long with - | Some _ -> () - | None -> failwith ("Error: --"^x.long^" option is missing.") - ) ;; diff --git a/ocaml/Command_line.mli b/ocaml/Command_line.mli index 9f6e7022..5ad4ee08 100644 --- a/ocaml/Command_line.mli +++ b/ocaml/Command_line.mli @@ -59,6 +59,8 @@ let () = *) +exception Error of string + type short_opt = char type long_opt = string diff --git a/ocaml/qp_create_ezfio.ml b/ocaml/qp_create_ezfio.ml index be6c305b..4583b118 100644 --- a/ocaml/qp_create_ezfio.ml +++ b/ocaml/qp_create_ezfio.ml @@ -677,6 +677,7 @@ let run ?o b au c d m p cart xyz_file = let () = + try ( let open Command_line in begin @@ -734,7 +735,7 @@ If a file with the same name as the basis set exists, this file will be read. O let basis = match Command_line.get "basis" with - | None -> assert false + | None -> "" | Some x -> x in @@ -773,10 +774,14 @@ If a file with the same name as the basis set exists, this file will be read. O let xyz_filename = match Command_line.anon_args () with - | [x] -> x - | _ -> (Command_line.help () ; failwith "input file is missing") + | [] -> failwith "input file is missing" + | x::_ -> x in run ?o:output basis au charge dummy multiplicity pseudo cart xyz_filename + ) + with + | Failure txt -> Printf.eprintf "Fatal error: %s\n%!" txt + | Command_line.Error txt -> Printf.eprintf "Command line error: %s\n%!" txt From f1a9a223997fa521e681ece7ce043f626c82c341 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sat, 18 Jun 2022 15:54:59 +0200 Subject: [PATCH 13/19] Improved truncate_wf --- src/tools/truncate_wf.irp.f | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/tools/truncate_wf.irp.f b/src/tools/truncate_wf.irp.f index 6c66c8ec..64c15bf7 100644 --- a/src/tools/truncate_wf.irp.f +++ b/src/tools/truncate_wf.irp.f @@ -54,11 +54,23 @@ subroutine routine_s2 double precision, allocatable :: psi_coef_tmp(:,:) integer :: i,j,k double precision :: accu(N_states) + integer :: weights(0:16), ix + double precision :: x - print *, 'Weights of the CFG' + weights(:) = 0 do i=1,N_det - print *, i, real(weight_configuration(det_to_configuration(i),:)), real(sum(weight_configuration(det_to_configuration(i),:))) + x = -dlog(1.d-32+sum(weight_configuration(det_to_configuration(i),:)))/dlog(10.d0) + ix = min(int(x), 16) + weights(ix) += 1 enddo + + print *, 'Histogram of the weights of the CFG' + do i=0,15 + print *, ' 10^{-', i, '} ', weights(i) + end do + print *, '< 10^{-', 15, '} ', weights(16) + + print*, 'Min weight of the configuration?' read(5,*) wmin From 0407def6782badc884946023753ba49196f0152d Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 22 Jun 2022 23:19:18 +0200 Subject: [PATCH 14/19] dummy args in ocaml --- external/qp2-dependencies | 2 +- ocaml/Molecule.ml | 4 ++-- ocaml/qp_run.ml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/external/qp2-dependencies b/external/qp2-dependencies index 90ee61f5..242151e0 160000 --- a/external/qp2-dependencies +++ b/external/qp2-dependencies @@ -1 +1 @@ -Subproject commit 90ee61f5041c7c94a0c605625a264860292813a0 +Subproject commit 242151e03d1d6bf042387226431d82d35845686a diff --git a/ocaml/Molecule.ml b/ocaml/Molecule.ml index 9b01ac3a..603244c8 100644 --- a/ocaml/Molecule.ml +++ b/ocaml/Molecule.ml @@ -101,7 +101,7 @@ let to_string_general ~f m = |> String.concat "\n" let to_string = - to_string_general ~f:(fun x -> Atom.to_string Units.Angstrom x) + to_string_general ~f:(fun x -> Atom.to_string ~units:Units.Angstrom x) let to_xyz = to_string_general ~f:Atom.to_xyz @@ -113,7 +113,7 @@ let of_xyz_string s = let l = String_ext.split s ~on:'\n' |> List.filter (fun x -> x <> "") - |> list_map (fun x -> Atom.of_string units x) + |> list_map (fun x -> Atom.of_string ~units x) in let ne = ( get_charge { nuclei=l ; diff --git a/ocaml/qp_run.ml b/ocaml/qp_run.ml index d096b15b..dfbab167 100644 --- a/ocaml/qp_run.ml +++ b/ocaml/qp_run.ml @@ -110,7 +110,7 @@ let run slave ?prefix exe ezfio_file = let task_thread = let thread = Thread.create ( fun () -> - TaskServer.run port_number ) + TaskServer.run ~port:port_number ) in thread (); in From f629fc993e05222e3e97674c51f39fa34f2b204c Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 29 Jun 2022 15:25:19 +0200 Subject: [PATCH 15/19] Fix normf=1 problem with gamess conversion --- bin/qp_convert_output_to_ezfio | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/qp_convert_output_to_ezfio b/bin/qp_convert_output_to_ezfio index 07ad2236..4c440dd9 100755 --- a/bin/qp_convert_output_to_ezfio +++ b/bin/qp_convert_output_to_ezfio @@ -146,6 +146,7 @@ def write_ezfio(res, filename): ezfio.set_ao_basis_ao_nucl(at) ezfio.set_ao_basis_ao_prim_num(num_prim) ezfio.set_ao_basis_ao_power(power_x + power_y + power_z) + ezfio.set_ao_basis_ao_normalized(False) # ~#~#~#~#~#~#~ # # P a r s i n g # From b1c91c205b98a2ea36c44d1870e4ef2e4206af95 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 29 Jun 2022 15:38:03 +0200 Subject: [PATCH 16/19] Better handling of normf=1 --- bin/qp_convert_output_to_ezfio | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/qp_convert_output_to_ezfio b/bin/qp_convert_output_to_ezfio index 4c440dd9..a6bbcf85 100755 --- a/bin/qp_convert_output_to_ezfio +++ b/bin/qp_convert_output_to_ezfio @@ -146,7 +146,13 @@ def write_ezfio(res, filename): ezfio.set_ao_basis_ao_nucl(at) ezfio.set_ao_basis_ao_prim_num(num_prim) ezfio.set_ao_basis_ao_power(power_x + power_y + power_z) - ezfio.set_ao_basis_ao_normalized(False) + try: + if res.normf == 0: + ezfio.set_ao_basis_ao_normalized(True) + elif res.normf == 1: + ezfio.set_ao_basis_ao_normalized(False) + except: + ezfio.set_ao_basis_ao_normalized(True) # ~#~#~#~#~#~#~ # # P a r s i n g # From 0e6ebdc5a2f806297bdb8eb6cc46d901ed4a7167 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 29 Jun 2022 15:43:35 +0200 Subject: [PATCH 17/19] Better handling of normf=1 --- bin/qp_convert_output_to_ezfio | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/qp_convert_output_to_ezfio b/bin/qp_convert_output_to_ezfio index a6bbcf85..e7c44b37 100755 --- a/bin/qp_convert_output_to_ezfio +++ b/bin/qp_convert_output_to_ezfio @@ -147,11 +147,15 @@ def write_ezfio(res, filename): ezfio.set_ao_basis_ao_prim_num(num_prim) ezfio.set_ao_basis_ao_power(power_x + power_y + power_z) try: - if res.normf == 0: + normf = res.normf + if normf == 0: ezfio.set_ao_basis_ao_normalized(True) - elif res.normf == 1: + elif normf == 1: ezfio.set_ao_basis_ao_normalized(False) - except: + else: + print("BUG in NORMF") + sys.exit(0) + except AttributeError: ezfio.set_ao_basis_ao_normalized(True) # ~#~#~#~#~#~#~ # From a6ffaa7da148bd24313112425507fe68bc4d0a6a Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 21 Apr 2022 13:39:01 +0200 Subject: [PATCH 18/19] Update test values --- src/fci/40.fci.bats | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index 1a0c5507..b8528e97 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -71,7 +71,7 @@ function run_stoch() { @test "HBO" { # 13.3144s [[ -n $TRAVIS ]] && skip qp set_file hbo.ezfio - run -100.214099486337 1.e-3 100000 + run -100.213 1.e-3 100000 } @test "H2O" { # 11.3727s @@ -89,7 +89,7 @@ function run_stoch() { @test "SO" { # 13.4952s [[ -n $TRAVIS ]] && skip qp set_file so.ezfio - run -26.0176563764039 1.e-3 100000 + run -26.014 5.e-3 100000 } @test "H2S" { # 13.6745s @@ -119,7 +119,7 @@ function run_stoch() { @test "SiH3" { # 15.99s [[ -n $TRAVIS ]] && skip qp set_file sih3.ezfio - run -5.57241217753818 5.e-4 100000 + run -5.572 1.e-3 100000 } @test "CH4" { # 16.1612s @@ -153,7 +153,7 @@ function run_stoch() { [[ -n $TRAVIS ]] && skip qp set_file n2.ezfio qp set_mo_class --core="[1,2]" --act="[3-40]" --del="[41-60]" - run -109.287917088107 1.5e-3 100000 + run -109.288 2.e-3 100000 } @test "N2H4" { # 18.5006s From d2c40fc1cb3afa6c22a0ef05eb16f25abf8b631f Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 21 Apr 2022 13:42:10 +0200 Subject: [PATCH 19/19] Update test values --- src/fci/40.fci.bats | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index b8528e97..d890d586 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -42,7 +42,7 @@ function run_stoch() { [[ -n $TRAVIS ]] && skip qp set_file f2.ezfio qp set_frozen_core - run_stoch -199.304922384814 3.e-4 100000 + run_stoch -199.304922384814 3.e-3 100000 } @test "NH3" { # 10.6657s @@ -89,7 +89,7 @@ function run_stoch() { @test "SO" { # 13.4952s [[ -n $TRAVIS ]] && skip qp set_file so.ezfio - run -26.014 5.e-3 100000 + run -26.015 3.e-3 100000 } @test "H2S" { # 13.6745s @@ -146,7 +146,7 @@ function run_stoch() { [[ -n $TRAVIS ]] && skip qp set_file c2h2.ezfio qp set_mo_class --act="[1-30]" --del="[31-36]" - run -12.3685464085969 2.e-3 100000 + run -12.367 3.e-3 100000 } @test "N2" { # 18.0198s @@ -182,6 +182,6 @@ function run_stoch() { [[ -n $TRAVIS ]] && skip qp set_file hcn.ezfio qp set_mo_class --core="[1,2]" --act="[3-40]" --del="[41-55]" - run -93.0777619629755 1.e-3 100000 + run -93.078 2.e-3 100000 }