Geant4_10
G4StatMFMicroManager.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4StatMFMicroManager.cc 67983 2013-03-13 10:42:03Z gcosmo $
28 //
29 // Hadronic Process: Nuclear De-excitations
30 // by V. Lara
31 
32 
33 #include "G4StatMFMicroManager.hh"
34 #include "G4HadronicException.hh"
35 
36 
37 // Copy constructor
39 {
40  throw G4HadronicException(__FILE__, __LINE__, "G4StatMFMicroManager::copy_constructor meant to not be accessable");
41 }
42 
43 // Operators
44 
45 G4StatMFMicroManager & G4StatMFMicroManager::
46 operator=(const G4StatMFMicroManager & )
47 {
48  throw G4HadronicException(__FILE__, __LINE__, "G4StatMFMicroManager::operator= meant to not be accessable");
49  return *this;
50 }
51 
52 
54 {
55  return false;
56 }
57 
58 
60 {
61  return true;
62 }
63 
64 // constructor
66  G4double FreeIntE, G4double SCompNuc) :
67  _Normalization(0.0)
68 {
69  // Perform class initialization
70  Initialize(theFragment,multiplicity,FreeIntE,SCompNuc);
71 }
72 
73 
74 // destructor
76 {
77  if (!_Partition.empty())
78  {
79  std::for_each(_Partition.begin(),_Partition.end(),
80  DeleteFragment());
81  }
82 }
83 
84 
85 
86 // Initialization method
87 
88 void G4StatMFMicroManager::Initialize(const G4Fragment & theFragment, G4int im,
89  G4double FreeIntE, G4double SCompNuc)
90 {
91  G4int i;
92 
93  G4double U = theFragment.GetExcitationEnergy();
94 
95  G4int A = theFragment.GetA_asInt();
96  G4int Z = theFragment.GetZ_asInt();
97 
98  // Statistical weights
99  _WW = 0.0;
100 
101  // Mean breakup multiplicity
102  _MeanMultiplicity = 0.0;
103 
104  // Mean channel temperature
105  _MeanTemperature = 0.0;
106 
107  // Mean channel entropy
108  _MeanEntropy = 0.0;
109 
110  // Keep fragment atomic numbers
111 // G4int * FragmentAtomicNumbers = new G4int(static_cast<G4int>(A+0.5));
112 // G4int * FragmentAtomicNumbers = new G4int(m);
113  G4int FragmentAtomicNumbers[4];
114 
115  // We distribute A nucleons between m fragments mantaining the order
116  // FragmentAtomicNumbers[m-1]>FragmentAtomicNumbers[m-2]>...>FragmentAtomicNumbers[0]
117  // Our initial distribution is
118  // FragmentAtomicNumbers[m-1]=A, FragmentAtomicNumbers[m-2]=0, ..., FragmentAtomicNumbers[0]=0
119  FragmentAtomicNumbers[im-1] = A;
120  for (i = 0; i < (im - 1); i++) FragmentAtomicNumbers[i] = 0;
121 
122  // We try to distribute A nucleons in partitions of m fragments
123  // MakePartition return true if it is possible
124  // and false if it is not
125  while (MakePartition(im,FragmentAtomicNumbers)) {
126  // Allowed partitions are stored and its probability calculated
127 
128  G4StatMFMicroPartition * aPartition = new G4StatMFMicroPartition(A,Z);
129  G4double PartitionProbability = 0.0;
130 
131  for (i = im-1; i >= 0; i--) aPartition->SetPartitionFragment(FragmentAtomicNumbers[i]);
132  PartitionProbability = aPartition->CalcPartitionProbability(U,FreeIntE,SCompNuc);
133  _Partition.push_back(aPartition);
134 
135  _WW += PartitionProbability;
136  _MeanMultiplicity += im*PartitionProbability;
137  _MeanTemperature += aPartition->GetTemperature() * PartitionProbability;
138  if (PartitionProbability > 0.0)
139  _MeanEntropy += PartitionProbability * aPartition->GetEntropy();
140 
141  }
142 }
143 
144 G4bool G4StatMFMicroManager::MakePartition(G4int k, G4int * ANumbers)
145  // Distributes A nucleons between k fragments
146  // mantaining the order ANumbers[k-1] > ANumbers[k-2] > ... > ANumbers[0]
147  // If it is possible returns true. In other case returns false
148 {
149  G4int l = 1;
150  while (l < k) {
151  G4int tmp = ANumbers[l-1] + ANumbers[k-1];
152  ANumbers[l-1] += 1;
153  ANumbers[k-1] -= 1;
154  if (ANumbers[l-1] > ANumbers[l] || ANumbers[k-2] > ANumbers[k-1]) {
155  ANumbers[l-1] = 1;
156  ANumbers[k-1] = tmp - 1;
157  l++;
158  } else return true;
159  }
160  return false;
161 }
162 
164 {
165  _Normalization = Norm;
166  _WW /= Norm;
167  _MeanMultiplicity /= Norm;
168  _MeanTemperature /= Norm;
169  _MeanEntropy /= Norm;
170 
171  return;
172 }
173 
176 {
177  G4double RandNumber = _Normalization * _WW * G4UniformRand();
178  G4double AccumWeight = 0.0;
179 
180  for (std::vector<G4StatMFMicroPartition*>::iterator i = _Partition.begin();
181  i != _Partition.end(); ++i)
182  {
183  AccumWeight += (*i)->GetProbability();
184  if (RandNumber < AccumWeight)
185  return (*i)->ChooseZ(A0,Z0,MeanT);
186  }
187 
188  throw G4HadronicException(__FILE__, __LINE__,
189  "G4StatMFMicroCanonical::ChooseChannel: Couldn't find a channel.");
190  return 0;
191 }
Float_t tmp
Definition: plot.C:37
void Normalize(G4double Norm)
G4StatMFChannel * ChooseChannel(G4int A0, G4int Z0, G4double MeanT)
int G4int
Definition: G4Types.hh:78
#define G4UniformRand()
Definition: Randomize.hh:87
G4int GetA_asInt() const
Definition: G4Fragment.hh:218
Float_t Z
Definition: plot.C:39
bool G4bool
Definition: G4Types.hh:79
G4bool operator==(const G4StatMFMicroManager &right) const
G4StatMFMicroManager(const G4Fragment &theFragment, G4int multiplicity, G4double FreeIntE, G4double SCompNuc)
G4double CalcPartitionProbability(G4double U, G4double FreeInternalE0, G4double SCompound)
G4int GetZ_asInt() const
Definition: G4Fragment.hh:223
double G4double
Definition: G4Types.hh:76
G4double GetExcitationEnergy() const
Definition: G4Fragment.hh:235
void SetPartitionFragment(G4int anA)
G4bool operator!=(const G4StatMFMicroManager &right) const