47#define CHECK_CYC_FSCANF_EOF(arg) if (arg == EOF)\
48throw GeneralClassicException("Cyclotron::getFieldFromFile",\
49 "fscanf returned EOF at " #arg);
99 double* br,
double* bz) {
101 trimcoil->applyField(r, z, tet_rad, br, bz);
106 const double tet_rad,
107 double& br,
double& bz) {
186 "Cyclotron::getFieldMapFN",
187 "The attribute FMAPFN isn't set for the CYCLOTRON element");
188 }
else if (std::filesystem::exists(
fmapfn_m)) {
192 "Failed to open file '" +
fmapfn_m +
193 "', please check if it exists");
218 "RFPHI not defined for CYCLOTRON");
231 "RFFREQ not defined for CYCLOTRON");
244 "SUPERPOSE not defined for CYCLOTRON");
292 "ESCALE not defined for CYCLOTRON");
325 "MINR must be positive");
334 "The attribute MAXR has to be higher than MINR");
355 "The attribute MAXZ has to be higher than MINZ");
380 static const std::map<std::string, BFieldType> typeStringToBFieldType_s = {
400 if ( (refZ < minz_m || refZ >
maxz_m) ||
401 (refR < minr_m || refR >
maxr_m) ) {
403 "Cyclotron::checkInitialReferenceParticle",
404 "The initial position of the reference particle (RINIT, ZINIT) "
405 "must be in the range of (MINR, MAXR) and (MINZ, MAXZ)");
410 "PHIINIT is out of [-180, 180)");
416 bool flagNeedUpdate =
false;
422 flagNeedUpdate =
true;
424 <<
" out of the global aperture of cyclotron!" <<
endl;
430 if (flagNeedUpdate) {
432 <<
" out of the field map boundary!" <<
endl;
438 if (flagNeedUpdate) {
445 return flagNeedUpdate;
452 if (std::abs(R[0]) < 1.0E-10) {
458 }
else if (R[0] < 0.0) {
462 tet = std::atan(R[1] / R[0]);
472 double brint = 0.0, btint = 0.0, bzint = 0.0;
474 const double rad = std::hypot(R[0],R[1]);
475 if ( this->
interpolate(rad, tet, brint, btint, bzint) ) {
478 double br = - brint * R[2];
481 double bt = - btint / rad * R[2];
489 B[0] = br * std::cos(tet) - bt * std::sin(tet);
490 B[1] = br * std::sin(tet) + bt * std::cos(tet);
501 std::vector<Fieldmap>::const_iterator fi =
RFfields_m.begin();
502 std::vector<double>::const_iterator rffi =
rffrequ_m.begin();
503 std::vector<double>::const_iterator rfphii =
rfphi_m.begin();
504 std::vector<double>::const_iterator escali =
escale_m.begin();
505 std::vector<bool>::const_iterator superposei =
superpose_m.begin();
509 double xBegin(0), xEnd(0), yBegin(0), yEnd(0), zBegin(0), zEnd(0);
512 for (; fi !=
RFfields_m.end(); ++fi, ++rffi, ++rfphii, ++escali, ++superposei) {
513 (*fi)->getFieldDimensions(xBegin, xEnd, yBegin, yEnd, zBegin, zEnd);
514 if (fcount > 0 && *superposei ==
false)
continue;
520 if (temp_R(0) < xBegin || temp_R(0) > xEnd ||
521 temp_R(1) < yBegin || temp_R(1) > yEnd ||
522 temp_R(2) < zBegin || temp_R(2) > zEnd)
continue;
524 Vector_t tmpE(0.0, 0.0, 0.0), tmpB(0.0, 0.0, 0.0);
526 if ((*fi)->getFieldstrength(temp_R, tmpE, tmpB))
continue;
530 double frequency = (*rffi);
531 double ebscale = (*escali);
535 for (
const double fcoef : (*rffci)) {
537 frequency += fcoef * powert;
540 for (
const double vcoef : (*rfvci)) {
542 ebscale += vcoef * powert;
548 E += ebscale * std::cos(phase) * tmpE;
549 B -= ebscale * std::sin(phase) * tmpB;
557 phase_print = std::fmod(phase_print, 360) - 360.0;
559 *
gmsg <<
endl <<
"Gap 1 phase = " << phase_print <<
" Deg" <<
endl;
560 *
gmsg <<
"Gap 1 E-Field = (" << E[0] <<
"/" << E[1] <<
"/" << E[2] <<
")" <<
endl;
561 *
gmsg <<
"Gap 1 B-Field = (" << B[0] <<
"/" << B[1] <<
"/" << B[2] <<
")" <<
endl;
562 *
gmsg <<
"RF Frequency = " << frequency <<
" MHz" <<
endl;
566 phase_print = std::fmod(phase_print, 360) - 360.0;
568 *
gmsg <<
endl <<
"Gap 2 phase = " << phase_print <<
" Deg" <<
endl;
569 *
gmsg <<
"Gap 2 E-Field = (" << E[0] <<
"/" << E[1] <<
"/" << E[2] <<
")" <<
endl;
570 *
gmsg <<
"Gap 2 B-Field = (" << B[0] <<
"/" << B[1] <<
"/" << B[2] <<
")" <<
endl;
571 *
gmsg <<
"RF Frequency = " << frequency <<
" MHz" <<
endl;
582 const double& tet_rad,
double& br,
583 double& bt,
double& bz) {
600 const int krl,
const int lpr) {
602 double C[5][5][3], FAC[3];
703 for (j = 0; j < 5; j++) {
704 result += C[j][krl][kor] * *(f + j * lpr);
707 return result / (FAC[kor] * std::pow(dx, (kor + 1)));
712 const double& tet_rad,
717 const double xir = (rad -
BP_m.rmin_m) /
BP_m.delr_m;
720 const int ir = (int)xir;
723 const double wr1 = xir - (double)ir;
725 const double wr2 = 1.0 - wr1;
731 double xit = tet_map /
BP_m.dtet_m;
734 const double wt1 = xit - (double)it;
735 const double wt2 = 1.0 - wt1;
742 int r1t1, r2t1, r1t2, r2t2;
752 r1t1 = it + ntetS * ir - 1;
763 r2t1 =
idx(ir + 1, it);
764 r1t2 =
idx(ir , it + 1);
765 r2t2 =
idx(ir + 1, it + 1);
768 if ((r1t1 >= 0) && (r2t2 <
Bfield_m.ntot_m)) {
770 double bzf =
Bfield_m.bfld_m[r1t1] * wr2 * wt2 +
777 brint =
Bfield_m.dbr_m[r1t1] * wr2 * wt2 +
783 btint =
Bfield_m.dbt_m[r1t1] * wr2 * wt2 +
797 "The attribute TYPE isn't set for the CYCLOTRON element");
801 *
gmsg <<
"* Read field data from PSI format field map file" <<
endl;
806 *
gmsg <<
"* Read data from 450MeV Carbon cyclotron field file" <<
endl;
811 *
gmsg <<
"* Read data from 100MeV H- cyclotron CYCIAE-100 field file" <<
endl;
816 *
gmsg <<
"* Read AVFEQ data (Riken)" <<
endl;
821 *
gmsg <<
"* Read FFA data MSU/FNAL" <<
endl;
826 *
gmsg <<
"* Read both median plane B field map and 3D E field map of RF cavity for compact cyclotron" <<
endl;
831 *
gmsg <<
"* Read midplane B-field, 3D RF fieldmaps, and text files with RF frequency/Voltage coefficients for Synchrocyclotron" <<
endl;
837 "Unknown TYPE for the CYCLOTRON element");
863 for (
int i = 0; i <
Bfield_m.nrad_m; i++) {
864 for (
int k = 0; k <
Bfield_m.ntet_m; k++) {
870 kEdge = std::max(k - 2, 0);
871 kEdge = std::min(kEdge,
Bfield_m.ntet_m - 5);
873 int dkFromEdge = k - kEdge;
874 int index =
idx(i, k);
875 int indexkEdge =
idx(i, kEdge);
883 for (
int k = 0; k <
Bfield_m.ntet_m; k++) {
885 for (
int i = 0; i <
Bfield_m.nrad_m; i++) {
886 double rac =
BP_m.rarr_m[i];
889 int iredg = std::max(i - 2, 0);
890 iredg = std::min(iredg,
Bfield_m.nrad_m - 5);
891 int irtak = i - iredg;
892 int index =
idx(i, k);
893 int indexredg =
idx(iredg, k);
906 +
Bfield_m.dbtt_m[index] / rac / rac) / 2.0;
911 - 2.0 *
Bfield_m.dbtt_m[index] / rac / rac / rac) / 6.0;
915 +
Bfield_m.dbttt_m[index] / rac / rac) / 6.0;
920 for (
int i = 0; i <
Bfield_m.nrad_m; i++) {
922 int istart =
idx(i, 0);
959 BP_m.rarr_m.resize(nrad);
960 for (
int i = 0; i < nrad; i++) {
961 BP_m.rarr_m[i] = rmin + i * dr;
975 this->
read(scaleFactor);
987 *
gmsg <<
"* ----------------------------------------------" <<
endl;
988 *
gmsg <<
"* READ IN RING FIELD MAP " <<
endl;
989 *
gmsg <<
"* (The first data block is useless) " <<
endl;
990 *
gmsg <<
"* ----------------------------------------------" <<
endl;
992 BP_m.Bfact_m = scaleFactor;
994 f = std::fopen(
fmapfn_m.c_str(),
"r");
997 *
gmsg <<
"* Minimal radius of measured field map: " <<
BP_m.rmin_m <<
" [mm]" <<
endl;
1002 if (
BP_m.delr_m < 0.0)
BP_m.delr_m = 1.0 / (-
BP_m.delr_m);
1003 *
gmsg <<
"* Stepsize in radial direction: " <<
BP_m.delr_m <<
" [mm]" <<
endl;
1007 *
gmsg <<
"* Minimal angle of measured field map: " <<
BP_m.tetmin_m <<
" [deg]" <<
endl;
1011 if (
BP_m.dtet_m < 0.0)
BP_m.dtet_m = 1.0 / (-
BP_m.dtet_m);
1012 *
gmsg <<
"* Stepsize in azimuth direction: " <<
BP_m.dtet_m <<
" [deg]" <<
endl;
1014 for (
int i = 0; i < 13; i++) {
1025 *
gmsg <<
"* Accordingly, total grid point along azimuth: " <<
Bfield_m.ntetS_m <<
endl;
1027 for (
int i = 0; i < 5; i++) {
1033 for (
int i = 0; i < 4; i++) {
1037 for (
int i = 0; i < lpar; i++) {
1040 for (
int i = 0; i < 6; i++) {
1044 for (
int i = 0; i < 10000; i++) {
1046 if (std::strcmp(fout,
"LREC=") == 0)
break;
1049 for (
int i = 0; i < 5; i++) {
1053 *
gmsg <<
"* Total stored grid point number ( ntetS * nrad ): " <<
Bfield_m.ntot_m <<
endl;
1060 *
gmsg <<
"* Read-in loop one block per radius" <<
endl;
1061 *
gmsg <<
"* Rescaling of the magnetic fields with factor: " <<
BP_m.Bfact_m <<
endl;
1062 for (
int i = 0; i <
Bfield_m.nrad_m; i++) {
1064 for (
int dummy = 0; dummy < 6; dummy++) {
1068 for (
int k = 0; k <
Bfield_m.ntet_m; k++) {
1072 for (
int k = 0; k <
Bfield_m.ntet_m; k++) {
1076 for (
int k = 0; k <
Bfield_m.ntet_m; k++) {
1080 for (
int k = 0; k <
Bfield_m.ntet_m; k++) {
1087 *
gmsg <<
"* Field Map read successfully!" <<
endl <<
endl;
1112 std::vector<double> rv;
1113 std::vector<double> thv;
1114 std::vector<double> xv;
1115 std::vector<double> yv;
1116 std::vector<double> bzv;
1117 std::vector<double>::iterator vit;
1119 *
gmsg <<
"* ----------------------------------------------" <<
endl;
1120 *
gmsg <<
"* READ IN FFA FIELD MAP " <<
endl;
1121 *
gmsg <<
"* ----------------------------------------------" <<
endl;
1125 std::ifstream file_to_read(
fmapfn_m.c_str());
1126 const int max_num_of_char_in_a_line = 128;
1127 const int num_of_header_lines = 1;
1130 for (
int i = 0; i < num_of_header_lines; ++i)
1131 file_to_read.ignore(max_num_of_char_in_a_line,
'\n');
1133 while(!file_to_read.eof()) {
1134 double r, th, x, y, bz;
1135 file_to_read >> r >> th >> x >> y >> bz;
1136 if ((
int)th != 360) {
1145 double maxtheta = 360.0;
1146 BP_m.dtet_m = thv[1] - thv[0];
1147 BP_m.rmin_m = *(rv.begin());
1148 double rmax = rv.back();
1151 for (vit = rv.begin(); *vit <=
BP_m.rmin_m; ++vit) {}
1154 BP_m.tetmin_m = thv[0];
1156 Bfield_m.ntet_m = (int)((maxtheta - thv[0]) /
BP_m.dtet_m);
1160 *
gmsg <<
"* Maximal radius of measured field map: " <<
Units::m2mm * rmax <<
" [mm]" <<
endl;
1162 *
gmsg <<
"* Minimal angle of measured field map: " <<
BP_m.tetmin_m <<
" [deg]" <<
endl;
1163 *
gmsg <<
"* Maximal angle of measured field map: " << maxtheta <<
" [deg]" <<
endl;
1166 if (
BP_m.dtet_m < 0.0)
BP_m.dtet_m = 1.0 / (-
BP_m.dtet_m);
1167 *
gmsg <<
"* Stepsize in azimuth direction: " <<
BP_m.dtet_m <<
" [deg]" <<
endl;
1172 *
gmsg <<
"* Total stored grid point number ( ntetS * nrad ): " <<
Bfield_m.ntot_m <<
endl;
1179 *
gmsg <<
"* Rescaling of the magnetic fields with factor: " <<
BP_m.Bfact_m <<
endl;
1182 for (
int r = 0; r <
Bfield_m.nrad_m; r++) {
1183 for (
int k = 0; k <
Bfield_m.ntet_m; k++) {
1192 *
gmsg <<
"* Number of elements read: " << count <<
endl;
1193 *
gmsg <<
"* Field Map read successfully!" <<
endl <<
endl;
1200 *
gmsg <<
"* ----------------------------------------------" <<
endl;
1201 *
gmsg <<
"* READ IN AVFEQ CYCLOTRON FIELD MAP " <<
endl;
1202 *
gmsg <<
"* ----------------------------------------------" <<
endl;
1218 BP_m.Bfact_m = scaleFactor / 1000.;
1220 f = std::fopen(
fmapfn_m.c_str(),
"r");
1223 *
gmsg <<
"* Minimal radius of measured field map: " <<
BP_m.rmin_m <<
" [mm]" <<
endl;
1228 *
gmsg <<
"* Maximal radius of measured field map: " << rmax <<
" [mm]" <<
endl;
1232 *
gmsg <<
"* Stepsize in radial direction: " <<
BP_m.delr_m <<
" [mm]" <<
endl;
1236 *
gmsg <<
"* Minimal angle of measured field map: " <<
BP_m.tetmin_m <<
" [deg]" <<
endl;
1240 *
gmsg <<
"* Maximal angle of measured field map: " << tetmax <<
" [deg]" <<
endl;
1245 if (
BP_m.dtet_m < 0.0)
BP_m.dtet_m = 1.0 / (-
BP_m.dtet_m);
1246 *
gmsg <<
"* Stepsize in azimuth direction: " <<
BP_m.dtet_m <<
" [deg]" <<
endl;
1256 *
gmsg <<
"* Total stored grid point number ( ntetS * nrad ): "
1257 <<
Bfield_m.ntot_m <<
" ntot-idx= " << ntotidx <<
endl;
1264 *
gmsg <<
"* Rescaling of the magnetic fields with factor: " <<
BP_m.Bfact_m <<
endl;
1268 for (
int r = 0; r <
Bfield_m.nrad_m; r++) {
1270 for (
int k = 0; k <
Bfield_m.ntetS_m; k++) {
1282 *
gmsg <<
"* Number of elements read: " << count <<
endl;
1283 *
gmsg <<
"* Field Map read successfully!" <<
endl <<
endl;
1290 *
gmsg <<
"* ----------------------------------------------" <<
endl;
1291 *
gmsg <<
"* READ IN CARBON CYCLOTRON FIELD MAP " <<
endl;
1292 *
gmsg <<
"* ----------------------------------------------" <<
endl;
1294 BP_m.Bfact_m = scaleFactor;
1296 f = std::fopen(
fmapfn_m.c_str(),
"r");
1299 *
gmsg <<
"* Minimal radius of measured field map: " <<
BP_m.rmin_m <<
" [mm]" <<
endl;
1304 if (
BP_m.delr_m < 0.0)
BP_m.delr_m = 1.0 / (-
BP_m.delr_m);
1305 *
gmsg <<
"* Stepsize in radial direction: " <<
BP_m.delr_m <<
" [mm]" <<
endl;
1309 *
gmsg <<
"* Minimal angle of measured field map: " <<
BP_m.tetmin_m <<
" [deg]" <<
endl;
1313 if (
BP_m.dtet_m < 0.0)
BP_m.dtet_m = 1.0 / (-
BP_m.dtet_m);
1314 *
gmsg <<
"* Stepsize in azimuthal direction: " <<
BP_m.dtet_m <<
" [deg]" <<
endl;
1317 *
gmsg <<
"* Grid points along azimuth (ntet): " <<
Bfield_m.ntet_m <<
endl;
1329 *
gmsg <<
"* Adding a guard cell along azimuth" <<
endl;
1330 *
gmsg <<
"* Total stored grid point number ((ntet+1) * nrad): " <<
Bfield_m.ntot_m <<
endl;
1336 *
gmsg <<
"* Rescaling of the magnetic fields with factor: " <<
BP_m.Bfact_m <<
endl;
1338 for (
int i = 0; i <
Bfield_m.nrad_m; i++) {
1339 for (
int k = 0; k <
Bfield_m.ntet_m; k++) {
1350 *
gmsg <<
"* Field Map read successfully!" <<
endl <<
endl;
1360 *
gmsg <<
"* ----------------------------------------------" <<
endl;
1361 *
gmsg <<
"* READ IN CYCIAE-100 CYCLOTRON FIELD MAP " <<
endl;
1362 *
gmsg <<
"* ----------------------------------------------" <<
endl;
1364 BP_m.Bfact_m = scaleFactor;
1366 f = std::fopen(
fmapfn_m.c_str(),
"r");
1369 *
gmsg <<
"* Minimal radius of measured field map: " <<
BP_m.rmin_m <<
" [mm]" <<
endl;
1373 *
gmsg <<
"* Stepsize in radial direction: " <<
BP_m.delr_m <<
" [mm]" <<
endl;
1377 *
gmsg <<
"* Minimal angle of measured field map: " <<
BP_m.tetmin_m <<
" [deg]" <<
endl;
1381 if (
BP_m.dtet_m < 0.0)
BP_m.dtet_m = 1.0 / (-
BP_m.dtet_m);
1382 *
gmsg <<
"* Stepsize in azimuth direction: " <<
BP_m.dtet_m <<
" [deg]" <<
endl;
1391 *
gmsg <<
"* Accordingly, total grid point along azimuth: " <<
Bfield_m.ntetS_m <<
endl;
1395 *
gmsg <<
"* Total stored grid point number ( ntetS * nrad ): " <<
Bfield_m.ntot_m <<
endl;
1401 *
gmsg <<
"* Rescaling of the magnetic fields with factor: " <<
BP_m.Bfact_m <<
endl;
1403 int nHalfPoints =
Bfield_m.ntet_m / 2.0 + 1;
1405 for (
int i = 0; i <
Bfield_m.nrad_m; i++) {
1406 for (
int ii = 0; ii < 13; ii++) {
1409 for (
int k = 0; k < nHalfPoints; k++) {
1417 for (
int k = nHalfPoints; k <
Bfield_m.ntet_m; k++) {
1423 *
gmsg <<
"* Field Map read successfully!" <<
endl <<
endl;
1432 *
gmsg <<
"* Reading '" << fm <<
"'" <<
endl;
1444 std::vector<std::string>::const_iterator fm =
RFfilename_m.begin();
1445 std::vector<std::string>::const_iterator rffcfni =
RFFCoeff_fn_m.begin();
1446 std::vector<std::string>::const_iterator rfvcfni =
RFVCoeff_fn_m.begin();
1449 FILE *rffcf =
nullptr;
1450 FILE *rfvcf =
nullptr;
1453 *
gmsg <<
"* ------------------------------------------------------------" <<
endl;
1454 *
gmsg <<
"* READ IN 3D RF Fields and Frequency Coefficients " <<
endl;
1455 *
gmsg <<
"* ------------------------------------------------------------" <<
endl;
1457 for (; fm !=
RFfilename_m.end(); ++fm, ++rffcfni, ++rfvcfni, ++fcount) {
1464 *
gmsg <<
"RF Frequency Coefficient Filename: " << (*rffcfni) <<
endl;
1466 rffcf = std::fopen((*rffcfni).c_str(),
"r");
1468 if (rffcf ==
nullptr) {
1470 "Cyclotron::getFieldFromFile_Synchrocyclotron",
1471 "failed to open file '" + *rffcfni +
"', please check if it exists");
1474 std::vector<double> fcoeff;
1479 *
gmsg <<
"* Number of coefficients in file: " << nc <<
endl;
1480 for (
int k = 0; k < nc; k++) {
1482 fcoeff.push_back(value);
1485 rffc_m.push_back(fcoeff);
1490 *
gmsg <<
"RF Voltage Coefficient Filename: " << (*rfvcfni) <<
endl;
1492 rfvcf = std::fopen((*rfvcfni).c_str(),
"r");
1493 if (rfvcf ==
nullptr) {
1495 "Cyclotron::getFieldFromFile_Synchrocyclotron",
1496 "failed to open file '" + *rfvcfni +
"', please check if it exists");
1499 std::vector<double> vcoeff;
1502 *
gmsg <<
"* Number of coefficients in file: " << nc <<
endl;
1503 for (
int k = 0; k < nc; k++) {
1505 vcoeff.push_back(value);
1508 rfvc_m.push_back(vcoeff);
1527 fp1.open(fname, std::ios::out);
1528 for (
int i = 0; i <
Bfield_m.nrad_m; i++) {
1529 for (
int k = 0; k <
Bfield_m.ntet_m; k++) {
1531 << k * (
BP_m.tetmin_m +
BP_m.dtet_m) <<
" \t "
1545 fp2.open(fname, std::ios::out);
1546 for (
int i = 0; i <
Bfield_m.nrad_m; i++) {
1547 for (
int k = 0; k <
Bfield_m.ntet_m; k++) {
1549 Vector_t tmpE(0.0, 0.0, 0.0), tmpB(0.0, 0.0, 0.0);
1551 Vector_t E(0.0, 0.0, 0.0), B(0.0, 0.0, 0.0);
1552 if (!fi->getFieldstrength(tmpR, tmpE, tmpB)) {
1557 fp2 << tmpR <<
" \t E= " << tmpE <<
"\t B= " << tmpB << std::endl;
1560 *
gmsg <<
"\n* Writing 'gnu.out' and 'eb.out' files of cyclotron field maps\n" <<
endl;
1563 *
gmsg <<
"\n* Writing 'gnu.out' file of cyclotron field map\n" <<
endl;
1567#undef CHECK_CYC_FSCANF_EOF
#define CHECK_CYC_FSCANF_EOF(arg)
std::shared_ptr< _Fieldmap > Fieldmap
void fp2(BareField< T, 2U > &field, bool docomm=true)
void fp1(BareField< T, 1U > &field, bool docomm=true)
Inform & level4(Inform &inf)
Inform & endl(Inform &inf)
constexpr double two_pi
The value of.
constexpr double pi
The value of.
std::string combineFilePath(std::initializer_list< std::string > ilist)
bool angleBetweenAngles(const double angle, const double min, const double max)
check if angle (in rad and in range [0,2pi]) is within [min, max]
static OpalData * getInstance()
std::string getAuxiliaryOutputDirectory() const
get the name of the the additional data directory
virtual void visitCyclotron(const Cyclotron &)=0
Apply the algorithm to a cyclotron.
Component(const std::string &name)
Constructor with given name.
PartBunchBase< double, 3 > * RefPartBunch_m
virtual std::vector< double > getEScale() const
void setTrimCoilThreshold(double)
void setZinit(double zinit)
virtual double getCyclHarm() const
virtual void getDimensions(double &zBegin, double &zEnd) const
std::vector< std::string > RFfilename_m
virtual bool getSpiralFlag() const
virtual bool bends() const
void getFieldFromFile_CYCIAE(const double &scaleFactor)
void setSpiralFlag(bool spiral_flag)
virtual ElementType getType() const
Get element type std::string.
virtual double getPRinit() const
void getFieldFromFile_BandRF(const double &scaleFactor)
void setSuperpose(std::vector< bool > flag)
virtual double getTrimCoilThreshold() const
void checkInitialReferenceParticle(double refR, double refTheta, double refZ)
void setRfPhi(std::vector< double > f)
void setRFVCoeffFN(std::vector< std::string > rfv_coeff_fn)
void setPZinit(double zinit)
void setCyclotronType(const std::string &type)
virtual void accept(BeamlineVisitor &) const
Apply visitor to Cyclotron.
virtual double getPZinit() const
virtual std::string getFieldMapFN() const
virtual double getRmin() const
void read(const double &scaleFactor)
int idx(int irad, int ktet)
virtual double getMaxR() const
void setEScale(std::vector< double > bs)
void setSymmetry(double symmetry)
std::vector< bool > superpose_m
virtual std::vector< double > getRfFrequ() const
std::vector< double > escale_m
std::vector< std::string > RFVCoeff_fn_m
std::vector< double > rffrequ_m
void getFieldFromFile_AVFEQ(const double &scaleFactor)
virtual double getRmax() const
virtual double getFMHighE() const
double gutdf5d(double *f, double dx, const int kor, const int krl, const int lpr)
void setFieldMapFN(const std::string &fmapfn)
double trimCoilThreshold_m
virtual double getMaxZ() const
virtual double getBScale() const
virtual double getZinit() const
void getFieldFromFile_Carbon(const double &scaleFactor)
void writeOutputFieldFiles()
virtual double getPHIinit() const
std::vector< TrimCoil * > trimcoils_m
std::vector< std::string > RFFCoeff_fn_m
void setTrimCoils(const std::vector< TrimCoil * > &trimcoils)
virtual double getSymmetry() const
void setCyclHarm(double h)
virtual double getMinZ() const
void getFieldFromFile_Synchrocyclotron(const double &scaleFactor)
virtual std::vector< double > getRfPhi() const
void applyTrimCoil_m(const double r, const double z, const double tet_rad, double *br, double *bz)
Apply trim coils (calculate field contributions).
BFieldType getBFieldType() const
virtual void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField)
Cyclotron(const std::string &name)
Constructor with given name.
void getFieldFromFile_FFA(const double &scaleFactor)
void initR(double rmin, double dr, int nrad)
void setPHIinit(double phiinit)
void setRfFrequ(std::vector< double > f)
void setPRinit(double prinit)
void applyTrimCoil(const double r, const double z, const double tet_rad, double &br, double &bz)
Apply trim coils (calculate field contributions) with smooth field transition.
virtual bool apply(const size_t &id, const double &t, Vector_t &E, Vector_t &B)
void setRfFieldMapFN(std::vector< std::string > rffmapfn)
bool interpolate(const double &rad, const double &tet_rad, double &br, double &bt, double &bz)
void setFMHighE(double e)
std::vector< double > rfphi_m
void setRinit(double rinit)
virtual std::vector< bool > getSuperpose() const
std::vector< std::vector< double > > rfvc_m
std::vector< std::vector< double > > rffc_m
std::vector< Fieldmap > RFfields_m
virtual double getFMLowE() const
std::unique_ptr< LossDataSink > lossDs_m
unsigned int getNumberOfTrimcoils() const
virtual double getRinit() const
void getFieldFromFile_Ring(const double &scaleFactor)
virtual double getMinR() const
const std::string & getCyclotronType() const
void setRFFCoeffFN(std::vector< std::string > rff_coeff_fn)
void setBScale(double bs)
virtual const std::string & getName() const
Get element name.
std::string getOutputFN() const
Get output filename.
static void readMap(std::string Filename)
static Fieldmap getFieldmap(std::string Filename, bool fast=false)
Vektor< double, 3 > Vector_t