# struphy-hub/struphy architecture

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

- Interactive diagram: https://gitdiagram.com/struphy-hub/struphy
- Repository: https://github.com/struphy-hub/struphy

## Overview

STRUPHY is a Python framework for structure-preserving PDE simulation, especially plasma physics. The principal workflow is to configure a model and its numerical setup, initialize the simulation, execute its time evolution, and inspect saved results. Its documented model families include fluid, kinetic, and hybrid plasma systems; the tree also shows dedicated geometry, finite-element, particle, and background-field machinery. The graph combines README capabilities with indexed source references; some implementation details are not shown in the excerpts, so uncertain wiring is omitted.

Main entry points: [`src/struphy/simulation/sim.py`](https://github.com/struphy-hub/struphy/blob/devel/src/struphy/simulation/sim.py) (Simulation driver), [`src/struphy/models/base.py`](https://github.com/struphy-hub/struphy/blob/devel/src/struphy/models/base.py) (PDE models), [`src/struphy/post_processing/output.py`](https://github.com/struphy-hub/struphy/blob/devel/src/struphy/post_processing/output.py) (Post-processing output), [`src/struphy/pic/base.py`](https://github.com/struphy-hub/struphy/blob/devel/src/struphy/pic/base.py) (Particle methods)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_cli["Command line<br/>[main.py]"]
end

subgraph group_simulation["Simulation setup"]
  node_options["Run options<br/>[options.py]"]
  node_sim["Simulation driver<br/>[sim.py]"]
  node_geometry["Mapped domains<br/>[base.py]"]
  node_initial["Initial conditions<br/>[perturbations.py]"]
end

subgraph group_numerics["Numerical methods"]
  node_derham["FEEC spaces<br/>[psydac_derham.py]"]
  node_mass["Mass operators<br/>[mass.py]"]
  node_particles["Particle methods<br/>[base.py]"]
  node_spline_eval["Spline evaluation"]
end

subgraph group_physics["Physics components"]
  node_models["PDE models<br/>[base.py]"]
  node_species["Model species<br/>[species.py]"]
  node_variables["Model variables<br/>[variables.py]"]
  node_equilibria["Fluid equilibria<br/>[equils.py]"]
  node_backgrounds["Background fields<br/>[base.py]"]
  node_kinetic["Kinetic backgrounds<br/>[base.py]"]
end

subgraph group_results["Results"]
  node_output["Post-processing output<br/>[output.py]"]
end

node_user(("User"))

node_user -->|"runs commands"| node_cli
node_cli -->|"resolves models"| node_models
node_sim -->|"uses model"| node_models
node_sim -->|"reads options"| node_options
node_sim -->|"uses domain"| node_geometry
node_sim -->|"sets initial state"| node_initial
node_sim -->|"uses backgrounds"| node_backgrounds
node_sim -->|"uses spaces"| node_derham
node_sim -->|"uses operators"| node_mass
node_sim -->|"uses particle methods"| node_particles
node_sim -->|"writes results"| node_output
node_models -->|"uses species"| node_species
node_models -->|"uses variables"| node_variables
node_models -->|"uses particle methods"| node_particles
node_equilibria -->|"extends backgrounds"| node_backgrounds
node_geometry -->|"evaluates splines"| node_spline_eval
node_output -->|"reads particle state"| node_particles
node_output -->|"reads variables"| node_variables
node_sim -->|"uses kinetic backgrounds"| node_kinetic

click node_cli "https://github.com/struphy-hub/struphy/blob/devel/src/struphy/console/main.py"
click node_options "https://github.com/struphy-hub/struphy/blob/devel/src/struphy/io/options.py"
click node_sim "https://github.com/struphy-hub/struphy/blob/devel/src/struphy/simulation/sim.py"
click node_models "https://github.com/struphy-hub/struphy/blob/devel/src/struphy/models/base.py"
click node_species "https://github.com/struphy-hub/struphy/blob/devel/src/struphy/models/species.py"
click node_variables "https://github.com/struphy-hub/struphy/blob/devel/src/struphy/models/variables.py"
click node_geometry "https://github.com/struphy-hub/struphy/blob/devel/src/struphy/geometry/base.py"
click node_equilibria "https://github.com/struphy-hub/struphy/blob/devel/src/struphy/fields_background/equils.py"
click node_backgrounds "https://github.com/struphy-hub/struphy/blob/devel/src/struphy/fields_background/base.py"
click node_kinetic "https://github.com/struphy-hub/struphy/blob/devel/src/struphy/kinetic_background/base.py"
click node_initial "https://github.com/struphy-hub/struphy/blob/devel/src/struphy/initial/perturbations.py"
click node_derham "https://github.com/struphy-hub/struphy/blob/devel/src/struphy/feec/psydac_derham.py"
click node_mass "https://github.com/struphy-hub/struphy/blob/devel/src/struphy/feec/mass.py"
click node_particles "https://github.com/struphy-hub/struphy/blob/devel/src/struphy/pic/base.py"
click node_spline_eval "https://github.com/struphy-hub/struphy/blob/devel/src/struphy/bsplines/evaluation_kernels_3d.py"
click node_output "https://github.com/struphy-hub/struphy/blob/devel/src/struphy/post_processing/output.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_cli,node_user toneBlue
class node_options,node_sim,node_geometry,node_initial toneAmber
class node_derham,node_mass,node_particles,node_spline_eval toneMint
class node_models,node_species,node_variables,node_equilibria,node_backgrounds,node_kinetic toneRose
class node_output toneIndigo
```

## Components

### User interface

- [Command line](https://github.com/struphy-hub/struphy/blob/devel/src/struphy/console/main.py): `src/struphy/console/main.py`

### Simulation setup

- [Run options](https://github.com/struphy-hub/struphy/blob/devel/src/struphy/io/options.py): `src/struphy/io/options.py`
- [Simulation driver](https://github.com/struphy-hub/struphy/blob/devel/src/struphy/simulation/sim.py): `src/struphy/simulation/sim.py`
- [Mapped domains](https://github.com/struphy-hub/struphy/blob/devel/src/struphy/geometry/base.py): `src/struphy/geometry/base.py`
- [Initial conditions](https://github.com/struphy-hub/struphy/blob/devel/src/struphy/initial/perturbations.py): `src/struphy/initial/perturbations.py`

### Numerical methods

- [FEEC spaces](https://github.com/struphy-hub/struphy/blob/devel/src/struphy/feec/psydac_derham.py): `src/struphy/feec/psydac_derham.py`
- [Mass operators](https://github.com/struphy-hub/struphy/blob/devel/src/struphy/feec/mass.py): `src/struphy/feec/mass.py`
- [Particle methods](https://github.com/struphy-hub/struphy/blob/devel/src/struphy/pic/base.py): `src/struphy/pic/base.py`
- [Spline evaluation](https://github.com/struphy-hub/struphy/blob/devel/src/struphy/bsplines/evaluation_kernels_3d.py): `src/struphy/bsplines/evaluation_kernels_3d.py`

### Physics components

- [PDE models](https://github.com/struphy-hub/struphy/blob/devel/src/struphy/models/base.py): `src/struphy/models/base.py`
- [Model species](https://github.com/struphy-hub/struphy/blob/devel/src/struphy/models/species.py): `src/struphy/models/species.py`
- [Model variables](https://github.com/struphy-hub/struphy/blob/devel/src/struphy/models/variables.py): `src/struphy/models/variables.py`
- [Fluid equilibria](https://github.com/struphy-hub/struphy/blob/devel/src/struphy/fields_background/equils.py): `src/struphy/fields_background/equils.py`
- [Background fields](https://github.com/struphy-hub/struphy/blob/devel/src/struphy/fields_background/base.py): `src/struphy/fields_background/base.py`
- [Kinetic backgrounds](https://github.com/struphy-hub/struphy/blob/devel/src/struphy/kinetic_background/base.py): `src/struphy/kinetic_background/base.py`

### Results

- [Post-processing output](https://github.com/struphy-hub/struphy/blob/devel/src/struphy/post_processing/output.py): `src/struphy/post_processing/output.py`

### Other components

- **User**

## Connections

- User → Command line: runs commands (evidence: `README.md`)
- Command line → PDE models: resolves models (evidence: `src/struphy/console/main.py`)
- Simulation driver → PDE models: uses model (evidence: `src/struphy/simulation/sim.py`)
- Simulation driver → Run options: reads options (evidence: `src/struphy/simulation/sim.py`)
- Simulation driver → Mapped domains: uses domain (evidence: `src/struphy/simulation/sim.py`)
- Simulation driver → Initial conditions: sets initial state (evidence: `src/struphy/simulation/sim.py`)
- Simulation driver → Background fields: uses backgrounds (evidence: `src/struphy/simulation/sim.py`)
- Simulation driver → FEEC spaces: uses spaces (evidence: `src/struphy/simulation/sim.py`)
- Simulation driver → Mass operators: uses operators (evidence: `src/struphy/simulation/sim.py`)
- Simulation driver → Particle methods: uses particle methods (evidence: `src/struphy/simulation/sim.py`)
- Simulation driver → Post-processing output: writes results (evidence: `src/struphy/simulation/sim.py`)
- PDE models → Model species: uses species (evidence: `src/struphy/models/base.py`)
- PDE models → Model variables: uses variables (evidence: `src/struphy/models/base.py`)
- PDE models → Particle methods: uses particle methods (evidence: `src/struphy/models/base.py`)
- Fluid equilibria → Background fields: extends backgrounds (evidence: `src/struphy/fields_background/equils.py`)
- Mapped domains → Spline evaluation: evaluates splines (evidence: `src/struphy/geometry/base.py`)
- Post-processing output → Particle methods: reads particle state (evidence: `src/struphy/post_processing/output.py`)
- Post-processing output → Model variables: reads variables (evidence: `src/struphy/post_processing/output.py`)
- Simulation driver → Kinetic backgrounds: uses kinetic backgrounds (evidence: `src/struphy/simulation/sim.py`)
