38.4. Phase-Space Sources
Table of Contents
Creating sources from recorded particles
Phase space data describes the state of particles that cross a given surface at a given time. Once you have recorded such particles with a phase-space actor, you can reuse them as an input particle source in a new GATE simulation. This avoids simulating the whole upstream geometry again and is one of the main reasons to use phase-space files.
In this chapter you will focus on how to turn existing phase-space data into new sources. You will not learn how to record phase space itself here, because that is covered in the previous chapter of this section.
Why create a source from phase space?
A phase-space source is a way to reuse a previously simulated particle distribution as if it were a normal source in GATE. Instead of defining a simple point or volume source with a given spectrum and angular distribution, you tell GATE to read particles from a phase-space file that was written in an earlier run.
This is particularly useful when you have a complex upstream part of the system, for example a linear accelerator head or a full CT gantry, that is expensive to simulate for every study. You can simulate it once, record all particles on a scoring plane, and then create a phase-space source that reproduces those particles as input for many different downstream simulations, such as different patients, phantoms, or detector designs.
Conceptually, you separate the simulation into two stages. The first stage produces phase-space particles at a surface. The second stage uses those particles as an incoming source to whatever geometry you want to study.
Basic idea of a phase-space source in GATE
In an OpenGATE Python simulation, a phase-space source behaves like any other source object from the point of view of the simulation. You still add it to the simulation object, it still has a name, and you can still control its activity and time interval. The difference is that instead of configuring a distribution for energy, position, and direction, you reference the phase-space file and tell GATE which particle attributes to read.
The phase-space file is usually created by a phase-space actor and stored in a format such as ROOT or a text-like file that OpenGATE can read. Each entry in this file corresponds to one particle crossing the phase-space surface, with attributes such as position, direction, energy, particle type, and time.
When the simulation runs, the phase-space source samples entries from this file and generates new particles that inherit these attributes. It can use each recorded particle once, or reuse them multiple times, depending on your configuration.
Setting up a phase-space source in a Python script
To create a phase-space source in OpenGATE, you usually follow these steps:
You first create the simulation object and geometry, including the volume that will receive the incoming particles from the phase space. Then you add a new source with something like sim.add_source. When specifying the type of this source, instead of a simple generic type, you choose the type that corresponds to a phase-space source. The exact string or class name may depend on the OpenGATE version you use, but the idea is the same: GATE must know that the primary particles will come from a file.
Next, you point the source to the phase-space file produced in the previous simulation. You also specify which tree or dataset inside the file contains the particles if the file format requires it. Finally, you configure options that define how GATE reads and reuses particles, such as sequential reading or random access, and whether to loop over the file multiple times.
Most of the usual source parameters like position and direction are taken directly from the phase-space file, so you do not define them manually. The virtual source position is, in practice, the scoring plane where the phase space was recorded. You place your downstream geometry so that this plane is just upstream of the region you want to simulate now.
The following table summarizes the main configuration ideas.
| Aspect | For a normal source | For a phase-space source |
|---|---|---|
| Particle definition | User chooses type and spectrum | Read from phase-space file entries |
| Position and direction | Defined by simple geometric distributions | Taken from recorded positions and directions |
| Energy distribution | Simple distributions or monoenergetic | Exact recorded energy for each particle |
| Time distribution | Simple time law or constant rate | Recorded times or reinterpreted according to activity |
| Reuse of particles | Not applicable | Configurable reuse and looping over the file |
Using phase-space sources with activity and time
In the original phase-space recording, the actor may have stored an absolute time for each particle, or only a relative event index. When you create a phase-space source, you must decide how to interpret this in the new simulation.
In many applications you want the phase-space particles to represent a realistic beam or scanner flux over a given acquisition time. GATE usually lets you specify the activity or the number of particles to generate from the phase-space file. If you set an activity, GATE will relate the particle generation rate to the simulation time and may use or ignore the recorded times in the file depending on your settings.
It is important to understand whether your phase-space file has meaningful time information or not. If it does, and you are studying time-resolved effects, you may want to keep the original time structure. If it does not, you might choose to assign new times uniformly over the acquisition interval.
When you reuse phase-space particles multiple times, the same original time stamps would repeat unless GATE offsets them or regenerates them. You should check how your version of OpenGATE handles this, and verify the resulting time distribution in a simple test run, for example by recording a time histogram with an actor.
Matching geometry between phase space and new simulation
To use a phase-space source correctly, the geometry in your second simulation must be consistent with how the phase space was recorded. The phase-space surface, for example a plane or a volume boundary, defined where the particles were recorded in the first simulation. In the second simulation, you must place that same surface, or an equivalent plane, at exactly the same spatial location and orientation relative to the incoming beam.
If you shift or rotate the downstream geometry incorrectly, you can easily introduce errors in the angular distribution or in which particles interact with the geometry. In practice, this means you must know precisely the position and orientation of the phase-space actor in the original run, and reproduce that location in your new simulation.
If you want to change the beam direction or scanner orientation compared to the original phase space, you may need to transform the recorded coordinates and directions. Some tools and actors in GATE can perform such transformations, but it is safer for beginners to first work with aligned geometries and only later explore more advanced transformations.
A phase-space source must be spatially consistent with the geometry used when recording the phase space. If the scoring plane location or orientation is not matched correctly, the resulting simulation can be physically incorrect even though it runs without errors.
Reuse, looping, and statistical considerations
A phase-space file contains a finite number of particles. If your new simulation requires more particles, you have two main options. You can generate new particles only up to the number of entries in the file, or you can loop and reuse the file multiple times.
Reusing particles improves statistical precision without rerunning the expensive upstream simulation. However, it also introduces correlations, because the same particle histories are used more than once. For many practical applications in imaging and therapy dosimetry, this reuse is acceptable, but it is important to be aware of it.
Some configurations allow random access to the phase-space file, possibly with a random seed. This slightly reduces the visible repetition structure, although the same finite set of particles is still reused.
From a practical point of view, you should record a phase-space file with enough particles to cover several downstream simulations if possible. That way, you limit the amount of reuse that is necessary.
When comparing results that are based on the same phase-space file, it is often helpful to keep the reuse strategy consistent between runs so that statistical differences are easier to interpret.
Filtering and selecting particles from phase space
Another useful feature when creating sources from phase-space data is the ability to apply selection criteria. You might not want to use every recorded particle, for example if the phase space contains several particle types, and you are only interested in photons, or only in protons. You may want to restrict energy to a certain range, or include only particles that cross a given region of the scoring plane.
GATE typically allows you to specify filters when reading from a phase-space file. For example, you can accept only particles whose type is gamma, or whose energy exceeds a threshold. This is conceptually similar to actor filters, but applied at the source stage.
Filtering reduces the effective number of particles available. If you apply very restrictive filters to a small phase-space file, you may force GATE to reuse particles many times, which can increase correlations. It is therefore useful to plan your recording so that it already focuses on the types and energy ranges you are likely to need later.
You can also create several phase-space sources from the same file, each with different filters, and use them together in one simulation. For example, one source could use only photons and another only electrons, each with its own activity, allowing flexible composition of complex beams.
Typical applications of phase-space sources
Although the detailed use in accelerators and scanners is covered elsewhere in the course, it is helpful to connect the concept of phase-space sources to concrete tasks.
In external beam radiotherapy, a phase-space file recorded at the exit of the treatment head can be reused as a source for many patient or phantom simulations. You can switch patients without regenerating the complex head simulation. Similarly, for proton therapy, a phase space at the nozzle exit can become the starting point for many water phantom or patient simulations.
In CT and x ray system modeling, you can record the beam just before it enters the patient region, and later use that beam as a source for different detectors or patient geometries.
In PET and SPECT, phase-space sources are less common at the patient level but can be very useful for scanner design, for example by using a phase-space file at an intermediate collimator or shielding surface when optimizing detector components.
Across all these applications, the logic is the same: expensive upstream physics and geometry are simulated once and captured as a phase-space file, then turned into a reusable source that feeds many downstream studies.
A phase-space source reproduces exactly the distributions and limitations of the recorded particles. If the original phase-space recording used simplified physics or incomplete geometry, every simulation based on that phase-space source will inherit those approximations.
By understanding how to create and configure sources from recorded particles, you gain a powerful tool to speed up complex workflows, perform parameter studies efficiently, and reuse high quality upstream simulations across many projects.
Views: 12
KAHIBARO