Geant4  10.01
XVCrystalIntegratedDensity.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 
28 
30  fNumberOfPoints = 512;
31  fIntegrationPoints[0] = 32;
32  fIntegrationPoints[1] = 32;
33  fIntegrationPoints[2] = 32;
34 }
35 
36 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
37 
39 }
40 
41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
42 
44 SetIntegrationPoints(unsigned int vIndex,
45  unsigned int vIntegrationPoints){
46  if(vIndex<3) {
47  if(vIntegrationPoints > 0){
48  fIntegrationPoints[vIndex] = vIntegrationPoints;
49  }
50  }
51 }
52 
53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
54 
56 GetIntegrationPoints(unsigned int vIndex){
57  if(vIndex<3) {
58  return fIntegrationPoints[vIndex];
59  }
60  else{
61  return 0;
62  }
63 }
64 
65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
66 
69 }
70 
71 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
72 
74 SetNumberOfPoints(unsigned int vNumberOfPoints){
75  fNumberOfPoints = vNumberOfPoints;
76 }
77 
78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
79 
81  return fNumberOfPoints;
82 }
83 
84 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
85 
88  fPotential = vPotential;
89 }
90 
91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
92 
94  return fPotential;
95 }
96 
97 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
98 
101  fDensity = vDensity;
102 }
103 
104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
105 
107  return fDensity;
108 }
109 
110 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
111 
114  fLattice = vLattice;
115 }
116 
117 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
118 
120  return fLattice;
121 }
122 
123 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
124 
126  fParticleCharge = vParticleCharge;
127 }
128 
129 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
130 
132  return fParticleCharge;
133 }
134 
135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
136 
139 }
140 
141 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
142 
145  G4int vParticleCharge){
146  //now it checks only of the table is initialized,
147  //it does not check if the particular crystal is initialized.
148  //To be changed in the future!
149  if(fTableVector->GetVectorLength() == 0) return false;
150  else if(vLattice!=fLattice) return false;
151  else if(vParticleCharge!=fParticleCharge) return false;
152  else return true;
153 }
154 
155 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
156 
159  if(fParticleCharge < 0.){
161  }
162 
164  if(fParticleCharge < 0.){
166  }
167 
169 }
170 
171 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
172 
174 
176 
177  G4cout << "XVCrystalIntegratedDensity::InitializeTable()::";
178  G4cout << "Potential Range = " << fPotentialRange/CLHEP::eV;
179  G4cout << " - Minimum = " << fPotentialMinimum / CLHEP::eV;
180  G4cout << " - Maximum " << fPotentialMaximum / CLHEP::eV << G4endl;
181 
182  G4double vPotentialInitial = 0.;
183 
184  fTableVector =
185  new G4PhysicsLinearVector(0.,
188 
189  G4double vValue = 0;
190  for(unsigned int i=0;i<GetNumberOfPoints();i++){
191  vPotentialInitial = (fPotentialMinimum +
194  vValue = ComputeIntegratedDensity(vPotentialInitial,fParticleCharge);
195  fTableVector->PutValue(i,vValue);
196  }
197 }
198 
199 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
200 
203  XPhysicalLattice* vLattice,
204  G4int vParticleCharge){
205 
206  G4double vPotentialModified = vPotential /
207  std::fabs(G4double(vParticleCharge)) - fPotentialMinimum;
208 
209  // if the crystal has not been initialized return -1 -> Error!
210  if(!HasBeenInitialized(vLattice,vParticleCharge))
211  return -1.;
212  // if the potential is higher than the maximum the average density
213  // is equal to the one of the amorphous material
214  else if(vPotentialModified >= std::fabs(fPotentialMaximum - fPotentialMinimum))
215  return 1.;
216  // if the value is less than zero (because of possible variation
217  // due to centrifugal force) take the zero value
218  else if(vPotentialModified < 0.) return fTableVector->Value(0.);
219  //else if(vPotentialModified < 1. && vParticleCharge < 0.) return 1.;
220  else{
221  return fTableVector->Value(vPotentialModified);
222  }
223 }
224 
225 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
226 
229  G4int){
230 
231  unsigned int i1,i2,i3;
232  i1 = i2 = i3 = 0;
233 
234  G4ThreeVector vPositionTemp = G4ThreeVector(0.,0.,0.);
235  G4double vDensity = 0.;
236 
238  while(i1<fIntegrationPoints[2]){
239  vPositionTemp.setY(G4double(G4double(i3)/
240  G4double(fIntegrationPoints[2])*vSize.z()));
241  while(i1<fIntegrationPoints[1]){
242  vPositionTemp.setZ(G4double(G4double(i2)/
243  G4double(fIntegrationPoints[1])*vSize.y()));
244  while(i1<fIntegrationPoints[0]){
245  vPositionTemp.setX(G4double(G4double(i1)/
246  G4double(fIntegrationPoints[0])*vSize.x()));
247  if(fPotential->GetEC(vPositionTemp,fLattice).x()
248  < vPotentialInitial){
249  vDensity += fDensity->GetEC(vPositionTemp,fLattice).x();
250  }
251  i1++;
252  };
253  i2++;
254  };
255  i3++;
256  };
257 
258  vDensity *= fLattice->GetXUnitCell()->ComputeVolume();
259  vDensity /= GetIntegrationPoints();
260 
261  return vDensity;
262 }
263 
264 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
265 
268  G4double &p1,
269  G4double &p2,
270  G4double &p3,
271  G4double &x)
272 {
273  double a0, a1 , a2 , a3 , x2;
274 
275  x2 = x * x;
276  a0 = -0.5 * p0 + 1.5 * p1 - 1.5 * p2 + 0.5 * p3;
277  a1 = p0 - 2.5 * p1 + 2.0 * p2 - 0.5 * p3;
278  a2 = -0.5 * p0 + 0.5 * p2;
279  a3 = p1;
280 
281  return (a0 * x * x2 + a1 * x2 + a2 * x + a3);
282 }
283 
284 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
285 
287  std::ofstream vFileOut;
288  vFileOut.open(filename);
289  G4double vStep = GetStep();
290 
291  vFileOut << "energy,dens" << std::endl;
292  for(unsigned int i = 0;i < fNumberOfPoints;i++){
293  vFileOut << i * vStep / CLHEP::eV;
294  vFileOut << " , ";
295  vFileOut << GetIntegratedDensity((i+1) * vStep
297  vFileOut << std::endl;
298  }
299  vFileOut.close();
300 }
301 
302 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
303 
305  std::ifstream vFileIn;
306  vFileIn.open(filename);
307  if(!vFileIn){
308  G4cout << "XVCrystalIntegratedDensity::";
309  G4cout << "ReadFromFile - ERROR READING FILE!!!!! ";
310  G4cout << filename << G4endl;
311  }
312 
315  G4double vDensity = 0.;
316 
317  vFileIn >> fPotentialMinimum;
318  vFileIn >> fPotentialMaximum;
319 
320  fPotentialMinimum *= CLHEP::eV;
321  fPotentialMaximum *= CLHEP::eV;
322 
323  std::vector<G4double> fTable;
324 
325  while(!vFileIn.eof()){
326  vFileIn >> vDensity;
327  if(vDensity < 1.E-2) {
328  vDensity = 1.E-2;
329  }
330  fTable.push_back(vDensity);
331  };
332 
333  fNumberOfPoints = fTable.size();
334 
335  fTableVector =
336  new G4PhysicsLinearVector(0.,
337  std::fabs(fPotentialMaximum - fPotentialMinimum),
339 
340  for(unsigned int i=0;i<fTable.size();i++){
341  fTableVector->PutValue(i,fTable.at(i));
342  }
343 
344  fPotentialRange = std::fabs(fPotentialMaximum - fPotentialMinimum);
345 
346  G4cout << "XVCrystalIntegratedDensity::InitializeTable()::";
347  G4cout << "Potential Range = " << fPotentialRange/CLHEP::eV;
348  G4cout << " - Minimum = " << fPotentialMinimum / CLHEP::eV;
349  G4cout << " - Maximum " << fPotentialMaximum / CLHEP::eV << G4endl;
350  vFileIn.close();
351 }
352 
353 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
const G4double a0
void SetIntegrationPoints(unsigned int, unsigned int)
G4PhysicsLinearVector * fTableVector
CLHEP::Hep3Vector G4ThreeVector
virtual G4double ComputeIntegratedDensity(G4double, G4int)
static const G4double a1
G4double FindCatmullRomInterpolate(G4double &p0, G4double &p1, G4double &p2, G4double &p3, G4double &x)
size_t GetVectorLength() const
G4double GetIntegratedDensity(G4double, XPhysicalLattice *, G4int)
int G4int
Definition: G4Types.hh:78
G4double ComputeVolume()
Definition: XUnitCell.cc:105
virtual G4double GetMinimum(XPhysicalLattice *)
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
G4ThreeVector GetSize()
Definition: XUnitCell.cc:48
void PutValue(size_t index, G4double theValue)
XUnitCell * GetXUnitCell()
G4double Value(G4double theEnergy, size_t &lastidx) const
void SetXPhysicalLattice(XPhysicalLattice *)
static const G4double a3
void SetDensity(XVCrystalCharacteristic *)
G4ThreeVector GetEC(G4ThreeVector, XPhysicalLattice *)
static const double eV
Definition: G4SIunits.hh:194
virtual G4double GetMaximum(XPhysicalLattice *)
G4bool HasBeenInitialized(XPhysicalLattice *, G4int)
void SetPotential(XVCrystalCharacteristic *)
XVCrystalCharacteristic * GetDensity()
XVCrystalCharacteristic * GetPotential()
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
XVCrystalCharacteristic * fDensity
#define DBL_MAX
Definition: templates.hh:83
XVCrystalCharacteristic * fPotential
static const G4double a2