10
1
mirror of https://gitlab.com/scemama/qmcchem.git synced 2024-12-21 11:53:30 +01:00

Jastrow opt

This commit is contained in:
Anthony Scemama 2021-07-23 23:35:55 +02:00
parent 3815c4ef35
commit f05933e4f4

View File

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