10 #ifndef MAPGENERATOR_H
11 #define MAPGENERATOR_H
17 #include <boost/numeric/ublas/matrix.hpp>
28 template<
typename Value_type,
typename Size_type,
typename Series_type,
29 typename Map_type,
typename Hamiltonian_type,
typename Space_charge_type>
47 typedef boost::numeric::ublas::matrix<value_type>
matrix_type;
72 void combine(std::vector<matrix_type>&, std::vector<matrix_type>&);
104 template<
typename Value_type,
106 typename Series_type,
108 typename Hamiltonian_type,
109 typename Space_charge_type>
119 template<
typename Value_type,
121 typename Series_type,
123 typename Hamiltonian_type,
124 typename Space_charge_type>
130 Space_charge_type>::matrix_type
146 matrix_type map = boost::numeric::ublas::zero_matrix<value_type>(6);
150 map(i,j) = matrix[i][j];
157 template<
typename Value_type,
159 typename Series_type,
161 typename Hamiltonian_type,
162 typename Space_charge_type>
168 Space_charge_type>::combine(std::vector<matrix_type>& Mscs,
169 std::vector<matrix_type>& Mcycs) {
171 if (nMaps_m != Mscs.size() || nMaps_m != Mcycs.size())
172 throw OpalException(
"MapGenerator::combine()",
"Wrong vector dimensions.");
174 Mturn_m = boost::numeric::ublas::identity_matrix<value_type>(6);
177 Mturn_m = matt_boost::gemmm<matrix_type>(Mscs[i],Mcycs[i],Mturn_m);
180 template<
typename Value_type,
182 typename Series_type,
184 typename Hamiltonian_type,
185 typename Space_charge_type>
191 Space_charge_type>::matrix_type
197 Space_charge_type>::combine(std::vector<matrix_type>& maps)
199 matrix_type map = boost::numeric::ublas::identity_matrix<value_type>(6);
201 for (std::size_t i = 0; i < maps.size(); ++i) {
211 template<
typename Value_type,
213 typename Series_type,
215 typename Hamiltonian_type,
216 typename Space_charge_type>
222 Space_charge_type>::matrix_type
228 Space_charge_type>::getMap() {
233 template<
typename Value_type,
235 typename Series_type,
237 typename Hamiltonian_type,
238 typename Space_charge_type>
240 std::pair<Value_type,
259 arg = 0.5 * ( map(0, 0) + map(1, 1) );
263 "Horizontal phase advance: Acos argument " + std::to_string(
arg) +
" out of range.");
268 arg = 0.5 * ( map(2, 2) + map(3, 3) );
272 "Vertical phase advance: Acos argument " + std::to_string(
arg) +
" out of range.");
T * value_type(const SliceIterator< T > &)
FVps< T, N > ExpMap(const FTps< T, N > &H, int trunc=FTps< T, N >::EXACT)
Build the exponential series.
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
T::PETE_Expr_t::PETE_Return_t prod(const PETE_Expr< T > &expr)
PETE_TUTree< FnArcCos, typename T::PETE_Expr_t > acos(const PETE_Expr< T > &l)
constexpr double u_two_pi
The value of.
A templated representation for matrices.
This class generates the matrices for the one turn matrix of a cyclotron.
Series_type series_type
Type of truncated power series.
boost::numeric::ublas::matrix< value_type > matrix_type
Type for specifying matrices.
Hamiltonian_type hamiltonian_type
Type of the Hamiltonian.
Value_type value_type
Type of variables.
MapGenerator(size_type)
Initialize.
std::pair< value_type, value_type > computeTunes(const matrix_type &map)
matrix_type Mturn_m
One-turn matrix.
Size_type size_type
Type for specifying sizes.
matrix_type generateMap(const series_type &, value_type, size_type)
Generates a map based on the Hamiltonian for a given angle.
matrix_type getMap()
Returns the one turn map.
Space_charge_type space_charge_type
Type of the Hamiltonian representing the space charge.
std::vector< value_type > vector_type
Type for specifying vectors.
void combine(std::vector< matrix_type > &, std::vector< matrix_type > &)
Combine given maps.
size_type nMaps_m
Number of maps.
Map_type map_type
Type of a map.
The base class for all OPAL exceptions.