G4NeutronHPElementData.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 // neutron_hp -- source file
00027 // J.P. Wellisch, Nov-1996
00028 // A prototype of the low energy neutron transport model.
00029 //
00030 // 02-08-06 Modified Harmonise to reslove cross section trouble at high-end. T. KOI
00031 //
00032 #include "G4NeutronHPElementData.hh"
00033 #include "G4SystemOfUnits.hh"
00034 
00035   G4NeutronHPElementData::G4NeutronHPElementData()
00036   {
00037      precision = 0.02;
00038      theFissionData = new G4NeutronHPVector;
00039      theCaptureData = new G4NeutronHPVector;
00040      theElasticData = new G4NeutronHPVector;
00041      theInelasticData = new G4NeutronHPVector;
00042     theIsotopeWiseData = 0;
00043   }
00044   
00045   G4NeutronHPElementData::~G4NeutronHPElementData()
00046   {
00047     delete theFissionData;
00048     delete theCaptureData;
00049     delete theElasticData;
00050     delete theInelasticData;
00051     delete [] theIsotopeWiseData;
00052   }
00053   
00054   void G4NeutronHPElementData::Init(G4Element * theElement)  
00055   {
00056     G4int count = theElement->GetNumberOfIsotopes();
00057       if(count == 0) count +=
00058          theStableOnes.GetNumberOfIsotopes(static_cast<G4int>(theElement->GetZ()));
00059     theIsotopeWiseData = new G4NeutronHPIsoData[count];
00060     // filename = ein data-set je isotope.
00061     count = 0;
00062     G4int nIso = theElement->GetNumberOfIsotopes();
00063     G4int Z = static_cast<G4int> (theElement->GetZ());
00064     //G4int i1;
00065     if(nIso!=0)
00066     {
00067       for (G4int i1=0; i1<nIso; i1++)
00068       {
00069 //        G4cout <<" Init: normal case"<<G4endl;
00070         G4int A = theElement->GetIsotope(i1)->GetN();
00071         G4int M = theElement->GetIsotope(i1)->Getm();
00072         G4double frac = theElement->GetRelativeAbundanceVector()[i1]/perCent;
00073         //UpdateData(A, Z, count++, frac);
00074         UpdateData(A, Z, M, count++, frac);
00075       }
00076     }else{
00077 //      G4cout <<" Init: theStableOnes case: Z="<<Z<<G4endl;
00078       G4int first = theStableOnes.GetFirstIsotope(Z);
00079 //      G4cout <<"first="<<first<<" "<<theStableOnes.GetNumberOfIsotopes(theElement->GetZ())<<G4endl;
00080       for(G4int i1=0; 
00081         i1<theStableOnes.GetNumberOfIsotopes(static_cast<G4int>(theElement->GetZ()) );
00082         i1++)
00083       {
00084 //        G4cout <<" Init: theStableOnes in the loop"<<G4endl;
00085         G4int A = theStableOnes.GetIsotopeNucleonCount(first+i1);
00086         G4double frac = theStableOnes.GetAbundance(first+i1);
00087 //        G4cout <<" Init: theStableOnes in the loop: "<<A<<G4endl;
00088         UpdateData(A, Z, count++, frac);
00089       }
00090     }
00091     theElasticData->ThinOut(precision);
00092     theInelasticData->ThinOut(precision);
00093     theCaptureData->ThinOut(precision);
00094     theFissionData->ThinOut(precision);
00095   }
00096   
00097   //void G4NeutronHPElementData::UpdateData(G4int A, G4int Z, G4int index, G4double abundance)
00098   void G4NeutronHPElementData::UpdateData(G4int A, G4int Z, G4int M, G4int index, G4double abundance)
00099   {
00100     //Reads in the Data, using G4NeutronHPIsoData[], and its Init
00101 //    G4cout << "entered: ElementWiseData::UpdateData"<<G4endl;
00102     //theIsotopeWiseData[index].Init(A, Z, abundance);
00103     theIsotopeWiseData[index].Init(A, Z, M, abundance);
00104 //    G4cout << "ElementWiseData::UpdateData Init finished"<<G4endl;
00105 
00106     theBuffer = theIsotopeWiseData[index].MakeElasticData();
00107 //    G4cout << "ElementWiseData::UpdateData MakeElasticData finished: "
00108 //         <<theBuffer->GetVectorLength()<<G4endl;
00109     Harmonise(theElasticData, theBuffer);
00110 //    G4cout << "ElementWiseData::UpdateData Harmonise finished: "
00111 //         <<theElasticData->GetVectorLength()<<G4endl;
00112     delete theBuffer;
00113     
00114     theBuffer = theIsotopeWiseData[index].MakeInelasticData();
00115 //    G4cout << "ElementWiseData::UpdateData MakeInelasticData finished: "
00116 //         <<theBuffer->GetVectorLength()<<G4endl;
00117     Harmonise(theInelasticData, theBuffer);
00118 //    G4cout << "ElementWiseData::UpdateData Harmonise finished: "
00119 //         <<theInelasticData->GetVectorLength()<<G4endl;
00120     delete theBuffer;
00121     
00122     theBuffer = theIsotopeWiseData[index].MakeCaptureData();
00123 //    G4cout << "ElementWiseData::UpdateData MakeCaptureData finished: "
00124 //         <<theBuffer->GetVectorLength()<<G4endl;
00125     Harmonise(theCaptureData, theBuffer);
00126 //    G4cout << "ElementWiseData::UpdateData Harmonise finished: "
00127 //         <<theCaptureData->GetVectorLength()<<G4endl;
00128     delete theBuffer;
00129     
00130     theBuffer = theIsotopeWiseData[index].MakeFissionData();
00131 //    G4cout << "ElementWiseData::UpdateData MakeFissionData finished: "
00132 //         <<theBuffer->GetVectorLength()<<G4endl;
00133     Harmonise(theFissionData, theBuffer);
00134 //    G4cout << "ElementWiseData::UpdateData Harmonise finished: "
00135 //         <<theFissionData->GetVectorLength()<<G4endl;
00136     delete theBuffer;
00137     
00138 //    G4cout << "ElementWiseData::UpdateData finished"<endl;
00139   }
00140   
00141   void G4NeutronHPElementData::Harmonise(G4NeutronHPVector *& theStore, G4NeutronHPVector * theNew)
00142   {
00143     if(theNew == 0) { return; }
00144     G4int s_tmp = 0, n=0, m_tmp=0;
00145     G4NeutronHPVector * theMerge = new G4NeutronHPVector(theStore->GetVectorLength());
00146 //    G4cout << "Harmonise 1: "<<theStore->GetEnergy(s)<<" "<<theNew->GetEnergy(0)<<G4endl;
00147     while ( theStore->GetEnergy(s_tmp)<theNew->GetEnergy(0)&&s_tmp<theStore->GetVectorLength() )
00148     {
00149       theMerge->SetData(m_tmp++, theStore->GetEnergy(s_tmp), theStore->GetXsec(s_tmp));
00150       s_tmp++;
00151     }
00152     G4NeutronHPVector *active = theStore;
00153     G4NeutronHPVector * passive = theNew;
00154     G4NeutronHPVector * tmp;
00155     G4int a = s_tmp, p = n, t;
00156 //    G4cout << "Harmonise 2: "<<active->GetVectorLength()<<" "<<passive->GetVectorLength()<<G4endl;
00157     while (a<active->GetVectorLength()&&p<passive->GetVectorLength())
00158     {
00159       if(active->GetEnergy(a) <= passive->GetEnergy(p))
00160       {
00161         theMerge->SetData(m_tmp, active->GetEnergy(a), active->GetXsec(a));
00162         G4double x  = theMerge->GetEnergy(m_tmp);
00163         G4double y = std::max(0., passive->GetXsec(x)); 
00164         theMerge->SetData(m_tmp, x, theMerge->GetXsec(m_tmp)+y);
00165         m_tmp++;
00166         a++;
00167       } else {
00168 //        G4cout << "swapping in Harmonise"<<G4endl;
00169         tmp = active; t=a;
00170         active = passive; a=p;
00171         passive = tmp; p=t;
00172       }
00173     }
00174 //    G4cout << "Harmonise 3: "<< a <<" "<<active->GetVectorLength()<<" "<<m<<G4endl;
00175     while (a!=active->GetVectorLength())
00176     {
00177       theMerge->SetData(m_tmp++, active->GetEnergy(a), active->GetXsec(a));
00178       a++;
00179     }
00180 //    G4cout << "Harmonise 4: "<< p <<" "<<passive->GetVectorLength()<<" "<<m<<G4endl;
00181     while (p!=passive->GetVectorLength())
00182     {
00183       // Modified by T. KOI
00184       //theMerge->SetData(m++, passive->GetEnergy(p), passive->GetXsec(p));
00185       G4double x = passive->GetEnergy(p);
00186       G4double y = std::max(0., active->GetXsec(x));
00187       theMerge->SetData(m_tmp++, x, passive->GetXsec(p)+y);
00188       p++;
00189     }
00190 //    G4cout <<"Harmonise 5: "<< theMerge->GetVectorLength() << " " << m << G4endl;
00191     delete theStore;
00192     theStore = theMerge;
00193 //    G4cout <<"Harmonise 6: "<< theStore->GetVectorLength() << " " << m << G4endl;
00194   }
00195 
00196   G4NeutronHPVector * G4NeutronHPElementData::MakePhysicsVector(G4Element * theElement,
00197                                       G4ParticleDefinition * theP,
00198                                       G4NeutronHPFissionData* theSet)
00199   {
00200    if(theP != G4Neutron::Neutron()) throw G4HadronicException(__FILE__, __LINE__, "not a neutron");
00201    Init ( theElement );
00202    return GetData(theSet);
00203   }
00204   G4NeutronHPVector * G4NeutronHPElementData::MakePhysicsVector(G4Element * theElement,
00205                                       G4ParticleDefinition * theP,
00206                                       G4NeutronHPCaptureData * theSet)
00207   {
00208    if(theP != G4Neutron::Neutron()) throw G4HadronicException(__FILE__, __LINE__, "not a neutron");
00209    Init ( theElement );
00210    return GetData(theSet);
00211   }
00212   G4NeutronHPVector * G4NeutronHPElementData::MakePhysicsVector(G4Element * theElement,
00213                                       G4ParticleDefinition * theP,
00214                                       G4NeutronHPElasticData * theSet)
00215   {
00216    if(theP != G4Neutron::Neutron()) throw G4HadronicException(__FILE__, __LINE__, "not a neutron");
00217    Init ( theElement );
00218    return GetData(theSet);
00219   }
00220     G4NeutronHPVector * G4NeutronHPElementData::MakePhysicsVector(G4Element * theElement,
00221                                       G4ParticleDefinition * theP,
00222                                       G4NeutronHPInelasticData * theSet)
00223   {
00224    if(theP != G4Neutron::Neutron()) throw G4HadronicException(__FILE__, __LINE__, "not a neutron");
00225    Init ( theElement );
00226    return GetData(theSet);
00227   }

Generated on Mon May 27 17:49:00 2013 for Geant4 by  doxygen 1.4.7