10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-11-04 05:03:54 +01:00

Merge branch 'LCPQ-master'

This commit is contained in:
Anthony Scemama 2017-07-15 18:08:13 +02:00
commit ce35cfe2bb
3 changed files with 48 additions and 44 deletions

View File

@ -53,6 +53,6 @@ let psi_det () =
let () = let () =
basis (); basis ();
mo (); mo ()
psi_det () (* psi_det () *)

View File

@ -91,7 +91,7 @@ process = subprocess.Popen(
stdout=subprocess.PIPE) stdout=subprocess.PIPE)
out, err = process.communicate() out, err = process.communicate()
basis_raw, sym_raw, _ , det_raw, _ = out.split("\n\n\n") basis_raw, sym_raw, _ = out.split("\n\n\n")
# _ __ # _ __
# |_) _. _ o _ (_ _ _|_ # |_) _. _ o _ (_ _ _|_
@ -129,27 +129,24 @@ print "END_BASIS_SET"
# #
# Function # Function
# #
def same_character(item1): d_gms_order ={ 0:["s"],
return item1 == item1[0] * len(item1) 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: return 0
return -1 # raise (KeyError, "We dont handle L than 4")
else:
return 1
elif same_character(item1) and not same_character(item2):
return -1
elif not same_character(item1) and same_character(item2):
return 1
else: else:
return compare_gamess_style(item1[:-1], item2[:-1]) a = l.index(item1)
b = l.index(item2)
return cmp( a, b )
def expend_sym_str(str_): def expend_sym_str(str_):
#Expend x2 -> xx #Expend x2 -> xx
@ -173,18 +170,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,6 +197,7 @@ 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
@ -330,6 +332,12 @@ if do_pseudo:
# | \ _ _|_ # | \ _ _|_
# |_/ (/_ |_ # |_/ (/_ |_
# #
psi_coef = ezfio.get_determinants_psi_coef()
psi_det = ezfio.get_determinants_psi_det()
bit_kind = ezfio.get_determinants_bit_kind()
print "" print ""
print "BEGIN_DET" print "BEGIN_DET"
print "" print ""
@ -337,26 +345,22 @@ print "mo_num", mo_num
print "det_num", n_det print "det_num", n_det
print "" print ""
state = 0
psi_coef = psi_coef[state]
encode = 8*bit_kind
token = "Determinants ::" def bindigits(n, bits):
pos = det_raw.rfind(token) + len(token) s = bin(n & int("1"*bits, 2))[2:]
return ("{0:0>%s}" % (bits)).format(s)
det_without_header = det_raw[pos+2::] decode = lambda det: ''.join(bindigits(i,encode)[::-1] for i in det)[:mo_num]
d_rep={"+":"1","-":"0"} for coef, (det_a, det_b) in zip(psi_coef, psi_det):
det_without_header = det_raw[pos+2::] print coef
print decode(det_a)
for line_raw in det_without_header.split("\n"): print decode(det_b)
line = line_raw print ''
if line_raw:
try:
float(line)
except ValueError:
line= "".join([d_rep[x] if x in d_rep else x for x in line_raw])
print line.strip()
print "END_DET" print "END_DET"

View File

@ -31,6 +31,6 @@ interface: ezfio,provider,ocaml
[distributed_davidson] [distributed_davidson]
type: logical type: logical
doc: If true, use the distributed algorithm doc: If true, use the distributed algorithm
default: False default: True
interface: ezfio,provider,ocaml interface: ezfio,provider,ocaml