OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
ClosedOrbitFinder< Value_type, Size_type, Stepper > Class Template Reference

Finds a closed orbit of a cyclotron for a given energy. More...

#include <ClosedOrbitFinder.h>

Collaboration diagram for ClosedOrbitFinder< Value_type, Size_type, Stepper >:
Collaboration graph
[legend]

Public Types

typedef Value_type value_type
 Type of variables. More...
 
typedef Size_type size_type
 Type for specifying sizes. More...
 
typedef std::vector< value_typecontainer_type
 Type of container for storing quantities (path length, orbit, etc.) More...
 
typedef std::vector< value_typestate_type
 Type for holding state of ODE values. More...
 
typedef std::function< void(const
state_type &, state_type
&, const double)> 
function_t
 

Public Member Functions

 ClosedOrbitFinder (value_type E0, size_type N, Cyclotron *cycl, bool domain=true, int Nsectors=1)
 Sets the initial values for the integration and calls findOrbit(). More...
 
container_type getInverseBendingRadius (const value_type &angle=0)
 Returns the inverse bending radius (size of container N+1) More...
 
container_type getPathLength (const value_type &angle=0)
 Returns the step lengths of the path (size of container N+1) More...
 
container_type getFieldIndex (const value_type &angle=0)
 Returns the field index (size of container N+1) More...
 
std::pair< value_type, value_typegetTunes ()
 Returns the radial and vertical tunes (in that order) More...
 
container_type getOrbit (value_type angle=0)
 
container_type getMomentum (value_type angle=0)
 
value_type getAverageRadius ()
 Returns the average orbit radius. More...
 
value_type getFrequencyError ()
 Returns the frequency error. More...
 
bool isConverged ()
 Returns true if a closed orbit could be found. More...
 
bool findOrbit (value_type accuracy, size_type maxit, value_type ekin, value_type dE=1.0, value_type rguess=-1.0, bool isTuneMode=false)
 Computes the closed orbit. More...
 
void computeOrbitProperties (const value_type &E)
 Fills in the values of h_m, ds_m, fidx_m. More...
 

Private Member Functions

value_type computeTune (const std::array< value_type, 2 > &, value_type, size_type)
 This function is called by the function getTunes(). More...
 
bool findOrbitOfEnergy_m (const value_type &, container_type &, value_type &, const value_type &, size_type)
 
container_type rotate (value_type angle, container_type &orbitProperty)
 This function computes nzcross_ which is used to compute the tune in z-direction and the frequency error. More...
 

Private Attributes

std::array< value_type, 2 > x_m
 Stores current position in horizontal direction for the solutions of the ODE with different initial values. More...
 
std::array< value_type, 2 > px_m
 Stores current momenta in horizontal direction for the solutions of the ODE with different initial values. More...
 
std::array< value_type, 2 > z_m
 Stores current position in vertical direction for the solutions of the ODE with different initial values. More...
 
std::array< value_type, 2 > pz_m
 Stores current momenta in vertical direction for the solutions of the ODE with different initial values. More...
 
container_type h_m
 Stores the inverse bending radius. More...
 
container_type ds_m
 Stores the step length. More...
 
container_type r_m
 Stores the radial orbit (size: N_m+1) More...
 
container_type vz_m
 Stores the vertical oribt (size: N_m+1) More...
 
container_type pr_m
 Stores the radial momentum. More...
 
container_type vpz_m
 Stores the vertical momentum. More...
 
container_type fidx_m
 Stores the field index. More...
 
size_type nxcross_m
 Counts the number of zero-line crossings in horizontal direction (used for computing horizontal tune) More...
 
size_type nzcross_m
 Counts the number of zero-line crossings in vertical direction (used for computing vertical tune) More...
 
value_type E0_m
 Is the rest mass [MeV / c**2]. More...
 
value_type wo_m
 Is the nominal orbital frequency. More...
 
size_type N_m
 Number of integration steps. More...
 
