Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
f640da1
Add CLI for generating datasets
sgreenbury Mar 5, 2026
6524aa5
Refactor with configs
sgreenbury Mar 6, 2026
b1376f7
Add configs
sgreenbury Mar 6, 2026
bb0c41d
Add base class
sgreenbury Mar 6, 2026
c81b434
Add list subcommand
sgreenbury Mar 6, 2026
2252870
Update base class to SpatioTemporalSimulator
sgreenbury Mar 6, 2026
bd5e774
Refactor CLI to ensure inheritance from SpatioTemporalSimulator
sgreenbury Mar 6, 2026
3a95f95
Add optional stratification
sgreenbury Mar 6, 2026
a08534e
Remove obsolete protocol
sgreenbury Mar 6, 2026
d80255f
Refactor to prevent circular imports
sgreenbury Mar 6, 2026
e6d580d
Add initial additiona GPE configs
sgreenbury Mar 6, 2026
fab715a
Update advection-diffusion to output subset of channels
sgreenbury Mar 6, 2026
75e7744
Update GPE and SWE configs
sgreenbury Mar 6, 2026
5a82165
Update README
sgreenbury Mar 6, 2026
feca860
Add `__init__`s
sgreenbury Mar 6, 2026
92c48ff
Update gitignore
sgreenbury Mar 6, 2026
845dfb2
Fix type of skip_nt
sgreenbury Mar 6, 2026
dcfd827
Update output_dir
sgreenbury Mar 6, 2026
51bd3db
Add optional visualisation outputs
sgreenbury Mar 6, 2026
c27b406
Fix UUID generation to use cache
sgreenbury Mar 6, 2026
4b66d03
Update default
sgreenbury Mar 6, 2026
bb25dfd
Add default seed, remove run namespace
sgreenbury Mar 6, 2026
9de1021
Use explicit output names in visualizations
sgreenbury Mar 7, 2026
d049144
Add skip_nt option to shallow water simulator
sgreenbury Mar 7, 2026
3fa81eb
Remove output channel names and SWE initial test
sgreenbury Mar 7, 2026
7096f56
Update defaults
sgreenbury Mar 7, 2026
7199721
Update high complexity config
sgreenbury Mar 7, 2026
2c4a924
Update default GPE
sgreenbury Mar 7, 2026
76cae92
Update GPE configs
sgreenbury Mar 7, 2026
72d3b93
Update conditioned Navier-Stokes 2D config
sgreenbury Mar 7, 2026
abc443a
Limit output_indices to first channel
sgreenbury Mar 7, 2026
b2efcda
Add ReactionDiffusion to experimental package
sgreenbury Mar 7, 2026
6ca585d
Add reaction and advection notebooks
sgreenbury Mar 7, 2026
50e49c9
Update reaction and advection configs
sgreenbury Mar 7, 2026
16c455f
Update config for Gray-Scott
sgreenbury Mar 7, 2026
7bb03db
Update LB config
sgreenbury Mar 7, 2026
fe2e95a
Save resolved config
sgreenbury Mar 7, 2026
09878cb
Update configs to 321 frames per trajectory
sgreenbury Mar 7, 2026
7b14b81
Increase lower bound on amp
sgreenbury Mar 7, 2026
bd5ac31
Add index and sources for torch
sgreenbury Mar 7, 2026
617258d
Update lock
sgreenbury Mar 7, 2026
fafca4e
Add API to support exact n samples
sgreenbury Mar 8, 2026
f086dd4
Add saturation fraction checks and failure handling in simulate_swe_2d
sgreenbury Mar 8, 2026
6fe940f
Fix pre-commit and update re-exports
sgreenbury Mar 9, 2026
b780c79
Fix tests
sgreenbury Mar 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,9 @@ cython_debug/
marimo/_static/
marimo/_lsp/
__marimo__/

# Outputs
outputs/

