DPsim
Loading...
Searching...
No Matches
EMT_DC_Inductor.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Institute for Automation of Complex Power Systems, EONERC, RWTH Aachen University
2// SPDX-License-Identifier: MPL-2.0
3
5
6using namespace CPS;
7
12
14 auto copy = Inductor::make(name, mLogLevel);
15 copy->setParameters(**mInductance, **mInitialCurrent);
16 return copy;
17}
18
19void EMT::DC::Inductor::setParameters(Real inductance, Real initialCurrent) {
20 if (!Math::isFinite(inductance) ||
21 inductance <= std::numeric_limits<Real>::epsilon())
22 throw std::invalid_argument(
23 "DC inductance must be finite and safely greater than zero.");
24 if (!Math::isFinite(initialCurrent))
25 throw std::invalid_argument("Initial inductor current must be finite.");
26
27 **mInductance = inductance;
28 **mInitialCurrent = initialCurrent;
29
30 // x = iL, u = v, y = iL
31 SSNComp::setParameters(Matrix::Zero(1, 1),
32 Matrix::Constant(1, 1, 1.0 / inductance),
33 Matrix::Identity(1, 1), Matrix::Zero(1, 1));
34}
35
37 if (!mParametersSet)
38 throw std::logic_error(
39 "setParameters() must be called before inductor initialization.");
41
43 if (!Math::isFinite(voltage) ||
44 std::abs(voltage.imag()) > std::numeric_limits<Real>::epsilon())
45 throw std::invalid_argument(
46 "DC initial inductor voltage must be a finite real scalar value.");
47
48 (**mX)(0, 0) = **mInitialCurrent;
49 (**mIntfVoltage)(0, 0) = voltage.real();
50 (**mIntfCurrent)(0, 0) = **mInitialCurrent;
51}
void initializeFromNodesAndTerminals(Real frequency) override final
Initializes Component variables according to power flow data stored in Nodes.
const Attribute< Real >::Ptr mInitialCurrent
Initial current from terminal 1 to terminal 0 [A].
SimPowerComp< Real >::Ptr clone(String name) override final
Returns a modified copy of the component with the given suffix added to the name and without.
Inductor(String uid, String name, Logger::Level logLevel=Logger::Level::off)
void setParameters(Real inductance, Real initialCurrent=0.0)
const Attribute< Real >::Ptr mInductance
Inductance [H].
TwoTerminalVTypeSSNComp(String uid, String name, Logger::Level logLevel=Logger::Level::off)
void setParameters(const Matrix &A, const Matrix &B, const Matrix &C, const Matrix &D)
String uid()
Returns unique id.
AttributeList::Ptr mAttributes
Attribute List.
spdlog::level::level_enum Level
Definition Logger.h:33
static bool isFinite(Real value)
Definition MathUtils.cpp:63
std::shared_ptr< SimPowerComp< VarType > > Ptr
Complex initialSingleVoltage(UInt index)
Logger::Level mLogLevel
Component logger control for internal variables.
bool mParametersSet
Flag indicating that parameters are set via setParameters() function.
static std::shared_ptr< Inductor > make(Args &&...args)
Definition PtrFactory.h:19
std::string String
Definition Definitions.h:65
double Real
Definition Definitions.h:62
std::complex< Real > Complex
Definition Definitions.h:63