Neutron simulation

Please fill out the following information to help in answering your question, and also see tips for posting code snippets. If you don’t provide this information it will take more time to help with your problem!

_Geant4 Version:_11.2.2
_Operating System:_ubuntu 24.04.02
_CMake Version:_3.28.3


I’m new to Geant4 and currently trying to simulate neutrons using the GPS macro in Geant4, but I’ve encountered an issue when running my simulation. Specifically, after selecting the physics list for neutrons and executing beamOn, the program crashes with a “core dumped” error.
Could anyone kindly point me in the right direction or share advice on how to resolve this issue? Any help would be greatly appreciated.

this is my physicsList
include “physics.hh”

//define constructor
MyPhysicsList::MyPhysicsList()
{
//define physics
RegisterPhysics (new G4EmStandardPhysics());
RegisterPhysics (new G4OpticalPhysics());

//define physics of decay for radioactive source
RegisterPhysics (new G4DecayPhysics()); //handle particle decays
RegisterPhysics (new G4RadioactiveDecayPhysics());
RegisterPhysics (new G4HadronElasticPhysicsHP());
RegisterPhysics (new G4HadronPhysicsQGSP_BERT_HP());

G4double CutValue = 0.1*um;
    SetCutValue(CutValue, "gamma");

}

MyPhysicsList::~MyPhysicsList()
{}

GPS macro in which i define neutron
/gps/particle neutron
/gps/ene/mono 10000 keV
/gps/pos/type Point
/gps/ang/type iso
/gps/pos/centre 0. 0. 16. mm

vis.mac file
/run/initialize
/vis/open OGLI

/vis/viewer/set/autoRefresh false
/vis/verbose errors

/vis/drawVolume
/vis/viewer/set/viewpointVector -1 0 0
/vis/viewer/set/rotationStyle freeRotation
/vis/scene/add/trajectories smooth
/vis/modeling/trajectories/create/drawByCharge
/vis/modeling/trajectories/drawByCharge-0/default/setDrawStepPts false
/vis/modeling/trajectories/drawByCharge-0/default/setStepPtsSize 1

(if too many tracks cause core dump => /tracking/storeTrajectory 0)

/vis/scene/add/axes
/vis/scene/add/scale
/vis/scene/add/eventID

/vis/modeling/trajectories/create/drawByParticleID
/vis/modeling/trajectories/drawByParticleID-0/set e- red
/vis/modeling/trajectories/drawByParticleID-0/set gamma green
/vis/modeling/trajectories/drawByParticleID-0/set neutron yellow
/vis/modeling/trajectories/drawByParticleID-0/set alpha blue
/vis/modeling/trajectories/drawByParticleID-0/set GenericIon blue

/vis/scene/endOfEventAction accumulate 10

/vis/viewer/set/autoRefresh true
/vis/verbose warnings

/control/execute gps.mac

and this is what I’m getting
-------- WWWW -------- G4Exception-END --------- WWWW -------

G4ParticleHPNames: There are no data available for some isotopes in this material
G4ParticleHPNames: nor are there data for nearby isotopes.
G4ParticleHPNames: Please make sure G4NEUTRONHPDATA points to the directory
G4ParticleHPNames: in which the neutron scattering data are located.
G4ParticleHPNames: The material was A = 71, Z = 31

-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : hadhp01
issued by : G4ParticleHPName::Init(…)
Data for Z=31 A=71 M=0 does not exist in G4NEUTRONHPDATA

*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------

G4ParticleHPNames: There are no data available for some isotopes in this material
G4ParticleHPNames: nor are there data for nearby isotopes.
G4ParticleHPNames: Please make sure G4NEUTRONHPDATA points to the directory
G4ParticleHPNames: in which the neutron scattering data are located.
G4ParticleHPNames: The material was A = 69, Z = 31

-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : hadhp01
issued by : G4ParticleHPName::Init(…)
Data for Z=31 A=69 M=0 does not exist in G4NEUTRONHPDATA

*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------

G4ParticleHPNames: There are no data available for some isotopes in this material
G4ParticleHPNames: nor are there data for nearby isotopes.
G4ParticleHPNames: Please make sure G4NEUTRONHPDATA points to the directory
G4ParticleHPNames: in which the neutron scattering data are located.
G4ParticleHPNames: The material was A = 71, Z = 31

-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : hadhp01
issued by : G4ParticleHPName::Init(…)
Data for Z=31 A=71 M=0 does not exist in G4NEUTRONHPDATA

*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------

=======================================================
====== ParticleHP Physics Parameters ========

Use only photo-evaporation 0
Skip missing isotopes 0
Neglect Doppler 0
Do not adjust final state 0
Produce fission fragments 0
Use WendtFissionModel 0
Use NRESP71Model 0
Use DBRC 0
PHP use Poisson 0
PHP check 1
CHECK HP NAMES 0
Enable DEBUG 0

