Import Geant4 1.0.0 source tree
This commit is contained in:
+85
@@ -0,0 +1,85 @@
|
||||
#include "G4NeutronElementIsoCrossSections.hh"
|
||||
|
||||
G4NeutronElementIsoCrossSections::
|
||||
G4NeutronElementIsoCrossSections()
|
||||
{
|
||||
nIsotopes = 0;
|
||||
theData = NULL;
|
||||
}
|
||||
|
||||
G4NeutronElementIsoCrossSections::
|
||||
~G4NeutronElementIsoCrossSections()
|
||||
{
|
||||
for(G4int i=0; i<nIsotopes; i++)
|
||||
{
|
||||
delete theData[i];
|
||||
}
|
||||
delete theData;
|
||||
}
|
||||
|
||||
void G4NeutronElementIsoCrossSections::
|
||||
Init(const G4Element * anElement)
|
||||
{
|
||||
G4int Z = anElement->GetZ();
|
||||
nIsotopes = anElement->GetNumberOfIsotopes();
|
||||
G4bool useIsotopesFromElement = true;
|
||||
if( nIsotopes == 0 )
|
||||
{
|
||||
nIsotopes += theStableOnes.GetNumberOfIsotopes(Z);
|
||||
useIsotopesFromElement = false;
|
||||
}
|
||||
theData = new G4NeutronIsoIsoCrossSections * [nIsotopes];
|
||||
if(useIsotopesFromElement)
|
||||
{
|
||||
for (G4int i=0; i<nIsotopes; i++)
|
||||
{
|
||||
G4int A = anElement->GetIsotope(i)->GetN();
|
||||
G4double frac = anElement->GetRelativeAbundanceVector()[i]/perCent;
|
||||
theData[i] = new G4NeutronIsoIsoCrossSections;
|
||||
theData[i]->Init(A, Z, frac);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
G4int first = theStableOnes.GetFirstIsotope(Z);
|
||||
for(G4int i=0; i<theStableOnes.GetNumberOfIsotopes(Z); i++)
|
||||
{
|
||||
G4int A = theStableOnes.GetIsotopeNucleonCount(first+i);
|
||||
G4double frac = theStableOnes.GetAbundance(first+i);
|
||||
theData[i] = new G4NeutronIsoIsoCrossSections;
|
||||
theData[i]->Init(A, Z, frac);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
G4double G4NeutronElementIsoCrossSections::
|
||||
GetCrossSection(G4double anEnergy)
|
||||
{
|
||||
G4double result = 0;
|
||||
for(G4int i=0; i<nIsotopes; i++)
|
||||
{
|
||||
result += theData[i]->GetCrossSection(anEnergy);
|
||||
}
|
||||
crossSectionBuffer = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
G4IsoResult * G4NeutronElementIsoCrossSections::
|
||||
GetProductIsotope(G4double anEnergy)
|
||||
{
|
||||
G4double running = 0;
|
||||
G4int index;
|
||||
G4double random = G4UniformRand();
|
||||
for(G4int i=0; i<nIsotopes; i++)
|
||||
{
|
||||
running += theData[i]->GetCrossSection(anEnergy);
|
||||
index = i;
|
||||
if(running/crossSectionBuffer > random) break;
|
||||
}
|
||||
G4String result = theData[index]->GetProductIsotope(anEnergy);
|
||||
G4Nucleus nucleus(theData[index]->GetA(), theData[index]->GetZ());
|
||||
G4IsoResult * theResult = new G4IsoResult(result, nucleus);
|
||||
return theResult;
|
||||
}
|
||||
|
||||
|
||||
+222
@@ -0,0 +1,222 @@
|
||||
#include "G4NeutronIsoIsoCrossSections.hh"
|
||||
#include "G4NeutronHPDataUsed.hh"
|
||||
#include "G4NeutronInelasticCrossSection.hh"
|
||||
|
||||
G4NeutronIsoIsoCrossSections::
|
||||
G4NeutronIsoIsoCrossSections()
|
||||
: theCrossSection(), theNames()
|
||||
{
|
||||
theProductionData = NULL;
|
||||
hasData = false;
|
||||
theNumberOfProducts = 0;
|
||||
theZ = 0;
|
||||
theA = 0;
|
||||
}
|
||||
|
||||
G4NeutronIsoIsoCrossSections::
|
||||
~G4NeutronIsoIsoCrossSections()
|
||||
{
|
||||
for(G4int i=0; i<theNumberOfProducts; i++)
|
||||
{
|
||||
delete theProductionData[i];
|
||||
}
|
||||
delete theProductionData;
|
||||
}
|
||||
|
||||
void G4NeutronIsoIsoCrossSections::
|
||||
Init(G4int A, G4int Z, G4double frac)
|
||||
{
|
||||
frac = frac/100.;
|
||||
// First transmution scattering cross-section
|
||||
// in our definition inelastic and fission.
|
||||
|
||||
theZ = Z;
|
||||
theA = A;
|
||||
theNames.SetMaxOffSet(5);
|
||||
G4NeutronHPDataUsed dataUsed;
|
||||
G4String rest = "/CrossSection/";
|
||||
G4String base = getenv("NeutronHPCrossSections");
|
||||
G4String base1 = base + "/Inelastic/";
|
||||
G4bool hasInelasticData = false;
|
||||
dataUsed = theNames.GetName(A, Z, base1, rest, hasInelasticData);
|
||||
G4String aName = dataUsed.GetName();
|
||||
G4NeutronHPVector inelasticData;
|
||||
G4double dummy;
|
||||
G4int total;
|
||||
if(hasInelasticData)
|
||||
{
|
||||
ifstream aDataSet(aName, ios::in);
|
||||
aDataSet >> dummy >> dummy >> total;
|
||||
inelasticData.Init(aDataSet, total, eV);
|
||||
}
|
||||
base1 = base + "/Capture/";
|
||||
G4bool hasCaptureData = false;
|
||||
dataUsed = theNames.GetName(A, Z, base1, rest, hasCaptureData);
|
||||
aName = dataUsed.GetName();
|
||||
G4NeutronHPVector captureData;
|
||||
if(hasCaptureData)
|
||||
{
|
||||
ifstream aDataSet(aName, ios::in);
|
||||
aDataSet >> dummy >> dummy >> total;
|
||||
captureData.Init(aDataSet, total, eV);
|
||||
}
|
||||
base1 = base + "/Elastic/";
|
||||
G4bool hasElasticData = false;
|
||||
dataUsed = theNames.GetName(A, Z, base1, rest, hasElasticData);
|
||||
aName = dataUsed.GetName();
|
||||
G4NeutronHPVector elasticData;
|
||||
if(hasElasticData)
|
||||
{
|
||||
ifstream aDataSet(aName, ios::in);
|
||||
aDataSet >> dummy >> dummy >> total;
|
||||
elasticData.Init(aDataSet, total, eV);
|
||||
}
|
||||
base1 = base + "/Fission/";
|
||||
G4bool hasFissionData = false;
|
||||
if(Z>=91)
|
||||
{
|
||||
dataUsed = theNames.GetName(A, Z, base1, rest, hasFissionData);
|
||||
aName = dataUsed.GetName();
|
||||
}
|
||||
G4NeutronHPVector fissionData;
|
||||
if(hasFissionData)
|
||||
{
|
||||
ifstream aDataSet(aName, ios::in);
|
||||
aDataSet >> dummy >> dummy >> total;
|
||||
fissionData.Init(aDataSet, total, eV);
|
||||
}
|
||||
hasData = hasFissionData||hasInelasticData||hasElasticData||hasCaptureData;
|
||||
G4NeutronHPVector merged, merged1;
|
||||
if(hasData)
|
||||
{
|
||||
if(hasFissionData&&hasInelasticData)
|
||||
{
|
||||
merged = fissionData + inelasticData;
|
||||
}
|
||||
else if(hasFissionData)
|
||||
{
|
||||
merged = fissionData;
|
||||
}
|
||||
else if(hasInelasticData)
|
||||
{
|
||||
merged = inelasticData;
|
||||
}
|
||||
|
||||
if(hasElasticData&&hasCaptureData)
|
||||
{
|
||||
merged1=elasticData + captureData;
|
||||
}
|
||||
else if(hasCaptureData)
|
||||
{
|
||||
merged1 = captureData;
|
||||
}
|
||||
else if(hasElasticData)
|
||||
{
|
||||
merged1 = elasticData;
|
||||
}
|
||||
|
||||
if((hasElasticData||hasCaptureData)&&(hasFissionData||hasInelasticData))
|
||||
{
|
||||
theCrossSection = merged + merged1;
|
||||
}
|
||||
else if(hasElasticData||hasCaptureData)
|
||||
{
|
||||
theCrossSection = merged1;
|
||||
}
|
||||
else if(hasFissionData||hasInelasticData)
|
||||
{
|
||||
theCrossSection = merged;
|
||||
}
|
||||
theCrossSection.Times(frac);
|
||||
}
|
||||
// theCrossSection.Dump();
|
||||
|
||||
// now isotope-production cross-sections
|
||||
theNames.SetMaxOffSet(1);
|
||||
rest = "/CrossSection/";
|
||||
base1 = base + "/IsotopeProduction/";
|
||||
G4bool hasIsotopeProductionData;
|
||||
dataUsed = theNames.GetName(A, Z, base1, rest, hasIsotopeProductionData);
|
||||
aName = dataUsed.GetName();
|
||||
if(hasIsotopeProductionData)
|
||||
{
|
||||
ifstream aDataSet(aName, ios::in);
|
||||
aDataSet>>theNumberOfProducts;
|
||||
theProductionData = new G4NeutronIsoProdCrossSections * [theNumberOfProducts];
|
||||
for(G4int i=0; i<theNumberOfProducts; i++)
|
||||
{
|
||||
G4String aName;
|
||||
aDataSet >> aName;
|
||||
aDataSet >> dummy >> dummy;
|
||||
theProductionData[i] = new G4NeutronIsoProdCrossSections(aName);
|
||||
theProductionData[i]->Init(aDataSet);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hasData = false;
|
||||
}
|
||||
G4NeutronInelasticCrossSection theParametrization;
|
||||
G4double lastEnergy = theCrossSection.GetX(theCrossSection.GetVectorLength()-1);
|
||||
G4double lastValue = theCrossSection.GetY(theCrossSection.GetVectorLength()-1);
|
||||
G4double norm = theParametrization.GetCrossSection(lastEnergy, A, Z);
|
||||
G4double increment = 1*MeV;
|
||||
while(lastEnergy+increment<101*MeV)
|
||||
{
|
||||
G4double currentEnergy = lastEnergy+increment;
|
||||
G4double value = theParametrization.GetCrossSection(currentEnergy, A, Z)*(lastValue/norm);
|
||||
G4int position = theCrossSection.GetVectorLength();
|
||||
theCrossSection.SetData(position, currentEnergy, value);
|
||||
increment+=1*MeV;
|
||||
}
|
||||
}
|
||||
|
||||
G4double G4NeutronIsoIsoCrossSections::
|
||||
GetCrossSection(G4double anEnergy)
|
||||
{
|
||||
G4double result;
|
||||
result = theCrossSection.GetY(anEnergy);
|
||||
return result;
|
||||
}
|
||||
|
||||
G4String G4NeutronIsoIsoCrossSections::
|
||||
GetProductIsotope(G4double anEnergy)
|
||||
{
|
||||
G4String result = "UNCHANGED";
|
||||
|
||||
G4double totalXSec = theCrossSection.GetY(anEnergy);
|
||||
if(totalXSec==0) return result;
|
||||
|
||||
// now do the isotope changing reactions
|
||||
G4double * xSec = new G4double[theNumberOfProducts];
|
||||
G4double sum = 0;
|
||||
{
|
||||
for(G4int i=0; i<theNumberOfProducts; i++)
|
||||
{
|
||||
xSec[i] = theProductionData[i]->GetProductionCrossSection(anEnergy);
|
||||
sum += xSec[i];
|
||||
}
|
||||
}
|
||||
G4double isoChangeXsec = sum;
|
||||
G4double rand = G4UniformRand();
|
||||
if(rand > isoChangeXsec/totalXSec)
|
||||
{
|
||||
delete [] xSec;
|
||||
return result;
|
||||
}
|
||||
G4double random = G4UniformRand();
|
||||
G4double running = 0;
|
||||
G4int index;
|
||||
{
|
||||
for(G4int i=0; i<theNumberOfProducts; i++)
|
||||
{
|
||||
running += xSec[i];
|
||||
index = i;
|
||||
if(random<=running/sum) break;
|
||||
}
|
||||
}
|
||||
delete [] xSec;
|
||||
result = theProductionData[index]->GetProductIsotope();
|
||||
|
||||
return result;
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
#include "G4NeutronIsoProdCrossSections.hh"
|
||||
|
||||
void G4NeutronIsoProdCrossSections::
|
||||
Init(ifstream & aDataSet)
|
||||
{
|
||||
G4int aNumberOfPoints;
|
||||
aDataSet>>aNumberOfPoints;
|
||||
theProductionCrossSections.Init(aDataSet, aNumberOfPoints, eV);
|
||||
}
|
||||
|
||||
G4double G4NeutronIsoProdCrossSections::
|
||||
GetProductionCrossSection(G4double anEnergy)
|
||||
{
|
||||
G4double result;
|
||||
result = theProductionCrossSections.GetY(anEnergy);
|
||||
return result;
|
||||
}
|
||||
|
||||
G4String G4NeutronIsoProdCrossSections::
|
||||
GetProductIsotope()
|
||||
{
|
||||
return theProductName;
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
#include "G4NeutronIsotopeProduction.hh"
|
||||
|
||||
G4NeutronIsotopeProduction::
|
||||
G4NeutronIsotopeProduction()
|
||||
{
|
||||
numberOfElements = G4Element::GetNumberOfElements();
|
||||
theData = new G4NeutronElementIsoCrossSections * [numberOfElements];
|
||||
for(G4int i=0; i< numberOfElements; i++)
|
||||
{
|
||||
theData[i] = new G4NeutronElementIsoCrossSections;
|
||||
if((*(G4Element::GetElementTable()))(i)->GetZ()>12 &&
|
||||
(*(G4Element::GetElementTable()))(i)->GetZ()<84) // @@@@@@ workaround to ne fixed in G4NeutronHPNames.
|
||||
{
|
||||
theData[i]->Init((*(G4Element::GetElementTable()))(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
G4NeutronIsotopeProduction::
|
||||
~G4NeutronIsotopeProduction()
|
||||
{
|
||||
for(G4int i=0; i<numberOfElements; i++)
|
||||
{
|
||||
delete theData[i];
|
||||
}
|
||||
if(theData!=NULL) delete [] theData;
|
||||
}
|
||||
|
||||
|
||||
G4IsoResult * G4NeutronIsotopeProduction::
|
||||
GetIsotope(const G4Track& aTrack,
|
||||
const G4Nucleus & aNucleus)
|
||||
{
|
||||
// is applicable?
|
||||
if(aTrack.GetDynamicParticle()->GetDefinition() != G4Neutron::Neutron()) return NULL;
|
||||
if(aTrack.GetKineticEnergy()>100*MeV) return NULL;
|
||||
|
||||
// get the isotope
|
||||
G4Material * theMaterial = aTrack.GetMaterial();
|
||||
if(theMaterial->GetZ()<13) return NULL; //@@@@@@ workaround to ne fixed in G4NeutronHPNames.
|
||||
if(theMaterial->GetZ()>83) return NULL; //@@@@@@ workaround to ne fixed in G4NeutronHPNames.
|
||||
G4int nEleInMat = theMaterial->GetNumberOfElements();
|
||||
G4int index;
|
||||
G4double * xSec = new G4double[nEleInMat];
|
||||
G4double sum = 0;
|
||||
{
|
||||
for(G4int i=0; i<nEleInMat; i++)
|
||||
{
|
||||
index = theMaterial->GetElement(i)->GetIndex();
|
||||
xSec[i] = theData[index]->GetCrossSection(aTrack.GetKineticEnergy());
|
||||
sum += xSec[i];
|
||||
}
|
||||
}
|
||||
G4double random = G4UniformRand();
|
||||
G4double running = 0;
|
||||
{
|
||||
for(G4int i=0; i<nEleInMat; i++)
|
||||
{
|
||||
running += xSec[i];
|
||||
index = theMaterial->GetElement(i)->GetIndex();
|
||||
if(random<=running/sum) break;
|
||||
}
|
||||
}
|
||||
delete [] xSec;
|
||||
G4IsoResult * result = theData[index]->GetProductIsotope(aTrack.GetKineticEnergy());
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user