12.07.2015 Views

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Detector Definition and ResponseAn example with an electric field is examples/extended/field/field02, where the class F02ElectricFieldSetupdemonstrates how to set these and other parameters, and how to choose different Integration Steppers.The user can also create their own type of field, inheriting from G4VField, and an associated Equation of Motionclass (inheriting from G4EqRhs) to simulate other types of fields.4.3.2.4. Choosing a StepperRunge-Kutta integration is used to compute the motion of a charged track in a general field. There are manygeneral steppers from which to choose, of low and high order, and specialized steppers <strong>for</strong> pure magnetic fields.By default, <strong>Geant4</strong> uses the classical fourth-order Runge-Kutta stepper, which is general purpose and robust. Ifthe field is known to have specific properties, lower or higher order steppers can be used to obtain the same qualityresults using fewer computing cycles.In particular, if the field is calculated from a field map, a lower order stepper is recommended. The less smooththe field is, the lower the order of the stepper that should be used. The choice of lower order steppers includes thethird order stepper G4SimpleHeum, the second order G4ImplicitEuler and G4SimpleRunge, and thefirst order G4ExplicitEuler. A first order stepper would be useful only <strong>for</strong> very rough fields. For somewhatsmooth fields (intermediate), the choice between second and third order steppers should be made by trial and error.Trying a few different types of steppers <strong>for</strong> a particular field or application is suggested if maximum per<strong>for</strong>manceis a goal.The choice of stepper depends on the type of field: magnetic or general. A general field can be an electric orelectromagnetic field, it can be a magnetic field or a user-defined field (which requires a user-defined equation ofmotion.) For a general field several steppers are available as alternatives to the default (G4ClassicalRK4):G4int nvar = 8; // To integrate time & energy// in addition to position, momentumG4EqMagElectricField* fEquation= new G4EqMagElectricField(fEMfield);fStepper = new G4SimpleHeum( fEquation, nvar );// 3rd order, a good alternative to ClassicalRKfStepper = new G4SimpleRunge( fEquation, nvar );// 2nd order, <strong>for</strong> less smooth fieldsfStepper = new G4CashKarpRKF45( fEquation );// 4/5th order <strong>for</strong> very smooth fieldsSpecialized steppers <strong>for</strong> pure magnetic fields are also available. They take into account the fact that a local trajectoryin a slowly varying field will not vary significantly from a helix. Combining this in with a variation theRunge-Kutta method can provide higher accuracy at lower computational cost when large steps are possible.G4Mag_UsualEqRhs*fEquation = new G4Mag_UsualEqRhs(fMagneticField);fStepper = new G4HelixImplicitEuler( fEquation );// Note that <strong>for</strong> magnetic field that do not vary with time,// the default number of variables suffices.// or ..fStepper = new G4HelixExplicitEuler( fEquation );fStepper = new G4HelixSimpleRunge( fEquation );A new stepper <strong>for</strong> propagation in magnetic field is available in release 9.3. Choosing the G4NystromRK4 stepperprovides accuracy near that of G4ClassicalRK4 (4th order) with a significantly reduced cost in field evaluation.Using a novel analytical expression <strong>for</strong> estimating the error of a proposed step and the Nystrom reuse of the midpointfield value, it requires only 2 additional field evaluations per attempted step, in place of 10 field evaluationsof ClassicalRK4 (which uses the general midpoint method <strong>for</strong> estimating the step error.)G4Mag_UsualEqRhs*pMagFldEquation = new G4Mag_UsualEqRhs(fMagneticField);fStepper = new G4NystromRK4( pMagFldEquation );121

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!