msc: for pi+ SubType= 10
===== EM models for the G4Region DefaultRegionForTheWorld ======
WentzelVIUni : Emin= 0 eV Emax= 100 TeV Nbins=84 100 eV - 100 TeV
StepLim=Minimal Rfact=0.2 Gfact=2.5 Sfact=0.6 DispFlag:0 Skin=1 Llim=1 mm

hIoni: for pi+ XStype:3 SubType=2
dE/dx and range tables from 100 eV to 100 TeV in 84 bins
Lambda tables from threshold to 100 TeV, 7 bins/decade, spline: 1
StepFunction=(0.2, 0.1 mm), integ: 3, fluct: 1, linLossLim= 0.01
===== EM models for the G4Region DefaultRegionForTheWorld ======
Bragg : Emin= 0 eV Emax=297.505 keV
BetheBloch : Emin=297.505 keV Emax= 100 TeV

hBrems: for pi+ XStype:1 SubType=3
dE/dx and range tables from 100 eV to 100 TeV in 84 bins
Lambda tables from threshold to 100 TeV, 7 bins/decade, spline: 1
===== EM models for the G4Region DefaultRegionForTheWorld ======
hBrem : Emin= 0 eV Emax= 100 TeV ModifiedMephi

hPairProd: for pi+ XStype:1 SubType=4
dE/dx and range tables from 100 eV to 100 TeV in 84 bins
Lambda tables from threshold to 100 TeV, 7 bins/decade, spline: 1
Sampling table 20x1001; from 1.11656 GeV to 100 TeV
===== EM models for the G4Region DefaultRegionForTheWorld ======
hPairProd : Emin= 0 eV Emax= 100 TeV ModifiedMephi

CoulombScat: for pi+ XStype:1 SubType=1 BuildTable=1
Lambda table from threshold to 100 TeV, 7 bins/decade, spline: 0
ThetaMin(p) < Theta(degree) < 180, pLimit(GeV^1)= 0.139531
===== EM models for the G4Region DefaultRegionForTheWorld ======
eCoulombScattering : Emin= 0 eV Emax= 100 TeV

msc: for pi- SubType= 10
===== EM models for the G4Region DefaultRegionForTheWorld ======
WentzelVIUni : Emin= 0 eV Emax= 100 TeV Nbins=84 100 eV - 100 TeV
StepLim=Minimal Rfact=0.2 Gfact=2.5 Sfact=0.6 DispFlag:0 Skin=1 Llim=1 mm

hIoni: for pi- XStype:3 SubType=2
dE/dx and range tables from 100 eV to 100 TeV in 84 bins
Lambda tables from threshold to 100 TeV, 7 bins/decade, spline: 1
StepFunction=(0.2, 0.1 mm), integ: 3, fluct: 1, linLossLim= 0.01
===== EM models for the G4Region DefaultRegionForTheWorld ======
ICRU73QO : Emin= 0 eV Emax=297.505 keV
BetheBloch : Emin=297.505 keV Emax= 100 TeV

hBrems: for pi- XStype:1 SubType=3
dE/dx and range tables from 100 eV to 100 TeV in 84 bins
Lambda tables from threshold to 100 TeV, 7 bins/decade, spline: 1
===== EM models for the G4Region DefaultRegionForTheWorld ======
hBrem : Emin= 0 eV Emax= 100 TeV ModifiedMephi

hPairProd: for pi- XStype:1 SubType=4
dE/dx and range tables from 100 eV to 100 TeV in 84 bins
Lambda tables from threshold to 100 TeV, 7 bins/decade, spline: 1
Sampling table 20x1001; from 1.11656 GeV to 100 TeV
===== EM models for the G4Region DefaultRegionForTheWorld ======
hPairProd : Emin= 0 eV Emax= 100 TeV ModifiedMephi

CoulombScat: for pi- XStype:1 SubType=1 BuildTable=1
Used Lambda table of pi+
ThetaMin(p) < Theta(degree) < 180, pLimit(GeV^1)= 0.139531
===== EM models for the G4Region DefaultRegionForTheWorld ======
eCoulombScattering : Emin= 0 eV Emax= 100 TeV
Segmentation fault (core dumped)

First of all, I just started using Geant4 a month ago, but from my initial experience, you should always check the first error and not the last to be faster in debugging.

It seems to me that you either haven’t set up your environment variables correctly (see Postinstall Setup — Geant4 Installation Guide 11.3 documentation) or you didn’t download the required data sets.

You can check using “echo $G4NEUTRONHPDATA” if it points to a valid path with the data it’s another problem.

I hope this helps.

thank you so much!!! Now it’s working.