33 SPDLOG_LOGGER_INFO(
mSLog,
"\nResistance [Ohm]: {:s}",
35 SPDLOG_LOGGER_INFO(
mSLog,
36 "\n--- Initialization from powerflow ---"
37 "\nVoltage across: {:s}"
39 "\nTerminal 0 voltage: {:s}"
40 "\nTerminal 1 voltage: {:s}"
41 "\n--- Initialization from powerflow finished ---",
51 mBaseVoltage = baseVoltage;
55 SPDLOG_LOGGER_INFO(
mSLog,
"#### Calculate Per Unit Parameters for {}",
57 mBaseApparentPower = baseApparentPower;
58 SPDLOG_LOGGER_INFO(
mSLog,
"Base Power={} [VA]", baseApparentPower);
60 mBaseImpedance = mBaseVoltage * mBaseVoltage / mBaseApparentPower;
61 mBaseAdmittance = 1.0 / mBaseImpedance;
62 mBaseCurrent = baseApparentPower /
65 SPDLOG_LOGGER_INFO(
mSLog,
"Base Voltage={} [V] Base Impedance={} [Ohm]",
66 mBaseVoltage, mBaseImpedance);
68 mResistancePerUnit = **
mResistance / mBaseImpedance;
69 mConductancePerUnit = 1. / mResistancePerUnit;
70 SPDLOG_LOGGER_INFO(
mSLog,
"Resistance={} [pu] Conductance={} [pu]",
71 mResistancePerUnit, mConductancePerUnit);
79 SPDLOG_LOGGER_ERROR(
mSLog,
80 "Resistor {}: non-finite per-unit admittance {} at "
87 Y.coeffRef(bus1, bus1) += Y_element;
88 SPDLOG_LOGGER_INFO(
mSLog,
"#### Y matrix stamping: {}", Y_element);
98 SPDLOG_LOGGER_INFO(
mSLog,
99 "\n--- MNA initialization ---"
100 "\nInitial voltage {:s}"
101 "\nInitial current {:s}"
102 "\n--- MNA initialization finished ---",
121 attributeDependencies.push_back(leftVector);
135 (**mIntfVoltage)(0, freq) = 0;
140 (**mIntfVoltage)(0, freq) =
145 SPDLOG_LOGGER_DEBUG(
mSLog,
"Voltage {:s}",
153 SPDLOG_LOGGER_DEBUG(
mSLog,
"Current {:s}",
AttributePointer< Attribute< T > > Ptr
const CPS::Attribute< Real >::Ptr mResistance
Resistance [ohm].
const Attribute< String >::Ptr mName
Human readable name.
String uid()
Returns unique id.
AttributeList::Ptr mAttributes
Attribute List.
spdlog::level::level_enum Level
static String complexToString(const Complex &num)
static String realToString(const Real &num)
static String phasorToString(const Complex &num)
void mnaUpdateCurrent(const Matrix &leftVector) final
void mnaUpdateVoltage(const Matrix &leftVector) final
MNASimPowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
Attribute< Matrix >::Ptr mRightVector
static void stampAdmittance(Complex admittance, SparseMatrixRow &mat, UInt node1Index, UInt node2Index, Bool isTerminal1NotGrounded, Bool isTerminal2NotGrounded, const Logger::Log &mSLog, Int maxFreq=1, Int freqIdx=0)
static Complex complexFromVectorElement(const Matrix &mat, Matrix::Index row, Int maxFreq=1, Int freqIdx=0)
static bool isFinite(Real value)
static void addToMatrixElement(SparseMatrixRow &mat, Matrix::Index row, Matrix::Index column, Complex value, Int maxFreq=1, Int freqIdx=0)
void mnaCompUpdateCurrent(const Matrix &leftVector)
Update interface current from MNA system result.
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector)
add MNA pre and post step dependencies
SimPowerComp< Complex >::Ptr clone(String name)
Returns a modified copy of the component with the given suffix added to the name and without.
void mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector)
void mnaCompPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector)
MNA pre and post step operations.
void mnaCompUpdateVoltage(const Matrix &leftVector)
Update interface voltage from MNA system result.
void setBaseVoltage(Real baseVoltage)
Set base voltage.
Resistor(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name and logging level.
void mnaTearApplyMatrixStamp(SparseMatrixRow &tearMatrix)
void initializeFromNodesAndTerminals(Real frequency)
Initializes component from power flow data.
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix)
Stamps system matrix.
void pfApplyAdmittanceMatrixStamp(SparseMatrixCompRow &Y)
Stamps admittance matrix.
void calculatePerUnitParameters(Real baseApparentPower)
Initializes component from power flow data.
UInt matrixNodeIndex(UInt nodeIndex)
const Attribute< MatrixVar< Complex > >::Ptr mIntfCurrent
const Attribute< MatrixVar< Complex > >::Ptr mIntfVoltage
std::shared_ptr< SimPowerComp< VarType > > Ptr
Bool terminalNotGrounded(UInt index)
Complex initialSingleVoltage(UInt index)
void updateMatrixNodeIndices()
void setTerminalNumber(UInt num)
Logger::Level mLogLevel
Component logger control for internal variables.
Logger::Log mSLog
Component logger.
static std::shared_ptr< Resistor > 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).
std::complex< Real > Complex
Eigen::SparseMatrix< Real, Eigen::RowMajor > SparseMatrixRow
Sparse matrix for real numbers (row major).