1
0
mirror of https://gitlab.com/scemama/qp_plugins_scemama.git synced 2024-11-07 14:43:41 +01:00

Import trexio

This commit is contained in:
Anthony Scemama 2022-01-03 01:20:16 +01:00
parent f87df2b4e9
commit e789983821

View File

@ -120,7 +120,7 @@ def write_ezfio(trexio_filename, filename):
nucl_index = trexio.read_basis_nucleus_index(trexio_file) nucl_index = trexio.read_basis_nucleus_index(trexio_file)
ezfio.set_basis_shell_ang_mom(ang_mom) ezfio.set_basis_shell_ang_mom(ang_mom)
ezfio.set_basis_basis_nucleus_index(nucl_index) ezfio.set_basis_basis_nucleus_index([ x+1 for x in nucl_index ])
exponent = trexio.read_basis_exponent(trexio_file) exponent = trexio.read_basis_exponent(trexio_file)
coefficient = trexio.read_basis_coefficient(trexio_file) coefficient = trexio.read_basis_coefficient(trexio_file)
@ -131,29 +131,34 @@ def write_ezfio(trexio_filename, filename):
shell_index = trexio.read_basis_shell_index(trexio_file) shell_index = trexio.read_basis_shell_index(trexio_file)
ao_shell = trexio.read_ao_shell(trexio_file) ao_shell = trexio.read_ao_shell(trexio_file)
shell_prim_num = []
nucl_shell_num = [] nucl_shell_num = []
prev = None prev = None
count = 0
n = 0
m = 0 m = 0
for i in ao_shell: for i in ao_shell:
count += 1
if i != prev: if i != prev:
n += 1
m += 1 m += 1
if prev is None or nucl_index[i] != nucl_index[prev]: if prev is None or nucl_index[i] != nucl_index[prev]:
nucl_shell_num.append(m) nucl_shell_num.append(m)
m = 0 m = 0
shell_prim_num.append(count)
count = 0
prev = i prev = i
assert (len(nucl_shell_num) == nucl_num) assert (len(nucl_shell_num) == nucl_num)
shell_prim_num = []
prev = shell_index[0]
count = 0
for i in shell_index:
if i != prev:
shell_prim_num.append(count)
count = 0
count += 1
prev = i
shell_prim_num.append(count)
print(shell_prim_num)
assert (len(shell_prim_num) == shell_num) assert (len(shell_prim_num) == shell_num)
ezfio.set_basis_shell_prim_num(shell_prim_num) ezfio.set_basis_shell_prim_num(shell_prim_num)
ezfio.set_basis_shell_index(shell_index) ezfio.set_basis_shell_index([x+1 for x in shell_index])
ezfio.set_basis_nucleus_shell_num(nucl_shell_num) ezfio.set_basis_nucleus_shell_num(nucl_shell_num)
@ -169,7 +174,7 @@ def write_ezfio(trexio_filename, filename):
ao_num = trexio.read_ao_num(trexio_file) ao_num = trexio.read_ao_num(trexio_file)
ezfio.set_ao_basis_ao_num(ao_num) ezfio.set_ao_basis_ao_num(ao_num)
at = [ nucl_index[i] for i in ao_shell ] at = [ nucl_index[i]+1 for i in ao_shell ]
ezfio.set_ao_basis_ao_nucl(at) ezfio.set_ao_basis_ao_nucl(at)
num_prim0 = [ 0 for i in range(shell_num) ] num_prim0 = [ 0 for i in range(shell_num) ]
@ -203,7 +208,6 @@ def write_ezfio(trexio_filename, filename):
exponent.append(expo[i]) exponent.append(expo[i])
num_prim.append(num_prim0[i]) num_prim.append(num_prim0[i])
print (len(coefficient) , ao_num, len(ao_shell))
assert (len(coefficient) == ao_num) assert (len(coefficient) == ao_num)
ezfio.set_ao_basis_ao_power(power_x + power_y + power_z) ezfio.set_ao_basis_ao_power(power_x + power_y + power_z)
ezfio.set_ao_basis_ao_prim_num(num_prim) ezfio.set_ao_basis_ao_prim_num(num_prim)
@ -243,17 +247,26 @@ def write_ezfio(trexio_filename, filename):
label = trexio.read_mo_type(trexio_file) label = trexio.read_mo_type(trexio_file)
ezfio.set_mo_basis_mo_label(label) ezfio.set_mo_basis_mo_label(label)
clss = trexio.read_mo_class(trexio_file) try:
core = [ i for i in clss if i.lower() == "core" ] clss = trexio.read_mo_class(trexio_file)
inactive = [ i for i in clss if i.lower() == "inactive" ] core = [ i for i in clss if i.lower() == "core" ]
active = [ i for i in clss if i.lower() == "active" ] inactive = [ i for i in clss if i.lower() == "inactive" ]
virtual = [ i for i in clss if i.lower() == "virtual" ] active = [ i for i in clss if i.lower() == "active" ]
deleted = [ i for i in clss if i.lower() == "deleted" ] virtual = [ i for i in clss if i.lower() == "virtual" ]
deleted = [ i for i in clss if i.lower() == "deleted" ]
except trexio.Error:
pass
MoMatrix = trexio.read_mo_coefficient(trexio_file) MoMatrix = trexio.read_mo_coefficient(trexio_file)
ezfio.set_mo_basis_mo_num(mo_num) ezfio.set_mo_basis_mo_num(mo_num)
ezfio.set_mo_basis_mo_coef(MoMatrix) ezfio.set_mo_basis_mo_coef(MoMatrix)
mo_occ = [ 0. for i in range(mo_num) ]
for i in range(num_alpha):
mo_occ[i] += 1.
for i in range(num_beta):
mo_occ[i] += 1.
ezfio.set_mo_basis_mo_occ(mo_occ)
print("OK") print("OK")
@ -282,7 +295,7 @@ def write_ezfio(trexio_filename, filename):
center = nucleus_index[i] center = nucleus_index[i]
if center != prev_center: if center != prev_center:
ecp[center] = { "lmax": max_ang_mom_plus_1[center], ecp[center] = { "lmax": max_ang_mom_plus_1[center],
"zcore": zcore[center], "zcore": z_core[center],
"contr": {} } "contr": {} }
for i in range(max_ang_mom_plus_1[center]+1): for i in range(max_ang_mom_plus_1[center]+1):
ecp[center]["contr"][i] = [] ecp[center]["contr"][i] = []
@ -295,13 +308,14 @@ def write_ezfio(trexio_filename, filename):
kmax = 0 kmax = 0
klocmax = 0 klocmax = 0
for center in ecp: for center in ecp:
ecp_nl [center] = {}
for k in ecp[center]["contr"]: for k in ecp[center]["contr"]:
if k == ecp[center]["lmax"]: if k == ecp[center]["lmax"]:
ecp_loc[center] = ecp[center]["contr"][k] ecp_loc[center] = ecp[center]["contr"][k]
klocmax = max(len(ecp_loc[center], klocmax)) klocmax = max(len(ecp_loc[center]), klocmax)
else: else:
ecp_nl [center][k] = ecp[center]["contr"][k] ecp_nl [center][k] = ecp[center]["contr"][k]
kmax = max(len(ecp_nl [center][k], kmax)) kmax = max(len(ecp_nl [center][k]), kmax)
ezfio.set_pseudo_pseudo_klocmax(klocmax) ezfio.set_pseudo_pseudo_klocmax(klocmax)
ezfio.set_pseudo_pseudo_kmax(kmax) ezfio.set_pseudo_pseudo_kmax(kmax)
@ -335,9 +349,7 @@ def write_ezfio(trexio_filename, filename):
ezfio.set_pseudo_pseudo_v_kl(pseudo_v_kl) ezfio.set_pseudo_pseudo_v_kl(pseudo_v_kl)
ezfio.set_pseudo_pseudo_dz_kl(pseudo_dz_kl) ezfio.set_pseudo_pseudo_dz_kl(pseudo_dz_kl)
charge = [ x-y for x,y in zip(charge,z_core) ]
for i in range(nucl_num):
charge[i] -= nucl_charge_remove[i]
ezfio.set_nuclei_nucl_charge(charge) ezfio.set_nuclei_nucl_charge(charge)
print("OK") print("OK")