31 Real seriesInductance,
32 Real parallelCapacitance,
33 Real parallelConductance,
34 Real initialCurrent) {
35 const Real epsilon = std::numeric_limits<Real>::epsilon();
37 throw std::invalid_argument(
38 "DC pi-line series resistance must be finite and positive.");
40 throw std::invalid_argument(
41 "DC pi-line series inductance must be finite and positive.");
42 if (!
Math::isFinite(parallelCapacitance) || parallelCapacitance < 0.0 ||
43 (parallelCapacitance > 0.0 &&
45 throw std::invalid_argument(
46 "DC pi-line shunt capacitance must be zero or safely positive.");
47 if (!
Math::isFinite(parallelConductance) || parallelConductance < 0.0 ||
48 (parallelConductance > 0.0 && parallelConductance <=
DOUBLE_EPSILON))
49 throw std::invalid_argument(
50 "DC pi-line shunt conductance must be zero or safely positive.");
52 throw std::invalid_argument(
"DC pi-line initial current must be finite.");
62void EMT::DC::PiLine::validateDCTerminals()
const {
63 for (
UInt terminalIdx = 0; terminalIdx < 2; ++terminalIdx) {
64 const auto terminalNode =
const_cast<PiLine *
>(
this)->node(terminalIdx);
65 if (!terminalNode->isGround() && terminalNode->phaseType() !=
PhaseType::DC)
66 throw std::invalid_argument(
67 "DC pi-line requires DC nodes or ground at both terminals.");
75 throw std::logic_error(
76 "setParameters() must be called before pi-line construction.");
77 validateDCTerminals();
97 throw std::invalid_argument(
"DC pi-line shunt resistance is non-finite.");
100 mShuntResistor0->setParameters(halfShuntResistance);
107 mShuntResistor1->setParameters(halfShuntResistance);
117 mShuntCapacitor0->setParameters(halfCapacitance);
124 mShuntCapacitor1->setParameters(halfCapacitance);
133 validateDCTerminals();
137 std::abs(voltage0.imag()) > std::numeric_limits<Real>::epsilon() ||
138 std::abs(voltage1.imag()) > std::numeric_limits<Real>::epsilon())
139 throw std::invalid_argument(
140 "DC pi-line initial node voltages must be finite real values.");
142 (**mIntfVoltage)(0, 0) = voltage1.real() - voltage0.real();
145 const Real virtualVoltage =
151 (**mIntfVoltage)(0, 0) = 0.0;
153 (**mIntfVoltage)(0, 0) =
156 (**mIntfVoltage)(0, 0) -=
159 throw std::runtime_error(
160 "DC pi-line voltage update produced a non-finite value.");
165 if (!(**mIntfCurrent).allFinite())
166 throw std::runtime_error(
167 "DC pi-line current update produced a non-finite value.");
190 attributeDependencies.push_back(leftVector);
AttributePointer< Attribute< T > > Ptr
void addMNASubComponent(typename SimPowerComp< Real >::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)
const Attribute< Real >::Ptr mSeriesResistance
Series resistance [ohm].
void initializeParentFromNodesAndTerminals(Real frequency) override final
void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override final
const Attribute< Real >::Ptr mInitialCurrent
Initial series current from terminal 1 to terminal 0 [A].
void mnaCompUpdateVoltage(const Matrix &leftVector) override final
void mnaParentPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override final
const Attribute< Real >::Ptr mParallelCapacitance
Total terminal-to-ground shunt capacitance [F].
const Attribute< Real >::Ptr mSeriesInductance
Series inductance [H].
void createSubComponents() override final
Constructs and registers MNA subcomponents; called before collectVirtualNodes so virtual nodes exist ...
void mnaParentPreStep(Real time, Int timeStepCount) override final
void setParameters(Real seriesResistance, Real seriesInductance, Real parallelCapacitance=0.0, Real parallelConductance=0.0, Real initialCurrent=0.0)
void mnaCompUpdateCurrent(const Matrix &leftVector) override final
const Attribute< Real >::Ptr mParallelConductance
Total terminal-to-ground shunt conductance [S].
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.
void mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override final
PiLine(String uid, String name, Logger::Level logLevel=Logger::Level::off)
const Attribute< String >::Ptr mName
Human readable name.
String uid()
Returns unique id.
AttributeList::Ptr mAttributes
Attribute List.
spdlog::level::level_enum Level
Attribute< Matrix >::Ptr mRightVector
static Real realFromVectorElement(const Matrix &mat, Matrix::Index row)
static bool isFinite(Real value)
UInt matrixNodeIndex(UInt nodeIndex)
const Attribute< MatrixVar< Real > >::Ptr mIntfCurrent
SimTerminal< Real >::List mTerminals
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.
static std::shared_ptr< PiLine > make(Args &&...args)
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > Matrix
Dense matrix for real numbers.
std::complex< Real > Complex