Commit 644ca275 authored by Georg Martin Reinke's avatar Georg Martin Reinke
Browse files

implement getCurrent for some trivial components

parent 4794b6ef
...@@ -72,3 +72,7 @@ void Capacitor::postStep(SystemModel& system) { ...@@ -72,3 +72,7 @@ void Capacitor::postStep(SystemModel& system) {
currr = mGcr * deltavr - mGci * deltavi - cureqr; currr = mGcr * deltavr - mGci * deltavi - cureqr;
curri = mGci * deltavr + mGcr * deltavi - cureqi; curri = mGci * deltavr + mGcr * deltavi - cureqi;
} }
Complex Capacitor::getCurrent(SystemModel& system) {
return Complex(currr, curri);
}
...@@ -55,6 +55,9 @@ namespace DPsim { ...@@ -55,6 +55,9 @@ namespace DPsim {
/// Recalculates variables detalvr, deltavi, currr and curri based on the simulation results of one time step /// Recalculates variables detalvr, deltavi, currr and curri based on the simulation results of one time step
void postStep(SystemModel& system); void postStep(SystemModel& system);
/// Return current from the previous step
Complex getCurrent(SystemModel& system);
}; };
} }
#endif #endif
\ No newline at end of file
...@@ -19,3 +19,7 @@ void CurrentSource::applyRightSideVectorStamp(SystemModel& system) { ...@@ -19,3 +19,7 @@ void CurrentSource::applyRightSideVectorStamp(SystemModel& system) {
void CurrentSource::step(SystemModel& system, Real time) { void CurrentSource::step(SystemModel& system, Real time) {
this->applyRightSideVectorStamp(system); this->applyRightSideVectorStamp(system);
} }
Complex CurrentSource::getCurrent(SystemModel& system) {
return Complex(currentr, currenti);
}
...@@ -19,6 +19,7 @@ namespace DPsim { ...@@ -19,6 +19,7 @@ namespace DPsim {
void applyRightSideVectorStamp(SystemModel& system); void applyRightSideVectorStamp(SystemModel& system);
void step(SystemModel& system, Real time); void step(SystemModel& system, Real time);
void postStep(SystemModel& system) { } void postStep(SystemModel& system) { }
virtual Complex getCurrent(SystemModel& system);
}; };
} }
#endif #endif
...@@ -80,3 +80,7 @@ void Inductor::postStep(SystemModel& system) { ...@@ -80,3 +80,7 @@ void Inductor::postStep(SystemModel& system) {
mCurrRe = mGlr * mDeltaVre - mGli * mDeltaVim + mCurEqRe; mCurrRe = mGlr * mDeltaVre - mGli * mDeltaVim + mCurEqRe;
mCurrIm = mGli * mDeltaVre + mGlr * mDeltaVim + mCurEqIm; mCurrIm = mGli * mDeltaVre + mGlr * mDeltaVim + mCurEqIm;
} }
Complex Inductor::getCurrent(SystemModel& system) {
return Complex(mCurrRe, mCurrIm);
}
...@@ -60,6 +60,9 @@ namespace DPsim { ...@@ -60,6 +60,9 @@ namespace DPsim {
/// Recalculates variables detalvr, deltavi, currr and curri based on the simulation results of one time step /// Recalculates variables detalvr, deltavi, currr and curri based on the simulation results of one time step
void postStep(SystemModel& system); void postStep(SystemModel& system);
/// Return current from the previous step
Complex getCurrent(SystemModel& system);
}; };
} }
#endif #endif
\ No newline at end of file
...@@ -33,6 +33,5 @@ Complex LinearResistor::getCurrent(SystemModel& model) { ...@@ -33,6 +33,5 @@ Complex LinearResistor::getCurrent(SystemModel& model) {
realVolt -= model.getRealFromLeftSideVector(mNode1); realVolt -= model.getRealFromLeftSideVector(mNode1);
imagVolt -= model.getImagFromLeftSideVector(mNode2); imagVolt -= model.getImagFromLeftSideVector(mNode2);
} }
Complex curr(realVolt*mConductance, imagVolt*mConductance); return Complex(realVolt*mConductance, imagVolt*mConductance);
return curr;
} }
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