Import Geant4 8.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 14:55:03 +02:00
parent 216a75eeb1
commit fe73f43734
6714 changed files with 118229 additions and 68144 deletions
@@ -27,6 +27,9 @@
// J.P. Wellisch, Nov-1996
// A prototype of the low energy neutron transport model.
//
// 25-08-06 New Final State type (refFlag==3 , Legendre (Low Energy) + Probability (High Energy) )
// is added by T. KOI
//
#include "G4NeutronHPElasticFS.hh"
#include "G4ReactionProduct.hh"
#include "G4Nucleus.hh"
@@ -105,6 +108,61 @@
}
}
}
else if ( repFlag==3 )
{
G4int nEnergy_Legendre;
theData >> nEnergy_Legendre;
theCoefficients = new G4NeutronHPLegendreStore( nEnergy_Legendre );
theCoefficients->InitInterpolation( theData );
G4double temp, energy;
G4int tempdep, nLegendre;
G4int i, ii;
for ( i = 0 ; i < nEnergy_Legendre ; i++ )
{
theData >> temp >> energy >> tempdep >> nLegendre;
energy *=eV;
theCoefficients->Init( i , energy , nLegendre );
theCoefficients->SetTemperature( i , temp );
G4double coeff = 0;
for ( ii = 0 ; ii < nLegendre ; ii++ )
{
// load legendre coefficients.
theData >> coeff;
theCoefficients->SetCoeff(i, ii+1, coeff); // @@@HPW@@@
}
}
tE_of_repFlag3 = energy;
G4int nEnergy_Prob;
theData >> nEnergy_Prob;
theProbArray = new G4NeutronHPPartial( nEnergy_Prob , nEnergy_Prob );
theProbArray->InitInterpolation( theData );
G4int nPoints;
for ( G4int i=0 ; i < nEnergy_Prob ; i++ )
{
theData >> temp >> energy >> tempdep >> nPoints;
energy *= eV;
// consistensy check
if ( i == 0 )
if ( energy != tE_of_repFlag3 )
G4cout << "Warning Trangition Energy of repFlag3 is not consistent." << G4endl;
theProbArray->InitInterpolation( i , theData );
theProbArray->SetT( i , temp );
theProbArray->SetX( i , energy );
G4double prob, costh;
for( G4int ii = 0 ; ii < nPoints ; ii++ )
{
// fill probability arrays.
theData >> costh >> prob;
theProbArray->SetX( i , ii , costh );
theProbArray->SetY( i , ii , prob );
}
}
}
else if (repFlag==0)
{
theData >> frameFlag;
@@ -169,6 +227,17 @@
{
cosTh = theProbArray->Sample(eKinetic);
}
else if (repFlag==3)
{
if ( eKinetic <= tE_of_repFlag3 )
{
cosTh = theCoefficients->SampleElastic(eKinetic);
}
else
{
cosTh = theProbArray->Sample(eKinetic);
}
}
else if (repFlag==0)
{
cosTh = 2.*G4UniformRand()-1.;
@@ -27,6 +27,8 @@
// J.P. Wellisch, Nov-1996
// A prototype of the low energy neutron transport model.
//
// 02-08-06 Modified Harmonise to reslove cross section trouble at high-end. T. KOI
//
#include "G4NeutronHPElementData.hh"
G4NeutronHPElementData::G4NeutronHPElementData()
@@ -173,7 +175,11 @@
// G4cout << "Harmonise 4: "<< p <<" "<<passive->GetVectorLength()<<" "<<m<<G4endl;
while (p!=passive->GetVectorLength())
{
theMerge->SetData(m++, passive->GetEnergy(p), passive->GetXsec(p));
// Modified by T. KOI
//theMerge->SetData(m++, passive->GetEnergy(p), passive->GetXsec(p));
G4double x = passive->GetEnergy(p);
G4double y = std::max(0., active->GetXsec(x));
theMerge->SetData(m++, x, passive->GetXsec(p)+y);
p++;
}
// G4cout <<"Harmonise 5: "<< theMerge->GetVectorLength() << " " << m << G4endl;
@@ -27,6 +27,8 @@
// J.P. Wellisch, Nov-1996
// A prototype of the low energy neutron transport model.
//
// 08-08-06 delete unnecessary and harmed declaration; Bug Report[857]
//
#include "G4NeutronHPFission.hh"
G4NeutronHPFission::G4NeutronHPFission()
@@ -66,7 +68,7 @@
{
xSec = new G4double[n];
G4double sum=0;
G4int i, index;
G4int i;
const G4double * NumAtomsPerVolume = theMaterial->GetVecNbOfAtomsPerVolume();
G4double rWeight;
G4NeutronHPThermalBoost aThermalE;
@@ -33,7 +33,7 @@
// and all its terms.
//
// $Id: G4NeutronHPInelastic.cc,v 1.20 2006/06/29 20:52:32 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
// GEANT4 tag $Name: geant4-08-02 $
//
#include "G4NeutronHPInelastic.hh"
@@ -0,0 +1,390 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Class Description
// Cross-section data set for a high precision (based on JENDL_HE evaluated data
// libraries) description of elastic scattering 20 MeV ~ 3 GeV;
// Class Description - End
// 15-Nov-06 First Implementation is done by T. Koi (SLAC/SCCS)
#include "G4NeutronHPJENDLHEData.hh"
#include "G4LPhysicsFreeVector.hh"
#include "G4ElementTable.hh"
#include "G4NeutronHPData.hh"
G4bool G4NeutronHPJENDLHEData::IsApplicable(const G4DynamicParticle*aP, const G4Element* anE)
{
G4bool result = true;
G4double eKin = aP->GetKineticEnergy();
//if(eKin>20*MeV||aP->GetDefinition()!=G4Neutron::Neutron()) result = false;
if ( eKin < 20*MeV || 3*GeV < eKin || aP->GetDefinition()!=G4Neutron::Neutron() )
{
result = false;
}
// Element Check
else if ( !(vElement[ anE->GetIndex() ]) ) result = false;
return result;
}
G4NeutronHPJENDLHEData::G4NeutronHPJENDLHEData()
{
;
}
G4NeutronHPJENDLHEData::G4NeutronHPJENDLHEData( G4String reaction , G4ParticleDefinition* pd )
{
reactionName = reaction;
BuildPhysicsTable( *pd );
}
G4NeutronHPJENDLHEData::~G4NeutronHPJENDLHEData()
{
;
//delete theCrossSections;
}
void G4NeutronHPJENDLHEData::BuildPhysicsTable( const G4ParticleDefinition& aP )
{
// if ( &aP != G4Neutron::Neutron() )
// throw G4HadronicException(__FILE__, __LINE__, "Attempt to use NeutronHP data for particles other than neutrons!!!");
particleName = aP.GetParticleName();
G4String baseName = getenv( "NeutronHPCrossSections" );
G4String dirName = baseName+"/JENDL_HE/"+particleName+"/"+reactionName ;
G4String aFSType = "/CrossSection/";
G4NeutronHPNames theNames;
G4String filename;
// Create JENDL_HE data
// Create map element or isotope
size_t numberOfElements = G4Element::GetNumberOfElements();
//theCrossSections = new G4PhysicsTable( numberOfElements );
// make a PhysicsVector for each element
static const G4ElementTable *theElementTable = G4Element::GetElementTable();
vElement.clear();
vElement.resize( numberOfElements );
for ( size_t i = 0; i < numberOfElements; ++i )
{
G4Element* theElement = (*theElementTable)[i];
vElement[i] = false;
// isotope
G4int nIso = (*theElementTable)[i]->GetNumberOfIsotopes();
G4int Z = static_cast<G4int> ((*theElementTable)[i]->GetZ());
if ( nIso!=0 )
{
G4bool found_at_least_one = false;
for ( G4int i1 = 0; i1 < nIso; i1++ )
{
G4int A = theElement->GetIsotope(i1)->GetN();
if ( isThisNewIsotope( Z , A ) )
{
std::stringstream ss;
ss << dirName << aFSType << Z << "_" << A << "_" << theNames.GetName( Z-1 );
filename = ss.str();
std::fstream file;
file.open ( filename , std::fstream::in );
G4int dummy;
file >> dummy;
if ( file.good() )
{
//G4cout << "Found file for Z=" << Z << ", A=" << A << ", as " << filename << G4endl;
found_at_least_one = true;
// read the file
G4PhysicsVector* aPhysVec = readAFile ( &file );
//Regist
registAPhysicsVector( Z , A , aPhysVec );
}
else
{
//G4cout << "No file for "<< reactionType << " Z=" << Z << ", A=" << A << G4endl;
}
file.close();
}
else
{
found_at_least_one = TRUE;
}
}
if ( found_at_least_one ) vElement[i] = true;
}
else
{
G4StableIsotopes theStableOnes;
G4int first = theStableOnes.GetFirstIsotope( Z );
G4bool found_at_least_one = FALSE;
for ( G4int i1 = 0; i1 < theStableOnes.GetNumberOfIsotopes( static_cast<G4int>(theElement->GetZ() ) ); i1++)
{
G4int A = theStableOnes.GetIsotopeNucleonCount( first+i1 );
if ( isThisNewIsotope( Z , A ) )
{
std::stringstream ss;
ss << dirName << aFSType << Z << "_" << A << "_" << theNames.GetName( Z-1 );
filename = ss.str();
std::fstream file;
file.open ( filename , std::fstream::in );
G4int dummy;
file >> dummy;
if ( file.good() )
{
//G4cout << "Found file for Z=" << Z << ", A=" << A << ", as " << filename << G4endl;
found_at_least_one = TRUE;
//Read the file
G4PhysicsVector* aPhysVec = readAFile ( &file );
//Regist the PhysicsVector
registAPhysicsVector( Z , A , aPhysVec );
}
else
{
//G4cout << "No file for "<< reactionType << " Z=" << Z << ", A=" << A << G4endl;
}
file.close();
}
else
{
found_at_least_one = TRUE;
}
}
if ( found_at_least_one ) vElement[i] = true;
}
}
}
void G4NeutronHPJENDLHEData::DumpPhysicsTable(const G4ParticleDefinition& aP)
{
if(&aP!=G4Neutron::Neutron())
throw G4HadronicException(__FILE__, __LINE__, "Attempt to use NeutronHP data for particles other than neutrons!!!");
// G4cout << "G4NeutronHPJENDLHEData::DumpPhysicsTable still to be implemented"<<G4endl;
}
G4double G4NeutronHPJENDLHEData::
GetCrossSection(const G4DynamicParticle* aP, const G4Element*anE, G4double )
// aTemp
{
// Primary energy >20MeV
// Thus
// Not take account of Doppler broadening
// also
// Not take account of Target thermal motions
G4double result = 0;
G4double ek = aP->GetKineticEnergy();
G4int nIso = anE->GetNumberOfIsotopes();
G4int Z = static_cast<G4int> ( anE->GetZ() );
if ( nIso!=0 )
{
for ( G4int i1 = 0; i1 < nIso; i1++ )
{
G4int A = anE->GetIsotope(i1)->GetN();
G4double frac = anE->GetRelativeAbundanceVector()[ i1 ]; // This case do NOT request "*perCent".
result += frac * getXSfromThisIsotope( Z , A , ek );
//G4cout << reactionType << " XS in barn " << Z << " " << A << " " << frac << " " << getXSfromThisIsotope( Z , A , ek )/barn << G4endl;
}
}
else
{
G4StableIsotopes theStableOnes;
G4int first = theStableOnes.GetFirstIsotope( Z );
for ( G4int i1 = 0; i1 < theStableOnes.GetNumberOfIsotopes( static_cast<G4int>(anE->GetZ() ) ); i1++)
{
G4int A = theStableOnes.GetIsotopeNucleonCount( first+i1 );
G4double frac = theStableOnes.GetAbundance( first+i1 )*perCent; // This case request "*perCent".
result += frac * getXSfromThisIsotope( Z , A , ek );
//G4cout << reactionType << " XS in barn " << Z << " " << A << " " << frac << " " << getXSfromThisIsotope( Z , A , ek )/barn << G4endl;
}
}
return result;
}
G4PhysicsVector* G4NeutronHPJENDLHEData::readAFile ( std::fstream* file )
{
G4int dummy;
G4int len;
*file >> dummy;
*file >> len;
std::vector< G4double > v_e;
std::vector< G4double > v_xs;
for ( G4int i = 0 ; i < len ; i++ )
{
G4double e;
G4double xs;
*file >> e;
*file >> xs;
// data are written in eV and barn.
v_e.push_back( e*eV );
v_xs.push_back( xs*barn );
}
G4LPhysicsFreeVector* aPhysVec = new G4LPhysicsFreeVector( static_cast< size_t >( len ) , v_e.front() , v_e.back() );
for ( G4int i = 0 ; i < len ; i++ )
{
aPhysVec->PutValues( static_cast< size_t >( i ) , v_e[ i ] , v_xs[ i ] );
}
return aPhysVec;
}
G4bool G4NeutronHPJENDLHEData::isThisInMap( G4int z , G4int a )
{
if ( mIsotope.find ( z ) == mIsotope.end() ) return false;
if ( mIsotope.find ( z ) -> second->find ( a ) == mIsotope.find ( z ) -> second->end() ) return false;
return true;
}
void G4NeutronHPJENDLHEData::registAPhysicsVector( G4int Z , G4int A , G4PhysicsVector* aPhysVec )
{
std::pair< G4int , G4PhysicsVector* > aPair = std::pair < G4int , G4PhysicsVector* > ( A , aPhysVec );
std::map < G4int , std::map< G4int , G4PhysicsVector* >* >::iterator itm;
itm = mIsotope.find ( Z );
if ( itm != mIsotope.end() )
{
itm->second->insert ( aPair );
}
else
{
std::map< G4int , G4PhysicsVector* >* aMap = new std::map< G4int , G4PhysicsVector* >;
aMap->insert ( aPair );
mIsotope.insert( std::pair< G4int , std::map< G4int , G4PhysicsVector* >* > ( Z , aMap ) );
}
}
G4double G4NeutronHPJENDLHEData::getXSfromThisIsotope( G4int Z , G4int A , G4double ek )
{
G4double aXSection = 0.0;
G4bool outOfRange;
G4PhysicsVector* aPhysVec;
if ( mIsotope.find ( Z )->second->find ( A ) != mIsotope.find ( Z )->second->end() )
{
aPhysVec = mIsotope.find ( Z )->second->find ( A )->second;
aXSection = aPhysVec->GetValue( ek , outOfRange );
}
else
{
//Select closest one in the same Z
std::map < G4int , G4PhysicsVector* >::iterator it;
G4int delta0 = 99; // no mean for 99
for ( it = mIsotope.find ( Z )->second->begin() ; it != mIsotope.find ( Z )->second->end() ; it++ )
{
G4int delta = std::abs( A - it->first );
if ( delta < delta0 ) delta0 = delta;
}
// Randomize of selection larger or smaller than A
if ( G4UniformRand() < 0.5 ) delta0 *= -1;
G4int A1 = A + delta0;
if ( mIsotope.find ( Z )->second->find ( A1 ) != mIsotope.find ( Z )->second->end() )
{
aPhysVec = mIsotope.find ( Z )->second->find ( A1 )->second;
}
else
{
A1 = A - delta0;
aPhysVec = mIsotope.find ( Z )->second->find ( A1 )->second;
}
aXSection = aPhysVec->GetValue( ek , outOfRange );
// X^(2/3) factor
aXSection *= std::pow ( 1.0*A/ A1 , 2.0 / 3.0 );
}
return aXSection;
}
@@ -0,0 +1,40 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Class Description
// Cross-section data set for a high precision (based on JENDL_HE evaluated data
// libraries) description of elastic scattering 20 MeV ~ 3 GeV;
// Class Description - End
// 15-Nov-06 First Implementation is done by T. Koi (SLAC/SCCS)
#include "G4NeutronHPJENDLHEElasticData.hh"
#include "G4Neutron.hh"
G4NeutronHPJENDLHEElasticData::G4NeutronHPJENDLHEElasticData()
:G4NeutronHPJENDLHEData( "Elastic" , G4Neutron::Neutron() )
{
;
}
@@ -0,0 +1,40 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Class Description
// Cross-section data set for a high precision (based on JENDL_HE evaluated data
// libraries) description of elastic scattering 20 MeV ~ 3 GeV;
// Class Description - End
// 15-Nov-06 First Implementation is done by T. Koi (SLAC/SCCS)
#include "G4NeutronHPJENDLHEInelasticData.hh"
#include "G4Neutron.hh"
G4NeutronHPJENDLHEInelasticData::G4NeutronHPJENDLHEInelasticData()
:G4NeutronHPJENDLHEData( "Inelastic" , G4Neutron::Neutron() )
{
;
}
@@ -25,7 +25,7 @@
//
//
// $Id: G4NeutronHPNBodyPhaseSpace.cc,v 1.13 2006/06/29 20:53:11 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
// GEANT4 tag $Name: geant4-08-02 $
//
#include "G4NeutronHPNBodyPhaseSpace.hh"
#include "G4Gamma.hh"
@@ -0,0 +1,838 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Thermal Neutron Scattering
// Koi, Tatsumi (SLAC/SCCS)
//
// Class Description
// Final State Generators for a high precision (based on evaluated data
// libraries) description of themal neutron scattering below 4 eV;
// Based on Thermal neutron scattering files
// from the evaluated nuclear data files ENDF/B-VI, Release2
// To be used in your physics list in case you need this physics.
// In this case you want to register an object of this class with
// the corresponding process.
// Class Description - End
#include "G4NeutronHPThermalScattering.hh"
#include "G4Neutron.hh"
#include "G4ElementTable.hh"
G4NeutronHPThermalScattering::G4NeutronHPThermalScattering()
{
theHPElastic = new G4NeutronHPElastic();
SetMinEnergy( 0.*eV );
SetMaxEnergy( 4*eV );
theXSection = new G4NeutronHPThermalScatteringData();
theXSection->BuildPhysicsTable( *(G4Neutron::Neutron()) );
// Check Elements
std::vector< G4int > indexOfThermalElement;
static const G4ElementTable* theElementTable = G4Element::GetElementTable();
size_t numberOfElements = G4Element::GetNumberOfElements();
for ( size_t i = 0 ; i < numberOfElements ; i++ )
{
if ( names.IsThisThermalElement ( (*theElementTable)[i]->GetName() ) )
{
indexOfThermalElement.push_back( i );
}
}
G4String dirName;
if ( !getenv("NeutronHPCrossSections") )
throw G4HadronicException(__FILE__, __LINE__, "Please setenv NeutronHPCrossSections to point to the neutron cross-section files.");
dirName = getenv("NeutronHPCrossSections");
// Read data
// Element (id) -> FS Type -> read file
for ( size_t i = 0 ; i < indexOfThermalElement.size() ; i++ )
{
//G4cout << "G4NeutronHPThermalScattering " << (*theElementTable)[i]->GetName() << G4endl;
G4String tsndlName = names.GetTS_NDL_Name ( (*theElementTable)[ indexOfThermalElement[ i ] ]->GetName() );
//G4cout << "G4NeutronHPThermalScattering " << tsndlName << std::endl;
// coherent elastic
G4String fsName = "/ThermalScattering/Coherent/FS/";
G4String fileName = dirName + fsName + tsndlName;
coherentFSs.insert ( std::pair < G4int , std::map < G4double , std::vector < std::pair< G4double , G4double >* >* >* > ( indexOfThermalElement[ i ] , readACoherentFSDATA( fileName ) ) );
// incoherent elastic
fsName = "/ThermalScattering/Incoherent/FS/";
fileName = dirName + fsName + tsndlName;
incoherentFSs.insert ( std::pair < G4int , std::map < G4double , std::vector < E_isoAng* >* >* > ( indexOfThermalElement[ i ] , readAnIncoherentFSDATA( fileName ) ) );
// inelastic
fsName = "/ThermalScattering/Inelastic/FS/";
fileName = dirName + fsName + tsndlName;
inelasticFSs.insert ( std::pair < G4int , std::map < G4double , std::vector < E_P_E_isoAng* >* >* > ( indexOfThermalElement[ i ] , readAnInelasticFSDATA( fileName ) ) );
}
}
G4NeutronHPThermalScattering::~G4NeutronHPThermalScattering()
{
;
}
std::map < G4double , std::vector < std::pair< G4double , G4double >* >* >* G4NeutronHPThermalScattering::readACoherentFSDATA( G4String name )
{
std::map < G4double , std::vector < std::pair< G4double , G4double >* >* >* aCoherentFSDATA = new std::map < G4double , std::vector < std::pair< G4double , G4double >* >* >;
std::ifstream theChannel( name.c_str() );
std::vector< G4double > vBraggE;
G4int dummy;
while ( theChannel >> dummy ) // MF
{
theChannel >> dummy; // MT
G4double temp;
theChannel >> temp;
std::vector < std::pair< G4double , G4double >* >* anBragE_P = new std::vector < std::pair< G4double , G4double >* >;
G4int n;
theChannel >> n;
for ( G4int i = 0 ; i < n ; i++ )
{
G4double Ei;
G4double Pi;
if ( aCoherentFSDATA->size() == 0 )
{
theChannel >> Ei;
vBraggE.push_back( Ei );
}
else
{
Ei = vBraggE[ i ];
}
theChannel >> Pi;
anBragE_P->push_back ( new std::pair < G4double , G4double > ( Ei , Pi ) );
//G4cout << "Coherent Elastic " << Ei << " " << Pi << G4endl;
}
aCoherentFSDATA->insert ( std::pair < G4double , std::vector < std::pair< G4double , G4double >* >* > ( temp , anBragE_P ) );
}
return aCoherentFSDATA;
}
std::map < G4double , std::vector < E_P_E_isoAng* >* >* G4NeutronHPThermalScattering::readAnInelasticFSDATA ( G4String name )
{
std::map < G4double , std::vector < E_P_E_isoAng* >* >* anT_E_P_E_isoAng = new std::map < G4double , std::vector < E_P_E_isoAng* >* >;
std::ifstream theChannel( name.c_str() );
G4int dummy;
while ( theChannel >> dummy ) // MF
{
theChannel >> dummy; // MT
G4double temp;
theChannel >> temp;
std::vector < E_P_E_isoAng* >* vE_P_E_isoAng = new std::vector < E_P_E_isoAng* >;
G4int n;
theChannel >> n;
for ( G4int i = 0 ; i < n ; i++ )
{
vE_P_E_isoAng->push_back ( readAnE_P_E_isoAng ( &theChannel ) );
}
anT_E_P_E_isoAng->insert ( std::pair < G4double , std::vector < E_P_E_isoAng* >* > ( temp , vE_P_E_isoAng ) );
}
theChannel.close();
return anT_E_P_E_isoAng;
}
E_P_E_isoAng* G4NeutronHPThermalScattering::readAnE_P_E_isoAng( std::ifstream* file )
{
E_P_E_isoAng* aData = new E_P_E_isoAng;
G4double dummy;
G4double energy;
G4int nep , nl;
*file >> dummy;
*file >> energy;
aData->energy = energy*eV;
*file >> dummy;
*file >> dummy;
*file >> nep;
*file >> nl;
aData->n = nep/nl;
for ( G4int i = 0 ; i < aData->n ; i++ )
{
G4double prob;
E_isoAng* anE_isoAng = new E_isoAng;
aData->vE_isoAngle.push_back( anE_isoAng );
*file >> energy;
anE_isoAng->energy = energy*eV;
anE_isoAng->n = nl - 2;
anE_isoAng->isoAngle.resize( anE_isoAng->n );
*file >> prob;
aData->prob.push_back( prob );
//G4cout << "G4NeutronHPThermalScattering inelastic " << energy/eV << " " << i << " " << prob << " " << aData->prob[ i ] << G4endl;
for ( G4int j = 0 ; j < anE_isoAng->n ; j++ )
{
G4double x;
*file >> x;
anE_isoAng->isoAngle[j] = x ;
//G4cout << "G4NeutronHPThermalScattering inelastic " << x << anE_isoAng->isoAngle[j] << G4endl;
}
}
// Calcuate sum_of_provXdEs
G4double total = 0;
for ( G4int i = 0 ; i < aData->n - 1 ; i++ )
{
G4double E_L = aData->vE_isoAngle[i]->energy/eV;
G4double E_H = aData->vE_isoAngle[i+1]->energy/eV;
G4double dE = E_H - E_L;
total += ( ( aData->prob[i] ) * dE );
}
aData->sum_of_probXdEs = total;
return aData;
}
std::map < G4double , std::vector < E_isoAng* >* >* G4NeutronHPThermalScattering::readAnIncoherentFSDATA ( G4String name )
{
std::map < G4double , std::vector < E_isoAng* >* >* T_E = new std::map < G4double , std::vector < E_isoAng* >* >;
std::ifstream theChannel( name.c_str() );
G4int dummy;
while ( theChannel >> dummy ) // MF
{
theChannel >> dummy; // MT
G4double temp;
theChannel >> temp;
std::vector < E_isoAng* >* vE_isoAng = new std::vector < E_isoAng* >;
G4int n;
theChannel >> n;
for ( G4int i = 0 ; i < n ; i++ )
vE_isoAng->push_back ( readAnE_isoAng( &theChannel ) );
T_E->insert ( std::pair < G4double , std::vector < E_isoAng* >* > ( temp , vE_isoAng ) );
}
theChannel.close();
return T_E;
}
E_isoAng* G4NeutronHPThermalScattering::readAnE_isoAng( std::ifstream* file )
{
E_isoAng* aData = new E_isoAng;
G4double dummy;
G4double energy;
G4int n;
*file >> dummy;
*file >> energy;
*file >> dummy;
*file >> dummy;
*file >> n;
*file >> dummy;
aData->energy = energy*eV;
aData->n = n-2;
aData->isoAngle.resize( n );
*file >> dummy;
*file >> dummy;
for ( G4int i = 0 ; i < aData->n ; i++ )
*file >> aData->isoAngle[i];
return aData;
}
G4HadFinalState* G4NeutronHPThermalScattering::ApplyYourself(const G4HadProjectile& aTrack, G4Nucleus& aNucleus )
{
// Select Element > Reaction >
const G4Material * theMaterial = aTrack.GetMaterial();
G4double aTemp = theMaterial->GetTemperature();
G4int n = theMaterial->GetNumberOfElements();
static const G4ElementTable* theElementTable = G4Element::GetElementTable();
G4bool findThermalElement = false;
G4int ielement;
for ( G4int i = 0; i < n ; i++ )
{
G4int index = theMaterial->GetElement(i)->GetIndex();
if ( aNucleus.GetZ() == (*theElementTable)[index]->GetZ() && ( names.IsThisThermalElement ( (*theElementTable)[index]->GetName() ) ) )
{
ielement = index;
findThermalElement = true;
break;
}
}
if ( findThermalElement == true )
{
// Select Reaction (Inelastic, coherent, incoherent)
G4ParticleDefinition* pd = const_cast< G4ParticleDefinition* >( aTrack.GetDefinition() );
G4DynamicParticle* dp = new G4DynamicParticle ( pd , aTrack.Get4Momentum() );
G4double total = theXSection->GetCrossSection( dp , (*theElementTable)[ ielement ] , aTemp );
G4double inelastic = theXSection->GetInelasticCrossSection( dp , (*theElementTable)[ ielement ] , aTemp );
G4double random = G4UniformRand();
if ( random <= inelastic/total )
{
// Inelastic
// T_L and T_H
std::map < G4double , std::vector< E_P_E_isoAng* >* >::iterator it;
std::vector<G4double> v_temp;
v_temp.clear();
for ( it = inelasticFSs.find( ielement )->second->begin() ; it != inelasticFSs.find( ielement )->second->end() ; it++ )
{
v_temp.push_back( it->first );
}
// T_L T_H
std::pair < G4double , G4double > tempLH = find_LH ( aTemp , &v_temp );
//
// For T_L aNEP_EPM_TL and T_H aNEP_EPM_TH
//
std::vector< E_P_E_isoAng* >* vNEP_EPM_TL = NULL;
std::vector< E_P_E_isoAng* >* vNEP_EPM_TH = NULL;
if ( tempLH.first != 0.0 && tempLH.second != 0.0 )
{
vNEP_EPM_TL = inelasticFSs.find( ielement )->second->find ( tempLH.first/kelvin )->second;
vNEP_EPM_TH = inelasticFSs.find( ielement )->second->find ( tempLH.second/kelvin )->second;
}
else if ( tempLH.first == 0.0 )
{
std::map < G4double , std::vector< E_P_E_isoAng* >* >::iterator itm;
itm = inelasticFSs.find( ielement )->second->begin();
vNEP_EPM_TL = itm->second;
itm++;
vNEP_EPM_TH = itm->second;
}
else if ( tempLH.second == 0.0 )
{
std::map < G4double , std::vector< E_P_E_isoAng* >* >::iterator itm;
itm = inelasticFSs.find( ielement )->second->end();
itm--;
vNEP_EPM_TH = itm->second;
itm--;
vNEP_EPM_TL = itm->second;
}
//
G4double rand_for_sE = G4UniformRand();
std::pair< G4double , E_isoAng > TL = create_sE_and_EPM_from_pE_and_vE_P_E_isoAng ( rand_for_sE , aTrack.GetKineticEnergy() , vNEP_EPM_TL );
std::pair< G4double , E_isoAng > TH = create_sE_and_EPM_from_pE_and_vE_P_E_isoAng ( rand_for_sE , aTrack.GetKineticEnergy() , vNEP_EPM_TH );
G4double sE;
sE = get_linear_interpolated ( aTemp , std::pair < G4double , G4double > ( tempLH.first , TL.first ) , std::pair < G4double , G4double > ( tempLH.second , TH.first ) );
E_isoAng anE_isoAng;
if ( TL.second.n == TH.second.n )
{
anE_isoAng.energy = sE;
anE_isoAng.n = TL.second.n;
for ( G4int i=0 ; i < anE_isoAng.n ; i++ )
{
G4double angle;
angle = get_linear_interpolated ( aTemp , std::pair< G4double , G4double > ( tempLH.first , TL.second.isoAngle[ i ] ) , std::pair< G4double , G4double > ( tempLH.second , TH.second.isoAngle[ i ] ) );
anE_isoAng.isoAngle.push_back( angle );
}
}
else
{
std::cout << "Do not Suuport yet." << std::endl;
}
//set
theParticleChange.SetEnergyChange( sE );
G4double mu = getMu( &anE_isoAng );
theParticleChange.SetMomentumChange( 0.0 , std::sqrt ( 1 - mu*mu ) , mu );
}
else if ( random <= ( inelastic + theXSection->GetCoherentCrossSection( dp , (*theElementTable)[ ielement ] , aTemp ) ) / total )
{
// Coherent Elastic
G4double E = aTrack.GetKineticEnergy();
// T_L and T_H
std::map < G4double , std::vector< std::pair< G4double , G4double >* >* >::iterator it;
std::vector<G4double> v_temp;
v_temp.clear();
for ( it = coherentFSs.find( ielement )->second->begin() ; it != coherentFSs.find( ielement )->second->end() ; it++ )
{
v_temp.push_back( it->first );
}
// T_L T_H
std::pair < G4double , G4double > tempLH = find_LH ( aTemp , &v_temp );
//
//
// For T_L anEPM_TL and T_H anEPM_TH
//
std::vector< std::pair< G4double , G4double >* >* pvE_p_TL = NULL;
std::vector< std::pair< G4double , G4double >* >* pvE_p_TH = NULL;
if ( tempLH.first != 0.0 && tempLH.second != 0.0 )
{
pvE_p_TL = coherentFSs.find( ielement )->second->find ( tempLH.first/kelvin )->second;
pvE_p_TH = coherentFSs.find( ielement )->second->find ( tempLH.first/kelvin )->second;
}
else if ( tempLH.first == 0.0 )
{
pvE_p_TL = coherentFSs.find( ielement )->second->find ( v_temp[ 0 ] )->second;
pvE_p_TH = coherentFSs.find( ielement )->second->find ( v_temp[ 1 ] )->second;
}
else if ( tempLH.second == 0.0 )
{
pvE_p_TL = coherentFSs.find( ielement )->second->find ( v_temp.back() )->second;
std::vector< G4double >::iterator itv;
itv = v_temp.end();
itv--;
itv--;
pvE_p_TL = coherentFSs.find( ielement )->second->find ( *itv )->second;
}
std::vector< G4double > vE_T;
std::vector< G4double > vp_T;
G4int n1 = pvE_p_TL->size();
//G4int n2 = pvE_p_TH->size();
for ( G4int i=1 ; i < n1 ; i++ )
{
if ( (*pvE_p_TL)[i]->first != (*pvE_p_TH)[i]->first ) abort();
vE_T.push_back ( (*pvE_p_TL)[i]->first );
vp_T.push_back ( get_linear_interpolated ( aTemp , std::pair< G4double , G4double > ( tempLH.first , (*pvE_p_TL)[i]->second ) , std::pair< G4double , G4double > ( tempLH.second , (*pvE_p_TL)[i]->second ) ) );
}
G4int j = 0;
for ( G4int i = 1 ; i < n ; i++ )
{
if ( E/eV < vE_T[ i ] )
{
j = i-1;
break;
}
}
G4double rand_for_mu = G4UniformRand();
G4int k = 0;
for ( G4int i = 1 ; i < j ; i++ )
{
G4double Pi = vp_T[ i ] / vp_T[ j ];
if ( rand_for_mu < Pi )
{
k = i-1;
break;
}
}
G4double Ei = vE_T[ j ];
G4double mu = 1 - 2 * Ei / (E/eV) ;
theParticleChange.SetEnergyChange( E );
theParticleChange.SetMomentumChange( 0.0 , std::sqrt ( 1 - mu*mu ) , mu );
}
else
{
// InCoherent Elastic
// T_L and T_H
std::map < G4double , std::vector < E_isoAng* >* >::iterator it;
std::vector<G4double> v_temp;
v_temp.clear();
for ( it = incoherentFSs.find( ielement )->second->begin() ; it != incoherentFSs.find( ielement )->second->end() ; it++ )
{
v_temp.push_back( it->first );
}
// T_L T_H
std::pair < G4double , G4double > tempLH = find_LH ( aTemp , &v_temp );
//
// For T_L anEPM_TL and T_H anEPM_TH
//
E_isoAng anEPM_TL_E;
E_isoAng anEPM_TH_E;
if ( tempLH.first != 0.0 && tempLH.second != 0.0 )
{
anEPM_TL_E = create_E_isoAng_from_energy ( aTrack.GetKineticEnergy() , incoherentFSs.find( ielement )->second->find ( tempLH.first/kelvin )->second );
anEPM_TH_E = create_E_isoAng_from_energy ( aTrack.GetKineticEnergy() , incoherentFSs.find( ielement )->second->find ( tempLH.second/kelvin )->second );
}
else if ( tempLH.first == 0.0 )
{
anEPM_TL_E = create_E_isoAng_from_energy ( aTrack.GetKineticEnergy() , incoherentFSs.find( ielement )->second->find ( v_temp[ 0 ] )->second );
anEPM_TH_E = create_E_isoAng_from_energy ( aTrack.GetKineticEnergy() , incoherentFSs.find( ielement )->second->find ( v_temp[ 1 ] )->second );
}
else if ( tempLH.second == 0.0 )
{
anEPM_TH_E = create_E_isoAng_from_energy ( aTrack.GetKineticEnergy() , incoherentFSs.find( ielement )->second->find ( v_temp.back() )->second );
std::vector< G4double >::iterator itv;
itv = v_temp.end();
itv--;
itv--;
anEPM_TL_E = create_E_isoAng_from_energy ( aTrack.GetKineticEnergy() , incoherentFSs.find( ielement )->second->find ( *itv )->second );
}
// E_isoAng for aTemp and aTrack.GetKineticEnergy()
E_isoAng anEPM_T_E;
if ( anEPM_TL_E.n == anEPM_TH_E.n )
{
anEPM_T_E.n = anEPM_TL_E.n;
for ( G4int i=0 ; i < anEPM_TL_E.n ; i++ )
{
G4double angle;
angle = get_linear_interpolated ( aTemp , std::pair< G4double , G4double > ( tempLH.first , anEPM_TL_E.isoAngle[ i ] ) , std::pair< G4double , G4double > ( tempLH.second , anEPM_TH_E.isoAngle[ i ] ) );
anEPM_T_E.isoAngle.push_back( angle );
}
}
else
{
std::cout << "Do not Suuport yet." << std::endl;
}
// Decide mu
G4double mu = getMu ( &anEPM_T_E );
// Set Final State
theParticleChange.SetEnergyChange( aTrack.GetKineticEnergy() ); // No energy change in Elastic
theParticleChange.SetMomentumChange( 0.0 , std::sqrt ( 1 - mu*mu ) , mu );
}
delete dp;
return &theParticleChange;
}
else
{
// Not thermal element
// Neutron HP will handle
return theHPElastic -> ApplyYourself( aTrack, aNucleus );
}
}
G4double G4NeutronHPThermalScattering::getMu( E_isoAng* anEPM )
{
G4double random = G4UniformRand();
G4double result = 0.0;
G4int in = int ( random * ( (*anEPM).n ) );
if ( in != 0 )
{
G4double mu_l = (*anEPM).isoAngle[ in-1 ];
G4double mu_h = (*anEPM).isoAngle[ in ];
result = ( mu_h - mu_l ) * ( random * ( (*anEPM).n ) - in ) + mu_l;
}
else
{
G4double x = random * (*anEPM).n;
G4double D = ( (*anEPM).isoAngle[ 0 ] - ( -1 ) ) + ( 1 - (*anEPM).isoAngle[ (*anEPM).n - 1 ] );
G4double ratio = ( (*anEPM).isoAngle[ 0 ] - ( -1 ) ) / D;
if ( x <= ratio )
{
G4double mu_l = -1;
G4double mu_h = (*anEPM).isoAngle[ 0 ];
result = ( mu_h - mu_l ) * x + mu_l;
}
else
{
G4double mu_l = (*anEPM).isoAngle[ (*anEPM).n - 1 ];
G4double mu_h = 1;
result = ( mu_h - mu_l ) * x + mu_l;
}
}
return result;
}
std::pair < G4double , G4double > G4NeutronHPThermalScattering::find_LH ( G4double x , std::vector< G4double >* aVector )
{
G4double L = 0.0;
G4double H = 0.0;
std::vector< G4double >::iterator it;
for ( it = aVector->begin() ; it != aVector->end() ; it++ )
{
if ( x <= *it )
{
H = *it;
if ( it != aVector->begin() )
{
it--;
L = *it;
}
else
{
L = 0.0;
}
break;
}
}
if ( H == 0.0 )
L = aVector->back();
return std::pair < G4double , G4double > ( L , H );
}
G4double G4NeutronHPThermalScattering::get_linear_interpolated ( G4double x , std::pair< G4double , G4double > Low , std::pair< G4double , G4double > High )
{
G4double y=0.0;
if ( High.first - Low.first != 0 )
y = ( High.second - Low.second ) / ( High.first - Low.first ) * ( x - Low.first ) + Low.second;
else
std::cout << "G4NeutronHPThermalScattering liner interpolation err!!" << std::endl;
return y;
}
E_isoAng G4NeutronHPThermalScattering::create_E_isoAng_from_energy ( G4double energy , std::vector< E_isoAng* >* vEPM )
{
E_isoAng anEPM_T_E;
std::vector< E_isoAng* >::iterator iv;
std::vector< G4double > v_e;
v_e.clear();
for ( iv = vEPM->begin() ; iv != vEPM->end() ; iv++ )
v_e.push_back ( (*iv)->energy );
std::pair < G4double , G4double > energyLH = find_LH ( energy , &v_e );
//std::cout << " " << energy/eV << " " << energyLH.first/eV << " " << energyLH.second/eV << std::endl;
E_isoAng* panEPM_T_EL=NULL;
E_isoAng* panEPM_T_EH=NULL;
if ( energyLH.first != 0.0 && energyLH.second != 0.0 )
{
for ( iv = vEPM->begin() ; iv != vEPM->end() ; iv++ )
{
if ( energyLH.first == (*iv)->energy )
break;
}
panEPM_T_EL = *iv;
iv++;
panEPM_T_EH = *iv;
}
else if ( energyLH.first == 0.0 )
{
panEPM_T_EL = (*vEPM)[0];
panEPM_T_EH = (*vEPM)[1];
}
else if ( energyLH.second == 0.0 )
{
panEPM_T_EH = (*vEPM).back();
iv = vEPM->end();
iv--;
iv--;
panEPM_T_EL = *iv;
}
if ( panEPM_T_EL->n == panEPM_T_EH->n )
{
anEPM_T_E.energy = energy;
anEPM_T_E.n = panEPM_T_EL->n;
for ( G4int i=0 ; i < panEPM_T_EL->n ; i++ )
{
G4double angle;
angle = get_linear_interpolated ( energy , std::pair< G4double , G4double > ( energyLH.first , panEPM_T_EL->isoAngle[ i ] ) , std::pair< G4double , G4double > ( energyLH.second , panEPM_T_EH->isoAngle[ i ] ) );
anEPM_T_E.isoAngle.push_back( angle );
}
}
else
{
G4cout << "G4NeutronHPThermalScattering Do not Suuport yet." << G4endl;
}
return anEPM_T_E;
}
G4double G4NeutronHPThermalScattering::get_secondary_energy_from_E_P_E_isoAng ( G4double random , E_P_E_isoAng* anE_P_E_isoAng )
{
G4double secondary_energy = 0.0;
G4int n = anE_P_E_isoAng->n;
G4double sum_p = 0.0; // sum_p_H
G4double sum_p_L = 0.0;
G4double total=0.0;
/*
delete for speed up
for ( G4int i = 0 ; i < n-1 ; i++ )
{
G4double E_L = anE_P_E_isoAng->vE_isoAngle[i]->energy/eV;
G4double E_H = anE_P_E_isoAng->vE_isoAngle[i+1]->energy/eV;
G4double dE = E_H - E_L;
total += ( ( anE_P_E_isoAng->prob[i] ) * dE );
}
if ( std::abs( total - anE_P_E_isoAng->sum_of_probXdEs ) > 1.0e-14 ) std::cout << total - anE_P_E_isoAng->sum_of_probXdEs << std::endl;
*/
total = anE_P_E_isoAng->sum_of_probXdEs;
for ( G4int i = 0 ; i < n-1 ; i++ )
{
G4double E_L = anE_P_E_isoAng->vE_isoAngle[i]->energy/eV;
G4double E_H = anE_P_E_isoAng->vE_isoAngle[i+1]->energy/eV;
G4double dE = E_H - E_L;
sum_p += ( ( anE_P_E_isoAng->prob[i] ) * dE );
if ( random <= sum_p/total )
{
secondary_energy = get_linear_interpolated ( random , std::pair < G4double , G4double > ( sum_p_L/total , E_L ) , std::pair < G4double , G4double > ( sum_p/total , E_H ) );
secondary_energy = secondary_energy*eV; //need eV
break;
}
sum_p_L = sum_p;
}
return secondary_energy;
}
std::pair< G4double , E_isoAng > G4NeutronHPThermalScattering::create_sE_and_EPM_from_pE_and_vE_P_E_isoAng ( G4double rand_for_sE , G4double pE , std::vector < E_P_E_isoAng* >* vNEP_EPM )
{
std::map< G4double , G4int > map_energy;
map_energy.clear();
std::vector< G4double > v_energy;
v_energy.clear();
std::vector< E_P_E_isoAng* >::iterator itv;
G4int i = 0;
for ( itv = vNEP_EPM->begin(); itv != vNEP_EPM->end(); itv++ )
{
v_energy.push_back( (*itv)->energy );
map_energy.insert( std::pair < G4double , G4int > ( (*itv)->energy , i ) );
i++;
}
std::pair < G4double , G4double > energyLH = find_LH ( pE , &v_energy );
E_P_E_isoAng* pE_P_E_isoAng_EL = NULL;
E_P_E_isoAng* pE_P_E_isoAng_EH = NULL;
if ( energyLH.first != 0.0 && energyLH.second != 0.0 )
{
pE_P_E_isoAng_EL = (*vNEP_EPM)[ map_energy.find ( energyLH.first )->second ];
pE_P_E_isoAng_EH = (*vNEP_EPM)[ map_energy.find ( energyLH.second )->second ];
}
else if ( energyLH.first == 0.0 )
{
pE_P_E_isoAng_EL = (*vNEP_EPM)[ 0 ];
pE_P_E_isoAng_EH = (*vNEP_EPM)[ 1 ];
}
if ( energyLH.second == 0.0 )
{
pE_P_E_isoAng_EH = (*vNEP_EPM).back();
itv = vNEP_EPM->end();
itv--;
itv--;
pE_P_E_isoAng_EL = *itv;
}
G4double sE;
G4double sE_L;
G4double sE_H;
sE_L = get_secondary_energy_from_E_P_E_isoAng ( rand_for_sE , pE_P_E_isoAng_EL );
sE_H = get_secondary_energy_from_E_P_E_isoAng ( rand_for_sE , pE_P_E_isoAng_EH );
sE = get_linear_interpolated ( pE , std::pair < G4double , G4double > ( energyLH.first , sE_L ) , std::pair < G4double , G4double > ( energyLH.second , sE_H ) );
E_isoAng E_isoAng_L = create_E_isoAng_from_energy ( sE , &(pE_P_E_isoAng_EL->vE_isoAngle) );
E_isoAng E_isoAng_H = create_E_isoAng_from_energy ( sE , &(pE_P_E_isoAng_EH->vE_isoAngle) );
E_isoAng anE_isoAng;
if ( E_isoAng_L.n == E_isoAng_H.n )
{
anE_isoAng.n = E_isoAng_L.n;
for ( G4int i=0 ; i < anE_isoAng.n ; i++ )
{
G4double angle;
angle = get_linear_interpolated ( sE , std::pair< G4double , G4double > ( sE_L , E_isoAng_L.isoAngle[ i ] ) , std::pair< G4double , G4double > ( sE_H , E_isoAng_H.isoAngle[ i ] ) );
anE_isoAng.isoAngle.push_back( angle );
}
}
else
{
std::cout << "Do not Suuport yet." << std::endl;
}
return std::pair< G4double , E_isoAng >( sE , anE_isoAng);
}
@@ -0,0 +1,285 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Thermal Neutron Scattering
// Koi, Tatsumi (SCCS/SLAC)
//
// Class Description
// Cross Sections for a high precision (based on evaluated data
// libraries) description of themal neutron scattering below 4 eV;
// Based on Thermal neutron scattering files
// from the evaluated nuclear data files ENDF/B-VI, Release2
// To be used in your physics list in case you need this physics.
// In this case you want to register an object of this class with
// the corresponding process.
// Class Description - End
// 15-Nov-06 First implementation is done by T. Koi (SLAC/SCCS)
#include "G4NeutronHPThermalScatteringData.hh"
#include "G4Neutron.hh"
#include "G4ElementTable.hh"
//#include "G4NeutronHPData.hh"
G4NeutronHPThermalScatteringData::G4NeutronHPThermalScatteringData()
{
// Upper limit of neutron energy
emax = 4*eV;
indexOfThermalElement.clear();
names = new G4NeutronHPThermalScatteringNames();
BuildPhysicsTable( *G4Neutron::Neutron() );
}
G4NeutronHPThermalScatteringData::~G4NeutronHPThermalScatteringData()
{
delete names;
}
G4bool G4NeutronHPThermalScatteringData::IsApplicable( const G4DynamicParticle* aP , const G4Element* anEle )
{
G4bool result = false;
G4double eKin = aP->GetKineticEnergy();
// Check energy
if ( eKin < emax )
{
// Check Particle Species
if ( aP->GetDefinition() == G4Neutron::Neutron() )
{
// anEle is one of Thermal elements
G4int ie = (G4int) anEle->GetIndex();
std::vector < G4int >::iterator it;
for ( it = indexOfThermalElement.begin() ; it != indexOfThermalElement.end() ; it++ )
{
if ( ie == *it ) return true;
}
}
}
/*
if ( names->IsThisThermalElement ( anEle->GetName() ) )
{
// Check energy and projectile species
G4double eKin = aP->GetKineticEnergy();
if ( eKin < emax && aP->GetDefinition() == G4Neutron::Neutron() ) result = true;
}
*/
return result;
}
void G4NeutronHPThermalScatteringData::BuildPhysicsTable(const G4ParticleDefinition& aP)
{
if ( &aP != G4Neutron::Neutron() )
throw G4HadronicException(__FILE__, __LINE__, "Attempt to use NeutronHP data for particles other than neutrons!!!");
indexOfThermalElement.clear();
static const G4ElementTable* theElementTable = G4Element::GetElementTable();
size_t numberOfElements = G4Element::GetNumberOfElements();
size_t numberOfThermalElements = 0;
for ( size_t i = 0 ; i < numberOfElements ; i++ )
{
if ( names->IsThisThermalElement ( (*theElementTable)[i]->GetName() ) )
{
indexOfThermalElement.push_back( i );
numberOfThermalElements++;
}
}
// Read Cross Section Data files
G4String dirName;
if ( !getenv( "NeutronHPCrossSections" ) )
throw G4HadronicException(__FILE__, __LINE__, "Please setenv NeutronHPCrossSections to point to the neutron cross-section files.");
G4String baseName = getenv( "NeutronHPCrossSections" );
dirName = baseName + "/ThermalScattering";
G4String ndl_filename;
G4String name;
for ( size_t i = 0 ; i < numberOfThermalElements ; i++ )
{
ndl_filename = names->GetTS_NDL_Name( (*theElementTable)[ indexOfThermalElement[ i ] ]->GetName() );
// Coherent
name = dirName + "/Coherent/CrossSection/" + ndl_filename;
std::map< G4double , G4NeutronHPVector* >* coh_amapTemp_EnergyCross = readData( name );
coherent.insert ( std::pair < G4int , std::map< G4double , G4NeutronHPVector* >* > ( indexOfThermalElement[ i ] , coh_amapTemp_EnergyCross ) );
// Incoherent
name = dirName + "/Incoherent/CrossSection/" + ndl_filename;
std::map< G4double , G4NeutronHPVector* >* incoh_amapTemp_EnergyCross = readData( name );
incoherent.insert ( std::pair < G4int , std::map< G4double , G4NeutronHPVector* >* > ( indexOfThermalElement[ i ] , incoh_amapTemp_EnergyCross ) );
// Inelastic
name = dirName + "/Inelastic/CrossSection/" + ndl_filename;
std::map< G4double , G4NeutronHPVector* >* inela_amapTemp_EnergyCross = readData( name );
inelastic.insert ( std::pair < G4int , std::map< G4double , G4NeutronHPVector* >* > ( indexOfThermalElement[ i ] , inela_amapTemp_EnergyCross ) );
}
}
std::map< G4double , G4NeutronHPVector* >* G4NeutronHPThermalScatteringData::readData ( G4String name )
{
std::map< G4double , G4NeutronHPVector* >* aData = new std::map< G4double , G4NeutronHPVector* >;
std::ifstream theChannel( name.c_str() );
//G4cout << "G4NeutronHPThermalScatteringData " << name << G4endl;
G4int dummy;
while ( theChannel >> dummy ) // MF
{
theChannel >> dummy; // MT
G4double temp;
theChannel >> temp;
G4NeutronHPVector* anEnergyCross = new G4NeutronHPVector;
G4int nData;
theChannel >> nData;
anEnergyCross->Init ( theChannel , nData , eV , barn );
aData->insert ( std::pair < G4double , G4NeutronHPVector* > ( temp , anEnergyCross ) );
}
theChannel.close();
return aData;
}
void G4NeutronHPThermalScatteringData::DumpPhysicsTable( const G4ParticleDefinition& aP )
{
if( &aP != G4Neutron::Neutron() )
throw G4HadronicException(__FILE__, __LINE__, "Attempt to use NeutronHP data for particles other than neutrons!!!");
// G4cout << "G4NeutronHPThermalScatteringData::DumpPhysicsTable still to be implemented"<<G4endl;
}
//#include "G4Nucleus.hh"
//#include "G4NucleiPropertiesTable.hh"
//#include "G4Neutron.hh"
//#include "G4Electron.hh"
G4double G4NeutronHPThermalScatteringData::GetCrossSection( const G4DynamicParticle* aP , const G4Element*anE , G4double aT )
{
G4double result = 0;
G4int iele = anE->GetIndex();
G4double Xcoh = GetX ( aP , aT , coherent.find(iele)->second );
G4double Xincoh = GetX ( aP , aT , incoherent.find(iele)->second );
G4double Xinela = GetX ( aP , aT , inelastic.find(iele)->second );
result = Xcoh + Xincoh + Xinela;
//G4cout << "G4NeutronHPThermalScatteringData::GetCrossSection Tot= " << result/barn << " Coherent= " << Xcoh/barn << " Incoherent= " << Xincoh/barn << " Inelastic= " << Xinela/barn << G4endl;
return result;
}
G4double G4NeutronHPThermalScatteringData::GetInelasticCrossSection( const G4DynamicParticle* aP , const G4Element*anE , G4double aT )
{
G4double result = 0;
G4int iele = anE->GetIndex();
result = GetX ( aP , aT , inelastic.find(iele)->second );
return result;
}
G4double G4NeutronHPThermalScatteringData::GetCoherentCrossSection( const G4DynamicParticle* aP , const G4Element*anE , G4double aT )
{
G4double result = 0;
G4int iele = anE->GetIndex();
result = GetX ( aP , aT , coherent.find(iele)->second );
return result;
}
G4double G4NeutronHPThermalScatteringData::GetIncoherentCrossSection( const G4DynamicParticle* aP , const G4Element*anE , G4double aT )
{
G4double result = 0;
G4int iele = anE->GetIndex();
result = GetX ( aP , aT , incoherent.find(iele)->second );
return result;
}
G4double G4NeutronHPThermalScatteringData::GetX ( const G4DynamicParticle* aP, G4double aT , std::map < G4double , G4NeutronHPVector* >* amapTemp_EnergyCross )
{
G4double result = 0;
if ( amapTemp_EnergyCross->size() == 0 ) return result;
std::map< G4double , G4NeutronHPVector* >::iterator it;
for ( it = amapTemp_EnergyCross->begin() ; it != amapTemp_EnergyCross->end() ; it++ )
{
if ( aT < it->first ) break;
}
if ( it == amapTemp_EnergyCross->begin() ) it++; // lower than first
else if ( it == amapTemp_EnergyCross->end() ) it--; // upper than last
G4double eKinetic = aP->GetKineticEnergy();
G4double TH = it->first;
G4double XH = it->second->GetXsec ( eKinetic );
//G4cout << "G4NeutronHPThermalScatteringData::GetX TH " << TH << " E " << eKinetic << " XH " << XH << G4endl;
it--;
G4double TL = it->first;
G4double XL = it->second->GetXsec ( eKinetic );
//G4cout << "G4NeutronHPThermalScatteringData::GetX TL " << TL << " E " << eKinetic << " XL " << XL << G4endl;
if ( TH == TL )
throw G4HadronicException(__FILE__, __LINE__, "Thermal Scattering Data Error!");
G4double T = aT;
G4double X = ( XH - XL ) / ( TH - TL ) * ( T - TL ) + XL;
result = X;
return result;
}
@@ -0,0 +1,66 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Class Description
// Name list of Elements for a high precision (based on evaluated data
// libraries) description of themal neutron scattering below 4 eV;
// Based on Thermal neutron scattering files
// from the evaluated nuclear data files ENDF/B-VI, Release2
// To be used in your physics list in case you need this physics.
// In this case you want to register an object of this class with
// the corresponding process.
// Class Description - End
// 15-Nov-06 First implementation is done by T. Koi (SLAC/SCCS)
#include "G4NeutronHPThermalScatteringNames.hh"
#include "G4Neutron.hh"
#include "G4ElementTable.hh"
//#include "G4NeutronHPData.hh"
G4NeutronHPThermalScatteringNames::G4NeutronHPThermalScatteringNames()
{
names.insert ( std::pair < G4String , G4String > ( "TS_H_of_Water" , "h_water" ) );
names.insert ( std::pair < G4String , G4String > ( "TS_H_of_Polyethylene" , "h_polyethylene" ) );
names.insert ( std::pair < G4String , G4String > ( "TS_C_of_Graphite" , "graphite" ) );
}
G4NeutronHPThermalScatteringNames::~G4NeutronHPThermalScatteringNames()
{
;
}
G4bool G4NeutronHPThermalScatteringNames::IsThisThermalElement( G4String aname)
{
G4bool result = false;
if ( names.find ( aname ) != names.end() ) result = true;
return result;
}