Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4DensityEffectCalculator Class Reference

#include <G4DensityEffectCalculator.hh>

Public Member Functions

 G4DensityEffectCalculator (const G4Material *, G4int)
 
 ~G4DensityEffectCalculator ()
 
G4double ComputeDensityCorrection (G4double x)
 

Detailed Description

Definition at line 53 of file G4DensityEffectCalculator.hh.

Constructor & Destructor Documentation

◆ G4DensityEffectCalculator()

G4DensityEffectCalculator::G4DensityEffectCalculator ( const G4Material mat,
G4int  n 
)

Definition at line 56 of file G4DensityEffectCalculator.cc.

57 : fMaterial(mat), fVerbose(0), fWarnings(0), nlev(n)
58{
59 fVerbose = std::max(fVerbose, G4NistManager::Instance()->GetVerbose());
60
61 sternf = new G4double [nlev];
62 levE = new G4double [nlev];
63 sternl = new G4double [nlev];
64 sternEbar = new G4double [nlev];
65 for(G4int i=0; i<nlev; ++i) {
66 sternf[i] = 0.0;
67 levE[i] = 0.0;
68 sternl[i] = 0.0;
69 sternEbar[i] = 0.0;
70 }
71
72 fConductivity = sternx = 0.0;
73 G4bool conductor = (fMaterial->GetFreeElectronDensity() > 0.0);
74
75 G4int sh = 0;
76 G4double sum = 0.;
77 const G4double tot = fMaterial->GetTotNbOfAtomsPerVolume();
78 for(size_t j = 0; j < fMaterial->GetNumberOfElements(); ++j) {
79 // The last subshell is considered to contain the conduction
80 // electrons. Sternheimer 1984 says "the lowest chemical valance of
81 // the element" is used to set the number of conduction electrons.
82 // I'm not sure if that means the highest subshell or the whole
83 // shell, but in any case, he also says that the choice is arbitrary
84 // and offers a possible alternative. This is one of the sources of
85 // uncertainty in the model.
86 const G4double frac = fMaterial->GetVecNbOfAtomsPerVolume()[j]/tot;
87 const G4int Z = fMaterial->GetElement((G4int)j)->GetZasInt();
89 for(G4int i = 0; i < nshell; ++i) {
90 // For conductors, put *all* top shell electrons into the conduction
91 // band, regardless of element.
93 if(i < nshell-1 || !conductor) {
94 sternf[sh] += xx;
95 } else {
96 fConductivity += xx;
97 }
98 levE[sh] = G4AtomicShells::GetBindingEnergy(Z, i)/CLHEP::eV;
99 ++sh;
100 }
101 }
102 for(G4int i=0; i<nlev; ++i) {
103 sum += sternf[i];
104 }
105 sum += fConductivity;
106
107 const G4double invsum = (sum > 0.0) ? 1./sum : 0.0;
108 for(G4int i=0; i<nlev; ++i) {
109 sternf[i] *= invsum;
110 }
111 fConductivity *= invsum;
112 plasmaE = fMaterial->GetIonisation()->GetPlasmaEnergy()/CLHEP::eV;
113 meanexcite = fMaterial->GetIonisation()->GetMeanExcitationEnergy()/CLHEP::eV;
114}
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
const G4int Z[17]
static G4int GetNumberOfElectrons(G4int Z, G4int SubshellNb)
static G4double GetBindingEnergy(G4int Z, G4int SubshellNb)
static G4int GetNumberOfShells(G4int Z)
G4double GetMeanExcitationEnergy() const
G4double GetPlasmaEnergy() const
G4double GetTotNbOfAtomsPerVolume() const
Definition: G4Material.hh:204
const G4Element * GetElement(G4int iel) const
Definition: G4Material.hh:197
G4IonisParamMat * GetIonisation() const
Definition: G4Material.hh:221
G4double GetFreeElectronDensity() const
Definition: G4Material.hh:174
size_t GetNumberOfElements() const
Definition: G4Material.hh:181
const G4double * GetVecNbOfAtomsPerVolume() const
Definition: G4Material.hh:201
static G4NistManager * Instance()

◆ ~G4DensityEffectCalculator()

G4DensityEffectCalculator::~G4DensityEffectCalculator ( )

Definition at line 116 of file G4DensityEffectCalculator.cc.

117{
118 delete [] sternf;
119 delete [] levE;
120 delete [] sternl;
121 delete [] sternEbar;
122}

Member Function Documentation

◆ ComputeDensityCorrection()

G4double G4DensityEffectCalculator::ComputeDensityCorrection ( G4double  x)

Definition at line 124 of file G4DensityEffectCalculator.cc.

125{
126 if(fVerbose > 1) {
127 G4cout << "G4DensityEffectCalculator::ComputeDensityCorrection for "
128 << fMaterial->GetName() << ", x= " << x << G4endl;
129 }
130 const G4double approx = fMaterial->GetIonisation()->GetDensityCorrection(x);
131 const G4double exact = FermiDeltaCalculation(x);
132
133 if(fVerbose > 1) {
134 G4cout << " Delta: computed= " << exact
135 << ", parametrized= " << approx << G4endl;
136 }
137 if(approx >= 0. && exact < 0.) {
138 if(fVerbose > 0) {
139 ++fWarnings;
140 if(fWarnings < maxWarnings) {
142 ed << "Sternheimer fit failed for " << fMaterial->GetName()
143 << ", x = " << x << ": Delta exact= "
144 << exact << ", approx= " << approx;
145 G4Exception("G4DensityEffectCalculator::DensityCorrection", "mat008",
146 JustWarning, ed);
147 }
148 }
149 return approx;
150 }
151 // Fall back to approx if exact and approx are very different, under the
152 // assumption that this means the exact calculation has gone haywire
153 // somehow, with the exception of the case where approx is negative. I
154 // have seen this clearly-wrong result occur for substances with extremely
155 // low density (1e-25 g/cc).
156 if(approx >= 0. && std::abs(exact - approx) > 1.) {
157 if(fVerbose > 0) {
158 ++fWarnings;
159 if(fWarnings < maxWarnings) {
161 ed << "Sternheimer exact= " << exact << " and approx= "
162 << approx << " are too different for "
163 << fMaterial->GetName() << ", x = " << x;
164 G4Exception("G4DensityEffectCalculator::DensityCorrection", "mat008",
165 JustWarning, ed);
166 }
167 }
168 return approx;
169 }
170 return exact;
171}
const G4int maxWarnings
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4double GetDensityCorrection(G4double x) const
const G4String & GetName() const
Definition: G4Material.hh:172

Referenced by G4IonisParamMat::DensityCorrection().


The documentation for this class was generated from the following files: