19#include "BDSFieldMagDipole.hh"
20#include "BDSFieldMagDipoleOuterOld.hh"
21#include "BDSMagnetStrength.hh"
24#include "G4ThreeVector.hh"
26#include "CLHEP/Units/PhysicalConstants.h"
27#include "CLHEP/Units/SystemOfUnits.h"
32G4double BDSFieldMagDipoleOuterOld::transitionLengthScale = 1*CLHEP::cm;
34BDSFieldMagDipoleOuterOld::BDSFieldMagDipoleOuterOld(
const BDSMagnetStrength* strength,
35 G4double poleTipRadiusIn,
36 G4double arbitraryScaling):
37 poleTipRadius(poleTipRadiusIn),
42 localField = innerField->
GetField(G4ThreeVector(0,0,0));
43 m = localField.unit();
45 G4ThreeVector normalisationPoint = m*poleTipRadius;
46 G4ThreeVector innerFieldValue = innerField->
GetField(normalisationPoint);
47 G4ThreeVector outerFieldValue = GetField(normalisationPoint);
49 normalisation = arbitraryScaling * innerFieldValue.mag() / outerFieldValue.mag();
50 if (std::isnan(normalisation))
53 finiteStrength =
false;
60 const G4double )
const
63 {
return G4ThreeVector();}
64 G4double rmag = position.mag();
70 G4ThreeVector b = 3*position*(
m.dot(position))/std::pow(rmag,5) -
m/std::pow(rmag,3);
77 G4double weight = (std::tanh(3*(rmag - std::abs(0.5*
poleTipRadius))/(transitionLengthScale)) + 1) / 2.0;
78 if (std::abs(weight) > 0.99 || std::abs(weight) < 0.01)
79 {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.