18 Bool useSubcomponents,
21 mUseSubcomponents(useSubcomponents),
27 SPDLOG_LOGGER_INFO(
mSLog,
"Create {} {}", this->
type(), name);
32 if (mUseSubcomponents) {
34 std::make_shared<DP::Ph1::VoltageSource>(**
mName +
"_vs",
mLogLevel);
38 mSubVoltageSource->mVoltageRef->setReference(
mVoltageRef);
39 mSubVoltageSource->mSrcFreq->setReference(
mSrcFreq);
42 SPDLOG_LOGGER_INFO(
mSLog,
"Electrical subcomponents: ");
44 SPDLOG_LOGGER_INFO(
mSLog,
"- {}", subcomp->name());
56 if (mUseSubcomponents)
57 mSubVoltageSource->setParameters(voltageRef, srcFreq);
63 signal->mFreq->setReference(
mSrcFreq);
64 signal->setParameters(voltageRef, srcFreq);
65 mDirectSignal = signal;
68 SPDLOG_LOGGER_INFO(
mSLog,
69 "\nVoltage Ref={:s} [V]"
70 "\nFrequency={:s} [Hz]",
80 if (mUseSubcomponents)
81 mSubVoltageSource->setParameters(initialPhasor, freqStart, rocof, timeStart,
82 duration, smoothRamp);
87 signal->mFreq->setReference(
mSrcFreq);
88 signal->setParameters(initialPhasor, freqStart, rocof, timeStart, duration,
90 mDirectSignal = signal;
95 "\nVoltage Ref={:s} [V]"
96 "\nInitial frequency={:s} [Hz]"
97 "\nRamp ROCOF={:s} [Hz/s]"
98 "\nRamp duration={:s} [s]"
99 "\nRamp nadir={:s} [Hz]",
106 Real modulationFrequency,
107 Real modulationAmplitude,
111 if (mUseSubcomponents)
112 mSubVoltageSource->setParameters(initialPhasor, modulationFrequency,
113 modulationAmplitude, baseFrequency,
119 signal->mFreq->setReference(
mSrcFreq);
120 signal->setParameters(initialPhasor, modulationFrequency,
121 modulationAmplitude, baseFrequency, zigzag);
122 mDirectSignal = signal;
125 SPDLOG_LOGGER_INFO(
mSLog,
126 "\nVoltage Ref={:s} [V]"
127 "\nFrequency={:s} [Hz]",
135 if (mUseSubcomponents) {
141 if (mDirectSignal ==
nullptr) {
144 signal->mFreq->setReference(
mSrcFreq);
146 mDirectSignal = signal;
151 (**mIntfVoltage)(0, 0) = mDirectVoltage;
158 if (mUseSubcomponents)
171 if (!mUseSubcomponents)
174 SPDLOG_LOGGER_DEBUG(
mSLog,
"Right Side Vector: {:s}",
183 if (!mUseSubcomponents) {
185 attributeDependencies.push_back(
mSrcFreq);
193 if (!mUseSubcomponents) {
194 mDirectSignal->step(time);
195 mDirectVoltage = mDirectSignal->getSignal();
196 (**mIntfVoltage)(0, 0) = mDirectVoltage;
208 attributeDependencies.push_back(leftVector);
221 if (mUseSubcomponents)
226 if (mUseSubcomponents) {
233 leftVector, sourceCurrent,
mNumFreqs, freq);
237 const double dstate_dt[],
239 std::vector<int> &off) {
254 int c_offset = off[0] + off[1];
259 resid[c_offset] = (state[Pos2] - state[Pos1]) -
262 resid[n_offset_1] += (**mIntfCurrent)(0, 0).real();
263 resid[n_offset_2] += (**mIntfCurrent)(0, 0).real();
268 if (mUseSubcomponents)
269 (**mIntfVoltage)(0, 0) = (**mSubVoltageSource->mIntfVoltage)(0, 0);
AttributePointer< Attribute< T > > Ptr
void addMNASubComponent(typename SimPowerComp< Complex >::Ptr subc, MNA_SUBCOMP_TASK_ORDER preStepOrder, MNA_SUBCOMP_TASK_ORDER postStepOrder, Bool contributeToRightVector)
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override
CompositePowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
SimPowerComp< Complex >::Ptr clone(String name) override
Returns a modified copy of the component with the given suffix added to the name and without.
void daeResidual(double ttime, const double state[], const double dstate_dt[], double resid[], std::vector< int > &off) override
Residual function for DAE Solver.
Complex daeInitialize() override
Voltage Getter.
NetworkInjection(String uid, String name, Logger::Level loglevel=Logger::Level::off)
Defines UID, name and logging level.
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Returns current through the component.
void setParameters(Complex voltageRef, Real srcFreq=0.0)
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Updates voltage across component.
void mnaParentPreStep(Real time, Int timeStepCount) override
MNA pre step operations.
void mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
void mnaParentApplyRightSideVectorStamp(Matrix &rightVector) override
More General setter for voltage source parameters.
const Attribute< Complex >::Ptr mVoltageRef
const Attribute< Real >::Ptr mSrcFreq
void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
Add MNA pre step dependencies.
void mnaParentApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override
void initializeParentFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
void mnaParentPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
MNA post step operations.
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 matrixToString(const Matrix &mat)
static String realToString(const Real &num)
static String phasorToString(const Complex &num)
Attribute< Matrix >::Ptr mRightVector
static Complex complexFromVectorElement(const Matrix &mat, Matrix::Index row, Int maxFreq=1, Int freqIdx=0)
static void setVectorElement(Matrix &mat, Matrix::Index row, Complex value, Int maxFreq=1, Int freqIdx=0, Matrix::Index colOffset=0)
static void setMatrixElement(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
SimNode< Complex >::Ptr node(UInt index)
void setVirtualNodeNumber(UInt num)
const Attribute< MatrixVar< Complex > >::Ptr mIntfVoltage
SimNode< Complex >::Ptr virtualNode(UInt index)
std::shared_ptr< SimPowerComp< VarType > > Ptr
std::vector< std::shared_ptr< SimPowerComp< Complex > > > mSubComponents
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< NetworkInjection > 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).