Commit 0842582e authored by Markus Mirz's avatar Markus Mirz
Browse files

update circuit examples

parent ed3bb4d2
......@@ -23,6 +23,7 @@ set(CIRCUIT_SOURCES
# EMT examples
Circuits/EMT_VS_R1.cpp
Circuits/EMT_VS_RC1.cpp
Circuits/EMT_CS_R1.cpp
Circuits/EMT_VS_RL1.cpp
Circuits/EMT_CS_R2CL.cpp
......
......@@ -26,6 +26,11 @@ using namespace CPS::DP;
using namespace CPS::DP::Ph1;
int main(int argc, char* argv[]) {
// Define simulation scenario
Real timeStep = 0.0001;
Real finalTime = 0.1;
String simName = "DP_CS_R1";
// Nodes
auto n1 = Node::make("n1");
......@@ -43,12 +48,14 @@ int main(int argc, char* argv[]) {
// Define system topology
auto sys = SystemTopology(50, SystemNodeList{n1}, SystemComponentList{cs, r1});
// Define simulation scenario
Real timeStep = 0.0001;
Real finalTime = 0.1;
String simName = "DP_CS_R_1";
// Logging
auto logger = DataLogger::make(simName);
logger->addAttribute("v1", n1->attribute("voltage"));
logger->addAttribute("i10", r1->attribute("i_intf"));
Simulation sim(simName, sys, timeStep, finalTime);
sim.addLogger(logger);
sim.run();
return 0;
......
......@@ -26,16 +26,26 @@ using namespace CPS::DP;
using namespace CPS::DP::Ph1;
int main(int argc, char* argv[]) {
// Define simulation scenario
Real timeStep = 0.0001;
Real finalTime = 0.1;
String simName = "DP_CS_R2CL";
// Nodes
auto n1 = Node::make("n1");
auto n2 = Node::make("n2");
// Components
auto cs = CurrentSource::make("cs");
cs->setParameters(10);
auto r1 = Resistor::make("r_1");
r1->setParameters(1);
auto c1 = Capacitor::make("c_1");
c1->setParameters(0.001);
auto l1 = Inductor::make("l_1");
l1->setParameters(0.001);
auto r2 = Resistor::make("r_2");
r2->setParameters(1);
// Topology
cs->connect({ Node::GND, n1 });
......@@ -44,21 +54,18 @@ int main(int argc, char* argv[]) {
l1->connect({ n2, Node::GND });
r2->connect({ n2, Node::GND });
cs->setParameters(10);
r1->setParameters(1);
c1->setParameters(0.001);
l1->setParameters(0.001);
r2->setParameters(1);
// Define system topology
auto sys = SystemTopology(50, SystemNodeList{n1, n2}, SystemComponentList{cs, r1, c1, l1, r2});
// Define simulation scenario
Real timeStep = 0.0001;
Real finalTime = 0.1;
String simName = "DP_CS_R2CL";
// Logging
auto logger = DataLogger::make(simName);
logger->addAttribute("v1", n1->attribute("voltage"));
logger->addAttribute("v2", n2->attribute("voltage"));
logger->addAttribute("i10", l1->attribute("i_intf"));
Simulation sim(simName, sys, timeStep, finalTime);
sim.addLogger(logger);
sim.run();
return 0;
......
......@@ -26,6 +26,11 @@ using namespace CPS::DP;
using namespace CPS::DP::Ph1;
int main(int argc, char* argv[]) {
// Define simulation scenario
Real timeStep = 0.0001;
Real finalTime = 0.1;
String simName = "DP_VS_CS_R4";
// Nodes
auto n1 = Node::make("n1");
auto n2 = Node::make("n2");
......@@ -34,33 +39,37 @@ int main(int argc, char* argv[]) {
// Components
auto vs = VoltageSource::make("vs");
vs->setParameters(10);
vs->connect(Node::List{ Node::GND, n1 });
auto r1 = Resistor::make("r_1");
r1->setParameters(1);
r1->connect(Node::List{ n1, n2 });
auto r2 = Resistor::make("r_2", Logger::Level::DEBUG);
r2->setParameters(1);
r2->connect(Node::List{ n2, Node::GND });
auto r3 = Resistor::make("r_3");
r3->setParameters(10);
r3->connect(Node::List{ n2, n3 });
auto r4 = Resistor::make("r_4");
r4->setParameters(5);
r4->connect(Node::List{ n3, Node::GND });
auto cs = CurrentSource::make("cs");
cs->setParameters(1);
cs->connect(Node::List{ Node::GND, n3 });
// Topology
vs->connect(Node::List{ Node::GND, n1 });
r1->connect(Node::List{ n1, n2 });
r2->connect(Node::List{ n2, Node::GND });
r3->connect(Node::List{ n2, n3 });
r4->connect(Node::List{ n3, Node::GND });
cs->connect(Node::List{ Node::GND, n3 });
// Define system topology
auto sys = SystemTopology(50, SystemNodeList{n1, n2, n3}, SystemComponentList{vs, r1, r2, r3, r4, cs});
// Define simulation scenario
Real timeStep = 0.001;
Real finalTime = 0.1;
String simName = "DP_IdealVS_CS_R4_1a";
// Logging
auto logger = DataLogger::make(simName);
logger->addAttribute("v1", n1->attribute("voltage"));
logger->addAttribute("v2", n2->attribute("voltage"));
logger->addAttribute("v3", n3->attribute("voltage"));
Simulation sim(simName, sys, timeStep, finalTime);
sim.addLogger(logger);
sim.run();
return 0;
......
......@@ -26,29 +26,33 @@ using namespace CPS::DP;
using namespace CPS::DP::Ph1;
int main(int argc, char* argv[]) {
// Define simulation scenario
Real timeStep = 0.0001;
Real finalTime = 0.1;
String simName = "DP_VS_R1";
// Nodes
auto n1 = Node::make("n1");
// Components
auto vs = VoltageSource::make("v_1");
vs->setParameters(Complex(10, 0));
auto r = Resistor::make("r_1");
r->setParameters(1);
// Topology
vs->connect({Node::GND, n1});
r->connect({n1, Node::GND});
// Parameters
vs->setParameters(Complex(10, 0));
r->setParameters(1);
auto sys = SystemTopology(50, SystemNodeList{n1}, SystemComponentList{vs, r});
// Define simulation scenario
Real timeStep = 0.00005;
Real finalTime = 0.2;
String simName = "DP_IdealVS_R_1";
// Logging
auto logger = DataLogger::make(simName);
logger->addAttribute("v1", n1->attribute("voltage"));
Simulation sim(simName, sys, timeStep, finalTime);
sim.addLogger(logger);
sim.run();
return 0;
......
......@@ -26,6 +26,11 @@ using namespace CPS::DP;
using namespace CPS::DP::Ph1;
int main(int argc, char* argv[]) {
// Define simulation scenario
Real timeStep = 0.0001;
Real finalTime = 0.1;
String simName = "DP_VS_R2L3";
// Nodes
auto n1 = Node::make("n1");
auto n2 = Node::make("n2");
......@@ -35,31 +40,27 @@ int main(int argc, char* argv[]) {
// Components
auto vs = VoltageSource::make("vs");
vs->setParameters(10);
vs->connect(Node::List{ Node::GND, n1 });
auto r1 = Resistor::make("r_1");
r1->setParameters(1);
r1->connect(Node::List{ n1, n2 });
auto l1 = Inductor::make("l_1");
l1->setParameters(0.02);
l1->connect(Node::List{ n2, n3 });
auto l2 = Inductor::make("l_2");
l2->setParameters(0.1);
l2->connect(Node::List{ n3, Node::GND });
auto l3 = Inductor::make("l_3");
l3->setParameters(0.05);
l3->connect(Node::List{ n3, n4 });
auto r2 = Resistor::make("r_2");
r2->setParameters(2);
// Topology
vs->connect(Node::List{ Node::GND, n1 });
r1->connect(Node::List{ n1, n2 });
l1->connect(Node::List{ n2, n3 });
l2->connect(Node::List{ n3, Node::GND });
l3->connect(Node::List{ n3, n4 });
r2->connect(Node::List{ n4, Node::GND });
// Define system topology
auto sys = SystemTopology(50, SystemNodeList{n1, n2, n3, n4}, SystemComponentList{vs, r1, l1, l2, l3, r2});
// Define simulation scenario
Real timeStep = 0.0001;
Real finalTime = 0.1;
String simName = "DP_IdealVS_R2L3";
// Logging
auto logger = DataLogger::make(simName);
logger->addAttribute("v1", n1->attribute("voltage"));
......
......@@ -26,37 +26,35 @@ using namespace CPS::DP;
using namespace CPS::DP::Ph1;
int main(int argc, char* argv[]) {
// Define simulation scenario
Real timeStep = 0.0001;
Real finalTime = 0.1;
String simName = "DP_VS_RC1";
// Nodes
auto n1 = Node::make("n1");
auto n2 = Node::make("n2");
// Components
auto vs = VoltageSource::make("vs", Logger::Level::DEBUG);
vs->setParameters(Complex(10, 0));
auto r1 = Resistor::make("r_1", Logger::Level::DEBUG);
r1->setParameters(1);
auto c1 = Capacitor::make("c_1", Logger::Level::DEBUG);
c1->setParameters(0.001);
// Topology
vs->connect({ Node::GND, n1 });
r1->connect({ n1, n2 });
c1->connect({ n2, Node::GND });
vs->setParameters(Complex(10, 0));
r1->setParameters(1);
c1->setParameters(0.001);
// Define system topology
auto sys = SystemTopology(50, SystemNodeList{n1, n2}, SystemComponentList{vs, r1, c1});
// Define simulation scenario
Real timeStep = 0.0001;
Real finalTime = 0.1;
String simName = "DP_IdealVS_RC1";
// Logging
auto logger = DataLogger::make(simName);
logger->addAttribute("v1", n1->attribute("voltage"));
logger->addAttribute("v2", n2->attribute("voltage"));
logger->addAttribute("i1", r1->attribute("i_comp"));
logger->addAttribute("i1", r1->attribute("i_intf"));
Simulation sim(simName, sys, timeStep, finalTime);
sim.addLogger(logger);
......
......@@ -26,6 +26,11 @@ using namespace CPS::DP;
using namespace CPS::DP::Ph1;
int main(int argc, char* argv[]) {
// Define simulation scenario
Real timeStep = 0.0001;
Real finalTime = 0.1;
String simName = "DP_VS_RL1";
// Nodes
auto n1 = Node::make("n1");
auto n2 = Node::make("n2");
......@@ -46,16 +51,11 @@ int main(int argc, char* argv[]) {
// Define system topology
auto sys = SystemTopology(50, SystemNodeList{n1, n2}, SystemComponentList{vs, r1, l1});
// Define simulation scenario
Real timeStep = 0.0001;
Real finalTime = 0.1;
String simName = "DP_IdealVS_RL1";
// Logger
auto logger = DataLogger::make(simName);
logger->addAttribute("v1", n1->attribute("voltage"));
logger->addAttribute("v2", n2->attribute("voltage"));
logger->addAttribute("i1", r1->attribute("i_comp"));
logger->addAttribute("i1", r1->attribute("i_intf"));
Simulation sim(simName, sys, timeStep, finalTime);
sim.addLogger(logger);
......
......@@ -26,6 +26,11 @@ using namespace CPS::EMT;
using namespace CPS::EMT::Ph1;
int main(int argc, char* argv[]) {
// Define simulation scenario
Real timeStep = 0.0001;
Real finalTime = 0.1;
String simName = "EMT_CS_R_1";
// Nodes
auto n1 = Node::make("n1");
......@@ -40,12 +45,13 @@ int main(int argc, char* argv[]) {
// Define system topology
auto sys = SystemTopology(50, SystemNodeList{n1}, SystemComponentList{cs, r1});
// Define simulation scenario
Real timeStep = 0.0001;
Real finalTime = 0.1;
String simName = "EMT_CS_R_1";
// Logging
auto logger = DataLogger::make(simName);
logger->addAttribute("v1", n1->attribute("voltage"));
Simulation sim(simName, sys, timeStep, finalTime, Domain::EMT);
sim.addLogger(logger);
sim.run();
return 0;
......
......@@ -26,6 +26,11 @@ using namespace CPS::EMT;
using namespace CPS::EMT::Ph1;
int main(int argc, char* argv[]) {
// Define simulation scenario
Real timeStep = 0.0001;
Real finalTime = 0.1;
String simName = "EMT_CS_R2CL";
// Nodes
auto n1 = Node::make("n1");
auto n2 = Node::make("n2");
......@@ -50,12 +55,14 @@ int main(int argc, char* argv[]) {
// Define system topology
auto sys = SystemTopology(50, SystemNodeList{n1, n2}, SystemComponentList{cs, r1, c1, l1, r2});
// Define simulation scenario
Real timeStep = 0.0001;
Real finalTime = 0.1;
String simName = "EMT_CS_R2CL";
// Logging
auto logger = DataLogger::make(simName);
logger->addAttribute("v1", n1->attribute("voltage"));
logger->addAttribute("v2", n2->attribute("voltage"));
Simulation sim(simName, sys, timeStep, finalTime, Domain::EMT);
sim.addLogger(logger);
sim.run();
return 0;
......
......@@ -26,6 +26,11 @@ using namespace CPS::EMT;
using namespace CPS::EMT::Ph1;
int main(int argc, char* argv[]) {
// Define simulation scenario
Real timeStep = 0.0001;
Real finalTime = 0.1;
String simName = "EMT_VS_CS_R4_AC";
// Nodes
auto n1 = Node::make("n1");
auto n2 = Node::make("n2");
......@@ -33,33 +38,38 @@ int main(int argc, char* argv[]) {
// Components
auto vs = VoltageSource::make("vs");
vs->setParameters(10, 50); // 10 * Complex(cos(phi), sin(phi))
vs->connect(Node::List{ Node::GND, n1 });
vs->setParameters(10, 50);
auto r1 = Resistor::make("r_1");
r1->setParameters(1);
r1->connect(Node::List{ n1, n2 });
auto r2 = Resistor::make("r_2");
r2->setParameters(1);
r2->connect(Node::List{ n2, Node::GND });
auto r3 = Resistor::make("r_3");
r3->setParameters(10);
r3->connect(Node::List{ n2, n3 });
auto r4 = Resistor::make("r_4");
r4->setParameters(5);
r4->connect(Node::List{ n3, Node::GND });
auto cs = CurrentSource::make("cs");
cs->setParameters(1, 50);
// Topology
vs->connect(Node::List{ Node::GND, n1 });
r1->connect(Node::List{ n1, n2 });
r2->connect(Node::List{ n2, Node::GND });
r3->connect(Node::List{ n2, n3 });
r4->connect(Node::List{ n3, Node::GND });
cs->connect(Node::List{ Node::GND, n3 });
// Define system topology
auto sys = SystemTopology(50, SystemNodeList{n1, n2, n3}, SystemComponentList{vs, r1, r2, r3, r4, cs});
// Define simulation scenario
Real timeStep = 0.0001;
Real finalTime = 0.1;
String simName = "EMT_IdealVS_CS_R4_1b";
// Logging
auto logger = DataLogger::make(simName);
logger->addAttribute("v1", n1->attribute("voltage"));
logger->addAttribute("v2", n2->attribute("voltage"));
logger->addAttribute("v3", n3->attribute("voltage"));
Simulation sim(simName, sys, timeStep, finalTime, Domain::EMT);
sim.addLogger(logger);
sim.run();
return 0;
......
......@@ -26,6 +26,11 @@ using namespace CPS::EMT;
using namespace CPS::EMT::Ph1;
int main(int argc, char* argv[]) {
// Define simulation scenario
Real timeStep = 0.001;
Real finalTime = 0.1;
String simName = "EMT_VS_CS_R4_DC";
// Nodes
auto n1 = Node::make("n1");
auto n2 = Node::make("n2");
......@@ -34,32 +39,37 @@ int main(int argc, char* argv[]) {
// Components
auto vs = VoltageSource::make("vs");
vs->setParameters(10);
vs->connect(Node::List{ Node::GND, n1 });
auto r1 = Resistor::make("r_1", Logger::Level::DEBUG);
r1->setParameters(1);
r1->connect(Node::List{ n1, n2 });
auto r2 = Resistor::make("r_2");
r2->setParameters(1);
r2->connect(Node::List{ n2, Node::GND });
auto r3 = Resistor::make("r_3");
r3->setParameters(10);
r3->connect(Node::List{ n2, n3 });
auto r4 = Resistor::make("r_4");
r4->setParameters(5);
r4->connect(Node::List{ n3, Node::GND });
auto cs = CurrentSource::make("cs");
cs->setParameters(1);
// Topology
vs->connect(Node::List{ Node::GND, n1 });
r1->connect(Node::List{ n1, n2 });
r2->connect(Node::List{ n2, Node::GND });
r3->connect(Node::List{ n2, n3 });
r4->connect(Node::List{ n3, Node::GND });
cs->connect(Node::List{ Node::GND, n3 });
// Define system topology
auto sys = SystemTopology(50, SystemNodeList{n1, n2, n3}, SystemComponentList{vs, r1, r2, r3, r4, cs});
// Define simulation scenario
Real timeStep = 0.001;
Real finalTime = 0.1;
String simName = "EMT_IdealVS_CS_R4_1a";
// Logging
auto logger = DataLogger::make(simName);
logger->addAttribute("v1", n1->attribute("voltage"));
logger->addAttribute("v2", n2->attribute("voltage"));
logger->addAttribute("v3", n3->attribute("voltage"));
Simulation sim(simName, sys, timeStep, finalTime, Domain::EMT);
sim.addLogger(logger);
sim.run();
return 0;
......
......@@ -27,6 +27,11 @@ using namespace CPS::EMT;
using namespace CPS::EMT::Ph1;
int main(int argc, char* argv[]) {
// Define simulation scenario
Real timeStep = 0.0001;
Real finalTime = 0.1;
String simName = "EMT_VS_R1";
// Nodes
auto n1 = Node::make("n1");
auto n2 = Node::make("n2");
......@@ -34,9 +39,13 @@ int main(int argc, char* argv[]) {
// Components
auto vin = VoltageSource::make("v_in");
vin->setParameters(10);
auto r1 = Resistor::make("r_1");
r1->setParameters(5);
auto r2 = Resistor::make("r_2");
r2->setParameters(10);
auto r3 = Resistor::make("r_3");
r3->setParameters(2);
// Topology
vin->connect({ n1, n2 });
......@@ -44,21 +53,18 @@ int main(int argc, char* argv[]) {
r2->connect({ n2, Node::GND });
r3->connect({ n2, Node::GND });
// Parameters
vin->setParameters(10);
r1->setParameters(5);
r2->setParameters(10);
r3->setParameters(2);
// Define system topology
SystemTopology system(50, SystemNodeList{n1, n2, n3, Node::GND}, SystemComponentList{vin, r1, r2, r3});
// Define simulation scenario
Real timeStep = 0.00005;
Real finalTime = 0.2;
String simName = "EMT_VS_R1";
// Logging
auto logger = DataLogger::make(simName);
logger->addAttribute("v1", n1->attribute("voltage"));
logger->addAttribute("v2", n2->attribute("voltage"));
logger->addAttribute("v3", n3->attribute("voltage"));
Simulation sim(simName, system, timeStep, finalTime, Domain::EMT);
sim.addLogger(logger);
sim.run();
return 0;
......
......@@ -26,6 +26,11 @@ using namespace CPS::EMT;
using namespace CPS::EMT::Ph1;
int main(int argc, char* argv[]) {
// Define simulation scenario
Real timeStep = 0.00001;
Real finalTime = 0.1;
String simName = "EMT_VS_R2L3";
// Nodes
auto n1 = Node::make("n1");
auto n2 = Node::make("n2");
......@@ -35,31 +40,28 @@ int main(int argc, char* argv[]) {
// Components
auto vs = VoltageSource::make("vs", Logger::Level::DEBUG);
vs->setParameters(10, 50);
vs->connect(Node::List{ Node::GND, n1 });
auto r1 = Resistor::make("r_1", Logger::Level::DEBUG);
r1->setParameters(1);
r1->connect(Node::List{ n1, n2 });
auto l1 = Inductor::make("l_1", Logger::Level::DEBUG);
l1->setParameters(0.02);
l1->connect(Node::List{ n2, n3 });
auto l2 = Inductor::make("l_2", Logger::Level::DEBUG);
l2->setParameters(0.1);
l2->connect(Node::List{ n3, Node::GND });