44const G4double G4BorisDriver::fErrorConstraintShrink = std::pow(
45 fMaxSteppingDecrease / fSafetyFactor, 1. / fPowerShrink);
47const G4double G4BorisDriver::fErrorConstraintGrow = std::pow(
48 fMaxSteppingIncrease / fSafetyFactor, 1. / fPowerGrow);
54 G4int numberOfComponents,
bool verbosity )
55 : fMinimumStep(hminimum),
56 fVerbosity(verbosity),
64 std::ostringstream msg;
65 msg <<
"Disagreement in number of variables = "
67 <<
" vs no of components = " << numberOfComponents;
88 std::ostringstream message;
89 message <<
"Proposed step is zero; hstep = " << hstep <<
" !";
96 std::ostringstream message;
97 message <<
"Invalid run condition." <<
G4endl
98 <<
"Proposed step is negative; hstep = " << hstep <<
G4endl
99 <<
"Requested step cannot be negative! Aborting event.";
105 if( hinitial == 0.0 ) { hinitial = hstep; }
106 if( hinitial < 0.0 ) { hinitial = std::fabs( hinitial ); }
119 const G4int nvar= GetNumberOfVariables();
123 std::memcpy(yOut + nvar,
128 const G4double endCurveLength = curveLength + hstep;
138 std::max(
epsilon * hstep, fSmallestFraction * curveLength);
142 for (
G4int nstp = 0; nstp < fMaxNoSteps; ++nstp)
152 CheckStep(EndPos, StartPos, hdid);
155 if (curveLength >= endCurveLength || htry < hThreshold)
160 htry = std::max(hnext, fMinimumStep);
161 if (curveLength + htry > endCurveLength)
163 htry = endCurveLength - curveLength;
190 const G4int max_trials = 100;
192 for (
G4int iter = 0; iter < max_trials; ++iter)
206 if(xnew == curveLength)
208 std::ostringstream message;
209 message <<
"Stepsize underflow in Stepper !" <<
G4endl
210 <<
"- Step's start x=" << curveLength
211 <<
" and end x= " << xnew
212 <<
" are equal !! " <<
G4endl
213 <<
" Due to step-size= " << h
214 <<
". Note that input step was " << htry;
222 curveLength += (hdid = h);
262 std::memcpy(yOut + nvar, yIn + nvar,
299 if (error2 > fErrorConstraintShrink * fErrorConstraintShrink)
301 return fMaxSteppingDecrease * h;
303 return fSafetyFactor * h * std::pow(error2, 0.5 * fPowerShrink);
311 if (error2 < fErrorConstraintGrow * fErrorConstraintGrow)
313 return fMaxSteppingIncrease * h;
315 return fSafetyFactor * h * std::pow(error2, 0.5 * fPowerGrow);
323 "This method is not implemented. BorisDriver/Stepper should keep its equation");
331 os <<
"State of G4BorisDriver: " << std::endl;
332 os <<
" Method is implemented, but gives no information. " << std::endl;
G4double epsilon(G4double density, G4double temperature)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
void OneGoodStep(G4double yCurrentState[], G4double &curveLength, G4double htry, G4double epsilon_rel, G4double restMass, G4double charge, G4double &hdid, G4double &hnext)
virtual void StreamInfo(std::ostream &os) const override
G4double ShrinkStepSize2(G4double h, G4double error2) const
virtual void GetDerivatives(const G4FieldTrack &track, G4double dydx[]) const override
G4BorisDriver(G4double hminimum, G4BorisScheme *Boris, G4int numberOfComponents=6, bool verbosity=false)
virtual void SetEquationOfMotion(G4EquationOfMotion *equation) override
virtual G4bool AccurateAdvance(G4FieldTrack &track, G4double stepLen, G4double epsilon, G4double beginStep=0) override
virtual G4EquationOfMotion * GetEquationOfMotion() override
virtual G4bool QuickAdvance(G4FieldTrack &y_val, const G4double dydx[], G4double hstep, G4double &missDist, G4double &dyerr) override
G4double GrowStepSize2(G4double h, G4double error2) const
G4int GetNumberOfVariables() const
void StepWithErrorEstimate(const G4double yIn[], G4double restMass, G4double charge, G4double hstep, G4double yOut[], G4double yErr[]) const
void StepWithMidAndErrorEstimate(const G4double yIn[], G4double restMass, G4double charge, G4double hstep, G4double yMid[], G4double yOut[], G4double yErr[]) const
void EvaluateRhsReturnB(const G4double y[], G4double dydx[], G4double Field[]) const
G4double GetCurveLength() const
G4double GetCharge() const
void SetCurveLength(G4double nCurve_s)
G4double GetRestMass() const
void DumpToArray(G4double valArr[ncompSVEC]) const
void LoadFromArray(const G4double valArr[ncompSVEC], G4int noVarsIntegrated)
static G4double Distline(const G4ThreeVector &OtherPnt, const G4ThreeVector &LinePntA, const G4ThreeVector &LinePntB)
G4double absoluteError(const G4double y[], const G4double yerr[], G4double hstep)
G4double relativeError2(const G4double y[], const G4double yerr[], G4double hstep, G4double errorTolerance)
G4ThreeVector makeVector(const ArrayType &array, Value3D value)
void copy(G4double dst[], const G4double src[], std::size_t size=G4FieldTrack::ncompSVEC)