G4NeutronHPFFFissionFS.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 #include "G4NeutronHPFFFissionFS.hh"
00031 #include "G4SystemOfUnits.hh"
00032 
00033 void G4NeutronHPFFFissionFS::Init (G4double A, G4double Z, G4int M, G4String & dirName, G4String & )
00034 {
00035    //G4cout << "G4NeutronHPFFFissionFS::Init" << G4endl;
00036    G4String aString = "FF";
00037 
00038    G4String tString = dirName;
00039    G4bool dbool;
00040    G4NeutronHPDataUsed aFile = theNames.GetName(static_cast<G4int>(A), static_cast<G4int>(Z), M, tString, aString , dbool);
00041    G4String filename = aFile.GetName();
00042    theBaseA = aFile.GetA();
00043    theBaseZ = aFile.GetZ();
00044 
00045 //3456
00046    if ( !dbool || ( Z < 2.5 && ( std::abs(theBaseZ-Z)>0.0001 || std::abs(theBaseA-A)>0.0001) ) )
00047    {
00048       hasAnyData = false;
00049       hasFSData = false; 
00050       hasXsec = false;
00051       return; // no data for exactly this isotope.
00052    }
00053    std::ifstream theData(filename, std::ios::in);
00054    G4double dummy;
00055    if ( !theData )
00056    {
00057       theData.close();
00058       hasFSData = false;
00059       hasXsec = false;
00060       hasAnyData = false;
00061       return; // no data for this FS for this isotope
00062    }
00063 
00064 
00065    hasFSData = true; 
00066       //          MT              Energy            FPS    Yield
00067       //std::map< int , std::map< double , std::map< int , double >* >* > FisionProductYieldData; 
00068    while ( theData.good() )
00069    {
00070       G4int iMT, iMF;
00071       G4int imax;
00072       //Reading the data
00073       //         MT       MF       AWR
00074       theData >> iMT >> iMF >> dummy;
00075       //         nBlock 
00076       theData >> imax;
00077       //if ( !theData.good() ) continue;
00078       //        Ei                   FPS     Yield
00079       std::map< G4double , std::map< G4int , G4double >* >* mEnergyFSPData = new std::map< G4double , std::map< G4int , G4double >* >;
00080 
00081       std::map< G4double , G4int >* mInterporation = new std::map< G4double , G4int >;
00082       for ( G4int i = 0 ; i <= imax ; i++ ) 
00083       {
00084        
00085          G4double YY=0.0; 
00086          G4double Ei;
00087          G4int jmax;
00088          G4int ip;
00089          //        energy of incidnece neutron 
00090          theData >> Ei;
00091          //        Number of data set followings 
00092          theData >> jmax;
00093          //         interpolation scheme
00094          theData >> ip;
00095          mInterporation->insert( std::pair<G4double,G4int>(Ei*eV,ip) );
00096          //         nNumber  nIP
00097          std::map<G4int,G4double>* mFSPYieldData = new std::map<G4int,G4double>;
00098          for ( G4int j = 0 ; j < jmax ; j++ ) 
00099          {
00100             G4int FSP;
00101             G4int mFSP;
00102             G4double Y;
00103             theData >> FSP >> mFSP >> Y;
00104             G4int k = FSP*100+mFSP;
00105             YY = YY + Y;
00106             //if ( iMT == 454 )G4cout << iMT << " " << i << " " << j << " " <<  k << " " << Y << " " << YY << G4endl;
00107             mFSPYieldData->insert( std::pair<G4int,G4double>( k , YY ) );
00108          }
00109          mEnergyFSPData->insert( std::pair<G4double,std::map<G4int,G4double>*>(Ei*eV,mFSPYieldData) ); 
00110       }
00111 
00112       FissionProductYieldData.insert( std::pair< G4int , std::map< G4double , std::map< G4int , G4double >* >* > (iMT,mEnergyFSPData));
00113       mMTInterpolation.insert( std::pair<G4int,std::map<G4double,G4int>*> (iMT,mInterporation) ); 
00114    } 
00115    theData.close();
00116 }
00117   
00118 G4DynamicParticleVector * G4NeutronHPFFFissionFS::ApplyYourself(G4int nNeutrons)
00119 {  
00120    G4DynamicParticleVector * aResult;
00121 //    G4cout <<"G4NeutronHPFFFissionFS::ApplyYourself +"<<G4endl;
00122    aResult = G4NeutronHPFissionBaseFS::ApplyYourself(nNeutrons);    
00123    return aResult;
00124 }
00125 
00126 void G4NeutronHPFFFissionFS::GetAFissionFragment( G4double energy , G4int& fragZ , G4int& fragA , G4int& fragM )
00127 {
00128    //G4cout << "G4NeutronHPFFFissionFS::GetAFissionFragment " << G4endl;
00129 
00130    G4double rand =G4UniformRand();
00131    //G4cout << rand << G4endl;
00132 
00133    std::map< G4double , std::map< G4int , G4double >* >* mEnergyFSPData = FissionProductYieldData.find( 454 )->second;
00134     
00135    //It is not clear that the treatment of the scheme 2 on two-dimensional interpolation. 
00136    //So, here just use the closest energy point array of yield data. 
00137    //TK120531
00138    G4double key_energy = DBL_MAX;
00139    if ( mEnergyFSPData->size() == 1 )
00140    {
00141       key_energy = mEnergyFSPData->begin()->first;
00142    }
00143    else
00144    {
00145       //Find closest energy point
00146       G4double Dmin=DBL_MAX; 
00147       G4int i = 0;
00148       for ( std::map< G4double , std::map< G4int , G4double >* >::iterator it = mEnergyFSPData->begin() ; 
00149       it != mEnergyFSPData->end() ; it++ )
00150       {
00151          G4double e = (it->first);
00152          G4double d = std::fabs ( energy - e ); 
00153          if ( d < Dmin ) 
00154          {
00155             Dmin = d;
00156             key_energy = e;
00157          }
00158          i++;
00159       }
00160    }
00161 
00162    std::map<G4int,G4double>* mFSPYieldData = (*mEnergyFSPData)[key_energy];
00163 
00164    G4int ifrag=0;
00165    G4double ceilling = mFSPYieldData->rbegin()->second; // Becaseu of numerical accuracy, this is not always 2 
00166    for ( std::map<G4int,G4double>::iterator it = mFSPYieldData->begin() ; it != mFSPYieldData->end() ; it++ )
00167    {
00168       //if ( ( rand - it->second/ceilling ) < 1.0e-6 ) std::cout << rand - it->second/ceilling << std::endl;
00169       if ( rand <= it->second/ceilling ) 
00170       {  
00171          //G4cout << it->first << " " << it->second/ceilling << G4endl;
00172          ifrag = it->first;
00173          break;
00174       }
00175    }
00176 
00177    fragZ = ifrag/100000;
00178    fragA = (ifrag%100000)/100;
00179    fragM = (ifrag%100);
00180 
00181    //G4cout << fragZ << " " << fragA << " " << fragM << G4endl;
00182 }

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