21 Bool useSubcomponents,
26 mUseSubcomponents = useSubcomponents;
33 SPDLOG_LOGGER_INFO(
mSLog,
"Create {} {}", this->
type(), name);
36 if (mUseSubcomponents) {
38 std::make_shared<EMT::Ph3::VoltageSource>(**
mName +
"_vs",
mLogLevel);
42 mSubVoltageSource->mVoltageRef->setReference(
mVoltageRef);
43 mSubVoltageSource->mSrcFreq->setReference(
mSrcFreq);
57 if (mUseSubcomponents)
58 mSubVoltageSource->setParameters(voltageRef, srcFreq);
61 source->mFreq->setReference(
mSrcFreq);
62 source->setParameters(
Complex(1, 0), srcFreq);
68 SPDLOG_LOGGER_INFO(
mSLog,
69 "\nVoltage Ref={:s} [V]"
70 "\nFrequency={:s} [Hz]",
81 if (mUseSubcomponents)
82 mSubVoltageSource->setParameters(voltageRef, freqStart, rocof, timeStart,
83 duration, smoothRamp);
86 source->mFreq->setReference(
mSrcFreq);
87 source->setParameters(
Complex(1, 0), freqStart, rocof, timeStart, duration,
96 "\nVoltage Ref={:s} [V]"
97 "\nInitial frequency={:s} [Hz]"
98 "\nRamp ROCOF={:s} [Hz/s]"
99 "\nRamp duration={:s} [s]"
100 "\nRamp nadir={:s} [Hz]",
107 Real modulationFrequency,
108 Real modulationAmplitude,
113 if (mUseSubcomponents)
114 mSubVoltageSource->setParameters(voltageRef, modulationFrequency,
115 modulationAmplitude, baseFrequency,
119 source->mFreq->setReference(
mSrcFreq);
120 source->setParameters(
Complex(1, 0), modulationFrequency,
121 modulationAmplitude, baseFrequency, zigzag);
127 SPDLOG_LOGGER_INFO(
mSLog,
128 "\nVoltage Ref={:s} [V]"
129 "\nFrequency={:s} [Hz]",
136 if (!mUseSubcomponents) {
139 source->mFreq->setReference(
mSrcFreq);
140 source->setParameters(
Complex(1, 0), frequency);
155 if (!mUseSubcomponents) {
156 for (
UInt phase = 0; phase < 3; ++phase)
163 SPDLOG_LOGGER_DEBUG(
mSLog,
"Right Side Vector: {:s}",
169 if (mUseSubcomponents)
171 for (
UInt phase = 0; phase < 3; ++phase) {
172 const UInt sourceCurrent =
184 return !mUseSubcomponents ||
190 if (mUseSubcomponents) {
194 for (
UInt phase = 0; phase < 3; ++phase) {
208 if (!mUseSubcomponents) {
210 attributeDependencies.push_back(
mSrcFreq);
217 if (!mUseSubcomponents) {
218 if (mSrcSig !=
nullptr) {
220 for (
UInt phase = 0; phase < 3; ++phase)
236 attributeDependencies.push_back(leftVector);
248 const Matrix &leftVector) {
249 if (mUseSubcomponents)
254 const Matrix &leftVector) {
255 if (mUseSubcomponents)
258 for (
UInt phase = 0; phase < 3; ++phase)
AttributePointer< Attribute< T > > Ptr
void addMNASubComponent(typename SimPowerComp< Real >::Ptr subc, MNA_SUBCOMP_TASK_ORDER preStepOrder, MNA_SUBCOMP_TASK_ORDER postStepOrder, Bool contributeToRightVector)
Bool mnaHasCompactRightSideVectorStamp() const override
Composite stamps touch only their cached terminal and virtual-node rows.
void mnaAddCompactRightSideVectorStamp(Matrix &rightVector) override
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override
CompositePowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
void mnaParentApplyRightSideVectorStamp(Matrix &rightVector) override
Stamps right side (source) vector.
void setParameters(MatrixComp voltageRef, Real srcFreq=50.0)
Setter for reference voltage parameters.
void initializeParentFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Updates voltage across component.
void mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Returns current through the component.
void mnaParentPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
MNA post step operations.
Bool mnaHasCompactRightSideVectorStamp() const override
Composite stamps touch only their cached terminal and virtual-node rows.
void mnaAddCompactRightSideVectorStamp(Matrix &rightVector) override
SimPowerComp< Real >::Ptr clone(String name) override
Returns a modified copy of the component with the given suffix added to the name and without.
void mnaParentPreStep(Real time, Int timeStepCount) override
MNA pre step operations.
const CPS::Attribute< MatrixComp >::Ptr mVoltageRef
const CPS::Attribute< Real >::Ptr mSrcFreq
void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
Add MNA pre step dependencies.
NetworkInjection(String uid, String name, Logger::Level loglevel=Logger::Level::off)
Defines UID, name, component parameters and logging level.
void mnaParentApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override
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 matrixCompToString(const MatrixComp &mat)
static String matrixToString(const Matrix &mat)
static String realToString(const Real &num)
Attribute< Matrix >::Ptr mRightVector
static Real realFromVectorElement(const Matrix &mat, Matrix::Index row)
static void setVectorElement(Matrix &mat, Matrix::Index row, Complex value, Int maxFreq=1, Int freqIdx=0, Matrix::Index colOffset=0)
static void addToVectorElement(Matrix &mat, Matrix::Index row, Complex value, Int maxFreq=1, Int freqIdx=0)
static Real phase(Complex value)
static Real abs(Complex value)
static void addToMatrixElement(SparseMatrixRow &mat, Matrix::Index row, Matrix::Index column, Complex value, Int maxFreq=1, Int freqIdx=0)
static MatrixComp singlePhaseVariableToThreePhase(Complex var_1ph)
To convert single phase complex variables (voltages, currents) to symmetrical three phase ones.
UInt matrixNodeIndex(UInt nodeIndex)
const Attribute< MatrixVar< Real > >::Ptr mIntfCurrent
SimNode< Real >::Ptr node(UInt index)
void setVirtualNodeNumber(UInt num)
const Attribute< MatrixVar< Real > >::Ptr mIntfVoltage
std::shared_ptr< SimPowerComp< VarType > > Ptr
SimNode< Real >::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< NetworkInjection > make(Args &&...args)
#define RMS3PH_TO_PEAK1PH
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > Matrix
Dense matrix for real 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).