source: trunk/source/processes/hadronic/models/neutron_hp/src/G4NeutronHPFissionData.cc @ 1358

Last change on this file since 1358 was 1340, checked in by garnier, 14 years ago

update ti head

File size: 6.9 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// neutron_hp -- source file
27// J.P. Wellisch, Nov-1996
28// A prototype of the low energy neutron transport model.
29//
30// 070618 fix memory leaking by T. Koi
31// 071002 enable cross section dump by T. Koi
32// 081024 G4NucleiPropertiesTable:: to G4NucleiProperties::
33// 081124 Protect invalid read which caused run time errors by T. Koi
34// 100729 Add safty for 0 lenght cross sections by T. Koi
35
36#include "G4NeutronHPFissionData.hh"
37#include "G4Neutron.hh"
38#include "G4ElementTable.hh"
39#include "G4NeutronHPData.hh"
40
41G4bool G4NeutronHPFissionData::IsApplicable(const G4DynamicParticle*aP, const G4Element*)
42{
43  G4bool result = true;
44  G4double eKin = aP->GetKineticEnergy();
45  if(eKin>20*MeV||aP->GetDefinition()!=G4Neutron::Neutron()) result = false;
46  return result;
47}
48
49G4NeutronHPFissionData::G4NeutronHPFissionData()
50{
51  theCrossSections = 0;
52  BuildPhysicsTable(*G4Neutron::Neutron());
53}
54   
55G4NeutronHPFissionData::~G4NeutronHPFissionData()
56{
57
58// TKDB
59   if ( theCrossSections != NULL )
60   {
61      theCrossSections->clearAndDestroy();
62      delete theCrossSections;
63   }
64}
65   
66void G4NeutronHPFissionData::BuildPhysicsTable(const G4ParticleDefinition& aP)
67{
68  if(&aP!=G4Neutron::Neutron()) 
69     throw G4HadronicException(__FILE__, __LINE__, "Attempt to use NeutronHP data for particles other than neutrons!!!"); 
70  size_t numberOfElements = G4Element::GetNumberOfElements();
71  //theCrossSections = new G4PhysicsTable( numberOfElements );
72   // TKDB
73   if ( theCrossSections == NULL ) theCrossSections = new G4PhysicsTable( numberOfElements );
74
75  // make a PhysicsVector for each element
76
77  static const G4ElementTable *theElementTable = G4Element::GetElementTable();
78  for( size_t i=0; i<numberOfElements; ++i )
79  {
80    G4PhysicsVector* physVec = G4NeutronHPData::
81      Instance()->MakePhysicsVector((*theElementTable)[i], this);
82    theCrossSections->push_back(physVec);
83  }
84}
85
86void G4NeutronHPFissionData::DumpPhysicsTable(const G4ParticleDefinition& aP)
87{
88  if(&aP!=G4Neutron::Neutron()) 
89     throw G4HadronicException(__FILE__, __LINE__, "Attempt to use NeutronHP data for particles other than neutrons!!!"); 
90
91//
92// Dump element based cross section
93// range 10e-5 eV to 20 MeV
94// 10 point per decade
95// in barn
96//
97
98   G4cout << G4endl;
99   G4cout << G4endl;
100   G4cout << "Fission Cross Section of Neutron HP"<< G4endl;
101   G4cout << "(Pointwise cross-section at 0 Kelvin.)" << G4endl;
102   G4cout << G4endl;
103   G4cout << "Name of Element" << G4endl;
104   G4cout << "Energy[eV]  XS[barn]" << G4endl;
105   G4cout << G4endl;
106
107   size_t numberOfElements = G4Element::GetNumberOfElements();
108   static const G4ElementTable *theElementTable = G4Element::GetElementTable();
109
110   for ( size_t i = 0 ; i < numberOfElements ; ++i )
111   {
112
113      G4cout << (*theElementTable)[i]->GetName() << G4endl;
114
115      if ( (*((*theCrossSections)(i))).GetVectorLength() == 0 ) 
116      {
117         G4cout << "The cross-section data of the fission of this element is not available." << G4endl; 
118         G4cout << G4endl; 
119         continue;
120      }
121
122      G4int ie = 0;
123
124      for ( ie = 0 ; ie < 130 ; ie++ )
125      {
126         G4double eKinetic = 1.0e-5 * std::pow ( 10.0 , ie/10.0 ) *eV;
127         G4bool outOfRange = false;
128
129         if ( eKinetic < 20*MeV )
130         {
131            G4cout << eKinetic/eV << " " << (*((*theCrossSections)(i))).GetValue(eKinetic, outOfRange)/barn << G4endl;
132         }
133
134      }
135
136      G4cout << G4endl;
137   }
138
139  //G4cout << "G4NeutronHPFissionData::DumpPhysicsTable still to be implemented"<<G4endl;
140}
141
142#include "G4NucleiProperties.hh"
143
144G4double G4NeutronHPFissionData::
145GetCrossSection(const G4DynamicParticle* aP, const G4Element*anE, G4double aT)
146{
147  G4double result = 0;
148  if(anE->GetZ()<90) return result;
149  G4bool outOfRange;
150  G4int index = anE->GetIndex();
151
152// 100729 TK add safety
153if ( ( ( *theCrossSections )( index ) )->GetVectorLength() == 0 ) return result;
154
155  // prepare neutron
156  G4double eKinetic = aP->GetKineticEnergy();
157  G4ReactionProduct theNeutron( aP->GetDefinition() );
158  theNeutron.SetMomentum( aP->GetMomentum() );
159  theNeutron.SetKineticEnergy( eKinetic );
160
161  // prepare thermal nucleus
162  G4Nucleus aNuc;
163  G4double eps = 0.0001;
164  G4double theA = anE->GetN();
165  G4double theZ = anE->GetZ();
166  G4double eleMass; 
167  eleMass = ( G4NucleiProperties::GetNuclearMass( static_cast<G4int>(theA+eps) , static_cast<G4int>(theZ+eps) )
168             ) / G4Neutron::Neutron()->GetPDGMass();
169 
170  G4ReactionProduct boosted;
171  G4double aXsection;
172 
173  // MC integration loop
174  G4int counter = 0;
175  G4double buffer = 0;
176  G4int size = G4int(std::max(10., aT/60*kelvin));
177  G4ThreeVector neutronVelocity = 1./G4Neutron::Neutron()->GetPDGMass()*theNeutron.GetMomentum();
178  G4double neutronVMag = neutronVelocity.mag();
179
180  while(counter == 0 || std::abs(buffer-result/std::max(1,counter)) > 0.01*buffer)
181  {
182    if(counter) buffer = result/counter;
183    while (counter<size)
184    {
185      counter ++;
186      G4ReactionProduct aThermalNuc = aNuc.GetThermalNucleus(eleMass, aT);
187      boosted.Lorentz(theNeutron, aThermalNuc);
188      G4double theEkin = boosted.GetKineticEnergy();
189      aXsection = (*((*theCrossSections)(index))).GetValue(theEkin, outOfRange);
190      // velocity correction.
191      G4ThreeVector targetVelocity = 1./aThermalNuc.GetMass()*aThermalNuc.GetMomentum();
192      aXsection *= (targetVelocity-neutronVelocity).mag()/neutronVMag;
193      result += aXsection;
194    }
195    size += size;
196  }
197  result /= counter;
198  return result;
199}
Note: See TracBrowser for help on using the repository browser.