DPsim
Loading...
Searching...
No Matches
EMT_Ph3_SSN_Capacitor.cpp
1// SPDX-FileCopyrightText: 2026 Institute for Automation of Complex Power Systems, EONERC, RWTH Aachen University
2// SPDX-License-Identifier: MPL-2.0
3
4#include <dpsim-models/EMT/EMT_Ph3_SSN_Capacitor.h>
5
6using namespace CPS;
7
8EMT::Ph3::SSN::Capacitor::Capacitor(String uid, String name,
9 Logger::Level logLevel)
10 : TwoTerminalITypeSSNComp(uid, name, logLevel),
11 Base::Ph3::Capacitor(mAttributes) {
12 mPhaseType = PhaseType::ABC;
13}
14
15SimPowerComp<Real>::Ptr EMT::Ph3::SSN::Capacitor::clone(String name) {
16 auto copy = Capacitor::make(name, mLogLevel);
17 copy->setParameters(**mCapacitance);
18 return copy;
19}
20
21void EMT::Ph3::SSN::Capacitor::setParameters(Matrix capacitance) {
23
24 Matrix aMatrix = Matrix::Zero(3, 3);
25 Matrix bMatrix = capacitance.inverse();
26 Matrix cMatrix = Matrix::Identity(3, 3);
27 Matrix dMatrix = Matrix::Zero(3, 3);
28
29 // I-type capacitor:
30 //
31 // x = vC_abc
32 // u = i_abc
33 // y = v_abc
34 //
35 // dvC/dt = C^{-1} i
36 // v = vC
37 TwoTerminalITypeSSNComp::setParameters(aMatrix, bMatrix, cMatrix, dMatrix);
38}
39
40MatrixComp
41EMT::Ph3::SSN::Capacitor::buildInitialInputFromNodes(Real frequency) {
42 Real omega = 2.0 * PI * frequency;
43
44 MatrixComp admittance = MatrixComp::Zero(3, 3);
45 admittance = Complex(0.0, omega) * (**mCapacitance).cast<Complex>();
46
47 MatrixComp vInitABC = MatrixComp::Zero(3, 1);
48
49 // Interface voltage convention: v = v_terminal1 - v_terminal0
50 vInitABC(0, 0) = RMS3PH_TO_PEAK1PH * initialSingleVoltage(1) -
51 RMS3PH_TO_PEAK1PH * initialSingleVoltage(0);
52 vInitABC(1, 0) = vInitABC(0, 0) * SHIFT_TO_PHASE_B;
53 vInitABC(2, 0) = vInitABC(0, 0) * SHIFT_TO_PHASE_C;
54
55 MatrixComp iInitABC = admittance * vInitABC;
56
57 SPDLOG_LOGGER_INFO(mSLog,
58 "\nCapacitance [F]: {:s}"
59 "\nAdmittance [S]: {:s}",
60 Logger::matrixToString(**mCapacitance),
61 Logger::matrixCompToString(admittance));
62
63 return iInitABC;
64}
const CPS::Attribute< Matrix >::Ptr mCapacitance
Capacitance [F].
void setParameters(Matrix capacitance)
Sets model specific parameters.
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.
Logger::Level mLogLevel
Component logger control for internal variables.