Geant4  10.00.p02
G4NeutronHPInelastic.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 // this code implementation is the intellectual property of
27 // neutron_hp -- source file
28 // J.P. Wellisch, Nov-1996
29 // A prototype of the low energy neutron transport model.
30 //
31 // By copying, distributing or modifying the Program (or any work
32 // based on the Program) you indicate your acceptance of this statement,
33 // and all its terms.
34 //
35 //
36 // 070523 bug fix for G4FPE_DEBUG on by A. Howard (and T. Koi)
37 // 081203 limit maximum trial for creating final states add protection for 1H isotope case by T. Koi
38 //
39 #include "G4NeutronHPInelastic.hh"
40 #include "G4SystemOfUnits.hh"
41 
42 #include "G4NeutronHPManager.hh"
43 
45  :G4HadronicInteraction("NeutronHPInelastic")
46  {
47  SetMinEnergy( 0.0 );
48  SetMaxEnergy( 20.*MeV );
49 
50  G4int istatus;
51 #if defined WIN32-VC
52  istatus = system("echo %G4NEUTRONHPDATA%");
53 #else
54  istatus = system("echo $G4NEUTRONHPDATA");
55 #endif
56  if ( istatus < 0 )
57  {
58  G4cout << "Warning! system(\"echo $G4NEUTRONHPDATA\") returns error value at G4NeutronHPInelastic" << G4endl;
59  }
60 
61 // G4cout << " entering G4NeutronHPInelastic constructor"<<G4endl;
62  if(!getenv("G4NEUTRONHPDATA"))
63  throw G4HadronicException(__FILE__, __LINE__, "Please setenv G4NEUTRONHPDATA to point to the neutron cross-section files.");
64  dirName = getenv("G4NEUTRONHPDATA");
65  G4String tString = "/Inelastic";
66  dirName = dirName + tString;
68 /*
69  theInelastic = new G4NeutronHPChannelList[numEle];
70  for (G4int i=0; i<numEle; i++)
71  {
72  theInelastic[i].Init((*(G4Element::GetElementTable()))[i], dirName);
73  G4int itry = 0;
74  do
75  {
76  theInelastic[i].Register(&theNFS, "F01"); // has
77  theInelastic[i].Register(&theNXFS, "F02");
78  theInelastic[i].Register(&the2NDFS, "F03");
79  theInelastic[i].Register(&the2NFS, "F04"); // has, E Done
80  theInelastic[i].Register(&the3NFS, "F05"); // has, E Done
81  theInelastic[i].Register(&theNAFS, "F06");
82  theInelastic[i].Register(&theN3AFS, "F07");
83  theInelastic[i].Register(&the2NAFS, "F08");
84  theInelastic[i].Register(&the3NAFS, "F09");
85  theInelastic[i].Register(&theNPFS, "F10");
86  theInelastic[i].Register(&theN2AFS, "F11");
87  theInelastic[i].Register(&the2N2AFS, "F12");
88  theInelastic[i].Register(&theNDFS, "F13");
89  theInelastic[i].Register(&theNTFS, "F14");
90  theInelastic[i].Register(&theNHe3FS, "F15");
91  theInelastic[i].Register(&theND2AFS, "F16");
92  theInelastic[i].Register(&theNT2AFS, "F17");
93  theInelastic[i].Register(&the4NFS, "F18"); // has, E Done
94  theInelastic[i].Register(&the2NPFS, "F19");
95  theInelastic[i].Register(&the3NPFS, "F20");
96  theInelastic[i].Register(&theN2PFS, "F21");
97  theInelastic[i].Register(&theNPAFS, "F22");
98  theInelastic[i].Register(&thePFS, "F23");
99  theInelastic[i].Register(&theDFS, "F24");
100  theInelastic[i].Register(&theTFS, "F25");
101  theInelastic[i].Register(&theHe3FS, "F26");
102  theInelastic[i].Register(&theAFS, "F27");
103  theInelastic[i].Register(&the2AFS, "F28");
104  theInelastic[i].Register(&the3AFS, "F29");
105  theInelastic[i].Register(&the2PFS, "F30");
106  theInelastic[i].Register(&thePAFS, "F31");
107  theInelastic[i].Register(&theD2AFS, "F32");
108  theInelastic[i].Register(&theT2AFS, "F33");
109  theInelastic[i].Register(&thePDFS, "F34");
110  theInelastic[i].Register(&thePTFS, "F35");
111  theInelastic[i].Register(&theDAFS, "F36");
112  theInelastic[i].RestartRegistration();
113  itry++;
114  }
115  //while(!theInelastic[i].HasDataInAnyFinalState());
116  while( !theInelastic[i].HasDataInAnyFinalState() && itry < 6 );
117  // 6 is corresponding to the value(5) of G4NeutronHPChannel. TK
118 
119  if ( itry == 6 )
120  {
121  // No Final State at all.
122  G4bool exceptional = false;
123  if ( (*(G4Element::GetElementTable()))[i]->GetNumberOfIsotopes() == 1 )
124  {
125  if ( (*(G4Element::GetElementTable()))[i]->GetIsotope( 0 )->GetZ() == 1 && (*(G4Element::GetElementTable()))[i]->GetIsotope( 0 )->GetN() == 1 ) exceptional = true; //1H
126  }
127  if ( !exceptional ) throw G4HadronicException(__FILE__, __LINE__, "Channel: Do not know what to do with this element");
128  }
129  }
130 */
131 
132  for (G4int i=0; i<numEle; i++)
133  {
134  theInelastic.push_back( new G4NeutronHPChannelList );
136  G4int itry = 0;
137  do
138  {
139  (*theInelastic[i]).Register(&theNFS, "F01"); // has
140  (*theInelastic[i]).Register(&theNXFS, "F02");
141  (*theInelastic[i]).Register(&the2NDFS, "F03");
142  (*theInelastic[i]).Register(&the2NFS, "F04"); // has, E Done
143  (*theInelastic[i]).Register(&the3NFS, "F05"); // has, E Done
144  (*theInelastic[i]).Register(&theNAFS, "F06");
145  (*theInelastic[i]).Register(&theN3AFS, "F07");
146  (*theInelastic[i]).Register(&the2NAFS, "F08");
147  (*theInelastic[i]).Register(&the3NAFS, "F09");
148  (*theInelastic[i]).Register(&theNPFS, "F10");
149  (*theInelastic[i]).Register(&theN2AFS, "F11");
150  (*theInelastic[i]).Register(&the2N2AFS, "F12");
151  (*theInelastic[i]).Register(&theNDFS, "F13");
152  (*theInelastic[i]).Register(&theNTFS, "F14");
153  (*theInelastic[i]).Register(&theNHe3FS, "F15");
154  (*theInelastic[i]).Register(&theND2AFS, "F16");
155  (*theInelastic[i]).Register(&theNT2AFS, "F17");
156  (*theInelastic[i]).Register(&the4NFS, "F18"); // has, E Done
157  (*theInelastic[i]).Register(&the2NPFS, "F19");
158  (*theInelastic[i]).Register(&the3NPFS, "F20");
159  (*theInelastic[i]).Register(&theN2PFS, "F21");
160  (*theInelastic[i]).Register(&theNPAFS, "F22");
161  (*theInelastic[i]).Register(&thePFS, "F23");
162  (*theInelastic[i]).Register(&theDFS, "F24");
163  (*theInelastic[i]).Register(&theTFS, "F25");
164  (*theInelastic[i]).Register(&theHe3FS, "F26");
165  (*theInelastic[i]).Register(&theAFS, "F27");
166  (*theInelastic[i]).Register(&the2AFS, "F28");
167  (*theInelastic[i]).Register(&the3AFS, "F29");
168  (*theInelastic[i]).Register(&the2PFS, "F30");
169  (*theInelastic[i]).Register(&thePAFS, "F31");
170  (*theInelastic[i]).Register(&theD2AFS, "F32");
171  (*theInelastic[i]).Register(&theT2AFS, "F33");
172  (*theInelastic[i]).Register(&thePDFS, "F34");
173  (*theInelastic[i]).Register(&thePTFS, "F35");
174  (*theInelastic[i]).Register(&theDAFS, "F36");
175  (*theInelastic[i]).RestartRegistration();
176  itry++;
177  }
178  while( !(*theInelastic[i]).HasDataInAnyFinalState() && itry < 6 );
179  // 6 is corresponding to the value(5) of G4NeutronHPChannel. TK
180 
181  if ( itry == 6 )
182  {
183  // No Final State at all.
184  G4bool exceptional = false;
185  if ( (*(G4Element::GetElementTable()))[i]->GetNumberOfIsotopes() == 1 )
186  {
187  if ( (*(G4Element::GetElementTable()))[i]->GetIsotope( 0 )->GetZ() == 1 && (*(G4Element::GetElementTable()))[i]->GetIsotope( 0 )->GetN() == 1 ) exceptional = true; //1H
188  }
189  if ( !exceptional ) throw G4HadronicException(__FILE__, __LINE__, "Channel: Do not know what to do with this element");
190  }
191 
192  }
193  }
194 
196  {
197 // delete [] theInelastic;
198  for ( std::vector<G4NeutronHPChannelList*>::iterator
199  it = theInelastic.begin() ; it != theInelastic.end() ; it++ )
200  {
201  delete *it;
202  }
203  theInelastic.clear();
204  }
205 
206  #include "G4NeutronHPThermalBoost.hh"
207 
209  {
212  const G4Material * theMaterial = aTrack.GetMaterial();
213  G4int n = theMaterial->GetNumberOfElements();
214  G4int index = theMaterial->GetElement(0)->GetIndex();
215  G4int it=0;
216  if(n!=1)
217  {
218  xSec = new G4double[n];
219  G4double sum=0;
220  G4int i;
221  const G4double * NumAtomsPerVolume = theMaterial->GetVecNbOfAtomsPerVolume();
222  G4double rWeight;
223  G4NeutronHPThermalBoost aThermalE;
224  for (i=0; i<n; i++)
225  {
226  index = theMaterial->GetElement(i)->GetIndex();
227  rWeight = NumAtomsPerVolume[i];
228  //xSec[i] = theInelastic[index].GetXsec(aThermalE.GetThermalEnergy(aTrack,
229  xSec[i] = (*theInelastic[index]).GetXsec(aThermalE.GetThermalEnergy(aTrack,
230  theMaterial->GetElement(i),
231  theMaterial->GetTemperature()));
232  xSec[i] *= rWeight;
233  sum+=xSec[i];
234  }
235  G4double random = G4UniformRand();
236  G4double running = 0;
237  for (i=0; i<n; i++)
238  {
239  running += xSec[i];
240  index = theMaterial->GetElement(i)->GetIndex();
241  it = i;
242  //if(random<=running/sum) break;
243  if( sum == 0 || random<=running/sum) break;
244  }
245  delete [] xSec;
246  }
247 
248  //return theInelastic[index].ApplyYourself(theMaterial->GetElement(it), aTrack);
249  G4HadFinalState* result = (*theInelastic[index]).ApplyYourself(theMaterial->GetElement(it), aTrack);
250 
251  //Overwrite target parameters
252  aNucleus.SetParameters(G4NeutronHPManager::GetInstance()->GetReactionWhiteBoard()->GetTargA(),G4NeutronHPManager::GetInstance()->GetReactionWhiteBoard()->GetTargZ());
253  const G4Element* target_element = (*G4Element::GetElementTable())[index];
254  const G4Isotope* target_isotope=NULL;
255  G4int iele = target_element->GetNumberOfIsotopes();
256  for ( G4int j = 0 ; j != iele ; j++ ) {
257  target_isotope=target_element->GetIsotope( j );
258  if ( target_isotope->GetN() == G4NeutronHPManager::GetInstance()->GetReactionWhiteBoard()->GetTargA() ) break;
259  }
260  //G4cout << "Target Material of this reaction is " << theMaterial->GetName() << G4endl;
261  //G4cout << "Target Element of this reaction is " << target_element->GetName() << G4endl;
262  //G4cout << "Target Isotope of this reaction is " << target_isotope->GetName() << G4endl;
263  aNucleus.SetIsotope( target_isotope );
264 
266  return result;
267  }
268 
269 const std::pair<G4double, G4double> G4NeutronHPInelastic::GetFatalEnergyCheckLevels() const
270 {
271  // max energy non-conservation is mass of heavy nucleus
272 // if ( getenv("G4NEUTRONHP_DO_NOT_ADJUST_FINAL_STATE") ) return std::pair<G4double, G4double>(5*perCent,250*GeV);
273  // This should be same to the hadron default value
274 // return std::pair<G4double, G4double>(10*perCent,10*GeV);
275  return std::pair<G4double, G4double>(10*perCent,DBL_MAX);
276 }
277 
279 {
280  for ( G4int i = numEle ; i < (G4int)G4Element::GetNumberOfElements() ; i++ )
281  {
282  G4cout << "G4NeutronHPInelastic Prepairing Data for the new element of " << (*(G4Element::GetElementTable()))[i]->GetName() << G4endl;
283 
284  theInelastic.push_back( new G4NeutronHPChannelList );
286  G4int itry = 0;
287  do
288  {
289  (*theInelastic[i]).Register(&theNFS, "F01"); // has
290  (*theInelastic[i]).Register(&theNXFS, "F02");
291  (*theInelastic[i]).Register(&the2NDFS, "F03");
292  (*theInelastic[i]).Register(&the2NFS, "F04"); // has, E Done
293  (*theInelastic[i]).Register(&the3NFS, "F05"); // has, E Done
294  (*theInelastic[i]).Register(&theNAFS, "F06");
295  (*theInelastic[i]).Register(&theN3AFS, "F07");
296  (*theInelastic[i]).Register(&the2NAFS, "F08");
297  (*theInelastic[i]).Register(&the3NAFS, "F09");
298  (*theInelastic[i]).Register(&theNPFS, "F10");
299  (*theInelastic[i]).Register(&theN2AFS, "F11");
300  (*theInelastic[i]).Register(&the2N2AFS, "F12");
301  (*theInelastic[i]).Register(&theNDFS, "F13");
302  (*theInelastic[i]).Register(&theNTFS, "F14");
303  (*theInelastic[i]).Register(&theNHe3FS, "F15");
304  (*theInelastic[i]).Register(&theND2AFS, "F16");
305  (*theInelastic[i]).Register(&theNT2AFS, "F17");
306  (*theInelastic[i]).Register(&the4NFS, "F18"); // has, E Done
307  (*theInelastic[i]).Register(&the2NPFS, "F19");
308  (*theInelastic[i]).Register(&the3NPFS, "F20");
309  (*theInelastic[i]).Register(&theN2PFS, "F21");
310  (*theInelastic[i]).Register(&theNPAFS, "F22");
311  (*theInelastic[i]).Register(&thePFS, "F23");
312  (*theInelastic[i]).Register(&theDFS, "F24");
313  (*theInelastic[i]).Register(&theTFS, "F25");
314  (*theInelastic[i]).Register(&theHe3FS, "F26");
315  (*theInelastic[i]).Register(&theAFS, "F27");
316  (*theInelastic[i]).Register(&the2AFS, "F28");
317  (*theInelastic[i]).Register(&the3AFS, "F29");
318  (*theInelastic[i]).Register(&the2PFS, "F30");
319  (*theInelastic[i]).Register(&thePAFS, "F31");
320  (*theInelastic[i]).Register(&theD2AFS, "F32");
321  (*theInelastic[i]).Register(&theT2AFS, "F33");
322  (*theInelastic[i]).Register(&thePDFS, "F34");
323  (*theInelastic[i]).Register(&thePTFS, "F35");
324  (*theInelastic[i]).Register(&theDAFS, "F36");
325  (*theInelastic[i]).RestartRegistration();
326  itry++;
327  }
328  while( !(*theInelastic[i]).HasDataInAnyFinalState() && itry < 6 );
329  // 6 is corresponding to the value(5) of G4NeutronHPChannel. TK
330 
331  if ( itry == 6 )
332  {
333  // No Final State at all.
334  G4bool exceptional = false;
335  if ( (*(G4Element::GetElementTable()))[i]->GetNumberOfIsotopes() == 1 )
336  {
337  if ( (*(G4Element::GetElementTable()))[i]->GetIsotope( 0 )->GetZ() == 1 && (*(G4Element::GetElementTable()))[i]->GetIsotope( 0 )->GetN() == 1 ) exceptional = true; //1H
338  }
339  if ( !exceptional ) throw G4HadronicException(__FILE__, __LINE__, "Channel: Do not know what to do with this element");
340  }
341  }
342 
344 }
345 
347 {
349 }
351 {
353 }
G4NeutronHPNDInelasticFS theNDFS
G4NeutronHPN2PInelasticFS theN2PFS
size_t GetNumberOfIsotopes() const
Definition: G4Element.hh:158
G4NeutronHP2PInelasticFS the2PFS
void SetIsotope(const G4Isotope *iso)
Definition: G4Nucleus.hh:122
void Init()
Definition: G4IonTable.cc:89
static const double MeV
Definition: G4SIunits.hh:193
G4NeutronHPHe3InelasticFS theHe3FS
G4NeutronHPPTInelasticFS thePTFS
G4NeutronHPT2AInelasticFS theT2AFS
static G4NeutronHPManager * GetInstance()
G4NeutronHPReactionWhiteBoard * GetReactionWhiteBoard()
G4NeutronHP2N2AInelasticFS the2N2AFS
G4NeutronHPDAInelasticFS theDAFS
G4NeutronHPNPAInelasticFS theNPAFS
G4NeutronHPNInelasticFS theNFS
G4NeutronHPTInelasticFS theTFS
G4NeutronHPPDInelasticFS thePDFS
virtual const std::pair< G4double, G4double > GetFatalEnergyCheckLevels() const
G4NeutronHP2NAInelasticFS the2NAFS
G4NeutronHPNXInelasticFS theNXFS
G4NeutronHP2NPInelasticFS the2NPFS
G4NeutronHPD2AInelasticFS theD2AFS
const G4Element * GetElement(G4int iel) const
Definition: G4Material.hh:200
int G4int
Definition: G4Types.hh:78
std::vector< G4NeutronHPChannelList * > theInelastic
G4NeutronHP3NInelasticFS the3NFS
void SetMinEnergy(G4double anEnergy)
const G4double * GetVecNbOfAtomsPerVolume() const
Definition: G4Material.hh:204
G4NeutronHP4NInelasticFS the4NFS
G4NeutronHP2NDInelasticFS the2NDFS
void Register(T *inst)
Definition: G4AutoDelete.hh:65
G4NeutronHP3NAInelasticFS the3NAFS
G4int GetN() const
Definition: G4Isotope.hh:94
#define G4UniformRand()
Definition: Randomize.hh:87
G4GLOB_DLL std::ostream G4cout
static size_t GetNumberOfElements()
Definition: G4Element.cc:410
G4NeutronHPNT2AInelasticFS theNT2AFS
G4NeutronHPPInelasticFS thePFS
bool G4bool
Definition: G4Types.hh:79
G4NeutronHPND2AInelasticFS theND2AFS
G4NeutronHP2AInelasticFS the2AFS
G4NeutronHPNAInelasticFS theNAFS
size_t GetIndex() const
Definition: G4Element.hh:181
static const double perCent
Definition: G4SIunits.hh:296
const G4int n
G4NeutronHPDInelasticFS theDFS
void SetVerboseLevel(G4int i)
G4NeutronHPNHe3InelasticFS theNHe3FS
G4double GetThermalEnergy(const G4HadProjectile &aP, const G4Element *anE, G4double aT)
G4NeutronHPPAInelasticFS thePAFS
G4HadFinalState * ApplyYourself(const G4HadProjectile &aTrack, G4Nucleus &aTargetNucleus)
void SetMaxEnergy(const G4double anEnergy)
const G4Isotope * GetIsotope(G4int iso) const
Definition: G4Element.hh:169
G4NeutronHP3AInelasticFS the3AFS
G4double GetTemperature() const
Definition: G4Material.hh:180
G4NeutronHPN2AInelasticFS theN2AFS
#define G4endl
Definition: G4ios.hh:61
const G4Material * GetMaterial() const
size_t GetNumberOfElements() const
Definition: G4Material.hh:184
double G4double
Definition: G4Types.hh:76
G4NeutronHPNPInelasticFS theNPFS
G4NeutronHP3NPInelasticFS the3NPFS
static G4ElementTable * GetElementTable()
Definition: G4Element.cc:403
G4NeutronHPN3AInelasticFS theN3AFS
#define DBL_MAX
Definition: templates.hh:83
G4NeutronHPNTInelasticFS theNTFS
void SetParameters(const G4double A, const G4double Z)
Definition: G4Nucleus.cc:198
G4NeutronHP2NInelasticFS the2NFS
G4NeutronHPAInelasticFS theAFS