KAHIBARO
Discord Login Register

24.5. Varying Shield Thickness

Why Vary Shield Thickness

In a radiation shielding study you usually want to know how effectively a given material reduces the radiation intensity. This effectiveness depends both on the material and on the shield thickness. With Geant4 you can explore this dependence numerically by simulating the same source and detector geometry while changing only the thickness of the shield.

In this chapter you focus on how to vary shield thickness within a single Geant4 application, how to control it from C++ and from macro commands, and how to prepare the simulation so that later chapters can compare transmission and attenuation across different thicknesses.

Choosing a Strategy

There are several practical ways to change shield thickness in Geant4. For a beginner friendly radiation shielding example, two approaches are most useful.

The first approach is to make the shield thickness a configurable parameter in your detector construction class. You then rebuild the geometry whenever the parameter changes. This works well when you want to run a sequence of simulations with fixed thickness values, for example 1 cm, 2 cm, 5 cm, and so on.

The second approach is to build the geometry with many thin layers from the start and treat different numbers of layers as different effective thicknesses. For a first example this can be more complex to implement, so the single parameter approach is usually better.

The key idea is that shield thickness must not be hard coded as a constant. It must be stored in a variable that is used to build the geometry and that can be changed before each set of events.

Always store shield thickness in a variable used when constructing the geometry, and never as a fixed number scattered throughout the code.

Parameterizing Shield Thickness in DetectorConstruction

Most Geant4 examples use a user class derived from G4VUserDetectorConstruction, often named DetectorConstruction. To make shield thickness adjustable, you introduce a member variable in this class that represents the current shield thickness, for example G4double fShieldThickness.

In the class constructor you assign a sensible default value, such as a few centimeters, that will be used if the user does not override it. You then modify the Construct() method so that any solid which represents the shielding material uses fShieldThickness when you define its dimension along the beam direction.

For example, if the shield is a simple box placed between the source and detector, the half thickness in that direction becomes 0.5 * fShieldThickness instead of a hard coded number. This is the only change required inside the solids definition, but it must be done carefully so that all dependent geometry, such as placements, remains consistent when the thickness changes.

Whenever you change the shield thickness variable, you must reconstruct the geometry so that the new value is reflected in the solids and placements.

Rebuilding Geometry When Thickness Changes

Geant4 does not automatically update the geometry when you change a variable in your detector construction class. Instead, you either reconstruct the geometry explicitly in C++, or you use the built in commands that tell the kernel to rebuild the world volume.

A typical workflow is to change the thickness before you start a new run, then notify the run manager that the geometry has changed. The run manager will call your Construct() method again, and your new shield thickness will be applied.

You must never change the geometry while events are being processed. Always modify the thickness and rebuild the geometry between runs, not during a run.

Change shield thickness and rebuild the geometry only between runs, never in the middle of /run/beamOn.

Exposing Thickness via a Messenger

To avoid recompiling for each thickness value, you can control shield thickness with macro commands. This is very useful if you want to script a series of runs with different thicknesses.

To do this in a clean way, you can create a messenger class associated with your detector construction, or at least a G4UIcmdWithADoubleAndUnit command that sets fShieldThickness. The command might look like /shield/setThickness 2.0 cm.

The messenger class receives the new value, passes it to a setter method in DetectorConstruction, and you then ensure that the geometry is rebuilt before the next run. This approach lets you define a macro file that loops over different thicknesses by setting the command, reinitializing the geometry, and starting a new run for each thickness.

A typical macro sequence for a single thickness would be:

  1. Set shield thickness with your custom command.
  2. Initialize or reinitialize the geometry.
  3. Start a run with the desired number of events.

Even if you are not yet implementing the messenger in full detail, it is important to design your detector construction so that thickness can be changed from outside the class.

Running Multiple Thickness Values

Once thickness is parameterized, you can plan a series of runs that sample a range of shield thicknesses. For instance, you might simulate shields from 0 cm up to several tens of centimeters, depending on the material and photon energy.

For each thickness you should:

  1. Set the shield thickness variable, either by calling a C++ setter or by a macro command.
  2. Tell Geant4 to reinitialize geometry, for example with /run/initialize if the detector construction is new, or /run/reinitializeGeometry after the first initialization.
  3. Use a fixed number of primary events with the same source configuration as in the previous chapters.
  4. Record the transmitted particles or deposited energy downstream of the shield. The details of what you record will be covered in the later sections about transmission and attenuation.

Keep all other conditions identical between runs so that any change in measured transmission can be attributed solely to the change in shield thickness.

When comparing different shield thicknesses, change only the thickness and keep source, physics list, and detector configuration identical.

Choosing Thickness Steps

The choice of thickness steps depends on the physics you want to study and the material. For thin shields you may want fine steps to see rapid changes in transmission. For very thick shields you may need coarser steps, because transmission can become very small and you will need more events to obtain reasonable statistics.

Although the actual numbers belong to the later analysis chapters, you should already plan the range of thicknesses in a way that spans from almost no attenuation to strong attenuation, so that later you can extract meaningful attenuation coefficients.

A simple pattern such as equal linear steps, for example every 1 cm, is usually good enough for a beginner example.

Preparing for Later Analysis

All the work of making shield thickness configurable is done so that the later steps, recording transmitted particles, calculating transmission, and computing attenuation, can be performed for many thickness values in the same application.

To make analysis easier later, you can already consider how you will label or identify runs with different thicknesses. For example, you can print the current thickness at the beginning of each run, and you can include it in any output file name or in the header of your results, so that you never mix up which data corresponds to which shield thickness.

As you proceed to the following chapters, the variable shield thickness will become the main independent parameter in your numerical study of radiation shielding performance.

Views: 7

Comments

Please login to add a comment.

Don't have an account? Register now!