File indexing completed on 2025-01-18 09:58:47
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 #ifndef G4OLD_MAGINT_DRIVER_HH
0038 #define G4OLD_MAGINT_DRIVER_HH
0039
0040 #include "G4VIntegrationDriver.hh"
0041 #include "G4MagIntegratorStepper.hh"
0042 #include "G4ChordFinderDelegate.hh"
0043
0044 class G4OldMagIntDriver : public G4VIntegrationDriver,
0045 public G4ChordFinderDelegate<G4OldMagIntDriver>
0046 {
0047 public:
0048
0049 G4OldMagIntDriver(G4double hminimum,
0050 G4MagIntegratorStepper* pItsStepper,
0051 G4int numberOfComponents = 6,
0052 G4int statisticsVerbosity = 0);
0053 ~G4OldMagIntDriver() override;
0054
0055
0056 G4OldMagIntDriver(const G4OldMagIntDriver&) = delete;
0057 G4OldMagIntDriver& operator=(const G4OldMagIntDriver&) = delete;
0058
0059 inline G4double AdvanceChordLimited(G4FieldTrack& track,
0060 G4double stepMax,
0061 G4double epsStep,
0062 G4double chordDistance) override;
0063
0064 inline void OnStartTracking() override;
0065 inline void OnComputeStep(const G4FieldTrack* = nullptr) override {}
0066 inline G4bool DoesReIntegrate() const override { return true; }
0067
0068 G4bool AccurateAdvance(G4FieldTrack& y_current,
0069 G4double hstep,
0070 G4double eps,
0071 G4double hinitial = 0.0) override;
0072
0073
0074
0075
0076
0077
0078 G4bool QuickAdvance(G4FieldTrack& y_val,
0079 const G4double dydx[],
0080 G4double hstep,
0081 G4double& dchord_step,
0082 G4double& dyerr) override;
0083
0084
0085 G4bool QuickAdvance( G4FieldTrack& y_posvel,
0086 const G4double dydx[],
0087 G4double hstep,
0088 G4double& dchord_step,
0089 G4double& dyerr_pos_sq,
0090 G4double& dyerr_mom_rel_sq);
0091
0092
0093
0094
0095 inline G4double GetHmin() const;
0096 inline G4double Hmin() const;
0097 inline G4double GetSafety() const;
0098 inline G4double GetPshrnk() const;
0099 inline G4double GetPgrow() const;
0100 inline G4double GetErrcon() const;
0101 void GetDerivatives(const G4FieldTrack& y_curr,
0102 G4double dydx[]) const override;
0103
0104 void GetDerivatives(const G4FieldTrack& track,
0105 G4double dydx[],
0106 G4double field[]) const override;
0107
0108
0109 G4EquationOfMotion* GetEquationOfMotion() override;
0110 void SetEquationOfMotion(G4EquationOfMotion* equation) override;
0111
0112 void RenewStepperAndAdjust(G4MagIntegratorStepper* pItsStepper) override;
0113
0114
0115
0116 inline void ReSetParameters(G4double new_safety = 0.9);
0117
0118
0119
0120
0121
0122 inline void SetSafety(G4double valS);
0123 inline void SetPshrnk(G4double valPs);
0124 inline void SetPgrow (G4double valPg);
0125 inline void SetErrcon(G4double valEc);
0126
0127
0128 inline G4double ComputeAndSetErrcon();
0129
0130 const G4MagIntegratorStepper* GetStepper() const override;
0131 G4MagIntegratorStepper* GetStepper() override;
0132
0133 void OneGoodStep( G4double ystart[],
0134 const G4double dydx[],
0135 G4double& x,
0136 G4double htry,
0137 G4double eps,
0138 G4double& hdid,
0139 G4double& hnext) ;
0140
0141
0142
0143
0144 G4double ComputeNewStepSize(G4double errMaxNorm,
0145 G4double hstepCurrent) override;
0146
0147
0148
0149
0150
0151 void StreamInfo( std::ostream& os ) const override;
0152
0153 G4double ComputeNewStepSize_WithinLimits(G4double errMaxNorm,
0154 G4double hstepCurrent);
0155
0156
0157
0158
0159 inline G4int GetMaxNoSteps() const;
0160 inline void SetMaxNoSteps(G4int val);
0161
0162
0163
0164
0165 inline void SetHmin(G4double newval);
0166 void SetVerboseLevel(G4int newLevel) override;
0167 G4int GetVerboseLevel() const override;
0168
0169 inline G4double GetSmallestFraction() const;
0170 void SetSmallestFraction( G4double val );
0171
0172 protected:
0173
0174 void WarnSmallStepSize(G4double hnext, G4double hstep,
0175 G4double h, G4double xDone,
0176 G4int noSteps);
0177
0178 void WarnTooManyStep(G4double x1start, G4double x2end, G4double xCurrent);
0179 void WarnEndPointTooFar(G4double endPointDist,
0180 G4double hStepSize ,
0181 G4double epsilonRelative,
0182 G4int debugFlag);
0183
0184
0185 void PrintStatus(const G4double* StartArr,
0186 G4double xstart,
0187 const G4double* CurrentArr,
0188 G4double xcurrent,
0189 G4double requestStep,
0190 G4int subStepNo);
0191 void PrintStatus(const G4FieldTrack& StartFT,
0192 const G4FieldTrack& CurrentFT,
0193 G4double requestStep,
0194 G4int subStepNo);
0195 void PrintStat_Aux(const G4FieldTrack& aFieldTrack,
0196 G4double requestStep,
0197 G4double actualStep,
0198 G4int subStepNo,
0199 G4double subStepSize,
0200 G4double dotVelocities);
0201
0202
0203 void PrintStatisticsReport();
0204
0205
0206 #ifdef QUICK_ADV_TWO
0207 G4bool QuickAdvance( G4double yarrin[],
0208 const G4double dydx[],
0209 G4double hstep,
0210 G4double yarrout[],
0211 G4double& dchord_step,
0212 G4double& dyerr );
0213 #endif
0214
0215 private:
0216
0217
0218
0219
0220 G4double fMinimumStep = 0.0;
0221
0222 G4double fSmallestFraction = 1.0e-12;
0223
0224
0225
0226 const G4int fNoIntegrationVariables = 0;
0227 const G4int fMinNoVars = 12;
0228 const G4int fNoVars = 0;
0229
0230 G4int fMaxNoSteps;
0231 G4int fMaxStepBase = 250;
0232
0233
0234 G4double safety;
0235 G4double pshrnk;
0236 G4double pgrow;
0237 G4double errcon;
0238
0239
0240 G4int fStatisticsVerboseLevel = 0;
0241
0242
0243
0244
0245 G4MagIntegratorStepper* pIntStepper = nullptr;
0246
0247
0248
0249
0250 unsigned long fNoTotalSteps=0, fNoBadSteps=0;
0251 unsigned long fNoSmallSteps=0, fNoInitialSmallSteps=0, fNoCalls=0;
0252 G4double fDyerr_max=0.0, fDyerr_mx2=0.0;
0253 G4double fDyerrPos_smTot=0.0, fDyerrPos_lgTot=0.0, fDyerrVel_lgTot=0.0;
0254 G4double fSumH_sm=0.0, fSumH_lg=0.0;
0255
0256
0257 G4int fVerboseLevel = 0;
0258
0259
0260 using ChordFinderDelegate = G4ChordFinderDelegate<G4OldMagIntDriver>;
0261 };
0262
0263 #include "G4OldMagIntDriver.icc"
0264
0265 #endif