Running jobs with pyOQP - Open-Quantum-Platform/openqp GitHub Wiki
PyOQP is a Python interface for the OpenQP quantum chemistry package, initiated by Prof. Jingbai Li at the Hoffmann Institute of Advanced Materials, Shenzhen, China. It provides a Python wrapper around the core liboqp.so library.
There are two primary methods for executing OpenQP calculations:
Execute calculations directly from the terminal:
openqp inputUse the PyOQP Python API for programmatic control and data access.
Define your molecular system and calculation parameters using a Python dictionary. You can specify the molecular geometry either inline (using semicolons) or by file path:
cfg = {
"input.system": "H 0 0 0; H 0 0 0.74", # inline geometry (or use "path/to/h2.xyz")
"input.runtype": "energy",
"input.basis": "6-31G*",
"input.method": "hf",
"scf.type": "rhf",
"scf.converger_type": "diis",
}Configuration Options:
from oqp.openqp import OPENQP
op = OPENQP(cfg) # Initialize with configuration
mol = op.run() # Execute calculation and return Molecule objectThe mol object provides access to all calculated properties and internal data structures.
PyOQP provides getter methods for all registered OpenQP data tags:
dm_a = mol.get_dm_a() # Alpha density matrix
dm_b = mol.get_dm_b() # Beta density matrixfock_a = mol.get_fock_a() # Alpha Fock matrix
fock_b = mol.get_fock_b() # Beta Fock matrixC_a = mol.get_vec_mo_a() # Alpha MO coefficients
C_b = mol.get_vec_mo_b() # Beta MO coefficients
eps_a = mol.get_e_mo_a() # Alpha orbital energies
eps_b = mol.get_e_mo_b() # Beta orbital energiesHcore = mol.get_hcore() # Core Hamiltonian
S = mol.get_sm() # Overlap matrix
T = mol.get_tm() # Kinetic energy matrixtd_abxc = mol.get_td_abxc() # TD coupling matrix
td_bvec = mol.get_td_bvec_mo() # TD B-vector (MO basis)
td_mrsf_density = mol.get_td_mrsf_density() # MRSF density
td_energies = mol.get_td_energies() # Excitation energies
td_overlap = mol.get_td_states_overlap() # State overlap matrixdc_matrix = mol.get_dc_matrix() # Derivative coupling matrix
nac_matrix = mol.get_nac_matrix() # Non-adiabatic coupling matrixYou can update internal data structures using setter methods:
# Clear alpha density matrix
mol.set_dm_a(dm_a * 0.0)
# Apply shift to alpha Fock matrix
mol.set_fock_a(fock_a + 0.1)This enables advanced workflows such as:
- Custom SCF procedures
- Modified density functionals
- Constrained calculations
from oqp.openqp import OPENQP
# Configuration for ROHF-MRSF-TDHF calculation
cfg = {
"input.system": "O 0.000000000 0.000000000 -0.041061554; H -0.533194329 0.533194329 -0.614469223; H 0.533194329 -0.533194329 -0.614469223",
"input.runtype": "energy",
"input.basis": "6-31G*",
"input.method": "tdhf",
"scf.type": "rohf",
"scf.multiplicity": "3",
"tdhf.type": "mrsf",
"tdhf.nstate": "3"
}
# Initialize and run
op = OPENQP(cfg)
mol = op.run()
# Access results
print("TD Energies:", mol.get_td_energies())
print("First alpha orbital energy:", mol.get_e_mo_a()[0])