2021-07-31 03:19:16 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import numpy as np
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
|
|
|
|
QP_PATH=os.environ["QP_ROOT"]+"/external/ezfio/Python/"
|
|
|
|
|
|
|
|
sys.path.insert(0,QP_PATH)
|
|
|
|
|
|
|
|
from ezfio import ezfio
|
|
|
|
|
|
|
|
def read_hamiltonian(inp):
|
2022-02-04 12:07:03 +01:00
|
|
|
# text = subprocess.run(["qmcchem", "result", inp], capture_output=True).stdout
|
|
|
|
text = subprocess.run(["cat", "OUT"], capture_output=True).stdout
|
2021-07-31 03:19:16 +02:00
|
|
|
inside = None
|
|
|
|
h = []
|
|
|
|
s = []
|
|
|
|
norm = None
|
|
|
|
for line in text.splitlines():
|
2022-02-04 12:07:03 +01:00
|
|
|
line = line.decode("utf-8")
|
|
|
|
if line == "":
|
|
|
|
continue
|
2021-07-31 03:19:16 +02:00
|
|
|
if "Psi_norm :" in line:
|
2022-02-04 12:07:03 +01:00
|
|
|
norm = float(line.split()[2])
|
2021-07-31 03:19:16 +02:00
|
|
|
if "]" in line:
|
|
|
|
inside = None
|
|
|
|
if inside == "H":
|
|
|
|
data = line.split()
|
2022-02-04 12:07:03 +01:00
|
|
|
# h.append(float(data[2])) #ave
|
|
|
|
h.append(max(float(data[2]) - float(data[4]),0.)) #diff
|
|
|
|
# if float(data[2]) - float(data[4])>0.: h.append(float(data[2]))
|
|
|
|
# else: h.append(0.)
|
2021-07-31 03:19:16 +02:00
|
|
|
elif "Ci_dress" in line:
|
|
|
|
inside = "H"
|
|
|
|
h = np.array(h)/norm
|
|
|
|
|
|
|
|
return h
|
|
|
|
|
|
|
|
|
|
|
|
h = read_hamiltonian(sys.argv[1])
|
|
|
|
ezfio.set_file(sys.argv[1])
|
|
|
|
ezfio.set_dmc_dress_dmc_delta_h(h)
|
|
|
|
print(h)
|
2022-02-04 12:07:03 +01:00
|
|
|
|