build_psi_SVD

This commit is contained in:
Abdallah Ammar 2021-05-26 09:34:22 +02:00
parent a93803151e
commit 12d8e84ddf
4 changed files with 29 additions and 73 deletions

View File

@ -43,7 +43,10 @@ spindeterminants
psi_coef_matrix_rows integer (spindeterminants_n_det)
psi_coef_matrix_columns integer (spindeterminants_n_det)
psi_coef_matrix_values double precision (spindeterminants_n_det,spindeterminants_n_states)
n_svd_coefs integer
psi_svd_alpha double precision (spindeterminants_n_det_alpha,spindeterminants_n_svd_coefs,spindeterminants_n_states)
psi_svd_beta double precision (spindeterminants_n_det_beta,spindeterminants_n_svd_coefs,spindeterminants_n_states)
psi_svd_coefs double precision (spindeterminants_n_svd_coefs,spindeterminants_n_states)
simulation
do_run integer

View File

@ -222,28 +222,3 @@ BEGIN_PROVIDER[ double precision, jast_elec_Simple_deriv_nucPar, (nucl_num) ]
END_PROVIDER
BEGIN_PROVIDER [ double precision , jast_elec_Simple_deriv_nucPar, (nucl_num) ]
implicit none
BEGIN_DOC
! Variation of the Jastrow factor with respect to nuclear parameters
END_DOC
integer :: i,j
double precision :: a, rij, tmp
do j=1,nucl_num
jast_elec_Simple_deriv_nucPar(j) = 0.d0
enddo
do j=1,nucl_num
a = jast_pen(j)
tmp = 0.d0
!DIR$ LOOP COUNT (100)
do i=1,elec_num
rij = nucl_elec_dist(i,j)
tmp += rij*rij/((1.d0+a*rij)*(1.d0+a*rij)*(1.d0+a*rij))
enddo
jast_elec_Simple_deriv_nucPar(j) = -2.d0*a*tmp
enddo
END_PROVIDER

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python3
import sys, os
QMCCHEM_PATH=os.environ["QMCCHEM_PATH"]
@ -12,6 +11,7 @@ import atexit
import scipy as sp
import scipy.optimize
from math import sqrt
from modif_powell_imp import my_fmin_powell
#------------------------------------------------------------------------------
def make_atom_map():
@ -136,8 +136,8 @@ def f(x):
# !!!
set_params_pen(x[:-1])
set_params_b(x[-1])
block_time_f = 30
total_time_f = 65
block_time_f = 45
total_time_f = 180
set_vmc_params(block_time_f, total_time_f)
# !!!
loc_err = 10.
@ -182,11 +182,11 @@ if __name__ == '__main__':
t0 = time.time()
# !!!
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ #
EZFIO_file = "/home/ammar/qp2/src/svdwf/h2o_optJast"
EZFIO_file = "/home/aammar/qp2/src/svdwf/h2o_optJast"
# PARAMETERS
thresh = 1.e-2
# maximum allowed number of function evaluations
N_fev = 4
N_fev = 50
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ #
# !!!
ezfio.set_file(EZFIO_file)
@ -208,15 +208,23 @@ if __name__ == '__main__':
x.append(b_par)
# !!!
i_fev = 1
bnds = [(0.001, 9.99) for _ in range(n_par)]
memo_energy = {'fmin': 100.}
opt = sp.optimize.minimize(f, x, method="Powell", bounds=bnds
, options= {'disp':True,
'ftol':0.2,
'xtol':0.2,
'maxfev':5} )
# !!!
#bnds = [(0.001, 9.99) for _ in range(n_par)]
#opt = sp.optimize.minimize(f, x, method="Newton-CG", bounds=bnds
# , options= {'disp':True} )
# !!!
x_min = [ (0.001) for _ in range(n_par) ]
x_max = [ (9.999) for _ in range(n_par) ]
opt = my_fmin_powell( f, x, x_min, x_max
, xtol = 0.02
, ftol = thresh
, maxfev = N_fev
, full_output = 1
, verbose = 1 )
# !!!
print(" x = "+str(opt))
set_params_pen(opt['x'])
#set_params_pen(opt['x'])
print(' number of function evaluations = {}'.format(i_fev))
# !!!
print(' memo_energy: {}'.format(memo_energy))

View File

@ -29,36 +29,6 @@ def get_energy():
# ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~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 ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ ! ~ !
def get_Ci_h_matrix_svd():
@ -79,7 +49,7 @@ def get_Ci_h_matrix_svd():
#print( line )
if( indc != iline ):
print('Error in reading Ci_h_matrix_svd')
stop
break
else:
#Ci_h_matrix_svd[indc-1] = float( line[2] )
irow = indc % n_svd
@ -117,7 +87,7 @@ def get_Ci_overlap_matrix_svd():
#print( line )
if( indc != iline ):
print('Error in reading Ci_overlap_matrix_svd')
stop
break
# !!!
# !!!
else:
@ -162,7 +132,7 @@ def get_Ci_h_matrix_postsvd():
#print( line )
if( indc != iline ):
print('Error in reading Ci_h_matrix_postsvd')
stop
break
else:
# !!!
kp = indc % n_svd
@ -212,7 +182,7 @@ def get_Ci_overlap_matrix_postsvd():
#print( line )
if( indc != iline ):
print('Error in reading Ci_overlap_matrix_postsvd')
stop
break
else:
# !!!
#kp = indc % n_svd
@ -413,7 +383,7 @@ if __name__ == '__main__':
t0 = time.time()
# !!!
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ #
EZFIO_file = "/home/aammar/qp2/src/svdwf/h2o_631g_J_art"
EZFIO_file = "/home/aammar/qp2/src/svdwf/h2o_631g_frez_nsvd10"
E_toadd = 9.194966082434476 #6.983610961797779
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ #
# !!!