27 throw std::invalid_argument(
"DC source current must be finite.");
32void EMT::DC::CurrentSource::validateDCTerminals()
const {
33 for (
UInt terminalIdx = 0; terminalIdx < 2; ++terminalIdx) {
34 const auto terminalNode =
36 if (!terminalNode->isGround() && terminalNode->phaseType() !=
PhaseType::DC)
37 throw std::invalid_argument(
38 "DC current source requires DC nodes or ground at both terminals.");
44 throw std::logic_error(
45 "setParameters() must be called before source initialization.");
46 validateDCTerminals();
50 std::abs(voltage.imag()) > std::numeric_limits<Real>::epsilon())
51 throw std::invalid_argument(
52 "DC initial node voltages must be finite real scalar values.");
53 (**mIntfVoltage)(0, 0) = voltage.real();
59 throw std::logic_error(
60 "setParameters() must be called before source initialization.");
61 validateDCTerminals();
77 (**mIntfVoltage)(0, 0) = 0.0;
79 (**mIntfVoltage)(0, 0) =
82 (**mIntfVoltage)(0, 0) -=
85 throw std::runtime_error(
86 "DC current-source voltage contains a non-finite value.");
91 throw std::runtime_error(
"DC source current became non-finite.");
117 attributeDependencies.push_back(leftVector);
AttributePointer< Attribute< T > > Ptr
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override final
void mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
void initializeFromNodesAndTerminals(Real frequency) override
Initializes Component variables according to power flow data stored in Nodes.
void mnaCompPreStep(Real time, Int timeStepCount) override final
void mnaCompPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override final
void mnaCompAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override final
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override final
void mnaCompUpdateVoltage(const Matrix &leftVector) override final
void setParameters(Real current)
SimPowerComp< Real >::Ptr clone(String name) override final
Returns a modified copy of the component with the given suffix added to the name and without.
const Attribute< Real >::Ptr mCurrentRef
CurrentSource(String uid, String name, Logger::Level logLevel=Logger::Level::off)
String uid()
Returns unique id.
AttributeList::Ptr mAttributes
Attribute List.
spdlog::level::level_enum Level
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 bool isFinite(Real value)
UInt matrixNodeIndex(UInt nodeIndex)
const Attribute< MatrixVar< Real > >::Ptr mIntfCurrent
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.
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