9#include "dpsim-models/SP/SP_Ph1_RXLine.h"
10#include "dpsim-models/MathUtils.h"
15 Real resistance, Real inductance,
16 Logger::Level logLevel)
46 setVirtualNodeNumber(1);
58 mBaseCurrent = baseApparentPower / (mBaseVoltage * sqrt(3));
68 int bus1 = this->matrixNodeIndex(0);
69 int bus2 = this->matrixNodeIndex(1);
76 mY_element = MatrixComp(2, 2);
78 mY_element(0, 1) = -y;
79 mY_element(1, 0) = -y;
83 for (
int i = 0; i < 2; i++)
84 for (
int j = 0; j < 2; j++)
85 if (!Math::isFinite(mY_element.coeff(i, j))) {
88 "Line {}: non-finite per-unit admittance {} in element Y({},{})",
89 this->name(), Logger::complexToString(mY_element.coeff(i, j)), i,
95 Y.coeffRef(bus1, bus1) += mY_element.coeff(0, 0);
96 Y.coeffRef(bus1, bus2) += mY_element.coeff(0, 1);
97 Y.coeffRef(bus2, bus1) += mY_element.coeff(1, 0);
98 Y.coeffRef(bus2, bus2) += mY_element.coeff(1, 1);
102 VectorComp &powerflow) {
117 auto copy = RXLine::make(name,
mLogLevel);
133 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
true);
140 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
true);
143 std::make_shared<SP::Ph1::Resistor>(**
mName +
"_snubber_res",
mLogLevel);
147 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
148 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
true);
152 (**mIntfVoltage)(0, 0) = initialSingleVoltage(1) - initialSingleVoltage(0);
154 (**mIntfCurrent)(0, 0) = (**
mIntfVoltage)(0, 0) / impedance;
155 mVirtualNodes[0]->setInitialVoltage(initialSingleVoltage(0) +
158 SPDLOG_LOGGER_INFO(
mSLog,
159 "\n--- Initialization from powerflow ---"
160 "\nVoltage across: {:s}"
162 "\nTerminal 0 voltage: {:s}"
163 "\nTerminal 1 voltage: {:s}"
164 "\n--- Initialization from powerflow finished ---",
167 Logger::phasorToString(initialSingleVoltage(0)),
168 Logger::phasorToString(initialSingleVoltage(1)));
171void SP::Ph1::RXLine::mnaParentAddPreStepDependencies(
172 AttributeBase::List &prevStepDependencies,
173 AttributeBase::List &attributeDependencies,
174 AttributeBase::List &modifiedAttributes) {
175 modifiedAttributes.push_back(mRightVector);
178void SP::Ph1::RXLine::mnaParentAddPostStepDependencies(
179 AttributeBase::List &prevStepDependencies,
180 AttributeBase::List &attributeDependencies,
181 AttributeBase::List &modifiedAttributes,
182 Attribute<Matrix>::Ptr &leftVector) {
183 attributeDependencies.push_back(leftVector);
184 modifiedAttributes.push_back(mIntfCurrent);
185 modifiedAttributes.push_back(mIntfVoltage);
188void SP::Ph1::RXLine::mnaParentPreStep(Real time, Int timeStepCount) {
189 mnaCompApplyRightSideVectorStamp(**mRightVector);
192void SP::Ph1::RXLine::mnaParentPostStep(Real time, Int timeStepCount,
193 Attribute<Matrix>::Ptr &leftVector) {
194 mnaCompUpdateVoltage(**leftVector);
195 mnaCompUpdateCurrent(**leftVector);
198void SP::Ph1::RXLine::mnaCompUpdateVoltage(
const Matrix &leftVector) {
199 (**mIntfVoltage)(0, 0) = 0;
200 if (terminalNotGrounded(1))
201 (**mIntfVoltage)(0, 0) =
202 Math::complexFromVectorElement(leftVector, matrixNodeIndex(1));
203 if (terminalNotGrounded(0))
204 (**mIntfVoltage)(0, 0) =
205 (**mIntfVoltage)(0, 0) -
206 Math::complexFromVectorElement(leftVector, matrixNodeIndex(0));
209void SP::Ph1::RXLine::mnaCompUpdateCurrent(
const Matrix &leftVector) {
210 (**mIntfCurrent)(0, 0) = mSubInductor->intfCurrent()(0, 0);
const Attribute< Real >::Ptr mSeriesInd
Inductance along the line [H].
const Attribute< Real >::Ptr mSeriesRes
Resistance along the line [ohms].
void addMNASubComponent(typename SimPowerComp< Complex >::Ptr subc, MNA_SUBCOMP_TASK_ORDER preStepOrder, MNA_SUBCOMP_TASK_ORDER postStepOrder, Bool contributeToRightVector)
CompositePowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
const Attribute< String >::Ptr mName
Human readable name.
String uid()
Returns unique id.
AttributeList::Ptr mAttributes
Attribute List.
std::shared_ptr< Resistor > mInitialResistor
Inductor end to ground resistor to facilitate initialization.
const Attribute< Real >::Ptr mInductance
Real getBaseVoltage() const
Get base voltage.
Real mBaseApparentPower
base apparent power [VA]
void initializeParentFromNodesAndTerminals(Real frequency) override
Derives values from power flow data and pushes them to subcomponents.
std::shared_ptr< Resistor > mSubResistor
Resistor submodel.
const Attribute< Real >::Ptr mActivePowerInjection
nodal active power injection
SimPowerComp< Complex >::Ptr clone(String name) override
DEPRECATED: Delete method.
void createSubComponents() override
Constructs and registers MNA subcomponents; idempotent.
Real mSeriesResPerUnit
resistance in [pu]
Real mBaseAdmittance
base admittance [S]
Real mBaseImpedance
base impedance [Ohm]
void setPerUnitSystem(Real baseApparentPower, Real baseOmega)
Specify per-unit system by base voltage, base apparent power and omega (rms value for voltage expecte...
const Attribute< Matrix >::Ptr mActivePowerBranch
branch active powerflow [W], coef(0) has data from node 0, coef(1) from node 1.
void pfApplyAdmittanceMatrixStamp(SparseMatrixCompRow &Y) override
Stamps admittance matrix.
void updateBranchFlow(VectorComp ¤t, VectorComp &powerflow)
updates branch current and power flow, input pu value, update with real value
const Attribute< MatrixComp >::Ptr mCurrent
branch Current flow [A], coef(0) has data from node 0, coef(1) from node 1.
Real mBaseInductance
base inductance [H]
const Attribute< Matrix >::Ptr mReactivePowerBranch
branch reactive powerflow [Var], coef(0) has data from node 0, coef(1) from node 1.
RXLine(String uid, String name, Real baseVoltage, Real resistance, Real inductance, Logger::Level logLevel=Logger::Level::off)
Defines UID, name, base voltage, component parameters and logging level.
const Attribute< Real >::Ptr mReactivePowerInjection
nodal reactive power injection
Real mSeriesIndPerUnit
Inductance of the line in [pu].
std::shared_ptr< Inductor > mSubInductor
Real mBaseCurrent
base current [V]
Real mBaseOmega
base omega [1/s]
void storeNodalInjection(Complex powerInjection)
stores nodal injection power in this line object
MatrixComp Y_element()
get admittance matrix
const Attribute< MatrixVar< Complex > >::Ptr mIntfCurrent
SimTerminal< Complex >::List mTerminals
const Attribute< MatrixVar< Complex > >::Ptr mIntfVoltage
SimNode< Complex >::List mVirtualNodes
void updateMatrixNodeIndices()
Logger::Level mLogLevel
Component logger control for internal variables.
Logger::Log mSLog
Component logger.