18#include "BDSFieldMagDipole.hh"
19#include "BDSFieldMagDipoleOuterOld.hh"
20#include "BDSMagnetStrength.hh"
23#include "G4ThreeVector.hh"
25#include "CLHEP/Units/PhysicalConstants.h"
26#include "CLHEP/Units/SystemOfUnits.h"
31G4double BDSFieldMagDipoleOuterOld::transitionLengthScale = 1*CLHEP::cm;
33BDSFieldMagDipoleOuterOld::BDSFieldMagDipoleOuterOld(
const BDSMagnetStrength* strength,
34 G4double poleTipRadiusIn,
35 G4double arbitraryScaling):
36 poleTipRadius(poleTipRadiusIn),
41 localField = innerField->
GetField(G4ThreeVector(0,0,0));
42 m = localField.unit();
44 G4ThreeVector normalisationPoint = m*poleTipRadius;
45 G4ThreeVector innerFieldValue = innerField->
GetField(normalisationPoint);
46 G4ThreeVector outerFieldValue = GetField(normalisationPoint);
48 normalisation = arbitraryScaling * innerFieldValue.mag() / outerFieldValue.mag();
49 if (std::isnan(normalisation))
52 finiteStrength =
false;
59 const G4double )
const
62 {
return G4ThreeVector();}
63 G4double rmag = position.mag();
69 G4ThreeVector b = 3*position*(
m.dot(position))/std::pow(rmag,5) -
m/std::pow(rmag,3);
76 G4double weight = (std::tanh(3*(rmag - std::abs(0.5*
poleTipRadius))/(transitionLengthScale)) + 1) / 2.0;
77 if (std::abs(weight) > 0.99 || std::abs(weight) < 0.01)
78 {weight = std::round(weight);}
G4ThreeVector m
Dipole moment as unit vector of field direction.
G4double normalisation
Storage of the overal normalisation factor.
virtual G4ThreeVector GetField(const G4ThreeVector &position, const double t=0) const
Access the field value.
G4double poleTipRadius
Used as radial limit for returning normal field.
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.