23 SPDLOG_LOGGER_INFO(
mSLog,
"Create {} {}", this->
type(), name);
36 Real capacitance,
Real conductance) {
40 SPDLOG_LOGGER_INFO(
mSLog,
"Resistance={} [Ohm] Inductance={} [H]",
43 if (capacitance > 0) {
45 mParallelCapIsFallback =
false;
48 mParallelCapIsFallback =
true;
50 mSLog,
"Zero value for Capacitance, setting default value of C={} [F]",
53 if (conductance > 0) {
55 mParallelCondIsFallback =
false;
64 mParallelCondIsFallback =
true;
66 mSLog,
"Zero value for Conductance, setting default value of G={} [S]",
69 SPDLOG_LOGGER_INFO(
mSLog,
"Capacitance={} [F] Conductance={} [S]",
87 mBaseVoltage = baseVoltage;
92 SPDLOG_LOGGER_INFO(
mSLog,
"#### Calculate Per Unit Parameters for {}",
96 SPDLOG_LOGGER_INFO(
mSLog,
"Base Power={} [VA] Base Omega={} [1/s]",
97 baseApparentPower, baseOmega);
106 SPDLOG_LOGGER_INFO(
mSLog,
"Base Voltage={} [V] Base Impedance={} [Ohm]",
114 SPDLOG_LOGGER_INFO(
mSLog,
"Resistance={} [pu] Reactance={} [pu]",
116 SPDLOG_LOGGER_INFO(
mSLog,
"Susceptance={} [pu] Conductance={} [pu]",
126 Real parallelCondPerUnit =
130 Real parallelCapPerUnit =
139 Complex(parallelCondPerUnit, 1. * parallelCapPerUnit) /
Complex(2, 0);
149 for (
int i = 0; i < 2; i++)
150 for (
int j = 0; j < 2; j++)
154 "Line {}: non-finite per-unit admittance {} in element Y({},{})",
161 Y.coeffRef(bus1, bus1) +=
mY_element.coeff(0, 0);
162 Y.coeffRef(bus1, bus2) +=
mY_element.coeff(0, 1);
163 Y.coeffRef(bus2, bus2) +=
mY_element.coeff(1, 1);
164 Y.coeffRef(bus2, bus1) +=
mY_element.coeff(1, 0);
166 SPDLOG_LOGGER_INFO(
mSLog,
"#### PF Y matrix stamping #### ");
212 std::make_shared<SP::Ph1::Resistor>(**
mName +
"_con0",
mLogLevel);
220 std::make_shared<SP::Ph1::Resistor>(**
mName +
"_con1",
mLogLevel);
230 std::make_shared<SP::Ph1::Capacitor>(**
mName +
"_cap0",
mLogLevel);
238 std::make_shared<SP::Ph1::Capacitor>(**
mName +
"_cap1",
mLogLevel);
249 Real omega = 2. *
PI * frequency;
252 (**mIntfCurrent)(0, 0) = (**
mIntfVoltage)(0, 0) / impedance;
260 "\n--- Initialization from powerflow ---"
261 "\nVoltage across: {:s}"
263 "\nTerminal 0 voltage: {:s}"
264 "\nTerminal 1 voltage: {:s}"
265 "\nVirtual Node 1 voltage: {:s}"
266 "\n--- Initialization from powerflow finished ---",
279 attributeDependencies.push_back(leftVector);
291 (**mIntfVoltage)(0, 0) = 0;
293 (**mIntfVoltage)(0, 0) =
296 (**mIntfVoltage)(0, 0) =
316 return gndComponents;
AttributePointer< Attribute< T > > Ptr
const Attribute< Real >::Ptr mParallelCap
Capacitance in parallel to the line [F].
const Attribute< Real >::Ptr mParallelCond
Conductance in parallel to the line [S].
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.
String type()
Get component type (cross-platform)
AttributeList::Ptr mAttributes
Attribute List.
spdlog::level::level_enum Level
static String complexToString(const Complex &num)
static String phasorToString(const Complex &num)
void mnaUpdateCurrent(const Matrix &leftVector) final
void mnaUpdateVoltage(const Matrix &leftVector) final
static Complex complexFromVectorElement(const Matrix &mat, Matrix::Index row, Int maxFreq=1, Int freqIdx=0)
static bool isFinite(Real value)
void createSubComponents() override
Constructs and registers MNA subcomponents; idempotent.
void setBaseVoltage(Real baseVoltage)
Set base voltage.
Real mBaseCapacitance
base capacitance [F]
void calculatePerUnitParameters(Real baseApparentPower, Real baseOmega)
Calculates component's parameters in specified per-unit system.
std::shared_ptr< Resistor > mSubSeriesResistor
Series Resistor submodel.
const Attribute< Matrix >::Ptr mActivePowerBranch
branch active powerflow [W], coef(0) has data from node 0, coef(1) from node 1.
Real mSeriesIndPerUnit
Inductance of the line in [pu].
const Attribute< Real >::Ptr mReactivePowerInjection
nodal reactive power injection
const Attribute< MatrixComp >::Ptr mCurrent
branch Current flow [A], coef(0) has data from node 0, coef(1) from node 1.
std::shared_ptr< Capacitor > mSubParallelCapacitor0
Real mBaseAdmittance
base admittance [S]
Real mBaseInductance
base inductance [H]
MNAInterface::List mnaTearGroundComponents() override
Real mParallelCapPerUnit
Capacitance of the line in [pu].
std::shared_ptr< Resistor > mSubParallelResistor1
Parallel resistor submodel at Terminal 1.
const Attribute< Matrix >::Ptr mReactivePowerBranch
branch reactive powerflow [Var], coef(0) has data from node 0, coef(1) from node 1.
void mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
add MNA post-step dependencies
void updateBranchFlow(VectorComp ¤t, VectorComp &powerflow)
updates branch current and power flow, input pu value, update with real value
void mnaParentPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
MNA post-step operations.
MatrixComp Y_element()
get admittance matrix
Real mSeriesResPerUnit
resistance in [pu]
std::shared_ptr< Resistor > mSubParallelResistor0
Parallel Resistor submodel at Terminal 0.
void initializeParentFromNodesAndTerminals(Real frequency) override
Derives values from power flow data and pushes them to subcomponents.
void pfApplyAdmittanceMatrixStamp(SparseMatrixCompRow &Y) override
Stamps admittance matrix.
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Updates internal current variable of the component.
std::shared_ptr< Capacitor > mSubParallelCapacitor1
Parallel capacitor submodel at Terminal 1.
Real getBaseVoltage() const
Get base voltage.
PiLine(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name and logging level.
void mnaTearApplyMatrixStamp(SparseMatrixRow &tearMatrix) override
void setParameters(Real resistance, Real inductance, Real capacitance=-1, Real conductance=-1)
SimPowerComp< Complex >::Ptr clone(String copySuffix) override
DEPRECATED: Delete method.
void mnaTearApplyVoltageStamp(Matrix &voltageVector) override
std::shared_ptr< Inductor > mSubSeriesInductor
Series Inductance submodel.
void mnaTearInitialize(Real omega, Real timeStep) override
const Attribute< Real >::Ptr mActivePowerInjection
nodal active power injection
Real mParallelCondPerUnit
Conductance of the line in [pu].
Real mBaseApparentPower
base apparent power [VA]
void mnaTearPostStep(Complex voltage, Complex current) override
Real mBaseImpedance
base impedance [Ohm]
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Updates internal voltage variable of the component.
Real mBaseOmega
base omega [1/s]
void storeNodalInjection(Complex powerInjection)
stores nodal injection power in this line object
UInt matrixNodeIndex(UInt nodeIndex)
const Attribute< MatrixVar< Complex > >::Ptr mIntfCurrent
SimTerminal< Complex >::List mTerminals
void setVirtualNodeNumber(UInt num)
const Attribute< MatrixVar< Complex > >::Ptr mIntfVoltage
std::shared_ptr< SimPowerComp< VarType > > Ptr
SimNode< Complex >::List mVirtualNodes
Bool terminalNotGrounded(UInt index)
Complex initialSingleVoltage(UInt index)
void setTerminalNumber(UInt num)
Logger::Level mLogLevel
Component logger control for internal variables.
bool mParametersSet
Flag indicating that parameters are set via setParameters() function.
Logger::Log mSLog
Component logger.
static std::shared_ptr< PiLine > make(Args &&...args)
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > Matrix
Dense matrix for real numbers.
Eigen::SparseMatrix< Complex, Eigen::RowMajor > SparseMatrixCompRow
Sparse matrix for complex numbers (row major).
Eigen::Matrix< Complex, Eigen::Dynamic, 1 > VectorComp
Dense vector for complex numbers.
std::complex< Real > Complex
Eigen::Matrix< Complex, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > MatrixComp
Dense matrix for complex numbers.
Eigen::SparseMatrix< Real, Eigen::RowMajor > SparseMatrixRow
Sparse matrix for real numbers (row major).