19#include "BDSFieldMagDipole.hh"
20#include "BDSFieldMagDipoleOuter.hh"
21#include "BDSMagnetStrength.hh"
24#include "G4ThreeVector.hh"
26#include "CLHEP/Units/PhysicalConstants.h"
27#include "CLHEP/Units/SystemOfUnits.h"
32G4double BDSFieldMagDipoleOuter::transitionLengthScale = 1*CLHEP::cm;
35 const G4double& poleTipRadiusIn,
36 G4double arbitraryScaling):
37 spatialLimit(0.05*poleTipRadiusIn),
38 poleTipRadius(poleTipRadiusIn),
41 initialisationPhase(true)
45 localField = innerField->
GetField(G4ThreeVector(0,0,0));
46 m = localField.unit();
48 G4ThreeVector normalisationPoint = m*poleTipRadius;
49 G4ThreeVector innerFieldValue = innerField->
GetField(normalisationPoint);
50 G4ThreeVector outerFieldValue = GetField(normalisationPoint);
53 maxField = innerFieldValue.mag() * arbitraryScaling;
55 normalisation = maxField / outerFieldValue.mag();
56 normalisation *= arbitraryScaling;
57 if (std::isnan(normalisation))
60 finiteStrength =
false;
62 initialisationPhase =
false;
67 const G4double )
const
70 {
return G4ThreeVector();}
71 G4double rmag = position.mag();
77 G4ThreeVector b = 3*position*(
m.dot(position))/std::pow(rmag,5) -
m/std::pow(rmag,3);
82 G4double weight = (std::tanh(3*(rmag - std::abs(0.5*
poleTipRadius))/(transitionLengthScale)) + 1) / 2.0;
83 if (std::abs(weight) > 0.99 || std::abs(weight) < 0.01)
84 {weight = std::round(weight);}
virtual G4ThreeVector GetField(const G4ThreeVector &position, const double t=0) const
Access the field value.
G4ThreeVector m
Dipole moment as unit vector of field direction.
G4double normalisation
Storage of the overal normalisation factor.
G4bool initialisationPhase
Need a way to control cludge normalisation behaviour during initial normalisation calculation.
G4double poleTipRadius
Used as radial limit for returning normal field.
G4double maxField
Any field beyond this will curtailed to this value.
G4double spatialLimit
Limit for getting too close to a current source.
G4ThreeVector localField
Nominal dipole field.
virtual G4ThreeVector GetField(const G4ThreeVector &position, const G4double t=0) const
Access the field value.
G4bool finiteStrength
Flag to cache whether finite nor not.
Efficient storage of magnet strengths.