Commit 61374501 authored by Jan Dinkelbach's avatar Jan Dinkelbach
Browse files

refactor tasks of average inverter, controlled VS and transformer for dp1ph

parent ffd38e8a
......@@ -28,8 +28,7 @@ namespace Ph1 {
public MNAInterface,
public SharedFactory<AvVoltageSourceInverterDQ> {
protected:
// ### Subcomponents ###
// ### Electrical Subcomponents ###
/// Controlled voltage source
std::shared_ptr<DP::Ph1::ControlledVoltageSource> mSubCtrledVoltageSource;
/// Resistor Rf as part of LCL filter
......@@ -50,15 +49,16 @@ namespace Ph1 {
Matrix mIrcdq = Matrix::Zero(2, 1);
// ### outputs ###
///
/// Control Output before Transformation Interface
Matrix mVsdq = Matrix::Zero(2, 1);
/// Control Output before Transformation Interface
MatrixComp mControllerOutput = MatrixComp::Zero(1,1);
/// instantaneous omega
Real mOmegaInst=0;
/// instantaneous frequency
Real mFreqInst=0;
///
Bool mCtrlOn = true;
///
Bool mCoveeCtrled=true;
///
......@@ -84,6 +84,9 @@ namespace Ph1 {
std::vector<const Matrix*> mRightVectorStamps;
public:
/// Setter for parameters of control loops
void setControllerParameters(Real Kp_pll, Real Ki_pll, Real Kp_powerCtrl, Real Ki_powerCtrl, Real Kp_currCtrl, Real Ki_currCtrl, Real Omega_cutoff);
///
std::vector<PQData> mLoadProfile;
......@@ -99,9 +102,6 @@ namespace Ph1 {
void setTransformerParameters(Real nomVoltageEnd1, Real nomVoltageEnd2,
Real ratedPower, Real ratioAbs, Real ratioPhase, Real resistance, Real inductance, Real omega);
///
void setControllerParameters(Real Kp_pll, Real Ki_pll, Real Kp_powerCtrl, Real Ki_powerCtrl,
Real Kp_currCtrl, Real Ki_currCtrl, Real Omega_cutoff);
///
void setFilterParameters(Real Lf, Real Cf, Real Rf, Real Rc);
///
void setInitialStateValues(Real thetaPLLInit, Real phiPLLInit, Real pInit, Real qInit,
......@@ -138,6 +138,7 @@ namespace Ph1 {
void initializeFromPowerflow(Real frequency);
// #### interface with villas node ####
void ctrlReceiver(Attribute<Real>::Ptr qref);
// #### MNA section ####
/// Initializes internal variables of the component
void mnaInitialize(Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector);
......@@ -147,6 +148,17 @@ namespace Ph1 {
void mnaApplyRightSideVectorStamp(Matrix& rightVector);
/// Returns current through the component
void mnaUpdateCurrent(const Matrix& leftVector);
/// MNA pre and post step operations
void mnaPreStep(Real time, Int timeStepCount);
void mnaPostStep(Real time, Int timeStepCount, Attribute<Matrix>::Ptr &leftVector);
/// add MNA pre and post step dependencies
void mnaAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes);
void mnaAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute<Matrix>::Ptr &leftVector);
// #### Control section ####
void controlStep(Real time, Int timeStepCount);
void controlStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes);
/// interface with power control service
void coveeCtrled(Bool ctrled){mCoveeCtrled=ctrled;};
///
......@@ -156,37 +168,41 @@ namespace Ph1 {
///
void setProfileUpdateRate(UInt rate){mProfileUndateRate=rate;};
class ControlStep : public CPS::Task {
public:
ControlStep(AvVoltageSourceInverterDQ& AvVoltageSourceInverterDQ) :
Task(AvVoltageSourceInverterDQ.mName + ".ControlStep"), mAvVoltageSourceInverterDQ(AvVoltageSourceInverterDQ) {
mAvVoltageSourceInverterDQ.controlStepDependencies(mPrevStepDependencies, mAttributeDependencies, mModifiedAttributes);
}
void execute(Real time, Int timeStepCount) { mAvVoltageSourceInverterDQ.controlStep(time, timeStepCount); };
private:
AvVoltageSourceInverterDQ& mAvVoltageSourceInverterDQ;
};
class MnaPreStep : public CPS::Task {
public:
MnaPreStep(AvVoltageSourceInverterDQ& AvVoltageSourceInverterDQ) :
Task(AvVoltageSourceInverterDQ.mName + ".MnaPreStep"), mAvVoltageSourceInverterDQ(AvVoltageSourceInverterDQ) {
//mAttributeDependencies.push_back(AvVoltageSourceInverterDQ.attribute("P_ref"));
mPrevStepDependencies.push_back(AvVoltageSourceInverterDQ.attribute("i_intf"));
mPrevStepDependencies.push_back(AvVoltageSourceInverterDQ.attribute("v_intf"));
mModifiedAttributes.push_back(AvVoltageSourceInverterDQ.mSubCtrledVoltageSource->attribute("v_intf"));
mAvVoltageSourceInverterDQ.mnaAddPreStepDependencies(mPrevStepDependencies, mAttributeDependencies, mModifiedAttributes);
}
void execute(Real time, Int timeStepCount);
void execute(Real time, Int timeStepCount) { mAvVoltageSourceInverterDQ.mnaPreStep(time, timeStepCount); };
private:
AvVoltageSourceInverterDQ& mAvVoltageSourceInverterDQ;
};
class AddBStep : public Task {
class MnaPostStep : public CPS::Task {
public:
AddBStep(AvVoltageSourceInverterDQ& AvVoltageSourceInverterDQ) :
Task(AvVoltageSourceInverterDQ.mName + ".AddBStep"), mAvVoltageSourceInverterDQ(AvVoltageSourceInverterDQ) {
mAttributeDependencies.push_back(AvVoltageSourceInverterDQ.mSubInductorF->attribute("right_vector"));
mAttributeDependencies.push_back(AvVoltageSourceInverterDQ.mConnectionTransformer->attribute("right_vector"));
mAttributeDependencies.push_back(AvVoltageSourceInverterDQ.mSubCapacitorF->attribute("right_vector"));
mAttributeDependencies.push_back(AvVoltageSourceInverterDQ.mSubCtrledVoltageSource->attribute("right_vector"));
mModifiedAttributes.push_back(AvVoltageSourceInverterDQ.attribute("right_vector"));
MnaPostStep(AvVoltageSourceInverterDQ& AvVoltageSourceInverterDQ, Attribute<Matrix>::Ptr leftVector) :
Task(AvVoltageSourceInverterDQ.mName + ".MnaPostStep"), mAvVoltageSourceInverterDQ(AvVoltageSourceInverterDQ), mLeftVector(leftVector) {
mAvVoltageSourceInverterDQ.mnaAddPostStepDependencies(mPrevStepDependencies, mAttributeDependencies, mModifiedAttributes, mLeftVector);
}
void execute(Real time, Int timeStepCount);
void execute(Real time, Int timeStepCount) { mAvVoltageSourceInverterDQ.mnaPostStep(time, timeStepCount, mLeftVector); };
private:
AvVoltageSourceInverterDQ& mAvVoltageSourceInverterDQ;
Attribute<Matrix>::Ptr mLeftVector;
};
class CtrlStep : public Task {
......@@ -196,39 +212,11 @@ namespace Ph1 {
mAttributeDependencies.push_back(AvVoltageSourceInverterDQ.mQRefInput);
mModifiedAttributes.push_back(AvVoltageSourceInverterDQ.attribute("Q_ref"));
}
void execute(Real time, Int timeStepCount);
private:
AvVoltageSourceInverterDQ& mAvVoltageSourceInverterDQ;
};
class MnaPostStep : public CPS::Task {
public:
MnaPostStep(AvVoltageSourceInverterDQ& AvVoltageSourceInverterDQ, Attribute<Matrix>::Ptr leftVector) :
Task(AvVoltageSourceInverterDQ.mName + ".MnaPostStep"), mAvVoltageSourceInverterDQ(AvVoltageSourceInverterDQ), mLeftVector(leftVector)
{
mAttributeDependencies.push_back(leftVector);
//mAttributeDependencies.push_back(AvVoltageSourceInverterDQ.attribute("Q_ref"));
//mAttributeDependencies.push_back(AvVoltageSourceInverterDQ.mQRefInput);
mAttributeDependencies.push_back(AvVoltageSourceInverterDQ.mSubCtrledVoltageSource->attribute("i_intf"));
mAttributeDependencies.push_back(AvVoltageSourceInverterDQ.mSubResistorF->attribute("i_intf"));
mAttributeDependencies.push_back(AvVoltageSourceInverterDQ.mSubInductorF->attribute("i_intf"));
mAttributeDependencies.push_back(AvVoltageSourceInverterDQ.mConnectionTransformer->attribute("i_intf"));
mAttributeDependencies.push_back(AvVoltageSourceInverterDQ.mSubResistorC->attribute("i_intf"));
mModifiedAttributes.push_back(AvVoltageSourceInverterDQ.attribute("i_intf"));
mModifiedAttributes.push_back(AvVoltageSourceInverterDQ.attribute("v_intf"));
}
void execute(Real time, Int timeStepCount);
private:
AvVoltageSourceInverterDQ& mAvVoltageSourceInverterDQ;
Attribute<Matrix>::Ptr mLeftVector;
};
};
}
}
......
......@@ -46,17 +46,20 @@ namespace CPS {
void mnaApplyRightSideVectorStamp(Matrix& rightVector);
/// Returns current through the component
void mnaUpdateCurrent(const Matrix& leftVector);
/// MNA pre and post step operations
void mnaPreStep(Real time, Int timeStepCount);
void mnaPostStep(Real time, Int timeStepCount, Attribute<Matrix>::Ptr &leftVector);
/// add MNA pre and post step dependencies
void mnaAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes);
void mnaAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute<Matrix>::Ptr &leftVector);
class MnaPreStep : public CPS::Task {
public:
MnaPreStep(ControlledVoltageSource& ControlledVoltageSource) :
Task(ControlledVoltageSource.mName + ".MnaPreStep"), mControlledVoltageSource(ControlledVoltageSource) {
mAttributeDependencies.push_back(ControlledVoltageSource.attribute("v_intf"));
mModifiedAttributes.push_back(mControlledVoltageSource.attribute("right_vector"));
}
void execute(Real time, Int timeStepCount);
mControlledVoltageSource.mnaAddPreStepDependencies(mPrevStepDependencies, mAttributeDependencies, mModifiedAttributes);
}
void execute(Real time, Int timeStepCount) { mControlledVoltageSource.mnaPreStep(time, timeStepCount); };
private:
ControlledVoltageSource& mControlledVoltageSource;
};
......@@ -64,14 +67,10 @@ namespace CPS {
class MnaPostStep : public CPS::Task {
public:
MnaPostStep(ControlledVoltageSource& ControlledVoltageSource, Attribute<Matrix>::Ptr leftVector) :
Task(ControlledVoltageSource.mName + ".MnaPostStep"), mControlledVoltageSource(ControlledVoltageSource), mLeftVector(leftVector)
{
mAttributeDependencies.push_back(mLeftVector);
mModifiedAttributes.push_back(mControlledVoltageSource.attribute("i_intf"));
}
void execute(Real time, Int timeStepCount);
Task(ControlledVoltageSource.mName + ".MnaPostStep"), mControlledVoltageSource(ControlledVoltageSource), mLeftVector(leftVector) {
mControlledVoltageSource.mnaAddPostStepDependencies(mPrevStepDependencies, mAttributeDependencies, mModifiedAttributes, mLeftVector);
}
void execute(Real time, Int timeStepCount) { mControlledVoltageSource.mnaPostStep(time, timeStepCount, mLeftVector); };
private:
ControlledVoltageSource& mControlledVoltageSource;
Attribute<Matrix>::Ptr mLeftVector;
......
......@@ -64,20 +64,20 @@ namespace Ph1 {
void mnaUpdateCurrent(const Matrix& leftVector);
/// Updates internal voltage variable of the component
void mnaUpdateVoltage(const Matrix& leftVector);
/// MNA pre and post step operations
void mnaPreStep(Real time, Int timeStepCount);
void mnaPostStep(Real time, Int timeStepCount, Attribute<Matrix>::Ptr &leftVector);
/// add MNA pre and post step dependencies
void mnaAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes);
void mnaAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute<Matrix>::Ptr &leftVector);
class MnaPreStep : public Task {
public:
MnaPreStep(Transformer& transformer) :
Task(transformer.mName + ".MnaPreStep"), mTransformer(transformer) {
mAttributeDependencies.push_back(transformer.mSubSnubResistor->attribute("right_vector"));
mAttributeDependencies.push_back(transformer.mSubInductor->attribute("right_vector"));
if (transformer.mSubResistor)
mAttributeDependencies.push_back(transformer.mSubResistor->attribute("right_vector"));
mModifiedAttributes.push_back(transformer.attribute("right_vector"));
mTransformer.mnaAddPreStepDependencies(mPrevStepDependencies, mAttributeDependencies, mModifiedAttributes);
}
void execute(Real time, Int timeStepCount);
void execute(Real time, Int timeStepCount) { mTransformer.mnaPreStep(time, timeStepCount); };
private:
Transformer& mTransformer;
};
......@@ -87,13 +87,9 @@ namespace Ph1 {
public:
MnaPostStep(Transformer& transformer, Attribute<Matrix>::Ptr leftVector) :
Task(transformer.mName + ".MnaPostStep"), mTransformer(transformer), mLeftVector(leftVector) {
mAttributeDependencies.push_back(transformer.mSubInductor->attribute("i_intf"));
mAttributeDependencies.push_back(leftVector);
mModifiedAttributes.push_back(transformer.attribute("i_intf"));
mModifiedAttributes.push_back(transformer.attribute("v_intf"));
mTransformer.mnaAddPostStepDependencies(mPrevStepDependencies, mAttributeDependencies, mModifiedAttributes, mLeftVector);
}
void execute(Real time, Int timeStepCount);
void execute(Real time, Int timeStepCount) { mTransformer.mnaPostStep(time, timeStepCount, mLeftVector); };
private:
Transformer& mTransformer;
......
......@@ -33,11 +33,11 @@ DP::Ph1::AvVoltageSourceInverterDQ::AvVoltageSourceInverterDQ(String uid, String
// additional output variables
addAttribute<Matrix>("Vsdq", &mVsdq, Flags::read | Flags::write);
addAttribute<MatrixComp>("controller_output", &mControllerOutput, Flags::read | Flags::write);
// additional variables for logging
addAttribute<Real>("omega", &mOmegaInst, Flags::read | Flags::write);
addAttribute<Real>("freq", &mFreqInst, Flags::read | Flags::write);
addAttribute<Bool>("ctrl_on", &mCtrlOn, Flags::read | Flags::write);
// state variables
addAttribute<Real>("theta", &mThetaPLL, Flags::read | Flags::write);
......@@ -109,6 +109,7 @@ void DP::Ph1::AvVoltageSourceInverterDQ::setInitialStateValues(Real thetaPLLInit
mSLog->info("Gamma_dInit = {}, Gamma_qInit = {}", mGamma_dInit, mGamma_qInit);
}
SimPowerComp<Complex>::Ptr DP::Ph1::AvVoltageSourceInverterDQ::clone(String name) {
auto copy = DP::Ph1::AvVoltageSourceInverterDQ::make(name, mLogLevel);
copy->setParameters(mOmegaN, mVnom, mPref, mQref);
......@@ -223,42 +224,25 @@ void DP::Ph1::AvVoltageSourceInverterDQ::step(Real time, Int timeStepCount) {
newU << mOmegaN, mPref, mQref, mVcdq(0, 0), mVcdq(1, 0), mIrcdq(0, 0), mIrcdq(1, 0);
newStates = Math::StateSpaceTrapezoidal(mStates, mA, mB, mTimeStep, newU, mU);
if (mCtrlOn) {
// update states
mThetaPLL = newStates(0, 0);
mPhiPLL = newStates(1, 0);
mP = newStates(2, 0);
mQ = newStates(3, 0);
mPhi_d = newStates(4, 0);
mPhi_q = newStates(5, 0);
mGamma_d = newStates(6, 0);
mGamma_q = newStates(7, 0);
// update measurements ( for additional loggers)
mOmegaInst = (newStates(0, 0) - mStates(0,0))/mTimeStep;
mFreqInst = mOmegaInst / 2 / PI;
mStates = newStates;
mU = newU;
// new output
mVsdq = mC * mStates + mD * mU;
}
else {
mThetaPLL = newStates(0, 0);
// update measurements ( for additional loggers)
mOmegaInst = (time > 0) ? mThetaPLL / time : 0;
mFreqInst = mOmegaInst / 2 / PI;
mPhiPLL = newStates(1, 0);
mP = newStates(2, 0);
mQ = newStates(3, 0);
mStates(0, 0) = newStates(0, 0);
mStates(1, 0) = newStates(1, 0);
mU = newU;
mVsdq(0, 0) = mVirtualNodes[1]->initialSingleVoltage().real();
mVsdq(1, 0) = mVirtualNodes[1]->initialSingleVoltage().imag();
}
// update states
mThetaPLL = newStates(0, 0);
mPhiPLL = newStates(1, 0);
mP = newStates(2, 0);
mQ = newStates(3, 0);
mPhi_d = newStates(4, 0);
mPhi_q = newStates(5, 0);
mGamma_d = newStates(6, 0);
mGamma_q = newStates(7, 0);
// update measurements ( for additional loggers)
mOmegaInst = (newStates(0, 0) - mStates(0,0))/mTimeStep;
mFreqInst = mOmegaInst / 2 / PI;
mStates = newStates;
mU = newU;
// new output
mVsdq = mC * mStates + mD * mU;
}
void DP::Ph1::AvVoltageSourceInverterDQ::updateBMatrixStateSpaceModel() {
......@@ -374,36 +358,32 @@ void DP::Ph1::AvVoltageSourceInverterDQ::mnaInitialize(Real omega, Real timeStep
if(!mLoadProfile.empty())
mCurrentLoad = mLoadProfile.begin();
MNAInterface::List subComps({ mSubResistorF, mSubInductorF, mSubCapacitorF, mSubResistorC, mSubCtrledVoltageSource });
// initialize subcomponents
mSubResistorF->mnaInitialize(omega, timeStep, leftVector);
mSubInductorF->mnaInitialize(omega, timeStep, leftVector);
mSubCapacitorF->mnaInitialize(omega, timeStep, leftVector);
mSubResistorC->mnaInitialize(omega, timeStep, leftVector);
mSubCtrledVoltageSource->mnaInitialize(omega, timeStep, leftVector);
if (mWithConnectionTransformer)
mConnectionTransformer->mnaInitialize(omega, timeStep, leftVector);
// initialize state space controller
initializeStateSpaceModel(omega, timeStep, leftVector);
// collect right side vectors of subcomponents
mRightVectorStamps.push_back(&mSubCapacitorF->attribute<Matrix>("right_vector")->get());
mRightVectorStamps.push_back(&mSubInductorF->attribute<Matrix>("right_vector")->get());
mRightVectorStamps.push_back(&mSubCtrledVoltageSource->attribute<Matrix>("right_vector")->get());
// add tasks
for (auto comp : subComps) {
for (auto task : comp->mnaTasks())
mMnaTasks.push_back(task);
}
if (mWithConnectionTransformer) {
mConnectionTransformer->mnaInitialize(omega, timeStep, leftVector);
if (mWithConnectionTransformer)
mRightVectorStamps.push_back(&mConnectionTransformer->attribute<Matrix>("right_vector")->get());
for (auto task : mConnectionTransformer->mnaTasks()) {
mMnaTasks.push_back(task);
}
}
// collect tasks
mMnaTasks.push_back(std::make_shared<MnaPreStep>(*this));
mMnaTasks.push_back(std::make_shared<AddBStep>(*this));
mMnaTasks.push_back(std::make_shared<ControlStep>(*this));
if(mCoveeCtrled)
mMnaTasks.push_back(std::make_shared<CtrlStep>(*this));
mMnaTasks.push_back(std::make_shared<MnaPostStep>(*this, leftVector));
mRightVector = Matrix::Zero(leftVector->get().rows(), 1);
}
......@@ -429,29 +409,73 @@ void DP::Ph1::AvVoltageSourceInverterDQ::updateSetPoint(Real time){
mQref = mQRefInput->get();
}
void DP::Ph1::AvVoltageSourceInverterDQ::MnaPreStep::execute(Real time, Int timeStepCount) {
if (mAvVoltageSourceInverterDQ.mCtrlOn) {
MatrixComp vsDqOmegaS = MatrixComp::Zero(1,1);
vsDqOmegaS(0,0) = mAvVoltageSourceInverterDQ.rotatingFrame2to1(Complex(mAvVoltageSourceInverterDQ.mVsdq(0, 0), mAvVoltageSourceInverterDQ.mVsdq(1, 0)), mAvVoltageSourceInverterDQ.mOmegaN * time, mAvVoltageSourceInverterDQ.mThetaPLL);
mAvVoltageSourceInverterDQ.mSubCtrledVoltageSource->setParameters(vsDqOmegaS);
}
else
mAvVoltageSourceInverterDQ.mSubCtrledVoltageSource->setParameters(mAvVoltageSourceInverterDQ.mVsdq);
void DP::Ph1::AvVoltageSourceInverterDQ::controlStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) {
prevStepDependencies.push_back(this->attribute("i_intf"));
prevStepDependencies.push_back(this->attribute("v_intf"));
modifiedAttributes.push_back(this->attribute("controller_output"));
}
void DP::Ph1::AvVoltageSourceInverterDQ::MnaPostStep::execute(Real time, Int timeStepCount) {
mAvVoltageSourceInverterDQ.mnaUpdateCurrent(*mLeftVector);
mAvVoltageSourceInverterDQ.updateInputStateSpaceModel(*mLeftVector, time);
mAvVoltageSourceInverterDQ.step(time, timeStepCount);
void DP::Ph1::AvVoltageSourceInverterDQ::controlStep(Real time, Int timeStepCount) {
// Transformation interface inverse
this->mControllerOutput(0,0) = this->rotatingFrame2to1(Complex(this->mVsdq(0, 0), this->mVsdq(1, 0)), this->mOmegaN * time, this->mThetaPLL);
}
void DP::Ph1::AvVoltageSourceInverterDQ::CtrlStep::execute(Real time, Int timeStepCount){
mAvVoltageSourceInverterDQ.updateSetPoint(time);
void DP::Ph1::AvVoltageSourceInverterDQ::mnaAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) {
// add pre-step dependencies of subcomponents
attributeDependencies.push_back(this->attribute("controller_output"));
this->mSubCtrledVoltageSource->mnaAddPreStepDependencies(prevStepDependencies, attributeDependencies, modifiedAttributes);
this->mSubInductorF->mnaAddPreStepDependencies(prevStepDependencies, attributeDependencies, modifiedAttributes);
this->mSubCapacitorF->mnaAddPreStepDependencies(prevStepDependencies, attributeDependencies, modifiedAttributes);
// add pre-step dependencies of component itself
prevStepDependencies.push_back(this->attribute("i_intf"));
prevStepDependencies.push_back(this->attribute("v_intf"));
modifiedAttributes.push_back(this->attribute("right_vector"));
}
void DP::Ph1::AvVoltageSourceInverterDQ::mnaPreStep(Real time, Int timeStepCount) {
// pre-step of subcomponents
if (mWithConnectionTransformer)
this->mConnectionTransformer->mnaPreStep(time, timeStepCount);
this->mSubCtrledVoltageSource->setParameters(mControllerOutput);
this->mSubCtrledVoltageSource->mnaPreStep(time, timeStepCount);
this->mSubInductorF->mnaPreStep(time, timeStepCount);
this->mSubCapacitorF->mnaPreStep(time, timeStepCount);
// pre-step of component itself
this->mnaApplyRightSideVectorStamp(this->mRightVector);
}
void DP::Ph1::AvVoltageSourceInverterDQ::AddBStep::execute(Real time, Int timeStepCount) {
mAvVoltageSourceInverterDQ.mnaApplyRightSideVectorStamp(mAvVoltageSourceInverterDQ.mRightVector);
void DP::Ph1::AvVoltageSourceInverterDQ::mnaAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute<Matrix>::Ptr &leftVector) {
// add post-step dependencies of subcomponents
if (mWithConnectionTransformer)
this->mConnectionTransformer->mnaAddPostStepDependencies(prevStepDependencies, attributeDependencies, modifiedAttributes, leftVector);
this->mSubCtrledVoltageSource->mnaAddPostStepDependencies(prevStepDependencies, attributeDependencies, modifiedAttributes, leftVector);
this->mSubResistorF->mnaAddPostStepDependencies(prevStepDependencies, attributeDependencies, modifiedAttributes, leftVector);
this->mSubInductorF->mnaAddPostStepDependencies(prevStepDependencies, attributeDependencies, modifiedAttributes, leftVector);
this->mSubCapacitorF->mnaAddPostStepDependencies(prevStepDependencies, attributeDependencies, modifiedAttributes, leftVector);
this->mSubResistorC->mnaAddPostStepDependencies(prevStepDependencies, attributeDependencies, modifiedAttributes, leftVector);
// add post-step dependencies of component itself
attributeDependencies.push_back(leftVector);
modifiedAttributes.push_back(this->attribute("v_intf"));
modifiedAttributes.push_back(this->attribute("i_intf"));
}
void DP::Ph1::AvVoltageSourceInverterDQ::mnaPostStep(Real time, Int timeStepCount, Attribute<Matrix>::Ptr &leftVector) {
// post-step of subcomponents
if (mWithConnectionTransformer)
this->mConnectionTransformer->mnaPostStep(time, timeStepCount, leftVector);
this->mSubCtrledVoltageSource->mnaPostStep(time, timeStepCount, leftVector);
this->mSubResistorF->mnaPostStep(time, timeStepCount, leftVector);
this->mSubInductorF->mnaPostStep(time, timeStepCount, leftVector);
this->mSubCapacitorF->mnaPostStep(time, timeStepCount, leftVector);
this->mSubResistorC->mnaPostStep(time, timeStepCount, leftVector);
// post-step of component itself
this->mnaUpdateCurrent(*leftVector);
this->updateInputStateSpaceModel(*leftVector, time);
this->step(time, timeStepCount);
}
void DP::Ph1::AvVoltageSourceInverterDQ::CtrlStep::execute(Real time, Int timeStepCount){
mAvVoltageSourceInverterDQ.updateSetPoint(time);
}
void DP::Ph1::AvVoltageSourceInverterDQ::mnaUpdateCurrent(const Matrix& leftvector) {
......
......@@ -80,12 +80,22 @@ void DP::Ph1::ControlledVoltageSource::mnaApplyRightSideVectorStamp(Matrix& righ
Logger::complexToString(mIntfVoltage(0, 0)), mVirtualNodes[0]->matrixNodeIndex());
}
void DP::Ph1::ControlledVoltageSource::MnaPreStep::execute(Real time, Int timeStepCount) {
mControlledVoltageSource.mnaApplyRightSideVectorStamp(mControlledVoltageSource.mRightVector);
void DP::Ph1::ControlledVoltageSource::mnaAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) {
attributeDependencies.push_back(this->attribute("v_intf"));
modifiedAttributes.push_back(this->attribute("right_vector"));
}
void DP::Ph1::ControlledVoltageSource::MnaPostStep::execute(Real time, Int timeStepCount) {
mControlledVoltageSource.mnaUpdateCurrent(*mLeftVector);
void DP::Ph1::ControlledVoltageSource::mnaPreStep(Real time, Int timeStepCount) {
this->mnaApplyRightSideVectorStamp(this->mRightVector);
}
void DP::Ph1::ControlledVoltageSource::mnaAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute<Matrix>::Ptr &leftVector) {
attributeDependencies.push_back(leftVector);
modifiedAttributes.push_back(this->attribute("i_intf"));
}
void DP::Ph1::ControlledVoltageSource::mnaPostStep(Real time, Int timeStepCount, Attribute<Matrix>::Ptr &leftVector) {
this->mnaUpdateCurrent(*leftVector);
}
void DP::Ph1::ControlledVoltageSource::mnaUpdateCurrent(const Matrix& leftVector) {
......
......@@ -122,14 +122,18 @@ void DP::Ph1::Transformer::mnaInitialize(Real omega, Real timeStep, Attribute<Ma
mRightVector = Matrix::Zero(leftVector->get().rows(), 1);
auto subComponents = MNAInterface::List({mSubInductor, mSubSnubResistor});
if (mSubResistor)
subComponents.push_back(mSubResistor);
for (auto comp : subComponents) {
comp->mnaInitialize(omega, timeStep, leftVector);
for (auto task : comp->mnaTasks()) {
for (auto task : comp->mnaTasks())
mMnaTasks.push_back(task);
}
}
mMnaTasks.push_back(std::make_shared<MnaPreStep>(*this));
mMnaTasks.push_back(std::make_shared<MnaPostStep>(*this, leftVector));
......@@ -177,13 +181,43 @@ void DP::Ph1::Transformer::mnaApplyRightSideVectorStamp(Matrix& rightVector) {
mSubInductor->mnaApplyRightSideVectorStamp(rightVector);
}
void DP::Ph1::Transformer::MnaPreStep::execute(Real time, Int timeStepCount) {
mTransformer.mnaApplyRightSideVectorStamp(mTransformer.mRightVector);
void DP::Ph1::Transformer::mnaAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) {
// add pre-step dependencies of subcomponents
this->mSubInductor->mnaAddPreStepDependencies(prevStepDependencies, attributeDependencies, modifiedAttributes);
// add pre-step dependencies of component itself
prevStepDependencies.push_back(this->attribute("i_intf"));
prevStepDependencies.push_back(this->attribute("v_intf"));
modifiedAttributes.push_back(this->attribute("right_vector"));
}
void DP::Ph1::Transformer::mnaPreStep(Real time, Int timeStepCount) {
// pre-step of subcomponents
this->mSubInductor->mnaPreStep(time, timeStepCount);
// pre-step of component itself
this->mnaApplyRightSideVectorStamp(this->mRightVector);
}
void DP::Ph1::Transformer::MnaPostStep::execute(Real time, Int timeStepCount) {
mTransformer.mnaUpdateVoltage(*mLeftVector);
mTransformer.mnaUpdateCurrent(*mLeftVector);
void DP::Ph1::Transformer::mnaAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute<Matrix>::Ptr &leftVector) {
// add post-step dependencies of subcomponents
if (mSubResistor)
this->mSubResistor->mnaAddPostStepDependencies(prevStepDependencies, attributeDependencies, modifiedAttributes, leftVector);
this->mSubInductor->mnaAddPostStepDependencies(prevStepDependencies, attributeDependencies, modifiedAttributes, leftVector);
this->mSubSnubResistor->mnaAddPostStepDependencies(prevStepDependencies, attributeDependencies, modifiedAttributes, leftVector);
// add post-step dependencies of component itself
attributeDependencies.push_back(leftVector);
modifiedAttributes.push_back(this->attribute("v_intf"));
modifiedAttributes.push_back(this->attribute("i_intf"));
}
void DP::Ph1::Transformer::mnaPos