OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
SinusoidalTimeDependence Class Referencefinal

#include <SinusoidalTimeDependence.h>

Inheritance diagram for SinusoidalTimeDependence:
Collaboration diagram for SinusoidalTimeDependence:

Public Member Functions

 SinusoidalTimeDependence (const std::vector< double > &f, const std::vector< double > &p, const std::vector< double > &a, const std::vector< double > &o)
 SinusoidalTimeDependence ()=default
 ~SinusoidalTimeDependence () override=default
double getValue (double time) override
SinusoidalTimeDependenceclone () override
Informprint (Inform &os) const

Static Public Member Functions

static std::shared_ptr< AbstractTimeDependencegetTimeDependence (std::string name)
static void setTimeDependence (std::string name, std::shared_ptr< AbstractTimeDependence > time_dep)
static std::string getName (std::shared_ptr< AbstractTimeDependence > time_dep)

Private Attributes

std::vector< double > f_m
std::vector< double > p_m
std::vector< double > a_m
std::vector< double > o_m

Static Private Attributes

static std::map< std::string, std::shared_ptr< AbstractTimeDependence > > td_map

Detailed Description

Time dependence that follows sum of a set of sinusoids sigma_over_i(a[i] / 2 * sin(2 * pi * f[i] * t + p[i]) + o[i]) a is the peak to peak amplitude, f is the frequency, p is the phase offset, o is the DC offset, t is the time.

Definition at line 34 of file SinusoidalTimeDependence.h.

Constructor & Destructor Documentation

◆ SinusoidalTimeDependence() [1/2]

SinusoidalTimeDependence::SinusoidalTimeDependence ( const std::vector< double > & f,
const std::vector< double > & p,
const std::vector< double > & a,
const std::vector< double > & o )

Constructor

Parameters
fthe frequencies in Hz; can be of arbitrary length
pthe phase offsets in radians; can be of arbitrary length
athe peak-to-peak amplitude; can be of arbitrary length
othe DC offset; can be of arbitrary length (user is responsible for issues like floating point precision).

Definition at line 24 of file SinusoidalTimeDependence.cpp.

References a, a_m, f_m, o_m, and p_m.

Referenced by clone(), and ~SinusoidalTimeDependence().

◆ SinusoidalTimeDependence() [2/2]

SinusoidalTimeDependence::SinusoidalTimeDependence ( )
default

Default Constructor makes a 0 length polynomial

Referenced by clone().

◆ ~SinusoidalTimeDependence()

SinusoidalTimeDependence::~SinusoidalTimeDependence ( )
overridedefault

Destructor does default

References SinusoidalTimeDependence().

Here is the call graph for this function:

Member Function Documentation

◆ clone()

SinusoidalTimeDependence * SinusoidalTimeDependence::clone ( )
overridevirtual

Inheritable clone function

Returns
new SinusoidalTimeDependence that is a copy of this. User owns returned memory.

Implements AbstractTimeDependence.

Definition at line 52 of file SinusoidalTimeDependence.cpp.

References a_m, f_m, o_m, p_m, SinusoidalTimeDependence(), and SinusoidalTimeDependence().

Here is the call graph for this function:

◆ getName()

std::string AbstractTimeDependence::getName ( std::shared_ptr< AbstractTimeDependence > time_dep)
staticinherited

Get the name corresponding to a given time_dep

Parameters
time_deptime dependence to lookup
Returns
name corresponding to the time dependence. Note that this just does a dumb loop over the stored map values; so O(N).
Exceptions
GeneralClassicExceptionif time_dep is not recognised

Definition at line 50 of file AbstractTimeDependence.cpp.

References td_map.

◆ getTimeDependence()

std::shared_ptr< AbstractTimeDependence > AbstractTimeDependence::getTimeDependence ( std::string name)
staticinherited

Look up the time dependence that has a given name

Parameters
namename of the time dependence
Returns
shared_ptr to the appropriate time dependence.
Exceptions
GeneralClassicExceptionif name is not recognised

Definition at line 36 of file AbstractTimeDependence.cpp.

References name, and td_map.

Referenced by PyOpal::PyAbstractTimeDependence::function(), VariableRFCavity::initialise(), MultipoleT::initialiseTimeDepencencies(), and ParallelCyclotronTracker::visitRFCavity().

◆ getValue()

double SinusoidalTimeDependence::getValue ( double time)
overridevirtual

Return the sinusoidal value

Parameters
timesimulation time in seconds

Implements AbstractTimeDependence.

Definition at line 30 of file SinusoidalTimeDependence.cpp.

References a, a_m, f_m, o_m, p_m, and Physics::pi.

◆ print()

Inform & SinusoidalTimeDependence::print ( Inform & os) const

Print the sinusoidals

Parameters
os"Inform" stream to which the sinusoidals are printed.

Definition at line 56 of file SinusoidalTimeDependence.cpp.

References a_m, endl(), f_m, Inform::flags(), o_m, and p_m.

Referenced by operator<<().

Here is the call graph for this function:

◆ setTimeDependence()

void AbstractTimeDependence::setTimeDependence ( std::string name,
std::shared_ptr< AbstractTimeDependence > time_dep )
staticinherited

Add a value to the lookup table

Parameters
namename of the time dependence. If name already exists in the map, it is overwritten with the new value.
time_depshared_ptr to the time dependence.

Definition at line 45 of file AbstractTimeDependence.cpp.

References name, and td_map.

Referenced by OpalPolynomialTimeDependence::update(), OpalSinusoidalTimeDependence::update(), and OpalSplineTimeDependence::update().

Member Data Documentation

◆ a_m

std::vector<double> SinusoidalTimeDependence::a_m
private

Definition at line 72 of file SinusoidalTimeDependence.h.

Referenced by clone(), getValue(), print(), and SinusoidalTimeDependence().

◆ f_m

std::vector<double> SinusoidalTimeDependence::f_m
private

Definition at line 70 of file SinusoidalTimeDependence.h.

Referenced by clone(), getValue(), print(), and SinusoidalTimeDependence().

◆ o_m

std::vector<double> SinusoidalTimeDependence::o_m
private

Definition at line 73 of file SinusoidalTimeDependence.h.

Referenced by clone(), getValue(), print(), and SinusoidalTimeDependence().

◆ p_m

std::vector<double> SinusoidalTimeDependence::p_m
private

Definition at line 71 of file SinusoidalTimeDependence.h.

Referenced by clone(), getValue(), print(), and SinusoidalTimeDependence().

◆ td_map

std::map< std::string, std::shared_ptr< AbstractTimeDependence > > AbstractTimeDependence::td_map
staticprivateinherited
Initial value:
=
std::map<std::string, std::shared_ptr<AbstractTimeDependence> >()

Definition at line 95 of file AbstractTimeDependence.h.

Referenced by getName(), getTimeDependence(), and setTimeDependence().


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