Added the analytical approximation for the magnetic
field in the P8 LFA scenario: Ioffe: infinite wire approximations Bottle: Gaussian profile in Bz
This commit is contained in:
@@ -95,6 +95,9 @@ std::shared_ptr<VectorField> buildVectorField(json_t* object) {
|
||||
|
||||
return std::make_shared<VectorFieldFromArray>(
|
||||
v_radial, v_azimuthal, v_longitudinal, radius, length);
|
||||
} else if (json_object_by_path(object, {"PredefinedLFAMagneticField"})) {
|
||||
SIM_INFO("Warn: The predefined function is a magnetic field!!!");
|
||||
return std::shared_ptr<VectorField>(new PredefinedMagneticVectorFieldLFA());
|
||||
} else {
|
||||
ERROR("This vector field is not implemented");
|
||||
return nullptr;
|
||||
|
||||
@@ -58,4 +58,92 @@ CylinderVector VectorFieldFunctionInZ::value(
|
||||
return CylinderVector(blitz::TinyVector<double, 3>(
|
||||
0., 0.,
|
||||
F_z_(cylinder_position(0), cylinder_position(1), cylinder_position(2))));
|
||||
}
|
||||
|
||||
PredefinedMagneticVectorFieldLFA::PredefinedMagneticVectorFieldLFA() {
|
||||
double theta = M_PI/64.;
|
||||
for(int i = 0; i < 128; ++i) {
|
||||
cosktheta(i) = std::cos(i*theta);
|
||||
sinktheta(i) = std::sin(i*theta);
|
||||
}
|
||||
|
||||
z1 = 0.1;
|
||||
z2 = RIoffe*cosa/sina;
|
||||
zoffset = 6e-3/sina;
|
||||
}
|
||||
|
||||
// does not make use of the transition functions!!!
|
||||
CylinderVector PredefinedMagneticVectorFieldLFA::value(const Coordinate& coordinate) const {
|
||||
// Important that coordinate is a CartesianCoordinate since the transformation from
|
||||
// CylinderCoordinate to CartesianCoordinate does not work, since phi is not tracked
|
||||
blitz::TinyVector<double, 3> cartPos = coordinate.cartesianEntries();
|
||||
double x = cartPos(0); double y = cartPos(1); double z = cartPos(2) + zoffset;
|
||||
double r = std::sqrt(x*x + y*y);
|
||||
double Bx, By, Bz;
|
||||
|
||||
Bx = 0;
|
||||
By = 0;
|
||||
Bz = 0;
|
||||
|
||||
double Dp = x*x + y*y + z*z;
|
||||
double D0 = x*x + y*y + RIoffe*RIoffe;
|
||||
|
||||
double Dpk_plus, Dpk_minus, D0k;
|
||||
|
||||
// loop to gather cylinder Ioffe contribution
|
||||
double sign = -1;
|
||||
for(int i = 0; i < 128; ++i) {
|
||||
sign *= -1;
|
||||
|
||||
D0k = 2*RIoffe*(x*cosktheta(i) + y*sinktheta(i));
|
||||
|
||||
Bx += sign*(y - RIoffe*sinktheta(i))/(D0 - D0k);
|
||||
By += sign*(RIoffe*cosktheta(i) - x)/(D0 - D0k);
|
||||
}
|
||||
|
||||
// only consider the cone contibution close to the cone
|
||||
if(z < 1.2*z1) {
|
||||
// loop to gather the cone Ioffe contribution
|
||||
for(int i = 0; i < 128; i+=4) {
|
||||
// positive current contribution at index i
|
||||
Dpk_plus = x*sina*cosktheta(i) + y*sina*sinktheta(i) + z*cosa;
|
||||
// negative current contribution at index i+1
|
||||
Dpk_minus = x*sina*cosktheta(i+1) + y*sina*sinktheta(i+1) + z*cosa;
|
||||
|
||||
Bx += (z*sina*sinktheta(i) - y*cosa)/(Dp - Dpk_plus*Dpk_plus) -
|
||||
(z*sina*sinktheta(i+1) - y*cosa)/(Dp - Dpk_minus*Dpk_minus);
|
||||
|
||||
By += (x*cosa - z*sina*cosktheta(i) )/(Dp - Dpk_plus*Dpk_plus) -
|
||||
(x*cosa - z*sina*cosktheta(i+1))/(Dp - Dpk_minus*Dpk_minus);
|
||||
|
||||
Bz += (y*sina*cosktheta(i) - x*sina*sinktheta(i) )/(Dp - Dpk_plus*Dpk_plus) -
|
||||
(y*sina*cosktheta(i+1) - x*sina*sinktheta(i+1))/(Dp - Dpk_minus*Dpk_minus);
|
||||
}
|
||||
}
|
||||
|
||||
Bx *= B0Ioffe;
|
||||
By *= B0Ioffe;
|
||||
Bz *= B0Ioffe;
|
||||
|
||||
|
||||
// Magnetic Bottle
|
||||
// assume the peak is located 2m away from the transition from cone to cylinder
|
||||
double zg0 = z1 + 2; // m
|
||||
double sig2 = 0.211954; // m^2
|
||||
double B0g = 3.07e-4; // T
|
||||
|
||||
double Bzg = std::exp(-(z - zg0)*(z - zg0)/sig2)*B0g;
|
||||
double Bxg = x*(z-zg0)/sig2*Bzg;
|
||||
double Byg = y*(z-zg0)/sig2*Bzg;
|
||||
|
||||
// add all contributions
|
||||
Bx += Bxg;
|
||||
By += Byg;
|
||||
Bz += Bzg + Bbg;
|
||||
|
||||
// transformation into cylinder vector
|
||||
double Br = Bx*x/r + By*y/r;
|
||||
double Bphi = By*x/r - Bx*y/r;
|
||||
|
||||
return CylinderVector(blitz::TinyVector<double, 3>(Br, Bphi, Bz));
|
||||
}
|
||||
Reference in New Issue
Block a user