DP_VS_R1.cpp 1.65 KB
Newer Older
Markus Mirz's avatar
Markus Mirz committed
1
2
3
/** Reference Circuits
 *
 * @author Markus Mirz <mmirz@eonerc.rwth-aachen.de>
4
 * @copyright 2017-2018, Institute for Automation of Complex Power Systems, EONERC
Markus Mirz's avatar
Markus Mirz committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 *
 * DPsim
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *********************************************************************************/

22
#include <DPsim.h>
Markus Mirz's avatar
Markus Mirz committed
23
24

using namespace DPsim;
Steffen Vogel's avatar
Steffen Vogel committed
25
using namespace CPS::DP;
26
using namespace CPS::DP::Ph1;
Markus Mirz's avatar
Markus Mirz committed
27

28
int main(int argc, char* argv[]) {
Markus Mirz's avatar
Markus Mirz committed
29
30
31
32
33
	// Define simulation scenario
	Real timeStep = 0.0001;
	Real finalTime = 0.1;
	String simName = "DP_VS_R1";

34
35
36
37
	// Nodes
	auto n1 = Node::make("n1");

	// Components
Steffen Vogel's avatar
Steffen Vogel committed
38
	auto vs = VoltageSource::make("v_1");
Markus Mirz's avatar
Markus Mirz committed
39
	vs->setParameters(Complex(10, 0));
Steffen Vogel's avatar
Steffen Vogel committed
40
	auto r = Resistor::make("r_1");
Markus Mirz's avatar
Markus Mirz committed
41
	r->setParameters(1);
42

Steffen Vogel's avatar
Steffen Vogel committed
43
44
45
46
47
	// Topology
	vs->connect({Node::GND, n1});
	r->connect({n1, Node::GND});

	auto sys = SystemTopology(50, SystemNodeList{n1}, SystemComponentList{vs, r});
Markus Mirz's avatar
Markus Mirz committed
48

Markus Mirz's avatar
Markus Mirz committed
49
50
51
	// Logging
	auto logger = DataLogger::make(simName);
	logger->addAttribute("v1", n1->attribute("voltage"));
Steffen Vogel's avatar
Steffen Vogel committed
52

53
	Simulation sim(simName, sys, timeStep, finalTime);
Markus Mirz's avatar
Markus Mirz committed
54
55
	sim.addLogger(logger);

56
	sim.run();
Markus Mirz's avatar
Markus Mirz committed
57

Steffen Vogel's avatar
Steffen Vogel committed
58
59
	return 0;
}