value_type dtheta_m
 Is the angle step size. More...
 
value_type ravg_m
 Is the average radius. More...
 
value_type phase_m
 Is the phase. More...
 
bool domain_m
 
int nSectors_m
 
Stepper stepper_m
 Defines the stepper for integration of the ODE's. More...
 
std::function< double(double)> acon_m = [](double wo) { return Physics::c / wo; }
 
std::function< double(double,
double)> 
bcon_m
 Cyclotron unit \( \left[T\right] \) (Tesla) More...
 
Cyclotroncycl_m
 

Detailed Description

template<typename Value_type, typename Size_type, class Stepper>
class ClosedOrbitFinder< Value_type, Size_type, Stepper >

Finds a closed orbit of a cyclotron for a given energy.

Definition at line 42 of file ClosedOrbitFinder.h.

Member Typedef Documentation

template<typename Value_type, typename Size_type, class Stepper>
typedef std::vector<value_type> ClosedOrbitFinder< Value_type, Size_type, Stepper >::container_type

Type of container for storing quantities (path length, orbit, etc.)

Definition at line 50 of file ClosedOrbitFinder.h.

template<typename Value_type, typename Size_type, class Stepper>
typedef std::function<void(const state_type&, state_type&, const double)> ClosedOrbitFinder< Value_type, Size_type, Stepper >::function_t

Definition at line 54 of file ClosedOrbitFinder.h.

template<typename Value_type, typename Size_type, class Stepper>
typedef Size_type ClosedOrbitFinder< Value_type, Size_type, Stepper >::size_type

Type for specifying sizes.

Definition at line 48 of file ClosedOrbitFinder.h.

template<typename Value_type, typename Size_type, class Stepper>
typedef std::vector<value_type> ClosedOrbitFinder< Value_type, Size_type, Stepper >::state_type

Type for holding state of ODE values.

Definition at line 52 of file ClosedOrbitFinder.h.

template<typename Value_type, typename Size_type, class Stepper>
typedef Value_type ClosedOrbitFinder< Value_type, Size_type, Stepper >::value_type

Type of variables.

Definition at line 46 of file ClosedOrbitFinder.h.

Constructor & Destructor Documentation

template<typename Value_type , typename Size_type , class Stepper >
ClosedOrbitFinder< Value_type, Size_type, Stepper >::ClosedOrbitFinder ( value_type  E0,
size_type  N,
Cyclotron cycl,
bool  domain = true,
int  Nsectors = 1 
)

Sets the initial values for the integration and calls findOrbit().

Parameters
E0is the potential energy (particle energy at rest) [MeV].
Nspecifies the number of splits (2pi/N), i.e number of integration steps
cyclis the cyclotron element
domainis a boolean (default: true). If "true" the closed orbit is computed over a single sector, otherwise over 2*pi.
Nsectorsis an int (default: 1). Number of sectors that the field map is averaged over in order to avoid first harmonic. Only valid if domain is false

Definition at line 246 of file ClosedOrbitFinder.h.

References ClosedOrbitFinder< Value_type, Size_type, Stepper >::cycl_m, ClosedOrbitFinder< Value_type, Size_type, Stepper >::domain_m, ClosedOrbitFinder< Value_type, Size_type, Stepper >::ds_m, ClosedOrbitFinder< Value_type, Size_type, Stepper >::fidx_m, Cyclotron::getBScale(), Cyclotron::getCyclotronType(), Cyclotron::getFieldFlag(), Cyclotron::getFMHighE(), Cyclotron::getFMLowE(), Cyclotron::getSymmetry(), ClosedOrbitFinder< Value_type, Size_type, Stepper >::h_m, ClosedOrbitFinder< Value_type, Size_type, Stepper >::N_m, ClosedOrbitFinder< Value_type, Size_type, Stepper >::pr_m, ClosedOrbitFinder< Value_type, Size_type, Stepper >::r_m, Cyclotron::read(), ClosedOrbitFinder< Value_type, Size_type, Stepper >::vpz_m, and ClosedOrbitFinder< Value_type, Size_type, Stepper >::vz_m.

