mirror of
https://github.com/LCPQ/quantum_package
synced 2024-06-22 13:12:16 +02:00
Same phase for the MOs than gamess
This commit is contained in:
parent
263bdd0f6c
commit
99a9ba01e1
|
@ -2,6 +2,11 @@
|
|||
|
||||
print "#QP -> QMCPACK"
|
||||
|
||||
# ___
|
||||
# | ._ o _|_
|
||||
# _|_ | | | |_
|
||||
#
|
||||
|
||||
from ezfio import ezfio
|
||||
|
||||
import sys
|
||||
|
@ -9,7 +14,6 @@ ezfio_path = sys.argv[1]
|
|||
|
||||
ezfio.set_file(ezfio_path)
|
||||
|
||||
|
||||
do_pseudo = ezfio.get_pseudo_do_pseudo()
|
||||
if do_pseudo:
|
||||
print "do_pseudo True"
|
||||
|
@ -27,13 +31,16 @@ if n_det == 1:
|
|||
else:
|
||||
print "multi_det True"
|
||||
|
||||
#
|
||||
# |\/| o _ _
|
||||
# | | | _> (_
|
||||
#
|
||||
ao_num = ezfio.get_ao_basis_ao_num()
|
||||
print "ao_num", ao_num
|
||||
|
||||
mo_num = ezfio.get_mo_basis_mo_tot_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
|
||||
|
@ -48,6 +55,11 @@ l_coord = ezfio.get_nuclei_nucl_coord()
|
|||
l_coord_str = [" ".join(map(str, i)) for i in l_coord]
|
||||
|
||||
print "nucl_num", len(l_label)
|
||||
|
||||
# _
|
||||
# / _ _ ._ _|
|
||||
# \_ (_) (_) | (_|
|
||||
#
|
||||
print "Atomic coord in Bohr"
|
||||
|
||||
for i, t in enumerate(zip(l_label, l_charge, l_coord_str)):
|
||||
|
@ -57,12 +69,22 @@ for i,t in enumerate(zip(l_label,l_charge,l_coord_str)):
|
|||
l = t
|
||||
print " ".join(map(str, l))
|
||||
|
||||
|
||||
#
|
||||
# Call externet process to get the sysmetry
|
||||
#
|
||||
import subprocess
|
||||
process = subprocess.Popen(['qp_print_basis', ezfio_path], stdout=subprocess.PIPE)
|
||||
process = subprocess.Popen(
|
||||
['qp_print_basis', ezfio_path],
|
||||
stdout=subprocess.PIPE)
|
||||
out, err = process.communicate()
|
||||
|
||||
basis_raw, sym_raw, mo_raw = out.split("\n\n\n")
|
||||
basis_raw, sym_raw, _ = out.split("\n\n\n")
|
||||
|
||||
# _ __
|
||||
# |_) _. _ o _ (_ _ _|_
|
||||
# |_) (_| _> | _> __) (/_ |_
|
||||
#
|
||||
|
||||
|
||||
basis_without_header = "\n".join(basis_raw.split("\n")[7:])
|
||||
for i, l in enumerate(l_label):
|
||||
|
@ -73,13 +95,19 @@ print ""
|
|||
print basis_without_header
|
||||
print "END_BASIS_SET"
|
||||
|
||||
|
||||
# _
|
||||
# |\/| / \ _
|
||||
# | | \_/ _>
|
||||
#
|
||||
|
||||
#
|
||||
# Function
|
||||
#
|
||||
def same_character(item1):
|
||||
return item1 == item1[0] * len(item1)
|
||||
|
||||
|
||||
def compare_gamess_style(item1, item2):
|
||||
if len(item1) < len(item2):
|
||||
return -1
|
||||
|
@ -97,6 +125,7 @@ def compare_gamess_style(item1, item2):
|
|||
else:
|
||||
return compare_gamess_style(item1[:-1], item2[:-1])
|
||||
|
||||
|
||||
def expend_and_order_sym(str_):
|
||||
#Expend
|
||||
for i, c in enumerate(str_):
|
||||
|
@ -110,6 +139,7 @@ def expend_and_order_sym(str_):
|
|||
#Order by frequency
|
||||
return "".join(sorted(str_, key=str_.count, reverse=True))
|
||||
|
||||
|
||||
def get_nb_permutation(str_):
|
||||
|
||||
l = len(str_) - 1
|
||||
|
@ -118,7 +148,10 @@ def get_nb_permutation(str_):
|
|||
else:
|
||||
return 2 * (2 * l + 1)
|
||||
|
||||
## We will order the symetry
|
||||
#==========================
|
||||
# We will order the symetry
|
||||
#==========================
|
||||
|
||||
l_sym_without_header = sym_raw.split("\n")[3:-2]
|
||||
|
||||
l_l_sym = [i.split() for i in l_sym_without_header]
|
||||
|
@ -130,33 +163,91 @@ l_l_sym_iter = iter(l_l_sym)
|
|||
for i, l in enumerate(l_l_sym_iter):
|
||||
n = get_nb_permutation(l[2])
|
||||
if n != 1:
|
||||
l_l_sym[i:i+n] = sorted(l_l_sym[i:i+n],key=lambda x : x[2], cmp=compare_gamess_style)
|
||||
l_l_sym[i:i + n] = sorted(l_l_sym[i:i + n],
|
||||
key=lambda x: x[2],
|
||||
cmp=compare_gamess_style)
|
||||
for next_ in range(n - 1):
|
||||
next(l_l_sym_iter)
|
||||
|
||||
#Is orderd now
|
||||
|
||||
l_block = mo_raw.split("\n\n")[5:-1]
|
||||
#========
|
||||
#MO COEF
|
||||
#========
|
||||
def order_phase(mo_coef):
|
||||
#Order
|
||||
mo_coef_phase = []
|
||||
import math
|
||||
|
||||
for i in mo_coef:
|
||||
if abs(max(i)) > abs(min(i)):
|
||||
sign_max = math.copysign(1, max(i))
|
||||
else:
|
||||
sign_max = math.copysign(1, min(i))
|
||||
|
||||
if sign_max == -1:
|
||||
ii = [-1 * l for l in i]
|
||||
else:
|
||||
ii = i
|
||||
|
||||
mo_coef_phase.append(ii)
|
||||
return mo_coef_phase
|
||||
|
||||
|
||||
l_block_format=[]
|
||||
def order_by_sim(mo_coef, l_l_sym):
|
||||
l_sym_oder = [int(l[0]) - 1 for l in l_l_sym]
|
||||
mo_coef_order = [[x for (y, x) in sorted(zip(l_sym_oder, i))]
|
||||
for i in mo_coef]
|
||||
return mo_coef_order
|
||||
|
||||
|
||||
def chunked(mo_coef, chunks_size):
|
||||
mo_coef_block = []
|
||||
for i in mo_coef:
|
||||
chunks = [i[x:x + chunks_size] for x in xrange(0, len(i), chunks_size)]
|
||||
mo_coef_block.append(chunks)
|
||||
return mo_coef_block
|
||||
|
||||
|
||||
def print_mo_coef(mo_coef_block, l_l_sym):
|
||||
print ""
|
||||
print "BEGIN_MO"
|
||||
for block in l_block:
|
||||
print ""
|
||||
l_ligne = block.split("\n")
|
||||
print l_ligne.pop(0)
|
||||
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]
|
||||
|
||||
print " ".join([str(
|
||||
i + 1) for i in range(len_block_curent, len_block_curent + len(a[
|
||||
0]))])
|
||||
|
||||
len_block_curent += len(a[0])
|
||||
|
||||
for l in l_l_sym:
|
||||
i = int(l[0]) - 1
|
||||
i_a = int(l[1]) - 1
|
||||
sym = l[2]
|
||||
|
||||
print l_label[i_a],sym,l_ligne[i]
|
||||
print l_label[i_a], sym, " ".join('{: 3.8f}'.format(i)
|
||||
for i in a[i])
|
||||
|
||||
if i_block != nb_block - 1:
|
||||
print ""
|
||||
else:
|
||||
print "END_MO"
|
||||
|
||||
|
||||
mo_coef = ezfio.get_mo_basis_mo_coef()
|
||||
mo_coef_phase = order_phase(mo_coef)
|
||||
mo_coef_phase_order = order_by_sim(mo_coef_phase, l_l_sym)
|
||||
mo_coef_transp = zip(*mo_coef_phase_order)
|
||||
mo_coef_block = chunked(mo_coef_transp, 4)
|
||||
print_mo_coef(mo_coef_block, l_l_sym)
|
||||
|
||||
# _
|
||||
# |_) _ _ _| _
|
||||
# | _> (/_ |_| (_| (_)
|
||||
#
|
||||
if do_pseudo:
|
||||
print ""
|
||||
print "BEGIN_PSEUDO"
|
||||
|
@ -164,7 +255,6 @@ if do_pseudo:
|
|||
kmax = ezfio.get_pseudo_pseudo_kmax()
|
||||
lmax = ezfio.get_pseudo_pseudo_lmax()
|
||||
|
||||
|
||||
n_k = ezfio.get_pseudo_pseudo_n_k()
|
||||
v_k = ezfio.get_pseudo_pseudo_v_k()
|
||||
dz_k = ezfio.get_pseudo_pseudo_dz_k()
|
||||
|
@ -191,7 +281,8 @@ if do_pseudo:
|
|||
l_dump = []
|
||||
for k in range(kmax):
|
||||
if v_kl[l][k][i]:
|
||||
l_ = list_to_string([v_kl[l][k][i], n_kl[l][k][i]+2, dz_kl[l][k][i]])
|
||||
l_ = list_to_string([v_kl[l][k][i], n_kl[l][k][i] + 2,
|
||||
dz_kl[l][k][i]])
|
||||
l_dump.append(l_)
|
||||
if l_dump:
|
||||
l_str.append(l_dump)
|
||||
|
@ -209,6 +300,10 @@ if do_pseudo:
|
|||
print str_.format(sum(zcore))
|
||||
print "END_PSEUDO"
|
||||
|
||||
# _
|
||||
# | \ _ _|_
|
||||
# |_/ (/_ |_
|
||||
#
|
||||
print ""
|
||||
print "BEGIN_DET"
|
||||
print ""
|
||||
|
@ -219,7 +314,6 @@ print ""
|
|||
psi_det = ezfio.get_determinants_psi_det()
|
||||
psi_coef = ezfio.get_determinants_psi_coef()[0]
|
||||
|
||||
|
||||
for c, (l_det_bit_alpha, l_det_bit_beta) in zip(psi_coef, psi_det):
|
||||
print c
|
||||
for det in l_det_bit_alpha:
|
||||
|
|
Loading…
Reference in New Issue
Block a user