| helics 3.6.1

SignalGenerators.hpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2017-2025,
3 Battelle Memorial Institute; Lawrence Livermore National Security, LLC; Alliance for Sustainable
4 Energy, LLC. See the top-level NOTICE for additional details. All rights reserved.
5 SPDX-License-Identifier: BSD-3-Clause
6 */
7 #pragma once
8
13 #include "Source.hpp"
14
15 #include <complex>
16 #include <string>
17
18 namespace helics {
19 namespace apps {
21 class RampGenerator: public SignalGenerator {
22 private:
23 double level = 0.0;
24 double ramp = 0.0;
25
26 public:
27 RampGenerator() = default;
28 explicit RampGenerator(std::string_view name): SignalGenerator(name) {}
29 virtual void set(std::string_view parameter, double val) override;
30
31 virtual defV generate(Time signalTime) override;
32 };
33
35 class SineGenerator: public SignalGenerator {
36 private:
37 double level = 0.0;
38 double frequency = 0.0;
39 double offset = 0.0;
40 double amplitude = 0.0;
41 double dAdt = 0.0;
42 double dfdt = 0.0;
43 double period = 1e7;
44 Time lastCycle = timeZero;
45
46 public:
47 SineGenerator() = default;
48 explicit SineGenerator(std::string_view name): SignalGenerator(name) {}
49 virtual void set(std::string_view parameter, double val) override;
50
51 virtual defV generate(Time signalTime) override;
52 };
53
56 class PhasorGenerator: public SignalGenerator {
57 private:
58 double bias_real = 0.0;
59 double bias_imag = 0.0;
60 double frequency = 0.0;
61 double offset = 0.0;
62 double amplitude = 0.0;
63 double dAdt = 0.0;
64 double dfdt = 0.0;
65 // Time lastCycle = timeZero;
66 std::complex<double> state{1.0, 0};
67 std::complex<double> rotation{1.0, 0};
68
69 public:
70 PhasorGenerator() = default;
71 explicit PhasorGenerator(std::string_view name): SignalGenerator(name) {}
72 virtual void set(std::string_view parameter, double val) override;
74 void set(std::string_view parameter, std::complex<double> val);
75 virtual void setString(std::string_view parameter, std::string_view val) override;
76 virtual defV generate(Time signalTime) override;
77 };
78 } // namespace apps
79 } // namespace helics
helics::apps::PhasorGenerator
Definition: SignalGenerators.hpp:56
helics::apps::PhasorGenerator::set
virtual void set(std::string_view parameter, double val) override
Definition: SignalGenerators.cpp:79
helics::apps::PhasorGenerator::generate
virtual defV generate(Time signalTime) override
Definition: SignalGenerators.cpp:121
helics::apps::PhasorGenerator::setString
virtual void setString(std::string_view parameter, std::string_view val) override
Definition: SignalGenerators.cpp:111
helics::apps::RampGenerator
Definition: SignalGenerators.hpp:21
helics::apps::RampGenerator::set
virtual void set(std::string_view parameter, double val) override
Definition: SignalGenerators.cpp:16
helics::apps::RampGenerator::generate
virtual defV generate(Time signalTime) override
Definition: SignalGenerators.cpp:33
helics::apps::SignalGenerator
Definition: Source.hpp:37
helics::apps::SineGenerator
Definition: SignalGenerators.hpp:35
helics::apps::SineGenerator::set
virtual void set(std::string_view parameter, double val) override
Definition: SignalGenerators.cpp:40
helics::apps::SineGenerator::generate
virtual defV generate(Time signalTime) override
Definition: SignalGenerators.cpp:61
helics
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
helics::timeZero
constexpr Time timeZero
Definition: helicsTime.hpp:31
helics::Time
TimeRepresentation< count_time< 9 > > Time
Definition: helicsTime.hpp:27
helics::defV
std::variant< double, int64_t, std::string, std::complex< double >, std::vector< double >, std::vector< std::complex< double > >, NamedPoint > defV
Definition: HelicsPrimaryTypes.hpp:37