BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSIntegratorG4RK4MinStep.cc
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#include "BDSIntegratorG4RK4MinStep.hh"
19#include "BDSUtilities.hh"
20
21#include "G4ClassicalRK4.hh"
22#include "G4Mag_EqRhs.hh"
23#include "G4MagIntegratorStepper.hh"
24
26 G4double minimumStepSizeIn):
27 BDSIntegratorMag(eqOfMIn, 6),
28 g4integrator(new G4ClassicalRK4(eqOfMIn, 6)),
29 minimumStepSize(minimumStepSizeIn)
30{;}
31
32BDSIntegratorG4RK4MinStep::~BDSIntegratorG4RK4MinStep()
33{
34 delete g4integrator;
35}
36
37void BDSIntegratorG4RK4MinStep::Stepper(const G4double yIn[],
38 const G4double dydx[],
39 const G4double h,
40 G4double yOut[],
41 G4double yErr[])
42{
43 // in case of zero field or neutral particles do a linear step
44 const G4double fcof = eqOfM->FCof();
45 if (!BDS::IsFiniteStrength(fcof) || h < minimumStepSize)
46 {
47 AdvanceDriftMag(yIn,h,yOut,yErr);
48 SetDistChord(0);
49 return;
50 }
51 else
52 {
53 g4integrator->Stepper(yIn, dydx, h, yOut, yErr);
54 return;
55 }
56}
57
58
void AdvanceDriftMag(const G4double yIn[], const G4double h, G4double yOut[], G4double yErr[]) const
Error array [6] all 0.
virtual void Stepper(const G4double y[], const G4double dydx[], const G4double h, G4double yOut[], G4double yErr[])
BDSIntegratorG4RK4MinStep()
Private default constructor to enforce use of supplied constructor.
Common functionality to BDSIM integrators.
G4Mag_EqRhs * eqOfM
void SetDistChord(G4double distChordIn)
Setter for distChord to private member.
G4bool IsFiniteStrength(G4double variable)