mirror of
https://github.com/QuantumPackage/qp2.git
synced 2024-12-22 12:23:43 +01:00
Moving to Python3.
This commit is contained in:
parent
c50707568c
commit
c22daadf40
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
"""
|
"""
|
||||||
convert output of GAMESS/GAU$$IAN to ezfio
|
convert output of GAMESS/GAU$$IAN to ezfio
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ try:
|
|||||||
QP_ROOT = os.environ["QP_ROOT"]
|
QP_ROOT = os.environ["QP_ROOT"]
|
||||||
QP_EZFIO = os.environ["QP_EZFIO"]
|
QP_EZFIO = os.environ["QP_EZFIO"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print "Error: QP_ROOT environment variable not found."
|
print("Error: QP_ROOT environment variable not found.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
sys.path = [QP_EZFIO + "/Python",
|
sys.path = [QP_EZFIO + "/Python",
|
||||||
@ -30,10 +30,11 @@ else:
|
|||||||
QP_ROOT + "/install",
|
QP_ROOT + "/install",
|
||||||
QP_ROOT + "/scripts"] + sys.path
|
QP_ROOT + "/scripts"] + sys.path
|
||||||
|
|
||||||
|
from resultsFile import *
|
||||||
try:
|
try:
|
||||||
from resultsFile import *
|
from resultsFile import *
|
||||||
except:
|
except:
|
||||||
print "Error: resultsFile Python library not installed"
|
print("Error: resultsFile Python library not installed")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
@ -48,17 +49,17 @@ def write_ezfio(res, filename):
|
|||||||
# |_ | _ _ _|_ ._ _ ._ _
|
# |_ | _ _ _|_ ._ _ ._ _
|
||||||
# |_ | (/_ (_ |_ | (_) | | _>
|
# |_ | (/_ (_ |_ | (_) | | _>
|
||||||
#
|
#
|
||||||
print "Electrons\t...\t",
|
print("Electrons\t...\t", end=' ')
|
||||||
ezfio.set_electrons_elec_alpha_num(res.num_alpha)
|
ezfio.set_electrons_elec_alpha_num(res.num_alpha)
|
||||||
ezfio.set_electrons_elec_beta_num(res.num_beta)
|
ezfio.set_electrons_elec_beta_num(res.num_beta)
|
||||||
print "OK"
|
print("OK")
|
||||||
|
|
||||||
#
|
#
|
||||||
# |\ | _ | _ o
|
# |\ | _ | _ o
|
||||||
# | \| |_| (_ | (/_ |
|
# | \| |_| (_ | (/_ |
|
||||||
#
|
#
|
||||||
|
|
||||||
print "Nuclei\t\t...\t",
|
print("Nuclei\t\t...\t", end=' ')
|
||||||
# ~#~#~#~ #
|
# ~#~#~#~ #
|
||||||
# I n i t #
|
# I n i t #
|
||||||
# ~#~#~#~ #
|
# ~#~#~#~ #
|
||||||
@ -93,24 +94,23 @@ def write_ezfio(res, filename):
|
|||||||
|
|
||||||
# Transformt H1 into H
|
# Transformt H1 into H
|
||||||
import re
|
import re
|
||||||
p = re.compile(ur'(\d*)$')
|
p = re.compile(r'(\d*)$')
|
||||||
label = [p.sub("", x.name).capitalize() for x in res.geometry]
|
label = [p.sub("", x.name).capitalize() for x in res.geometry]
|
||||||
ezfio.set_nuclei_nucl_label(label)
|
ezfio.set_nuclei_nucl_label(label)
|
||||||
|
|
||||||
ezfio.set_nuclei_nucl_coord(coord_x + coord_y + coord_z)
|
ezfio.set_nuclei_nucl_coord(coord_x + coord_y + coord_z)
|
||||||
print "OK"
|
print("OK")
|
||||||
|
|
||||||
# _
|
# _
|
||||||
# /\ _ _ |_) _. _ o _
|
# /\ _ _ |_) _. _ o _
|
||||||
# /--\ (_) _> |_) (_| _> | _>
|
# /--\ (_) _> |_) (_| _> | _>
|
||||||
#
|
#
|
||||||
|
|
||||||
print "AOS\t\t...\t",
|
print("AOS\t\t...\t", end=' ')
|
||||||
# ~#~#~#~ #
|
# ~#~#~#~ #
|
||||||
# I n i t #
|
# I n i t #
|
||||||
# ~#~#~#~ #
|
# ~#~#~#~ #
|
||||||
|
|
||||||
import string
|
|
||||||
at = []
|
at = []
|
||||||
num_prim = []
|
num_prim = []
|
||||||
power_x = []
|
power_x = []
|
||||||
@ -131,9 +131,9 @@ def write_ezfio(res, filename):
|
|||||||
at.append(i + 1)
|
at.append(i + 1)
|
||||||
num_prim.append(len(b.prim))
|
num_prim.append(len(b.prim))
|
||||||
s = b.sym
|
s = b.sym
|
||||||
power_x.append(string.count(s, "x"))
|
power_x.append(str.count(s, "x"))
|
||||||
power_y.append(string.count(s, "y"))
|
power_y.append(str.count(s, "y"))
|
||||||
power_z.append(string.count(s, "z"))
|
power_z.append(str.count(s, "z"))
|
||||||
coefficient.append(b.coef)
|
coefficient.append(b.coef)
|
||||||
exponent.append([p.expo for p in b.prim])
|
exponent.append([p.expo for p in b.prim])
|
||||||
|
|
||||||
@ -175,14 +175,14 @@ def write_ezfio(res, filename):
|
|||||||
ezfio.set_ao_basis_ao_expo(expo)
|
ezfio.set_ao_basis_ao_expo(expo)
|
||||||
ezfio.set_ao_basis_ao_basis("Read by resultsFile")
|
ezfio.set_ao_basis_ao_basis("Read by resultsFile")
|
||||||
|
|
||||||
print "OK"
|
print("OK")
|
||||||
|
|
||||||
# _
|
# _
|
||||||
# |\/| _ _ |_) _. _ o _
|
# |\/| _ _ |_) _. _ o _
|
||||||
# | | (_) _> |_) (_| _> | _>
|
# | | (_) _> |_) (_| _> | _>
|
||||||
#
|
#
|
||||||
|
|
||||||
print "MOS\t\t...\t",
|
print("MOS\t\t...\t", end=' ')
|
||||||
# ~#~#~#~ #
|
# ~#~#~#~ #
|
||||||
# I n i t #
|
# I n i t #
|
||||||
# ~#~#~#~ #
|
# ~#~#~#~ #
|
||||||
@ -205,9 +205,9 @@ def write_ezfio(res, filename):
|
|||||||
virtual = []
|
virtual = []
|
||||||
active = [(allMOs[i].eigenvalue, i) for i in range(len(allMOs))]
|
active = [(allMOs[i].eigenvalue, i) for i in range(len(allMOs))]
|
||||||
|
|
||||||
closed = map(lambda x: x[1], closed)
|
closed = [x[1] for x in closed]
|
||||||
active = map(lambda x: x[1], active)
|
active = [x[1] for x in active]
|
||||||
virtual = map(lambda x: x[1], virtual)
|
virtual = [x[1] for x in virtual]
|
||||||
MOindices = closed + active + virtual
|
MOindices = closed + active + virtual
|
||||||
|
|
||||||
MOs = []
|
MOs = []
|
||||||
@ -223,7 +223,7 @@ def write_ezfio(res, filename):
|
|||||||
MOmap[i] = MOindices.index(i)
|
MOmap[i] = MOindices.index(i)
|
||||||
|
|
||||||
energies = []
|
energies = []
|
||||||
for i in xrange(mo_num):
|
for i in range(mo_num):
|
||||||
energies.append(MOs[i].eigenvalue)
|
energies.append(MOs[i].eigenvalue)
|
||||||
|
|
||||||
if res.occ_num is not None:
|
if res.occ_num is not None:
|
||||||
@ -237,11 +237,11 @@ def write_ezfio(res, filename):
|
|||||||
MoMatrix = []
|
MoMatrix = []
|
||||||
sym0 = [i.sym for i in res.mo_sets[MO_type]]
|
sym0 = [i.sym for i in res.mo_sets[MO_type]]
|
||||||
sym = [i.sym for i in res.mo_sets[MO_type]]
|
sym = [i.sym for i in res.mo_sets[MO_type]]
|
||||||
for i in xrange(len(sym)):
|
for i in range(len(sym)):
|
||||||
sym[MOmap[i]] = sym0[i]
|
sym[MOmap[i]] = sym0[i]
|
||||||
|
|
||||||
MoMatrix = []
|
MoMatrix = []
|
||||||
for i in xrange(len(MOs)):
|
for i in range(len(MOs)):
|
||||||
m = MOs[i]
|
m = MOs[i]
|
||||||
for coef in m.vector:
|
for coef in m.vector:
|
||||||
MoMatrix.append(coef)
|
MoMatrix.append(coef)
|
||||||
@ -256,10 +256,10 @@ def write_ezfio(res, filename):
|
|||||||
ezfio.set_mo_basis_mo_num(mo_num)
|
ezfio.set_mo_basis_mo_num(mo_num)
|
||||||
ezfio.set_mo_basis_mo_occ(OccNum)
|
ezfio.set_mo_basis_mo_occ(OccNum)
|
||||||
ezfio.set_mo_basis_mo_coef(MoMatrix)
|
ezfio.set_mo_basis_mo_coef(MoMatrix)
|
||||||
print "OK"
|
print("OK")
|
||||||
|
|
||||||
|
|
||||||
print "Pseudos\t\t...\t",
|
print("Pseudos\t\t...\t", end=' ')
|
||||||
try:
|
try:
|
||||||
lmax = 0
|
lmax = 0
|
||||||
nucl_charge_remove = []
|
nucl_charge_remove = []
|
||||||
@ -327,7 +327,7 @@ def write_ezfio(res, filename):
|
|||||||
else:
|
else:
|
||||||
ezfio.set_pseudo_do_pseudo(True)
|
ezfio.set_pseudo_do_pseudo(True)
|
||||||
|
|
||||||
print "OK"
|
print("OK")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -354,15 +354,15 @@ if __name__ == '__main__':
|
|||||||
except:
|
except:
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
print FILE, 'recognized as', str(RES_FILE).split('.')[-1].split()[0]
|
print(FILE, 'recognized as', str(RES_FILE).split('.')[-1].split()[0])
|
||||||
|
|
||||||
write_ezfio(RES_FILE, EZFIO_FILE)
|
write_ezfio(RES_FILE, EZFIO_FILE)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
if os.system("qp_run save_ortho_mos "+EZFIO_FILE) != 0:
|
if os.system("qp_run save_ortho_mos "+EZFIO_FILE) != 0:
|
||||||
print """Warning: You need to run
|
print("""Warning: You need to run
|
||||||
|
|
||||||
qp run save_ortho_mos
|
qp run save_ortho_mos
|
||||||
|
|
||||||
to be sure your MOs will be orthogonal, which is not the case when
|
to be sure your MOs will be orthogonal, which is not the case when
|
||||||
the MOs are read from output files (not enough precision in output)."""
|
the MOs are read from output files (not enough precision in output).""")
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -49,7 +49,7 @@ import os.path
|
|||||||
try:
|
try:
|
||||||
import qp_path
|
import qp_path
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print "source .quantum_package.rc"
|
print("source .quantum_package.rc")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
from docopt import docopt
|
from docopt import docopt
|
||||||
@ -102,7 +102,7 @@ def main(arguments):
|
|||||||
mo_num = ezfio.mo_basis_mo_num
|
mo_num = ezfio.mo_basis_mo_num
|
||||||
|
|
||||||
if arguments["--query"]:
|
if arguments["--query"]:
|
||||||
print n_frozen
|
print(n_frozen)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if n_frozen == 0:
|
if n_frozen == 0:
|
||||||
|
46
external/Python/.gitignore
vendored
46
external/Python/.gitignore
vendored
@ -0,0 +1,46 @@
|
|||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
env/
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.coverage
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
target/
|
@ -21,10 +21,6 @@ let () =
|
|||||||
doc="Downloads the EZFIO directory." ;
|
doc="Downloads the EZFIO directory." ;
|
||||||
arg=Without_arg; } ;
|
arg=Without_arg; } ;
|
||||||
|
|
||||||
{ short='v' ; long="verbose" ; opt=Optional ;
|
|
||||||
doc="Prints the transfer speed." ;
|
|
||||||
arg=Without_arg; } ;
|
|
||||||
|
|
||||||
anonymous
|
anonymous
|
||||||
"(EZFIO_DIR|ADDRESS)"
|
"(EZFIO_DIR|ADDRESS)"
|
||||||
Mandatory
|
Mandatory
|
||||||
@ -47,11 +43,6 @@ let () =
|
|||||||
ADDRESS x
|
ADDRESS x
|
||||||
in
|
in
|
||||||
|
|
||||||
let verbose =
|
|
||||||
Command_line.get_bool "verbose"
|
|
||||||
in
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let localhost =
|
let localhost =
|
||||||
Lazy.force TaskServer.ip_address
|
Lazy.force TaskServer.ip_address
|
||||||
@ -155,45 +146,6 @@ let () =
|
|||||||
Zmq.Socket.subscribe socket_in "";
|
Zmq.Socket.subscribe socket_in "";
|
||||||
|
|
||||||
|
|
||||||
(*
|
|
||||||
let action =
|
|
||||||
if verbose then
|
|
||||||
begin
|
|
||||||
match req_or_sub with
|
|
||||||
| REQ -> (fun () ->
|
|
||||||
let msg =
|
|
||||||
Zmq.Socket.recv_all socket_in
|
|
||||||
in
|
|
||||||
let t0 = Unix.gettimeofday () in
|
|
||||||
Zmq.Socket.send_all socket_out msg;
|
|
||||||
let in_size =
|
|
||||||
float_of_int ( List.fold_left (fun accu x -> accu + String.length x) 0 msg )
|
|
||||||
/. 8192. /. 1024.
|
|
||||||
in
|
|
||||||
let msg =
|
|
||||||
Zmq.Socket.recv_all socket_out
|
|
||||||
in
|
|
||||||
let t1 = Unix.gettimeofday () in
|
|
||||||
Zmq.Socket.send_all socket_in msg;
|
|
||||||
let in_time = t1 -. t0 in
|
|
||||||
in_time_sum := !in_time_sum +. in_time;
|
|
||||||
in_size_sum := !in_size_sum +. in_size;
|
|
||||||
Printf.printf " %16.2f MiB/s -- %16.2f MiB/s\n%!" (in_size /. in_time) (!in_size_sum /. !in_time_sum);
|
|
||||||
)
|
|
||||||
| SUB -> (fun () ->
|
|
||||||
Zmq.Socket.recv_all socket_in |> Zmq.Socket.send_all socket_out)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
match req_or_sub with
|
|
||||||
| REQ -> (fun () ->
|
|
||||||
Zmq.Socket.recv_all socket_in |> Zmq.Socket.send_all socket_out;
|
|
||||||
Zmq.Socket.recv_all socket_out |> Zmq.Socket.send_all socket_in )
|
|
||||||
| SUB -> (fun () ->
|
|
||||||
Zmq.Socket.recv_all socket_in |> Zmq.Socket.send_all socket_out)
|
|
||||||
end
|
|
||||||
in
|
|
||||||
*)
|
|
||||||
|
|
||||||
let action_in =
|
let action_in =
|
||||||
match req_or_sub with
|
match req_or_sub with
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
try:
|
try:
|
||||||
QP_ROOT = os.environ['QP_ROOT']
|
QP_ROOT = os.environ['QP_ROOT']
|
||||||
except:
|
except:
|
||||||
print "source quantum_package.rc"
|
print("source quantum_package.rc")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
QP_EZFIO = os.environ["QP_EZFIO"]
|
QP_EZFIO = os.environ["QP_EZFIO"]
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
with open(sys.argv[1],'r') as f:
|
with open(sys.argv[1],'r') as f:
|
||||||
raw_data = f.read()
|
raw_data = f.read()
|
||||||
|
|
||||||
print "set -x"
|
print("set -x")
|
||||||
|
|
||||||
output = []
|
output = []
|
||||||
inside = False
|
inside = False
|
||||||
@ -25,9 +25,9 @@ for i in raw_data:
|
|||||||
level -= 1
|
level -= 1
|
||||||
output.append(new_i)
|
output.append(new_i)
|
||||||
|
|
||||||
print "".join(output).replace("@test ",
|
print("".join(output).replace("@test ",
|
||||||
"""[[ -z $BATS_TEST_NUMBER ]] && BATS_TEST_NUMBER=0 || ((++BATS_TEST_NUMBER)) ;
|
"""[[ -z $BATS_TEST_NUMBER ]] && BATS_TEST_NUMBER=0 || ((++BATS_TEST_NUMBER)) ;
|
||||||
export BATS_TEST_DESCRIPTION=""").replace("skip","return")
|
export BATS_TEST_DESCRIPTION=""").replace("skip","return"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user