42 interpolationCacheSet_m(false)
59 layout->
getLayout().changeDomain(*fLayout);
81 "P3M solver not available during emission");
116 double scaleFactor = 1;
122 double tmp2 = 1 /
hr_m[0] * 1 /
hr_m[1] * 1 /
hr_m[2] / (scaleFactor * scaleFactor * scaleFactor) / gammaz;
128 hr_scaled[2] *= gammaz;
132 imagePotential =
rho_m;
137 rho_m *= hr_scaled[0] * hr_scaled[1] * hr_scaled[2];
149 eg_m *=
Vector_t(gammaz / (scaleFactor), gammaz / (scaleFactor), 1.0 / (scaleFactor * gammaz));
155 int mx = (int)
nr_m[0];
156 int mx2 = (int)
nr_m[0] / 2;
157 int my = (int)
nr_m[1];
158 int my2 = (int)
nr_m[1] / 2;
159 int mz = (int)
nr_m[2];
160 int mz2 = (int)
nr_m[2] / 2;
162 for (
int i=0; i<mx; i++ )
163 *
gmsg <<
"Bin " << binNumber
164 <<
", Self Field along x axis E = " <<
eg_m[i][my2][mz2]
165 <<
", Pot = " <<
rho_m[i][my2][mz2] <<
endl;
167 for (
int i=0; i<my; i++ )
168 *
gmsg <<
"Bin " << binNumber
169 <<
", Self Field along y axis E = " <<
eg_m[mx2][i][mz2]
170 <<
", Pot = " <<
rho_m[mx2][i][mz2] <<
endl;
172 for (
int i=0; i<mz; i++ )
173 *
gmsg <<
"Bin " << binNumber
174 <<
", Self Field along z axis E = " <<
eg_m[mx2][my2][i]
175 <<
", Pot = " <<
rho_m[mx2][my2][i] <<
endl;
206 double zshift = -(2 * origin(2) + (domain[2].first() + domain[2].last() + 1) * hz) * gammaz * scaleFactor;
213 imagePotential *= hr_scaled[0] * hr_scaled[1] * hr_scaled[2];
219#ifdef DBG_SCALARFIELD
220 const int dumpFreq = 100;
236 eg_m *=
Vector_t(gammaz / (scaleFactor), gammaz / (scaleFactor), 1.0 / (scaleFactor * gammaz));
249 for (
int i=0; i<mx; i++ )
250 *
gmsg <<
"Bin " << binNumber
251 <<
", Image Field along x axis E = " <<
eg_m[i][my2][mz2]
252 <<
", Pot = " <<
rho_m[i][my2][mz2] <<
endl;
254 for (
int i=0; i<my; i++ )
255 *
gmsg <<
"Bin " << binNumber
256 <<
", Image Field along y axis E = " <<
eg_m[mx2][i][mz2]
257 <<
", Pot = " <<
rho_m[mx2][i][mz2] <<
endl;
259 for (
int i=0; i<mz; i++ )
260 *
gmsg <<
"Bin " << binNumber
261 <<
", Image Field along z axis E = " <<
eg_m[mx2][my2][i]
262 <<
", Pot = " <<
rho_m[mx2][my2][i] <<
endl;
265#ifdef DBG_SCALARFIELD
312 if(
R[
n](0) < xmin ||
R[
n](0) > xmax ||
313 R[
n](1) < ymin ||
R[
n](1) > ymax) {
368 double scaleFactor = 1;
372 hr_scaled[2] *= gammaz;
375 double tmp2 = 1 / hr_scaled[0] * 1 / hr_scaled[1] * 1 / hr_scaled[2];
385#ifdef DBG_SCALARFIELD
399 rho_m *= hr_scaled[0] * hr_scaled[1] * hr_scaled[2];
408#ifdef DBG_SCALARFIELD
420 int mx = (int)
nr_m[0];
421 int mx2 = (int)
nr_m[0] / 2;
422 int my = (int)
nr_m[1];
423 int my2 = (int)
nr_m[1] / 2;
424 int mz = (int)
nr_m[2];
425 int mz2 = (int)
nr_m[2] / 2;
427 for (
int i=0; i<mx; i++ )
428 *
gmsg <<
"Field along x axis Ex = " <<
eg_m[i][my2][mz2] <<
" Pot = " <<
rho_m[i][my2][mz2] <<
endl;
430 for (
int i=0; i<my; i++ )
431 *
gmsg <<
"Field along y axis Ey = " <<
eg_m[mx2][i][mz2] <<
" Pot = " <<
rho_m[mx2][i][mz2] <<
endl;
433 for (
int i=0; i<mz; i++ )
434 *
gmsg <<
"Field along z axis Ez = " <<
eg_m[mx2][my2][i] <<
" Pot = " <<
rho_m[mx2][my2][i] <<
endl;
437#ifdef DBG_SCALARFIELD
451 Ef =
Ef *
Vector_t(gammaz / (scaleFactor), gammaz / (scaleFactor), 1.0 / (scaleFactor * gammaz));
462 Bf(0) =
Bf(0) - betaC *
Ef(1);
463 Bf(1) =
Bf(1) + betaC *
Ef(0);
487 "P3M solver not available yet for cyclotrons");
506 hr_scaled[1] *= gamma;
509 double tmp2 = 1.0 / (hr_scaled[0] * hr_scaled[1] * hr_scaled[2]);
518#ifdef DBG_SCALARFIELD
533 rho_m *= hr_scaled[0] * hr_scaled[1] * hr_scaled[2];
540#ifdef DBG_SCALARFIELD
556 int mx = (int)
nr_m[0];
557 int mx2 = (int)
nr_m[0] / 2;
558 int my = (int)
nr_m[1];
559 int my2 = (int)
nr_m[1] / 2;
560 int mz = (int)
nr_m[2];
561 int mz2 = (int)
nr_m[2] / 2;
563 for (
int i=0; i<mx; i++ )
564 *
gmsg <<
"Field along x axis Ex = " <<
eg_m[i][my2][mz2] <<
" Pot = " <<
rho_m[i][my2][mz2] <<
endl;
566 for (
int i=0; i<my; i++ )
567 *
gmsg <<
"Field along y axis Ey = " <<
eg_m[mx2][i][mz2] <<
" Pot = " <<
rho_m[mx2][i][mz2] <<
endl;
569 for (
int i=0; i<mz; i++ )
570 *
gmsg <<
"Field along z axis Ez = " <<
eg_m[mx2][my2][i] <<
" Pot = " <<
rho_m[mx2][my2][i] <<
endl;
573#ifdef DBG_SCALARFIELD
589 Bf(0) = betaC *
Ef(2);
590 Bf(2) = -betaC *
Ef(0);
626 "P3M solver not available yet for cyclotrons");
648 hr_scaled[1] *= gamma;
651 double tmp2 = 1.0 / (hr_scaled[0] * hr_scaled[1] * hr_scaled[2]);
655#ifdef DBG_SCALARFIELD
668 rho_m *= hr_scaled[0] * hr_scaled[1] * hr_scaled[2];
675#ifdef DBG_SCALARFIELD
691 int mx = (int)
nr_m[0];
692 int mx2 = (int)
nr_m[0] / 2;
693 int my = (int)
nr_m[1];
694 int my2 = (int)
nr_m[1] / 2;
695 int mz = (int)
nr_m[2];
696 int mz2 = (int)
nr_m[2] / 2;
698 for (
int i=0; i<mx; i++ )
699 *
gmsg <<
"Bin " << bin
700 <<
", Field along x axis Ex = " <<
eg_m[i][my2][mz2]
701 <<
", Pot = " <<
rho_m[i][my2][mz2] <<
endl;
703 for (
int i=0; i<my; i++ )
704 *
gmsg <<
"Bin " << bin
705 <<
", Field along y axis Ey = " <<
eg_m[mx2][i][mz2]
706 <<
", Pot = " <<
rho_m[mx2][i][mz2] <<
endl;
708 for (
int i=0; i<mz; i++ )
709 *
gmsg <<
"Bin " << bin
710 <<
", Field along z axis Ez = " <<
eg_m[mx2][my2][i]
711 <<
", Pot = " <<
rho_m[mx2][my2][i] <<
endl;
715#ifdef DBG_SCALARFIELD
766 for (
int i = 0; i < 2 * 3; ++i) {
785 for (
int i = 0; i < 2 * 3; ++i) {
795 for (
int i = 0; i < 2 * 3; ++ i) {
819 for (
unsigned int i = 0; i <
Dimension; i++)
820 grid[i] = domain[i].length();
Tps< T > sqrt(const Tps< T > &x)
Square root.
void BinaryRepartition(FieldLayout< Dim > &layout, BareField< double, Dim > &weights)
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
T::PETE_Expr_t::PETE_Return_t min(const PETE_Expr< T > &expr, NDIndex< D > &loc)
Field< Vektor< T, 1U >, 1U, Cartesian< 1U, MFLOAT >, Cell > & Grad(Field< T, 1U, Cartesian< 1U, MFLOAT >, Vert > &x, Field< Vektor< T, 1U >, 1U, Cartesian< 1U, MFLOAT >, Cell > &r)
T::PETE_Expr_t::PETE_Return_t sum(const PETE_Expr< T > &expr)
T ParticlePeriodicBCond(const T t, const T minval, const T maxval)
T ParticleNoBCond(const T t, const T, const T)
Inform & level2(Inform &inf)
Inform & endl(Inform &inf)
Inform & level3(Inform &inf)
constexpr double q_e
The elementary charge in As.
constexpr double c
The velocity of light in m/s.
ParticleAttrib< Vector_t > Ef
std::shared_ptr< AbstractParticle< double, Dim > > pbase_m
long long localTrackStep_m
step in a TRACK command
void get_bounds(Vector_t &rmin, Vector_t &rmax) const
double getCouplingConstant() const
ParticleAttrib< Vector_t > Eftmp
size_t getLocalNum() const
Vector_t rmax_m
maximal extend of particles
size_t getTotalNum() const
ParticleBConds< Position_t, Dimension > & getBConds()
ParticleAttrib< Vector_t > P
Inform & print(Inform &os)
double getBinGamma(int bin)
Get gamma of one bin.
ParticleAttrib< double > Q
Vector_t rmin_m
minimal extend of particles
FieldSolver * fs_m
stores the used field solver
std::pair< Vector_t, Vector_t > VectorPair_t
double dh_m
Mesh enlargement.
ParticleAttrib< double > dt
static const unsigned Dimension
Vector_t hr_m
meshspacing of cartesian mesh
void destroy(size_t M, size_t I, bool doNow=false)
ParticleAttrib< Vector_t > Bf
virtual void swap(unsigned int i, unsigned int j)
void calcDebyeLength()
Compute the (global) Debye length for the beam.
Vektor< int, 3 > nr_m
meshsize of cartesian mesh
IpplTimings::TimerRef selfFieldTimer_m
timer for selfField calculation
void resetInterpolationCache(bool clearCache=false)
BConds< double, 3, Mesh_t, Center_t > bc_m
for defining the boundary conditions
Field_t rho_m
scalar potential
void swap(unsigned int i, unsigned int j)
ParticleLayout< double, 3 > & getLayout()
void initialize(FieldLayout_t *fLayout)
bool interpolationCacheSet_m
Inform & print(Inform &os)
void updateDomainLength(Vektor< int, 3 > &grid)
FieldLayout_t & getFieldLayout()
VField_t eg_m
vector field on the grid
VectorPair_t getEExtrema()
const Mesh_t & getMesh() const
ParticleAttrib< CacheDataCIC< double, 3U > > interpolationCache_m
void resizeMesh()
resize mesh to geometry specified
BConds< Vector_t, 3, Mesh_t, Center_t > vbc_m
void computeSelfFields_cycl(double gamma)
Calculates the self electric field from the charge density distribution for use in cyclotrons.
void updateFields(const Vector_t &hr, const Vector_t &origin)
virtual void computePotential(Field_t &rho, Vector_t hr)=0
virtual double getYRangeMin(unsigned short level=0)=0
virtual double getXRangeMin(unsigned short level=0)=0
virtual void calculatePairForces(PartBunchBase< double, 3 > *, double)
virtual void resizeMesh(Vector_t &, Vector_t &, const Vector_t &, const Vector_t &, double)
virtual double getYRangeMax(unsigned short level=0)=0
virtual double getXRangeMax(unsigned short level=0)=0
PoissonSolver * solver_m
the actual solver, should be a base object
FieldSolverType getFieldSolverType() const
void dumpField(FieldType &field, std::string name, std::string unit, long long step, FieldType *image=nullptr)
Dump a scalar or vector field to a file.
void initialize(Layout_t &)
Mesh_t & get_mesh() const
void scatter(Field< T, Dim, M, C > &f, const ParticleAttrib< Vektor< PT, Dim > > &pp, const IntOp &) const
virtual void destroy(size_t M, size_t I, bool optDestroy=true)
virtual void create(size_t)
const NDIndex< Dim > & getDomain() const
void set_origin(const Vektor< MFLOAT, Dim > &o)
void set_meshSpacing(MFLOAT *const del)
RegionLayout< T, Dim, Mesh > & getLayout()
static void stopTimer(TimerRef t)
static void startTimer(TimerRef t)
Vektor< double, 3 > Vector_t