DPsim
Loading...
Searching...
No Matches
EMT_DC_Capacitor.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
11
13 auto copy = Capacitor::make(name, mLogLevel);
14 copy->setParameters(**mCapacitance);
15 return copy;
16}
17
19 if (!Math::isFinite(capacitance) ||
20 capacitance <= std::numeric_limits<Real>::epsilon())
21 throw std::invalid_argument(
22 "DC capacitance must be finite and safely greater than zero.");
23
24 **mCapacitance = capacitance;
25
26 // x = vC, u = i, y = vC
27 SSNComp::setParameters(Matrix::Zero(1, 1),
28 Matrix::Constant(1, 1, 1.0 / capacitance),
29 Matrix::Identity(1, 1), Matrix::Zero(1, 1));
30}
31
33 if (!mParametersSet)
34 throw std::logic_error(
35 "setParameters() must be called before capacitor initialization.");
37
39 if (!Math::isFinite(voltage) ||
40 std::abs(voltage.imag()) > std::numeric_limits<Real>::epsilon())
41 throw std::invalid_argument(
42 "DC initial capacitor voltage must be a finite real scalar value.");
43
44 (**mX)(0, 0) = voltage.real();
45 (**mIntfVoltage)(0, 0) = voltage.real();
46 (**mIntfCurrent)(0, 0) = 0.0;
47}
Capacitor(String uid, String name, Logger::Level logLevel=Logger::Level::off)
void setParameters(Real capacitance)
void initializeFromNodesAndTerminals(Real frequency) override final
Initializes Component variables according to power flow data stored in Nodes.
const Attribute< Real >::Ptr mCapacitance
Capacitance [F].
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.
TwoTerminalITypeSSNComp(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< Capacitor > 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