DPsim
Loading...
Searching...
No Matches
SineWaveGenerator.cpp
1/* Copyright 2017-2021 Institute for Automation of Complex Power Systems,
2 * EONERC, RWTH Aachen University
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7 *********************************************************************************/
8
9#include <dpsim-models/Signal/SineWaveGenerator.h>
10
11using namespace CPS;
12
14 Logger::Level logLevel)
15 : SignalGenerator(name, logLevel),
16 mVoltageRef(mAttributes->createDynamic<Complex>("V_ref")) {
17 SPDLOG_LOGGER_INFO(mSLog, "Create {} {}", type(), name);
18}
19
21 Real frequency /*= -1*/) {
22 **mVoltageRef = initialPhasor;
23 mMagnitude = mVoltageRef->deriveMag();
24 mPhase = mVoltageRef->derivePhase();
25 **mFreq = frequency;
26 **mSigOut = initialPhasor;
27
28 SPDLOG_LOGGER_INFO(mSLog,
29 "Parameters: \n"
30 "Sine wave magnitude: {} [V] \n"
31 "Sine wave initial phase: {} [rad] \n"
32 "Sine wave frequency: {} [Hz] \n",
33 **mMagnitude, **mPhase, **mFreq);
34}
35
37 **mSigOut = Complex(**mMagnitude * cos(time * 2. * PI * **mFreq + **mPhase),
38 **mMagnitude * sin(time * 2. * PI * **mFreq + **mPhase));
39}
String type()
Get component type (cross-platform)
AttributeList::Ptr mAttributes
Attribute List.
void setParameters(Complex initialPhasor, Real frequency=0.0)
set the source's parameters
SineWaveGenerator(String name, Logger::Level logLevel=Logger::Level::off)
init the identified object
void step(Real time)
implementation of inherited method step to update and return the current signal value
Logger::Log mSLog
Component logger.