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

add test for comparing operation with/without VILLAS interface


Former-commit-id: 81e9061b
parent 3ae462d2
......@@ -15,6 +15,7 @@ int main(int argc, char* argv[]) {
//villasExample();
villasDistributedExample(argc, argv);
//villasDistributedRef();
//simulationExample1();
//simulationExample2();
//simulationExample3();
......
......@@ -46,7 +46,7 @@ void DPsim::villasExample()
void DPsim::villasDistributedExample(int argc, char *argv[])
{
// Testing the interface with the same circuit as above,
// Testing the interface with a simple circuit,
// but the load is simulated in a different instance.
// Values are exchanged using the ideal transformator model: an ideal
// current source on the supply side and an ideal voltage source on the
......@@ -62,21 +62,19 @@ void DPsim::villasDistributedExample(int argc, char *argv[])
if (!strcmp(argv[1], "0")) {
comps.push_back(new VoltSourceRes("v_s", 1, 0, 10000, 0, 1));
comps.push_back(new LinearResistor("r_line", 1, 2, 1));
comps.push_back(new Inductor("l_line", 2, 3, 1));
ExternalCurrentSource *ecs = new ExternalCurrentSource("i_s", 1, 0, 0, 0);
comps.push_back(ecs);
villas = new VillasInterface("/villas0");
villas->registerCurrentSource(ecs, 0, 1);
villas->registerExportedVoltage(1, 0, 0, 1);
} else if (!strcmp(argv[1], "1")) {
ExternalVoltageSource *evs = new ExternalVoltageSource("v_s", 1, 0, 0, 0, 1);
comps.push_back(new Inductor("l_1", 1, 2, 1e-3));
ExternalVoltageSource *evs = new ExternalVoltageSource("v_t", 2, 0, 0, 0, 1);
comps.push_back(evs);
comps.push_back(new LinearResistor("r_load", 1, 2, 100));
comps.push_back(new Inductor("l_load", 2, 0, 0.1));
villas = new VillasInterface("/villas1");
villas = new VillasInterface("/villas0");
villas->registerVoltageSource(evs, 0, 1);
villas->registerExportedCurrent(evs, 0, 1);
} else if (!strcmp(argv[1], "1")) {
ExternalCurrentSource *ecs = new ExternalCurrentSource("v_s", 1, 0, 0, 0);
comps.push_back(ecs);
comps.push_back(new LinearResistor("r_2", 1, 0, 1));
villas = new VillasInterface("/villas1");
villas->registerCurrentSource(ecs, 0, 1);
villas->registerExportedVoltage(1, 0, 0, 1);
} else {
std::cerr << "invalid test number" << std::endl;
std::exit(1);
......@@ -103,3 +101,33 @@ void DPsim::villasDistributedExample(int argc, char *argv[])
}
delete villas;
}
void DPsim::villasDistributedRef()
{
// Same circuit as above, but the simulation is done normally in one instance.
Logger log, llog, rlog;
std::vector<BaseComponent*> comps;
comps.push_back(new VoltSourceRes("v_s", 1, 0, 10000, 0, 1));
comps.push_back(new Inductor("l_1", 1, 2, 1e-3));
comps.push_back(new LinearResistor("r_2", 2, 0, 1));
// Set up simulation
Real timeStep = 0.001;
Simulation newSim(comps, 2.0*M_PI*50.0, timeStep, 0.3, log);
// Main Simulation Loop
std::cout << "Start simulation." << std::endl;
while (newSim.step(log, llog, rlog))
{
newSim.increaseByTimeStep();
updateProgressBar(newSim.getTime(), newSim.getFinalTime());
}
std::cout << "Simulation finished." << std::endl;
log.WriteLogToFile("output.log");
rlog.WriteLogToFile("rvector.log");
llog.WriteLogToFile("lvector.log");
for (auto comp : comps) {
delete comp;
}
}
......@@ -5,6 +5,7 @@ namespace DPsim {
void villasExample();
void villasDistributedExample(int argc, char *argv[]);
void villasDistributedRef();
}
#endif
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