54 : edgeMin(0.), edgeMax(0.), numberOfNodes(0),
55 dBin(0.), baseBin(0.),
56 lastEnergy(-
DBL_MAX), lastValue(0.), lastBin(0),
57 maxT( 1000.0 ), minT( 0.0001 ), NbinT( 500 )
59 PrepareVelocityTable();
72void G4VelocityTable::PrepareVelocityTable()
78 dBin = std::log10(maxT/minT)/NbinT;
79 baseBin = std::log10(minT)/dBin;
81 numberOfNodes = NbinT + 1;
82 dataVector.reserve(numberOfNodes);
83 binVector.reserve(numberOfNodes);
85 const G4double g4log10 = std::log(10.);
87 binVector.push_back(minT);
88 dataVector.push_back(0.0);
90 for (
size_t i=1; i<numberOfNodes-1; i++){
91 binVector.push_back(std::exp(g4log10*(baseBin+i)*dBin));
92 dataVector.push_back(0.0);
94 binVector.push_back(maxT);
95 dataVector.push_back(0.0);
97 edgeMin = binVector[0];
98 edgeMax = binVector[numberOfNodes-1];
100 for (
G4int i=0; i<=NbinT; i++){
102 dataVector[i]= c_light*std::sqrt(T*(T+2.))/(T+1.0);
108size_t G4VelocityTable::FindBinLocation(
G4double theEnergy)
const
120 return size_t( std::log10(theEnergy)/dBin - baseBin );
130 if( theEnergy == lastEnergy ) {
132 }
else if( theEnergy < lastEnergy
133 && theEnergy >= binVector[lastBin]) {
134 lastEnergy = theEnergy;
135 lastValue = Interpolation();
137 }
else if( theEnergy <= edgeMin ) {
139 lastEnergy = edgeMin;
140 lastValue = dataVector[0];
142 }
else if( theEnergy >= edgeMax ){
143 lastBin = numberOfNodes-1;
144 lastEnergy = edgeMax;
145 lastValue = dataVector[lastBin];
148 lastBin = FindBinLocation(theEnergy);
149 lastEnergy = theEnergy;
150 lastValue = Interpolation();
175 G4Exception(
"G4VelocityTable::SetVelocityTableProperties",
177 "Can modify only in PreInit or Idle state : Method ignored.");
181 if (nbin > 100 ) theInstance->NbinT = nbin;
182 if ((t_min < t_max)&&(t_min>0.)) {
183 theInstance->minT = t_min;
184 theInstance->maxT = t_max;
186 theInstance->PrepareVelocityTable();
192{
return theInstance->maxT; }
197{
return theInstance->minT; }
202{
return theInstance->NbinT; }
G4ApplicationState GetCurrentState() const
static G4StateManager * GetStateManager()
static G4VelocityTable * GetVelocityTable()
static void SetVelocityTableProperties(G4double t_max, G4double t_min, G4int nbin)
G4double Value(G4double theEnergy)
static G4double GetMaxTOfVelocityTable()
static G4double GetMinTOfVelocityTable()
static G4int GetNbinOfVelocityTable()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)