Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4NeutronIsoIsoCrossSections.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//
27#include "G4SystemOfUnits.hh"
30
33: theCrossSection(), theNames()
34{
35 theProductionData = NULL;
36 hasData = false;
37 theNumberOfProducts = 0;
38 theZ = 0;
39 theA = 0;
40 G4cout << "WARNING: G4NeutronIsoIsoCrossSections is deprecated and will be removed with Geant4 version 10"
41 << G4endl;
42}
43
46{
47 for(G4int i=0; i<theNumberOfProducts; i++)
48 {
49 delete theProductionData[i];
50 }
51 delete [] theProductionData;
52}
53
55Init(G4int A, G4int Z, G4double frac)
56{
57 frac = frac/100.;
58 // First transmution scattering cross-section
59 // in our definition inelastic and fission.
60
61 theZ = Z;
62 theA = A;
63 theNames.SetMaxOffSet(5);
64 G4NeutronHPDataUsed dataUsed;
65 G4String rest = "/CrossSection/";
66 G4String base = getenv("G4NEUTRONHPDATA");
67 G4String base1 = base + "/Inelastic/";
68 G4bool hasInelasticData = false;
69 dataUsed = theNames.GetName(A, Z, base1, rest, hasInelasticData);
70 G4String aName = dataUsed.GetName();
71 G4NeutronHPVector inelasticData;
72 G4double dummy;
73 G4int total;
74 if(hasInelasticData)
75 {
76 std::ifstream aDataSet(aName, std::ios::in);
77 aDataSet >> dummy >> dummy >> total;
78 inelasticData.Init(aDataSet, total, eV);
79 }
80 base1 = base + "/Capture/";
81 G4bool hasCaptureData = false;
82 dataUsed = theNames.GetName(A, Z, base1, rest, hasCaptureData);
83 aName = dataUsed.GetName();
84 G4NeutronHPVector captureData;
85 if(hasCaptureData)
86 {
87 std::ifstream aDataSet(aName, std::ios::in);
88 aDataSet >> dummy >> dummy >> total;
89 captureData.Init(aDataSet, total, eV);
90 }
91 base1 = base + "/Elastic/";
92 G4bool hasElasticData = false;
93 dataUsed = theNames.GetName(A, Z, base1, rest, hasElasticData);
94 aName = dataUsed.GetName();
95 G4NeutronHPVector elasticData;
96 if(hasElasticData)
97 {
98 std::ifstream aDataSet(aName, std::ios::in);
99 aDataSet >> dummy >> dummy >> total;
100 elasticData.Init(aDataSet, total, eV);
101 }
102 base1 = base + "/Fission/";
103 G4bool hasFissionData = false;
104 if(Z>=91)
105 {
106 dataUsed = theNames.GetName(A, Z, base1, rest, hasFissionData);
107 aName = dataUsed.GetName();
108 }
109 G4NeutronHPVector fissionData;
110 if(hasFissionData)
111 {
112 std::ifstream aDataSet(aName, std::ios::in);
113 aDataSet >> dummy >> dummy >> total;
114 fissionData.Init(aDataSet, total, eV);
115 }
116 hasData = hasFissionData||hasInelasticData||hasElasticData||hasCaptureData;
117 G4NeutronHPVector merged, merged1;
118 if(hasData)
119 {
120 if(hasFissionData&&hasInelasticData)
121 {
122 merged = fissionData + inelasticData;
123 }
124 else if(hasFissionData)
125 {
126 merged = fissionData;
127 }
128 else if(hasInelasticData)
129 {
130 merged = inelasticData;
131 }
132
133 if(hasElasticData&&hasCaptureData)
134 {
135 merged1=elasticData + captureData;
136 }
137 else if(hasCaptureData)
138 {
139 merged1 = captureData;
140 }
141 else if(hasElasticData)
142 {
143 merged1 = elasticData;
144 }
145
146 if((hasElasticData||hasCaptureData)&&(hasFissionData||hasInelasticData))
147 {
148 theCrossSection = merged + merged1;
149 }
150 else if(hasElasticData||hasCaptureData)
151 {
152 theCrossSection = merged1;
153 }
154 else if(hasFissionData||hasInelasticData)
155 {
156 theCrossSection = merged;
157 }
158 theCrossSection.Times(frac);
159 }
160
161 // now isotope-production cross-sections
162 theNames.SetMaxOffSet(1);
163 rest = "/CrossSection/";
164 base1 = base + "/IsotopeProduction/";
165 G4bool hasIsotopeProductionData;
166 dataUsed = theNames.GetName(A, Z, base1, rest, hasIsotopeProductionData);
167 aName = dataUsed.GetName();
168 if(hasIsotopeProductionData)
169 {
170 std::ifstream aDataSet(aName, std::ios::in);
171 aDataSet>>theNumberOfProducts;
172 theProductionData = new G4IsoProdCrossSections * [theNumberOfProducts];
173 for(G4int i=0; i<theNumberOfProducts; i++)
174 {
175 G4String dName;
176 aDataSet >> dName;
177 aDataSet >> dummy >> dummy;
178 theProductionData[i] = new G4IsoProdCrossSections(dName);
179 theProductionData[i]->Init(aDataSet);
180 }
181 }
182 else
183 {
184 hasData = false;
185 }
186 G4NeutronInelasticCrossSection theParametrization;
187 G4double lastEnergy = theCrossSection.GetX(theCrossSection.GetVectorLength()-1);
188 G4double lastValue = theCrossSection.GetY(theCrossSection.GetVectorLength()-1);
189 G4double norm = theParametrization.GetCrossSection(lastEnergy, Z, A);
190 G4double increment = 1*MeV;
191 while(lastEnergy+increment<101*MeV)
192 {
193 G4double currentEnergy = lastEnergy+increment;
194 G4double value = theParametrization.GetCrossSection(currentEnergy, Z, A)*(lastValue/norm);
195 G4int position = theCrossSection.GetVectorLength();
196 theCrossSection.SetData(position, currentEnergy, value);
197 increment+=1*MeV;
198 }
199}
200
203{
204 G4double result;
205 result = theCrossSection.GetY(anEnergy);
206 return result;
207}
208
211{
212 G4String result = "UNCHANGED";
213
214 G4double totalXSec = theCrossSection.GetY(anEnergy);
215 if(totalXSec==0) return result;
216
217 // now do the isotope changing reactions
218 G4double * xSec = new G4double[theNumberOfProducts];
219 G4double sum = 0;
220 {
221 for(G4int i=0; i<theNumberOfProducts; i++)
222 {
223 xSec[i] = theProductionData[i]->GetProductionCrossSection(anEnergy);
224 sum += xSec[i];
225 }
226 }
227 G4double isoChangeXsec = sum;
228 G4double rand = G4UniformRand();
229 if(rand > isoChangeXsec/totalXSec)
230 {
231 delete [] xSec;
232 return result;
233 }
234 G4double random = G4UniformRand();
235 G4double running = 0;
236 G4int index(0);
237 {
238 for(G4int i=0; i<theNumberOfProducts; i++)
239 {
240 running += xSec[i];
241 index = i;
242 if(random<=running/sum) break;
243 }
244 }
245 delete [] xSec;
246 result = theProductionData[index]->GetProductIsotope();
247
248 return result;
249}
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
#define G4UniformRand()
Definition: Randomize.hh:53
void Init(std::ifstream &aDataSet)
G4double GetProductionCrossSection(G4double anEnergy)
G4NeutronHPDataUsed GetName(G4int A, G4int Z, G4String base, G4String rest, G4bool &active)
void SetMaxOffSet(G4int anOffset)
void Init(std::ifstream &aDataFile, G4int total, G4double ux=1., G4double uy=1.)
G4int GetVectorLength() const
G4double GetX(G4int i) const
G4double GetY(G4double x)
void SetData(G4int i, G4double x, G4double y)
void Times(G4double factor)
G4double GetCrossSection(G4double kineticEnergy, G4int Z, G4int A)
void Init(G4int A, G4int Z, G4double frac)
G4double GetCrossSection(G4double anEnergy)
G4String GetProductIsotope(G4double anEnergy)