1 #ifndef _ENVELOPE_BUNCH_H
2 #define _ENVELOPE_BUNCH_H
91 void initialize(
int sli,
double charge,
double energy,
double width,
double te,
double frac,
92 double current,
double center,
double bX,
double bY,
double mX,
double mY,
double Bz,
int nbin);
112 void timeStep(
double tStep,
double zCat = 0.0);
121 void derivs(
double tc,
double Y[],
double dYdt[]);
204 sign_m = _Q < 0.0 ? -1 : 1;
360 min[2] = this->
zTail();
363 max[2] = this->
zHead();
422 std::unique_ptr<Vector_t[]>
KR;
424 std::unique_ptr<Vector_t[]>
KT;
426 std::unique_ptr<Vector_t[]>
EF;
428 std::unique_ptr<Vector_t[]>
BF;
430 std::vector< std::shared_ptr<EnvelopeSlice> >
slices_m;
521 void calcEmittance(
double *emtnx,
double *emtny,
double *emtx,
double *emty,
int *nValid);
531 void calcEnergyChirp(
double *g0,
double *dgdt,
double *gInc,
int *nValid);
552 void setTShape(
double enx,
double eny,
double rx,
double ry,
double b0);
562 void setTOffset(
double x0,
double px0,
double y0,
double py0);
std::unique_ptr< Vector_t[]> EF
external E fields
size_t mySliceEndOffset_m
last global slice on this processor
double zCat_m
cathode position
pX0 angular deflection centriod x
ParticleAttrib< Vector_t > P
void setR(int i, const Vector_t &R)
std::ostream & operator<<(std::ostream &os, const Attribute &attr)
std::vector< double > Exw_m
transverse wake field x
void setP(int i, const Vector_t &P)
void setBeta(int i, double val)
void setPy(int i, double val)
void setPy0(int i, double val)
double get_dEdt()
returns the energy spread
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
Vector_t minX()
returns vector with the min spatial extends of the bunch
double get_meanKineticEnergy()
returns the mean energy
void calcEmittance(double *emtnx, double *emtny, double *emtx, double *emty, int *nValid)
calculate bunch emittance
Vector_t get_rrms()
returns RMS x,y,z
double emtnx0_m
intrinsic normalized emittance of slice [m rad]
double getT()
returns the current time of the bunch
void backup()
backup slice values
wakes and space-charge fields calculated
double t_m
local time in bunch [s]
std::vector< double > b_m
synchronized betas for parallel tracker
core of the envelope tracker based on Rene Bakkers BET implementation
Vector_t maxX()
returns vector with the max spatial extends of the bunch
Vector_t get_norm_emit()
returns vector with normalized emittance
double dfi_x_m
rotation of coordinate system when tracking along the s-axis [rad]
std::unique_ptr< Vector_t[]> KR
define value of radial kick for each slice
unsigned int activeSlice_m
void setCharge(double _Q)
set the charge of the bunch
IpplTimings::TimerRef calcITimer_m
void synchronizeSlices()
synchronize z position and betas of all slices (needed in calcI and space charge calculation) ...
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
double getZ(int i)
returns Z coordinate of slice i
Vector_t KTsl_m
transverse kick of beam
int numMySlices_m
number of my slices in bunch
void initialize(int sli, double charge, double energy, double width, double te, double frac, double current, double center, double bX, double bY, double mX, double mY, double Bz, int nbin)
void setZ(int i, double coo)
set Z coordinate of slice i
void createBunch()
create and initialize local num slices
slice data synchronized with other MPI nodes
beta normalized velocity (total) [-]
double getGamma(int i)
returns gamma of slice i
double zAvg()
calculate <z> [m]
bool isOffaxis()
check if solver includes off-axis tracking
void setTOffset(double x0, double px0, double y0, double py0)
set transverse offset of bunch
std::vector< std::vector< int > > bins_m
bins for emission
void setX(int i, double val)
int sign_m
gives the sign of charge Q
double getX0(int i)
returns X coordinate of the centroid of slice i
double hbin_m
emission bin width
double zHead()
calculate the head of the bunch [m]
double emtbx0_m
intrinsic normalized emittance Bush effect [m rad]
void getExternalFields(int i, Vector_t &EF, Vector_t &BF, Vector_t &KR, Vector_t &KT) const
transverse wakes calculated
Vector_t sigmax()
returns vector with rms position
constexpr double m_e
The electron rest mass in GeV.
double AvBField()
returns average magnetic field
angular deflection centriod x
pY0 angular deflection centriod y
EnvelopeBunch(const PartData *ref)
Default constructor.
int solver_m
see enum SolverParameters
double Bz0_m
magnetic field on cathode [T]
int dStat_m
see enum DataStatus
void setEx(double emi)
set emittance X
py beam divergence y [rad]
void setTShape(double enx, double eny, double rx, double ry, double b0)
set transverse shape of bunch (initial distribution)
Vector_t maxP()
returns vector with the max momentum of the bunch
Vector_t emtn()
returns vector with emittance
double getPy(int i)
returns Y momenta of slice i
double zTail()
calculate tail of bunch [m]
std::unique_ptr< Vector_t[]> BF
external B fields
double getY0(int i)
returns Y coordinate of the centroid of slice i
int numSlices_m
number of total slices in bunch
std::unique_ptr< Profile > currentProfile_m
current profile of bunch (fit)
int currentSlice_m
current Slice set in run() & cSpaceCharge() and used in derivs() & zcsI()
double get_sPos()
return reference position
include radial movement in DV
void setExternalFields(int i, const Vector_t &EF, const Vector_t &BF, const Vector_t &KR, const Vector_t &KT)
double getPx0(int i)
returns angular deflection centroid in x of slice i
bool isRadial()
check if solver includes radial
Vector_t Esl_m
electric field
size_t mySliceEndOffset()
double I0avg_m
average current on creation of bunch (see setLshape)
longitudinal wakes calculated
fields synchronized with other MPI nodes
X0 position centroid x [m].
int getLocalNum()
returns the number of local slices
void setX0(int i, double val)
std::vector< double > Esct_m
Longitudinal Space-charge field.
double getPy0(int i)
returns angular deflection centroid in y of slice i
int activeSlices_m
number of active slices
void calcI()
calculates the current current distribution
double Eavg()
calculate the average energy of the bunch
std::vector< std::shared_ptr< EnvelopeSlice > > slices_m
array of slices
double emission_time_step_m
Tps< T > sqrt(const Tps< T > &x)
Square root.
ParticleAttrib< double > dt
std::vector< double > Ezw_m
longitudinal wake field
void setY(int i, double val)
void initialize(FieldLayout_t *fLayout)
void derivs(double tc, double Y[], double dYdt[])
helper function to calculate derivatives need in RH equation
double getY(int i)
returns Y coordinate of slice i
Inform & slprint(Inform &os)
void computeSpaceCharge()
double AvEField()
returns average electric field
normalized velocity (total) [-]
std::vector< double > z_m
synchronized z positions for parallel tracker
double t_offset_m
accumulated time offset by tReset function
void setY0(int i, double val)
void distributeSlices(int nSlice=101)
distributes nSlice amongst processors and initializes slices
void setBinnedLShape(EnvelopeBunchShape shape, double z0, double w, double frac)
set longitudinal shape of bunch (initial distribution)
double getChargePerParticle()
returns charge per slice
double getPz(int i)
returns Z momenta of slice i
Y0 position centroid y [m].
void setSolverParameter(int s)
set the DE solver flag
double getBeta(int i)
returns beta of slice i
double Q_m
total bunch charge [C]
void setPx0(int i, double val)
Vector_t KRsl_m
radial focussing term beam
Vector_t sigmap()
returns vector with rms momenta
void setEy(double emi)
set emittance Y
double tReset(double dt=0.0)
void timeStep(double tStep, double zCat=0.0)
performs a time-step for all active slices (also handles emission)
px beam divergence x [rad]
double getPx(int i)
returns X momenta of slice i
void get_bounds(Vector_t &min, Vector_t &max)
returns bounds of envelope bunch
Timing::TimerRef TimerRef
std::vector< double > Eyw_m
transverse wake field y
int nebin_m
number of bins for emission
include off-axis movement in DV
int getTotalNum()
returns the total number of slices
double moveZ0(double zC)
move the complete bunch forward such that the head of the bunch matches the cahtode position ...
size_t mySliceStartOffset()
void setEnergy(double, double=0.0)
Vector_t Bsl_m
magnetic field
void runStats(EnvelopeBunchParameter sp, double *xAvg, double *xMax, double *xMin, double *rms, int *nValid)
run statistics on slices
void calcBeamParameters()
calculates envelope statistics
T::PETE_Expr_t::PETE_Return_t min(const PETE_Expr< T > &expr, NDIndex< D > &loc)
void setPx(int i, double val)
int firstBinWithValue_m
first bin on processor containing slices
double time()
read time-stamp of bunch
void calcEnergyChirp(double *g0, double *dgdt, double *gInc, int *nValid)
calculate the energy chirp and uncorrelated energy spread
IpplTimings::TimerRef spaceChargeTimer_m
std::unique_ptr< Vector_t[]> KT
define value of transversal kick for each slice
Vector_t minP()
returns vector with the min momentum of the bunch
size_t mySliceStartOffset_m
first global slice on this processor
double dx0_m
offset of the coordinate system when tracking along the s-axis [m]
solve DV with fixed time-step
Vector_t get_prms()
returns RMSP x,y,z
solve field outside of DV
std::vector< double > G_m
Transverse Space-charge term: Eq.(9)
double getX(int i)
returns X coordinate of slice i