10
1
mirror of https://github.com/pfloos/quack synced 2025-05-06 07:05:33 +02:00

skipping cap-calculation, if no cap data is provided

This commit is contained in:
lburth 2025-05-02 16:02:32 +02:00
parent 9063eb7a77
commit 34e872d0cc

View File

@ -191,49 +191,53 @@ def create_psi4_basis(basis_dict):
# CAP definition # CAP definition
if use_cap: if use_cap:
f = open(working_dir+'/cap_data/'+args.xyz, 'r') try:
lines = f.read().splitlines() f = open(working_dir+'/cap_data/'+args.xyz, 'r')
line = lines[1] lines = f.read().splitlines()
tmp = line.split() line = lines[1]
onset_x = float(tmp[0]) tmp = line.split()
onset_y = float(tmp[1]) onset_x = float(tmp[0])
onset_z = float(tmp[2]) onset_y = float(tmp[1])
eta_opt = float(tmp[3]) onset_z = float(tmp[2])
f.close() eta_opt = float(tmp[3])
f = open(working_dir+'/input/eta_opt.dat', 'w')
f.write(" {} ".format(str(eta_opt)))
f.close()
print(f"CAP eta = {eta_opt}")
# xyz file
with open(working_dir + "/mol/" + xyz, "r") as f:
lines = f.readlines()
f.close() f.close()
num_atoms = int(lines[0].strip()) f = open(working_dir+'/input/eta_opt.dat', 'w')
atoms = [line.strip() for line in lines[2:2+num_atoms]] f.write(" {} ".format(str(eta_opt)))
if unit == 'Bohr': f.close()
bohr_coordinates = 'true' print(f"CAP eta = {eta_opt}")
else:
bohr_coordinates = 'false' # xyz file
sys_dict = { with open(working_dir + "/mol/" + xyz, "r") as f:
"molecule": "inline", lines = f.readlines()
"geometry": "\n".join(atoms), # XYZ format as a string f.close()
"basis_file": create_psi4_basis(basis_dict), num_atoms = int(lines[0].strip())
"bohr_coordinates": bohr_coordinates atoms = [line.strip() for line in lines[2:2+num_atoms]]
} if unit == 'Bohr':
cap_system = pyopencap.System(sys_dict) bohr_coordinates = 'true'
if not(cap_system.check_overlap_mat(ovlp, "pyscf")): else:
raise Exception( bohr_coordinates = 'false'
"Provided cap basis does not match to the pyscf basis.") sys_dict = {
cap_dict = {"cap_type": "box", "molecule": "inline",
"cap_x": onset_x, "geometry": "\n".join(atoms), # XYZ format as a string
"cap_y": onset_y, "basis_file": create_psi4_basis(basis_dict),
"cap_z": onset_z, "bohr_coordinates": bohr_coordinates
"Radial_precision": "16", }
"angular_points": "590", cap_system = pyopencap.System(sys_dict)
"thresh": 15} if not(cap_system.check_overlap_mat(ovlp, "pyscf")):
pc = pyopencap.CAP(cap_system, cap_dict, norb) raise Exception(
cap_ao = pc.get_ao_cap(ordering="pyscf") "Provided cap basis does not match to the pyscf basis.")
cap_dict = {"cap_type": "box",
"cap_x": onset_x,
"cap_y": onset_y,
"cap_z": onset_z,
"Radial_precision": "16",
"angular_points": "590",
"thresh": 15}
pc = pyopencap.CAP(cap_system, cap_dict, norb)
cap_ao = pc.get_ao_cap(ordering="pyscf")
except Exception:
print("No CAP-data provided for this molecule. Skipping CAP calculation...")
use_cap = False
def write_matrix_to_file(matrix, size, file, cutoff=1e-15): def write_matrix_to_file(matrix, size, file, cutoff=1e-15):
f = open(file, 'w') f = open(file, 'w')