Import Geant4 10.3.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2016-06-30 14:12:05 +02:00
parent a654a7ab1f
commit 4ec577e5c4
2021 changed files with 100995 additions and 78277 deletions
@@ -23,28 +23,30 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4DNAScreenedRutherfordElasticModel.cc 92074 2015-08-17 07:03:46Z gcosmo $
// $Id: G4DNAScreenedRutherfordElasticModel.cc 97520 2016-06-03 14:23:17Z gcosmo $
//
#include "G4DNAScreenedRutherfordElasticModel.hh"
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
#include "G4DNAMolecularMaterial.hh"
#include "G4Exp.hh"
#include "G4Log.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
using namespace std;
//#define SR_VERBOSE
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4DNAScreenedRutherfordElasticModel::G4DNAScreenedRutherfordElasticModel(const G4ParticleDefinition*,
const G4String& nam) :
G4DNAScreenedRutherfordElasticModel::
G4DNAScreenedRutherfordElasticModel(const G4ParticleDefinition*,
const G4String& nam) :
G4VEmModel(nam), isInitialised(false)
{
// nistwater = G4NistManager::Instance()->FindOrBuildMaterial("G4_WATER");
fpWaterDensity = 0;
killBelowEnergy = 9 * eV;
lowEnergyLimit = 0 * eV;
intermediateEnergyLimit = 200 * eV; // Switch between two final state models
highEnergyLimit = 1. * MeV;
@@ -59,13 +61,17 @@ G4DNAScreenedRutherfordElasticModel::G4DNAScreenedRutherfordElasticModel(const G
// 3 = calculation of cross sections, file openings, sampling of atoms
// 4 = entering in methods
#ifdef SR_VERBOSE
if (verboseLevel > 0)
{
G4cout << "Screened Rutherford Elastic model is constructed " << G4endl<< "Energy range: "
<< lowEnergyLimit / eV << " eV - "
<< highEnergyLimit / MeV << " MeV"
<< G4endl;
G4cout << "Screened Rutherford Elastic model is constructed "
<< G4endl
<< "Energy range: "
<< lowEnergyLimit / eV << " eV - "
<< highEnergyLimit / MeV << " MeV"
<< G4endl;
}
#endif
fParticleChangeForGamma = 0;
// Selection of computation method
@@ -81,133 +87,159 @@ G4DNAScreenedRutherfordElasticModel::~G4DNAScreenedRutherfordElasticModel()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4DNAScreenedRutherfordElasticModel::Initialise(const G4ParticleDefinition* /*particle*/,
const G4DataVector& /*cuts*/)
void G4DNAScreenedRutherfordElasticModel::
Initialise(const G4ParticleDefinition* particle,
const G4DataVector& /*cuts*/)
{
#ifdef SR_VERBOSE
if (verboseLevel > 3)
G4cout << "Calling G4DNAScreenedRutherfordElasticModel::Initialise()"
<< G4endl;
{
G4cout << "Calling G4DNAScreenedRutherfordElasticModel::Initialise()"
<< G4endl;
}
#endif
if(particle->GetParticleName() != "e-")
{
G4Exception ("*** WARNING: the G4DNAScreenedRutherfordElasticModel is not "
"intented to be used with another particle than the electron",
"",FatalException,"") ;
}
// Energy limits
if (LowEnergyLimit() < lowEnergyLimit)
if (LowEnergyLimit() < 9*eV)
{
G4cout << "G4DNAScreenedRutherfordElasticModel: low energy limit increased from " <<
LowEnergyLimit()/eV << " eV to " << lowEnergyLimit/eV << " eV" << G4endl;
SetLowEnergyLimit(lowEnergyLimit);
G4Exception("*** WARNING: the G4DNAScreenedRutherfordElasticModel class is "
"not validated below 9 eV",
"",JustWarning,"") ;
}
if (HighEnergyLimit() > highEnergyLimit)
if (HighEnergyLimit() > 1*MeV)
{
G4cout << "G4DNAScreenedRutherfordElasticModel: high energy limit decreased from " <<
HighEnergyLimit()/MeV << " MeV to " << highEnergyLimit/MeV << " MeV" << G4endl;
SetHighEnergyLimit(highEnergyLimit);
G4Exception("*** WARNING: the G4DNAScreenedRutherfordElasticModel class is "
"not validated above 1 MeV",
"",JustWarning,"") ;
}
// Constants for final state by Brenner & Zaider
// March 25th, 2014 - Vaclav Stepan, Sebastien Incerti
// Added clear for MT
betaCoeff.clear();
betaCoeff.push_back(7.51525);
betaCoeff.push_back(-0.41912);
betaCoeff.push_back(7.2017E-3);
betaCoeff.push_back(-4.646E-5);
betaCoeff.push_back(1.02897E-7);
deltaCoeff.clear();
deltaCoeff.push_back(2.9612);
deltaCoeff.push_back(-0.26376);
deltaCoeff.push_back(4.307E-3);
deltaCoeff.push_back(-2.6895E-5);
deltaCoeff.push_back(5.83505E-8);
gamma035_10Coeff.clear();
gamma035_10Coeff.push_back(-1.7013);
gamma035_10Coeff.push_back(-1.48284);
gamma035_10Coeff.push_back(0.6331);
gamma035_10Coeff.push_back(-0.10911);
gamma035_10Coeff.push_back(8.358E-3);
gamma035_10Coeff.push_back(-2.388E-4);
gamma10_100Coeff.clear();
gamma10_100Coeff.push_back(-3.32517);
gamma10_100Coeff.push_back(0.10996);
gamma10_100Coeff.push_back(-4.5255E-3);
gamma10_100Coeff.push_back(5.8372E-5);
gamma10_100Coeff.push_back(-2.4659E-7);
gamma100_200Coeff.clear();
gamma100_200Coeff.push_back(2.4775E-2);
gamma100_200Coeff.push_back(-2.96264E-5);
gamma100_200Coeff.push_back(-1.20655E-7);
//
#ifdef SR_VERBOSE
if( verboseLevel>0 )
{
G4cout << "Screened Rutherford elastic model is initialized " << G4endl
<< "Energy range: "
<< LowEnergyLimit() / eV << " eV - "
<< HighEnergyLimit() / MeV << " MeV"
<< G4endl;
<< "Energy range: "
<< LowEnergyLimit() / eV << " eV - "
<< HighEnergyLimit() / MeV << " MeV"
<< G4endl;
}
#endif
if (isInitialised) { return; } // return here, prevent reinit consts + pointer
// Initialize water density pointer
fpWaterDensity = G4DNAMolecularMaterial::Instance()->GetNumMolPerVolTableFor(G4Material::GetMaterial("G4_WATER"));
if (isInitialised)
{ return;}
fpWaterDensity = G4DNAMolecularMaterial::Instance()->
GetNumMolPerVolTableFor(G4Material::GetMaterial("G4_WATER"));
fParticleChangeForGamma = GetParticleChangeForGamma();
isInitialised = true;
// Constants for final state by Brenner & Zaider
// note: if called after if(isInitialised) no need for clear and resetting
// the values at every call
betaCoeff=
{
7.51525,
-0.41912,
7.2017E-3,
-4.646E-5,
1.02897E-7};
deltaCoeff=
{
2.9612,
-0.26376,
4.307E-3,
-2.6895E-5,
5.83505E-8};
gamma035_10Coeff =
{
-1.7013,
-1.48284,
0.6331,
-0.10911,
8.358E-3,
-2.388E-4};
gamma10_100Coeff =
{
-3.32517,
0.10996,
-4.5255E-3,
5.8372E-5,
-2.4659E-7};
gamma100_200Coeff =
{
2.4775E-2,
-2.96264E-5,
-1.20655E-7};
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4DNAScreenedRutherfordElasticModel::CrossSectionPerVolume(const G4Material* material,
const G4ParticleDefinition* particleDefinition,
G4double ekin,
G4double,
G4double)
G4double G4DNAScreenedRutherfordElasticModel::
CrossSectionPerVolume(const G4Material* material,
#ifdef SR_VERBOSE
const G4ParticleDefinition* particleDefinition,
#else
const G4ParticleDefinition*,
#endif
G4double ekin,
G4double,
G4double)
{
#ifdef SR_VERBOSE
if (verboseLevel > 3)
G4cout << "Calling CrossSectionPerVolume() of G4DNAScreenedRutherfordElasticModel"
<< G4endl;
{
G4cout << "Calling CrossSectionPerVolume() of "
"G4DNAScreenedRutherfordElasticModel"
<< G4endl;
}
#endif
// Calculate total cross section for model
G4double sigma=0;
G4double sigma=0.;
G4double waterDensity = (*fpWaterDensity)[material->GetIndex()];
if(waterDensity!= 0.0)
// if (material == nistwater || material->GetBaseMaterial() == nistwater)
{
if (ekin < highEnergyLimit)
if(ekin < HighEnergyLimit() && ekin >= LowEnergyLimit())
{
if (ekin < killBelowEnergy) return DBL_MAX;
G4double z = 10.;
G4double n = ScreeningFactor(ekin,z);
G4double crossSection = RutherfordCrossSection(ekin, z);
sigma = pi * crossSection / (n * (n + 1.));
}
#ifdef SR_VERBOSE
if (verboseLevel > 2)
{
G4cout << "__________________________________" << G4endl;
G4cout << "=== G4DNAScreenedRutherfordElasticModel - XS INFO START" << G4endl;
G4cout << "=== Kinetic energy(eV)=" << ekin/eV << " particle : " << particleDefinition->GetParticleName() << G4endl;
G4cout << "=== Cross section per water molecule (cm^2)=" << sigma/cm/cm << G4endl;
G4cout << "=== Cross section per water molecule (cm^-1)=" << sigma*waterDensity/(1./cm) << G4endl;
// G4cout << " - Cross section per water molecule (cm^-1)=" << sigma*material->GetAtomicNumDensityVector()[1]/(1./cm) << G4endl;
G4cout << "=== G4DNAScreenedRutherfordElasticModel - XS INFO END" << G4endl;
G4cout << "=== G4DNAScreenedRutherfordElasticModel - XS INFO START"
<< G4endl;
G4cout << "=== Kinetic energy(eV)=" << ekin/eV
<< " particle : " << particleDefinition->GetParticleName()
<< G4endl;
G4cout << "=== Cross section per water molecule (cm^2)=" << sigma/cm/cm
<< G4endl;
G4cout << "=== Cross section per water molecule (cm^-1)="
<< sigma*waterDensity/(1./cm) << G4endl;
G4cout << "=== G4DNAScreenedRutherfordElasticModel - XS INFO END"
<< G4endl;
}
#endif
}
return sigma*waterDensity;
@@ -255,7 +287,7 @@ G4double G4DNAScreenedRutherfordElasticModel::ScreeningFactor(G4double k,
const G4double beta_1(-0.0825);
const G4double constK(1.7E-5);
G4double numerator = (alpha_1 + beta_1 * std::log(k / eV)) * constK
G4double numerator = (alpha_1 + beta_1 * G4Log(k / eV)) * constK
* std::pow(z, 2. / 3.);
k /= electron_mass_c2;
@@ -270,43 +302,42 @@ G4double G4DNAScreenedRutherfordElasticModel::ScreeningFactor(G4double k,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4DNAScreenedRutherfordElasticModel::SampleSecondaries(std::vector<
G4DynamicParticle*>* /*fvect*/,
const G4MaterialCutsCouple* /*couple*/,
const G4DynamicParticle* aDynamicElectron,
G4double,
G4double)
void G4DNAScreenedRutherfordElasticModel::
SampleSecondaries(std::vector<G4DynamicParticle*>* /*fvect*/,
const G4MaterialCutsCouple* /*couple*/,
const G4DynamicParticle* aDynamicElectron,
G4double,
G4double)
{
#ifdef SR_VERBOSE
if (verboseLevel > 3)
{
G4cout << "Calling SampleSecondaries() of G4DNAScreenedRutherfordElasticModel"
G4cout << "Calling SampleSecondaries() of "
"G4DNAScreenedRutherfordElasticModel"
<< G4endl;
}
#endif
G4double electronEnergy0 = aDynamicElectron->GetKineticEnergy();
if (electronEnergy0 < killBelowEnergy)
{
fParticleChangeForGamma->SetProposedKineticEnergy(0.);
fParticleChangeForGamma->ProposeTrackStatus(fStopAndKill);
fParticleChangeForGamma->ProposeLocalEnergyDeposit(electronEnergy0);
return;
}
G4double cosTheta = 0.;
if (electronEnergy0>= killBelowEnergy && electronEnergy0 < highEnergyLimit)
// if (electronEnergy0 < highEnergyLimit)
{
if (electronEnergy0<intermediateEnergyLimit)
{
if (verboseLevel > 3) G4cout << "---> Using Brenner & Zaider model" << G4endl;
#ifdef SR_VERBOSE
if (verboseLevel > 3)
{G4cout << "---> Using Brenner & Zaider model" << G4endl;}
#endif
cosTheta = BrennerZaiderRandomizeCosTheta(electronEnergy0);
}
if (electronEnergy0>=intermediateEnergyLimit)
{
if (verboseLevel > 3) G4cout << "---> Using Screened Rutherford model" << G4endl;
#ifdef SR_VERBOSE
if (verboseLevel > 3)
{G4cout << "---> Using Screened Rutherford model" << G4endl;}
#endif
G4double z = 10.;
cosTheta = ScreenedRutherfordRandomizeCosTheta(electronEnergy0,z);
}
@@ -328,12 +359,12 @@ void G4DNAScreenedRutherfordElasticModel::SampleSecondaries(std::vector<
fParticleChangeForGamma->SetProposedKineticEnergy(electronEnergy0);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4DNAScreenedRutherfordElasticModel::BrennerZaiderRandomizeCosTheta(G4double k)
G4double G4DNAScreenedRutherfordElasticModel::
BrennerZaiderRandomizeCosTheta(G4double k)
{
// d sigma_el 1 beta(K)
// ------------ (K) ~ --------------------------------- + ---------------------------------
@@ -347,8 +378,8 @@ G4double G4DNAScreenedRutherfordElasticModel::BrennerZaiderRandomizeCosTheta(G4d
k /= eV;
G4double beta = std::exp(CalculatePolynomial(k, betaCoeff));
G4double delta = std::exp(CalculatePolynomial(k, deltaCoeff));
G4double beta = G4Exp(CalculatePolynomial(k, betaCoeff));
G4double delta = G4Exp(CalculatePolynomial(k, deltaCoeff));
G4double gamma;
if (k > 100.)
@@ -360,11 +391,11 @@ G4double G4DNAScreenedRutherfordElasticModel::BrennerZaiderRandomizeCosTheta(G4d
{
if (k > 10)
{
gamma = std::exp(CalculatePolynomial(k, gamma10_100Coeff));
gamma = G4Exp(CalculatePolynomial(k, gamma10_100Coeff));
}
else
{
gamma = std::exp(CalculatePolynomial(k, gamma035_10Coeff));
gamma = G4Exp(CalculatePolynomial(k, gamma035_10Coeff));
}
}
@@ -390,7 +421,8 @@ G4double G4DNAScreenedRutherfordElasticModel::BrennerZaiderRandomizeCosTheta(G4d
rightDenominator = (1. + 2.*delta + cosTheta);
if ( (leftDenominator * rightDenominator) != 0. )
{
fCosTheta = oneOverMax * (1./(leftDenominator*leftDenominator) + beta/(rightDenominator*rightDenominator));
fCosTheta = oneOverMax * (1./(leftDenominator*leftDenominator)
+ beta/(rightDenominator*rightDenominator));
}
}
while (fCosTheta < G4UniformRand());
@@ -402,7 +434,64 @@ G4double G4DNAScreenedRutherfordElasticModel::BrennerZaiderRandomizeCosTheta(G4d
if (fasterCode)
{
//
// modified by Shogo OKADA @ KEK, JP, 2016.2.27(Sat.)
//
// An integral of differential cross-section formula shown above this member function
// (integral variable: cos(theta), integral interval: [-1, x]) is as follows:
//
// 1.0 + x beta * (1 + x)
// I = --------------------- + ---------------------- (1)
// (a - x) * (a + 1.0) (b + x) * (b - 1.0)
//
// where a = 1.0 + 2.0 * gamma(K), b = 1.0 + 2.0 * delta(K)
//
// Then, a cumulative probability (cp) is as follows:
//
// cp 1.0 + x beta * (1 + x)
// ---- = --------------------- + ---------------------- (2)
// S (a - x) * (a + 1.0) (b + x) * (b - 1.0)
//
// where 1/S is the integral of differnetical cross-section (1) on interval [-1, 1]
//
// 1 2.0 2.0 * beta
// --- = ----------------------- + ----------------------- (3)
// S (a - 1.0) * (a + 1.0) (b + 1.0) * (b - 1.0)
//
// x is calculated from the quadratic equation derived from (2) and (3):
//
// A * x^2 + B * x + C = 0
//
// where A, B, anc C are coefficients of the equation:
// A = S * {(b - 1.0) - beta * (a + 1.0)} + cp * (a + 1.0) * (b - 1.0),
// B = S * {(b - 1.0) * (b + 1.0) + beta * (a - 1.0) * (a + 1.0)} - cp * (a + 1.0) * (b - 1.0) * (a - b)
// C = S * {b * (b - 1.0) + beta * a * (a + 1.0)} - cp * (a + 1.0) * (b - 1.0) * ab
//
// sampling cumulative probability
G4double cp = G4UniformRand();
G4double a = 1.0 + 2.0 * gamma;
G4double b = 1.0 + 2.0 * delta;
G4double a1 = a - 1.0;
G4double a2 = a + 1.0;
G4double b1 = b - 1.0;
G4double b2 = b + 1.0;
G4double c1 = a - b;
G4double c2 = a * b;
G4double S = 2.0 / (a1 * a2) + 2.0 * beta / (b1 * b2); S = 1.0 / S;
// coefficients for the quadratic equation
G4double A = S * (b1 - beta * a2) + cp * a2 * b1;
G4double B = S * (b1 * b2 + beta * a1 * a2) - cp * a2 * b1 * c1;
G4double C = S * (b * b1 + beta * a * a2) - cp * a2 * b1 * c2;
// calculate cos(theta)
return (-1.0 * B + std::sqrt(B * B - 4.0 * A * C)) / (2.0 * A);
/*
G4double cosTheta = -1;
G4double cumul = 0;
G4double value = 0;
@@ -438,6 +527,7 @@ G4double G4DNAScreenedRutherfordElasticModel::BrennerZaiderRandomizeCosTheta(G4d
}
return cosTheta;
*/
}
return 0.;
@@ -445,9 +535,9 @@ G4double G4DNAScreenedRutherfordElasticModel::BrennerZaiderRandomizeCosTheta(G4d
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4DNAScreenedRutherfordElasticModel::CalculatePolynomial(G4double k,
std::vector<
G4double>& vec)
G4double G4DNAScreenedRutherfordElasticModel::
CalculatePolynomial(G4double k,
std::vector<G4double>& vec)
{
// Sum_{i=0}^{size-1} vector_i k^i
//
@@ -469,8 +559,9 @@ G4double G4DNAScreenedRutherfordElasticModel::CalculatePolynomial(G4double k,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4DNAScreenedRutherfordElasticModel::ScreenedRutherfordRandomizeCosTheta(G4double k,
G4double z)
G4double G4DNAScreenedRutherfordElasticModel::
ScreenedRutherfordRandomizeCosTheta(G4double k,
G4double z)
{
// d sigma_el sigma_Ruth(K)
@@ -509,7 +600,33 @@ G4double G4DNAScreenedRutherfordElasticModel::ScreenedRutherfordRandomizeCosThet
// ***** Alternative method using cumulative probability
if (fasterCode)
{
//
// modified by Shogo OKADA @ KEK, JP, 2016.2.27(Sat.)
//
// The cumulative probability (cp) is calculated by integrating
// the differential cross-section fomula with cos(theta):
//
// n(K) * (1.0 + cos(theta))
// cp = ---------------------------------
// 1.0 + 2.0 * n(K) - cos(theta)
//
// Then, cos(theta) is as follows:
//
// cp * (1.0 + 2.0 * n(K)) - n(K)
// cos(theta) = --------------------------------
// n(k) + cp
//
// where, K is kinetic energy, n(K) is screeing factor, and cp is cumulative probability
//
G4double n = ScreeningFactor(k, z);
G4double cp = G4UniformRand();
G4double numerator = cp * (1.0 + 2.0 * n) - n;
G4double denominator = n + cp;
return numerator / denominator;
/*
G4double cosTheta = -1;
G4double cumul = 0;
G4double value = 0;
@@ -538,8 +655,10 @@ G4double G4DNAScreenedRutherfordElasticModel::ScreenedRutherfordRandomizeCosThet
if (random < value) break;
}
return cosTheta;
*/
}
return 0.;
}