53 G4VelocityTable::G4VelocityTable()
55 : edgeMin(0.), edgeMax(0.), numberOfNodes(0),
56 dBin(0.), baseBin(0.),
57 lastEnergy(-
DBL_MAX), lastValue(0.), lastBin(0),
58 maxT( 1000.0 ), minT( 0.0001 ), NbinT( 500 )
60 PrepareVelocityTable();
64 G4VelocityTable::~G4VelocityTable()
73 void G4VelocityTable::PrepareVelocityTable()
76 const G4double g4log10 = std::log(10.);
80 dBin = std::log10(maxT/minT)/NbinT;
81 baseBin = std::log10(minT)/dBin;
83 numberOfNodes = NbinT + 1;
84 dataVector.reserve(numberOfNodes);
85 binVector.reserve(numberOfNodes);
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);
108 size_t G4VelocityTable::FindBinLocation(
G4double theEnergy)
const
121 return size_t(
G4Log(theEnergy)/dBin/g4log10 - baseBin );
131 if( theEnergy == lastEnergy ) {
133 }
else if( theEnergy < lastEnergy
134 && theEnergy >= binVector[lastBin]) {
135 lastEnergy = theEnergy;
136 lastValue = Interpolation();
138 }
else if( theEnergy <= edgeMin ) {
140 lastEnergy = edgeMin;
141 lastValue = dataVector[0];
143 }
else if( theEnergy >= edgeMax ){
144 lastBin = numberOfNodes-1;
145 lastEnergy = edgeMax;
146 lastValue = dataVector[lastBin];
149 lastBin = FindBinLocation(theEnergy);
150 lastEnergy = theEnergy;
151 lastValue = Interpolation();
179 G4Exception(
"G4VelocityTable::SetVelocityTableProperties",
181 "Can modify only in PreInit or Idle state : Method ignored.");
185 if (nbin > 100 ) theInstance->NbinT = nbin;
186 if ((t_min < t_max)&&(t_min>0.)) {
187 theInstance->minT = t_min;
188 theInstance->maxT = t_max;
190 theInstance->PrepareVelocityTable();
static G4VelocityTable * GetVelocityTable()
static G4double GetMinTOfVelocityTable()
static G4StateManager * GetStateManager()
static G4int GetNbinOfVelocityTable()
G4ApplicationState GetCurrentState() const
static void SetVelocityTableProperties(G4double t_max, G4double t_min, G4int nbin)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
G4double G4Log(G4double x)
static constexpr double c_light
static G4double GetMaxTOfVelocityTable()
G4double Value(G4double theEnergy)