Commit 6910b01f authored by Georg Martin Reinke's avatar Georg Martin Reinke
Browse files

implement getCurrent for IdealVoltageSource

parent 644ca275
...@@ -35,4 +35,8 @@ void IdealVoltageSource::step(SystemModel& system, Real time) { ...@@ -35,4 +35,8 @@ void IdealVoltageSource::step(SystemModel& system, Real time) {
// Apply matrix stamp for equivalent current source // Apply matrix stamp for equivalent current source
system.addRealToRightSideVector(system.getCompOffset() - number, mVoltageDiffr); system.addRealToRightSideVector(system.getCompOffset() - number, mVoltageDiffr);
system.addRealToRightSideVector(2 * system.getCompOffset() - number, mVoltageDiffi); system.addRealToRightSideVector(2 * system.getCompOffset() - number, mVoltageDiffi);
} }
\ No newline at end of file
Complex IdealVoltageSource::getCurrent(SystemModel& system) {
return Complex(system.getRealFromLeftSideVector(system.getCompOffset()-number), system.getRealFromLeftSideVector(2*system.getCompOffset()-number));
}
...@@ -48,6 +48,7 @@ namespace DPsim { ...@@ -48,6 +48,7 @@ namespace DPsim {
void postStep(SystemModel& system) { } void postStep(SystemModel& system) { }
virtual Complex getCurrent(SystemModel& system);
}; };
} }
#endif #endif
...@@ -11,15 +11,14 @@ void DPsim::villasExample() ...@@ -11,15 +11,14 @@ void DPsim::villasExample()
Logger log, llog, rlog; Logger log, llog, rlog;
std::vector<BaseComponent*> comps; std::vector<BaseComponent*> comps;
ExternalCurrentSource *ecs = new ExternalCurrentSource("i1", 1, 0); ExternalVoltageSource *evs = new ExternalVoltageSource("v1", 1, 0, 1);
comps.push_back(ecs); comps.push_back(evs);
comps.push_back(new LinearResistor("r1", 1, 2, 1)); comps.push_back(new LinearResistor("r1", 1, 2, 1));
LinearResistor *r2 = new LinearResistor("r2", 2, 0, 1); LinearResistor *r2 = new LinearResistor("r2", 2, 0, 1);
comps.push_back(r2); comps.push_back(r2);
VillasInterface *villas = new VillasInterface("/villas1"); VillasInterface *villas = new VillasInterface("/villas1");
villas->registerCurrentSource(ecs, 0, 1); villas->registerVoltageSource(evs, 0, 1);
villas->registerExportedVoltage(1, 0, 0, 1); villas->registerExportedCurrent(evs, 0, 1);
villas->registerExportedCurrent(r2, 2, 3);
// Set up simulation // Set up simulation
Real timeStep = 0.01; 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