Ignore:
Timestamp:
Jun 18, 2010, 11:42:07 AM (14 years ago)
Author:
garnier
Message:

update geant4-09-04-beta-cand-01 interfaces-V09-03-09 vis-V09-03-08

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/processes/hadronic/models/de_excitation/multifragmentation/src/G4StatMFMacroTemperature.cc

    r1228 r1315  
    2525//
    2626//
    27 // $Id: G4StatMFMacroTemperature.cc,v 1.7 2008/11/19 14:33:31 vnivanch Exp $
    28 // GEANT4 tag $Name: geant4-09-03 $
     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 $
    2929//
    3030// Hadronic Process: Nuclear De-excitations
     
    3636//          Moscow, pshenich@fias.uni-frankfurt.de) make algorithm closer to
    3737//          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 
    3841
    3942#include "G4StatMFMacroTemperature.hh"
     43
     44G4StatMFMacroTemperature::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
     59G4StatMFMacroTemperature::G4StatMFMacroTemperature()
     60{}
     61       
     62G4StatMFMacroTemperature::~G4StatMFMacroTemperature()
     63{}
    4064
    4165// operators definitions
     
    82106
    83107    G4int iterations = 0; 
    84     while (fTa < 0.0 && iterations++ < 10) {
     108    while (fTa < 0.0 && ++iterations < 10) {
    85109        Ta -= 0.5*Ta;
    86110        fTa = this->operator()(Ta);
     
    89113    iterations = 0; 
    90114    while (fTa*fTb > 0.0 && iterations++ < 10) {
    91         Tb += 2.*std::abs(Tb-Ta);
     115        Tb += 2.*std::fabs(Tb-Ta);
    92116        fTb = this->operator()(Tb);
    93117    }
     
    96120      G4cerr <<"G4StatMFMacroTemperature:"<<" Ta="<<Ta<<" Tb="<<Tb<< G4endl;
    97121      G4cerr <<"G4StatMFMacroTemperature:"<<" fTa="<<fTa<<" fTb="<<fTb<< G4endl;
    98         throw G4HadronicException(__FILE__, __LINE__, "G4StatMFMacroTemperature::CalcTemperature: I couldn't bracket the solution.");
     122      throw G4HadronicException(__FILE__, __LINE__, "G4StatMFMacroTemperature::CalcTemperature: I couldn't bracket the solution.");
    99123    }
    100124
     
    102126    theSolver->SetIntervalLimits(Ta,Tb);
    103127    if (!theSolver->Crenshaw(*this)){
    104       G4cerr <<"G4StatMFMacroTemperature, Crenshaw method failed:"<<" Ta="<<Ta<<" Tb="<<Tb<< G4endl;
    105       G4cerr <<"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;
    106130    }
    107131    _MeanTemperature = theSolver->GetRoot();
     
    111135    // Verify if the root is found and it is indeed within the physical domain,
    112136    // 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;
    120156        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;
    133161    return _MeanTemperature;
    134162}
Note: See TracChangeset for help on using the changeset viewer.