Import Geant4 11.2.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2023-06-30 09:09:57 +02:00
parent aef78ca386
commit dd1f179cda
3780 changed files with 212808 additions and 142780 deletions
@@ -1,33 +0,0 @@
# ----------------------------------------------------------------
# GNUmakefile for hadronic management library. G.Folger 10-Dec-97
# ----------------------------------------------------------------
name := G4hadronic_util
ifndef G4INSTALL
G4INSTALL = ../../../..
endif
include $(G4INSTALL)/config/architecture.gmk
CPPFLAGS += -DG4HADRONIC_ALLOC_EXPORT
CPPFLAGS += -I$(G4BASE)/global/management/include \
-I$(G4BASE)/global/HEPRandom/include \
-I$(G4BASE)/global/HEPGeometry/include \
-I$(G4BASE)/global/HEPNumerics/include \
-I$(G4BASE)/intercoms/include \
-I$(G4BASE)/track/include \
-I$(G4BASE)/geometry/volumes/include \
-I$(G4BASE)/geometry/management/include \
-I$(G4BASE)/particles/management/include \
-I$(G4BASE)/particles/leptons/include \
-I$(G4BASE)/particles/bosons/include \
-I$(G4BASE)/particles/hadrons/mesons/include \
-I$(G4BASE)/particles/hadrons/barions/include \
-I$(G4BASE)/particles/hadrons/ions/include \
-I$(G4BASE)/processes/management/include \
-I$(G4BASE)/materials/include
include $(G4INSTALL)/config/common.gmk
+41 -2
View File
@@ -7,11 +7,50 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2023-05-25 Alberto Ribon (hadr-util-V11-00-14)
## 2023-05-25 Alberto Ribon (hadr-util-V11-01-06)
- G4Fragment : replaced (fatal) G4HadronicException with G4Exception.
Note: in the method CalculateMassAndExcitationEnergy(), the exception type
is "EventMustBeAborted" to avoid rare crashes seen in INCLXX, which
are difficult to reproduce and fix.
are difficult to reproduce and fix.
## 2023-04-25 Vladimir Ivanchenko (hadr-util-V11-01-05)
- G4HadronicParameters - added extra Boolean method for access to debug
flag for the BinaryCascade, which may be defined via environment
variable BINARY_CASCADE_DEBUG
## 2023-03-29 Vladimir Ivanchenko (hadr-util-V11-01-04)
- G4HadronicParameters - added two strings and extra methods to access
environment variables used in G4HadronicProcessStore. These variables
are not used in ordinary runs but are checked in each thread and for
each particle. With this update these variables will be checked only once.
Added G4Exception for the case, when environment variable G4PARTICLEXSDATA
is not defined (gitlab issue #160).
## 2023-03-27 Alberto Ribon (hadr-util-V11-01-03)
- G4HadronicParameter : introduced the neutron kinetic energy threshold for
applying the SVT (Sampling of the Velocity of the Target) algorithm.
This is needed to have a consistent value in the two methods
G4Nucleus::GetBiasedThermalNucleus and
G4ParticleHPElasticFS::GetBiasedThermalNucleus
without cycling dependencies between util/ and models/particle_hp/ .
- G4Nucleus : in the method GetBiasedThermalNucleus, get the neutron kinetic
energy threshold for applying the SVT algorithm from G4HadronicParameter
in the method DoKinematicsOfThermalNucleus, and corrected the way to pass
the last parameter, by reference instead of by value.
## 2023-03-04 Alberto Ribon (hadr-util-V11-01-02)
- G4Nucleus : split the method GetBiasedThermalNucleus into two parts, by
introducing a new public method, DoKinematicsOfThermalNucleus (which is
used also by G4ParticleHPElasticFS to implement the DBRC algorithm).
## 2023-01-21 Vladimir Ivanchenko (hadr-util-V11-01-01)
- G4HadronicParameters - removed two obsolete environment variables and access
methods; add flag for charge exchange
## 2023-01-09 Vladimir Ivanchenko (hadr-util-V11-01-00)
- G4HadronicParameters - added class members defined via environment variable
and access methods for these members, this allows exclude the major part
of calls to std::getenv in hadronics
## 2022-11-26 Gabriele Cosmo (hadr-util-V11-00-13)
- Fixed compilation warnings for implicit type conversions on macOS/XCode 14.1.
@@ -50,7 +50,7 @@ class G4HadronicParameters {
static G4HadronicParameters* Instance();
~G4HadronicParameters();
G4double GetMaxEnergy() const;
inline G4double GetMaxEnergy() const;
void SetMaxEnergy( const G4double val );
// Getter/Setter for the upper limit for Geant4 hadronic physics, for any application.
// Any hadronic model, physics list builder and constructor should use this method
@@ -58,68 +58,68 @@ class G4HadronicParameters {
// Any application which tries to use hadronic physics for an energy higher than this limit
// will get a run-time crash, because no model is found.
G4double GetMinEnergyTransitionFTF_Cascade() const;
G4double GetMaxEnergyTransitionFTF_Cascade() const;
inline G4double GetMinEnergyTransitionFTF_Cascade() const;
inline G4double GetMaxEnergyTransitionFTF_Cascade() const;
void SetMinEnergyTransitionFTF_Cascade( const G4double val );
void SetMaxEnergyTransitionFTF_Cascade( const G4double val );
// Getter/Setter of the recommended energy limits, for physics lists, of the
// transition region between the Fritiof (FTF) string model and the
// intranuclear cascade model, either Bertini (BERT) or Binary (BIC).
G4double GetMinEnergyTransitionQGS_FTF() const;
G4double GetMaxEnergyTransitionQGS_FTF() const;
inline G4double GetMinEnergyTransitionQGS_FTF() const;
inline G4double GetMaxEnergyTransitionQGS_FTF() const;
void SetMinEnergyTransitionQGS_FTF( const G4double val );
void SetMaxEnergyTransitionQGS_FTF( const G4double val );
// Getter/Setter of the recommended energy limits, for physics lists, of the
// transition region between the two strings models - the Quark Gluon String (QGS)
// model and the Fritiof (FTF) model.
G4double EnergyThresholdForHeavyHadrons() const;
inline G4double EnergyThresholdForHeavyHadrons() const;
void SetEnergyThresholdForHeavyHadrons( G4double val );
// if max kinetic energy is below this limit EM and hadronic physics is not
// instantiated for hyperons, anti-hyperons, anti light ions, b-, c- particles
// If max kinetic energy is below this limit, then EM and hadronic physics are not
// instantiated for hyperons, anti-hyperons, anti light ions, b-, c- particles.
G4double XSFactorNucleonInelastic() const;
inline G4double XSFactorNucleonInelastic() const;
void SetXSFactorNucleonInelastic( G4double val );
G4double XSFactorNucleonElastic() const;
inline G4double XSFactorNucleonElastic() const;
void SetXSFactorNucleonElastic( G4double val );
// cross section factor for protons and neutrons
// Cross section factor for protons and neutrons.
G4double XSFactorPionInelastic() const;
inline G4double XSFactorPionInelastic() const;
void SetXSFactorPionInelastic( G4double val );
G4double XSFactorPionElastic() const;
inline G4double XSFactorPionElastic() const;
void SetXSFactorPionElastic( G4double val );
// cross section factor for pions
// Cross section factor for pions.
G4double XSFactorHadronInelastic() const;
inline G4double XSFactorHadronInelastic() const;
void SetXSFactorHadronInelastic( G4double val );
G4double XSFactorHadronElastic() const;
inline G4double XSFactorHadronElastic() const;
void SetXSFactorHadronElastic( G4double val );
// cross section factor for other hadrons and ions
// Cross section factor for other hadrons and ions.
G4double XSFactorEM() const;
inline G4double XSFactorEM() const;
void SetXSFactorEM( G4double val );
// cross section factor for gamma and leptons
// Cross section factor for gamma and leptons.
G4bool EnableBCParticles() const;
inline G4bool EnableBCParticles() const;
void SetEnableBCParticles( G4bool val );
// Baryons and mesons with c- and b- quarks may be enabled/disabled
// This flag is used both by EM and hadronic physics constructors
// Baryons and mesons with c- and b- quarks may be enabled/disabled.
// This flag is used both by EM and hadronic physics constructors.
G4bool EnableHyperNuclei() const;
inline G4bool EnableHyperNuclei() const;
void SetEnableHyperNuclei( G4bool val );
// Light hyper-nuclei may be enabled/disabled
// This flag is used both by EM and hadronic physics constructors
// Light hyper-nuclei may be enabled/disabled.
// This flag is used both by EM and hadronic physics constructors.
G4bool ApplyFactorXS() const;
inline G4bool ApplyFactorXS() const;
void SetApplyFactorXS( G4bool val );
// Flag enabling cross section factor definition
// Flag enabling cross section factor definition.
G4int GetVerboseLevel() const;
inline G4int GetVerboseLevel() const;
void SetVerboseLevel( const G4int val );
// Getter/Setter of the general verbosity level for hadronics.
G4bool EnableCRCoalescence() const;
inline G4bool EnableCRCoalescence() const;
void SetEnableCRCoalescence( G4bool val );
// Boolean switch that allows to apply the Cosmic Ray (CR) coalescence algorithm
// to the secondaries produced by a string model. By default it is disabled.
@@ -128,19 +128,38 @@ class G4HadronicParameters {
inline G4bool EnableIntegralElasticXS() const;
void SetEnableIntegralInelasticXS( G4bool val );
void SetEnableIntegralElasticXS( G4bool val );
// Enable/disable integral method for main hadrons
// Enable/disable integral method for main types of hadrons.
inline G4bool EnableDiffDissociationForBGreater10() const;
/// For nucleon-hadron interactions, it's not decided what to do with diffraction
/// dissociation. For the moment, they are turned off. This option allows it to
/// be turned back on. Applies to Baryon Number > 10 or # target nucleons > 10.
// For nucleon-hadron interactions, it's not decided what to do with diffraction
// dissociation. For the moment, they are turned off. This option allows it to
// be turned back on. Applies to Baryon Number > 10 or # target nucleons > 10.
void SetEnableDiffDissociationForBGreater10(G4bool val);
inline G4bool EnableCoherentChargeExchange() const;
void SetEnableCoherentChargeExchange( G4bool val );
// Coherent Charge exchange process may be enabled/disabled.
inline G4bool EnableNeutronGeneralProcess() const;
void SetEnableNeutronGeneralProcess( G4bool val );
// Neutron general process may be enabled/disabled
// Neutron general process may be enabled/disabled.
inline G4double GetEPRelativeLevel() const;
inline G4double GetEPAbsoluteLevel() const;
inline G4int GetEPReportLevel() const;
inline G4bool GetBinaryDebug() const;
inline const G4String& GetDirPARTICLEXS() const;
inline const G4String& GetPhysListDocDir() const;
inline const G4String& GetPhysListName() const;
// Access to environment variables.
inline G4double GetNeutronKineticEnergyThresholdForSVT() const;
void SetNeutronKineticEnergyThresholdForSVT( const G4double val );
// Getter/Setter for the neutron kinetic energy threshold for
// applying the SVT (Sampling of the Velocity of the Target) algorithm.
private:
G4HadronicParameters();
G4bool IsLocked() const;
@@ -163,8 +182,13 @@ class G4HadronicParameters {
G4double fXSFactorHadronElastic = 1.0;
G4double fXSFactorEM = 1.0;
G4double fXSFactorLimit = 0.2;
G4double fRelativeDiff = DBL_MAX;
G4double fAbsoluteDiff = DBL_MAX;
G4double fNeutronEkinThresholdForSVT = -1.0;
G4int fVerboseLevel = 1;
G4int fReportLevel = 0;
G4bool fEnableBC = false;
G4bool fEnableHyperNuclei = false;
G4bool fApplyFactorXS = false;
@@ -173,6 +197,12 @@ class G4HadronicParameters {
G4bool fEnableIntegralElasticXS = true;
G4bool fEnableDiffDissociationForBGreater10 = false;
G4bool fNeutronGeneral = false;
G4bool fChargeExchange = false;
G4bool fBinaryDebug = false;
G4String fDirPARTICLEXS = "";
G4String fPhysListDocDir = "";
G4String fPhysListName = "";
};
inline G4double G4HadronicParameters::GetMaxEnergy() const {
@@ -262,4 +292,42 @@ inline G4bool G4HadronicParameters::EnableNeutronGeneralProcess() const {
return fNeutronGeneral;
}
inline G4bool G4HadronicParameters::EnableCoherentChargeExchange() const {
return fChargeExchange;
}
inline G4bool G4HadronicParameters::GetBinaryDebug() const {
return fBinaryDebug;
}
inline G4double G4HadronicParameters::GetEPRelativeLevel() const {
return fRelativeDiff;
}
inline G4double G4HadronicParameters::GetEPAbsoluteLevel() const {
return fAbsoluteDiff;
}
inline G4int G4HadronicParameters::GetEPReportLevel() const {
return fReportLevel;
}
inline const G4String& G4HadronicParameters::GetDirPARTICLEXS() const {
return fDirPARTICLEXS;
}
inline const G4String& G4HadronicParameters::GetPhysListDocDir() const
{
return fPhysListDocDir;
}
inline const G4String& G4HadronicParameters::GetPhysListName() const
{
return fPhysListName;
}
inline G4double G4HadronicParameters::GetNeutronKineticEnergyThresholdForSVT() const {
return fNeutronEkinThresholdForSVT;
}
#endif
@@ -134,6 +134,9 @@ class G4Nucleus
G4ReactionProduct GetBiasedThermalNucleus(G4double aMass, G4ThreeVector aVelocity, G4double temp=-1) const;
void DoKinematicsOfThermalNucleus(const G4double mu, const G4double vT_norm, const G4ThreeVector& aVelocity,
G4ReactionProduct& result) const;
G4double Cinema( G4double kineticEnergy );
G4double EvaporationEffects( G4double kineticEnergy );
@@ -77,6 +77,31 @@ G4HadronicParameters::G4HadronicParameters() {
fMaxEnergyTransitionQGS_FTF = 25.0*CLHEP::GeV;
fEnergyThresholdForHeavyHadrons = 1.1*CLHEP::GeV;
fMessenger = new G4HadronicParametersMessenger( this );
// read environment variables
fReportLevel = G4GetEnv<G4int>("G4Hadronic_epReportLevel", 0);
const char* ep1 = std::getenv("G4Hadronic_epCheckRelativeLevel");
if(nullptr != ep1) { fRelativeDiff = std::strtod(ep1, 0); }
const char* ep2 = std::getenv("G4Hadronic_epCheckAbsoluteLevel");
if(nullptr != ep2) { fAbsoluteDiff = std::strtod(ep2, 0); }
const char* v = G4FindDataDir("G4PARTICLEXSDATA");
if(nullptr != v) {
fDirPARTICLEXS = G4String(v);
} else {
if(1 < fVerboseLevel) {
G4ExceptionDescription ed;
ed << "Environment variable G4PARTICLEXSDATA is not defined or "
<< " it is pointing out to not existing directory";
G4Exception("G4LevelReader::LevelManager(..)","had014",
JustWarning, ed, "Check file path");
}
}
const char* x = std::getenv("G4PhysListDocDir");
if(nullptr != x) { fPhysListDocDir = G4String(x); }
const char* y = std::getenv("G4PhysListName");
if(nullptr != y) { fPhysListName = G4String(y); }
const char* z = std::getenv("BINARY_CASCADE_DEBUG");
if(nullptr != z) { fBinaryDebug = true; }
}
@@ -190,6 +215,15 @@ void G4HadronicParameters::SetXSFactorEM( G4double val ) {
}
void G4HadronicParameters::SetNeutronKineticEnergyThresholdForSVT( const G4double val ) {
// This setting works only after initialization (i.e. for G4State_Idle,
// whereas it does not work for G4State_PreInit).
if ( G4Threading::IsMasterThread() && val > 0.0 ) {
fNeutronEkinThresholdForSVT = val;
}
}
void G4HadronicParameters::SetApplyFactorXS( G4bool val ) {
if ( ! IsLocked() ) fApplyFactorXS = val;
}
@@ -218,3 +252,8 @@ void G4HadronicParameters::SetEnableDiffDissociationForBGreater10( G4bool val )
void G4HadronicParameters::SetEnableNeutronGeneralProcess( G4bool val ) {
if ( ! IsLocked() ) fNeutronGeneral = val;
}
void G4HadronicParameters::SetEnableCoherentChargeExchange( G4bool val ) {
if ( ! IsLocked() ) fChargeExchange = val;
}
+67 -55
View File
@@ -50,6 +50,7 @@
#include "G4Exp.hh"
#include "G4Log.hh"
#include "G4HyperNucleiProperties.hh"
#include "G4HadronicParameters.hh"
G4Nucleus::G4Nucleus()
@@ -117,10 +118,12 @@ G4Nucleus::~G4Nucleus() {}
G4ReactionProduct
G4Nucleus::GetBiasedThermalNucleus(G4double aMass, G4ThreeVector aVelocity, G4double temp) const
{
// If E_neutron <= 400*kB*T (400 is a common value encounter in MC neutron transport code)
// Then apply the Sampling ot the Velocity of the Target (SVT) method
// Else consider the target nucleus being without motion
G4double E_threshold = 400.0*8.617333262E-11*temp; // 400*kBoltzman*T
// If E_neutron <= E_threshold, Then apply the Sampling ot the Velocity of the Target (SVT) method;
// Else consider the target nucleus being without motion.
G4double E_threshold = G4HadronicParameters::Instance()->GetNeutronKineticEnergyThresholdForSVT();
if ( E_threshold == -1. ) {
E_threshold = 400.0*8.617333262E-11*temp;
}
G4double E_neutron = 0.5*aVelocity.mag2()*G4Neutron::Neutron()->GetPDGMass(); // E=0.5*m*v2
G4ReactionProduct result;
@@ -170,57 +173,8 @@ G4Nucleus::GetBiasedThermalNucleus(G4double aMass, G4ThreeVector aVelocity, G4do
randThreshold = G4UniformRand();
} while ( randThreshold >= acceptThreshold );
// Get target nucleus direction from the neutron direction and the relative angle between target nucleus and neutron (mu)
G4double cosTh = mu;
G4ThreeVector uNorm = aVelocity;
G4double sinTh = std::sqrt(1. - cosTh*cosTh);
// Sample randomly the phi angle between the neutron veloicty and the target velocity
G4double phi = CLHEP::twopi*G4UniformRand();
G4double sinPhi = std::sin(phi);
G4double cosPhi = std::cos(phi);
// Find orthogonal vector to aVelocity - solve equation xx' + yy' + zz' = 0
G4ThreeVector ortho(1,1,1);
if ( uNorm[0] ) ortho[0] = -(uNorm[1]+uNorm[2])/uNorm[0];
else if ( uNorm[1] ) ortho[1] = -(uNorm[0]+uNorm[2])/uNorm[1];
else if ( uNorm[2] ) ortho[2] = -(uNorm[0]+uNorm[1])/uNorm[2];
// Normalize the vector
ortho = (1/ortho.mag())*ortho;
// Find vector to draw a plan perpendicular to uNorm (i.e neutron velocity) with vectors ortho & orthoComp
G4ThreeVector orthoComp( uNorm[1]*ortho[2] - ortho[1]*uNorm[2],
uNorm[2]*ortho[0] - ortho[2]*uNorm[0],
uNorm[0]*ortho[1] - ortho[0]*uNorm[1] );
// Find the direction of the target velocity in the laboratory frame
G4ThreeVector directionTarget( cosTh*uNorm[0] + sinTh*(cosPhi*orthoComp[0] + sinPhi*ortho[0]),
cosTh*uNorm[1] + sinTh*(cosPhi*orthoComp[1] + sinPhi*ortho[1]),
cosTh*uNorm[2] + sinTh*(cosPhi*orthoComp[2] + sinPhi*ortho[2]) );
// Normalize directionTarget
directionTarget = (1/directionTarget.mag())*directionTarget;
// Set momentum
G4double px = result.GetMass()*vT_norm*directionTarget[0];
G4double py = result.GetMass()*vT_norm*directionTarget[1];
G4double pz = result.GetMass()*vT_norm*directionTarget[2];
result.SetMomentum(px, py, pz);
G4double tMom = std::sqrt(px*px+py*py+pz*pz);
G4double tEtot = std::sqrt((tMom+result.GetMass())*(tMom+result.GetMass())
- 2.*tMom*result.GetMass());
if ( tEtot/result.GetMass() - 1. > 0.001 ) {
// use relativistic energy for higher energies
result.SetTotalEnergy(tEtot);
} else {
// use p**2/2M for lower energies (to preserve precision?)
result.SetKineticEnergy(tMom*tMom/(2.*result.GetMass()));
}
DoKinematicsOfThermalNucleus(mu, vT_norm, aVelocity, result);
} else { // target nucleus considered as being without motion
result.SetMomentum(0., 0., 0.);
@@ -232,6 +186,64 @@ G4Nucleus::GetBiasedThermalNucleus(G4double aMass, G4ThreeVector aVelocity, G4do
}
void
G4Nucleus::DoKinematicsOfThermalNucleus(const G4double mu, const G4double vT_norm, const G4ThreeVector& aVelocity,
G4ReactionProduct& result) const {
// Get target nucleus direction from the neutron direction and the relative angle between target nucleus and neutron (mu)
G4double cosTh = mu;
G4ThreeVector uNorm = aVelocity;
G4double sinTh = std::sqrt(1. - cosTh*cosTh);
// Sample randomly the phi angle between the neutron veloicty and the target velocity
G4double phi = CLHEP::twopi*G4UniformRand();
G4double sinPhi = std::sin(phi);
G4double cosPhi = std::cos(phi);
// Find orthogonal vector to aVelocity - solve equation xx' + yy' + zz' = 0
G4ThreeVector ortho(1., 1., 1.);
if ( uNorm[0] ) ortho[0] = -(uNorm[1]+uNorm[2])/uNorm[0];
else if ( uNorm[1] ) ortho[1] = -(uNorm[0]+uNorm[2])/uNorm[1];
else if ( uNorm[2] ) ortho[2] = -(uNorm[0]+uNorm[1])/uNorm[2];
// Normalize the vector
ortho = (1/ortho.mag())*ortho;
// Find vector to draw a plan perpendicular to uNorm (i.e neutron velocity) with vectors ortho & orthoComp
G4ThreeVector orthoComp( uNorm[1]*ortho[2] - ortho[1]*uNorm[2],
uNorm[2]*ortho[0] - ortho[2]*uNorm[0],
uNorm[0]*ortho[1] - ortho[0]*uNorm[1] );
// Find the direction of the target velocity in the laboratory frame
G4ThreeVector directionTarget( cosTh*uNorm[0] + sinTh*(cosPhi*orthoComp[0] + sinPhi*ortho[0]),
cosTh*uNorm[1] + sinTh*(cosPhi*orthoComp[1] + sinPhi*ortho[1]),
cosTh*uNorm[2] + sinTh*(cosPhi*orthoComp[2] + sinPhi*ortho[2]) );
// Normalize directionTarget
directionTarget = ( 1./directionTarget.mag() )*directionTarget;
// Set momentum
G4double px = result.GetMass()*vT_norm*directionTarget[0];
G4double py = result.GetMass()*vT_norm*directionTarget[1];
G4double pz = result.GetMass()*vT_norm*directionTarget[2];
result.SetMomentum(px, py, pz);
G4double tMom = std::sqrt(px*px+py*py+pz*pz);
G4double tEtot = std::sqrt( (tMom+result.GetMass())*(tMom+result.GetMass())
- 2.*tMom*result.GetMass() );
if ( tEtot/result.GetMass() - 1. > 0.001 ) {
// use relativistic energy for higher energies
result.SetTotalEnergy(tEtot);
} else {
// use p**2/2M for lower energies (to preserve precision?)
result.SetKineticEnergy(tMom*tMom/(2.*result.GetMass()));
}
}
G4ReactionProduct
G4Nucleus::GetThermalNucleus(G4double targetMass, G4double temp) const
{