Running jobs with pyOQP - Open-Quantum-Platform/openqp GitHub Wiki

PyOQP User Guide

Overview

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.


Running OpenQP Calculations

There are two primary methods for executing OpenQP calculations:

Method 1: Command Line Interface

Execute calculations directly from the terminal:

openqp input

Method 2: Python Interface

Use the PyOQP Python API for programmatic control and data access.


Using the Python Interface

Step 1: Prepare Configuration Dictionary

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:


Step 2: Initialize and Run

from oqp.openqp import OPENQP

op = OPENQP(cfg)   # Initialize with configuration
mol = op.run()     # Execute calculation and return Molecule object

The mol object provides access to all calculated properties and internal data structures.


Step 3: Access Calculated Data

PyOQP provides getter methods for all registered OpenQP data tags:

Density Matrices

dm_a = mol.get_dm_a()    # Alpha density matrix
dm_b = mol.get_dm_b()    # Beta density matrix

Fock Matrices

fock_a = mol.get_fock_a()    # Alpha Fock matrix
fock_b = mol.get_fock_b()    # Beta Fock matrix

Molecular Orbitals

C_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 energies

Core Matrices

Hcore = mol.get_hcore()      # Core Hamiltonian
S = mol.get_sm()             # Overlap matrix
T = mol.get_tm()             # Kinetic energy matrix

TD-DFT/TD-HF Data

td_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 matrix

Dynamics Properties

dc_matrix = mol.get_dc_matrix()      # Derivative coupling matrix
nac_matrix = mol.get_nac_matrix()    # Non-adiabatic coupling matrix

Step 4: Modify Internal Data

You 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

Complete Example

TDHF Calculation on Water Triplet

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])

⚠️ **GitHub.com Fallback** ⚠️