-
Notifications
You must be signed in to change notification settings - Fork 21
Tagarray
Cheol Ho Choi edited this page Jan 4, 2024
·
10 revisions
Here we provide a simple Python script for its use.
#!/usr/bin/env python3
'''OQP mini-app'''
import os
import argparse
from signal import signal, SIGINT, SIG_DFL
import oqp
from oqp.utils import testing
from oqp.molecule import Molecule
from oqp.library import *
def setup_command_line_args():
'''Set up command line options for the OQP mini-app'''
parser = argparse.ArgumentParser()
parser.add_argument("input", type=argparse.FileType('r'), help="input file name")
parser.add_argument("-I", "--inspect", action="store_true",
help="Return to interactive Python console after script ends")
parser.add_argument("--validate", action="store_true", help="Run validation tests")
parser.add_argument(
"--create_tests",
action="store_true",
help="Create validation tests' values; Please, copy these values to your input",
)
return parser.parse_args()
if __name__ == "__main__":
args = setup_command_line_args()
if args.inspect:
os.environ['PYTHONINSPECT'] = '1'
_, tail_path = os.path.split(args.input.name)
project_name = tail_path.replace(".inp", "")
log = project_name + ".log"
if os.path.exists(log):
os.remove(log)
signal(SIGINT, SIG_DFL)
oqp.set_log(log)
mol = Molecule().from_file(args.input.name)
# Save project_name to the config as default name
mol.config["tests"]["project_name"] = project_name
oqp.library.set_basis(mol)
oqp.library.ints_1e(mol)
# Guess: read molden / init guess
oqp.library.guess(mol)
# put matrix to OQP::chc_matrix_py
mol.data["OQP::chc_matrix_py"] = np.reshape([1, 2.0, 3, 4.0, 5, 6], (2,3))
# read inside fortran OQP::chc_matrix_py and print it to the log file
oqp.chc_example(mol)
# get from the written in fortran OQP::chc_matrix_f
result = mol.data["OQP::chc_matrix_f"]
# print in python
print(result)
[Going back to Developer Documentation](Developer Documentation)