# ai4science-westlakeu/diffphycon architecture

> Architecture diagram of the GitHub repository ai4science-westlakeu/diffphycon, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ai4science-westlakeu/diffphycon
- Repository: https://github.com/ai4science-westlakeu/diffphycon
- Video tour (about a minute): https://gitdiagram.com/ai4science-westlakeu/diffphycon/video

## Overview

DiffPhyCon is a generative-model approach to controlling physical systems: users train models on simulated trajectories, then run inference to find control sequences that satisfy objectives. Its documented tasks are 1D Burgers, 2D jellyfish, and 2D smoke; jellyfish and smoke also use surrogate simulation components, while the repository includes RL baseline implementations. Edges are limited to relationships documented in the README or visible in the supplied source index and excerpts; unsampled internals are represented only where the tree or README supports them.

Main entry points: [`inference/inference_2d_jellyfish.py`](https://github.com/ai4science-westlakeu/diffphycon/blob/main/inference/inference_2d_jellyfish.py) (Jellyfish Inference), [`inference/inference_2d_smoke.py`](https://github.com/ai4science-westlakeu/diffphycon/blob/main/inference/inference_2d_smoke.py) (Smoke Inference), [`dataset/apps/evaluate_solver.py`](https://github.com/ai4science-westlakeu/diffphycon/blob/main/dataset/apps/evaluate_solver.py) (Solver Evaluation), [`baselines/BC_smoke/main.py`](https://github.com/ai4science-westlakeu/diffphycon/blob/main/baselines/BC_smoke/main.py) (BC Smoke Runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data and Simulation"]
  node_burgers_data["Burgers Data"]
  node_jelly_data["Jellyfish Data<br/>[data_2d.py]"]
  node_smoke_data["Smoke Data"]
  node_solver_eval["Solver Evaluation<br/>[evaluate_solver.py]"]
end

subgraph group_models["Generative Models"]
  node_train_1d["Burgers Training"]
  node_diff_1d["Burgers Diffusion"]
  node_diff_jelly["Jellyfish Diffusion"]
  node_diff_smoke["Smoke Diffusion"]
  node_video_model["Video Diffusion Network"]
end

subgraph group_control["Control and Baselines"]
  node_infer_1d["Burgers Inference"]
  node_infer_jelly["Jellyfish Inference"]
  node_infer_smoke["Smoke Inference"]
  node_surrogate["Surrogate Pipeline<br/>[sim_ppl_2d.py]"]
  node_bc_train["BC Smoke Runner<br/>[main.py]"]
  node_bc_policy["BC PPO Learner<br/>[bppo.py]"]
  node_bc_critic["Value and Q Learners<br/>[critic.py]"]
  node_bc_buffer[("Replay Buffers<br/>[buffer.py]")]
  node_replay[("Replay Memory<br/>[replay_memory.py]")]
end

subgraph group_runtime["Physics Runtime"]
  node_flow["Fluid Simulation<br/>[flow.py]"]
  node_fluid_format["Fluid Data Format<br/>[fluidformat.py]"]
  node_nd_math["Grid Mathematics<br/>[nd.py]"]
  node_sparse_solver["Sparse Solver<br/>[sparse.py]"]
end

node_user(("Researcher"))

node_user -->|"generates data"| node_burgers_data
node_user -->|"uses datasets"| node_jelly_data
node_user -->|"generates data"| node_smoke_data
node_user -->|"trains model"| node_train_1d
node_user -->|"trains model"| node_diff_jelly
node_user -->|"trains model"| node_diff_smoke
node_user -->|"runs control"| node_infer_1d
node_user -->|"runs control"| node_infer_jelly
node_user -->|"runs control"| node_infer_smoke
node_train_1d -->|"trains"| node_diff_1d
node_train_1d -->|"uses network"| node_video_model
node_infer_1d -->|"loads model"| node_diff_1d
node_infer_1d -->|"uses data generator"| node_burgers_data
node_infer_jelly -->|"loads data"| node_jelly_data
node_infer_jelly -->|"loads model"| node_diff_jelly
node_infer_jelly -->|"uses network"| node_video_model
node_infer_jelly -->|"runs simulator"| node_surrogate
node_infer_smoke -->|"loads dataset"| node_jelly_data
node_infer_smoke -->|"loads model"| node_diff_smoke
node_infer_smoke -->|"uses network"| node_video_model
node_infer_smoke -->|"evaluates solver"| node_solver_eval
node_smoke_data -->|"evaluates output"| node_solver_eval
node_solver_eval -->|"uses format"| node_fluid_format
node_solver_eval -->|"uses simulation"| node_flow
node_flow -->|"uses grid math"| node_nd_math
node_flow -->|"uses solver"| node_sparse_solver
node_nd_math -->|"supports solve"| node_sparse_solver
node_surrogate -.->|"serves inference"| node_infer_jelly
node_bc_train -.->|"trains policy"| node_bc_policy
node_bc_train -.->|"uses buffer"| node_bc_buffer
node_bc_train -->|"uses memory"| node_replay
node_bc_policy -->|"samples batches"| node_bc_buffer
node_bc_critic -->|"samples batches"| node_bc_buffer

click node_burgers_data "https://github.com/ai4science-westlakeu/diffphycon/blob/main/dataset/apps/generate_burgers.py"
click node_jelly_data "https://github.com/ai4science-westlakeu/diffphycon/blob/main/dataset/data_2d.py"
click node_smoke_data "https://github.com/ai4science-westlakeu/diffphycon/blob/main/dataset/apps/a_gen_dataset_128.py"
click node_solver_eval "https://github.com/ai4science-westlakeu/diffphycon/blob/main/dataset/apps/evaluate_solver.py"
click node_train_1d "https://github.com/ai4science-westlakeu/diffphycon/blob/main/train/train_1d_burgers.py"
click node_diff_1d "https://github.com/ai4science-westlakeu/diffphycon/blob/main/diffusion/diffusion_1d_burgers.py"
click node_diff_jelly "https://github.com/ai4science-westlakeu/diffphycon/blob/main/diffusion/diffusion_2d_jellyfish.py"
click node_diff_smoke "https://github.com/ai4science-westlakeu/diffphycon/blob/main/diffusion/diffusion_2d_smoke.py"
click node_video_model "https://github.com/ai4science-westlakeu/diffphycon/blob/main/model/video_diffusion_pytorch/video_diffusion_pytorch_conv3d.py"
click node_infer_1d "https://github.com/ai4science-westlakeu/diffphycon/blob/main/inference/inference_1d_burgers.py"
click node_infer_jelly "https://github.com/ai4science-westlakeu/diffphycon/blob/main/inference/inference_2d_jellyfish.py"
click node_infer_smoke "https://github.com/ai4science-westlakeu/diffphycon/blob/main/inference/inference_2d_smoke.py"
click node_surrogate "https://github.com/ai4science-westlakeu/diffphycon/blob/main/inference/sim_ppl_2d.py"
click node_bc_train "https://github.com/ai4science-westlakeu/diffphycon/blob/main/baselines/BC_smoke/main.py"
click node_bc_policy "https://github.com/ai4science-westlakeu/diffphycon/blob/main/baselines/BC_smoke/bppo.py"
click node_bc_critic "https://github.com/ai4science-westlakeu/diffphycon/blob/main/baselines/BC_smoke/critic.py"
click node_bc_buffer "https://github.com/ai4science-westlakeu/diffphycon/blob/main/baselines/BC_smoke/buffer.py"
click node_replay "https://github.com/ai4science-westlakeu/diffphycon/blob/main/baselines/BC_smoke/scripts/replay_memory.py"
click node_flow "https://github.com/ai4science-westlakeu/diffphycon/blob/main/phi/flow.py"
click node_fluid_format "https://github.com/ai4science-westlakeu/diffphycon/blob/main/phi/fluidformat.py"
click node_nd_math "https://github.com/ai4science-westlakeu/diffphycon/blob/main/phi/math/nd.py"
click node_sparse_solver "https://github.com/ai4science-westlakeu/diffphycon/blob/main/phi/solver/sparse.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_burgers_data,node_jelly_data,node_smoke_data,node_solver_eval toneBlue
class node_train_1d,node_diff_1d,node_diff_jelly,node_diff_smoke,node_video_model toneAmber
class node_infer_1d,node_infer_jelly,node_infer_smoke,node_surrogate,node_bc_train,node_bc_policy,node_bc_critic,node_bc_buffer,node_replay toneMint
class node_flow,node_fluid_format,node_nd_math,node_sparse_solver toneRose
class node_user toneIndigo
```

## Components

### Data and Simulation

- [Burgers Data](https://github.com/ai4science-westlakeu/diffphycon/blob/main/dataset/apps/generate_burgers.py): `dataset/apps/generate_burgers.py`
- [Jellyfish Data](https://github.com/ai4science-westlakeu/diffphycon/blob/main/dataset/data_2d.py): `dataset/data_2d.py`
- [Smoke Data](https://github.com/ai4science-westlakeu/diffphycon/blob/main/dataset/apps/a_gen_dataset_128.py): `dataset/apps/a_gen_dataset_128.py`
- [Solver Evaluation](https://github.com/ai4science-westlakeu/diffphycon/blob/main/dataset/apps/evaluate_solver.py): `dataset/apps/evaluate_solver.py`

### Generative Models

- [Burgers Training](https://github.com/ai4science-westlakeu/diffphycon/blob/main/train/train_1d_burgers.py): `train/train_1d_burgers.py`
- [Burgers Diffusion](https://github.com/ai4science-westlakeu/diffphycon/blob/main/diffusion/diffusion_1d_burgers.py): `diffusion/diffusion_1d_burgers.py`
- [Jellyfish Diffusion](https://github.com/ai4science-westlakeu/diffphycon/blob/main/diffusion/diffusion_2d_jellyfish.py): `diffusion/diffusion_2d_jellyfish.py`
- [Smoke Diffusion](https://github.com/ai4science-westlakeu/diffphycon/blob/main/diffusion/diffusion_2d_smoke.py): `diffusion/diffusion_2d_smoke.py`
- [Video Diffusion Network](https://github.com/ai4science-westlakeu/diffphycon/blob/main/model/video_diffusion_pytorch/video_diffusion_pytorch_conv3d.py): `model/video_diffusion_pytorch/video_diffusion_pytorch_conv3d.py`

### Control and Baselines

- [Burgers Inference](https://github.com/ai4science-westlakeu/diffphycon/blob/main/inference/inference_1d_burgers.py): `inference/inference_1d_burgers.py`
- [Jellyfish Inference](https://github.com/ai4science-westlakeu/diffphycon/blob/main/inference/inference_2d_jellyfish.py): `inference/inference_2d_jellyfish.py`
- [Smoke Inference](https://github.com/ai4science-westlakeu/diffphycon/blob/main/inference/inference_2d_smoke.py): `inference/inference_2d_smoke.py`
- [Surrogate Pipeline](https://github.com/ai4science-westlakeu/diffphycon/blob/main/inference/sim_ppl_2d.py): `inference/sim_ppl_2d.py`
- [BC Smoke Runner](https://github.com/ai4science-westlakeu/diffphycon/blob/main/baselines/BC_smoke/main.py): `baselines/BC_smoke/main.py`
- [BC PPO Learner](https://github.com/ai4science-westlakeu/diffphycon/blob/main/baselines/BC_smoke/bppo.py): `baselines/BC_smoke/bppo.py`
- [Value and Q Learners](https://github.com/ai4science-westlakeu/diffphycon/blob/main/baselines/BC_smoke/critic.py): `baselines/BC_smoke/critic.py`
- [Replay Buffers](https://github.com/ai4science-westlakeu/diffphycon/blob/main/baselines/BC_smoke/buffer.py): `baselines/BC_smoke/buffer.py`
- [Replay Memory](https://github.com/ai4science-westlakeu/diffphycon/blob/main/baselines/BC_smoke/scripts/replay_memory.py): `baselines/BC_smoke/scripts/replay_memory.py`

### Physics Runtime

- [Fluid Simulation](https://github.com/ai4science-westlakeu/diffphycon/blob/main/phi/flow.py): `phi/flow.py`
- [Fluid Data Format](https://github.com/ai4science-westlakeu/diffphycon/blob/main/phi/fluidformat.py): `phi/fluidformat.py`
- [Grid Mathematics](https://github.com/ai4science-westlakeu/diffphycon/blob/main/phi/math/nd.py): `phi/math/nd.py`
- [Sparse Solver](https://github.com/ai4science-westlakeu/diffphycon/blob/main/phi/solver/sparse.py): `phi/solver/sparse.py`

### Other components

- **Researcher**

## Connections

- Researcher → Burgers Data: generates data (evidence: `README.md`)
- Researcher → Jellyfish Data: uses datasets (evidence: `README.md`)
- Researcher → Smoke Data: generates data (evidence: `README.md`)
- Researcher → Burgers Training: trains model (evidence: `README.md`)
- Researcher → Jellyfish Diffusion: trains model (evidence: `README.md`)
- Researcher → Smoke Diffusion: trains model (evidence: `README.md`)
- Researcher → Burgers Inference: runs control (evidence: `README.md`)
- Researcher → Jellyfish Inference: runs control (evidence: `README.md`)
- Researcher → Smoke Inference: runs control (evidence: `README.md`)
- Burgers Training → Burgers Diffusion: trains (evidence: `train/train_1d_burgers.py`)
- Burgers Training → Video Diffusion Network: uses network (evidence: `train/train_1d_burgers.py`)
- Burgers Inference → Burgers Diffusion: loads model (evidence: `inference/inference_1d_burgers.py`)
- Burgers Inference → Burgers Data: uses data generator (evidence: `inference/inference_1d_burgers.py`)
- Jellyfish Inference → Jellyfish Data: loads data (evidence: `inference/inference_2d_jellyfish.py`)
- Jellyfish Inference → Jellyfish Diffusion: loads model (evidence: `inference/inference_2d_jellyfish.py`)
- Jellyfish Inference → Video Diffusion Network: uses network (evidence: `inference/inference_2d_jellyfish.py`)
- Jellyfish Inference → Surrogate Pipeline: runs simulator (evidence: `inference/inference_2d_jellyfish.py`)
- Smoke Inference → Jellyfish Data: loads dataset (evidence: `inference/inference_2d_smoke.py`)
- Smoke Inference → Smoke Diffusion: loads model (evidence: `inference/inference_2d_smoke.py`)
- Smoke Inference → Video Diffusion Network: uses network (evidence: `inference/inference_2d_smoke.py`)
- Smoke Inference → Solver Evaluation: evaluates solver (evidence: `inference/inference_2d_smoke.py`)
- Smoke Data → Solver Evaluation: evaluates output (evidence: `dataset/apps/a_gen_dataset_128.py`)
- Solver Evaluation → Fluid Data Format: uses format (evidence: `dataset/apps/evaluate_solver.py`)
- Solver Evaluation → Fluid Simulation: uses simulation (evidence: `dataset/apps/evaluate_solver.py`)
- Fluid Simulation → Grid Mathematics: uses grid math (evidence: `phi/flow.py`)
- Fluid Simulation → Sparse Solver: uses solver (evidence: `phi/flow.py`)
- Grid Mathematics → Sparse Solver: supports solve (evidence: `phi/solver/sparse.py`)
- Surrogate Pipeline → Jellyfish Inference: serves inference (evidence: `inference/inference_2d_jellyfish.py`)
- BC Smoke Runner → BC PPO Learner: trains policy (evidence: `baselines/BC_smoke/main.py`)
- BC Smoke Runner → Replay Buffers: uses buffer (evidence: `baselines/BC_smoke/main.py`)
- BC Smoke Runner → Replay Memory: uses memory (evidence: `baselines/BC_smoke/main.py`)
- BC PPO Learner → Replay Buffers: samples batches (evidence: `baselines/BC_smoke/bppo.py`)
- Value and Q Learners → Replay Buffers: samples batches (evidence: `baselines/BC_smoke/critic.py`)
