4.3. Adding the World
Table of Contents
World size
In every GATE simulation, the “world” is the outermost volume that contains everything else. Before you add detectors, phantoms, or sources, you must define this world volume and tell GATE how big it is.
Conceptually, the world should be a simple shape that fully encloses all geometry and all possible particle tracks. In practice, a box-shaped world is usually sufficient for medical physics simulations, and it is the default choice in OpenGATE.
In Python, once you have created your simulation object (covered in the previous sections), you typically access and configure the world like this:
import opengate as gate
from opengate import g4_units
sim = gate.Simulation()
world = sim.world
world.size = [2 * g4_units.m, 2 * g4_units.m, 2 * g4_units.m]
The key point here is the world.size attribute, which is a 3-element list giving the half lengths in $x$, $y$, and $z$ of the world box, in GATE units. If you set [2 m, 2 m, 2 * m], the full world size will be $4 \text{ m} \times 4 \text{ m} \times 4 \text{ m}$.
Always specify world dimensions with explicit units, for example 2 g4_units.m or 100 g4_units.cm. Never use bare numbers without units.
For beginners, a simple way to choose the world size is:
- Decide what is the largest physical object you will simulate, including detectors, shielding, and phantoms.
- Add a safety margin in every direction so particles that scatter or escape still remain inside the world.
- Use a cubic or rectangular box with half lengths several times larger than your largest object.
For example, if your detector is about 50 cm across, you might choose a world with half lengths of $150$ cm in all directions:
world.size = [150 * g4_units.cm, 150 * g4_units.cm, 150 * g4_units.cm]This world will comfortably contain the detector, any reasonable scatter, and also leave room if you later add shielding or support structures.
If the world is too small, particles can reach the boundaries and be stopped artificially. This can truncate scatter, change energy spectra, and distort dose or fluence results. On the other hand, choosing a world that is excessively large can make navigation through the geometry slightly slower, especially when combined with very detailed internal structures. For most introductory medical simulations, a few meters in each direction are more than enough and do not harm performance.
Finally, remember that all other volumes are defined relative to the world. When you place a detector or phantom at some position, that position is given in the coordinate system of the world. Defining the world size at the beginning makes it easier to think about where your objects will be located.
World material
After defining the world size, you must choose what fills the world. The world material is the medium through which particles travel whenever they are not inside another volume. In medical physics simulations, the world is usually filled with air or vacuum, depending on whether you want to simulate interactions with the surrounding environment.
You set the world material using its name from the Geant4 material database:
world.material = "G4_AIR"This example fills the world with standard air at room temperature and pressure. It is a good default choice for most imaging and detector simulations, where detectors, patients, and phantoms are naturally surrounded by air.
If you prefer to ignore interactions with air and approximate an empty space, you can set a vacuum material instead, such as:
world.material = "G4_Galactic"This predefined material represents a very low-density vacuum and greatly reduces interactions outside your main volumes. It is useful when you are only interested in what happens inside a phantom or detector and want to minimize computation in the surrounding region.
Always use valid Geant4 material names, such as "G4_AIR", "G4_WATER", or "G4_Galactic". If you misspell a material name or use a material that has not been defined, the simulation will fail at initialization.
The choice of world material can influence:
- How often particles interact before reaching your volume of interest.
- The amount of scattered radiation that appears in your detectors.
- The realism of your simulation environment.
For example, in a PET scanner simulation where the scanner is in air, "G4_AIR" is appropriate. In a pure dosimetry test where you only want to study protons in water without any external effects, a vacuum world can simplify the problem.
In more advanced simulations, you can also customize or replace standard materials, but for a first simulation, picking "G4_AIR" or "G4_Galactic" for the world is enough.
Putting the previous pieces together, a minimal world definition in your first GATE simulation might look like this:
import opengate as gate
from opengate import g4_units
sim = gate.Simulation()
world = sim.world
world.size = [1 * g4_units.m, 1 * g4_units.m, 1 * g4_units.m]
world.material = "G4_AIR"With these two lines for size and material, you have created a basic world volume that is large enough and correctly filled. You can now safely proceed to add detectors, phantoms, and sources inside it in the next steps of your first GATE simulation.
Views: 15
KAHIBARO