OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
OpalSinusoidalTimeDependence.cpp
Go to the documentation of this file.
1//
2// Class OpalSinusoidalTimeDependence
3// User interface for a time dependence class that generates sine waves
4//
5// Copyright (c) 2025, Jon Thompson, STFC Rutherford Appleton Laboratory, Didcot, UK
6//
7// This file is part of OPAL.
8//
9// OPAL is free software: you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation, either version 3 of the License, or
12// (at your option) any later version.
13//
14// You should have received a copy of the GNU General Public License
15// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
16//
17
19#include <string>
22
24 "The \"SINUSOIDAL_TIME_DEPENDENCE\" element defines "
25 "sinusoidal coefficients for a time dependence, "
26 "frequency, amplitude, phase offset, DC offset, given by "
27 "f(t) = sigma_over_i(a[i] / 2 * sin(2 * pi * f[i] * t + p[i]) + o[i])";
28
30 : OpalElement(static_cast<int>(SIZE), "SINUSOIDAL_TIME_DEPENDENCE", doc_string.c_str()) {
32 "FREQUENCIES",
33 "Sine wave frequencies, length determines the number of size waves included.");
35 "AMPLITUDES", "Peak-to-peak amplitude for each size wave. If undefined, defaults to 1.0.");
37 "PHASE_OFFSETS", "Phase offset for each sine wave. If undefined, defaults to 0.0.");
39 "DC_OFFSETS", "DC offset for each sine wave. If undefined, defaults to 0.0.");
41}
42
44 return new OpalSinusoidalTimeDependence(name, this);
45}
46
47void OpalSinusoidalTimeDependence::print(std::ostream& out) const {
49}
50
52 const std::string& name, OpalSinusoidalTimeDependence* parent)
53 : OpalElement(name, parent) {
54}
55
58 getOpalName(), std::make_shared<SinusoidalTimeDependence>(
63}
@ SIZE
Definition: IndexMap.cpp:174
const std::string name
Attribute makeRealArray(const std::string &name, const std::string &help)
Create real array attribute.
Definition: Attributes.cpp:289
std::vector< double > getRealArray(const Attribute &attr)
Get array value.
Definition: Attributes.cpp:294
const std::string & getOpalName() const
Return object name.
Definition: Object.cpp:310
std::vector< Attribute > itsAttr
The object attributes.
Definition: Object.h:216
static void setTimeDependence(std::string name, std::shared_ptr< AbstractTimeDependence > time_dep)
Add a value to the lookup table.
virtual void print(std::ostream &) const
Print the object.
void registerOwnership() const
The UI wrapper for SinusoidalTimeDependence.
OpalSinusoidalTimeDependence * clone(const std::string &name) override
Inherited copy constructor.
OpalSinusoidalTimeDependence()
Define mapping from enum variables to string UI parameter names.
void update() override
Receive parameters from the parser and hand them off to the OpalSinusoidalTimeDependence.
void print(std::ostream &) const override
Calls print on the OpalElement.