Commit 2e4192eb authored by Jan Dinkelbach's avatar Jan Dinkelbach
Browse files

refactor mna tasks and their attribute dependencies in RLC and PiLine for DP Ph1

parent 682a3bdf
......@@ -66,17 +66,20 @@ namespace Ph1 {
/// Update interface current from MNA system result
void mnaUpdateCurrent(const Matrix& leftVector);
void mnaUpdateCurrentHarm();
/// 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(Capacitor& capacitor)
: Task(capacitor.mName + ".MnaPreStep"), mCapacitor(capacitor) {
// actually depends on C, but then we'd have to modify the system matrix anyway
mModifiedAttributes.push_back(capacitor.attribute("right_vector"));
mPrevStepDependencies.push_back(capacitor.attribute("i_intf"));
mPrevStepDependencies.push_back(capacitor.attribute("v_intf"));
mCapacitor.mnaAddPreStepDependencies(mPrevStepDependencies, mAttributeDependencies, mModifiedAttributes);
}
void execute(Real time, Int timeStepCount);
void execute(Real time, Int timeStepCount) { mCapacitor.mnaPreStep(time, timeStepCount); };
private:
Capacitor& mCapacitor;
};
......@@ -85,11 +88,9 @@ namespace Ph1 {
public:
MnaPostStep(Capacitor& capacitor, Attribute<Matrix>::Ptr leftVector)
: Task(capacitor.mName + ".MnaPostStep"), mCapacitor(capacitor), mLeftVector(leftVector) {
mAttributeDependencies.push_back(mLeftVector);
mModifiedAttributes.push_back(mCapacitor.attribute("v_intf"));
mModifiedAttributes.push_back(mCapacitor.attribute("i_intf"));
mCapacitor.mnaAddPostStepDependencies(mPrevStepDependencies, mAttributeDependencies, mModifiedAttributes, mLeftVector);
}
void execute(Real time, Int timeStepCount);
void execute(Real time, Int timeStepCount) { mCapacitor.mnaPostStep(time, timeStepCount, mLeftVector); };
private:
Capacitor& mCapacitor;
Attribute<Matrix>::Ptr mLeftVector;
......
......@@ -67,6 +67,12 @@ namespace Ph1 {
/// Update interface current from MNA system results
void mnaUpdateCurrent(const Matrix& leftVector);
void mnaUpdateCurrentHarm();
/// 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);
// #### Tearing methods ####
void mnaTearInitialize(Real omega, Real timestep);
......@@ -78,12 +84,9 @@ namespace Ph1 {
public:
MnaPreStep(Inductor& inductor) :
Task(inductor.mName + ".MnaPreStep"), mInductor(inductor) {
// actually depends on L, but then we'd have to modify the system matrix anyway
mModifiedAttributes.push_back(inductor.attribute("right_vector"));
mPrevStepDependencies.push_back(inductor.attribute("v_intf"));
mPrevStepDependencies.push_back(inductor.attribute("i_intf"));
mInductor.mnaAddPreStepDependencies(mPrevStepDependencies, mAttributeDependencies, mModifiedAttributes);
}
void execute(Real time, Int timeStepCount);
void execute(Real time, Int timeStepCount) { mInductor.mnaPreStep(time, timeStepCount); };
private:
Inductor& mInductor;
};
......@@ -93,11 +96,9 @@ namespace Ph1 {
MnaPostStep(Inductor& inductor, Attribute<Matrix>::Ptr leftVector) :
Task(inductor.mName + ".MnaPostStep"),
mInductor(inductor), mLeftVector(leftVector) {
mAttributeDependencies.push_back(mLeftVector);
mModifiedAttributes.push_back(mInductor.attribute("v_intf"));
mModifiedAttributes.push_back(mInductor.attribute("i_intf"));
mInductor.mnaAddPostStepDependencies(mPrevStepDependencies, mAttributeDependencies, mModifiedAttributes, mLeftVector);
}
void execute(Real time, Int timeStepCount);
void execute(Real time, Int timeStepCount) { mInductor.mnaPostStep(time, timeStepCount, mLeftVector); };
private:
Inductor& mInductor;
Attribute<Matrix>::Ptr mLeftVector;
......
......@@ -67,27 +67,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(PiLine& line) :
Task(line.mName + ".MnaPreStep"), mLine(line) {
mAttributeDependencies.push_back(line.mSubSeriesResistor->attribute("right_vector"));
mAttributeDependencies.push_back(line.mSubSeriesInductor->attribute("right_vector"));
if (line.mParallelCond >= 0) {
mAttributeDependencies.push_back(line.mSubParallelResistor0->attribute("right_vector"));
mAttributeDependencies.push_back(line.mSubParallelResistor1->attribute("right_vector"));
}
if (line.mParallelCap >= 0) {
mAttributeDependencies.push_back(line.mSubParallelCapacitor0->attribute("right_vector"));
mAttributeDependencies.push_back(line.mSubParallelCapacitor1->attribute("right_vector"));
}
mModifiedAttributes.push_back(line.attribute("right_vector"));
mLine.mnaAddPreStepDependencies(mPrevStepDependencies, mAttributeDependencies, mModifiedAttributes);
}
void execute(Real time, Int timeStepCount);
void execute(Real time, Int timeStepCount) { mLine.mnaPreStep(time, timeStepCount); };
private:
PiLine& mLine;
};
......@@ -96,14 +89,9 @@ namespace Ph1 {
public:
MnaPostStep(PiLine& line, Attribute<Matrix>::Ptr leftVector) :
Task(line.mName + ".MnaPostStep"), mLine(line), mLeftVector(leftVector) {
mAttributeDependencies.push_back(leftVector);
mAttributeDependencies.push_back(line.mSubSeriesInductor->attribute("i_intf"));
mModifiedAttributes.push_back(line.attribute("i_intf"));
mModifiedAttributes.push_back(line.attribute("v_intf"));
mLine.mnaAddPostStepDependencies(mPrevStepDependencies, mAttributeDependencies, mModifiedAttributes, mLeftVector);
}
void execute(Real time, Int timeStepCount);
void execute(Real time, Int timeStepCount) { mLine.mnaPostStep(time, timeStepCount, mLeftVector); };
private:
PiLine& mLine;
Attribute<Matrix>::Ptr mLeftVector;
......
......@@ -51,17 +51,19 @@ namespace Ph1 {
/// Update interface current from MNA system result
void mnaUpdateCurrent(const Matrix& leftVector);
void mnaUpdateCurrentHarm();
/// MNA pre and post step operations
void mnaPostStep(Real time, Int timeStepCount, Attribute<Matrix>::Ptr &leftVector);
/// add MNA pre and post step dependencies
void mnaAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute<Matrix>::Ptr &leftVector);
class MnaPostStep : public Task {
public:
MnaPostStep(Resistor& resistor, Attribute<Matrix>::Ptr leftSideVector) :
Task(resistor.mName + ".MnaPostStep"),
mResistor(resistor), mLeftVector(leftSideVector) {
mAttributeDependencies.push_back(mLeftVector);
mModifiedAttributes.push_back(mResistor.attribute("v_intf"));
mModifiedAttributes.push_back(mResistor.attribute("i_intf"));
mResistor.mnaAddPostStepDependencies(mPrevStepDependencies, mAttributeDependencies, mModifiedAttributes, mLeftVector);
}
void execute(Real time, Int timeStepCount);
void execute(Real time, Int timeStepCount) { mResistor.mnaPostStep(time, timeStepCount, mLeftVector); };
private:
Resistor& mResistor;
Attribute<Matrix>::Ptr mLeftVector;
......
......@@ -211,17 +211,30 @@ void DP::Ph1::Capacitor::mnaApplyRightSideVectorStampHarm(Matrix& rightVector, I
Math::setVectorElement(rightVector, matrixNodeIndex(1), -mEquivCurrent(freq,0));
}
void DP::Ph1::Capacitor::MnaPreStep::execute(Real time, Int timeStepCount) {
mCapacitor.mnaApplyRightSideVectorStamp(mCapacitor.mRightVector);
void DP::Ph1::Capacitor::mnaAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) {
// actually depends on C, but then we'd have to modify the system matrix anyway
prevStepDependencies.push_back(this->attribute("i_intf"));
prevStepDependencies.push_back(this->attribute("v_intf"));
modifiedAttributes.push_back(this->attribute("right_vector"));
}
void DP::Ph1::Capacitor::MnaPreStepHarm::execute(Real time, Int timeStepCount) {
mCapacitor.mnaApplyRightSideVectorStampHarm(mCapacitor.mRightVector);
void DP::Ph1::Capacitor::mnaPreStep(Real time, Int timeStepCount) {
this->mnaApplyRightSideVectorStamp(this->mRightVector);
}
void DP::Ph1::Capacitor::mnaAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute<Matrix>::Ptr &leftVector) {
attributeDependencies.push_back(leftVector);
modifiedAttributes.push_back(this->attribute("v_intf"));
modifiedAttributes.push_back(this->attribute("i_intf"));
}
void DP::Ph1::Capacitor::MnaPostStep::execute(Real time, Int timeStepCount) {
mCapacitor.mnaUpdateVoltage(*mLeftVector);
mCapacitor.mnaUpdateCurrent(*mLeftVector);
void DP::Ph1::Capacitor::mnaPostStep(Real time, Int timeStepCount, Attribute<Matrix>::Ptr &leftVector) {
this->mnaUpdateVoltage(*leftVector);
this->mnaUpdateCurrent(*leftVector);
}
void DP::Ph1::Capacitor::MnaPreStepHarm::execute(Real time, Int timeStepCount) {
mCapacitor.mnaApplyRightSideVectorStampHarm(mCapacitor.mRightVector);
}
void DP::Ph1::Capacitor::MnaPostStepHarm::execute(Real time, Int timeStepCount) {
......
......@@ -195,17 +195,30 @@ void DP::Ph1::Inductor::mnaApplyRightSideVectorStampHarm(Matrix& rightVector) {
}
}
void DP::Ph1::Inductor::MnaPreStep::execute(Real time, Int timeStepCount) {
mInductor.mnaApplyRightSideVectorStamp(mInductor.mRightVector);
void DP::Ph1::Inductor::mnaAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) {
// actually depends on L, but then we'd have to modify the system matrix anyway
prevStepDependencies.push_back(this->attribute("v_intf"));
prevStepDependencies.push_back(this->attribute("i_intf"));
modifiedAttributes.push_back(this->attribute("right_vector"));
}
void DP::Ph1::Inductor::MnaPreStepHarm::execute(Real time, Int timeStepCount) {
mInductor.mnaApplyRightSideVectorStampHarm(mInductor.mRightVector);
void DP::Ph1::Inductor::mnaPreStep(Real time, Int timeStepCount) {
this->mnaApplyRightSideVectorStamp(this->mRightVector);
}
void DP::Ph1::Inductor::mnaAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute<Matrix>::Ptr &leftVector) {
attributeDependencies.push_back(leftVector);
modifiedAttributes.push_back(this->attribute("v_intf"));
modifiedAttributes.push_back(this->attribute("i_intf"));
}
void DP::Ph1::Inductor::MnaPostStep::execute(Real time, Int timeStepCount) {
mInductor.mnaUpdateVoltage(*mLeftVector);
mInductor.mnaUpdateCurrent(*mLeftVector);
void DP::Ph1::Inductor::mnaPostStep(Real time, Int timeStepCount, Attribute<Matrix>::Ptr &leftVector) {
this->mnaUpdateVoltage(*leftVector);
this->mnaUpdateCurrent(*leftVector);
}
void DP::Ph1::Inductor::MnaPreStepHarm::execute(Real time, Int timeStepCount) {
mInductor.mnaApplyRightSideVectorStampHarm(mInductor.mRightVector);
}
void DP::Ph1::Inductor::MnaPostStepHarm::execute(Real time, Int timeStepCount) {
......
......@@ -128,11 +128,6 @@ void DP::Ph1::PiLine::mnaInitialize(Real omega, Real timeStep, Attribute<Matrix>
subComps.push_back(mSubParallelCapacitor0);
subComps.push_back(mSubParallelCapacitor1);
}
for (auto comp : subComps) {
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));
mRightVector = Matrix::Zero(leftVector->get().rows(), 1);
......@@ -157,13 +152,63 @@ void DP::Ph1::PiLine::mnaApplyRightSideVectorStamp(Matrix& rightVector) {
rightVector += *stamp;
}
void DP::Ph1::PiLine::MnaPreStep::execute(Real time, Int timeStepCount) {
mLine.mnaApplyRightSideVectorStamp(mLine.mRightVector);
void DP::Ph1::PiLine::mnaAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) {
// add pre-step dependencies of subcomponents
this->mSubSeriesInductor->mnaAddPreStepDependencies(prevStepDependencies, attributeDependencies, modifiedAttributes);
if (this->mParallelCap >= 0) {
this->mSubParallelCapacitor0->mnaAddPreStepDependencies(prevStepDependencies, attributeDependencies, modifiedAttributes);
this->mSubParallelCapacitor1->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::PiLine::mnaPreStep(Real time, Int timeStepCount) {
// pre-step of subcomponents
this->mSubSeriesInductor->mnaPreStep(time, timeStepCount);
if (this->mParallelCap >= 0) {
this->mSubParallelCapacitor0->mnaPreStep(time, timeStepCount);
this->mSubParallelCapacitor1->mnaPreStep(time, timeStepCount);
}
// pre-step of component itself
this->mnaApplyRightSideVectorStamp(this->mRightVector);
}
void DP::Ph1::PiLine::MnaPostStep::execute(Real time, Int timeStepCount) {
mLine.mnaUpdateVoltage(*mLeftVector);
mLine.mnaUpdateCurrent(*mLeftVector);
void DP::Ph1::PiLine::mnaAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute<Matrix>::Ptr &leftVector) {
// add post-step dependencies of subcomponents
this->mSubSeriesResistor->mnaAddPostStepDependencies(prevStepDependencies, attributeDependencies, modifiedAttributes, leftVector);
this->mSubSeriesInductor->mnaAddPostStepDependencies(prevStepDependencies, attributeDependencies, modifiedAttributes, leftVector);
if (this->mParallelCap >= 0) {
this->mSubParallelCapacitor0->mnaAddPostStepDependencies(prevStepDependencies, attributeDependencies, modifiedAttributes, leftVector);
this->mSubParallelCapacitor1->mnaAddPostStepDependencies(prevStepDependencies, attributeDependencies, modifiedAttributes, leftVector);
}
if (this->mParallelCond >= 0) {
this->mSubParallelResistor0->mnaAddPostStepDependencies(prevStepDependencies, attributeDependencies, modifiedAttributes, leftVector);
this->mSubParallelResistor1->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::PiLine::mnaPostStep(Real time, Int timeStepCount, Attribute<Matrix>::Ptr &leftVector) {
// post-step of subcomponents
this->mSubSeriesResistor->mnaPostStep(time, timeStepCount, leftVector);
this->mSubSeriesInductor->mnaPostStep(time, timeStepCount, leftVector);
if (this->mParallelCap >= 0) {
this->mSubParallelCapacitor0->mnaPostStep(time, timeStepCount, leftVector);
this->mSubParallelCapacitor1->mnaPostStep(time, timeStepCount, leftVector);
}
if (this->mParallelCond >= 0) {
this->mSubParallelResistor0->mnaPostStep(time, timeStepCount, leftVector);
this->mSubParallelResistor1->mnaPostStep(time, timeStepCount, leftVector);
}
// post-step of component itself
this->mnaUpdateVoltage(*leftVector);
this->mnaUpdateCurrent(*leftVector);
}
void DP::Ph1::PiLine::mnaUpdateVoltage(const Matrix& leftVector) {
......
......@@ -114,9 +114,15 @@ void DP::Ph1::Resistor::mnaApplySystemMatrixStampHarm(Matrix& systemMatrix, Int
}
}
void DP::Ph1::Resistor::MnaPostStep::execute(Real time, Int timeStepCount) {
mResistor.mnaUpdateVoltage(*mLeftVector);
mResistor.mnaUpdateCurrent(*mLeftVector);
void DP::Ph1::Resistor::mnaAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute<Matrix>::Ptr &leftVector) {
attributeDependencies.push_back(leftVector);
modifiedAttributes.push_back(this->attribute("v_intf"));
modifiedAttributes.push_back(this->attribute("i_intf"));
}
void DP::Ph1::Resistor::mnaPostStep(Real time, Int timeStepCount, Attribute<Matrix>::Ptr &leftVector) {
this->mnaUpdateVoltage(*leftVector);
this->mnaUpdateCurrent(*leftVector);
}
void DP::Ph1::Resistor::MnaPostStepHarm::execute(Real time, Int timeStepCount) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment