# Class PropagationBP¶

## Class Documentation¶

class PropagationBP : public Module

Propagation through magnetic fields using the Boris method.

This module solves the equations of motion of a relativistic charged particle when propagating through a magnetic field.

It uses the Boris push integration method.

It can be used with a fixed step size or an adaptive version which supports the step size control. The step size control tries to keep the relative error close to, but smaller than the designated tolerance. Additionally a minimum and maximum size for the steps can be set. For neutral particles a rectilinear propagation is applied and a next step of the maximum step size proposed.

Public Functions

PropagationBP(ref_ptr<MagneticField> field = NULL, double fixedStep = (1. *kpc))

maximum step size of the propagation Default constructor for the Boris push. It is constructed with a fixed step size.

Parameters
• field:
• fixedStep:

PropagationBP(ref_ptr<MagneticField> field, double tolerance, double minStep, double maxStep)

Constructor for the adaptive Boris push.

Parameters
• field:
• tolerance: tolerance is criterion for step adjustment. Step adjustment takes place only if minStep < maxStep
• minStep: minStep/c_light is the minimum integration timestep
• maxStep: maxStep/c_light is the maximum integration timestep.

void process(Candidate *candidate) const

Propagates the particle. Is called once per iteration.

Parameters
• candidate: The Candidate is a passive object, that holds the information about the state of the cosmic ray and the simulation itself.

PropagationBP::Y dY(Vector3d pos, Vector3d dir, double step, double z, double q, double m) const

Calculates the new position and direction of the particle based on the solution of the Lorentz force

Return
return the new calculated position and direction of the candidate
Parameters
• pos: current position of the candidate
• dir: current direction of the candidate
• step: current step size of the candidate
• z: current redshift is needed to calculate the magnetic field
• q: current charge of the candidate
• m: current mass of the candidate

double errorEstimation(const Vector3d x1, const Vector3d x2, double step) const

comparison of the position after one step with the position after two steps with step/2.

Return
measurement of the error of the step
Parameters
• x1: position after one step of size step
• x2: position after two steps of size step/2
• step: current step size

Vector3d getFieldAtPosition(Vector3d pos, double z) const

get magnetic field vector at current candidate position

Return
magnetic field vector at the position pos
Parameters
• pos: current position of the candidate
• z: current redshift is needed to calculate the magnetic field

void tryStep(const Y &y, Y &out, Y &error, double h, ParticleState &p, double z, double m, double q) const

Adapte step size if required and calculates the new position and direction of the particle with the usage of the function dY

Parameters
• y: current position and direction of candidate
• out: position and direction of candidate after the step
• error: error for the current step
• h: current step size
• p: current particle state
• z: current red shift
• m: current mass of the candidate
• q: current charge of the candidate

void setField(ref_ptr<MagneticField> field)

set functions for the parameters of the class PropagationBP set a specific magnetic field

Parameters
• field: specific magnetic field

void setTolerance(double tolerance)

set a specific tolerance for the step size adaption

Parameters
• tolerance: tolerance is criterion for step adjustment. Step adjustment takes place only if minStep < maxStep.

void setMinimumStep(double minStep)

set the minimum step for the Boris push

Parameters
• minStep: minStep/c_light is the minimum integration time step

void setMaximumStep(double maxStep)

set the maximum step for the Boris push

Parameters
• maxStep: maxStep/c_light is the maximum integration time step

ref_ptr<MagneticField> getField() const

get functions for the parameters of the class PropagationBP, similar to the set functions

double getTolerance() const
double getMinimumStep() const
double getMaximumStep() const
std::string getDescription() const
void setDescription(const std::string &description)
void process(ref_ptr<Candidate> candidate) const
size_t addReference() const
size_t removeReference() const
int removeReferenceNoDelete() const
size_t getReferenceCount() const

Protected Attributes

size_t _referenceCount
class Y

Public Functions

Y()
Y(const Vector3d &x, const Vector3d &u)
Y(double f)
Y operator*(double f) const
Y &operator+=(const Y &y)

Public Members

Vector3d x
Vector3d u