java.lang.Object
simpa.core.api.utils.CalculatorUtils
Utilities for calculation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic double
evToJoules
(double ev) Convert from electron volts to Joulesstatic org.apache.commons.math3.geometry.euclidean.threed.Vector3D
getAVector
(PotentialProvider afp, org.apache.commons.math3.geometry.euclidean.threed.Vector3D pos) Evaluates the vector potential at the given position from the given PotentialProvider instance.static org.apache.commons.math3.geometry.euclidean.threed.Vector3D
getBField
(double[][] pots) Takes the curl of the given potential and derivatives and calculates the B.static org.apache.commons.math3.geometry.euclidean.threed.Vector3D
getBField
(PotentialProvider pp, org.apache.commons.math3.geometry.euclidean.threed.Vector3D pos) Evaluates the magnetic field at the given position from the given PotentialProvider instance.static org.apache.commons.math3.geometry.euclidean.threed.Vector3D
getEField
(double[][] pots) Returns the electric field derived from a two-dimensional double array with the potential and gradients.static org.apache.commons.math3.geometry.euclidean.threed.Vector3D
getEField
(PotentialProvider pp, org.apache.commons.math3.geometry.euclidean.threed.Vector3D pos) Evaluates the electric field at the given position from the given PotentialProvider instance.static double
getKineticEnergy
(Particle part) Gets the kinetic energy of the given particle.static double
getMomentumFromGeVoC
(double pInGev) Convert the momentum given in GeV/c to kg*m/s.static double
getMomentumInGeVoC
(double momentum) Convert the momentum given in kg*m/s to GeV/c.static double
getScalarPotential
(PotentialProvider afp, org.apache.commons.math3.geometry.euclidean.threed.Vector3D pos) Evaluates the scalar potential at the given position from the given PotentialProvider instance.static double
getTotalEnergy
(Particle part) Gets the total energy of the given particle.static double
getVelocityAbsValue
(Particle part) Gets the velocity of the given particle as an absolute value.static double
joulesToEv
(double joules) Convert from Joules to electron volts
-
Constructor Details
-
CalculatorUtils
public CalculatorUtils()
-
-
Method Details
-
getBField
public static org.apache.commons.math3.geometry.euclidean.threed.Vector3D getBField(PotentialProvider pp, org.apache.commons.math3.geometry.euclidean.threed.Vector3D pos) throws OutOfApertureException, KnownFatalException Evaluates the magnetic field at the given position from the given PotentialProvider instance. This should not be directly used for tracking. It is intended for diagnostic.- Parameters:
pp
- - A PotentialProvider instance.pos
- - The position of the field evaluation.- Returns:
- - The B field.
- Throws:
OutOfApertureException
- when the pos attribute is outside the region of interest.KnownFatalException
- when an internal error happens.
-
getBField
public static org.apache.commons.math3.geometry.euclidean.threed.Vector3D getBField(double[][] pots) Takes the curl of the given potential and derivatives and calculates the B.- Parameters:
pots
- -The potentials and the derivatives- Returns:
- - The B field
-
getEField
public static org.apache.commons.math3.geometry.euclidean.threed.Vector3D getEField(PotentialProvider pp, org.apache.commons.math3.geometry.euclidean.threed.Vector3D pos) throws OutOfApertureException, KnownFatalException Evaluates the electric field at the given position from the given PotentialProvider instance. This should not be directly used for tracking. It is intended for diagnostic.- Parameters:
pp
- - A PotentialProvider instance.pos
- - The position of the field evaluation.- Returns:
- - The E field.
- Throws:
OutOfApertureException
- when the pos attribute is outside the region of interest.KnownFatalException
- when an internal error happens.
-
getEField
public static org.apache.commons.math3.geometry.euclidean.threed.Vector3D getEField(double[][] pots) Returns the electric field derived from a two-dimensional double array with the potential and gradients.- Parameters:
pots
- - double array with the potential and gradients- Returns:
- the E field
-
getAVector
public static org.apache.commons.math3.geometry.euclidean.threed.Vector3D getAVector(PotentialProvider afp, org.apache.commons.math3.geometry.euclidean.threed.Vector3D pos) throws OutOfApertureException, KnownFatalException Evaluates the vector potential at the given position from the given PotentialProvider instance. This should not be directly used for tracking. It is intended for diagnostic.- Parameters:
afp
- - A PotentialProvider instance.pos
- - The position of the field evaluation.- Returns:
- - The vector potential.
- Throws:
OutOfApertureException
- when the pos attribute is outside the region of interest.KnownFatalException
- when an internal error happens.
-
getScalarPotential
public static double getScalarPotential(PotentialProvider afp, org.apache.commons.math3.geometry.euclidean.threed.Vector3D pos) throws OutOfApertureException, KnownFatalException Evaluates the scalar potential at the given position from the given PotentialProvider instance. This should not be directly used for tracking. It is intended for diagnostic.- Parameters:
afp
- - A PotentialProvider instance.pos
- - The position of the evaluation.- Returns:
- - The scalar potential.
- Throws:
OutOfApertureException
- when the pos attribute is outside the region of interest.KnownFatalException
- when an internal error happens.
-
getVelocityAbsValue
Gets the velocity of the given particle as an absolute value.- Parameters:
part
- particle object- Returns:
- Norm of the velocity vector in [m/s]
-
getTotalEnergy
Gets the total energy of the given particle.- Parameters:
part
- particle object- Returns:
- Total energy in [Joule or kg*m^2/s^2]
-
getKineticEnergy
Gets the kinetic energy of the given particle.- Parameters:
part
- particle object- Returns:
- Kinetic energy in [Joule or kg*m^2/s^2]
-
joulesToEv
public static double joulesToEv(double joules) Convert from Joules to electron volts- Parameters:
joules
- amount of joules- Returns:
- electron volts
-
evToJoules
public static double evToJoules(double ev) Convert from electron volts to Joules- Parameters:
ev
- electron volts- Returns:
- Joules
-
getMomentumFromGeVoC
public static double getMomentumFromGeVoC(double pInGev) Convert the momentum given in GeV/c to kg*m/s.- Parameters:
pInGev
- The magnitude of the momentum given in [GeV/c].- Returns:
- The momentum in units of [kg*m/s]
-
getMomentumInGeVoC
public static double getMomentumInGeVoC(double momentum) Convert the momentum given in kg*m/s to GeV/c.- Parameters:
momentum
- The magnitude of the momentum given in [kg*m/s]- Returns:
- The momentum in units of [GeV/c].
-