Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4StatMFMacroChemicalPotential.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: G4StatMFMacroChemicalPotential.cc 100379 2016-10-19 15:05:35Z gcosmo $
28 //
29 // Hadronic Process: Nuclear De-excitations
30 // by V. Lara
31 
33 #include "G4PhysicalConstants.hh"
34 #include "G4Pow.hh"
35 
36 // operators definitions
38 G4StatMFMacroChemicalPotential::operator=(const G4StatMFMacroChemicalPotential & )
39 {
40  throw G4HadronicException(__FILE__, __LINE__, "G4StatMFMacroChemicalPotential::operator= meant to not be accessable");
41  return *this;
42 }
43 
44 G4bool G4StatMFMacroChemicalPotential::operator==(const G4StatMFMacroChemicalPotential & ) const
45 {
46  throw G4HadronicException(__FILE__, __LINE__, "G4StatMFMacroChemicalPotential::operator== meant to not be accessable");
47  return false;
48 }
49 
50 
51 G4bool G4StatMFMacroChemicalPotential::operator!=(const G4StatMFMacroChemicalPotential & ) const
52 {
53  throw G4HadronicException(__FILE__, __LINE__, "G4StatMFMacroChemicalPotential::operator!= meant to not be accessable");
54  return true;
55 }
56 
58 // Calculate Chemical potential \nu
59 {
60  G4Pow* g4calc = G4Pow::GetInstance();
62 
63  // Initial value for _ChemPotentialNu
64  _ChemPotentialNu = (theZ/theA)*(8.0*G4StatMFParameters::GetGamma0()
65  +2.0*CP*g4calc->Z23(theA))
67 
68  G4double ChemPa = _ChemPotentialNu;
69  G4double ChemPb = 0.5*_ChemPotentialNu;
70 
71  G4double fChemPa = this->operator()(ChemPa);
72  G4double fChemPb = this->operator()(ChemPb);
73 
74  if (fChemPa*fChemPb > 0.0) {
75  // bracketing the solution
76  if (fChemPa < 0.0) {
77  do {
78  ChemPb -= 1.5*std::abs(ChemPb-ChemPa);
79  fChemPb = this->operator()(ChemPb);
80  // Loop checking, 05-Aug-2015, Vladimir Ivanchenko
81  } while (fChemPb < 0.0);
82  } else {
83  do {
84  ChemPb += 1.5*std::abs(ChemPb-ChemPa);
85  fChemPb = this->operator()(ChemPb);
86  // Loop checking, 05-Aug-2015, Vladimir Ivanchenko
87  } while (fChemPb > 0.0);
88  }
89  }
90 
93  theSolver->SetIntervalLimits(ChemPa,ChemPb);
94  // if (!theSolver->Crenshaw(*this))
95  if (!theSolver->Brent(*this)){
96  G4cout <<"G4StatMFMacroChemicalPotential:"<<" ChemPa="<<ChemPa
97  <<" ChemPb="<<ChemPb<< G4endl;
98  G4cout <<"G4StatMFMacroChemicalPotential:"<<" fChemPa="<<fChemPa
99  <<" fChemPb="<<fChemPb<< G4endl;
100  throw G4HadronicException(__FILE__, __LINE__, "G4StatMFMacroChemicalPotential::CalcChemicalPotentialNu: I couldn't find the root.");
101  }
102  _ChemPotentialNu = theSolver->GetRoot();
103  delete theSolver;
104  return _ChemPotentialNu;
105 }
106 
107 
108 
109 G4double G4StatMFMacroChemicalPotential::CalcMeanZ(const G4double nu)
110 {
111  std::vector<G4VStatMFMacroCluster*>::iterator i;
112  for (i= _theClusters->begin()+1; i != _theClusters->end(); ++i)
113  {
114  (*i)->CalcZARatio(nu);
115  }
116  CalcChemicalPotentialMu(nu);
117  // This is important, the Z over A ratio for proton and neutron depends on the
118  // chemical potential Mu, while for the first guess for Chemical potential mu
119  // some values of Z over A ratio. This is the reason for that.
120  (*_theClusters->begin())->CalcZARatio(nu);
121 
122  G4double MeanZ = 0.0;
123  G4int n = 1;
124  for (i = _theClusters->begin(); i != _theClusters->end(); ++i)
125  {
126  MeanZ += (n++) * (*i)->GetZARatio() * (*i)->GetMeanMultiplicity();
127  }
128  return MeanZ;
129 }
130 
131 void G4StatMFMacroChemicalPotential::CalcChemicalPotentialMu(const G4double nu)
132 // Calculate Chemical potential \mu
133 // For that is necesary to calculate mean multiplicities
134 {
135  G4StatMFMacroMultiplicity * theMultip = new
136  G4StatMFMacroMultiplicity(theA,_Kappa,_MeanTemperature,nu,_theClusters);
137 
138  _ChemPotentialMu = theMultip->CalcChemicalPotentialMu();
139  _MeanMultiplicity = theMultip->GetMeanMultiplicity();
140 
141  delete theMultip;
142 
143  return;
144 }
static G4double GetGamma0()
static G4Pow * GetInstance()
Definition: G4Pow.cc:55
Definition: G4Pow.hh:56
void SetIntervalLimits(const G4double Limit1, const G4double Limit2)
int G4int
Definition: G4Types.hh:78
G4bool Brent(Function &theFunction)
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
G4double GetMeanMultiplicity(void) const
G4double GetRoot(void) const
Definition: G4Solver.hh:77
static G4double GetCoulomb()
G4double Z23(G4int Z) const
Definition: G4Pow.hh:154
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76