### Development installation with uv Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/tutorial.org Install pychum in development mode using uv with all extras. This is intended for contributors or those needing the full feature set. ```bash cd pychum uv sync --all-extras ``` -------------------------------- ### Install pychum with pip Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/howto/install.org Quick install command for the pychum package using pip. ```bash pip install pychum ``` -------------------------------- ### Create ORCA job with jobflow Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/tutorial.org Python example showing how to create an ORCA single point job and run it with jobflow. Requires TOML config files (SKIP-DOCTEST). ```python # SKIP-DOCTEST -- requires TOML config files from pychum.engine.orca import create_orca_job from jobflow import Flow # Create a single point job job = create_orca_job( geometry="water.xyz", functional="PBE0", basis="def2-SVP", ) # Create a flow flow = Flow([job], name="ORCA Calculation") # Run the flow import jobflow.flows.local jobflow.run_locally(flow) ``` -------------------------------- ### Run ORCA on generated input Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/tutorial.org Run ORCA on the generated input file water.inp. ```bash orca water.inp ``` -------------------------------- ### Verify pychum installation Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/howto/install.org Command to check the installed pychum version. ```bash python -c "import pychum; print(pychum.__version__)" ``` -------------------------------- ### Clone and Setup pychum with uv Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/dev/index.org Clones the pychum repository and installs all extras using uv. Run this in a terminal to set up the development environment. ```bash git clone https://github.com/HaoZeke/pychum cd pychum uv sync --all-extras ``` -------------------------------- ### Set up environment with uv sync Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/dev/contributing.org Install all dependencies including extras using uv. ```bash uv sync --all-extras ``` -------------------------------- ### Python test example for ORCARenderer Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/dev/best_practices.org Minimal test example for the ORCARenderer, verifying that the rendered output contains the configured method. ```python def test_orca_renderer(): config = {"method": "B3LYP", "basis": "def2-SVP"} renderer = ORCARenderer(config) assert "B3LYP" in renderer.render() ``` -------------------------------- ### Install Test Dependencies Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/testing.org Command to install the test dependencies defined in the optional test extras. ```bash uv sync --extra test ``` -------------------------------- ### TOML configuration example for pychum Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/dev/best_practices.org Shows a clear, consistent TOML structure for configuring pychum, including ORCA method and basis settings, and geometry parameters. ```toml [orca] method = "B3LYP" basis = "def2-SVP" [geometry] coordinates = "input.xyz" charge = 0 multiplicity = 1 ``` -------------------------------- ### ConfigLoader usage example Source: https://github.com/haozeke/pychum/blob/main/docs/source/api/pychum.engine.orca.md Loads a TOML configuration file using ConfigLoader. The example creates a loader with 'config.toml' and calls load_config() to retrieve the configuration. ```python from pychum.engine.orca import ConfigLoader loader = ConfigLoader("config.toml") config = loader.load_config() ``` -------------------------------- ### Generate NWChem input file Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/tutorial.org Command to generate an NWChem input file from the eon_nwchem.toml configuration. Outputs to nwchem_input.nw. ```bash pychum nwchem --config eon_nwchem.toml --output nwchem_input.nw ``` -------------------------------- ### Generate ORCA input file from TOML Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/tutorial.org Command to generate an ORCA input file from the single point TOML configuration. Outputs to water.inp. ```bash pychum orca --config single_point.toml --output water.inp ``` -------------------------------- ### Generate NEB ORCA input files Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/tutorial.org Command to generate NEB input files from the neb.toml configuration. Outputs to the neb/ directory. ```bash pychum orca --config neb.toml --output neb/ ``` -------------------------------- ### Jinja2 template example for pychum Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/dev/best_practices.org A simple Jinja2 template for generating ORCA input files, using placeholders for method, basis, block content, and geometry parameters. ```jinja !{{ method }} {{ basis }} {{ block_content }} *xyzfile {{ charge }} {{ multiplicity }} {{ coordinates }} ``` -------------------------------- ### Unit-aware conversions with chemparseplot Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/tutorial.org Python example using chemparseplot.units (ureg) to convert bond length and energy. pychum does not own unit conversion; pychum.units is a deprecation stub. ```python # SKIP-DOCTEST -- chemparseplot is the suite units owner from chemparseplot.units import ureg # Convert bond length distance = 1.5 * ureg.angstrom print(distance.to(ureg.bohr)) # Convert energy energy = -76.0 * ureg.hartree print(energy.to(ureg.kJ)) ``` -------------------------------- ### Set up development environment with Jupyter Lab Source: https://github.com/haozeke/pychum/blob/main/readme_src.org Sets up a complete development environment including the notebook server. First syncs all extras with `uv sync --all-extras`, then starts Jupyter Lab with remote access allowed, browser not opened, and on port 8889. ```bash uv sync --all-extras uv run jupyter lab --ServerApp.allow_remote_access=1 \ --ServerApp.open_browser=False --port=8889 ``` -------------------------------- ### eOn NWChem TOML configuration Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/tutorial.org TOML configuration for a single point calculation with NWChem for eOn. Uses B3LYP functional and 6-31g* basis, with geometry from molecule.xyz. ```toml # eon_nwchem.toml [calculation] type = "single_point" theory = "dft" functional = "b3lyp" basis = "6-31g*" [geometry] method = "xyz" file = "molecule.xyz" [nwchem] task = "energy" ``` -------------------------------- ### render_nwchem Source: https://github.com/haozeke/pychum/blob/main/docs/source/api/pychum.md Generates an NWChem input file for eOn from a position file and settings file. Returns the input file content as a string. ```APIDOC ## render_nwchem ### Description Generates an NWChem input file for eOn from a position file and settings file. Returns the input file content as a string. ### Method Function ### Signature `render_nwchem(pos_file, settings_path, socket_address, unix_mode, mem_in_gb)` ### Parameters - **pos_file** (Path) - Required - Path to the molecular geometry file (e.g., .xyz). - **settings_path** (Path) - Required - Path to the NWChem settings TOML file. - **socket_address** (str) - Required - Socket address for eOn communication. - **unix_mode** (bool) - Required - Whether to use Unix socket mode. - **mem_in_gb** (int) - Required - Memory allocation in gigabytes. ### Returns - **str** - The generated NWChem input file content. ### Request Example ```python from pychum import render_nwchem from pathlib import Path nwchem_input = render_nwchem( pos_file=Path("molecule.xyz"), settings_path=Path("nwchem.toml"), socket_address="127.0.0.1:8888", unix_mode=False, mem_in_gb=4, ) ``` ``` -------------------------------- ### Example usage of render_orca and render_nwchem Source: https://github.com/haozeke/pychum/blob/main/docs/source/api/pychum.md Shows how to generate ORCA and NWChem input files using the pychum package. The render_orca function takes a TOML configuration file path and returns a string that is written to 'calculation.inp'. The render_nwchem function accepts a position file, settings file, socket address, unix mode flag, and memory in GB to generate input for eOn. ```python from pychum import render_orca, render_nwchem from pathlib import Path # Generate ORCA input orca_input = render_orca(Path("orca_config.toml")) with open("calculation.inp", "w") as f: f.write(orca_input) # Generate NWChem input for eOn nwchem_input = render_nwchem( pos_file=Path("molecule.xyz"), settings_path=Path("nwchem.toml"), socket_address="127.0.0.1:8888", unix_mode=False, mem_in_gb=4, ) ``` -------------------------------- ### Install pre-commit hooks Source: https://github.com/haozeke/pychum/blob/main/CONTRIBUTING.md Installs pre-commit hooks that run automatically on git commit. ```bash uv run pre-commit install ``` -------------------------------- ### NEB TOML configuration Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/tutorial.org TOML configuration for a nudged elastic band (NEB) calculation with ORCA. Specifies functional PBE0, basis def2-SVP, 5 images, reactant and product XYZ files, and IDPP interpolation method. ```toml # neb.toml [calculation] type = "neb" functional = "PBE0" basis = "def2-SVP" n_images = 5 [geometry.reactant] method = "xyz" file = "reactant.xyz" [geometry.product] method = "xyz" file = "product.xyz" [neb] method = "idpp" # IDPP interpolation ``` -------------------------------- ### Example TOML settings for NWChem Source: https://github.com/haozeke/pychum/blob/main/docs/source/api/pychum.engine.eon.md Provides a sample TOML configuration for NWChem with sections for task, theory, DFT functional, basis set, and SCF settings. This file is referenced by NWChemSocketConfig's settings_path. ```toml [nwchem] task = "energy" theory = "dft" [dft] functional = "b3lyp" [basis] type = "6-31g*" [scf] max_iter = 100 ``` -------------------------------- ### NWChemRenderer example usage Source: https://github.com/haozeke/pychum/blob/main/docs/source/api/pychum.engine.eon.md Shows how to create an NWChemRenderer instance with a config object and render an input file from a Jinja template. The render method takes a template filename and returns the rendered string. ```python from pychum.engine.eon import NWChemRenderer renderer = NWChemRenderer(config) nwchem_input = renderer.render("nwchem_socket.jinja") ``` -------------------------------- ### Install pychum with uv add Source: https://github.com/haozeke/pychum/blob/main/docs/source/llms.txt Adds pychum as a dependency using the uv package manager. ```sh uv add pychum ``` -------------------------------- ### NWChemSocketConfig example usage Source: https://github.com/haozeke/pychum/blob/main/docs/source/api/pychum.engine.eon.md Shows how to instantiate NWChemSocketConfig with a list of NWChemAtom objects and settings for a NWChem socket connection. Requires a Path object for settings_path and specifies socket address, unix_mode, and memory in GB. ```python from pychum.engine.eon import NWChemSocketConfig, NWChemAtom atoms = [ NWChemAtom(symbol="O", x=0.0, y=0.0, z=0.0), NWChemAtom(symbol="H", x=0.757, y=0.586, z=0.0), NWChemAtom(symbol="H", x=-0.757, y=0.586, z=0.0), ] config = NWChemSocketConfig( atoms=atoms, settings_path=Path("nwchem.toml"), socket_address="127.0.0.1:8888", unix_mode=False, mem_in_gb=4, ) ``` -------------------------------- ### Single point ORCA TOML configuration Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/tutorial.org TOML configuration for a single point energy calculation with ORCA. Defines engine, units, coordinates (water molecule), and extra SCF block. Units are converted from angstrom to bohr and hartree to hartree. ```toml # single_point.toml [engine] name = "orca" [orca] kwlines = """ !PBE0 def2-SVP """ [units.distance] inp = "angstrom" out = "bohr" [units.energy] inp = "hartree" out = "hartree" [coords] fmt = "xyz" charge = 0 multiplicity = 1 [[coords.atoms]] symbol = "O" x = 0.0 y = 0.0 z = 0.0 [[coords.atoms]] symbol = "H" x = 0.757 y = 0.586 z = 0.0 [[coords.atoms]] symbol = "H" x = -0.757 y = 0.586 z = 0.0 [orca.extra_blocks] scf = """ maxiter 100 """ ``` -------------------------------- ### OrcaInputRenderer usage example Source: https://github.com/haozeke/pychum/blob/main/docs/source/api/pychum.engine.orca.md Renders an ORCA input file from a Jinja2 template using OrcaInputRenderer. The example creates a renderer with a config object and calls render() with the template filename 'base.jinja'. ```python from pychum.engine.orca import OrcaInputRenderer renderer = OrcaInputRenderer(config) orca_input = renderer.render("base.jinja") ``` -------------------------------- ### Clone repository and install in development mode Source: https://github.com/haozeke/pychum/blob/main/CONTRIBUTING.md Clones the pychum repository and installs it in development mode using either uv or pip. Requires Python 3.12+ and Git. ```bash # Clone the repository git clone https://github.com/HaoZeke/pychum cd pychum # Install in development mode uv sync --all-extras # Or with pip pip install -e ".[dev,test,docs]" ``` -------------------------------- ### Add tests for new ORCA block Source: https://github.com/haozeke/pychum/blob/main/CONTRIBUTING.md Example test function for the new ORCA block, placed in tests/test_orca/test_new_block.py. ```python # tests/test_orca/test_new_block.py def test_new_block_generation(): # Test input file generation pass ``` -------------------------------- ### Example TOML configuration Source: https://github.com/haozeke/pychum/blob/main/docs/source/api/pychum.engine.orca.md A sample TOML configuration for ORCA calculations, specifying functional, basis set, coordinates, and SCF settings. Includes three atoms (O and two H) in XYZ format. ```toml [orca] functional = "PBE0" basis = "def2-SVP" [coords] charge = 0 multiplicity = 1 fmt = "xyz" [[coords.atoms]] symbol = "O" x = 0.0 y = 0.0 z = 0.0 [[coords.atoms]] symbol = "H" x = 0.757 y = 0.586 z = 0.0 [[coords.atoms]] symbol = "H" x = -0.757 y = 0.586 z = 0.0 [scf] max_iter = 100 ``` -------------------------------- ### ConfigLoader Source: https://github.com/haozeke/pychum/blob/main/docs/source/api/pychum.engine.orca.md Loads configuration from a TOML file for ORCA engine setup. The constructor takes a file path and the load_config method returns the parsed configuration. ```APIDOC ## ConfigLoader ### Description Loads configuration from a TOML file for ORCA engine setup. The constructor takes a file path and the load_config method returns the parsed configuration. ### Constructor `ConfigLoader(config_path: str)` ### Methods #### load_config() - **Returns**: `OrcaConfig` - The parsed configuration object. ### Example Usage ```python from pychum.engine.orca import ConfigLoader loader = ConfigLoader("config.toml") config = loader.load_config() ``` ``` -------------------------------- ### Create Jinja2 template for new ORCA block Source: https://github.com/haozeke/pychum/blob/main/CONTRIBUTING.md Example Jinja2 template for a new ORCA block, placed in pychum/engine/orca/_blocks/new_block.jinja. ```jinja2 # pychum/engine/orca/_blocks/new_block.jinja %newblock {{ parameter1 }} {{ value1 }} {{ parameter2 }} {{ value2 }} ``` -------------------------------- ### ORCA Input TOML Configuration Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/index.org Example TOML configuration file (input.toml) for generating an ORCA input file. Specifies calculation type, functional, basis set, and geometry source. ```toml # input.toml [calculation] type = "single_point" functional = "PBE0" basis = "def2-SVP" [geometry] method = "xyz" file = "molecule.xyz" ``` -------------------------------- ### Validate TOML configuration with tomllib Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/howto/troubleshooting.org Runs a Python one-liner to validate the TOML syntax of 'input.toml', helping to diagnose the 'Invalid TOML configuration' error. ```bash # Validate TOML python -c "import tomllib; tomllib.load(open('input.toml', 'rb'))" ``` -------------------------------- ### Force reinstall pychum to fix missing template Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/howto/troubleshooting.org Reinstalls pychum with --force-reinstall to restore missing Jinja2 templates that cause the 'Template not found' error. ```bash # Reinstall pychum pip install --force-reinstall pychum ``` -------------------------------- ### Required TOML fields for ORCA input generation Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/howto/troubleshooting.org Shows the required [orca] section with method and basis fields that must be present in the TOML to generate an ORCA input file. ```toml [orca] method = "B3LYP" basis = "def2-SVP" ``` -------------------------------- ### Import ensure_import from rgpycrumbs._aux Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/dev/lazy_imports.org Used to defer loading of optional dependencies until needed. Returns the imported module if available, or attempts to install it when RGPYCRUMBS_AUTO_DEPS is set. ```python from rgpycrumbs._aux import ensure_import ``` -------------------------------- ### Build a distribution with uv Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/release.org Builds the distribution package using uv. ```bash uv build ``` -------------------------------- ### Instantiate ConfigLoader with test TOML Source: https://github.com/haozeke/pychum/blob/main/nb/worklog.md Creates a ConfigLoader instance pointing to the test configuration file opt_scan.toml. ```python aa=ConfigLoader(Path("../tests/test_orca/opt_scan.toml")) ``` -------------------------------- ### Format and lint with ruff Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/dev/contributing.org Format the codebase and run lint checks using ruff. ```bash uv run ruff format . uv run ruff check . ``` -------------------------------- ### Build documentation with Sphinx Source: https://github.com/haozeke/pychum/blob/main/CONTRIBUTING.md Builds the documentation using Sphinx from the docs directory. ```bash cd docs uv run sphinx-build source/ build/ ``` -------------------------------- ### Tag and push a release Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/release.org Steps to cut a release: build the changelog, commit changes, tag with vX.Y.Z, and push the tag. The version is derived from the tag, so the tag name must match the version format. ```bash uvx towncrier build --version X.Y.Z ``` ```bash git tag -a vX.Y.Z -m "Release X.Y.Z" ``` ```bash git push origin vX.Y.Z ``` -------------------------------- ### Add a changelog entry with echo Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/release.org Creates a changelog fragment file in the appropriate subdirectory. The issue number in the filename links to the GitHub issue. ```bash echo "Added NEB restart support" > doc/release/upcoming_changes/added/42.added ``` -------------------------------- ### ConfigLoader initialization Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/dev/input_generation.org Initializes the ConfigLoader with a TOML file path and loads the configuration into dataclasses. ```python from pychum.engine.orca.config_loader import ConfigLoader loader = ConfigLoader("input.toml") config = loader.load_config() ``` -------------------------------- ### Clone and enter the pychum repository Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/dev/contributing.org Clone the repository from your fork and change into the project directory. ```bash git clone https://github.com/your-username/pychum cd pychum ``` -------------------------------- ### Instantiate OrcaInputRenderer Source: https://github.com/haozeke/pychum/blob/main/nb/worklog.md Creates an OrcaInputRenderer instance using the loaded configuration. ```python ac=OrcaInputRenderer(ab) ``` -------------------------------- ### Configure hatchling build backend in pyproject.toml Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/release.org Sets hatchling as the build backend with hatch-vcs and hatchling as required dependencies. ```toml [build-system] build-backend = "hatchling.build" requires = ["hatch-vcs", "hatchling"] ``` -------------------------------- ### Render NWChem input with NWChemRenderer and NWChemSocketConfig Source: https://github.com/haozeke/pychum/blob/main/docs/source/api/index.md Shows how to read a geometry with ASE, create an NWChem socket configuration, and render an NWChem input file using the eon engine's renderer. ```python from pychum.engine.eon import NWChemRenderer, NWChemSocketConfig from ase.io import read # Read geometry atoms = read("geometry.xyz") # Create NWChem socket config nw_config = NWChemSocketConfig( atoms=[...], # List of NWChemAtom settings_path=Path("settings.toml"), socket_address="127.0.0.1:8888", unix_mode=False, mem_in_gb=4, ) # Render NWChem input renderer = NWChemRenderer(nw_config) nwchem_input = renderer.render("nwchem_socket.jinja") ``` -------------------------------- ### Run pychum CLI help Source: https://github.com/haozeke/pychum/blob/main/readme_src.org Shows how to invoke the pychum command-line interface to display its help. Two equivalent commands are provided: one using `uv run` and one using `python -m pychum.cli`. ```bash uv run pychum --help # Or alternatively python -m pychum.cli --help ``` -------------------------------- ### Run tests with pytest Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/dev/contributing.org Execute the test suite using uv run pytest. ```bash uv run pytest ``` -------------------------------- ### Configure hatch-vcs versioning in pyproject.toml Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/release.org Sets up VCS-based versioning with hatch-vcs, writing the version string to _version.py at build time. No manual version field is needed. ```toml [tool.hatch.version] source = "vcs" [tool.hatch.build.hooks.vcs] version-file = "_version.py" ``` -------------------------------- ### Build changelog with towncrier Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/release.org Collects all fragment files, generates a formatted section in CHANGELOG.md, and removes the consumed fragments. Use the version number as X.Y.Z. ```bash uvx towncrier build --version X.Y.Z ``` -------------------------------- ### Load ORCA config and render input with ConfigLoader and OrcaInputRenderer Source: https://github.com/haozeke/pychum/blob/main/docs/source/api/index.md Demonstrates using the ORCA engine's ConfigLoader to load a TOML configuration and OrcaInputRenderer to render an input file from a Jinja template. ```python from pychum.engine.orca import ConfigLoader, OrcaInputRenderer # Load configuration from TOML loader = ConfigLoader("config.toml") config = loader.load_config() # Render ORCA input renderer = OrcaInputRenderer(config) orca_input = renderer.render("base.jinja") ``` -------------------------------- ### Run Tests with Coverage Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/testing.org Command to run tests with coverage reporting for the pychum package. ```bash uv run pytest --cov=pychum tests ``` -------------------------------- ### Load configuration Source: https://github.com/haozeke/pychum/blob/main/nb/worklog.md Calls load_config() on the ConfigLoader instance to parse the TOML file. ```python ab=aa.load_config() ``` -------------------------------- ### CI Matrix Strategy for Python Versions Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/testing.org YAML snippet from build_test.yml defining the Python version matrix for testing. ```yaml strategy: matrix: python-version: ["3.10", "3.11", "3.12"] ``` -------------------------------- ### Test Directory Structure Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/testing.org Shows the layout of the tests directory, focusing on ORCA engine rendering tests. ```text tests/ └── orca/ ├── test_coord.py # Coordinate rendering (xyz, int, gzmt, file refs) ├── test_neb.py # NEB block rendering ├── test_geom_scan.py # Geometry scan block rendering └── test_extra.py # Extra blocks rendering (uses datadir) ``` -------------------------------- ### Render ORCA and NWChem inputs from TOML config Source: https://github.com/haozeke/pychum/blob/main/docs/source/api/index.md Shows the main entry points for rendering ORCA and NWChem input files. Requires a TOML config for ORCA and geometry/settings files for NWChem, with optional socket address and memory settings. ```python from pychum import render_orca, render_nwchem from pathlib import Path # Render ORCA input from TOML config orca_input = render_orca(Path("config.toml")) # Render NWChem input for eOn socket nwchem_input = render_nwchem( pos_file=Path("geometry.xyz"), settings_path=Path("nwchem_settings.toml"), socket_address="127.0.0.1:8888", unix_mode=False, mem_in_gb=4, ) ``` -------------------------------- ### Build readme from org source Source: https://github.com/haozeke/pychum/blob/main/readme_src.org Converts the org-mode readme source to markdown using the provided script. ```bash ./scripts/org_to_md.sh readme_src.org readme.md ``` -------------------------------- ### Import Orca renderer and config loader Source: https://github.com/haozeke/pychum/blob/main/nb/worklog.md Imports the OrcaInputRenderer and ConfigLoader classes along with pprint and Path for use in the worklog. ```python from pprint import pprint as pp from pathlib import Path from pychum.engine.orca._renderer import OrcaInputRenderer from pychum.engine.orca.config_loader import ConfigLoader ``` -------------------------------- ### Manual linting and type checking Source: https://github.com/haozeke/pychum/blob/main/CONTRIBUTING.md Formats code with ruff, lints with ruff check, and runs mypy for static type checking. ```bash # Format code uv run ruff format . # Lint code uv run ruff check . # Type checking uv run mypy pychum/ ``` -------------------------------- ### Render base.jinja template Source: https://github.com/haozeke/pychum/blob/main/nb/worklog.md Renders the 'base.jinja' template using the renderer and prints the output. ```python print(ac.render('base.jinja')) ``` -------------------------------- ### Coordinate Test Render Helper Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/testing.org Helper function in test_coord.py that builds a Coords and OrcaConfig, then renders coord.jinja. ```python # test_coord.py def render_config(atoms, coord_type="xyz", charge=0, multiplicity=1): coords = Coords(charge=charge, multiplicity=multiplicity, atoms=atoms, fmt=coord_type) config = OrcaConfig(coords=coords, kwlines=default_kwline) renderer = OrcaInputRenderer(config) return renderer.render("coord.jinja") ``` -------------------------------- ### Issue link template for changelog Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/release.org Format used by towncrier to link changelog entries to GitHub issues. ```text [#42](https://github.com/HaoZeke/pychum/issues/42) ``` -------------------------------- ### render_nwchem(pos_file, settings_path, ...) Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/index.org Generates an NWChem socket input file for eOn's SocketNWChemPot. This is part of the public API in pychum.main. ```APIDOC ## render_nwchem(pos_file, settings_path, ...) ### Description Generates an NWChem socket input file for eOn's SocketNWChemPot. ### Parameters - **pos_file** (string) - Required - Path to the position file. - **settings_path** (string) - Required - Path to the settings file. - **...** - Additional parameters (not specified). ### Returns - **string** - The generated NWChem socket input file content. ``` -------------------------------- ### Engine directory structure Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/dev/contributing.org Shows the required file layout for a new engine under pychum/engine//. ```text pychum/engine// |-- __init__.py |-- _dataclasses.py |-- _renderer.py `-- test_renderer.py ``` -------------------------------- ### Generate ORCA input files with pychum orca Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/howto/faq.org Generate ORCA input files using the pychum orca command with a TOML configuration file. ```bash pychum orca --config input.toml ``` -------------------------------- ### Generate eOn input files with pychum eon Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/howto/faq.org Generate eOn input files using the pychum eon command with a TOML configuration file. ```bash pychum eon --config input.toml ``` -------------------------------- ### Run tests with pytest Source: https://github.com/haozeke/pychum/blob/main/CONTRIBUTING.md Runs all tests, specific test categories (unit, integration), or with coverage using uv run pytest. ```bash # Run all tests uv run pytest # Run specific test categories uv run pytest -m unit uv run pytest -m integration # Run with coverage uv run pytest --cov=pychum --cov-report=html ``` -------------------------------- ### Create feature branch Source: https://github.com/haozeke/pychum/blob/main/CONTRIBUTING.md Creates a new branch from main for a feature. ```bash git checkout -b feature/your-feature-name ``` -------------------------------- ### Display raw config data Source: https://github.com/haozeke/pychum/blob/main/nb/worklog.md Outputs the raw data attribute of the ConfigLoader instance. ```python aa.data ``` -------------------------------- ### Package Structure Tree Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/index.org Text representation of the pychum package directory structure, showing main modules and engine-specific generators for ORCA and eOn/NWChem. ```text pychum/ ├── main.py # Public API (render_orca, render_nwchem) ├── _base.py # Abstract base class ├── units.py # deprecation stub; use chemparseplot.units └── engine/ # Engine-specific generators ├── orca/ # ORCA input generation │ ├── config_loader.py # TOML loading │ ├── _renderer.py # Jinja2 rendering │ ├── _dataclasses.py # Configuration dataclasses │ └── _blocks/ # Jinja2 templates └── eon/ # eOn/NWChem input generation ├── _renderer.py # NWChem rendering └── _dataclasses.py # NWChem dataclasses ``` -------------------------------- ### render_orca(toml_path) Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/index.org Loads a TOML configuration and returns an ORCA input string. This is part of the public API in pychum.main. ```APIDOC ## render_orca(toml_path) ### Description Loads a TOML configuration and returns an ORCA input string. ### Parameters - **toml_path** (string) - Required - Path to the TOML configuration file. ### Returns - **string** - The generated ORCA input string. ``` -------------------------------- ### Geometry scan loading Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/dev/input_generation.org Converts TOML arrays of bond/angle/dihedral definitions into GeomScan dataclass lists. ```python bonds = [GeomScan(**bond) for bond in geom_data.get("bonds", [])] ``` -------------------------------- ### Pipeline flow diagram Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/dev/input_generation.org Shows the three-stage pipeline: TOML configuration is parsed into dataclasses, then rendered into engine-specific input text. ```text TOML file --> ConfigLoader --> dataclasses --> Renderer --> input string ``` -------------------------------- ### NWChemSocketConfig Source: https://github.com/haozeke/pychum/blob/main/docs/source/api/index.md Configuration for NWChem socket communication. This class is part of the EON engine and holds the parameters needed for rendering NWChem input. ```APIDOC ## NWChemSocketConfig ### Description Configuration for NWChem socket communication. ### Method Class instantiation ### Endpoint `NWChemSocketConfig(atoms, settings_path, socket_address, unix_mode, mem_in_gb)` ### Parameters - **atoms** (list) - Required - List of NWChemAtom objects. - **settings_path** (Path) - Required - Path to the settings TOML file. - **socket_address** (str) - Required - Socket address for eOn communication. - **unix_mode** (bool) - Required - Whether to use Unix socket mode. - **mem_in_gb** (int) - Required - Memory allocation in GB. ### Request Example ```python from pychum.engine.eon import NWChemSocketConfig from pathlib import Path nw_config = NWChemSocketConfig( atoms=[...], # List of NWChemAtom settings_path=Path("settings.toml"), socket_address="127.0.0.1:8888", unix_mode=False, mem_in_gb=4, ) ``` ``` -------------------------------- ### Rendering with OrcaInputRenderer Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/dev/input_generation.org Renders an OrcaConfig through Jinja2 templates using the render method, which post-processes by collapsing double newlines. ```python renderer = OrcaInputRenderer(config) output = renderer.render("base.jinja") ``` -------------------------------- ### Gaussian Z-matrix format output Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/dev/template_system.org Output format for the render_gzmt_atom(atom) macro in coord.jinja for Gaussian-style Z-matrix where connectivity is built incrementally. Fields are only included when the corresponding atom index is not None. ```text O C 1 1.2078 H 2 1.1161 1 121.74 H 2 1.1161 1 121.74 3 180 ``` -------------------------------- ### Render template with context and collapse double newlines Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/dev/template_system.org Used in the rendering flow to load a template by name, build a context dict with the config dataclass under the "config" key, render it, and for ORCA collapse double newlines to single. ```python def render(self, template_name: str): template = self.env.get_template(template_name) context = {"config": self.config} return template.render(context).replace("\n\n", "\n") ``` -------------------------------- ### XYZ coordinate format output Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/dev/template_system.org Output format for the render_atom(atom) macro in coord.jinja for Cartesian coordinates. ```text SYMBOL x y z ``` -------------------------------- ### Ecosystem Overview Diagram (DOT) Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/index.org Graphviz DOT diagram showing the ecosystem relationships among pychum, rgpycrumbs, chemparseplot, readcon-core, eOn, and ORCA. Used to visualize how pychum generates inputs and chemparseplot parses outputs. ```dot digraph G { rankdir=LR; fontname="Jost"; node [shape=box, style=filled, fontname="Jost", fontsize=12, fillcolor="white", color="#004D40", fontcolor="#004D40"]; edge [fontname="Jost", fontsize=11, color="#004D40", fontcolor="#004D40"]; compound=true; rgpycrumbs [label="rgpycrumbs\n(Core Utilities & Dispatcher)", fillcolor="#F1DB4B"]; pychum [label="pychum\n(Input Generation)", fillcolor="#FF655D", fontcolor="white", penwidth=3]; chemparseplot [label="chemparseplot\n(Parsers & Plotting)"]; readcon [label="readcon-core\n(CON / convel I/O)", URL="https://github.com/lode-org/readcon-core"]; eon [label="eOn"]; orca [label="ORCA"]; rgpycrumbs -> pychum [label="dispatches to"]; rgpycrumbs -> chemparseplot [label="dispatches to"]; chemparseplot -> rgpycrumbs [label="imports from"]; pychum -> rgpycrumbs [label="imports from"]; chemparseplot -> readcon [label="CON frames"]; pychum -> eon [label="generates input for", style=dashed]; pychum -> orca [label="generates input for", style=dashed]; chemparseplot -> eon [label="parses output from", style=dashed]; chemparseplot -> orca [label="parses output from", style=dashed]; eon -> readcon [label="writes CON", style=dashed]; rgpycrumbs -> eon [label="manages / visualizes"]; } ``` -------------------------------- ### Internal coordinate format output Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/dev/template_system.org Output format for the render_int_atom(atom) macro in coord.jinja for Z-matrix format with bond atom indices and internal coordinate values. ```text SYMBOL bond_atom angle_atom dihedral_atom bond_length angle dihedral ``` -------------------------------- ### NWChemSocketConfig Source: https://github.com/haozeke/pychum/blob/main/docs/source/api/pychum.engine.eon.md Configuration class for NWChem socket communication. It holds atom data, settings path, socket address, and memory settings for the NWChem engine. ```APIDOC ## NWChemSocketConfig ### Description Configuration class for NWChem socket communication. It holds atom data, settings path, socket address, and memory settings for the NWChem engine. ### Constructor Parameters - **atoms** (list of NWChemAtom) - Required - List of atoms for the molecular system. - **settings_path** (Path) - Required - Path to the TOML settings file. - **socket_address** (str) - Required - Socket address for communication (e.g., "127.0.0.1:8888"). - **unix_mode** (bool) - Required - Whether to use Unix socket mode. - **mem_in_gb** (int) - Required - Memory allocation in gigabytes. ### Request Example ```python from pychum.engine.eon import NWChemSocketConfig, NWChemAtom atoms = [ NWChemAtom(symbol="O", x=0.0, y=0.0, z=0.0), NWChemAtom(symbol="H", x=0.757, y=0.586, z=0.0), NWChemAtom(symbol="H", x=-0.757, y=0.586, z=0.0), ] config = NWChemSocketConfig( atoms=atoms, settings_path=Path("nwchem.toml"), socket_address="127.0.0.1:8888", unix_mode=False, mem_in_gb=4, ) ``` ``` -------------------------------- ### NEB sub-block loading Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/dev/input_generation.org Pops recognized sub-keys from the NEB dictionary and converts them to settings dataclasses. Leftover top-level fields are merged and passed to NebBlock. ```python if "optim" in neb_data: neb_block_args["optim_settings"] = OptimSettings(**neb_data.pop("optim")) if "lbfgs" in neb_data: neb_block_args["lbfgs_settings"] = LBFGSSettings(**neb_data.pop("lbfgs")) ``` -------------------------------- ### Test lazy imports in CI workflow Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/dev/lazy_imports.org CI test in ci_tutorials.yml that verifies ensure_import works by importing numpy and checking its array attribute. ```yaml - name: Test lazy imports run: | uv run python3 -c " from rgpycrumbs._aux import ensure_import np = ensure_import('numpy') assert hasattr(np, 'array'), 'numpy import failed' " ``` -------------------------------- ### Convert units with chemparseplot.units Source: https://github.com/haozeke/pychum/blob/main/docs/source/api/index.md Shows how to use chemparseplot.units for physical unit conversion, as pychum does not own unit conversion. Demonstrates converting distance and energy to different units. ```python from chemparseplot.units import ureg # Convert distance distance = 1.5 * ureg.angstrom print(distance.to(ureg.bohr)) # 2.8346 bohr # Convert energy energy = -76.0 * ureg.hartree print(energy.to(ureg.kcal / ureg.mol)) # -47690.7 kcal/mol ``` -------------------------------- ### TOML extra_blocks configuration Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/dev/orca_blocks.org Specifies arbitrary ORCA blocks as plain strings under [orca.extra_blocks]. Rendered as-is without template processing. ```toml [orca.extra_blocks] scf = "maxiter 300" ``` -------------------------------- ### Ensure all checks pass before pull request Source: https://github.com/haozeke/pychum/blob/main/CONTRIBUTING.md Runs pytest, ruff check, and mypy to verify code quality before submitting a pull request. ```bash uv run pytest uv run ruff check . uv run mypy pychum/ ``` -------------------------------- ### base.jinja template structure Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/dev/orca_blocks.org Top-level orchestrator for ORCA input files. Renders keyword lines, extra blocks, dynamic block inclusion, and coordinate block. Adding a new block type requires a new .jinja template and a corresponding entry in config.blocks. ```text {{ config.kwlines }} {% for block_name, block_content in config.extra_blocks.items() %} %{{ block_name }} {{ block_content }} end {% endfor %} {% for block_name, block_data in config.blocks.items() %} {% include block_name + ".jinja" %} {% endfor %} {% include "coord.jinja" %} ``` -------------------------------- ### Rendered extra block output Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/dev/orca_blocks.org Output produced by the extra_blocks mechanism for the given TOML configuration. ```text %scf maxiter 300 end ``` -------------------------------- ### geom_scan.jinja scan coordinate format Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/dev/orca_blocks.org Format for defining scan coordinates in the Scan sub-block within %geom. Handles bonds (B), angles (A), and dihedrals (D). A guard limits total scans to 3; more than 3 emits an error message. ```text B atom1 atom2 = start, end, npoints A atom1 atom2 atom3 = start, end, npoints D atom1 atom2 atom3 atom4 = start, end, npoints ``` -------------------------------- ### NWChemAtom Source: https://github.com/haozeke/pychum/blob/main/docs/source/api/pychum.engine.eon.md Represents an atom with symbol and Cartesian coordinates for use in NWChem configurations. ```APIDOC ## NWChemAtom ### Description Represents an atom with symbol and Cartesian coordinates for use in NWChem configurations. ### Constructor Parameters - **symbol** (str) - Required - Chemical element symbol. - **x** (float) - Required - X coordinate. - **y** (float) - Required - Y coordinate. - **z** (float) - Required - Z coordinate. ``` -------------------------------- ### Add dataclass for new ORCA block Source: https://github.com/haozeke/pychum/blob/main/CONTRIBUTING.md Dataclass definition for a new ORCA block, placed in pychum/engine/orca/dataclasses/new_block.py. ```python # pychum/engine/orca/dataclasses/new_block.py from dataclasses import dataclass @dataclass class NewBlock: parameter1: str value1: float parameter2: str value2: int ``` -------------------------------- ### BlockType enum and OrcaBlock abstract base class Source: https://github.com/haozeke/pychum/blob/main/docs/orgmode/dev/dataclasses.org Defines the BlockType enum and the abstract base class OrcaBlock. Concrete blocks like NebBlock and GeomBlock must implement block_type() returning a BlockType value. ```python class BlockType(Enum): NEB = "neb" GEOM = "geom" class OrcaBlock(ABC): @abstractmethod def block_type(self) -> BlockType: pass ```