# opalx-project/opalx architecture

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

- Interactive diagram: https://gitdiagram.com/opalx-project/opalx
- Repository: https://github.com/opalx-project/opalx

## Overview

OPALX is an accelerator simulation application: users provide an OPAL input file, which the executable parses to define a beamline and simulation, then tracking evolves a particle bunch and writes results. The tree shows separate modeling, tracking, field/space-charge, and output subsystems, plus SDDS/H5 conversion tools. Main.cpp confirms input streams are passed to the parser; the sampled excerpts do not establish most downstream call wiring, so those links are limited to the documented workflow and clear subsystem responsibilities.

Main entry points: [`src/Track/TrackRun.cpp`](https://github.com/opalx-project/opalx/blob/master/src/Track/TrackRun.cpp) (Particle tracking), [`src/Algorithms/Tracker.cpp`](https://github.com/opalx-project/opalx/blob/master/src/Algorithms/Tracker.cpp) (Tracking algorithms), [`src/OpalParser/OpalParser.cpp`](https://github.com/opalx-project/opalx/blob/master/src/OpalParser/OpalParser.cpp) (Input parser), [`src/Main.cpp`](https://github.com/opalx-project/opalx/blob/master/src/Main.cpp) (OPALX entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input_model["Input and model"]
  node_main["OPALX entry<br/>[Main.cpp]"]
  node_parser["Input parser<br/>[OpalParser.cpp]"]
  node_objects["Object definitions<br/>[OpalData.cpp]"]
  node_lines["Lattice sequences<br/>[SequenceParser.cpp]"]
  node_elements["Element models<br/>[OpalElement.cpp]"]
end

subgraph group_simulation["Simulation runtime"]
  node_beamline["Beamline runtime<br/>[Beamline.cpp]"]
  node_tracking["Particle tracking<br/>[TrackRun.cpp]"]
  node_tracker["Tracking algorithms<br/>[Tracker.cpp]"]
  node_bunch["Particle bunch<br/>[PartBunch.cpp]"]
  node_distribution["Initial distributions<br/>[Distribution.cpp]"]
end

subgraph group_physics["Fields and physics"]
  node_fields["Field models<br/>[Fieldmap.cpp]"]
  node_spacecharge["Space charge"]
  node_processes["Particle processes<br/>[GlobalProcess.cpp]"]
end

subgraph group_results["Results and exchange"]
  node_output["Simulation output<br/>[DataSink.cpp]"]
  node_checkpoint["Checkpoint state<br/>[CheckpointFile.cpp]"]
  node_opal2sdds["H5 to SDDS<br/>[main.cpp]"]
  node_sdds2opal["SDDS to OPAL<br/>[main.cpp]"]
end

node_user(("Simulation user"))

node_user -->|"starts simulation"| node_main
node_user -->|"provides input"| node_parser
node_main -->|"runs parser"| node_parser
node_parser -->|"defines objects"| node_objects
node_parser -->|"parses sequences"| node_lines
node_lines -->|"references elements"| node_elements
node_elements -->|"models components"| node_beamline
node_beamline -->|"provides lattice"| node_tracking
node_tracking -->|"runs tracking"| node_tracker
node_tracking -->|"advances particles"| node_bunch
node_distribution -->|"initializes particles"| node_bunch
node_tracker -->|"uses element fields"| node_fields
node_tracker -->|"computes collective fields"| node_spacecharge
node_tracker -->|"applies processes"| node_processes
node_tracking -->|"writes results"| node_output
node_tracking -->|"saves state"| node_checkpoint
node_user -.->|"converts H5 output"| node_opal2sdds
node_opal2sdds -.->|"reads H5 data"| node_output
node_user -.->|"converts SDDS data"| node_sdds2opal

click node_main "https://github.com/opalx-project/opalx/blob/master/src/Main.cpp"
click node_parser "https://github.com/opalx-project/opalx/blob/master/src/OpalParser/OpalParser.cpp"
click node_objects "https://github.com/opalx-project/opalx/blob/master/src/AbstractObjects/OpalData.cpp"
click node_lines "https://github.com/opalx-project/opalx/blob/master/src/Lines/SequenceParser.cpp"
click node_elements "https://github.com/opalx-project/opalx/blob/master/src/Elements/OpalElement.cpp"
click node_beamline "https://github.com/opalx-project/opalx/blob/master/src/Beamlines/Beamline.cpp"
click node_tracking "https://github.com/opalx-project/opalx/blob/master/src/Track/TrackRun.cpp"
click node_tracker "https://github.com/opalx-project/opalx/blob/master/src/Algorithms/Tracker.cpp"
click node_bunch "https://github.com/opalx-project/opalx/blob/master/src/PartBunch/PartBunch.cpp"
click node_distribution "https://github.com/opalx-project/opalx/blob/master/src/Distribution/Distribution.cpp"
click node_fields "https://github.com/opalx-project/opalx/blob/master/src/Fields/Fieldmap.cpp"
click node_spacecharge "https://github.com/opalx-project/opalx/blob/master/src/SpaceCharge/SpaceChargeFactory.cpp"
click node_processes "https://github.com/opalx-project/opalx/blob/master/src/Processes/GlobalProcesses/GlobalProcess.cpp"
click node_output "https://github.com/opalx-project/opalx/blob/master/src/Structure/DataSink.cpp"
click node_checkpoint "https://github.com/opalx-project/opalx/blob/master/src/Structure/CheckpointFile.cpp"
click node_opal2sdds "https://github.com/opalx-project/opalx/blob/master/tools/opal2sdds/main.cpp"
click node_sdds2opal "https://github.com/opalx-project/opalx/blob/master/tools/sdds2opal/main.cpp"

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_main,node_parser,node_objects,node_lines,node_elements,node_user toneBlue
class node_beamline,node_tracking,node_tracker,node_bunch,node_distribution toneAmber
class node_fields,node_spacecharge,node_processes toneMint
class node_output,node_checkpoint,node_opal2sdds,node_sdds2opal toneRose
```

## Components

### Input and model

- [OPALX entry](https://github.com/opalx-project/opalx/blob/master/src/Main.cpp): `src/Main.cpp`
- [Input parser](https://github.com/opalx-project/opalx/blob/master/src/OpalParser/OpalParser.cpp): `src/OpalParser/OpalParser.cpp`
- [Object definitions](https://github.com/opalx-project/opalx/blob/master/src/AbstractObjects/OpalData.cpp): `src/AbstractObjects/OpalData.cpp`
- [Lattice sequences](https://github.com/opalx-project/opalx/blob/master/src/Lines/SequenceParser.cpp): `src/Lines/SequenceParser.cpp`
- [Element models](https://github.com/opalx-project/opalx/blob/master/src/Elements/OpalElement.cpp): `src/Elements/OpalElement.cpp`

### Simulation runtime

- [Beamline runtime](https://github.com/opalx-project/opalx/blob/master/src/Beamlines/Beamline.cpp): `src/Beamlines/Beamline.cpp`
- [Particle tracking](https://github.com/opalx-project/opalx/blob/master/src/Track/TrackRun.cpp): `src/Track/TrackRun.cpp`
- [Tracking algorithms](https://github.com/opalx-project/opalx/blob/master/src/Algorithms/Tracker.cpp): `src/Algorithms/Tracker.cpp`
- [Particle bunch](https://github.com/opalx-project/opalx/blob/master/src/PartBunch/PartBunch.cpp): `src/PartBunch/PartBunch.cpp`
- [Initial distributions](https://github.com/opalx-project/opalx/blob/master/src/Distribution/Distribution.cpp): `src/Distribution/Distribution.cpp`

### Fields and physics

- [Field models](https://github.com/opalx-project/opalx/blob/master/src/Fields/Fieldmap.cpp): `src/Fields/Fieldmap.cpp`
- [Space charge](https://github.com/opalx-project/opalx/blob/master/src/SpaceCharge/SpaceChargeFactory.cpp): `src/SpaceCharge/SpaceChargeFactory.cpp`
- [Particle processes](https://github.com/opalx-project/opalx/blob/master/src/Processes/GlobalProcesses/GlobalProcess.cpp): `src/Processes/GlobalProcesses/GlobalProcess.cpp`

### Results and exchange

- [Simulation output](https://github.com/opalx-project/opalx/blob/master/src/Structure/DataSink.cpp): `src/Structure/DataSink.cpp`
- [Checkpoint state](https://github.com/opalx-project/opalx/blob/master/src/Structure/CheckpointFile.cpp): `src/Structure/CheckpointFile.cpp`
- [H5 to SDDS](https://github.com/opalx-project/opalx/blob/master/tools/opal2sdds/main.cpp): `tools/opal2sdds/main.cpp`
- [SDDS to OPAL](https://github.com/opalx-project/opalx/blob/master/tools/sdds2opal/main.cpp): `tools/sdds2opal/main.cpp`

### Other components

- **Simulation user**

## Connections

- Simulation user → OPALX entry: starts simulation
- Simulation user → Input parser: provides input
- OPALX entry → Input parser: runs parser
- Input parser → Object definitions: defines objects
- Input parser → Lattice sequences: parses sequences
- Lattice sequences → Element models: references elements
- Element models → Beamline runtime: models components
- Beamline runtime → Particle tracking: provides lattice
- Particle tracking → Tracking algorithms: runs tracking
- Particle tracking → Particle bunch: advances particles
- Initial distributions → Particle bunch: initializes particles
- Tracking algorithms → Field models: uses element fields
- Tracking algorithms → Space charge: computes collective fields
- Tracking algorithms → Particle processes: applies processes
- Particle tracking → Simulation output: writes results
- Particle tracking → Checkpoint state: saves state
- Simulation user → H5 to SDDS: converts H5 output
- H5 to SDDS → Simulation output: reads H5 data
- Simulation user → SDDS to OPAL: converts SDDS data
