Jastrow opt

This commit is contained in:
Anthony Scemama 2021-07-23 23:35:55 +02:00
parent 3815c4ef35
commit f05933e4f4
1 changed files with 15 additions and 5 deletions

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python3 -u
import scipy as sp
import scipy.optimize
@ -17,7 +17,7 @@ from ezfio import ezfio
# PARAMETERS
thresh = 1.e-2
block_time = 20
block_time = 6
def main():
if len(sys.argv) != 2:
@ -45,6 +45,9 @@ def main():
atom_map = make_atom_map()
def get_params_b():
return ezfio.jastrow_jast_b_up_dn
def get_params_pen():
d = ezfio.jastrow_jast_pen
return np.array([d[m[0]] for m in atom_map])
@ -72,6 +75,11 @@ def main():
return None, None
def set_params_b(x):
x = np.abs(x)
ezfio.set_jastrow_jast_b_up_up(x)
ezfio.set_jastrow_jast_b_up_dn(x)
def set_params_pen(x):
x = np.abs(x)
y=list(ezfio.jastrow_jast_pen)
@ -109,7 +117,8 @@ def main():
h = str(x)
if h in memo_energy:
return memo_energy[h]
set_params_pen(x)
set_params_b(x[0])
set_params_pen(x[1:])
set_vmc_params()
pid = os.fork()
if pid == 0:
@ -150,14 +159,15 @@ def main():
def run():
x = get_params_pen()
x = np.array([ get_params_b() ] + list(get_params_pen()))
if sum(x) == 0.:
jast_a_up_dn = ezfio.jastrow_jast_a_up_dn
x += jast_a_up_dn
opt = sp.optimize.minimize(f,x,method="Powell",
options= {'disp':True, 'ftol':thresh,'xtol':0.02})
print("x = "+str(opt))
set_params_pen(opt['x'])
set_params_b(opt['x'][0])
set_params_pen(opt['x'][1:])
run()