Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // 26 // >> 27 // $Id: G4StatMFMacroCanonical.cc,v 1.8 2008/11/19 14:33:31 vnivanch Exp $ >> 28 // GEANT4 tag $Name: geant4-09-02-patch-03 $ 27 // 29 // 28 // by V. Lara 30 // by V. Lara 29 // ------------------------------------------- 31 // -------------------------------------------------------------------- 30 // 32 // 31 // Modified: 33 // Modified: 32 // 25.07.08 I.Pshenichnov (in collaboration wi 34 // 25.07.08 I.Pshenichnov (in collaboration with Alexander Botvina and Igor 33 // Mishustin (FIAS, Frankfurt, INR, M 35 // Mishustin (FIAS, Frankfurt, INR, Moscow and Kurchatov Institute, 34 // Moscow, pshenich@fias.uni-frankfur 36 // Moscow, pshenich@fias.uni-frankfurt.de) fixed infinite loop for 35 // a fagment with Z=A; fixed memory l 37 // a fagment with Z=A; fixed memory leak 36 38 37 #include "G4StatMFMacroCanonical.hh" 39 #include "G4StatMFMacroCanonical.hh" 38 #include "G4PhysicalConstants.hh" << 40 39 #include "G4SystemOfUnits.hh" << 40 #include "G4Pow.hh" << 41 41 42 // constructor 42 // constructor 43 G4StatMFMacroCanonical::G4StatMFMacroCanonical 43 G4StatMFMacroCanonical::G4StatMFMacroCanonical(const G4Fragment & theFragment) 44 { 44 { 45 45 46 // Get memory for clusters 46 // Get memory for clusters 47 _theClusters.push_back(new G4StatMFMacroNucl 47 _theClusters.push_back(new G4StatMFMacroNucleon); // Size 1 48 _theClusters.push_back(new G4StatMFMacroBiNu 48 _theClusters.push_back(new G4StatMFMacroBiNucleon); // Size 2 49 _theClusters.push_back(new G4StatMFMacroTriN 49 _theClusters.push_back(new G4StatMFMacroTriNucleon); // Size 3 50 _theClusters.push_back(new G4StatMFMacroTetr 50 _theClusters.push_back(new G4StatMFMacroTetraNucleon); // Size 4 51 for (G4int i = 4; i < theFragment.GetA_asInt << 51 for (G4int i = 4; i < theFragment.GetA(); i++) 52 _theClusters.push_back(new G4StatMFMacroMu 52 _theClusters.push_back(new G4StatMFMacroMultiNucleon(i+1)); // Size 5 ... A 53 53 54 // Perform class initialization 54 // Perform class initialization 55 Initialize(theFragment); 55 Initialize(theFragment); 56 56 57 } 57 } 58 58 >> 59 59 // destructor 60 // destructor 60 G4StatMFMacroCanonical::~G4StatMFMacroCanonica 61 G4StatMFMacroCanonical::~G4StatMFMacroCanonical() 61 { 62 { 62 // garbage collection 63 // garbage collection 63 if (!_theClusters.empty()) 64 if (!_theClusters.empty()) 64 { 65 { 65 std::for_each(_theClusters.begin(),_theC 66 std::for_each(_theClusters.begin(),_theClusters.end(),DeleteFragment()); 66 } 67 } 67 } 68 } 68 69 >> 70 // operators definitions >> 71 G4StatMFMacroCanonical & >> 72 G4StatMFMacroCanonical::operator=(const G4StatMFMacroCanonical & ) >> 73 { >> 74 throw G4HadronicException(__FILE__, __LINE__, "G4StatMFMacroCanonical::operator= meant to not be accessable"); >> 75 return *this; >> 76 } >> 77 >> 78 G4bool G4StatMFMacroCanonical::operator==(const G4StatMFMacroCanonical & ) const >> 79 { >> 80 return false; >> 81 } >> 82 >> 83 >> 84 G4bool G4StatMFMacroCanonical::operator!=(const G4StatMFMacroCanonical & ) const >> 85 { >> 86 return true; >> 87 } >> 88 >> 89 69 // Initialization method 90 // Initialization method >> 91 >> 92 70 void G4StatMFMacroCanonical::Initialize(const 93 void G4StatMFMacroCanonical::Initialize(const G4Fragment & theFragment) 71 { 94 { 72 95 73 G4int A = theFragment.GetA_asInt(); << 96 G4double A = theFragment.GetA(); 74 G4int Z = theFragment.GetZ_asInt(); << 97 G4double Z = theFragment.GetZ(); 75 G4double x = 1.0 - 2.0*Z/G4double(A); << 76 G4Pow* g4calc = G4Pow::GetInstance(); << 77 98 78 // Free Internal energy at T = 0 99 // Free Internal energy at T = 0 79 __FreeInternalE0 = A*( -G4StatMFParameters:: << 100 __FreeInternalE0 = A*( -G4StatMFParameters::GetE0() + // Volume term (for T = 0) 80 G4StatMFParameters::GetGamma0()*x*x) // << 101 G4StatMFParameters::GetGamma0()* // Symmetry term 81 + G4StatMFParameters::GetBeta0()*g4calc->Z << 102 (1.0-2.0*Z/A)*(1.0-2.0*Z/A) ) + 82 0.6*elm_coupling*Z*Z/(G4StatMFParameters:: << 103 G4StatMFParameters::GetBeta0()*std::pow(A,2.0/3.0) + // Surface term (for T = 0) 83 g4calc->Z13(A)); << 104 (3.0/5.0)*elm_coupling*Z*Z/(G4StatMFParameters::Getr0()* // Coulomb term >> 105 std::pow(A,1.0/3.0)); >> 106 >> 107 84 108 85 CalculateTemperature(theFragment); 109 CalculateTemperature(theFragment); >> 110 86 return; 111 return; 87 } 112 } 88 113 >> 114 >> 115 >> 116 >> 117 89 void G4StatMFMacroCanonical::CalculateTemperat 118 void G4StatMFMacroCanonical::CalculateTemperature(const G4Fragment & theFragment) 90 { 119 { 91 // Excitation Energy 120 // Excitation Energy 92 G4double U = theFragment.GetExcitationEnergy 121 G4double U = theFragment.GetExcitationEnergy(); 93 122 94 G4int A = theFragment.GetA_asInt(); << 123 G4double A = theFragment.GetA(); 95 G4int Z = theFragment.GetZ_asInt(); << 124 G4double Z = theFragment.GetZ(); 96 125 97 // Fragment Multiplicity 126 // Fragment Multiplicity 98 G4double FragMult = std::max((1.0+(2.31/MeV) 127 G4double FragMult = std::max((1.0+(2.31/MeV)*(U/A - 3.5*MeV))*A/100.0, 2.0); 99 128 >> 129 100 // Parameter Kappa 130 // Parameter Kappa 101 G4Pow* g4calc = G4Pow::GetInstance(); << 131 _Kappa = (1.0+elm_coupling*(std::pow(FragMult,1./3.)-1)/ 102 _Kappa = (1.0+elm_coupling*(g4calc->A13(Frag << 132 (G4StatMFParameters::Getr0()*std::pow(A,1./3.))); 103 (G4StatMFParameters::Getr0()*g4calc->Z13 << 104 _Kappa = _Kappa*_Kappa*_Kappa - 1.0; 133 _Kappa = _Kappa*_Kappa*_Kappa - 1.0; >> 134 105 135 106 G4StatMFMacroTemperature * theTemp = new 136 G4StatMFMacroTemperature * theTemp = new 107 G4StatMFMacroTemperature(A,Z,U,__FreeInter 137 G4StatMFMacroTemperature(A,Z,U,__FreeInternalE0,_Kappa,&_theClusters); 108 138 109 __MeanTemperature = theTemp->CalcTemperature 139 __MeanTemperature = theTemp->CalcTemperature(); 110 _ChemPotentialNu = theTemp->GetChemicalPoten 140 _ChemPotentialNu = theTemp->GetChemicalPotentialNu(); 111 _ChemPotentialMu = theTemp->GetChemicalPoten 141 _ChemPotentialMu = theTemp->GetChemicalPotentialMu(); 112 __MeanMultiplicity = theTemp->GetMeanMultipl 142 __MeanMultiplicity = theTemp->GetMeanMultiplicity(); 113 __MeanEntropy = theTemp->GetEntropy(); 143 __MeanEntropy = theTemp->GetEntropy(); 114 144 115 delete theTemp; 145 delete theTemp; 116 146 117 return; 147 return; 118 } 148 } 119 149 >> 150 120 // ------------------------------------------- 151 // -------------------------------------------------------------------------- 121 152 122 G4StatMFChannel * G4StatMFMacroCanonical::Choo 153 G4StatMFChannel * G4StatMFMacroCanonical::ChooseAandZ(const G4Fragment &theFragment) 123 // Calculate total fragments multiplicity, fra << 154 // Calculate total fragments multiplicity, fragment atomic numbers and charges 124 { 155 { 125 G4int A = theFragment.GetA_asInt(); << 156 G4double A = theFragment.GetA(); 126 G4int Z = theFragment.GetZ_asInt(); << 157 G4double Z = theFragment.GetZ(); 127 158 128 std::vector<G4int> ANumbers(A); << 159 std::vector<G4double> ANumbers(static_cast<G4int>(A)); 129 160 130 G4double Multiplicity = ChooseA(A,ANumbers); 161 G4double Multiplicity = ChooseA(A,ANumbers); 131 162 132 std::vector<G4int> FragmentsA; << 133 163 134 G4int i = 0; << 164 std::vector<G4double> FragmentsA; 135 for (i = 0; i < A; i++) << 136 { << 137 for (G4int j = 0; j < ANumbers[i]; j++) << 138 } << 139 165 140 // Sort fragments in decreasing order << 166 G4int i = 0; 141 G4int im = 0; << 167 for (i = 0; i < A; i++) 142 for (G4int j = 0; j < Multiplicity; j++) << 168 { 143 { << 169 for (G4int j = 0; j < ANumbers[i]; j++) FragmentsA.push_back(i+1); 144 G4int FragmentsAMax = 0; << 170 } 145 im = j; << 171 146 for (i = j; i < Multiplicity; i++) << 172 147 { << 173 // Sort fragments in decreasing order 148 if (FragmentsA[i] <= FragmentsAMax) { cont << 174 G4int im = 0; 149 else << 175 for (G4int j = 0; j < Multiplicity; j++) 150 { << 176 { 151 im = i; << 177 G4double FragmentsAMax = 0.0; 152 FragmentsAMax = FragmentsA[im]; << 178 im = j; 153 } << 179 for (i = j; i < Multiplicity; i++) 154 } << 180 { 155 if (im != j) << 181 if (FragmentsA[i] <= FragmentsAMax) continue; 156 { << 182 else 157 FragmentsA[im] = FragmentsA[j]; << 183 { 158 FragmentsA[j] = FragmentsAMax; << 184 im = i; 159 } << 185 FragmentsAMax = FragmentsA[im]; 160 } << 186 } 161 return ChooseZ(Z,FragmentsA); << 187 } >> 188 >> 189 if (im != j) >> 190 { >> 191 FragmentsA[im] = FragmentsA[j]; >> 192 FragmentsA[j] = FragmentsAMax; >> 193 } >> 194 } >> 195 >> 196 return ChooseZ(static_cast<G4int>(Z),FragmentsA); 162 } 197 } 163 198 164 G4double G4StatMFMacroCanonical::ChooseA(G4int << 199 >> 200 >> 201 G4double G4StatMFMacroCanonical::ChooseA(const G4double A, std::vector<G4double> & ANumbers) 165 // Determines fragments multiplicities and c 202 // Determines fragments multiplicities and compute total fragment multiplicity 166 { 203 { 167 G4double multiplicity = 0.0; 204 G4double multiplicity = 0.0; 168 G4int i; 205 G4int i; 169 << 206 >> 207 170 std::vector<G4double> AcumMultiplicity; 208 std::vector<G4double> AcumMultiplicity; 171 AcumMultiplicity.reserve(A); << 209 AcumMultiplicity.reserve(static_cast<G4int>(A)); 172 210 173 AcumMultiplicity.push_back((*(_theClusters.b 211 AcumMultiplicity.push_back((*(_theClusters.begin()))->GetMeanMultiplicity()); 174 for (std::vector<G4VStatMFMacroCluster*>::it 212 for (std::vector<G4VStatMFMacroCluster*>::iterator it = _theClusters.begin()+1; 175 it != _theClusters.end(); ++it) 213 it != _theClusters.end(); ++it) 176 { 214 { 177 AcumMultiplicity.push_back((*it)->GetMea 215 AcumMultiplicity.push_back((*it)->GetMeanMultiplicity()+AcumMultiplicity.back()); 178 } 216 } 179 217 180 G4int CheckA; 218 G4int CheckA; 181 do { 219 do { 182 CheckA = -1; 220 CheckA = -1; 183 G4int SumA = 0; 221 G4int SumA = 0; 184 G4int ThisOne = 0; 222 G4int ThisOne = 0; 185 multiplicity = 0.0; 223 multiplicity = 0.0; 186 for (i = 0; i < A; i++) ANumbers[i] = 0; << 224 for (i = 0; i < A; i++) ANumbers[i] = 0.0; 187 do { 225 do { 188 G4double RandNumber = G4UniformRand()*__ 226 G4double RandNumber = G4UniformRand()*__MeanMultiplicity; 189 for (i = 0; i < A; i++) { 227 for (i = 0; i < A; i++) { 190 if (RandNumber < AcumMultiplicity[i]) { 228 if (RandNumber < AcumMultiplicity[i]) { 191 ThisOne = i; 229 ThisOne = i; 192 break; 230 break; 193 } 231 } 194 } 232 } 195 multiplicity++; 233 multiplicity++; 196 ANumbers[ThisOne] = ANumbers[ThisOne]+1; 234 ANumbers[ThisOne] = ANumbers[ThisOne]+1; 197 SumA += ThisOne+1; 235 SumA += ThisOne+1; 198 CheckA = A - SumA; << 236 CheckA = static_cast<G4int>(A) - SumA; 199 237 200 // Loop checking, 05-Aug-2015, Vladimir << 201 } while (CheckA > 0); 238 } while (CheckA > 0); 202 239 203 // Loop checking, 05-Aug-2015, Vladimir Iv << 240 } while (CheckA < 0 || std::abs(__MeanMultiplicity - multiplicity) > std::sqrt(__MeanMultiplicity) + 1./2.); 204 } while (CheckA < 0 || std::abs(__MeanMultip << 205 241 206 return multiplicity; 242 return multiplicity; 207 } 243 } 208 244 209 G4StatMFChannel * G4StatMFMacroCanonical::Choo << 245 210 std::vector<G4int> & FragmentsA) << 246 G4StatMFChannel * G4StatMFMacroCanonical::ChooseZ(const G4int & Z, >> 247 std::vector<G4double> & FragmentsA) 211 // 248 // 212 { 249 { 213 G4Pow* g4calc = G4Pow::GetInstance(); << 250 std::vector<G4double> FragmentsZ; 214 std::vector<G4int> FragmentsZ; << 215 251 216 G4int DeltaZ = 0; << 252 G4double DeltaZ = 0.0; 217 G4double CP = G4StatMFParameters::GetCoulom << 253 G4double CP = (3./5.)*(elm_coupling/G4StatMFParameters::Getr0())* 218 G4int multiplicity = (G4int)FragmentsA.size( << 254 (1.0 - 1.0/std::pow(1.0+G4StatMFParameters::GetKappaCoulomb(),1./3.)); 219 255 220 do { << 256 G4int multiplicity = FragmentsA.size(); 221 FragmentsZ.clear(); << 257 222 G4int SumZ = 0; << 258 do 223 for (G4int i = 0; i < multiplicity; ++i) << 259 { 224 { << 260 FragmentsZ.clear(); 225 G4int A = FragmentsA[i]; << 261 G4int SumZ = 0; 226 if (A <= 1) << 262 for (G4int i = 0; i < multiplicity; i++) 227 { << 263 { 228 G4double RandNumber = G4UniformRand(); << 264 G4double A = FragmentsA[i]; 229 if (RandNumber < (*_theClusters.begin()) << 265 if (A <= 1.0) 230 { << 266 { 231 FragmentsZ.push_back(1); << 267 G4double RandNumber = G4UniformRand(); 232 SumZ += FragmentsZ[i]; << 268 if (RandNumber < (*_theClusters.begin())->GetZARatio()) 233 } << 269 { 234 else FragmentsZ.push_back(0); << 270 FragmentsZ.push_back(1.0); 235 } << 271 SumZ += static_cast<G4int>(FragmentsZ[i]); 236 else << 272 } 237 { << 273 else FragmentsZ.push_back(0.0); 238 G4double RandZ; << 274 } 239 G4double CC = 8.0*G4StatMFParameters::Ge << 275 else 240 + 2*CP*g4calc->Z23(FragmentsA[i]); << 276 { 241 G4double ZMean; << 277 G4double RandZ; 242 if (FragmentsA[i] > 1 && FragmentsA[i] < << 278 G4double CC = 8.0*G4StatMFParameters::GetGamma0()+2.0*CP*std::pow(FragmentsA[i],2./3.); 243 else { << 279 G4double ZMean; 244 ZMean = FragmentsA[i]*(4.0*G4StatMFPar << 280 if (FragmentsA[i] > 1.5 && FragmentsA[i] < 4.5) ZMean = 0.5*FragmentsA[i]; 245 + _ChemPotentialNu)/CC; << 281 else ZMean = FragmentsA[i]*(4.0*G4StatMFParameters::GetGamma0()+_ChemPotentialNu)/CC; >> 282 G4double ZDispersion = std::sqrt(FragmentsA[i]*__MeanTemperature/CC); >> 283 G4int z; >> 284 do >> 285 { >> 286 RandZ = G4RandGauss::shoot(ZMean,ZDispersion); >> 287 z = static_cast<G4int>(RandZ+0.5); >> 288 } while (z < 0 || z > A); >> 289 FragmentsZ.push_back(z); >> 290 SumZ += z; 246 } 291 } 247 G4double ZDispersion = std::sqrt(Fragmen << 292 } 248 G4int z; << 293 DeltaZ = Z - SumZ; 249 do << 294 } 250 { << 295 while (std::abs(DeltaZ) > 1.1); 251 RandZ = G4RandGauss::shoot(ZMean,ZDispersi << 252 z = G4lrint(RandZ+0.5); << 253 // Loop checking, 05-Aug-2015, Vladimir Iv << 254 } while (z < 0 || z > A); << 255 FragmentsZ.push_back(z); << 256 SumZ += z; << 257 } << 258 } << 259 DeltaZ = Z - SumZ; << 260 // Loop checking, 05-Aug-2015, Vladimir Ivan << 261 } while (std::abs(DeltaZ) > 1); << 262 296 263 // DeltaZ can be 0, 1 or -1 297 // DeltaZ can be 0, 1 or -1 264 G4int idx = 0; 298 G4int idx = 0; 265 if (DeltaZ < 0.0) 299 if (DeltaZ < 0.0) 266 { 300 { 267 while (FragmentsZ[idx] < 1) { ++idx; } << 301 while (FragmentsZ[idx] < 0.5) ++idx; 268 } 302 } 269 FragmentsZ[idx] += DeltaZ; 303 FragmentsZ[idx] += DeltaZ; 270 304 271 G4StatMFChannel * theChannel = new G4StatMFC 305 G4StatMFChannel * theChannel = new G4StatMFChannel; 272 for (G4int i = multiplicity-1; i >= 0; --i) << 306 for (G4int i = multiplicity-1; i >= 0; i--) 273 { 307 { 274 theChannel->CreateFragment(FragmentsA[i] 308 theChannel->CreateFragment(FragmentsA[i],FragmentsZ[i]); 275 } 309 } 276 << 310 277 return theChannel; << 311 >> 312 return theChannel; 278 } 313 } 279 314