36 srcSigSine->setParameters(
Complex(1, 0), srcFreq);
40 mSrcFreq->setReference(mSrcSig->mFreq);
42 SPDLOG_LOGGER_INFO(
mSLog,
43 "\nCurrent reference phasor [I]: {:s}"
44 "\nFrequency [Hz]: {:s}",
53 mSLog,
"\n--- Initialization from node voltages and terminal ---");
58 srcSigSine->setParameters(
Complex(1, 0), frequency);
65 Complex i_ref = std::conj(s_ref / v_ref / sqrt(3.));
68 mSrcFreq->setReference(mSrcSig->attributeTyped<
Real>(
"freq"));
70 SPDLOG_LOGGER_INFO(
mSLog,
71 "\nReference current: {:s}"
72 "\nReference voltage: {:s}"
73 "\nReference power: {:s}"
74 "\nTerminal 0 voltage: {:s}"
75 "\nTerminal 1 voltage: {:s}"
76 "\nTerminal 0 power: {:s}"
77 "\nTerminal 1 power: {:s}",
88 "\nInitialization from node voltages and terminal omitted (parameter "
90 "\nReference voltage: {:s}",
94 mSLog,
"\n--- Initialization from node voltages and terminal ---");
124 if (mSrcSig !=
nullptr) {
126 for (
int i = 0; i < 3; i++) {
134 SPDLOG_LOGGER_DEBUG(
mSLog,
"\nUpdate current: {:s}",
157 attributeDependencies.push_back(leftVector);
170 (**mIntfVoltage)(0, 0) =
172 (**mIntfVoltage)(1, 0) =
174 (**mIntfVoltage)(2, 0) =
178 (**mIntfVoltage)(0, 0) =
181 (**mIntfVoltage)(1, 0) =
184 (**mIntfVoltage)(2, 0) =
AttributePointer< Attribute< T > > Ptr
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Returns voltage through the component.
CurrentSource(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name and logging level.
const Attribute< Real >::Ptr mSrcFreq
const Attribute< MatrixComp >::Ptr mCurrentRef
const Attribute< Complex >::Ptr mSigOut
void setParameters(MatrixComp currentRef, Real srcFreq=50.0)
Setter for reference current.
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override
Stamps right side (source) vector.
void updateCurrent(Real time)
void initializeFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
void mnaCompAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
Add MNA pre step dependencies.
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 mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
Initializes internal variables of the component.
void mnaCompPreStep(Real time, Int timeStepCount) override
MNA pre step operations.
void mnaCompPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
MNA post step operations.
const Attribute< String >::Ptr mName
Human readable name.
Attribute< T >::Ptr attributeTyped(const String &name) const
Return pointer to an attribute.
String uid()
Returns unique id.
AttributeList::Ptr mAttributes
Attribute List.
spdlog::level::level_enum Level
static String matrixCompToString(const MatrixComp &mat)
static String complexToString(const Complex &num)
static String matrixToString(const Matrix &mat)
static String realToString(const Real &num)
static String phasorToString(const Complex &num)
MNASimPowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
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 Real phase(Complex value)
static Real abs(Complex value)
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
SimTerminal< Real >::Ptr terminal(UInt index)
void setVirtualNodeNumber(UInt num)
const Attribute< MatrixVar< Real > >::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.
bool mParametersSet
Flag indicating that parameters are set via setParameters() function.
Logger::Log mSLog
Component logger.
static std::shared_ptr< CurrentSource > make(Args &&...args)
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.