Skip to content

Add Python interface (pyquick) via f2py#474

Draft
vtripath65 wants to merge 15 commits intomerzlab:masterfrom
vtripath65:install_python_interface
Draft

Add Python interface (pyquick) via f2py#474
vtripath65 wants to merge 15 commits intomerzlab:masterfrom
vtripath65:install_python_interface

Conversation

@vtripath65
Copy link
Copy Markdown
Collaborator

Summary

This PR adds pyquick, a Python interface to QUICK built with f2py, enabling
users to set up and run QUICK calculations directly from Python without writing
input files.

New files

  • src/pyquick/pyquick.f90 — Fortran module compiled by f2py into a Python C
    extension. Exposes subroutines for setting the calculation type, basis set,
    method keywords, and molecular geometry, as well as running the SCF and
    retrieving results (total energy, MO energies, density matrix, Mulliken/Löwdin
    charges).
  • src/pyquick/__init__.py — Pure-Python wrapper that imports the f2py extension,
    checks the had_error flag after every Fortran call and raises RuntimeError
    on failure, and provides the PyQuick class with per-instance state and a
    copy() method for creating independent conformations.
  • src/pyquick/CMakeLists.txt — Build rules for the f2py extension. Before
    attempting to compile, the build system explicitly checks that both Python and
    numpy (including f2py) are available
    via find_program and
    execute_process. A clear FATAL_ERROR is emitted if either is missing,
    rather than failing silently at compile time.

Build system changes

  • CMakeLists.txt — adds -DPYTHON=TRUE option.
  • src/CMakeLists.txt — adds add_subdirectory(pyquick) guarded by
    -DPYTHON=TRUE.
  • quick-cmake/quick.rc — prepends <prefix>/lib to PYTHONPATH so that
    import pyquick works after source quick.rc.

Build instructions

cmake .. -DCOMPILER=GNU -DENABLEF=FALSE -DPYTHON=TRUE \
         -DCMAKE_INSTALL_PREFIX=$PWD/../install
cmake --build . --parallel $(nproc)
cmake --install .
source ../install/quick.rc

Usage example

from pyquick import PyQuick

job = PyQuick()
job.set_calc('HF')
job.set_basis('STO-3G')
job.read_geom('''
    O  0.000  0.000  0.000
    H  0.757  0.586  0.000
    H -0.757  0.586  0.000
''')
job.run()
print(job.total_energy)

# Copy a job and modify independently
job2 = job.copy()
job2.read_geom('''
    O  0.100  0.000  0.000
    H  0.857  0.586  0.000
    H -0.657  0.586  0.000
''')
job2.run()
print(job2.total_energy)

@agoetz agoetz marked this pull request as draft April 8, 2026 03:53
@agoetz
Copy link
Copy Markdown
Collaborator

agoetz commented Apr 8, 2026

Converted this to draft so we don't merge it before releasing QUICK-26.03

Add pyq_ test category to runtest: check_python_error() skips gracefully
when the Python interface is not built (mirrors the F-function skip pattern),
run_pyquick_test() runs the Python smoke test and logs PASS/possible FAILURE,
--python flag, get_total_tests 7th arg, print_summary Python tests line, and
GNU parallel exports.  Add pyq_ene_H2O_rhf_sto3g to both short and full test
lists so runtest --serial (and --serial --full) now cover the pyquick test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants