32 #ifndef SIGMAGENERATOR_H
33 #define SIGMAGENERATOR_H
41 #include <boost/numeric/ublas/matrix.hpp>
87 double E,
double m,
double q,
const Cyclotron* cycl,
88 unsigned int N,
unsigned int Nsectors,
unsigned int truncOrder,
bool write =
true);
103 bool match(
double accuracy,
unsigned int maxit,
unsigned int maxitOrbit,
104 Cyclotron* cycl,
double denergy,
double rguess,
bool full);
241 const std::vector<matrix_t>&);
276 template<
class matrix>
279 template<
class matrix>
310 return std::array<double,3>{{
318 template<
class matrix>
332 for (
unsigned int i = 0; i < 2; ++i) {
337 M4x4(i + 2,0) = M(i + 4,0);
338 M4x4(i + 2,1) = M(i + 4,1);
343 M4x4(i + 2,2) = M(i + 4,4);
344 M4x4(i + 2,3) = M(i + 4,5);
351 template<
class matrix>
363 matrix M6x6 = boost::numeric::ublas::identity_matrix<double>(6,6);
365 for (
unsigned int i = 0; i < 2; ++i) {
370 M6x6(i + 4,0) = M(i + 2,0);
371 M6x6(i + 4,1) = M(i + 2,1);
376 M6x6(i + 4,4) = M(i + 2,2);
377 M6x6(i + 4,5) = M(i + 2,3);
constexpr double pi
The value of.
Vector truncated power series in n variables.
boost::numeric::ublas::compressed_matrix< double, boost::numeric::ublas::row_major > sparse_matrix_t
Sparse matrix type definition.
boost::numeric::ublas::matrix< double > matrix_t
Dense matrix type definition.
boost::numeric::ublas::vector< double, std::vector< double > > vector_t
Dense vector type definition.
unsigned int niterations_m
Is the number of iterations needed for convergence.
double E_m
Stores the user-define energy, .
bool write_m
Decides for writing output (default: true)
void writeMatrix(std::ofstream &, const matrix_t &)
double isEigenEllipse(const matrix_t &Mturn, const matrix_t &sigma)
Checks if the sigma-matrix is an eigenellipse and returns the L2 error.
std::vector< double > container_t
Container for storing the properties for each angle.
std::array< double, 3 > getEmittances() const
double gamma2_m
Relativistic factor squared.
FTps< double, 2 *3 > Series
Type of the truncated power series.
Hamiltonian H_m
Stores the Hamiltonian of the cyclotron.
double m_m
Is the mass of the particles, .
matrix_t & getSigma()
Returns the converged stationary distribution.
double error_m
Error of computation.
matrix_t updateInitialSigma(const matrix_t &, const vector_t &, sparse_matrix_t &, sparse_matrix_t &)
Computes the new initial sigma matrix.
unsigned int nSteps_m
Number of integration steps in total.
RealDiracMatrix::sparse_matrix_t sparse_matrix_t
Type for storing the sparse maps.
unsigned int nSectors_m
Number of (symmetric) sectors the field is averaged over.
unsigned int nStepsPerSector_m
Number of integration steps per sector (--> also: number of maps per sector)
const double & getInjectionRadius() const
double I_m
Stores the value of the current, .
std::function< Series(double, double, double)> SpaceCharge
Type of the Hamiltonian for the space charge.
double Emin_m
Minimum energy needed in cyclotron, .
unsigned int truncOrder_m
Truncation order of the power series for the Hamiltonian (cyclotron and space charge)
SigmaGenerator(double I, double ex, double ey, double ez, double E, double m, double q, const Cyclotron *cycl, unsigned int N, unsigned int Nsectors, unsigned int truncOrder, bool write=true)
Constructs an object of type SigmaGenerator.
double L2ErrorNorm(const matrix_t &, const matrix_t &)
Returns the L2-error norm between the old and new sigma-matrix.
RealDiracMatrix rdm_m
RealDiracMatrix-class member used for decoupling
FVps< double, 2 *3 > Map
Type of a map.
Series x_m
All variables x, px, z, pz, l, delta.
SpaceCharge Hsc_m
Stores the Hamiltonian for the space charge.
double q_m
Is the particle charge [e].
RealDiracMatrix::matrix_t matrix_t
Type for storing maps.
std::vector< matrix_t > sigmas_m
Vector storing the second moment matrix for each angle.
double Emax_m
Maximum energy reached in cyclotron, .
matrix_t sigma_m
Stores the stationary distribution (sigma matrix)
double nh_m
Harmonic number, .
vector_t decouple(const matrix_t &Mturn, sparse_matrix_t &R, sparse_matrix_t &invR)
Block diagonalizes the symplex part of the one turn transfer matrix.
double getError() const
Returns the error (if the program didn't converged, one can call this function to check the error)
const double & getInjectionMomentum() const
double wo_m
Is the orbital frequency, .
std::function< Series(double, double, double)> Hamiltonian
Type of the Hamiltonian for the cyclotron.
unsigned int N_m
Number of integration steps for closed orbit computation.
void initialize(double, double)
bool converged_m
Is true if converged, false otherwise.
void writeOrbitOutput_m(const container_t &r_turn, const container_t &peo, const container_t &h_turn, const container_t &fidx_turn, const container_t &ds_turn)
Called within SigmaGenerator::match().
void updateSigma(const std::vector< matrix_t > &, const std::vector< matrix_t > &)
Computes new sigma matrices (one for each angle)
std::string float2string(double val)
Transforms a floating point value to a string.
RealDiracMatrix::vector_t vector_t
Type for storing vectors.
unsigned int getIterations() const
Returns the number of iterations needed for convergence (if not converged, it returns zero)
double beta_m
Velocity (c/v), .
std::array< double, 3 > emittance_m
bool match(double accuracy, unsigned int maxit, unsigned int maxitOrbit, Cyclotron *cycl, double denergy, double rguess, bool full)
Searches for a matched distribution.