Simulation Work Continued and Troubleshooting
March 25, 2026
Over the past week, I worked on developing my own simulation setup within the TOPAS and Geant4 framework. I moved past the given example setups and I created my own tumor-in-lung model with custom defined parameters and beam configurations. This code was housed in a “nano”, which allowed me to run it through TOPAS/Geant4 using the topas command.
Here is what the setup looks like:
# WORLD
s:Ge/World/Type = “TsBox”
d:Ge/World/HLX = 50 cm
d:Ge/World/HLY = 50 cm
d:Ge/World/HLZ = 50 cm
s:Ge/World/Material = “G4_AIR”
# LUNG
s:Ge/Lung/Type = “TsBox”
s:Ge/Lung/Parent = “World”
d:Ge/Lung/HLX = 20 cm
d:Ge/Lung/HLY = 20 cm
d:Ge/Lung/HLZ = 20 cm
s:Ge/Lung/Material = “G4_LUNG_ICRP”
# TUMOR
s:Ge/Tumor/Type = “TsBox”
s:Ge/Tumor/Parent = “Lung”
d:Ge/Tumor/HLX = 5 cm
d:Ge/Tumor/HLY = 5 cm
d:Ge/Tumor/HLZ = 1 cm
s:Ge/Tumor/Material = “G4_WATER”
d:Ge/Tumor/TransZ = 10 cm
# BEAM
s:So/Beam/Type = “Beam”
s:So/Beam/BeamParticle = “proton”
d:So/Beam/Energy = 150 MeV
s:So/Beam/Component = “World”
# Beam position
s:So/Beam/BeamPositionDistribution = “Flat”
s:So/Beam/BeamPositionCutoffShape = “Rectangle”
d:So/Beam/BeamPositionCutoffX = 2 cm
d:So/Beam/BeamPositionCutoffY = 2 cm
d:So/Beam/TransX = 0 cm
d:So/Beam/TransY = 0 cm
d:So/Beam/TransZ = -40 cm
# Beam direction
i:So/Beam/BeamDirectionX = 0
i:So/Beam/BeamDirectionY = 0
i:So/Beam/BeamDirectionZ = 1
# Angular spread
s:So/Beam/BeamAngularDistribution = “None”
# RUN CONTROL
i:Ts/NumberOfHistories = 10000
# SCORING
s:Sc/Dose/Quantity = “DoseToMedium”
s:Sc/Dose/Component = “Tumor”
i:Sc/Dose/NBinsX = 50
i:Sc/Dose/NBinsY = 50
i:Sc/Dose/NBinsZ = 1
s:Sc/Dose/OutputType = “csv”
s:Sc/Dose/IfOutputFileAlreadyExists = “Overwrite”
I was compiled this and ran it in terminal. I also began using python more to try to visualize my simulation outputs. I was able to get some simple graphs to generate using basic setups, which indicated python and matplotlib were running fine. However, when I moved onto my TumorInLung setup, I encountered a persistent issue, which was that the simulation repeatedly registered “zero histories”, despite me explicitly defining thousands of histories in my input nano file (in essence, this meant the simulation registered 0 photons, despite the setup containing instructions to run it with 10000). The error looks something like this:
TOPAS run sequence complete.
Particle source Beam: Total number of histories: 0
Particle source Demo: Total number of histories: 0
I looked at multiple potential fixes, including adjusting beam parameters, configurations, and spatial separations between different parts, but the issue still remains unresolved. This debugging process has taken a while, and resolving this is my next step for the upcoming week.
In parallel with this coding work, I refined the conceptual direction of my project and expanded my scope to include CT scans, which also has relevance to K-edge imaging. My project is now more clearly focused on investigating how Inverse Compton Scattering (ICS) X-ray sources compare to conventional hospital X-ray systems, which typically rely on broad, polychromatic radiation. Using TOPAS/Geant4, I aim to evaluate whether ICS based sources, capable of producing narrower, more tunable energy spectra, can provide improved imaging performance and *reduced unnecessary radiation exposure* (lower overall dosage + less stray radiation). I also plan to include comparisons with CT imaging to better contextualize the potential advantages of ICS systems.

Leave a Reply
You must be logged in to post a comment.