31 (**mIntfCurrent)(0, 0) = (**
mIntfVoltage)(0, 0) / impedance;
33 SPDLOG_LOGGER_INFO(
mSLog,
34 "\nResistance [Ohm]: {:s}"
35 "\nImpedance [Ohm]: {:s}",
38 SPDLOG_LOGGER_INFO(
mSLog,
39 "\n--- Initialization from powerflow ---"
40 "\nVoltage across: {:s}"
42 "\nTerminal 0 voltage: {:s}"
43 "\nTerminal 1 voltage: {:s}"
44 "\n--- Initialization from powerflow finished ---",
58 SPDLOG_LOGGER_INFO(
mSLog,
59 "\n--- MNA initialization ---"
60 "\nInitial voltage {:s}"
61 "\nInitial current {:s}"
62 "\n--- MNA initialization finished ---",
72 mMnaTasks.push_back(std::make_shared<MnaPostStepHarm>(*
this, leftVectors));
100 attributeDependencies.push_back(leftVector);
112 for (
UInt freq = 0; freq < mResistor.mNumFreqs; freq++)
113 mResistor.mnaCompUpdateVoltageHarm(**mLeftVectors[freq], freq);
114 mResistor.mnaCompUpdateCurrentHarm();
120 (**mIntfVoltage)(0, freq) = 0;
125 (**mIntfVoltage)(0, freq) =
130 SPDLOG_LOGGER_DEBUG(
mSLog,
"Voltage {:s}",
138 SPDLOG_LOGGER_DEBUG(
mSLog,
"Current {:s}",
146 (**mIntfVoltage)(0, freqIdx) = 0;
148 (**mIntfVoltage)(0, freqIdx) =
151 (**mIntfVoltage)(0, freqIdx) =
155 SPDLOG_LOGGER_DEBUG(
mSLog,
"Voltage {:s}",
162 SPDLOG_LOGGER_DEBUG(
mSLog,
"Current {:s}",
176 const double dstate_dt[],
double resid[],
177 std::vector<int> &off) {
180 int c_offset = off[0] + off[1];
185 resid[c_offset] = (state[Pos2] - state[Pos1]) -
187 resid[n_offset_1] += 1.0 / **
mResistance * state[c_offset];
188 resid[n_offset_2] += 1.0 / **
mResistance * state[c_offset];
AttributePointer< Attribute< T > > Ptr
const CPS::Attribute< Real >::Ptr mResistance
Resistance [ohm].
void execute(Real time, Int timeStepCount)
void mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector)
Complex daeInitialize()
Voltage Getter.
void mnaCompUpdateCurrentHarm()
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector)
add MNA pre and post step dependencies
void mnaCompInitializeHarm(Real omega, Real timeStep, std::vector< Attribute< Matrix >::Ptr > leftVector)
void mnaCompApplySystemMatrixStampHarm(SparseMatrixRow &systemMatrix, Int freqIdx)
Stamps system matrix considering the frequency index.
Resistor(String uid, String name, Logger::Level loglevel=Logger::Level::off)
Defines UID, name and logging level.
void mnaCompPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector)
MNA pre and post step operations.
void daeResidual(double ttime, const double state[], const double dstate_dt[], double resid[], std::vector< int > &off)
Residual Function for DAE Solver.
void mnaCompUpdateCurrent(const Matrix &leftVector)
Update interface current from MNA system result.
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix)
Stamps system matrix.
SimPowerComp< Complex >::Ptr clone(String name)
Returns a modified copy of the component with the given suffix added to the name and without.
void mnaCompUpdateVoltageHarm(const Matrix &leftVector, Int freqIdx)
void mnaTearApplyMatrixStamp(SparseMatrixRow &tearMatrix)
void mnaCompUpdateVoltage(const Matrix &leftVector)
Update interface voltage from MNA system result.
void initializeFromNodesAndTerminals(Real frequency)
Initializes component from power flow data.
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 void addToMatrixElement(SparseMatrixRow &mat, Matrix::Index row, Matrix::Index column, Complex value, Int maxFreq=1, Int freqIdx=0)
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.
std::complex< Real > Complex
Eigen::SparseMatrix< Real, Eigen::RowMajor > SparseMatrixRow
Sparse matrix for real numbers (row major).