Commit e5f20993 authored by Georg Martin Reinke's avatar Georg Martin Reinke
Browse files

implement getCurrent for LinearResistor


Former-commit-id: 4794b6ef
parent 32b024bf
......@@ -23,5 +23,16 @@ void LinearResistor::applySystemMatrixStamp(SystemModel& system) {
}
}
Complex LinearResistor::getCurrent(SystemModel& model) {
Real realVolt = 0, imagVolt = 0;
if (mNode1 >= 0) {
realVolt += model.getRealFromLeftSideVector(mNode1);
imagVolt += model.getImagFromLeftSideVector(mNode2);
}
if (mNode2 >= 0) {
realVolt -= model.getRealFromLeftSideVector(mNode1);
imagVolt -= model.getImagFromLeftSideVector(mNode2);
}
Complex curr(realVolt*mConductance, imagVolt*mConductance);
return curr;
}
......@@ -36,6 +36,7 @@ namespace DPsim {
void applyRightSideVectorStamp(SystemModel& system) { }
void step(SystemModel& system, Real time) { }
void postStep(SystemModel& system) { }
Complex getCurrent(SystemModel& model);
};
}
#endif
......@@ -14,10 +14,12 @@ void DPsim::villasExample()
ExternalCurrentSource *ecs = new ExternalCurrentSource("i1", 1, 0);
comps.push_back(ecs);
comps.push_back(new LinearResistor("r1", 1, 2, 1));
comps.push_back(new LinearResistor("r2", 2, 0, 1));
LinearResistor *r2 = new LinearResistor("r2", 2, 0, 1);
comps.push_back(r2);
VillasInterface *villas = new VillasInterface("/villas1");
villas->registerCurrentSource(ecs, 0, 1);
villas->registerExportedVoltage(1, 2, 0, 1);
villas->registerExportedVoltage(1, 0, 0, 1);
villas->registerExportedCurrent(r2, 2, 3);
// Set up simulation
Real timeStep = 0.01;
......
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