Skip to content
Beta.topas@modelscript/topas 10 diagnostic rules
Parser WASM GLR
Diagnostics 10 rules
DAE Arena Lowering
Simulation Native Solvers
Projections Modelica, NIfTI, DICOM-RT
Live ExampleProtonBraggPeakWater.topas

TOPAS 150 MeV Clinical Proton Beam & Water Phantom Scoring

Monte Carlo radiation transport parameter file configuring a 150 MeV proton pencil beam and 300-bin Bragg peak depth-dose scorer.

Playground
Source (19 lines)
1s:Ge/World/Material  = "Air"
2d:Ge/World/HLX       = 50.0 cm
3d:Ge/World/HLY       = 50.0 cm
4d:Ge/World/HLZ       = 50.0 cm
5 
6s:Ge/WaterPhantom/Type     = "TsBox"
7s:Ge/WaterPhantom/Parent   = "World"
8s:Ge/WaterPhantom/Material = "G4_WATER"
9d:Ge/WaterPhantom/HLX      = 15.0 cm
10d:Ge/WaterPhantom/HLY      = 15.0 cm
11d:Ge/WaterPhantom/HLZ      = 20.0 cm
12i:Ge/WaterPhantom/ZBins    = 200
13 
14s:So/ProtonBeam/BeamParticle = "proton"
15d:So/ProtonBeam/BeamEnergy   = 150.0 MeV
16i:So/ProtonBeam/NumberOfHistoriesInRun = 100000
17 
18s:Sc/BraggPeakDose/Quantity  = "DoseToMedium"
19s:Sc/BraggPeakDose/Component = "WaterPhantom"
TOPAS Monte Carlo Geometry & Bragg Peak Scoring
transport score depth-dose «150 mev source» ProtonBeam «parameters» Particle = proton Histories = 100,000 «tsbox g4_water» WaterPhantom «model» HLZ = 20.0 cm ZBins = 200 «dosetomedium» BraggPeakDose «verification» R80 = 15.77 cm Bethe-Bloch LET
Drag to pan · Click % to reset

TOPAS & GATE Proton & Hadrontherapy Monte Carlo (.topas, .mac) ​

@modelscript/topas (languages/topas) provides native WebAssembly GLR parsing, Geant4 geometry hierarchy and parent-child bounding-box containment verification, Bortfeld (1997) analytical Bragg peak depth-dose and Spread-Out Bragg Peak (SOBP) evaluation, DAEBuilder lowering, and OpenSCAD / Modelica projections for TOPAS (Tool for Particle Simulation) and GATE proton, carbon-ion, and flash radiotherapy beamline configurations.


Supported Extensions & Standards ​

ExtensionFormatDescription
.topas, .txtTOPAS Parameter FileTyped Geant4 parameter system (s: string, d: double with units, i: integer, b: boolean, dv:/sv: vectors) for Ge/, So/, Sc/, and Ph/
.macGATE / Geant4 MacroCommand-stream macro (/gate/world/daughters/..., /gate/source/..., /gate/actor/...) for medical physics Monte Carlo

Key Capabilities ​

1. Typed Geometry (Ge/), Beam Sources (So/) & Dose Scorers (Sc/) ​

  • Parses hierarchical CSG beamline components (TsBox, TsCylinder, TsSphere, TsRangeModulator, TsPropeller, TsMultiLeafCollimator, water phantoms, and patient CT volumes), particle sources (Proton, Carbon12, Electron, Photon), and DoseToMedium / LETd scorers.

2. Analytical Bortfeld Bragg Peak & Range Calculation ​

  • Computes the continuous-slowing-down range R0=αE0p in water (α≈0.0022 cm⋅MeV−p, p≈1.77 for protons), distal 80% dose falloff (R80), peak-to-plateau ratio, and full depth-dose curves D(z) (computeBraggPeakDepthDose).

3. 3D Nozzle CSG & Modelica Projections ​

  • Projects TOPAS/GATE treatment nozzles and water phantoms into OpenSCAD 3D CSG geometry (topasToScad) and Modelica beamline dosimetry models (topasToModelica).

Pre-Flight Diagnostics ​

10 rules9 error1 warning

CodeRuleSeverityMessage
M9601topas-type-prefix-mismatcherrorParameter '<fullPath>' value '<rawVal>' does not match declared TOPAS type prefix '<typePrefix>:'.
M9602topas-unresolved-parent-componenterrorGeometry component '<compName>' references undeclared parent volume '<parentName>'.
M9603topas-non-positive-geometry-dimensionerrorGeometry component '<compName>' has invalid dimension: <detail>.
M9604topas-child-exceeds-parent-boundserrorChild geometry '<childName>' protrudes outside parent '<parentName>' along <axis>-axis ('<childExtent> mm' > '<parentHalfExtent> mm').
M9605topas-undefined-materialerrorComponent '<compName>' references unknown material '<materialName>' not found in Geant4/NIST materials or custom 'Ma/' definitions.
M9606topas-invalid-beam-energyerrorParticle source '<sourceName>' has invalid beam energy specification: <detail>.
M9607topas-circular-include-fileerrorCircular or self-referential includeFile chain detected: '<cycleChain>'.
M9608topas-scorer-missing-componenterrorScorer '<scorerName>' has invalid configuration: <detail>.
M9609topas-vector-length-mismatcherrorVector parameter '<fullPath>' declares length '<declaredCount>' but provides '<actualCount>' elements.
M9610topas-duplicate-parameter-assignmentwarningParameter '<fullPath>' is assigned multiple times in the same file without 'change' override prefix.

Generated from languages/topas/src/lints/rules.ts. All languages →


CLI Usage ​

bash
# Inspect TOPAS/GATE geometry components, beam sources, and scorers
msx topas inspect ProtonNozzle.topas

# Validate parent-child bounding box containment, materials, and beam energy
msx topas validate ProtonNozzle.topas

# Compute analytical Bortfeld Bragg peak range (R0, R80) and depth-dose curve
msx topas bragg-peak ProtonNozzle.topas

# Project treatment nozzle and phantom geometry to OpenSCAD or Modelica
msx topas to-scad ProtonNozzle.topas > ProtonNozzle.scad
msx topas to-modelica ProtonNozzle.topas > ProtonNozzle.mo

Open-Core under the GNU AGPL v3 License; Enterprise Edition (ee/) under the ModelScript Enterprise License. • Pricing • Trademark Policy