G4StatMFMicroManager.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 //
00027 // $Id$
00028 //
00029 // Hadronic Process: Nuclear De-excitations
00030 // by V. Lara
00031 
00032 
00033 #include "G4StatMFMicroManager.hh"
00034 #include "G4HadronicException.hh"
00035 
00036 
00037 // Copy constructor
00038 G4StatMFMicroManager::G4StatMFMicroManager(const G4StatMFMicroManager & )
00039 {
00040     throw G4HadronicException(__FILE__, __LINE__, "G4StatMFMicroManager::copy_constructor meant to not be accessable");
00041 }
00042 
00043 // Operators
00044 
00045 G4StatMFMicroManager & G4StatMFMicroManager::
00046 operator=(const G4StatMFMicroManager & )
00047 {
00048     throw G4HadronicException(__FILE__, __LINE__, "G4StatMFMicroManager::operator= meant to not be accessable");
00049     return *this;
00050 }
00051 
00052 
00053 G4bool G4StatMFMicroManager::operator==(const G4StatMFMicroManager & ) const
00054 {
00055     return false;
00056 }
00057  
00058 
00059 G4bool G4StatMFMicroManager::operator!=(const G4StatMFMicroManager & ) const
00060 {
00061     return true;
00062 }
00063 
00064 
00065 
00066 // constructor
00067 G4StatMFMicroManager::G4StatMFMicroManager(const G4Fragment & theFragment, const G4int multiplicity,
00068                                            const G4double FreeIntE, const G4double SCompNuc) : 
00069     _Normalization(0.0)
00070 {
00071     // Perform class initialization
00072     Initialize(theFragment,multiplicity,FreeIntE,SCompNuc);
00073 }
00074 
00075 
00076 // destructor
00077 G4StatMFMicroManager::~G4StatMFMicroManager() 
00078 {
00079   if (!_Partition.empty()) 
00080     {
00081       std::for_each(_Partition.begin(),_Partition.end(),
00082                       DeleteFragment());
00083     }
00084 }
00085 
00086 
00087 
00088 // Initialization method
00089 
00090 void G4StatMFMicroManager::Initialize(const G4Fragment & theFragment, const G4int im, 
00091                                       const G4double FreeIntE, const G4double SCompNuc) 
00092 {
00093     G4int i;
00094 
00095     G4double U = theFragment.GetExcitationEnergy();
00096 
00097     G4double A = theFragment.GetA();
00098     G4double Z = theFragment.GetZ();
00099         
00100     // Statistical weights
00101     _WW = 0.0;
00102 
00103     // Mean breakup multiplicity
00104     _MeanMultiplicity = 0.0;
00105 
00106     // Mean channel temperature
00107     _MeanTemperature = 0.0;
00108 
00109     // Mean channel entropy
00110     _MeanEntropy = 0.0; 
00111         
00112     // Keep fragment atomic numbers
00113 //      G4int * FragmentAtomicNumbers = new G4int(static_cast<G4int>(A+0.5));
00114 //      G4int * FragmentAtomicNumbers = new G4int(m);
00115     G4int FragmentAtomicNumbers[4];
00116         
00117     // We distribute A nucleons between m fragments mantaining the order
00118     // FragmentAtomicNumbers[m-1]>FragmentAtomicNumbers[m-2]>...>FragmentAtomicNumbers[0]
00119     // Our initial distribution is 
00120     // FragmentAtomicNumbers[m-1]=A, FragmentAtomicNumbers[m-2]=0, ..., FragmentAtomicNumbers[0]=0
00121     FragmentAtomicNumbers[im-1] = static_cast<G4int>(A);
00122     for (i = 0; i <  (im - 1); i++) FragmentAtomicNumbers[i] = 0;
00123 
00124     // We try to distribute A nucleons in partitions of m fragments
00125     // MakePartition return true if it is possible 
00126     // and false if it is not   
00127     while (MakePartition(im,FragmentAtomicNumbers)) {
00128         // Allowed partitions are stored and its probability calculated
00129                         
00130         G4StatMFMicroPartition * aPartition = new G4StatMFMicroPartition(static_cast<G4int>(A),
00131                                                                          static_cast<G4int>(Z));
00132         G4double PartitionProbability = 0.0;
00133                         
00134         for (i = im-1; i >= 0; i--) aPartition->SetPartitionFragment(FragmentAtomicNumbers[i]);
00135         PartitionProbability = aPartition->CalcPartitionProbability(U,FreeIntE,SCompNuc);
00136         _Partition.push_back(aPartition);
00137                         
00138         _WW += PartitionProbability;
00139         _MeanMultiplicity += im*PartitionProbability;
00140         _MeanTemperature += aPartition->GetTemperature() * PartitionProbability;
00141         if (PartitionProbability > 0.0) 
00142             _MeanEntropy += PartitionProbability * aPartition->GetEntropy();
00143                         
00144     }
00145                 
00146         
00147     // garbage collection
00148 //      delete [] FragmentAtomicNumbers;
00149         
00150 }
00151 
00152 
00153 G4bool G4StatMFMicroManager::MakePartition(const G4int k, G4int * ANumbers)
00154     // Distributes A nucleons between k fragments
00155     // mantaining the order ANumbers[k-1] > ANumbers[k-2] > ... > ANumbers[0]
00156     // If it is possible returns true. In other case returns false
00157 {
00158     G4int l = 1;
00159     while (l < k) {
00160         G4int tmp = ANumbers[l-1] + ANumbers[k-1];
00161         ANumbers[l-1] += 1;
00162         ANumbers[k-1] -= 1;
00163         if (ANumbers[l-1] > ANumbers[l] || ANumbers[k-2] > ANumbers[k-1]) {
00164             ANumbers[l-1] = 1;
00165             ANumbers[k-1] = tmp - 1;
00166             l++;
00167         } else return true;
00168     }
00169     return false;
00170 }
00171 
00172 
00173 
00174 void G4StatMFMicroManager::Normalize(const G4double Norm)
00175 {
00176     _Normalization = Norm;
00177     _WW /= Norm;
00178     _MeanMultiplicity /= Norm;
00179     _MeanTemperature /= Norm;
00180     _MeanEntropy /= Norm; 
00181         
00182     return;
00183 }
00184 
00185 G4StatMFChannel * G4StatMFMicroManager::ChooseChannel(const G4double A0, const G4double Z0, 
00186                                                       const G4double MeanT)
00187 {
00188     G4double RandNumber = _Normalization * _WW * G4UniformRand();
00189     G4double AccumWeight = 0.0;
00190         
00191     for (std::vector<G4StatMFMicroPartition*>::iterator i = _Partition.begin();
00192          i != _Partition.end(); ++i)
00193     {
00194         AccumWeight += (*i)->GetProbability();
00195         if (RandNumber < AccumWeight)
00196             return (*i)->ChooseZ(A0,Z0,MeanT);
00197     }
00198 
00199     throw G4HadronicException(__FILE__, __LINE__, 
00200         "G4StatMFMicroCanonical::ChooseChannel: Couldn't find a channel.");
00201     return 0;
00202 }

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