# .DS_Store
.DS_Store
96 changes: 89 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,10 @@ curl -LsSf https://astral.sh/uv/install.sh | sh
uv pip install -e .
```

This installs `autosim` in editable mode along with its runtime dependencies:
- `numpy>=1.24`
- `scipy>=1.10`
- `tqdm>=4.65`
- `torch>=2.0`

### Install development dependencies (includes pytest)

```bash
uv sync --group dev
uv sync --extra dev
```

## Running tests
Expand All @@ -36,3 +30,91 @@ Once dev dependencies are installed:
```bash
uv run pytest
```

## Generate training data (Hydra CLI)

Use the tiny CLI to generate train/valid/test splits from any simulator that
inherits `SpatioTemporalSimulator`:

```bash
uv run autosim
```

List available simulator configs:

```bash
uv run autosim list
```

Simulator defaults now live in package configs under
`src/autosim/configs/simulator` and can be selected via config groups.

Available simulator config names:
`advection_diffusion`, `advection_diffusion_multichannel`, `compressible_fluid_2d`,
`conditioned_navier_stokes_2d`, `epidemic`, `flow_problem`, `gray_scott`,
`gross_pitaevskii_equation_2d`, `hydrodynamics_2d`, `lattice_boltzmann`,
`projectile`, `projectile_multioutput`, `reaction_diffusion`, `seir_simulator`,
`shallow_water2d`.

Override simulator and dataset settings from the command line via Hydra:

```bash
uv run autosim \
simulator=shallow_water2d \
simulator.nx=32 \
simulator.ny=32 \
simulator.T=10.0 \
dataset.n_train=50 dataset.n_valid=10 dataset.n_test=10 \
dataset.output_dir=examples/experimental/generated_datasets/shallow_water_small \
seed=123 overwrite=true
```

Use a faster built-in simulator config:

```bash
uv run autosim \
simulator=advection_diffusion \
simulator.n=16 simulator.T=0.2 simulator.dt=0.1 \
dataset.n_train=1 dataset.n_valid=1 dataset.n_test=1
```

Optionally save example rollout videos for selected batch indices after generation:

```bash
uv run autosim \
simulator=advection_diffusion_multichannel \
dataset.n_train=4 dataset.n_valid=1 dataset.n_test=1 \
visualize.enabled=true \
visualize.split=train \
visualize.batch_indices=[0,2] \
visualize.file_ext=gif
```

By default videos are written under
`<dataset.output_dir>/examples/<split>/batch_<idx>.<ext>`.
Use `visualize.file_ext=mp4` if ffmpeg is available.

Generate one combined dataset from ordered strata values (single sweep key):

```bash
uv run autosim \
simulator=gray_scott \
stratify.enabled=true \
stratify.key=simulator.pattern \
stratify.values=[gliders,bubbles,maze,worms,spirals,spots] \
dataset.n_train=240 dataset.n_valid=24 dataset.n_test=24 \
dataset.output_dir=outputs/gray_scott_combined
```

When stratification is enabled, each split size is divided equally across strata,
and results are concatenated in the exact order of `stratify.values`.
If a split size is not divisible by the number of strata, an error is raised.

Bring your own simulator subclass (no registry needed):

```bash
uv run autosim \
simulator._target_=my_package.my_module.MySimulator \
++simulator.my_arg=42 \
simulator.log_level=warning
```
2 changes: 2 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ These simulation families are organized from foundational pattern dynamics to in

### Pattern-formation families

- [Reaction-Diffusion](experimental/00_00_reaction_diffusion.ipynb): A spectral (FFT-based) two-species reaction-diffusion generator that produces diverse spatiotemporal patterns — spirals, spots, and labyrinthine textures — across reaction and diffusion parameter regimes.
- [Gray-Scott](experimental/00_01_gray_scott.ipynb): A spectral ETDRK4 reaction-diffusion generator that spans diverse morphologies (spots, spirals, worms, and maze-like regimes) via feed/kill parameters.

### Weather-like and transport families

- [Advection-Diffusion](experimental/01_00_advection_diffusion.ipynb): A 2D incompressible vorticity–streamfunction solver with spectral Poisson inversion that generates vorticity fields across a range of viscosities and forcing strengths.
- [Shallow-Water 2D](experimental/01_01_shallow_water_equation.ipynb): A geophysical fluid model that evolves height and horizontal velocity fields to capture wave propagation, rotation effects, and balanced flow structure.

### Classical fluid dynamics families
Expand Down
133 changes: 133 additions & 0 deletions examples/experimental/00_00_reaction_diffusion.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "0",
"metadata": {},
"source": [
"# Reaction-Diffusion Simulator\n",
"\n",
"This notebook runs the `ReactionDiffusion` simulator — a coupled PDE system modelling two interacting species $u$ and $v$ with diffusion and nonlinear reaction kinetics.\n",
"\n",
"- **State variables**: `u` and `v` (species concentrations).\n",
"- **Conditioning variables**: `beta` (reaction rate strength), `d` (ratio of diffusion coefficients).\n",
"- **Dynamics**: spectral (FFT-based) spatial differentiation combined with `scipy` RK45 time integration.\n",
"- **Boundary conditions**: periodic in both spatial directions.\n",
"\n",
"### Why this is useful\n",
"\n",
"Reaction-diffusion systems produce a rich variety of spatiotemporal patterns — stripes, spots, spirals, and labyrinthine textures — depending on the parameter regime. This makes them a natural benchmark for learning PDEs that exhibit diverse structure from low-dimensional parameters.\n"
]
},
{
"cell_type": "markdown",
"id": "1",
"metadata": {},
"source": [
"## Governing equations\n",
"\n",
"The two-species reaction-diffusion system takes the form:\n",
"\n",
"$$\n",
"\\frac{\\partial u}{\\partial t} = D_u \\nabla^2 u + R_u(u, v; \\beta),\n",
"\\qquad\n",
"\\frac{\\partial v}{\\partial t} = D_v \\nabla^2 v + R_v(u, v; \\beta),\n",
"$$\n",
"\n",
"where $D_v / D_u = d$ and $R_u$, $R_v$ are the nonlinear reaction terms parameterised by $\\beta$.\n",
"\n",
"### Boundary conditions\n",
"\n",
"Periodic in both spatial directions on the domain $[-L/2, L/2]^2$:\n",
"\n",
"$$\n",
"u(-L/2, y, t) = u(L/2, y, t), \\qquad u(x, -L/2, t) = u(x, L/2, t),\n",
"$$\n",
"\n",
"and likewise for $v$.\n",
"\n",
"### Parameters\n",
"\n",
"- **`beta`**: controls the strength of the reaction nonlinearity. Larger values push the system further from equilibrium.\n",
"- **`d`**: ratio of diffusion coefficients $D_v / D_u$. Small `d` means species $v$ diffuses much more slowly, favouring pattern formation.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2",
"metadata": {},
"outputs": [],
"source": [
"from IPython.display import HTML\n",
"\n",
"from autosim.experimental.simulations import ReactionDiffusion\n",
"from autosim.utils import plot_spatiotemporal_video"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3",
"metadata": {},
"outputs": [],
"source": [
"sim = ReactionDiffusion(\n",
" return_timeseries=True,\n",
" log_level=\"progress_bar\",\n",
" n=64,\n",
" L=20,\n",
" T=32.2,\n",
" dt=0.1,\n",
" parameters_range={\n",
" \"beta\": (1.0, 2.0),\n",
" \"d\": (0.05, 0.3),\n",
" },\n",
")\n",
"\n",
"batch = sim.forward_samples_spatiotemporal(n=2, random_seed=42)\n",
"\n",
"print(\"data shape:\", batch[\"data\"].shape, \"[batch, time, x, y, channels={u, v}]\")\n",
"print(\"constant_scalars shape:\", batch[\"constant_scalars\"].shape)\n",
"print(\"sampled params (beta, d):\", batch[\"constant_scalars\"])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4",
"metadata": {},
"outputs": [],
"source": [
"anim = plot_spatiotemporal_video(\n",
" batch[\"data\"],\n",
" batch_idx=0,\n",
" channel_names=[\"u\", \"v\"],\n",
" preserve_aspect=True,\n",
")\n",
"HTML(anim.to_jshtml())"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "autosim (3.11.15)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.15"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
6 changes: 3 additions & 3 deletions examples/experimental/00_01_gray_scott.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
" # T=300.0,\n",
" # dt=1.0,\n",
" # snapshot_dt=1.0,\n",
" T=1280.0,\n",
" T=1284.0,\n",
" dt=1.0,\n",
" snapshot_dt=4.0,\n",
" initial_condition=\"gaussians\",\n",
Expand Down Expand Up @@ -216,7 +216,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "autosim (3.11.14)",
"display_name": "autosim (3.11.15)",
"language": "python",
"name": "python3"
},
Expand All @@ -230,7 +230,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.14"
"version": "3.11.15"
}
},
"nbformat": 4,
Expand Down
Loading