13 #include <dpsim-models/MNASimPowerComp.h>
14 #include <dpsim-models/Solver/MNAInterface.h>
72 std::vector<Real> mFactorials;
74 std::map<Int, Real> mMultInvFactorials;
76 void generateFrequencies();
84 long long factorial(Int n)
const;
85 Real multInvFactorial(Int n)
const;
86 Real multInvIntGamma(Real n)
const;
91 Logger::Level logLevel = Logger::Level::off);
93 Inverter(String name, Logger::Level logLevel = Logger::Level::off)
102 void setParameters(
const std::vector<Int> &carrierHarms,
103 const std::vector<Int> &modulHarms, Real inputVoltage,
104 Real ratio, Real phase);
106 void calculatePhasors();
112 void mnaCompInitializeHarm(
113 Real omega, Real timeStep,
117 void mnaCompApplySystemMatrixStampHarm(SparseMatrixRow &systemMatrix,
118 Int freqIdx)
override;
121 void mnaCompApplyRightSideVectorStampHarm(Matrix &rightVector)
override;
122 void mnaCompApplyRightSideVectorStampHarm(Matrix &sourceVector,
123 Int freqIdx)
override;
126 AttributeBase::List &prevStepDependencies,
127 AttributeBase::List &attributeDependencies,
128 AttributeBase::List &modifiedAttributes)
override;
132 AttributeBase::List &attributeDependencies,
133 AttributeBase::List &modifiedAttributes,
135 void mnaCompPreStep(Real time, Int timeStepCount)
override;
136 void mnaCompPostStep(Real time, Int timeStepCount,
142 :
Task(**inverter.
mName +
".MnaPreStepHarm"), mInverter(inverter) {
143 mModifiedAttributes.push_back(mInverter.
attribute(
"right_vector"));
144 mModifiedAttributes.push_back(mInverter.
attribute(
"v_intf"));
146 void execute(Real time, Int timeStepCount);
156 :
Task(**inverter.
mName +
".MnaPostStepHarm"), mInverter(inverter),
157 mLeftVectors(leftVectors) {
158 for (UInt i = 0; i < mLeftVectors.size(); i++)
159 mAttributeDependencies.push_back(mLeftVectors[i]);
160 mModifiedAttributes.push_back(mInverter.
attribute(
"i_intf"));
162 void execute(Real time, Int timeStepCount);
166 std::vector<Attribute<Matrix>::Ptr> mLeftVectors;
Single phase inverter model.
Int mMaxModulHarm
Maximum number of modulation signal harmonics.
std::vector< Int > mModHarms
Vector of modulation signal harmonics.
Real mModIdx
Modulation Index.
Real mOmCar
switching angular frequency
void mnaCompAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
Add MNA pre step dependencies.
Inverter(String name, Logger::Level logLevel=Logger::Level::off)
Defines name and logging level.
Real mFreqMod
system frequency (should be updated every step)
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override
Stamps system matrix.
UInt mHarNum
Number of harmonics.
Int mMaxCarrierHarm
Maximum number of carrier signal harmonics.
Matrix mPhasorPhases
Vector of phasor phases.
Real mPhaseCar
Carrier phase.
void initialize(Matrix frequencies) override
Initialize components with correct network frequencies.
Real besselFirstKind_n(Int n, Int k_max, Real x) const
Bessel function.
Real besselFirstKind_n_opt(Int n, Int k_max, Real x)
Bessel function using look up tables for factorials.
Inverter(String name, String uid, Logger::Level logLevel=Logger::Level::off)
Defines UID, name and logging level.
Real mOmMod
system angular frequency
Real mFreqCar
switching frequency (constant)
Matrix mPhasorMags
Vector of phasor magnitudes.
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override
Stamps right side (source) vector.
void initializeFromNodesAndTerminals(Real frequency) override
Initializes Component variables according to power flow data stored in Nodes.
Int mMaxBesselSumIdx
Maximum upper limit for Bessel function 1st kind summation.
Real mPhaseMod
Modulation phase.
std::vector< Int > mCarHarms
Vector of carrier signal harmonics.
Matrix mPhasorFreqs
Vector of phasor frequencies.
void mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
Initializes internal variables of the component.
Real mVfund
voltage part of system fundamental
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
const Attribute< String >::Ptr mName
Human readable name.
String uid()
Returns unique id.
AttributeBase::Ptr attribute(const String &name) const
Return pointer to an attribute.
Base class for all MNA components that are transmitting power.
Tasks to be defined by every component.