Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to simulate neutron detector under geant4 under python?

Under python , i want to develop :

  • A detector CSL ( TI) with geometry of 1 cm * 1 cm * 2 cm

  • will detect shielded container of cobalt ( 60 ) with a cylinder
    geometry.

    MEDevel.com: Open-source for Healthcare and Education

    Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

    Visit Medevel

import geant4_pybind as g4
import os

# Set the G4ENSDFSTATEDATA environment variable
ensdfstate_data_path = r"C:\Users\mouad\Desktop\G4\gears\INSTALL\Geant4\data\G4ENSDFSTATE2.3"
os.environ["G4ENSDFSTATEDATA"] = ensdfstate_data_path

# Initialize NIST Material Manager
nist_manager = g4.G4NistManager.Instance()

# Materials
air = nist_manager.FindOrBuildMaterial("G4_AIR")
silicon = nist_manager.FindOrBuildMaterial("G4_Si")
lead = nist_manager.FindOrBuildMaterial("G4_Pb")

# World Volume
world_size = 1 * g4.m
world_solid = g4.G4Box("World", world_size/2, world_size/2, world_size/2)
world_logic = g4.G4LogicalVolume(world_solid, air, "World")
world_phys = g4.G4PVPlacement(g4.G4Transform3D(), world_logic, "World", None, False, 0)

# Detector Volume
detector_size = g4.G4ThreeVector(1 * g4.cm, 1 * g4.cm, 2 * g4.cm)
detector_solid = g4.G4Box("Detector", detector_size.x/2, detector_size.y/2, detector_size.z/2)
detector_logic = g4.G4LogicalVolume(detector_solid, silicon, "Detector")
detector_position = g4.G4ThreeVector(0, 0, 0)
detector_phys = g4.G4PVPlacement(g4.G4Transform3D(), detector_logic, "Detector", world_logic, False, 0)

# Source Container (Cylindrical Geometry)
container_radius = 5 * g4.cm
container_height = 10 * g4.cm
container_solid = g4.G4Tubs("Container", 0, container_radius, container_height/2, 0, 2*g4.pi)
container_logic = g4.G4LogicalVolume(container_solid, lead, "Container")
container_position = g4.G4ThreeVector(0, 0, 5 * g4.cm)
container_phys = g4.G4PVPlacement(g4.G4Transform3D(), container_logic, "Container", world_logic, False, 0)

# Create a run manager
run_manager = g4.G4RunManager()

# Physics List
physics_list = g4.FTFP_BERT()
run_manager.SetUserInitialization(physics_list)

# Initialize and Run
run_manager.Initialize()
run_manager.BeamOn(1000)  # Number of events to simulate

I got following error :

>>> run_manager = g4.G4RunManager()

-------- EEEE ------- G4Exception-START -------- EEEE -------
    *** G4Exception : PART70001
          issued by : G4NuclideTable
    ENSDFSTATE.dat is not found.
    *** Fatal Exception *** core dump ***
     **** Track information is not available at this moment
     **** Step information is not available at this moment
    
    -------- EEEE -------- G4Exception-END --------- EEEE -------
    
    
    *** G4Exception: Aborting execution ***

>Solution :

You have already set the variable ensdfstate_data_path to the correct path, but it seems that Geant4 is not recognizing it. Make sure that the path is correctly formatted for your operating system. It appears that you are using a Windows path format, so you may need to adjust it accordingly.

Try using the following code to set the environment variable:

import geant4_pybind as g4
import os

# Set the G4ENSDFSTATEDATA environment variable
ensdfstate_data_path = r"C:\Users\mouad\Desktop\G4\gears\INSTALL\Geant4\data\G4ENSDFSTATE2.3"
os.environ["G4ENSDFSTATEDATA"] = ensdfstate_data_path

# ... rest of your code ...

Make sure to replace r"C:\Users\mouad\Desktop\G4\gears\INSTALL\Geant4\data\G4ENSDFSTATE2.3" with the correct path to the directory containing the ENSDFSTATE.dat file on your system.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading