File indexing completed on 2026-09-08 09:10:34
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 #ifndef G4QSS_STEPPER_HH
0034 #define G4QSS_STEPPER_HH
0035
0036 #include "G4FieldTrack.hh"
0037 #include "G4MagIntegratorStepper.hh"
0038 #include "G4QSSubstepStruct.hh"
0039
0040 #include <cmath>
0041 #include <CLHEP/Units/PhysicalConstants.h>
0042
0043
0044
0045
0046
0047
0048 class G4QSStepper : public G4MagIntegratorStepper
0049 {
0050 public:
0051
0052
0053
0054
0055
0056
0057
0058
0059 G4QSStepper( G4EquationOfMotion* equation,
0060 G4int num_integration_vars = 6,
0061 G4int qssOrder= -1 );
0062
0063
0064
0065
0066 ~G4QSStepper() override = default;
0067
0068
0069
0070
0071 inline constexpr G4double Cubic_Function(const QSStateVector* states,
0072 G4int index, G4double delta_t);
0073 inline constexpr G4double Parabolic_Function(const QSStateVector* states,
0074 G4int index, G4double delta_t);
0075 inline constexpr G4double Linear_Function(const QSStateVector* states,
0076 G4int index, G4double delta_t);
0077
0078
0079
0080
0081 inline constexpr int INDEX_TYPE(G4int i);
0082
0083
0084
0085
0086 inline void momentum_to_velocity(const G4double* momentum, G4double* out);
0087 void set_relativistic_coeff(const G4double* momentum);
0088 inline void velocity_to_momentum(G4double *y);
0089
0090
0091
0092
0093 void initialize(const G4double y[]);
0094 inline void compare_time_and_update(G4int& index, G4int i);
0095 inline G4int get_next_sync_index();
0096 inline void update_field();
0097 inline G4double extrapolate_polynomial(QSStateVector* states,
0098 G4int index, G4double delta_t, G4int order);
0099 inline void extrapolate_all_states_to_t(Substep* substep,
0100 G4double t, G4double* yOut);
0101
0102
0103
0104
0105 inline void update_x(G4int index, G4double t);
0106
0107
0108
0109
0110 inline void update_q(G4int index, G4double t);
0111
0112
0113
0114
0115 inline void update_x_position_derivates_using_q(G4int index);
0116 inline void update_x_velocity_derivates_using_q(G4int index);
0117 inline void update_x_derivates_using_q(G4int index);
0118 inline void update_sync_time_one_coefficient(G4int index);
0119
0120
0121
0122
0123
0124 void update_sync_time(G4int index);
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136 void Stepper( const G4double y[],
0137 const G4double [],
0138 G4double h,
0139 G4double yout[],
0140 G4double [] ) override;
0141
0142
0143
0144
0145 inline G4int IntegratorOrder() const override;
0146
0147
0148
0149
0150 inline G4StepperType StepperType() const override { return kQSStepper; }
0151
0152
0153
0154
0155 inline G4EquationOfMotion* GetSpecificEquation();
0156
0157
0158
0159
0160 inline const field_utils::State& GetYOut() const;
0161
0162
0163
0164
0165
0166
0167 void Interpolate(G4double tau, G4double yOut[]);
0168
0169
0170
0171
0172 inline G4double DistChord() const override;
0173
0174
0175
0176
0177 inline void Stepper(const G4double yInput[],
0178 const G4double dydx[],
0179 G4double hstep,
0180 G4double yOutput[],
0181 G4double yError[],
0182 G4double []);
0183
0184
0185
0186
0187 inline void SetupInterpolation();
0188
0189
0190
0191
0192 inline void reset(const G4FieldTrack* track);
0193 inline void SetPrecision(G4double dq_rel, G4double dq_min);
0194 inline G4double GetLastStepLength();
0195
0196
0197
0198
0199 inline void setRestMass(G4double restMass);
0200
0201 private:
0202
0203
0204
0205 static constexpr int DERIVATIVE_0{0};
0206 static constexpr int DERIVATIVE_1{1};
0207 static constexpr int DERIVATIVE_2{2};
0208 static constexpr int DERIVATIVE_3{3};
0209
0210 static constexpr int VX{3};
0211 static constexpr int VY{4};
0212 static constexpr int VZ{5};
0213
0214 static constexpr int POSITION_IDX{0};
0215 static constexpr int VELOCITY_IDX{3};
0216
0217 static constexpr G4double INFTY{1e+20};
0218
0219
0220 G4bool fField_changed{true};
0221 G4bool fTrack_changed{true};
0222
0223 const G4int qss_order{2};
0224
0225 Substeps substeps;
0226 Substep current_substep;
0227 const G4FieldTrack* fCurrent_track{nullptr};
0228 QSStateVector dq_vector;
0229
0230
0231 G4double fCharge{-1.0};
0232 G4double fCharge_c2;
0233 G4double fRestMass{CLHEP::electron_mass_c2};
0234 G4double fGamma{1.0};
0235 G4double fCoeff;
0236
0237
0238 G4double fMassOverC ;
0239 G4double fInv_mass_over_c;
0240
0241
0242 G4double fYout[12];
0243
0244
0245 G4double dqrel[2] = {0.0,0.0};
0246 G4double dqmin[2] = {0.001,0.001};
0247
0248 G4double fVelocity{0.0};
0249 G4double fFinal_t{0.0};
0250 };
0251
0252
0253
0254
0255
0256 #include "G4QSStepper.icc"
0257
0258 #endif