Changeset 1315 for trunk/source/processes/hadronic/models/de_excitation/multifragmentation/src/G4StatMFMacroTemperature.cc
- Timestamp:
- Jun 18, 2010, 11:42:07 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/processes/hadronic/models/de_excitation/multifragmentation/src/G4StatMFMacroTemperature.cc
r1228 r1315 25 25 // 26 26 // 27 // $Id: G4StatMFMacroTemperature.cc,v 1. 7 2008/11/19 14:33:31vnivanch Exp $28 // GEANT4 tag $Name: geant4-09-0 3$27 // $Id: G4StatMFMacroTemperature.cc,v 1.8 2010/04/16 17:04:08 vnivanch Exp $ 28 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 29 29 // 30 30 // Hadronic Process: Nuclear De-excitations … … 36 36 // Moscow, pshenich@fias.uni-frankfurt.de) make algorithm closer to 37 37 // original MF model 38 // 16.04.10 V.Ivanchenko improved logic of solving equation for tempetature 39 // to protect code from rare unwanted exception; moved constructor 40 // and destructor to source 38 41 39 42 #include "G4StatMFMacroTemperature.hh" 43 44 G4StatMFMacroTemperature::G4StatMFMacroTemperature(const G4double anA, const G4double aZ, 45 const G4double ExEnergy, const G4double FreeE0, const G4double kappa, 46 std::vector<G4VStatMFMacroCluster*> * ClusterVector) : 47 theA(anA), 48 theZ(aZ), 49 _ExEnergy(ExEnergy), 50 _FreeInternalE0(FreeE0), 51 _Kappa(kappa), 52 _MeanMultiplicity(0.0), 53 _MeanTemperature(0.0), 54 _ChemPotentialMu(0.0), 55 _ChemPotentialNu(0.0), 56 _theClusters(ClusterVector) 57 {} 58 59 G4StatMFMacroTemperature::G4StatMFMacroTemperature() 60 {} 61 62 G4StatMFMacroTemperature::~G4StatMFMacroTemperature() 63 {} 40 64 41 65 // operators definitions … … 82 106 83 107 G4int iterations = 0; 84 while (fTa < 0.0 && iterations++< 10) {108 while (fTa < 0.0 && ++iterations < 10) { 85 109 Ta -= 0.5*Ta; 86 110 fTa = this->operator()(Ta); … … 89 113 iterations = 0; 90 114 while (fTa*fTb > 0.0 && iterations++ < 10) { 91 Tb += 2.*std:: abs(Tb-Ta);115 Tb += 2.*std::fabs(Tb-Ta); 92 116 fTb = this->operator()(Tb); 93 117 } … … 96 120 G4cerr <<"G4StatMFMacroTemperature:"<<" Ta="<<Ta<<" Tb="<<Tb<< G4endl; 97 121 G4cerr <<"G4StatMFMacroTemperature:"<<" fTa="<<fTa<<" fTb="<<fTb<< G4endl; 98 122 throw G4HadronicException(__FILE__, __LINE__, "G4StatMFMacroTemperature::CalcTemperature: I couldn't bracket the solution."); 99 123 } 100 124 … … 102 126 theSolver->SetIntervalLimits(Ta,Tb); 103 127 if (!theSolver->Crenshaw(*this)){ 104 G4c err<<"G4StatMFMacroTemperature, Crenshaw method failed:"<<" Ta="<<Ta<<" Tb="<<Tb<< G4endl;105 G4c err<<"G4StatMFMacroTemperature, Crenshaw method failed:"<<" fTa="<<fTa<<" fTb="<<fTb<< G4endl;128 G4cout <<"G4StatMFMacroTemperature, Crenshaw method failed:"<<" Ta="<<Ta<<" Tb="<<Tb<< G4endl; 129 G4cout <<"G4StatMFMacroTemperature, Crenshaw method failed:"<<" fTa="<<fTa<<" fTb="<<fTb<< G4endl; 106 130 } 107 131 _MeanTemperature = theSolver->GetRoot(); … … 111 135 // Verify if the root is found and it is indeed within the physical domain, 112 136 // say, between 1 and 50 MeV, otherwise try Brent method: 113 if (_MeanTemperature < 1. || _MeanTemperature > 50. || std::abs(FunctionValureAtRoot) > 5.e-2) { 114 G4cout << "Crenshaw method failed; function = " << FunctionValureAtRoot << " solution? = " << _MeanTemperature << " MeV " << G4endl; 115 G4Solver<G4StatMFMacroTemperature> * theSolverBrent = new G4Solver<G4StatMFMacroTemperature>(200,1.e-3); 116 theSolverBrent->SetIntervalLimits(Ta,Tb); 117 if (!theSolverBrent->Brent(*this)){ 118 G4cerr <<"G4StatMFMacroTemperature, Brent method failed:"<<" Ta="<<Ta<<" Tb="<<Tb<< G4endl; 119 G4cerr <<"G4StatMFMacroTemperature, Brent method failed:"<<" fTa="<<fTa<<" fTb="<<fTb<< G4endl; 137 if (std::fabs(FunctionValureAtRoot) > 5.e-2) { 138 if (_MeanTemperature < 1. || _MeanTemperature > 50.) { 139 G4cout << "Crenshaw method failed; function = " << FunctionValureAtRoot 140 << " solution? = " << _MeanTemperature << " MeV " << G4endl; 141 G4Solver<G4StatMFMacroTemperature> * theSolverBrent = new G4Solver<G4StatMFMacroTemperature>(200,1.e-3); 142 theSolverBrent->SetIntervalLimits(Ta,Tb); 143 if (!theSolverBrent->Brent(*this)){ 144 G4cout <<"G4StatMFMacroTemperature, Brent method failed:"<<" Ta="<<Ta<<" Tb="<<Tb<< G4endl; 145 G4cout <<"G4StatMFMacroTemperature, Brent method failed:"<<" fTa="<<fTa<<" fTb="<<fTb<< G4endl; 146 throw G4HadronicException(__FILE__, __LINE__, "G4StatMFMacroTemperature::CalcTemperature: I couldn't find the root with any method."); 147 } 148 149 _MeanTemperature = theSolverBrent->GetRoot(); 150 FunctionValureAtRoot = this->operator()(_MeanTemperature); 151 delete theSolverBrent; 152 } 153 if (std::abs(FunctionValureAtRoot) > 5.e-2) { 154 //if (_MeanTemperature < 1. || _MeanTemperature > 50. || std::abs(FunctionValureAtRoot) > 5.e-2) { 155 G4cout << "Brent method failed; function = " << FunctionValureAtRoot << " solution? = " << _MeanTemperature << " MeV " << G4endl; 120 156 throw G4HadronicException(__FILE__, __LINE__, "G4StatMFMacroTemperature::CalcTemperature: I couldn't find the root with any method."); 121 } 122 123 _MeanTemperature = theSolverBrent->GetRoot(); 124 FunctionValureAtRoot = this->operator()(_MeanTemperature); 125 delete theSolverBrent; 126 127 if (_MeanTemperature < 1. || _MeanTemperature > 50. || std::abs(FunctionValureAtRoot) > 5.e-2) { 128 G4cout << "Brent method failed; function = " << FunctionValureAtRoot << " solution? = " << _MeanTemperature << " MeV " << G4endl; 129 throw G4HadronicException(__FILE__, __LINE__, "G4StatMFMacroTemperature::CalcTemperature: I couldn't find the root with any method."); 130 } 131 } 132 157 } 158 } 159 //G4cout << "G4StatMFMacroTemperature::CalcTemperature: function = " << FunctionValureAtRoot 160 // << " T(MeV)= " << _MeanTemperature << G4endl; 133 161 return _MeanTemperature; 134 162 }
Note: See TracChangeset
for help on using the changeset viewer.