mirror of
https://github.com/LCPQ/quantum_package
synced 2024-11-04 05:03:54 +01:00
Update qp_convert_qmcpack_to_ezfio.py
This commit is contained in:
parent
0483b7c3a0
commit
727b79bcab
@ -129,27 +129,22 @@ print "END_BASIS_SET"
|
|||||||
#
|
#
|
||||||
# Function
|
# Function
|
||||||
#
|
#
|
||||||
def same_character(item1):
|
#
|
||||||
return item1 == item1[0] * len(item1)
|
d_gms_order ={ 0:["s"],
|
||||||
|
1:[ "x", "y", "z" ],
|
||||||
|
2:[ "xx", "yy", "zz", "xy", "xz", "yz" ],
|
||||||
|
3:[ "xxx", "yyy", "zzz", "xxy", "xxz", "yyx", "yyz", "zzx", "zzy", "xyz"],
|
||||||
|
4: ["xxxx", "yyyy", "zzzz", "xxxy", "xxxz", "yyyx", "yyyz", "zzzx", "zzzy", "xxyy", "xxzz", "yyzz", "xxyz", "yyxz", "zzxy", "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):
|
||||||
if len(item1) < len(item2):
|
n1,n2 = map(len,(item1,item2))
|
||||||
return -1
|
assert (n1 == n2)
|
||||||
elif len(item1) > len(item2):
|
try:
|
||||||
return 1
|
l = d_gms_order[n1]
|
||||||
elif same_character(item1) and same_character(item2):
|
except KeyError:
|
||||||
if item1 < item2:
|
raise (KeyError, "We dont handle L than 4")
|
||||||
return -1
|
|
||||||
else:
|
else:
|
||||||
return 1
|
return l.index(item1) > l.index(item2)
|
||||||
elif same_character(item1) and not same_character(item2):
|
|
||||||
return -1
|
|
||||||
elif not same_character(item1) and same_character(item2):
|
|
||||||
return 1
|
|
||||||
else:
|
|
||||||
return compare_gamess_style(item1[:-1], item2[:-1])
|
|
||||||
|
|
||||||
|
|
||||||
def expend_sym_str(str_):
|
def expend_sym_str(str_):
|
||||||
#Expend x2 -> xx
|
#Expend x2 -> xx
|
||||||
@ -173,18 +168,22 @@ def expend_sym_l(l_l_sym):
|
|||||||
return l_l_sym
|
return l_l_sym
|
||||||
|
|
||||||
|
|
||||||
def get_nb_permutation(str_):
|
def n_orbital(n):
|
||||||
|
if n==0:
|
||||||
l = len(str_) - 1
|
|
||||||
if l == 0:
|
|
||||||
return 1
|
return 1
|
||||||
|
elif n==1:
|
||||||
|
return 3
|
||||||
else:
|
else:
|
||||||
return 2 * (2 * l + 1)
|
return 2*n_orbital(n-1)-n_orbital(n-2)+1
|
||||||
|
|
||||||
|
def get_nb_permutation(str_):
|
||||||
|
if (str_) == 's': return 1
|
||||||
|
else: return n_orbital(len(str_))
|
||||||
|
|
||||||
def order_l_l_sym(l_l_sym):
|
def order_l_l_sym(l_l_sym):
|
||||||
n = 1
|
n = 1
|
||||||
for i in range(len(l_l_sym)):
|
iter_ = range(len(l_l_sym))
|
||||||
|
for i in iter_:
|
||||||
if n != 1:
|
if n != 1:
|
||||||
n += -1
|
n += -1
|
||||||
continue
|
continue
|
||||||
@ -196,13 +195,13 @@ def order_l_l_sym(l_l_sym):
|
|||||||
key=lambda x: x[2],
|
key=lambda x: x[2],
|
||||||
cmp=compare_gamess_style)
|
cmp=compare_gamess_style)
|
||||||
|
|
||||||
|
|
||||||
return l_l_sym
|
return l_l_sym
|
||||||
|
|
||||||
|
|
||||||
#==========================
|
#==========================
|
||||||
# We will order the symetry
|
# We will order the symetry
|
||||||
#==========================
|
#==========================
|
||||||
|
|
||||||
l_sym_without_header = sym_raw.split("\n")[3:-2]
|
l_sym_without_header = sym_raw.split("\n")[3:-2]
|
||||||
l_l_sym_raw = [i.split() for i in l_sym_without_header]
|
l_l_sym_raw = [i.split() for i in l_sym_without_header]
|
||||||
l_l_sym_expend_sym = expend_sym_l(l_l_sym_raw)
|
l_l_sym_expend_sym = expend_sym_l(l_l_sym_raw)
|
||||||
@ -355,7 +354,7 @@ for line_raw in det_without_header.split("\n"):
|
|||||||
try:
|
try:
|
||||||
float(line)
|
float(line)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
line= "".join([d_rep[x] if x in d_rep else x for x in line_raw])
|
line= "".join(d_rep[x] if x in d_rep else x for x in line_raw)
|
||||||
|
|
||||||
print line.strip()
|
print line.strip()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user