Here is the call graph for this function:

Member Function Documentation

template<typename Value_type , typename Size_type , class Stepper >
void ClosedOrbitFinder< Value_type, Size_type, Stepper >::computeOrbitProperties ( const value_type E)

Fills in the values of h_m, ds_m, fidx_m.

Definition at line 818 of file ClosedOrbitFinder.h.

References sqrt(), and value_type().

Here is the call graph for this function:

template<typename Value_type , typename Size_type , class Stepper >
Value_type ClosedOrbitFinder< Value_type, Size_type, Stepper >::computeTune ( const std::array< value_type, 2 > &  y,
value_type  py2,
size_type  ncross 
)
private

This function is called by the function getTunes().

Transfer matrix Y = [y11, y12; y21, y22] (see Gordon paper for more details).

Parameters
yare the positions (elements y11 and y12 of Y)
py2is the momentum of the second solution (element y22 of Y)
ncrossis the number of sign changes (#crossings of zero-line)

Definition at line 760 of file ClosedOrbitFinder.h.

References acos(), cos(), fabs(), Physics::pi, sin(), Physics::two_pi, and Physics::u_two_pi.

Here is the call graph for this function:

template<typename Value_type , typename Size_type , class Stepper >
bool ClosedOrbitFinder< Value_type, Size_type, Stepper >::findOrbit ( value_type  accuracy,
size_type  maxit,
value_type  ekin,
value_type  dE = 1.0,
value_type  rguess = -1.0,
bool  isTuneMode = false 
)

Computes the closed orbit.

Parameters
accuracyspecifies the accuracy of the closed orbit
maxitis the maximal number of iterations done for finding the closed orbit
ekinenergy for which to find closed orbit (in tune mode: upper limit of range)
dEstep increase [MeV]
rguessinitial radius guess in [mm]
isTuneModecomptute tunes of all energies in one sweep

Definition at line 396 of file ClosedOrbitFinder.h.

References endl(), Hypervolume::fs, OpalData::getInputBasename(), OpalData::getInstance(), max(), EmissionModelT::NONE, and sqrt().

Here is the call graph for this function:

template<typename Value_type , typename Size_type , class Stepper >
bool ClosedOrbitFinder< Value_type, Size_type, Stepper >::findOrbitOfEnergy_m ( const value_type E,
container_type init,
value_type error,
const value_type accuracy,
size_type  maxit 
)
private

Definition at line 573 of file ClosedOrbitFinder.h.

References endl(), sqrt(), Physics::two_pi, Physics::u_two_pi, ClassicException::what(), and ClassicException::where().

Here is the call graph for this function:

template<typename Value_type , typename Size_type , class Stepper >
ClosedOrbitFinder< Value_type, Size_type, Stepper >::value_type ClosedOrbitFinder< Value_type, Size_type, Stepper >::getAverageRadius ( )
inline

Returns the average orbit radius.

Definition at line 377 of file ClosedOrbitFinder.h.

template<typename Value_type , typename Size_type , class Stepper >
ClosedOrbitFinder< Value_type, Size_type, Stepper >::container_type ClosedOrbitFinder< Value_type, Size_type, Stepper >::getFieldIndex ( const value_type angle = 0)
inline

Returns the field index (size of container N+1)

Definition at line 315 of file ClosedOrbitFinder.h.

template<typename Value_type , typename Size_type , class Stepper >
ClosedOrbitFinder< Value_type, Size_type, Stepper >::value_type ClosedOrbitFinder< Value_type, Size_type, Stepper >::getFrequencyError ( )

Returns the frequency error.

Definition at line 384 of file ClosedOrbitFinder.h.

template<typename Value_type , typename Size_type , class Stepper >
ClosedOrbitFinder< Value_type, Size_type, Stepper >::container_type ClosedOrbitFinder< Value_type, Size_type, Stepper >::getInverseBendingRadius ( const value_type angle = 0)
inline

Returns the inverse bending radius (size of container N+1)

Definition at line 295 of file ClosedOrbitFinder.h.

template<typename Value_type , typename Size_type , class Stepper >
ClosedOrbitFinder< Value_type, Size_type, Stepper >::container_type ClosedOrbitFinder< Value_type, Size_type, Stepper >::getMomentum ( value_type  angle = 0)
inline

Returns the momentum of the orbit (size of container N+1)starting at specific angle (only makes sense when computing the closed orbit for a whole turn) (default value: 0°), \( \left[ p_{r} \right] = \si{m}\). Attention: It computes the starting index of the array. If it's not an integer it just cuts the floating point part, i.e. it takes the next starting index below. There's no interpolation of the momentum.

Parameters
angleis the start angle for the output. Has to be within [0°,360°[ (default: 0°).
Returns
the momentum in \( \beta * \gamma \) units

Definition at line 345 of file ClosedOrbitFinder.h.

References for_each().

Here is the call graph for this function:

template<typename Value_type , typename Size_type , class Stepper >
ClosedOrbitFinder< Value_type, Size_type, Stepper >::container_type ClosedOrbitFinder< Value_type, Size_type, Stepper >::getOrbit ( value_type  angle = 0)
inline

Returns the closed orbit (size of container N+1) starting at specific angle (only makes sense when computing the closed orbit for a whole turn) (default value: 0°). Attention: It computes the starting index of the array. If it's not an integer it just cuts the floating point part, i.e. it takes the next starting index below. There's no interpolation of the radius.

Parameters
angleis the start angle for the output. Has to be within [0°,360°[ (default: 0°).

Definition at line 335 of file ClosedOrbitFinder.h.

template<typename Value_type , typename Size_type , class Stepper >
ClosedOrbitFinder< Value_type, Size_type, Stepper >::container_type ClosedOrbitFinder< Value_type, Size_type, Stepper >::getPathLength ( const value_type angle = 0)
inline

Returns the step lengths of the path (size of container N+1)

Definition at line 305 of file ClosedOrbitFinder.h.

template<typename Value_type , typename Size_type , class Stepper >
std::pair< Value_type, Value_type > ClosedOrbitFinder< Value_type, Size_type, Stepper >::getTunes ( )

Returns the radial and vertical tunes (in that order)

Definition at line 323 of file ClosedOrbitFinder.h.

template<typename Value_type, typename Size_type, class Stepper>
bool ClosedOrbitFinder< Value_type, Size_type, Stepper >::isConverged ( )

Returns true if a closed orbit could be found.

template<typename Value_type , typename Size_type , class Stepper >
ClosedOrbitFinder< Value_type, Size_type, Stepper >::container_type ClosedOrbitFinder< Value_type, Size_type, Stepper >::rotate ( value_type  angle,
container_type orbitProperty 
)
inlineprivate

This function computes nzcross_ which is used to compute the tune in z-direction and the frequency error.

This function rotates the calculated closed orbit finder properties to the initial angle

Definition at line 873 of file ClosedOrbitFinder.h.

Member Data Documentation

template<typename Value_type, typename Size_type, class Stepper>
std::function<double(double)> ClosedOrbitFinder< Value_type, Size_type, Stepper >::acon_m = [](double wo) { return Physics::c / wo; }
private

This quantity is defined in the paper "Transverse-Longitudinal Coupling by Space Charge in Cyclotrons" of Dr. Christian Baumgarten (2012) The lambda function takes the orbital frequency \( \omega_{o} \) (also defined in paper) as input argument.

Definition at line 226 of file ClosedOrbitFinder.h.

template<typename Value_type, typename Size_type, class Stepper>
std::function<double(double, double)> ClosedOrbitFinder< Value_type, Size_type, Stepper >::bcon_m
private
Initial value:
= [](double e0, double wo) {
return e0 * 1.0e7 / ( 1.0 * Physics::c * Physics::c / wo);
}

Cyclotron unit \( \left[T\right] \) (Tesla)

The lambda function takes the orbital frequency \( \omega_{o} \) as input argument.

Definition at line 232 of file ClosedOrbitFinder.h.

template<typename Value_type, typename Size_type, class Stepper>
Cyclotron* ClosedOrbitFinder< Value_type, Size_type, Stepper >::cycl_m
private
template<typename Value_type, typename Size_type, class Stepper>
bool ClosedOrbitFinder< Value_type, Size_type, Stepper >::domain_m
private

Stores the last orbit value (since we have to return to the beginning to check the convergence in the findOrbit() function. This last value is then deleted from the array but is stored in lastOrbitVal_m to compute the vertical oscillations) Stores the last momentum value (since we have to return to the beginning to check the convergence in the findOrbit() function. This last value is then deleted from the array but is stored in lastMomentumVal_m to compute the vertical oscillations) Boolean which is true by default. "true": orbit integration over one sector only, "false": integration over 2*pi

Definition at line 211 of file ClosedOrbitFinder.h.

Referenced by ClosedOrbitFinder< Value_type, Size_type, Stepper >::ClosedOrbitFinder().

template<typename Value_type, typename Size_type, class Stepper>
container_type ClosedOrbitFinder< Value_type, Size_type, Stepper >::ds_m
private

Stores the step length.

Definition at line 157 of file ClosedOrbitFinder.h.

Referenced by ClosedOrbitFinder< Value_type, Size_type, Stepper >::ClosedOrbitFinder().

template<typename Value_type, typename Size_type, class Stepper>
value_type ClosedOrbitFinder< Value_type, Size_type, Stepper >::dtheta_m
private

Is the angle step size.

Definition at line 185 of file ClosedOrbitFinder.h.

template<typename Value_type, typename Size_type, class Stepper>
value_type ClosedOrbitFinder< Value_type, Size_type, Stepper >::E0_m
private

Is the rest mass [MeV / c**2].

Definition at line 175 of file ClosedOrbitFinder.h.

template<typename Value_type, typename Size_type, class Stepper>
container_type ClosedOrbitFinder< Value_type, Size_type, Stepper >::fidx_m
private

Stores the field index.

Definition at line 167 of file ClosedOrbitFinder.h.

Referenced by ClosedOrbitFinder< Value_type, Size_type, Stepper >::ClosedOrbitFinder().

template<typename Value_type, typename Size_type, class Stepper>
container_type ClosedOrbitFinder< Value_type, Size_type, Stepper >::h_m
private

Stores the inverse bending radius.

Definition at line 155 of file ClosedOrbitFinder.h.

Referenced by ClosedOrbitFinder< Value_type, Size_type, Stepper >::ClosedOrbitFinder().

template<typename Value_type, typename Size_type, class Stepper>
size_type ClosedOrbitFinder< Value_type, Size_type, Stepper >::N_m
private

Number of integration steps.

Definition at line 183 of file ClosedOrbitFinder.h.

Referenced by ClosedOrbitFinder< Value_type, Size_type, Stepper >::ClosedOrbitFinder().

template<typename Value_type, typename Size_type, class Stepper>
int ClosedOrbitFinder< Value_type, Size_type, Stepper >::nSectors_m
private

Number of sectors to average the field map over in order to avoid first harmonic. Only valid if domain is false

Definition at line 216 of file ClosedOrbitFinder.h.

template<typename Value_type, typename Size_type, class Stepper>
size_type ClosedOrbitFinder< Value_type, Size_type, Stepper >::nxcross_m
private

Counts the number of zero-line crossings in horizontal direction (used for computing horizontal tune)

Definition at line 170 of file ClosedOrbitFinder.h.

template<typename Value_type, typename Size_type, class Stepper>
size_type ClosedOrbitFinder< Value_type, Size_type, Stepper >::nzcross_m
private

Counts the number of zero-line crossings in vertical direction (used for computing vertical tune)

Definition at line 172 of file ClosedOrbitFinder.h.

template<typename Value_type, typename Size_type, class Stepper>
value_type ClosedOrbitFinder< Value_type, Size_type, Stepper >::phase_m
private

Is the phase.

Definition at line 191 of file ClosedOrbitFinder.h.

template<typename Value_type, typename Size_type, class Stepper>
container_type ClosedOrbitFinder< Value_type, Size_type, Stepper >::pr_m
private

Stores the radial momentum.

Definition at line 163 of file ClosedOrbitFinder.h.

Referenced by ClosedOrbitFinder< Value_type, Size_type, Stepper >::ClosedOrbitFinder().

template<typename Value_type, typename Size_type, class Stepper>
std::array<value_type,2> ClosedOrbitFinder< Value_type, Size_type, Stepper >::px_m
private

Stores current momenta in horizontal direction for the solutions of the ODE with different initial values.

Definition at line 148 of file ClosedOrbitFinder.h.

template<typename Value_type, typename Size_type, class Stepper>
std::array<value_type,2> ClosedOrbitFinder< Value_type, Size_type, Stepper >::pz_m
private

Stores current momenta in vertical direction for the solutions of the ODE with different initial values.

Definition at line 152 of file ClosedOrbitFinder.h.

template<typename Value_type, typename Size_type, class Stepper>
container_type ClosedOrbitFinder< Value_type, Size_type, Stepper >::r_m
private

Stores the radial orbit (size: N_m+1)

Definition at line 159 of file ClosedOrbitFinder.h.

Referenced by ClosedOrbitFinder< Value_type, Size_type, Stepper >::ClosedOrbitFinder().

template<typename Value_type, typename Size_type, class Stepper>
value_type ClosedOrbitFinder< Value_type, Size_type, Stepper >::ravg_m
private

Is the average radius.

Definition at line 188 of file ClosedOrbitFinder.h.

template<typename Value_type, typename Size_type, class Stepper>
Stepper ClosedOrbitFinder< Value_type, Size_type, Stepper >::stepper_m
private

Defines the stepper for integration of the ODE's.

Definition at line 219 of file ClosedOrbitFinder.h.

template<typename Value_type, typename Size_type, class Stepper>
container_type ClosedOrbitFinder< Value_type, Size_type, Stepper >::vpz_m
private

Stores the vertical momentum.

Definition at line 165 of file ClosedOrbitFinder.h.

Referenced by ClosedOrbitFinder< Value_type, Size_type, Stepper >::ClosedOrbitFinder().

template<typename Value_type, typename Size_type, class Stepper>
container_type ClosedOrbitFinder< Value_type, Size_type, Stepper >::vz_m
private

Stores the vertical oribt (size: N_m+1)

Definition at line 161 of file ClosedOrbitFinder.h.

Referenced by ClosedOrbitFinder< Value_type, Size_type, Stepper >::ClosedOrbitFinder().

template<typename Value_type, typename Size_type, class Stepper>
value_type ClosedOrbitFinder< Value_type, Size_type, Stepper >::wo_m
private

Is the nominal orbital frequency.

Definition at line 181 of file ClosedOrbitFinder.h.

template<typename Value_type, typename Size_type, class Stepper>
std::array<value_type,2> ClosedOrbitFinder< Value_type, Size_type, Stepper >::x_m
private

Stores current position in horizontal direction for the solutions of the ODE with different initial values.

Definition at line 146 of file ClosedOrbitFinder.h.

template<typename Value_type, typename Size_type, class Stepper>
std::array<value_type,2> ClosedOrbitFinder< Value_type, Size_type, Stepper >::z_m
private

Stores current position in vertical direction for the solutions of the ODE with different initial values.

Definition at line 150 of file ClosedOrbitFinder.h.


The documentation for this class was generated from the following file: