File indexing completed on 2025-10-31 09:02:27
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 #ifndef G4BULIRSCH_STOER_DRIVER_HH
0036 #define G4BULIRSCH_STOER_DRIVER_HH
0037 
0038 #include "G4IntegrationDriver.hh"
0039 #include "G4BulirschStoer.hh"
0040 #include "G4ChordFinderDelegate.hh"
0041 
0042 template <>
0043 class G4IntegrationDriver<G4BulirschStoer>: 
0044     public G4VIntegrationDriver,
0045     public G4ChordFinderDelegate<G4IntegrationDriver<G4BulirschStoer>>
0046 {
0047   public:
0048 
0049     G4IntegrationDriver( G4double hminimum,
0050                          G4BulirschStoer* stepper,
0051                          G4int numberOfComponents = 6,
0052                          G4int statisticsVerbosity = 1);
0053 
0054     ~G4IntegrationDriver() = default;
0055 
0056     G4IntegrationDriver(const G4IntegrationDriver&) = delete;
0057     G4IntegrationDriver& operator=(const G4IntegrationDriver&) = delete;
0058 
0059     virtual G4double AdvanceChordLimited(G4FieldTrack& track,
0060                                          G4double hstep,
0061                                          G4double eps,
0062                                          G4double chordDistance) override
0063     {
0064       return ChordFinderDelegate::
0065              AdvanceChordLimitedImpl(track, hstep, eps, chordDistance);
0066     }
0067 
0068     virtual void OnStartTracking() override
0069     {
0070       ChordFinderDelegate::ResetStepEstimate();
0071     }
0072 
0073     virtual void OnComputeStep(const G4FieldTrack*  = nullptr) override {};
0074 
0075     virtual G4bool DoesReIntegrate() const override { return false; }  
0076    
0077     virtual G4bool AccurateAdvance( G4FieldTrack& track,
0078                                     G4double stepLen,
0079                                     G4double eps,
0080                                     G4double beginStep = 0) override;
0081 
0082     virtual G4bool QuickAdvance( G4FieldTrack& y_val,
0083                                  const G4double dydx[],
0084                                  G4double hstep,
0085                                  G4double& missDist,
0086                                  G4double& dyerr) override;
0087 
0088     void OneGoodStep( G4double y[],
0089                       const G4double dydx[],
0090                       G4double& curveLength,
0091                       G4double htry,
0092                       G4double eps,
0093                       G4double& hdid,
0094                       G4double& hnext);
0095 
0096     virtual void GetDerivatives( const G4FieldTrack& track,
0097                                  G4double dydx[]) const override;
0098 
0099     virtual void GetDerivatives( const G4FieldTrack& track,
0100                                  G4double dydx[],
0101                                  G4double field[]) const override;
0102 
0103     virtual void SetVerboseLevel(G4int level) override;
0104     virtual G4int GetVerboseLevel() const override;
0105 
0106     virtual G4double ComputeNewStepSize(
0107                           G4double  errMaxNorm,    
0108                           G4double  hstepCurrent) override; 
0109 
0110     virtual G4EquationOfMotion* GetEquationOfMotion() override;
0111     const G4EquationOfMotion* GetEquationOfMotion() const;
0112     virtual void SetEquationOfMotion(G4EquationOfMotion* equation) override;
0113 
0114     virtual const G4MagIntegratorStepper* GetStepper() const override;
0115     virtual G4MagIntegratorStepper* GetStepper() override;
0116 
0117     virtual void  StreamInfo( std::ostream& os ) const override;
0118      
0119    
0120   private:
0121 
0122     G4int GetNumberOfVarialbles() const;
0123 
0124     G4double fMinimumStep;
0125     G4double fVerbosity;
0126 
0127     G4ModifiedMidpoint fMidpointMethod;
0128     G4BulirschStoer* bulirschStoer;
0129 
0130     G4double yIn[G4FieldTrack::ncompSVEC],
0131              yMid[G4FieldTrack::ncompSVEC],
0132              yMid2[G4FieldTrack::ncompSVEC],
0133              yOut[G4FieldTrack::ncompSVEC],
0134              yOut2[G4FieldTrack::ncompSVEC],
0135              yError[G4FieldTrack::ncompSVEC];
0136 
0137 
0138     G4double dydxCurrent[G4FieldTrack::ncompSVEC];
0139     G4double yCurrent[G4FieldTrack::ncompSVEC];
0140 
0141     G4double derivs[2][6][G4FieldTrack::ncompSVEC];
0142 
0143     const G4int interval_sequence[2];
0144 
0145     using ChordFinderDelegate =
0146           G4ChordFinderDelegate<G4IntegrationDriver<G4BulirschStoer>>;
0147 };
0148 
0149 #include "G4BulirschStoerDriver.icc"
0150 
0151 #endif