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

#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, value_type q, 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, const 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 q_m
 
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 >

Definition at line 56 of file ClosedOrbitFinder.h.

Member Typedef Documentation

◆ container_type

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 64 of file ClosedOrbitFinder.h.

◆ function_t

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 68 of file ClosedOrbitFinder.h.

◆ size_type

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 62 of file ClosedOrbitFinder.h.

◆ state_type

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 66 of file ClosedOrbitFinder.h.

◆ value_type

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 60 of file ClosedOrbitFinder.h.

Constructor & Destructor Documentation

◆ ClosedOrbitFinder()

template<typename Value_type , typename Size_type , class Stepper >
ClosedOrbitFinder< Value_type, Size_type, Stepper >::ClosedOrbitFinder ( value_type  E0,
value_type  q,
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].
qis the particle charge [e]
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 264 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::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

◆ computeOrbitProperties()

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 847 of file ClosedOrbitFinder.h.

References sqrt(), and value_type().

Here is the call graph for this function:

◆ computeTune()

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 789 of file ClosedOrbitFinder.h.

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

Here is the call graph for this function:

◆ findOrbit()

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 415 of file ClosedOrbitFinder.h.

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

Here is the call graph for this function:

◆ findOrbitOfEnergy_m()

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 602 of file ClosedOrbitFinder.h.

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

Here is the call graph for this function:

◆ getAverageRadius()

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 396 of file ClosedOrbitFinder.h.

◆ getFieldIndex()

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 334 of file ClosedOrbitFinder.h.

◆ getFrequencyError()

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 403 of file ClosedOrbitFinder.h.

◆ getInverseBendingRadius()

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 314 of file ClosedOrbitFinder.h.

◆ getMomentum()

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 364 of file ClosedOrbitFinder.h.

References for_each().

Here is the call graph for this function:

◆ getOrbit()

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 354 of file ClosedOrbitFinder.h.

◆ getPathLength()

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 324 of file ClosedOrbitFinder.h.

◆ getTunes()

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 342 of file ClosedOrbitFinder.h.

◆ isConverged()

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.

◆ rotate()

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,
const 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 902 of file ClosedOrbitFinder.h.

Member Data Documentation

◆ acon_m

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 244 of file ClosedOrbitFinder.h.

◆ bcon_m

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:
= [this](double e0, double wo) {
return e0 * 1.0e7 / (q_m * Physics::c * Physics::c / wo);
}
constexpr double c
The velocity of light in m/s.
Definition: Physics.h:45

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

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

Definition at line 250 of file ClosedOrbitFinder.h.

◆ cycl_m

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

◆ domain_m

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 229 of file ClosedOrbitFinder.h.

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

◆ ds_m

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 172 of file ClosedOrbitFinder.h.

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

◆ dtheta_m

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 203 of file ClosedOrbitFinder.h.

◆ E0_m

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 190 of file ClosedOrbitFinder.h.

◆ fidx_m

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 182 of file ClosedOrbitFinder.h.

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

◆ h_m

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 170 of file ClosedOrbitFinder.h.

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

◆ N_m

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 201 of file ClosedOrbitFinder.h.

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

◆ nSectors_m

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 234 of file ClosedOrbitFinder.h.

◆ nxcross_m

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 185 of file ClosedOrbitFinder.h.

◆ nzcross_m

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 187 of file ClosedOrbitFinder.h.

◆ phase_m

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 209 of file ClosedOrbitFinder.h.

◆ pr_m

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 178 of file ClosedOrbitFinder.h.

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

◆ px_m

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 163 of file ClosedOrbitFinder.h.

◆ pz_m

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 167 of file ClosedOrbitFinder.h.

◆ q_m

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

Definition at line 193 of file ClosedOrbitFinder.h.

◆ r_m

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 174 of file ClosedOrbitFinder.h.

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

◆ ravg_m

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 206 of file ClosedOrbitFinder.h.

◆ stepper_m

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 237 of file ClosedOrbitFinder.h.

◆ vpz_m

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 180 of file ClosedOrbitFinder.h.

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

◆ vz_m

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 176 of file ClosedOrbitFinder.h.

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

◆ wo_m

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 199 of file ClosedOrbitFinder.h.

◆ x_m

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 161 of file ClosedOrbitFinder.h.

◆ z_m

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 165 of file ClosedOrbitFinder.h.


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