IMASH is a lightweight C++ library that extracts plasma and machine data from IMAS (Integrated Modelling & Analysis Suite) and maps it into solver-ready data structures. The actual C++ wrapper tends to increase the compile time when used in conjunction with accelerator compilers (e.g. nvcc). This library completely isolates the IMAS structure from the accelerator compilers.
It is designed as a bridge layer between IMAS and numerical solvers (e.g. AMReX-based FDTD codes), while preserving a Python-verifiable workflow via file outputs.
The executable requires the IMAS path and a time (in seconds):
./imash <imas_path> <time> [output_dir]Example:
./imash ~/iter/134174/117/ 60.0 ./This will read IMAS data at t = 60.0 s and write output files to the current directory.
IMASH performs three core operations:
Reads data from standard IMAS IDS:
core_profilesequilibriumedge_profiles (GGD)wall
Example:
IdsNs::IDS ids;
ids.open("imas:hdf5?path=...", OPEN_PULSE);IMAS data is not directly solver-ready. IMASH reconstructs physical fields:
Maps 1D profiles → 2D equilibrium grid:
- Produces:
$n_e(R,Z)$ $T_e(R,Z)$
- Uses interpolation in
$\rho$
- Extracts cell-centered data from GGD mesh
- Reconstructs:
-
$(R,Z)$ from node geometry -
$n_e, T_e$ from field values
-
Optional:
- Projection to equilibrium grid via
$(\rho,\theta)$
From equilibrium:
$B_R(R,Z)$ $B_Z(R,Z)$ $B_\phi = B_T \frac{R_0}{R}$
- Extracts limiter and vessel contours
- Produces polylines in
$(R,Z)$
IMASH builds clean C++ objects:
PlasmaDataWallDataEdgeCellPointEqGrid2D
These are independent of AMReX or any solver.
| Layer | Responsibility |
|---|---|
| IMASH | Read & reconstruct physics |
| Solver | Discretization & time evolution |
IMASH:
- does not know about
MultiFab, MPI, or GPUs - produces pure C++ data structures
IMASH supports:
Write outputs to file:
WriteCore2D(ids, time, "core.dat");
WriteEdge2D(ids, time, "edge.dat");Used with Python:
plt.pcolormesh(...)
plt.tricontourf(...)Return in-memory structures:
PlasmaData plasma = ExtractPlasmaData(ids, time);Flattening convention:
-
$i$ : radial index -
$j$ : vertical index
- Stored as unstructured points
- No flattening
- Derived from mesh connectivity
- Length: meters
- Density:
$\text{m}^{-3}$ - Temperature: eV
- Magnetic field: Tesla
IdsNs::IDS ids;
ids.open("imas:hdf5?path=...", OPEN_PULSE);
double time = 60.0;
// Full plasma extraction
PlasmaData plasma = ExtractPlasmaData(ids, time,
true, // core
true, // B field
true, // edge projection
true, // merge density
true); // merge temperature
// Debug output
WriteCore2D(plasma, "core.dat");
WriteBfield2D(plasma, "bfield.dat");IMASH is designed to feed directly into simulation codes:
PlasmaData plasma = ExtractPlasmaData(ids, time);
FillMultiFabFromPlasma(plasma, ...);- IMASH handles physics reconstruction
- Solver handles:
- domain decomposition
- GPU transfer
- time stepping
The key step takes place in the reader functions which will connect the data used by the solver and the data owned by IMAS. The reader functions must be designed in a way where IMASH.H is present only in the private part of the code, i.e. the cpp file. The public part where the function headers reside, the H file, should only have TokamakData.H. The H and cpp file should have no headers requiring accelerator compile or the problem will still exists. The isolation must be complete, and only pure C++ functions must be used in the reader functions.
- ✅ Core profile mapping
- ✅ Edge GGD reconstruction
- ✅ Edge → grid interpolation (
$\rho,\theta$ ) - ✅ Magnetic field extraction
- ✅ Wall geometry extraction
- ✅ Python-compatible outputs
- STL wall import (CAD geometry)
- Reflectometer / antenna geometry
- 3D toroidal reconstruction
- Direct AMReX ingestion utilities
- Time-dependent IMAS sequences
- IMAS C++ Access Layer (
ALClasses) - C++17
- Standard library only (no solver dependency)
IMAS provides rich physics data, but:
- data is heterogeneous
- grids are not solver-ready
- edge uses unstructured meshes
IMASH solves this by providing:
A consistent, physics-aware mapping from IMAS → simulation-ready fields
IMASH is a thin but critical layer that:
- converts IMAS data into physical fields
- unifies core + edge descriptions
- remains solver-agnostic
- preserves validation through file output
