Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4NeutronHPElementData.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 // neutron_hp -- source file
27 // J.P. Wellisch, Nov-1996
28 // A prototype of the low energy neutron transport model.
29 //
30 // 02-08-06 Modified Harmonise to reslove cross section trouble at high-end. T. KOI
31 //
33 #include "G4SystemOfUnits.hh"
34 
36  {
37  precision = 0.02;
38  theFissionData = new G4NeutronHPVector;
39  theCaptureData = new G4NeutronHPVector;
40  theElasticData = new G4NeutronHPVector;
41  theInelasticData = new G4NeutronHPVector;
42  theIsotopeWiseData = 0;
43  theBuffer = NULL;
44  }
45 
47  {
48  delete theFissionData;
49  delete theCaptureData;
50  delete theElasticData;
51  delete theInelasticData;
52  delete [] theIsotopeWiseData;
53  }
54 
56  {
57  G4int count = theElement->GetNumberOfIsotopes();
58  if(count == 0) count +=
59  theStableOnes.GetNumberOfIsotopes(static_cast<G4int>(theElement->GetZ()));
60  theIsotopeWiseData = new G4NeutronHPIsoData[count];
61  // filename = ein data-set je isotope.
62  count = 0;
63  G4int nIso = theElement->GetNumberOfIsotopes();
64  G4int Z = static_cast<G4int> (theElement->GetZ());
65  //G4int i1;
66  if(nIso!=0)
67  {
68  for (G4int i1=0; i1<nIso; i1++)
69  {
70 // G4cout <<" Init: normal case"<<G4endl;
71  G4int A = theElement->GetIsotope(i1)->GetN();
72  G4int M = theElement->GetIsotope(i1)->Getm();
73  G4double frac = theElement->GetRelativeAbundanceVector()[i1]/perCent;
74  //UpdateData(A, Z, count++, frac);
75  UpdateData(A, Z, M, count++, frac);
76  }
77  }else{
78 // G4cout <<" Init: theStableOnes case: Z="<<Z<<G4endl;
79  G4int first = theStableOnes.GetFirstIsotope(Z);
80 // G4cout <<"first="<<first<<" "<<theStableOnes.GetNumberOfIsotopes(theElement->GetZ())<<G4endl;
81  for(G4int i1=0;
82  i1<theStableOnes.GetNumberOfIsotopes(static_cast<G4int>(theElement->GetZ()) );
83  i1++)
84  {
85 // G4cout <<" Init: theStableOnes in the loop"<<G4endl;
86  G4int A = theStableOnes.GetIsotopeNucleonCount(first+i1);
87  G4double frac = theStableOnes.GetAbundance(first+i1);
88 // G4cout <<" Init: theStableOnes in the loop: "<<A<<G4endl;
89  UpdateData(A, Z, count++, frac);
90  }
91  }
92  theElasticData->ThinOut(precision);
93  theInelasticData->ThinOut(precision);
94  theCaptureData->ThinOut(precision);
95  theFissionData->ThinOut(precision);
96  }
97 
98  //void G4NeutronHPElementData::UpdateData(G4int A, G4int Z, G4int index, G4double abundance)
100  {
101  //Reads in the Data, using G4NeutronHPIsoData[], and its Init
102 // G4cout << "entered: ElementWiseData::UpdateData"<<G4endl;
103  //theIsotopeWiseData[index].Init(A, Z, abundance);
104  theIsotopeWiseData[index].Init(A, Z, M, abundance);
105 // G4cout << "ElementWiseData::UpdateData Init finished"<<G4endl;
106 
107  theBuffer = theIsotopeWiseData[index].MakeElasticData();
108 // G4cout << "ElementWiseData::UpdateData MakeElasticData finished: "
109 // <<theBuffer->GetVectorLength()<<G4endl;
110  Harmonise(theElasticData, theBuffer);
111 // G4cout << "ElementWiseData::UpdateData Harmonise finished: "
112 // <<theElasticData->GetVectorLength()<<G4endl;
113  delete theBuffer;
114 
115  theBuffer = theIsotopeWiseData[index].MakeInelasticData();
116 // G4cout << "ElementWiseData::UpdateData MakeInelasticData finished: "
117 // <<theBuffer->GetVectorLength()<<G4endl;
118  Harmonise(theInelasticData, theBuffer);
119 // G4cout << "ElementWiseData::UpdateData Harmonise finished: "
120 // <<theInelasticData->GetVectorLength()<<G4endl;
121  delete theBuffer;
122 
123  theBuffer = theIsotopeWiseData[index].MakeCaptureData();
124 // G4cout << "ElementWiseData::UpdateData MakeCaptureData finished: "
125 // <<theBuffer->GetVectorLength()<<G4endl;
126  Harmonise(theCaptureData, theBuffer);
127 // G4cout << "ElementWiseData::UpdateData Harmonise finished: "
128 // <<theCaptureData->GetVectorLength()<<G4endl;
129  delete theBuffer;
130 
131  theBuffer = theIsotopeWiseData[index].MakeFissionData();
132 // G4cout << "ElementWiseData::UpdateData MakeFissionData finished: "
133 // <<theBuffer->GetVectorLength()<<G4endl;
134  Harmonise(theFissionData, theBuffer);
135 // G4cout << "ElementWiseData::UpdateData Harmonise finished: "
136 // <<theFissionData->GetVectorLength()<<G4endl;
137  delete theBuffer;
138 
139 // G4cout << "ElementWiseData::UpdateData finished"<endl;
140  }
141 
143  {
144  if(theNew == 0) { return; }
145  G4int s_tmp = 0, n=0, m_tmp=0;
146  G4NeutronHPVector * theMerge = new G4NeutronHPVector(theStore->GetVectorLength());
147 // G4cout << "Harmonise 1: "<<theStore->GetEnergy(s)<<" "<<theNew->GetEnergy(0)<<G4endl;
148  while ( theStore->GetEnergy(s_tmp)<theNew->GetEnergy(0)&&s_tmp<theStore->GetVectorLength() )
149  {
150  theMerge->SetData(m_tmp++, theStore->GetEnergy(s_tmp), theStore->GetXsec(s_tmp));
151  s_tmp++;
152  }
153  G4NeutronHPVector *active = theStore;
154  G4NeutronHPVector * passive = theNew;
155  G4NeutronHPVector * tmp;
156  G4int a = s_tmp, p = n, t;
157 // G4cout << "Harmonise 2: "<<active->GetVectorLength()<<" "<<passive->GetVectorLength()<<G4endl;
158  while (a<active->GetVectorLength()&&p<passive->GetVectorLength())
159  {
160  if(active->GetEnergy(a) <= passive->GetEnergy(p))
161  {
162  theMerge->SetData(m_tmp, active->GetEnergy(a), active->GetXsec(a));
163  G4double x = theMerge->GetEnergy(m_tmp);
164  G4double y = std::max(0., passive->GetXsec(x));
165  theMerge->SetData(m_tmp, x, theMerge->GetXsec(m_tmp)+y);
166  m_tmp++;
167  a++;
168  } else {
169 // G4cout << "swapping in Harmonise"<<G4endl;
170  tmp = active; t=a;
171  active = passive; a=p;
172  passive = tmp; p=t;
173  }
174  }
175 // G4cout << "Harmonise 3: "<< a <<" "<<active->GetVectorLength()<<" "<<m<<G4endl;
176  while (a!=active->GetVectorLength())
177  {
178  theMerge->SetData(m_tmp++, active->GetEnergy(a), active->GetXsec(a));
179  a++;
180  }
181 // G4cout << "Harmonise 4: "<< p <<" "<<passive->GetVectorLength()<<" "<<m<<G4endl;
182  while (p!=passive->GetVectorLength())
183  {
184  // Modified by T. KOI
185  //theMerge->SetData(m++, passive->GetEnergy(p), passive->GetXsec(p));
186  G4double x = passive->GetEnergy(p);
187  G4double y = std::max(0., active->GetXsec(x));
188  theMerge->SetData(m_tmp++, x, passive->GetXsec(p)+y);
189  p++;
190  }
191 // G4cout <<"Harmonise 5: "<< theMerge->GetVectorLength() << " " << m << G4endl;
192  delete theStore;
193  theStore = theMerge;
194 // G4cout <<"Harmonise 6: "<< theStore->GetVectorLength() << " " << m << G4endl;
195  }
196 
198  G4ParticleDefinition * theP,
199  G4NeutronHPFissionData* theSet)
200  {
201  if(theP != G4Neutron::Neutron()) throw G4HadronicException(__FILE__, __LINE__, "not a neutron");
202  Init ( theElement );
203  return GetData(theSet);
204  }
206  G4ParticleDefinition * theP,
207  G4NeutronHPCaptureData * theSet)
208  {
209  if(theP != G4Neutron::Neutron()) throw G4HadronicException(__FILE__, __LINE__, "not a neutron");
210  Init ( theElement );
211  return GetData(theSet);
212  }
214  G4ParticleDefinition * theP,
215  G4NeutronHPElasticData * theSet)
216  {
217  if(theP != G4Neutron::Neutron()) throw G4HadronicException(__FILE__, __LINE__, "not a neutron");
218  Init ( theElement );
219  return GetData(theSet);
220  }
222  G4ParticleDefinition * theP,
223  G4NeutronHPInelasticData * theSet)
224  {
225  if(theP != G4Neutron::Neutron()) throw G4HadronicException(__FILE__, __LINE__, "not a neutron");
226  Init ( theElement );
227  return GetData(theSet);
228  }
size_t GetNumberOfIsotopes() const
Definition: G4Element.hh:158
G4double GetEnergy(G4int i) const
G4int GetVectorLength() const
G4NeutronHPVector * MakeFissionData()
void ThinOut(G4double precision)
G4int GetFirstIsotope(G4int Z)
const char * p
Definition: xmltok.h:285
G4double GetZ() const
Definition: G4Element.hh:131
void UpdateData(G4int A, G4int Z, G4int index, G4double abundance)
void SetData(G4int i, G4double x, G4double y)
G4bool Init(G4int A, G4int Z, G4double abun, G4String dirName, G4String aFSType)
int G4int
Definition: G4Types.hh:78
G4NeutronHPVector * MakeInelasticData()
G4NeutronHPVector * MakePhysicsVector(G4Element *theElement, G4ParticleDefinition *theP, G4NeutronHPFissionData *theSet)
G4int GetN() const
Definition: G4Isotope.hh:94
G4int Getm() const
Definition: G4Isotope.hh:100
G4double * GetRelativeAbundanceVector() const
Definition: G4Element.hh:166
static G4Neutron * Neutron()
Definition: G4Neutron.cc:104
const G4int n
G4NeutronHPVector * MakeCaptureData()
G4int GetNumberOfIsotopes(G4int Z)
G4NeutronHPVector * MakeElasticData()
G4int GetIsotopeNucleonCount(G4int number)
G4NeutronHPVector * GetData(G4NeutronHPFissionData *)
G4double GetXsec(G4int i)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
void Harmonise(G4NeutronHPVector *&theStore, G4NeutronHPVector *theNew)
void Init(G4Element *theElement)
const G4Isotope * GetIsotope(G4int iso) const
Definition: G4Element.hh:169
float perCent
Definition: hepunit.py:239
G4double GetAbundance(G4int number)
double G4double
Definition: G4Types.hh:76