9#include "dpsim-models/SP/SP_Ph1_RXLine.h"
14 Real resistance, Real inductance,
15 Logger::Level logLevel)
45 setVirtualNodeNumber(1);
57 mBaseCurrent = baseApparentPower / (mBaseVoltage * sqrt(3));
67 int bus1 = this->matrixNodeIndex(0);
68 int bus2 = this->matrixNodeIndex(1);
75 mY_element = MatrixComp(2, 2);
77 mY_element(0, 1) = -y;
78 mY_element(1, 0) = -y;
82 for (
int i = 0; i < 2; i++)
83 for (
int j = 0; j < 2; j++)
84 if (std::isinf(mY_element.coeff(i, j).real()) ||
85 std::isinf(mY_element.coeff(i, j).imag())) {
86 std::cout << mY_element << std::endl;
88 ss <<
"Line>>" << this->name()
89 <<
": infinite or nan values in the element Y at: " << i <<
"," << j;
90 throw std::invalid_argument(ss.str());
91 std::cout <<
"Line>>" << this->name()
92 <<
": infinite or nan values in the element Y at: " << i
93 <<
"," << j << std::endl;
97 Y.coeffRef(bus1, bus1) += mY_element.coeff(0, 0);
98 Y.coeffRef(bus1, bus2) += mY_element.coeff(0, 1);
99 Y.coeffRef(bus2, bus1) += mY_element.coeff(1, 0);
100 Y.coeffRef(bus2, bus2) += mY_element.coeff(1, 1);
104 VectorComp &powerflow) {
119 auto copy = RXLine::make(name,
mLogLevel);
126 (**mIntfVoltage)(0, 0) = initialSingleVoltage(1) - initialSingleVoltage(0);
128 (**mIntfCurrent)(0, 0) = (**
mIntfVoltage)(0, 0) / impedance;
129 mVirtualNodes[0]->setInitialVoltage(initialSingleVoltage(0) +
137 mSubResistor->initializeFromNodesAndTerminals(frequency);
139 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
true);
145 mSubInductor->initializeFromNodesAndTerminals(frequency);
147 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
true);
150 std::make_shared<SP::Ph1::Resistor>(**
mName +
"_snubber_res",
mLogLevel);
155 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
156 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
true);
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.
void initializeFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
const Attribute< Real >::Ptr mInductance
Real getBaseVoltage() const
Get base voltage.
Real mBaseApparentPower
base apparent power [VA]
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.
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
Inductance submodel.
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.