Skip to content

Converter Overview

The converter is a standalone Python package that translates the editor’s JSON project format into native input files for Monte Carlo particle transport simulators.

The YAPTIDE UI produces a JSON description of the simulation. Simulators like SHIELD-HIT12A, FLUKA, and Geant4 each expect their own specific input format. The converter bridges this gap.

Editor JSON ──> Converter ──> Simulator-specific input files
EngineParser ClassOutput FilesMaturity
SHIELD-HIT12AShieldhitParserbeam.dat, mat.dat, geo.dat, detect.datMost complete
FLUKAFlukaParserfl_sim.inpSolid
Geant4Geant4Parsergeometry.gdml, run.macGood
TOPASTopasParsertopas_config.txtMinimal / experimental

The converter is used in two contexts:

ContextHowWhen
BackendImported as a Python library by the Flask appServer-side conversion before dispatching simulations to workers
FrontendCompiled to WebAssembly via Pyodide, running in a Web WorkerInput file preview and Geant4 local simulations

Both contexts use the exact same codebase.

All parsers inherit from the abstract Parser class in converter/common.py:

class Parser(ABC):
@abstractmethod
def parse_configs(self, json_data: dict) -> None:
"""Parse the editor JSON and populate internal dataclasses."""
pass
@abstractmethod
def save_configs(self, output_dir: Path) -> None:
"""Write generated files to disk."""
pass
@abstractmethod
def get_configs_json(self) -> dict:
"""Return {filename: content} dict without writing to disk."""
pass

converter/solid_figures.py defines the geometry primitives:

SolidFigure (ABC)
├── BoxFigure (xLength, yLength, zLength)
├── CylinderFigure (radius, height)
└── SphereFigure (radius)

Each figure has position, rotation, and an expand(margin) method for generating the world-zone black-hole boundary.

converter/common.py provides:

FunctionPurpose
format_float(number, n)Format float with n decimal places (for fixed-width file formats)
rotate(vector, angles)3D Tait-Bryan rotation
convert_beam_energy()MeV ↔ MeV/nucl based on particle type
converter/
├── converter/
│ ├── __init__.py
│ ├── api.py # Public API
│ ├── common.py # Parser base class, utilities
│ ├── main.py # CLI entry point
│ ├── solid_figures.py # Geometry primitives
│ ├── shieldhit/ # SHIELD-HIT12A parser
│ │ ├── __init__.py
│ │ ├── parser.py # ShieldhitParser
│ │ ├── beam.py # BeamConfig → beam.dat
│ │ ├── geo.py # GeoMatConfig → geo.dat + mat.dat
│ │ ├── detect.py # DetectConfig → detect.dat
│ │ └── ...
│ ├── fluka/ # FLUKA parser
│ │ ├── __init__.py
│ │ ├── parser.py # FlukaParser
│ │ ├── input.py # Input dataclass
│ │ ├── cards/ # Card generators (beam, figures, regions...)
│ │ └── helper_parsers/ # JSON → card parsing logic
│ ├── geant4/ # Geant4 parser
│ │ ├── __init__.py
│ │ ├── parser.py # Geant4Parser (GDML + macro)
│ │ └── ...
│ └── topas/ # TOPAS parser
│ ├── __init__.py
│ └── parser.py # TopasParser (minimal)
└── tests/