Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4NeutronHPNames.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// 24-Jan-07 Enable to use exact data only and add warnig when substitute file is used T. Koi
31// 30-Jan-07 Modified method of searching substitute isotope data by T. Koi
32// 07-06-12 fix memory leaking by T. Koi
33// 07-06-25 Change data selection logic when G4NEUTRONHP_SKIP_MISSING_ISOTOPES is turn on
34// Natural Abundance data are allowed. by T. Koi
35// 07-07-06 Allow _nat_ final state even for isotoped cross sections by T. Koi
36// 08-09-01 Add protection that deuteron data do not selected for hydrogen and so on by T. Koi
37//
38#include "G4NeutronHPNames.hh"
39#include "G4SandiaTable.hh"
41#include <fstream>
42
43 const G4String G4NeutronHPNames::theString[100] = {"Hydrogen", "Helium",
44 "Lithium", "Berylium", "Boron", "Carbon", "Nitrogen", "Oxygen", "Fluorine",
45 "Neon", "Sodium", "Magnesium", "Aluminum", "Silicon", "Phosphorous",
46 "Sulfur", "Chlorine", "Argon", "Potassium", "Calcium", "Scandium",
47 "Titanium", "Vanadium", "Chromium", "Manganese", "Iron", "Cobalt", "Nickel",
48 "Copper", "Zinc", "Gallium", "Germanium", "Arsenic", "Selenium", "Bromine",
49 "Krypton", "Rubidium", "Strontium", "Yttrium", "Zirconium", "Niobium",
50 "Molybdenum", "Technetium", "Ruthenium", "Rhodium", "Palladium", "Silver",
51 "Cadmium", "Indium", "Tin", "Antimony", "Tellurium", "Iodine", "Xenon",
52 "Cesium", "Barium", "Lanthanum", "Cerium", "Praseodymium", "Neodymium",
53 "Promethium", "Samarium", "Europium", "Gadolinium", "Terbium", "Dysprosium",
54 "Holmium", "Erbium", "Thulium", "Ytterbium", "Lutetium", "Hafnium",
55 "Tantalum", "Tungsten", "Rhenium", "Osmium", "Iridium", "Platinium", "Gold",
56 "Mercury", "Thallium", "Lead", "Bismuth", "Polonium", "Astatine", "Radon",
57 "Francium", "Radium", "Actinium", "Thorium", "Protactinium", "Uranium",
58 "Neptunium", "Plutonium", "Americium", "Curium", "Berkelium", "Californium",
59 "Einsteinium","Fermium"};
60
61
63
64//G4NeutronHPDataUsed G4NeutronHPNames::GetName(G4int A, G4int Z, G4String base, G4String rest, G4bool & aFlag)
66{
67
68 //G4cout << Z << " " << A << " " << M << " " << base << " " << rest << G4endl;
69
70 //Excited isomer indicator
71 std::stringstream ss;
72 G4String sM;
73 if ( M > 0 )
74 {
75 ss << "m";
76 ss << M;
77 ss >> sM;
78 ss.clear();
79 }
80
82 aFlag = true;
83if(getenv("NeutronHPNames")) G4cout << "Names::GetName entered for Z = " << Z << ", A = " << A <<G4endl;
84
85 G4int myA = A;
86 G4int myZ = Z;
87
88 if(Z>92.5&&!getenv("AllowForHeavyElements") )
89 {
90 //G4cerr << "Please contact [email protected]"<<G4endl;
91 G4cerr << "Please contact Geant4 Hadron Group Coordinator"<<G4endl;
92 throw G4HadronicException(__FILE__, __LINE__, "G4NeutronHPNames::GetName - data with Z>92 are not provided");
93 }
94
95 G4String * theName = 0;
96 G4String theFileName("");
97
98// G4int inc = 1;
99
100 G4int flip_Z = 1;
101 G4int delta_Z = 0;
102
103 G4int flip_A = 1;
104 G4int delta_A = 0;
105
106 std::ifstream * check = new std::ifstream(".dummy");
107 G4bool first = true;
108if(getenv("NeutronHPNames")) G4cout << "entered GetName!!!"<<G4endl;
109 do
110 {
111 aFlag = true;
112 G4String * biff = new G4String(); // delete here as theName
113 *biff = base+"/CrossSection/"+itoa(myZ)+"_"+itoa(myA)+sM+"_"+theString[myZ-1];
114
115 if(theName!=0) delete theName;
116 theName = biff;
117 result.SetName(*theName);
118 result.SetA(myA);
119 result.SetZ(myZ);
120 result.SetM(M);
121if(getenv("NeutronHPNames")) G4cout <<"HPWD 1 "<<*theName<<G4endl;
122
123 // T.K. debug for memory leak
124 if ( check != 0 )
125 {
126 check->close();
127 delete check;
128 }
129 check = new std::ifstream(*theName);
130 if ( !(*check) )
131 {
132 check->close();
133 delete check;
134 check = 0;
135 aFlag = false;
136 if ( first )
137 {
138 aFlag = true;
139 first = false;
140 biff = new G4String(); // delete here as theName
141 *biff = base+"/CrossSection/"+itoa(myZ)+"_"+"nat"+"_"+theString[myZ-1];
142 if(theName!=0) delete theName;
143 theName = biff;
144if(getenv("NeutronHPNames")) G4cout <<"HPWD 2 "<<*theName<<G4endl;
145 result.SetName(*theName);
146 G4double natA = myZ/G4SandiaTable::GetZtoA(myZ);
147 result.SetA(natA);
148 result.SetZ(myZ);
149 result.SetM(M);
150 check = new std::ifstream(*theName);
151 if ( !(*check) )
152 {
153 check->close();
154 delete check;
155 check = 0;
156 aFlag = false;
157 }
158 else
159 {
160 biff = new G4String(); // delete here as theName
161 if(theName!=0) delete theName;
162 *biff = base+"/"+rest+"/"+itoa(myZ)+"_"+"nat"+"_"+theString[myZ-1];
163 if ( rest=="/CrossSection" ) *biff = base+rest+"/"+itoa(myZ)+"_"+"nat"+"_"+theString[myZ-1];
164 theName = biff;
165if(getenv("NeutronHPNames")) G4cout <<"HPWD 3 "<<*theName<<G4endl;
166 result.SetName(*theName);
167 natA = myZ/G4SandiaTable::GetZtoA(myZ);
168 result.SetA(natA);
169 result.SetZ(myZ);
170 result.SetM(M);
172 }
173 }
174 }
175 else
176 {
177// 070706 T. Koi Modified
178/*
179 biff = new G4String(); // delete here as theName
180 *biff = base+"/"+rest+itoa(myZ)+"_"+itoa(myA)+"_"+theString[myZ-1];
181 if(theName!=0) delete theName;
182 theName = biff;
183if(getenv("NeutronHPNames")) G4cout <<"HPWD 4 "<<*theName<<G4endl;
184 result.SetName(*theName);
185 result.SetA(myA);
186 result.SetZ(myZ);
187*/
188
189 G4double tmpA = myA;
190 std::ifstream* file = NULL;
191 G4String fileName;
192
193 if ( rest == "/CrossSection" )
194 {
195
196 //fileName = base+"/"+rest+"/"+itoa(myZ)+"_"+itoa(myA)+sM+"_"+theString[myZ-1];
197 fileName = base+rest+"/"+itoa(myZ)+"_"+itoa(myA)+sM+"_"+theString[myZ-1];
198if(getenv("NeutronHPNames")) G4cout <<"HPWD 4a "<<*theName<<G4endl;
199
200 }
201 else
202 {
203
204// For FS
205 fileName = base+"/"+rest+"/"+itoa(myZ)+"_"+itoa(myA)+sM+"_"+theString[myZ-1];
206 file = new std::ifstream(fileName);
207
208 if ( *file )
209 {
210
211// isotope FS
212if(getenv("NeutronHPNames")) G4cout <<"HPWD 4b1 "<<*theName<<G4endl;
213 }
214 else
215 {
216
217// _nat_ FS
218 fileName = base+"/"+rest+"/"+itoa(myZ)+"_"+"nat"+"_"+theString[myZ-1];
219
220 delete file;
221 file = new std::ifstream(fileName);
222 if ( *file )
223 {
224
225// FS neither isotope nor _nat_
226if(getenv("NeutronHPNames")) G4cout <<"HPWD 4b2a "<<*theName<<G4endl;
227 G4double natA = myZ/G4SandiaTable::GetZtoA(myZ);
228 tmpA = natA;
229 }
230 else
231 {
232if(getenv("NeutronHPNames")) G4cout <<"HPWD 4b2c "<<*theName<<G4endl;
233 fileName="INVALID";
234 }
235 }
236
237 delete file;
238
239 }
240
241 result.SetName(fileName);
242 result.SetA(tmpA);
243 result.SetZ(myZ);
244 result.SetM(M);
245
246 }
247
248 do
249 {
250// if (std::abs(myZ-Z)>theMaxOffSet||myZ==0||myA==0)
251 if ( delta_Z > theMaxOffSet )
252 {
253 //if ( inc > 0 )
254 //{
255 // inc*= -1;
256 // myZ = Z;
257 // myA = A;
258 //}
259 //else
260 //{
261 G4cout <<"G4NeutronHPNames: Sorry, this material does not come near to any data."<<G4endl;
262 G4cout <<"G4NeutronHPNames: Please make sure G4NEUTRONHPDATA points to the" << G4endl;
263 G4cout <<" directory, the neutron scattering data are located in." << G4endl;
264 G4cout << "G4NeutronHPNames: The material was: A="<<A<<", Z="<<Z<<G4endl;
265 //throw G4HadronicException(__FILE__, __LINE__, "In case the data sets are at present not available in the neutron data library, please contact [email protected]");
266 throw G4HadronicException(__FILE__, __LINE__, "In case the data sets are at present not available in the neutron data library, please contact Hadron Group Coordinator");
267 delete theName;
268 theFileName = "";
269 return result;
270 //}
271 }
272
273 //if ( std::abs( myA - A ) > theMaxOffSet )
274 if ( delta_A > 2*theMaxOffSet )
275 {
276 delta_A = 0;
277 flip_A = 1;
278
279 first = true;
280
281 if ( flip_Z > 0 )
282 {
283 delta_Z +=1;
284 }
285 myZ = Z + flip_Z * delta_Z;
286 flip_Z *= -1;
287
288 myA = A;
289 if ( myZ > 100 )
290 {
291 myZ = 100;
292 }
293 if ( myZ < 1 )
294 {
295 myZ = 1;
296 }
297
298// myZ += inc;
299 }
300 else
301 {
302 if ( flip_A > 0 )
303 {
304 delta_A += 1;
305 }
306 myA = A + flip_A * delta_A;
307 flip_A *= -1;
308
309 if ( myA < 1 )
310 {
311 myA = 1;
312 }
313
314// myA += inc;
315 }
316
317 }
318 while( myZ == 0 || myA == 0 ); // No meaning
319
320 }
321 while((!check) || (!(*check)));
322
323 if(getenv("NeutronHPNamesLogging") || getenv("NeutronHPNames"))
324 {
325 G4cout << "Names::GetName: last theName proposal = "<< G4endl;
326 G4cout << *theName <<" "<<A<<" "<<Z<<" "<<result.GetName()<<G4endl;
327 }
328
329// administration and anouncement for lacking of exact data in NDL
330 if ( Z != result.GetZ() || A != result.GetA() )
331 {
332 if ( rest == "/CrossSection" )
333 {
334 G4String reac = base;
335 G4String dir = getenv("G4NEUTRONHPDATA");
336 reac.erase ( 0 , dir.length() );
337 if ( getenv ( "G4NEUTRONHP_SKIP_MISSING_ISOTOPES" ) && !( Z == result.GetZ() && result.IsThisNaturalAbundance() ) )
338 {
339 G4cout << "NeutronHP: " << reac << " file for Z = " << Z << ", A = " << A << " is not found and CrossSection set to 0." << G4endl;
340 G4String new_name = base+"/"+rest+"/"+"0_0_Zero";
341 result.SetName( new_name );
342 }
343 else
344 {
345 //080901 Add protection that deuteron data do not selected for hydrogen and so on by T. Koi
346 if ( ( reac.find("Inelastic") != reac.size() && ( (Z == 1 && A == 1) || (Z == 2 && A == 4) ) )
347 || ( reac.find("Capture") != reac.size() && ( (Z == 1 && A == 3) || (Z == 2 && A == 4) ) )
348 || ( reac.find("Fission") != reac.size() && ( (Z == 88 && A == 224) || (Z == 88 && A == 225) || (Z == 89 && A == 225) || (Z == 88 && A == 226) ) ) )
349
350 {
351 G4String new_name = base+"/"+rest+"/"+"0_0_Zero";
352 result.SetName( new_name );
353 }
354 else
355 {
356 G4cout << "NeutronHP: " << reac << " file for Z = " << Z << ", A = " << A << " is not found and NeutronHP will use " << result.GetName() << G4endl;
357 }
358 }
359 }
360 }
361
362 delete theName;
363 if(aFlag)
364 {
365 check->close();
366 delete check;
367 check = 0;
368 }
369 return result;
370 }
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 G4cerr
G4DLLIMPORT std::ostream G4cout
void SetName(G4String aName)
void SetA(G4double anA)
static const G4String theString[100]
G4NeutronHPDataUsed GetName(G4int A, G4int Z, G4String base, G4String rest, G4bool &active)
G4String itoa(int current)
static G4double GetZtoA(G4int Z)