Skip to content

Commit 4d6fc60

Browse files
add field3d passmethod
1 parent 836294d commit 4d6fc60

5 files changed

Lines changed: 21 additions & 2 deletions

File tree

include/trackcpp/accelerator.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#define _ACCELERATOR_H
1919

2020
#include "kicktable.h"
21+
#include "field3d.h"
2122
#include "elements.h"
2223
#include <vector>
2324
#include <string>

include/trackcpp/elements.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class Element {
6565
double rescale_kicks = 1.0; // for kickmaps
6666
double ks = 0; // [1/m]
6767
double kx = 0; // [1/m]
68-
double s_init = 0; // [m]
68+
double s0 = 0; // [m]
6969
std::vector<std::vector<double>> coefs = std::vector<std::vector<double>>(5, std::vector<double>(5, 0.0));;
7070

7171
std::vector<double> polynom_a = default_polynom;

include/trackcpp/passmethods.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ template <typename T> Status::type pm_thinsext_pass (Pos<T> &pos, c
6666
template <typename T> Status::type pm_kickmap_pass (Pos<T> &pos, const Element &elem, const Accelerator& accelerator);
6767
template <typename T> Status::type pm_matrix_pass (Pos<T> &pos, const Element &elem, const Accelerator& accelerator);
6868
template <typename T> Status::type pm_drift_g2l_pass (Pos<T> &pos, const Element &elem, const Accelerator& accelerator);
69+
template <typename T> Status::type pm_field3d_pass (Pos<T> &pos, const Element &elem, const Accelerator& accelerator);
6970

7071
#include "passmethods.hpp"
7172

include/trackcpp/passmethods.hpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ Status::type kicktablethinkick(Pos<T>& pos, const int& kicktable_idx,
113113
return status;
114114
}
115115

116+
116117
template <typename T>
117118
void matthinkick(Pos<T> &pos, const Matrix &m) {
118119

@@ -468,6 +469,22 @@ Status::type pm_kickmap_pass(Pos<T> &pos, const Element &elem,
468469
return status;
469470
}
470471

472+
template <typename T>
473+
Status::type pm_field3d_pass(Pos<T> &pos, const Element &elem,
474+
const Accelerator& accelerator) {
475+
476+
global_2_local(pos, elem);
477+
const double brho = get_magnetic_rigidity(accelerator.energy);
478+
const double gamma = energy / electron_rest_energy_eV;
479+
const double beta0 = sqrt(1 - 1/(gamma*gamma));
480+
double step = elem.length / float(elem.nr_steps);
481+
for (int i=0; i<elem.nr_steps; ++i){
482+
prop_step(beta0, brho, elem.kx, elem.ks, elem.coefs, pos, elem.s0, step)
483+
}
484+
local_2_global(pos, elem);
485+
return Status::success;
486+
}
487+
471488
template <typename T>
472489
Status::type pm_matrix_pass(Pos<T> &pos, const Element &elem,
473490
const Accelerator& accelerator) {

src/elements.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,5 +321,5 @@ void initialize_field3d(Element& element, const double& s0, const double& kx, co
321321
element.coefs = coefs;
322322
element.kx = kx;
323323
element.ks = ks;
324-
element.s_init = s0;
324+
element.s0 = s0;
325325
}

0 commit comments

Comments
 (0)