10
1
mirror of https://gitlab.com/scemama/qmcchem.git synced 2024-06-13 16:55:17 +02:00

Jastrow opt

This commit is contained in:
Anthony Scemama 2021-12-01 11:14:37 +01:00
parent 8471cb050a
commit 2e5256bc63

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python3 -u
#!/usr/bin/env python3
import scipy as sp
import scipy.optimize
@ -9,6 +9,8 @@ import time
import subprocess
from math import sqrt
QMCCHEM_PATH=os.environ["QMCCHEM_PATH"]
sys.path.insert(0,QMCCHEM_PATH+"/EZFIO/Python/")
@ -54,6 +56,7 @@ def main():
for m in atom_map:
print(m[0])
print (d[m[0]])
sys.stdout.flush()
return np.array([d[m[0]] for m in atom_map])
@ -118,6 +121,7 @@ def main():
memo_energy = {'fmin': 100000000.}
def f(x):
print ("x = %s"%str(x))
sys.stdout.flush()
h = str(x)
if h in memo_energy:
return memo_energy[h]
@ -144,6 +148,7 @@ def main():
energy = e #+ variance
err = e_err #sqrt(e_err*e_err+v_err*v_err)
print(" %f %f %f %f %f %f"%(e, e_err, variance, v_err, energy, err))
sys.stdout.flush()
if (energy-2.*err) > memo_energy['fmin']+thresh:
local_thresh = 10.*thresh
elif (energy+2.*err) < memo_energy['fmin']-thresh:
@ -154,6 +159,7 @@ def main():
os.kill(pid,0)
except OSError:
print("---")
sys.stdout.flush()
break
stop_qmc()
os.wait()
@ -170,6 +176,7 @@ def main():
opt = sp.optimize.minimize(f,x,method="Powell",
options= {'disp':True, 'ftol':thresh,'xtol':0.02})
print("x = "+str(opt))
sys.stdout.flush()
set_params_b(opt['x'][0])
set_params_pen(opt['x'][1:])