mirror of
https://gitlab.com/scemama/qp_plugins_scemama.git
synced 2024-11-07 22:53:42 +01:00
Python3
This commit is contained in:
parent
e0e053b72f
commit
1568f6cd20
@ -2,7 +2,7 @@
|
|||||||
#
|
#
|
||||||
# Modified from the QMCPACK interface developed by @tapplencourt and @abenali
|
# Modified from the QMCPACK interface developed by @tapplencourt and @abenali
|
||||||
|
|
||||||
print "#QP -> CHAMP"
|
print("#QP -> CHAMP")
|
||||||
|
|
||||||
# ___
|
# ___
|
||||||
# | ._ o _|_
|
# | ._ o _|_
|
||||||
@ -19,7 +19,7 @@ ezfio.set_file(ezfio_path)
|
|||||||
|
|
||||||
do_pseudo = ezfio.get_pseudo_do_pseudo()
|
do_pseudo = ezfio.get_pseudo_do_pseudo()
|
||||||
if do_pseudo:
|
if do_pseudo:
|
||||||
print "do_pseudo True"
|
print("do_pseudo True")
|
||||||
from qp_path import QP_ROOT
|
from qp_path import QP_ROOT
|
||||||
|
|
||||||
l_ele_path = os.path.join(QP_ROOT,"data","list_element.txt")
|
l_ele_path = os.path.join(QP_ROOT,"data","list_element.txt")
|
||||||
@ -28,9 +28,9 @@ if do_pseudo:
|
|||||||
|
|
||||||
l_element_raw = data_raw.split("\n")
|
l_element_raw = data_raw.split("\n")
|
||||||
l_element = [element_raw.split() for element_raw in l_element_raw]
|
l_element = [element_raw.split() for element_raw in l_element_raw]
|
||||||
d_z = dict((abr, z) for (z, abr, ele, _) in filter(lambda x: x != [], l_element) )
|
d_z = dict((abr, z) for (z, abr, ele, _) in [x for x in l_element if x != []] )
|
||||||
else:
|
else:
|
||||||
print "do_pseudo False"
|
print("do_pseudo False")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
n_det = ezfio.get_determinants_n_det()
|
n_det = ezfio.get_determinants_n_det()
|
||||||
@ -38,9 +38,9 @@ except IOError:
|
|||||||
n_det = 1
|
n_det = 1
|
||||||
|
|
||||||
if n_det == 1:
|
if n_det == 1:
|
||||||
print "multi_det False"
|
print("multi_det False")
|
||||||
else:
|
else:
|
||||||
print "multi_det True"
|
print("multi_det True")
|
||||||
|
|
||||||
#
|
#
|
||||||
# |\/| o _ _
|
# |\/| o _ _
|
||||||
@ -52,17 +52,17 @@ def list_to_string(l):
|
|||||||
|
|
||||||
|
|
||||||
ao_num = ezfio.get_ao_basis_ao_num()
|
ao_num = ezfio.get_ao_basis_ao_num()
|
||||||
print "ao_num", ao_num
|
print("ao_num", ao_num)
|
||||||
|
|
||||||
mo_num = ezfio.get_mo_basis_mo_num()
|
mo_num = ezfio.get_mo_basis_mo_num()
|
||||||
print "mo_num", mo_num
|
print("mo_num", mo_num)
|
||||||
|
|
||||||
alpha = ezfio.get_electrons_elec_alpha_num()
|
alpha = ezfio.get_electrons_elec_alpha_num()
|
||||||
beta = ezfio.get_electrons_elec_beta_num()
|
beta = ezfio.get_electrons_elec_beta_num()
|
||||||
print "elec_alpha_num", alpha
|
print("elec_alpha_num", alpha)
|
||||||
print "elec_beta_num", beta
|
print("elec_beta_num", beta)
|
||||||
print "elec_tot_num", alpha + beta
|
print("elec_tot_num", alpha + beta)
|
||||||
print "spin_multiplicity", (alpha - beta) + 1
|
print("spin_multiplicity", (alpha - beta) + 1)
|
||||||
|
|
||||||
l_label = ezfio.get_nuclei_nucl_label()
|
l_label = ezfio.get_nuclei_nucl_label()
|
||||||
l_charge = ezfio.get_nuclei_nucl_charge()
|
l_charge = ezfio.get_nuclei_nucl_charge()
|
||||||
@ -70,19 +70,19 @@ l_coord = ezfio.get_nuclei_nucl_coord()
|
|||||||
|
|
||||||
l_coord_str = [list_to_string(i) for i in zip(*l_coord)]
|
l_coord_str = [list_to_string(i) for i in zip(*l_coord)]
|
||||||
|
|
||||||
print "nucl_num", len(l_label)
|
print("nucl_num", len(l_label))
|
||||||
|
|
||||||
# _
|
# _
|
||||||
# / _ _ ._ _|
|
# / _ _ ._ _|
|
||||||
# \_ (_) (_) | (_|
|
# \_ (_) (_) | (_|
|
||||||
#
|
#
|
||||||
print "Atomic coord in Bohr"
|
print("Atomic coord in Bohr")
|
||||||
|
|
||||||
for i, t in enumerate(zip(l_label, l_charge, l_coord_str)):
|
for i, t in enumerate(zip(l_label, l_charge, l_coord_str)):
|
||||||
t_1 = d_z[t[0]] if do_pseudo else t[1]
|
t_1 = d_z[t[0]] if do_pseudo else t[1]
|
||||||
|
|
||||||
t_new = [t[0],t_1,t[2]]
|
t_new = [t[0],t_1,t[2]]
|
||||||
print list_to_string(t_new)
|
print(list_to_string(t_new))
|
||||||
|
|
||||||
#
|
#
|
||||||
# Call externet process to get the sysmetry
|
# Call externet process to get the sysmetry
|
||||||
@ -118,9 +118,9 @@ for i, (a,b) in enumerate(zip(l_label,l_basis_raw)):
|
|||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
print "BEGIN_BASIS_SET\n"
|
print("BEGIN_BASIS_SET\n")
|
||||||
print "\n\n".join(l_basis_clean)
|
print("\n\n".join(l_basis_clean))
|
||||||
print "END_BASIS_SET"
|
print("END_BASIS_SET")
|
||||||
|
|
||||||
# _
|
# _
|
||||||
# |\/| / \ _
|
# |\/| / \ _
|
||||||
@ -138,7 +138,7 @@ d_gms_order ={ 0:["s"],
|
|||||||
4:[ "xxxx", "yyyy", "zzzz", "xxxy", "xxxz", "yyyx", "yyyz", "zzzx", "zzzy", "xxyy", "xxzz", "yyzz", "xxyz", "yyxz", "zzxy"] }
|
4:[ "xxxx", "yyyy", "zzzz", "xxxy", "xxxz", "yyyx", "yyyz", "zzzx", "zzzy", "xxyy", "xxzz", "yyzz", "xxyz", "yyxz", "zzxy"] }
|
||||||
|
|
||||||
def compare_gamess_style(item1, item2):
|
def compare_gamess_style(item1, item2):
|
||||||
n1,n2 = map(len,(item1,item2))
|
n1,n2 = list(map(len,(item1,item2)))
|
||||||
assert (n1 == n2)
|
assert (n1 == n2)
|
||||||
try:
|
try:
|
||||||
l = d_gms_order[n1]
|
l = d_gms_order[n1]
|
||||||
@ -186,7 +186,7 @@ def get_nb_permutation(str_):
|
|||||||
|
|
||||||
def order_l_l_sym(l_l_sym):
|
def order_l_l_sym(l_l_sym):
|
||||||
n = 1
|
n = 1
|
||||||
iter_ = range(len(l_l_sym))
|
iter_ = list(range(len(l_l_sym)))
|
||||||
for i in iter_:
|
for i in iter_:
|
||||||
if n != 1:
|
if n != 1:
|
||||||
n += -1
|
n += -1
|
||||||
@ -237,21 +237,21 @@ def order_phase(mo_coef):
|
|||||||
def chunked(l, chunks_size):
|
def chunked(l, chunks_size):
|
||||||
l_block = []
|
l_block = []
|
||||||
for i in l:
|
for i in l:
|
||||||
chunks = [i[x:x + chunks_size] for x in xrange(0, len(i), chunks_size)]
|
chunks = [i[x:x + chunks_size] for x in range(0, len(i), chunks_size)]
|
||||||
l_block.append(chunks)
|
l_block.append(chunks)
|
||||||
return l_block
|
return l_block
|
||||||
|
|
||||||
|
|
||||||
def print_mo_coef(mo_coef_block, l_l_sym):
|
def print_mo_coef(mo_coef_block, l_l_sym):
|
||||||
print ""
|
print("")
|
||||||
print "BEGIN_MO"
|
print("BEGIN_MO")
|
||||||
print ""
|
print("")
|
||||||
len_block_curent = 0
|
len_block_curent = 0
|
||||||
nb_block = len(mo_coef_block[0])
|
nb_block = len(mo_coef_block[0])
|
||||||
for i_block in range(0, nb_block):
|
for i_block in range(0, nb_block):
|
||||||
a = [i[i_block] for i in mo_coef_block]
|
a = [i[i_block] for i in mo_coef_block]
|
||||||
r_ = range(len_block_curent, len_block_curent + len(a[0]))
|
r_ = list(range(len_block_curent, len_block_curent + len(a[0])))
|
||||||
print " ".join([str(i + 1) for i in r_])
|
print(" ".join([str(i + 1) for i in r_]))
|
||||||
|
|
||||||
len_block_curent += len(a[0])
|
len_block_curent += len(a[0])
|
||||||
|
|
||||||
@ -260,17 +260,17 @@ def print_mo_coef(mo_coef_block, l_l_sym):
|
|||||||
i_a = int(l[1]) - 1
|
i_a = int(l[1]) - 1
|
||||||
sym = l[2]
|
sym = l[2]
|
||||||
|
|
||||||
print l_label[i_a], sym, " ".join('%20.15e'%i
|
print(l_label[i_a], sym, " ".join('%20.15e'%i
|
||||||
for i in a[i])
|
for i in a[i]))
|
||||||
|
|
||||||
if i_block != nb_block - 1:
|
if i_block != nb_block - 1:
|
||||||
print ""
|
print("")
|
||||||
else:
|
else:
|
||||||
print "END_MO"
|
print("END_MO")
|
||||||
|
|
||||||
|
|
||||||
mo_coef = ezfio.get_mo_basis_mo_coef()
|
mo_coef = ezfio.get_mo_basis_mo_coef()
|
||||||
mo_coef_transp = zip(*mo_coef)
|
mo_coef_transp = list(zip(*mo_coef))
|
||||||
mo_coef_block = chunked(mo_coef_transp, 4)
|
mo_coef_block = chunked(mo_coef_transp, 4)
|
||||||
print_mo_coef(mo_coef_block, l_l_sym_ordered)
|
print_mo_coef(mo_coef_block, l_l_sym_ordered)
|
||||||
|
|
||||||
@ -279,8 +279,8 @@ print_mo_coef(mo_coef_block, l_l_sym_ordered)
|
|||||||
# | _> (/_ |_| (_| (_)
|
# | _> (/_ |_| (_| (_)
|
||||||
#
|
#
|
||||||
if do_pseudo:
|
if do_pseudo:
|
||||||
print ""
|
print("")
|
||||||
print "BEGIN_PSEUDO"
|
print("BEGIN_PSEUDO")
|
||||||
klocmax = ezfio.get_pseudo_pseudo_klocmax()
|
klocmax = ezfio.get_pseudo_pseudo_klocmax()
|
||||||
kmax = ezfio.get_pseudo_pseudo_kmax()
|
kmax = ezfio.get_pseudo_pseudo_kmax()
|
||||||
lmax = ezfio.get_pseudo_pseudo_lmax()
|
lmax = ezfio.get_pseudo_pseudo_lmax()
|
||||||
@ -318,17 +318,17 @@ if do_pseudo:
|
|||||||
l_str.append(l_dump)
|
l_str.append(l_dump)
|
||||||
|
|
||||||
str_ = "PARAMETERS FOR {0} ON ATOM {1} WITH ZCORE {2} AND LMAX {3} ARE"
|
str_ = "PARAMETERS FOR {0} ON ATOM {1} WITH ZCORE {2} AND LMAX {3} ARE"
|
||||||
print str_.format(a, i + 1, int(d_z[a])-int(l_charge[i]), int(len(l_str) - 1))
|
print(str_.format(a, i + 1, int(d_z[a])-int(l_charge[i]), int(len(l_str) - 1)))
|
||||||
|
|
||||||
for i, l in enumerate(l_str):
|
for i, l in enumerate(l_str):
|
||||||
str_ = "FOR L= {0} COEFF N ZETA"
|
str_ = "FOR L= {0} COEFF N ZETA"
|
||||||
print str_.format(int(len(l_str) - i - 1))
|
print(str_.format(int(len(l_str) - i - 1)))
|
||||||
for ii, ll in enumerate(l):
|
for ii, ll in enumerate(l):
|
||||||
print " ", ii + 1, ll
|
print(" ", ii + 1, ll)
|
||||||
|
|
||||||
str_ = "THE ECP RUN REMOVES {0} CORE ELECTRONS, AND THE SAME NUMBER OF PROTONS."
|
str_ = "THE ECP RUN REMOVES {0} CORE ELECTRONS, AND THE SAME NUMBER OF PROTONS."
|
||||||
print str_.format(sum([int(d_z[a])-int(l_charge[i]) for i,a in enumerate(l_label)]))
|
print(str_.format(sum([int(d_z[a])-int(l_charge[i]) for i,a in enumerate(l_label)])))
|
||||||
print "END_PSEUDO"
|
print("END_PSEUDO")
|
||||||
|
|
||||||
# _
|
# _
|
||||||
# | \ _ _|_
|
# | \ _ _|_
|
||||||
@ -343,12 +343,12 @@ bit_kind = ezfio.get_determinants_bit_kind()
|
|||||||
|
|
||||||
nexcitedstate = ezfio.get_determinants_n_states()
|
nexcitedstate = ezfio.get_determinants_n_states()
|
||||||
|
|
||||||
print ""
|
print("")
|
||||||
print "BEGIN_DET"
|
print("BEGIN_DET")
|
||||||
print ""
|
print("")
|
||||||
print "mo_num", mo_num
|
print("mo_num", mo_num)
|
||||||
print "det_num", n_det
|
print("det_num", n_det)
|
||||||
print ""
|
print("")
|
||||||
|
|
||||||
if "QP_STATE" in os.environ:
|
if "QP_STATE" in os.environ:
|
||||||
state = int(os.environ["QP_STATE"])-1
|
state = int(os.environ["QP_STATE"])-1
|
||||||
@ -372,13 +372,13 @@ MultiDetAlpha = []
|
|||||||
MultiDetBeta = []
|
MultiDetBeta = []
|
||||||
for coef, (det_a, det_b) in zip(psi_coef_small, psi_det):
|
for coef, (det_a, det_b) in zip(psi_coef_small, psi_det):
|
||||||
|
|
||||||
print coef
|
print(coef)
|
||||||
MyDetA=decode(det_a)
|
MyDetA=decode(det_a)
|
||||||
MyDetB=decode(det_b)
|
MyDetB=decode(det_b)
|
||||||
print MyDetA
|
print(MyDetA)
|
||||||
print MyDetB
|
print(MyDetB)
|
||||||
print ''
|
print('')
|
||||||
MultiDetAlpha.append( det_a )
|
MultiDetAlpha.append( det_a )
|
||||||
MultiDetBeta.append( det_b )
|
MultiDetBeta.append( det_b )
|
||||||
print "END_DET"
|
print("END_DET")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user