source: trunk/source/processes/hadronic/models/isotope_production/src/G4NeutronIsoIsoCrossSections.cc @ 1348

Last change on this file since 1348 was 819, checked in by garnier, 16 years ago

import all except CVS

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