33 const double mm2m = 0.001;
46 const double Amax1 = 1;
47 const double Amax2 = 3;
48 const double Amin = -2;
51 const double h1 = 0.03;
52 const double h2 = 0.2;
53 const double justAnotherFudgeFactor = 1 / 2.78;
56 const double const3 = -(Amax1 - Amin) * h1 *
log10;
57 const double const4 = (Amax2 - Amin) * h2 *
log10;
59 const double &tcr1 =
rmin_m;
60 const double &tcr2 =
rmax_m;
62 const double &magnitude =
bmax_m;
67 if (2 * r < (tcr2 + tcr1)) {
68 part1 =
std::pow(10.0, ((r - tcr1) * slope - x01) * h1);
69 part2 =
std::pow(10.0, -((r - tcr1) * slope - x02) * h2);
71 part1 =
std::pow(10.0, ((tcr2 - r) * slope - x01) * h1);
72 part2 =
std::pow(10.0, -((tcr2 - r) * slope - x02) * h2);
75 const double part1plusinv = 1 / (1 + part1);
76 const double part2plusinv = 1 / (1 + part2);
78 double part3 = const3 * slope * part1 * part1plusinv * part1plusinv;
79 double part4 = const4 * slope * part2 * part2plusinv * part2plusinv;
81 const double constmag = magnitude * justAnotherFudgeFactor;
83 double dr = constmag * (part3 + part4);
84 double btr = constmag * (Amin - 1 +
85 (Amax1 - Amin) * part1plusinv +
86 (Amax2 - Amin) * part2plusinv);
90 ERRORMSG(
"r = " << r <<
" m, tcr1 = " << tcr1 <<
" m, tcr2 = " << tcr2 <<
" m\n");
91 ERRORMSG(
"slope = " << slope <<
", magnitude = " << magnitude <<
" kG\n");
92 ERRORMSG(
"part1 = " << part1 <<
", part2 = " << part2 <<
"\n");
93 ERRORMSG(
"part3 = " << part3 <<
", part4 = " << part4 <<
endl);
95 "dr or btr yield results that are either nan or inf");
Tps< T > log(const Tps< T > &x)
Natural logarithm.
Tps< T > pow(const Tps< T > &x, int y)
Integer power.
PETE_TUTree< FnLog10, typename T::PETE_Expr_t > log10(const PETE_Expr< T > &l)
Inform & endl(Inform &inf)
T isinf(T x)
isinf function with adjusted return type
T isnan(T x)
isnan function with adjusted return type
double bmax_m
Maximum B field (kG)
double rmax_m
Maximum radius (m)
double rmin_m
Minimum radius (m)
TrimCoilMirrored()=delete
double bslope_m
Slope in (1 / mm)
virtual void doApplyField(const double r, const double z, const double phi_rad, double *br, double *bz)
virtual implementation of applyField