3 #define M_PI 3.1415926535897932385
9 using namespace magfieldparam;
15 double w_0, w_1, B_mod = fabs(B);
16 if (B_mod <=
B_nom[0]) {
18 for (jj = 0; jj < 360; ++jj) {
19 C[jj] = w_0*
C0[jj][0];
21 }
else if (B_mod >=
B_nom[3]) {
23 for (jj = 0; jj < 360; ++jj) {
24 C[jj] = w_0*
C0[jj][3];
27 while (
B_nom[kk] < B_mod) ++kk;
34 for (jj = 0; jj < 360; ++jj) {
35 C[jj] = w_0*
C0[jj][kk-1] + w_1*
C0[jj][kk];
43 int jc,
k0 = 0, k1 = 1;
44 double dB2, dB = fabs(B);
47 for (jc = 0; jc < 360; ++jc)
C[jc] =
C0[jc][3] +
C1[jc][4]*dB;
50 dB2 = dB*dB / (3.*
B_nom[0]);
51 for (jc = 0; jc < 360; ++jc)
C[jc] = (
C2[jc][0]*dB2 +
C1[jc][0])*dB;
53 while (
B_nom[k1] < dB) ++k1;
57 for (jc = 0; jc < 360; ++jc)
58 C[jc] = (((
C2[jc][k1] -
C2[jc][k0])*dB2+
C2[jc][
k0])*dB +
C1[jc][k1])*dB +
C0[jc][
k0];
61 for (jc = 0; jc < 360; ++jc)
62 C[jc] = (
C2[jc][k0]*dB2 +
C1[jc][k1])*dB +
C0[jc][
k0];
66 if (B < 0)
for (jc = 0; jc < 360; ++jc)
C[jc] = -
C[jc];
71 double &Br,
double &Bz,
double &Bphi)
double GetBphi(double *coeff)
double GetBr(double *coeff)
static const double B_nom[4]
void GetField(const double r, const double z, const double phi, double &Br, double &Bz, double &Bphi)
static const double C0[360][4]
void SetCoeff_Linear(const double B)
static const double C1[360][5]
void SetPoint(const double r, const double z, const double phi)
void SetCoeff_Spline(const double B)
static const double C2[360][3]
double GetBz(double *coeff)