OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
TrimCoilPhaseFit.cpp
Go to the documentation of this file.
1//
2// Class TrimCoilPhaseFit
3// General rational function fit of the phase shift
4//
5// Copyright (c) 2018 - 2019, Jochem Snuverink, Paul Scherrer Institut, Villigen PSI, Switzerland
6// All rights reserved
7//
8// Implemented as part of the PhD thesis
9// "Precise Simulations of Multibunches in High Intensity Cyclotrons"
10// and the paper
11// "Matching of turn pattern measurements for cyclotrons using multiobjective optimization"
12// (https://doi.org/10.1103/PhysRevAccelBeams.22.064602)
13//
14// This file is part of OPAL.
15//
16// OPAL is free software: you can redistribute it and/or modify
17// it under the terms of the GNU General Public License as published by
18// the Free Software Foundation, either version 3 of the License, or
19// (at your option) any later version.
20//
21// You should have received a copy of the GNU General Public License
22// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
23//
25
27 double rmin,
28 double rmax,
29 const std::vector<double>& coefnum,
30 const std::vector<double>& coefdenom,
31 const std::vector<double>& coefnumphi,
32 const std::vector<double>& coefdenomphi):
33 TrimCoilFit(bmax, rmin, rmax, coefnum, coefdenom, coefnumphi, coefdenomphi)
34{}
35
36void TrimCoilPhaseFit::doApplyField(const double r, const double z, const double phi_rad, double *br, double *bz)
37{
38 // check range
39 if (r < rmin_m || r > rmax_m) return;
40
41 double phase=0.0, d_phase=0.0, d2_phase=0.0;
42 calculateRationalFunction(RADIUS, r, phase, d_phase, d2_phase);
43 double phi = 0.0, d_phi = 0.0, d2_phi=0.0;
44 calculateRationalFunction(PHI, phi_rad, phi, d_phi, d2_phi);
45
46 //std::cout << "r " << r << " dr " << dr << std::endl;
47 double derivative = d_phase * phi + phase * d_phi;
48 double der2 = d2_phase * phi + phase * d2_phi + 2*d_phi*d_phase;
49
50 *bz += - bmax_m * derivative;
51 *br += - bmax_m * der2 * z;
52}
double bmax_m
Maximum B field (kG).
Definition TrimCoil.h:45
double rmax_m
Maximum radius (m).
Definition TrimCoil.h:49
void calculateRationalFunction(FunctionType, double value, double &quot, double &der_quot) const
calculate rational function and its first derivative
TrimCoilFit(double bmax, double rmin, double rmax, const std::vector< double > &coefnum, const std::vector< double > &coefdenom, const std::vector< double > &coefnumphi, const std::vector< double > &coefdenomphi)
virtual void doApplyField(const double r, const double z, const double phi_rad, double *br, double *bz)
virtual implementation of applyField
TrimCoilPhaseFit()=delete