1#ifndef OPALX_AstraFIELDMAP1DMAGNETOSTATIC_HH
2#define OPALX_AstraFIELDMAP1DMAGNETOSTATIC_HH
9#include <Kokkos_Core.hpp>
10#include <Kokkos_DualView.hpp>
21 double& xIni,
double& xFinal,
double& yIni,
double& yFinal,
double& zIni,
22 double& zFinal)
const override;
30 void getInfo(Inform* msg)
override;
40 template <
class ViewType>
43 const ViewType& FourCoefs,
double zbegin,
double length,
int accuracy) {
44 const double RR2 = R(0) * R(0) + R(1) * R(1);
49 const double kz = two_pi * (R(2) - zbegin) / length + pi;
51 double bz = FourCoefs(0);
57 for (
int l = 1; l < accuracy; ++l, n += 2) {
58 const double base = dk * l;
60 const double coskzl = Kokkos::cos(kz * l);
61 const double sinkzl = Kokkos::sin(kz * l);
63 bz += FourCoefs(n) * coskzl - FourCoefs(n + 1) * sinkzl;
64 bzp += base * (-FourCoefs(n) * sinkzl - FourCoefs(n + 1) * coskzl);
65 bzpp += base * base * (-FourCoefs(n) * coskzl + FourCoefs(n + 1) * sinkzl);
66 bzppp += base * base * base * (FourCoefs(n) * sinkzl + FourCoefs(n + 1) * coskzl);
69 const double BfieldR = -bzp / 2.0 + bzppp * RR2 / 16.0;
71 B(0) += BfieldR * R(0);
72 B(1) += BfieldR * R(1);
73 B(2) += bz - bzpp * RR2 / 4.0;
76 void applyField(std::shared_ptr<ParticleContainer_t> pc,
double scale)
override;
ippl::Vector< T, Dim > Vector_t
bool isInside(const Vector_t< double, 3 > &r) const override
Check if a point is inside the field map.
double getFrequency() const override
Get the frequency.
static KOKKOS_INLINE_FUNCTION void computeField(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &, Vector_t< double, 3 > &B, const ViewType &FourCoefs, double zbegin, double length, int accuracy)
Kokkos::DualView< double * > FourCoefs_m
void swap() override
Swap coordinates (implementation dependent).
void freeMap() override
Pure virtual method to free the map data.
void applyField(std::shared_ptr< ParticleContainer_t > pc, double scale) override
Apply the FM to all the particles.
void getInfo(Inform *msg) override
Print info about the field map.
void getFieldDimensions(double &zBegin, double &zEnd) const override
Get the longitudinal dimensions of the field.
bool getFieldstrength(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B) const override
Get the fieldstrength at position R.
bool getFieldDerivative(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B, const DiffDirection &dir) const override
Get the derivative of the field at position R.
void setFrequency(double freq) override
Set the frequency.
void readMap() override
Pure virtual method to read the map data. Called by the public static readMap().
Abstract base class for all field maps. It acts as a factory for creating specific field map types ba...
constexpr double two_pi
The value of.
constexpr double pi
The value of.