15 const double mm2m = 0.001;
28 const double Amax1 = 1;
29 const double Amax2 = 3;
30 const double Amin = -2;
33 const double h1 = 0.03;
34 const double h2 = 0.2;
35 const double justAnotherFudgeFactor = 1 / 2.78;
38 const double const3 = -(Amax1 - Amin) * h1 * log10;
39 const double const4 = (Amax2 - Amin) * h2 * log10;
41 const double &tcr1 =
rmin_m;
42 const double &tcr2 =
rmax_m;
44 const double &magnitude =
bmax_m;
49 if (2 * r < (tcr2 + tcr1)) {
50 part1 =
std::pow(10.0, ((r - tcr1) * slope - x01) * h1);
51 part2 =
std::pow(10.0, -((r - tcr1) * slope - x02) * h2);
53 part1 =
std::pow(10.0, ((tcr2 - r) * slope - x01) * h1);
54 part2 =
std::pow(10.0, -((tcr2 - r) * slope - x02) * h2);
57 const double part1plusinv = 1 / (1 + part1);
58 const double part2plusinv = 1 / (1 + part2);
60 double part3 = const3 * slope * part1 * part1plusinv * part1plusinv;
61 double part4 = const4 * slope * part2 * part2plusinv * part2plusinv;
63 const double constmag = magnitude * justAnotherFudgeFactor;
65 double dr = constmag * (part3 + part4);
66 double btr = constmag * (Amin - 1 +
67 (Amax1 - Amin) * part1plusinv +
68 (Amax2 - Amin) * part2plusinv);
72 ERRORMSG(
"r = " << r <<
" m, tcr1 = " << tcr1 <<
" m, tcr2 = " << tcr2 <<
" m\n");
73 ERRORMSG(
"slope = " << slope <<
", magnitude = " << magnitude <<
" kG\n");
74 ERRORMSG(
"part1 = " << part1 <<
", part2 = " << part2 <<
"\n");
75 ERRORMSG(
"part3 = " << part3 <<
", part4 = " << part4 <<
endl);
77 "dr or btr yield results that are either nan or inf");
double bmax_m
Maximum B field (kG)
TrimCoilMirrored()=delete
Tps< T > log(const Tps< T > &x)
Natural logarithm.
double rmax_m
Maximum radius (m)
double bslope_m
Slope in (1 / mm)
Tps< T > pow(const Tps< T > &x, int y)
Integer power.
double rmin_m
Minimum radius (m)
T isnan(T x)
isnan function with adjusted return type
virtual void doApplyField(const double r, const double z, const double phi_rad, double *br, double *bz)
virtual implementation of applyField
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