1
0
mirror of https://gitlab.com/scemama/qp_plugins_scemama.git synced 2024-11-07 14:43:41 +01:00
This commit is contained in:
Anthony Scemama 2020-05-13 00:09:00 +02:00
parent e0e053b72f
commit 1568f6cd20

View File

@ -2,11 +2,11 @@
#
# Modified from the QMCPACK interface developed by @tapplencourt and @abenali
print "#QP -> CHAMP"
print("#QP -> CHAMP")
# ___
# | ._ o _|_
# _|_ | | | |_
# ___
# | ._ o _|_
# _|_ | | | |_
#
from ezfio import ezfio
@ -19,7 +19,7 @@ ezfio.set_file(ezfio_path)
do_pseudo = ezfio.get_pseudo_do_pseudo()
if do_pseudo:
print "do_pseudo True"
print("do_pseudo True")
from qp_path import QP_ROOT
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 = [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:
print "do_pseudo False"
print("do_pseudo False")
try:
n_det = ezfio.get_determinants_n_det()
@ -38,13 +38,13 @@ except IOError:
n_det = 1
if n_det == 1:
print "multi_det False"
print("multi_det False")
else:
print "multi_det True"
print("multi_det True")
#
# |\/| o _ _
# | | | _> (_
#
# |\/| o _ _
# | | | _> (_
#
def list_to_string(l):
@ -52,17 +52,17 @@ def list_to_string(l):
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()
print "mo_num", mo_num
print("mo_num", mo_num)
alpha = ezfio.get_electrons_elec_alpha_num()
beta = ezfio.get_electrons_elec_beta_num()
print "elec_alpha_num", alpha
print "elec_beta_num", beta
print "elec_tot_num", alpha + beta
print "spin_multiplicity", (alpha - beta) + 1
print("elec_alpha_num", alpha)
print("elec_beta_num", beta)
print("elec_tot_num", alpha + beta)
print("spin_multiplicity", (alpha - beta) + 1)
l_label = ezfio.get_nuclei_nucl_label()
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)]
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)):
t_1 = d_z[t[0]] if do_pseudo else t[1]
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
@ -95,9 +95,9 @@ out, err = process.communicate()
basis_raw, sym_raw, _ = out.split("\n\n\n")
# _ __
# |_) _. _ o _ (_ _ _|_
# |_) (_| _> | _> __) (/_ |_
# _ __
# |_) _. _ o _ (_ _ _|_
# |_) (_| _> | _> __) (/_ |_
#
basis_without_header = "\n".join(basis_raw.split("\n")[11:])
@ -118,13 +118,13 @@ for i, (a,b) in enumerate(zip(l_label,l_basis_raw)):
else:
continue
print "BEGIN_BASIS_SET\n"
print "\n\n".join(l_basis_clean)
print "END_BASIS_SET"
print("BEGIN_BASIS_SET\n")
print("\n\n".join(l_basis_clean))
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"] }
def compare_gamess_style(item1, item2):
n1,n2 = map(len,(item1,item2))
n1,n2 = list(map(len,(item1,item2)))
assert (n1 == n2)
try:
l = d_gms_order[n1]
@ -186,11 +186,11 @@ def get_nb_permutation(str_):
def order_l_l_sym(l_l_sym):
n = 1
iter_ = range(len(l_l_sym))
iter_ = list(range(len(l_l_sym)))
for i in iter_:
if n != 1:
n += -1
continue
continue
l = l_l_sym[i]
n = get_nb_permutation(l[2])
@ -237,21 +237,21 @@ def order_phase(mo_coef):
def chunked(l, chunks_size):
l_block = []
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)
return l_block
def print_mo_coef(mo_coef_block, l_l_sym):
print ""
print "BEGIN_MO"
print ""
print("")
print("BEGIN_MO")
print("")
len_block_curent = 0
nb_block = len(mo_coef_block[0])
for i_block in range(0, nb_block):
a = [i[i_block] for i in mo_coef_block]
r_ = range(len_block_curent, len_block_curent + len(a[0]))
print " ".join([str(i + 1) for i in r_])
r_ = list(range(len_block_curent, len_block_curent + len(a[0])))
print(" ".join([str(i + 1) for i in r_]))
len_block_curent += len(a[0])
@ -260,27 +260,27 @@ def print_mo_coef(mo_coef_block, l_l_sym):
i_a = int(l[1]) - 1
sym = l[2]
print l_label[i_a], sym, " ".join('%20.15e'%i
for i in a[i])
print(l_label[i_a], sym, " ".join('%20.15e'%i
for i in a[i]))
if i_block != nb_block - 1:
print ""
print("")
else:
print "END_MO"
print("END_MO")
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)
print_mo_coef(mo_coef_block, l_l_sym_ordered)
# _
# |_) _ _ _| _
# | _> (/_ |_| (_| (_)
# _
# |_) _ _ _| _
# | _> (/_ |_| (_| (_)
#
if do_pseudo:
print ""
print "BEGIN_PSEUDO"
print("")
print("BEGIN_PSEUDO")
klocmax = ezfio.get_pseudo_pseudo_klocmax()
kmax = ezfio.get_pseudo_pseudo_kmax()
lmax = ezfio.get_pseudo_pseudo_lmax()
@ -318,21 +318,21 @@ if do_pseudo:
l_str.append(l_dump)
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):
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):
print " ", ii + 1, ll
print(" ", ii + 1, ll)
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 "END_PSEUDO"
print(str_.format(sum([int(d_z[a])-int(l_charge[i]) for i,a in enumerate(l_label)])))
print("END_PSEUDO")
# _
# | \ _ _|_
# |_/ (/_ |_
# _
# | \ _ _|_
# |_/ (/_ |_
#
@ -343,12 +343,12 @@ bit_kind = ezfio.get_determinants_bit_kind()
nexcitedstate = ezfio.get_determinants_n_states()
print ""
print "BEGIN_DET"
print ""
print "mo_num", mo_num
print "det_num", n_det
print ""
print("")
print("BEGIN_DET")
print("")
print("mo_num", mo_num)
print("det_num", n_det)
print("")
if "QP_STATE" in os.environ:
state = int(os.environ["QP_STATE"])-1
@ -372,13 +372,13 @@ MultiDetAlpha = []
MultiDetBeta = []
for coef, (det_a, det_b) in zip(psi_coef_small, psi_det):
print coef
print(coef)
MyDetA=decode(det_a)
MyDetB=decode(det_b)
print MyDetA
print MyDetB
print ''
print(MyDetA)
print(MyDetB)
print('')
MultiDetAlpha.append( det_a )
MultiDetBeta.append( det_b )
print "END_DET"
MultiDetBeta.append( det_b )
print("END_DET")