Skip to main content

PatchSim

Release status: PatchSim follows semantic versioning. Before 1.0, minor releases may contain breaking API or configuration changes.

PatchSim Banner

PatchSim is a modular metapopulation simulation framework for multi-disease epidemiological modelling.

Documentation | GitHub repository


Vision

To develop a general-purpose, modular simulation framework for patch-based metapopulation epidemiology, enabling modellers and researchers to simulate disease transmission under diverse scenarios, diseases, and intervention strategies. The framework balances robust scientific modelling with flexibility for exploratory research and translational use cases.


Unique Selling Point (USP)

PatchSim combines metapopulation network dynamics with a lightweight, configuration-first workflow:

  • Network-aware compartment transitions across connected patches
  • Arrow-map transition syntax in YAML for explicit model specification
  • Fast iteration loop from config edits to reproducible outputs

Unique Value Proposition (UVP)

Compared to many epidemiology tools that are either code-heavy or tightly bound to a specific disease model, PatchSim offers:

  • Model flexibility: define SIR/SIRS-style variants through config transitions
  • Research-friendly reproducibility: deterministic inputs, logged runs, and versioned config files
  • Dual interface: SDK import for programmatic workflows and CLI for operational runs
  • Extensibility path: built-in structure for adding custom models and project templates

Core Features

PatchSim aims to support a range of modelling features commonly used in metapopulation disease simulations:

  • 🗺️ Spatial Networks: Represent geographical units (e.g., subdistricts, regions) as interconnected patches with movement/contact matrices.
  • 👥 Stratification by Population Attributes: Use a generic group axis for age, species, behavioural risk, occupation, or another categorical partition, with an explicitly supplied interaction matrix.
  • 🧪 Disease Agnostic Compartment Models:
    • SIR, SEIR, SIRS and extensions
    • Supports both discrete timestep and ODE-based solvers
  • 🛠️ Scenario and Parameter Management:
    • First-order and total-order Sobol sensitivity analysis for bounded global parameters
    • Compact samples, responses, indices, and provenance artifacts
  • 🧵 Reproducibility:
    • Seeded sensitivity sampling and confidence intervals
    • Input hashes and method versions in sensitivity manifests
  • 📦 Modularity:
    • Built-in ODE and discrete solvers consume the same validated spatial network format

Installation

Install from PyPI:

pip install patchsim

Sensitivity analysis uses an optional dependency:

pip install "patchsim[analysis]"

Install from source using uv:

# Clone the repository
git clone https://github.com/dsih-artpark/patchsim
cd patchsim

# Create a virtual environment and install dependencies
uv venv
source .venv/bin/activate
uv pip install -e .

# For development (with dev dependencies)
uv pip install -e .[dev]

Usage

Command Line Interface

PatchSim provides a subcommand-based CLI. Always run using uv run to ensure correct dependency resolution:

# Show help and available options
uv run patchsim --help

# Show package version
uv run patchsim --version

# Initialize a new self-contained project
uv run patchsim init my-project

# Initialize with a starter template
uv run patchsim init my-project --template seir

# Validate config without running
uv run patchsim validate -c my-project/config.yaml

# Print the JSON Schema for configs
uv run patchsim validate --schema

# Emit machine-readable JSON output
uv run patchsim validate -c my-project/config.yaml --json

# Run simulation
uv run patchsim run -c my-project/config.yaml

# Run and emit machine-readable JSON output
uv run patchsim run -c my-project/config.yaml --json

# Run or reuse a configured Sobol sensitivity study
uv run patchsim sensitivity -c my-project/config.yaml

# Run or reuse a configured bounded calibration study
uv run patchsim calibrate -c my-project/config.yaml

# List built-in model references and YAML templates
uv run patchsim list-models

# List models as JSON
uv run patchsim list-models --json

Python SDK

import patchsim

config = patchsim.load_config("config.yaml")
frame = patchsim.simulate(config, parameter_overrides={"beta": 0.08})

# A configured built-in fit writes verified study artifacts
summary = patchsim.run_calibration("config.yaml")

simulate returns the configured time series without writing files or mutating the loaded config. It is the integration point for external fitting code.

Configuration

YAML configuration defines model parameters, transition expressions, input files, solver settings, and output location. See the configuration reference and the worked simulation, sensitivity, and calibration workflow.


Contributing

We welcome contributions!

To contribute: fork the repo, create a branch, make your changes, and open a pull request.
For major changes, please open an issue first to discuss.

Thanks for helping improve the framework!

License

This project is licensed under the GNU General Public License v3.0.

License: GPL v3

You may use, modify, and share this project under the same license terms. See the LICENSE file for full details.

Release files for patchsim 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for patchsim 0.1.0
File Size Uploaded
patchsim-0.1.0.tar.gz 73.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for patchsim 0.1.0
File Interpreter ABI Platform
patchsim-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 149.7 kB

Release files / patchsim-0.1.0.tar.gz

Download URL patchsim-0.1.0.tar.gz
Size 73.5 kB
Tags Source
SHA-256 checksum
How to use checksums
173c15eff6dd7bc5304f66c5a563d175b6c1da467a08d7df593d34a35116841e
BLAKE2b-256 checksum
How to use checksums
1d1d6a317cf02ce9a15fce034fbe884117a8742c7a0ef5d5fb908cef5496ba74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 21, 2026.

Transparency log

Release files / patchsim-0.1.0-py3-none-any.whl

Download URL patchsim-0.1.0-py3-none-any.whl
Size 76.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ab68e42c0fd2e5b04ce9ef84aea6e953cce8707ac183a407fc50a06b3b0b9700
BLAKE2b-256 checksum
How to use checksums
4a315f43f482194ce5bc632f342cfd7b8fa27b4c5e8f456b3428e7733146ba3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 21, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.1

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page