CLI Reference#
Command-line interface reference for PatchSim.
Overview#
patchsim [COMMAND] [OPTIONS]
Available commands:
init– Scaffold a new projectrun– Execute a simulationvalidate– Check configuration and inputslist-models– Show available templates--version– Display version
init#
Initialize a new PatchSim project with starter files.
Usage#
patchsim init PROJECT_NAME [--template TEMPLATE] [--force]
Arguments#
Argument |
Required |
Description |
|---|---|---|
|
Yes |
Directory name for the new project |
Options#
Option |
Default |
Description |
|---|---|---|
|
|
Starter model template: |
|
- |
Overwrite target directory if it already exists |
Examples#
# Create a new SIR project (default)
patchsim init my-project
# Create with SEIR template
patchsim init my-project --template seir
# Overwrite existing directory
patchsim init my-project --force
Output#
Creates a directory with:
config.yaml # Model configuration
data/
patch/ # Patch population files
seeds/ # Initial conditions
networks/ # Network topology (if multi-patch)
output/ # (Empty until run)
validate#
Validate configuration file and input data for consistency.
Usage#
patchsim validate [-c CONFIG] [--schema] [--json]
Options#
Option |
Required |
Description |
|---|---|---|
|
Conditional* |
Path to config YAML file |
|
- |
Print the configuration JSON Schema |
|
- |
Output validation results as JSON |
*Required unless --schema is used.
Examples#
# Validate a configuration file
patchsim validate -c config.yaml
# Print the JSON Schema for config files
patchsim validate --schema
# Validate and output JSON
patchsim validate -c config.yaml --json
Output (Plain Text)#
Configuration is valid: config.yaml
Output (JSON)#
{
"ok": true,
"config": "config.yaml",
"model_name": "sample-sir-ode",
"num_patches": 1,
"patches": ["PatchA"]
}
Validation Checks#
All required fields present (see Configuration)
Compartments defined and non-empty
Transitions use valid compartments and parameters
Patch file exists and is readable
Seed file has correct structure
Compartments match seed file columns
Seed values sum to patch population
Network file (if provided) is consistent
run#
Execute a simulation and generate outputs.
Usage#
patchsim run -c CONFIG [--json]
Options#
Option |
Required |
Description |
|---|---|---|
|
Yes |
Path to configuration YAML file |
|
- |
Output run summary as JSON |
Examples#
# Run a simulation
patchsim run -c config.yaml
# Run and capture output as JSON
patchsim run -c config.yaml --json
Output (Plain Text)#
Starting PatchSim simulation...
Model: sample-sir-ode
Parameters: beta=0.5, gamma=0.1
Simulation completed successfully.
Output (JSON)#
{
"ok": true,
"config": "config.yaml",
"model_name": "sample-sir-ode",
"output_dir": "output",
"csv_path": "output/runs/all_patches_sample-sir-ode_ode.csv",
"plot_path": "output/plots/patch_timeseries_sample-sir-ode_ode.png",
"num_patches": 1,
"patches": ["PatchA"],
"t_max": 100
}
Output Files#
Generates in OutputDir (from config):
File |
Description |
|---|---|
|
Time series data (time + all compartments) |
|
Line plot of all compartments over time |
|
Simulation log (detailed diagnostics) |
See Results for output format details.
list-models#
Display available starter templates.
Usage#
patchsim list-models [--json]
Options#
Option |
Description |
|---|---|
|
Output model list as JSON |
Examples#
# List available templates
patchsim list-models
# Output as JSON
patchsim list-models --json
Output (Plain Text)#
Built-in models and templates:
- seir (yaml-template)
- sir (yaml-template)
- sirs (yaml-template)
- sis (yaml-template)
Output (JSON)#
{
"models": [
{"name": "seir", "kind": "yaml-template"},
{"name": "sir", "kind": "yaml-template"},
{"name": "sirs", "kind": "yaml-template"},
{"name": "sis", "kind": "yaml-template"}
]
}
Global Options#
--version#
Display the installed PatchSim version.
patchsim --version
Output:
patchsim 0.1.0b1
Common Errors and Solutions#
Error |
Cause |
Solution |
|---|---|---|
|
Seed file columns don’t match config |
Update seed file or config compartments |
|
Typo in transition rate |
Check parameter/compartment names in config |
|
Target directory exists |
Use |
|
Config missing field (e.g., |
See Configuration for required fields |
|
Seed values don’t sum to population |
Fix seed file CSV |