DPsim
Loading...
Searching...
No Matches
EMTComponents.cpp
1/* Copyright 2017-2021 Institute for Automation of Complex Power Systems,
2 * EONERC, RWTH Aachen University
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7 *********************************************************************************/
8
9#include <DPsim.h>
10#include <dpsim-models/CSVReader.h>
11#include <dpsim-models/IdentifiedObject.h>
12#include <dpsim/RealTimeSimulation.h>
13#include <dpsim/Simulation.h>
14#include <dpsim/pybind/EMTComponents.h>
15#include <dpsim/pybind/Utils.h>
16
17#ifdef WITH_JSON
18#include <nlohmann/json.hpp>
19using json = nlohmann::json;
20#endif
21
22namespace py = pybind11;
23using namespace pybind11::literals;
24
25void addEMTComponents(py::module_ mEMT) {
26 py::class_<CPS::EMT::SimNode, std::shared_ptr<CPS::EMT::SimNode>,
27 CPS::TopologicalNode>(mEMT, "SimNode", py::module_local())
28 .def(py::init<std::string>())
29 .def(py::init<std::string, CPS::PhaseType>())
30 .def(py::init<std::string, CPS::PhaseType,
31 const std::vector<CPS::Complex>>())
32 .def("set_initial_voltage",
33 py::overload_cast<CPS::MatrixComp>(
34 &CPS::EMT::SimNode::setInitialVoltage, py::const_))
35 .def("set_initial_voltage",
36 py::overload_cast<CPS::Complex>(
37 &CPS::EMT::SimNode::setInitialVoltage, py::const_))
38 .def("set_initial_voltage",
39 py::overload_cast<CPS::Complex, int>(
40 &CPS::EMT::SimNode::setInitialVoltage, py::const_))
41 .def_readonly_static("gnd", &CPS::EMT::SimNode::GND);
42
43 py::module mEMTPh1 = mEMT.def_submodule(
44 "ph1", "single phase electromagnetic-transient models");
45 addEMTPh1Components(mEMTPh1);
46 py::module mEMTPh3 =
47 mEMT.def_submodule("ph3", "three phase electromagnetic-transient models");
48 addEMTPh3Components(mEMTPh3);
49}
50
51void addEMTPh1Components(py::module_ mEMTPh1) {
53 std::shared_ptr<CPS::EMT::Ph1::CurrentSource>,
54 CPS::SimPowerComp<CPS::Real>>(mEMTPh1, "CurrentSource",
55 py::multiple_inheritance())
56 .def(py::init<std::string>())
57 .def(py::init<std::string, CPS::Logger::Level>())
58 .def("set_parameters", &CPS::EMT::Ph1::CurrentSource::setParameters,
59 "I_ref"_a, "f_src"_a = -1)
61 .def_property("I_ref", createAttributeGetter<CPS::Complex>("I_ref"),
62 createAttributeSetter<CPS::Complex>("I_ref"))
63 .def_property("f_src", createAttributeGetter<CPS::Real>("f_src"),
64 createAttributeSetter<CPS::Real>("f_src"));
65
67 std::shared_ptr<CPS::EMT::Ph1::VoltageSource>,
68 CPS::SimPowerComp<CPS::Real>>(mEMTPh1, "VoltageSource",
69 py::multiple_inheritance())
70 .def(py::init<std::string>())
71 .def(py::init<std::string, CPS::Logger::Level>())
72 .def("set_parameters", &CPS::EMT::Ph1::VoltageSource::setParameters,
73 "V_ref"_a, "f_src"_a = -1)
75 .def_property("V_ref", createAttributeGetter<CPS::Complex>("V_ref"),
76 createAttributeSetter<CPS::Complex>("V_ref"))
77 .def_property("f_src", createAttributeGetter<CPS::Real>("f_src"),
78 createAttributeSetter<CPS::Real>("f_src"));
79
80 py::class_<CPS::EMT::Ph1::Resistor, std::shared_ptr<CPS::EMT::Ph1::Resistor>,
81 CPS::SimPowerComp<CPS::Real>>(mEMTPh1, "Resistor",
82 py::multiple_inheritance())
83 .def(py::init<std::string>())
84 .def(py::init<std::string, CPS::Logger::Level>())
85 .def("set_parameters", &CPS::EMT::Ph1::Resistor::setParameters, "R"_a)
86 .def("connect", &CPS::EMT::Ph1::Resistor::connect)
87 .def_property("R", createAttributeGetter<CPS::Real>("R"),
88 createAttributeSetter<CPS::Real>("R"));
89
90 py::class_<CPS::EMT::Ph1::Capacitor,
91 std::shared_ptr<CPS::EMT::Ph1::Capacitor>,
92 CPS::SimPowerComp<CPS::Real>>(mEMTPh1, "Capacitor",
93 py::multiple_inheritance())
94 .def(py::init<std::string>())
95 .def(py::init<std::string, CPS::Logger::Level>())
96 .def("set_parameters", &CPS::EMT::Ph1::Capacitor::setParameters, "C"_a)
97 .def("connect", &CPS::EMT::Ph1::Capacitor::connect)
98 .def_property("C", createAttributeGetter<CPS::Real>("C"),
99 createAttributeSetter<CPS::Real>("C"));
100
101 py::class_<CPS::EMT::Ph1::Inductor, std::shared_ptr<CPS::EMT::Ph1::Inductor>,
102 CPS::SimPowerComp<CPS::Real>>(mEMTPh1, "Inductor",
103 py::multiple_inheritance())
104 .def(py::init<std::string>())
105 .def(py::init<std::string, CPS::Logger::Level>())
106 .def("set_parameters", &CPS::EMT::Ph1::Inductor::setParameters, "L"_a)
107 .def("connect", &CPS::EMT::Ph1::Inductor::connect)
108 .def_property("L", createAttributeGetter<CPS::Real>("L"),
109 createAttributeSetter<CPS::Real>("L"));
110
111 py::class_<CPS::EMT::Ph1::Switch, std::shared_ptr<CPS::EMT::Ph1::Switch>,
113 mEMTPh1, "Switch", py::multiple_inheritance())
114 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
115 "loglevel"_a = CPS::Logger::Level::off)
116 .def("set_parameters", &CPS::EMT::Ph1::Switch::setParameters,
117 "open_resistance"_a, "closed_resistance"_a,
118 "closed"_a = false) // cppcheck-suppress assignBoolToPointer
119 .def("open", &CPS::EMT::Ph1::Switch::open)
120 .def("close", &CPS::EMT::Ph1::Switch::close)
121 .def("connect", &CPS::EMT::Ph1::Switch::connect);
122
124 std::shared_ptr<CPS::EMT::Ph1::SSN::Full_Serial_RLC>,
125 CPS::SimPowerComp<CPS::Real>>(mEMTPh1, "Full_Serial_RLC",
126 py::multiple_inheritance())
127 .def(py::init<std::string>())
128 .def(py::init<std::string, CPS::Logger::Level>())
129 .def("set_parameters",
130 &CPS::EMT::Ph1::SSN::Full_Serial_RLC::setParameters, "R"_a, "L"_a,
131 "C"_a)
133 .def_property("R", createAttributeGetter<CPS::Real>("R"),
134 createAttributeSetter<CPS::Real>("R"))
135 .def_property("L", createAttributeGetter<CPS::Real>("L"),
136 createAttributeSetter<CPS::Real>("L"))
137 .def_property("C", createAttributeGetter<CPS::Real>("C"),
138 createAttributeSetter<CPS::Real>("C"));
139
140 py::class_<CPS::EMT::Ph1::SSNTypeI2T,
141 std::shared_ptr<CPS::EMT::Ph1::SSNTypeI2T>,
142 CPS::SimPowerComp<CPS::Real>>(mEMTPh1, "SSNTypeI2T",
143 py::multiple_inheritance())
144 .def(py::init<std::string>())
145 .def(py::init<std::string, CPS::Logger::Level>())
146 .def("set_parameters", &CPS::EMT::Ph1::SSNTypeI2T::setParameters, "A"_a,
147 "B"_a, "C"_a, "D"_a)
148 .def("manual_init", &CPS::EMT::Ph1::SSNTypeI2T::manualInit,
149 "initialState"_a, "initialInput"_a, "initialOldInput"_a,
150 "initCurr"_a, "initVol"_a)
151 .def("connect", &CPS::EMT::Ph1::SSNTypeI2T::connect)
152 .def_property("mA", createAttributeGetter<CPS::Matrix>("mA"),
153 createAttributeSetter<CPS::Matrix>("mA"))
154 .def_property("mB", createAttributeGetter<CPS::Matrix>("mB"),
155 createAttributeSetter<CPS::Matrix>("mB"))
156 .def_property("mC", createAttributeGetter<CPS::Matrix>("mC"),
157 createAttributeSetter<CPS::Matrix>("mC"))
158 .def_property("mD", createAttributeGetter<CPS::Matrix>("mD"),
159 createAttributeSetter<CPS::Matrix>("mD"))
160 .def_property("mdA", createAttributeGetter<CPS::Matrix>("mdA"),
161 createAttributeSetter<CPS::Matrix>("mdA"))
162 .def_property("mdB", createAttributeGetter<CPS::Matrix>("mdB"),
163 createAttributeSetter<CPS::Matrix>("mdB"))
164 .def_property("mdC", createAttributeGetter<CPS::Matrix>("mdC"),
165 createAttributeSetter<CPS::Matrix>("mdC"));
166
167 py::class_<CPS::EMT::Ph1::SSNTypeV2T,
168 std::shared_ptr<CPS::EMT::Ph1::SSNTypeV2T>,
169 CPS::SimPowerComp<CPS::Real>>(mEMTPh1, "SSNTypeV2T",
170 py::multiple_inheritance())
171 .def(py::init<std::string>())
172 .def(py::init<std::string, CPS::Logger::Level>())
173 .def("set_parameters", &CPS::EMT::Ph1::SSNTypeV2T::setParameters, "A"_a,
174 "B"_a, "C"_a, "D"_a)
175 .def("manual_init", &CPS::EMT::Ph1::SSNTypeV2T::manualInit,
176 "initialState"_a, "initialInput"_a, "initialOldInput"_a,
177 "initCurr"_a, "initVol"_a)
178 .def("connect", &CPS::EMT::Ph1::SSNTypeV2T::connect)
179 .def_property("mA", createAttributeGetter<CPS::Matrix>("mA"),
180 createAttributeSetter<CPS::Matrix>("mA"))
181 .def_property("mB", createAttributeGetter<CPS::Matrix>("mB"),
182 createAttributeSetter<CPS::Matrix>("mB"))
183 .def_property("mC", createAttributeGetter<CPS::Matrix>("mC"),
184 createAttributeSetter<CPS::Matrix>("mC"))
185 .def_property("mD", createAttributeGetter<CPS::Matrix>("mD"),
186 createAttributeSetter<CPS::Matrix>("mD"))
187 .def_property("mdA", createAttributeGetter<CPS::Matrix>("mdA"),
188 createAttributeSetter<CPS::Matrix>("mdA"))
189 .def_property("mdB", createAttributeGetter<CPS::Matrix>("mdB"),
190 createAttributeSetter<CPS::Matrix>("mdB"))
191 .def_property("mdC", createAttributeGetter<CPS::Matrix>("mdC"),
192 createAttributeSetter<CPS::Matrix>("mdC"));
193}
194
195void addEMTPh3Components(py::module_ mEMTPh3) {
197 std::shared_ptr<CPS::EMT::Ph3::VoltageSource>,
198 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "VoltageSource",
199 py::multiple_inheritance())
200 .def(py::init<std::string>())
201 .def(py::init<std::string, CPS::Logger::Level>())
202 .def("set_parameters",
203 py::overload_cast<CPS::MatrixComp, CPS::Real>(
205 "V_ref"_a, "f_src"_a = 50)
207 .def_property("V_ref", createAttributeGetter<CPS::MatrixComp>("V_ref"),
208 createAttributeSetter<CPS::MatrixComp>("V_ref"))
209 .def_property("f_src", createAttributeGetter<CPS::Real>("f_src"),
210 createAttributeSetter<CPS::Real>("f_src"));
211
213 std::shared_ptr<CPS::EMT::Ph3::ControlledVoltageSource>,
214 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "ControlledVoltageSource",
215 py::multiple_inheritance())
216 .def(py::init<std::string>())
217 .def(py::init<std::string, CPS::Logger::Level>())
218 .def("set_parameters",
219 py::overload_cast<CPS::Matrix>(
221 "V_ref"_a)
223 .def_property("V_ref", createAttributeGetter<CPS::MatrixComp>("V_ref"),
224 createAttributeSetter<CPS::MatrixComp>("V_ref"));
225
227 std::shared_ptr<CPS::EMT::Ph3::CurrentSource>,
228 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "CurrentSource",
229 py::multiple_inheritance())
230 .def(py::init<std::string>())
231 .def(py::init<std::string, CPS::Logger::Level>())
232 .def("set_parameters",
233 py::overload_cast<CPS::MatrixComp, CPS::Real>(
235 "I_ref"_a, "f_src"_a = 50)
237 .def_property("I_ref", createAttributeGetter<CPS::MatrixComp>("I_ref"),
238 createAttributeSetter<CPS::MatrixComp>("V_ref"))
239 .def_property("f_src", createAttributeGetter<CPS::Real>("f_src"),
240 createAttributeSetter<CPS::Real>("f_src"));
241
242 py::class_<CPS::EMT::Ph3::Resistor, std::shared_ptr<CPS::EMT::Ph3::Resistor>,
243 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "Resistor",
244 py::multiple_inheritance())
245 .def(py::init<std::string>())
246 .def(py::init<std::string, CPS::Logger::Level>())
247 .def("set_parameters", &CPS::EMT::Ph3::Resistor::setParameters, "R"_a)
248 .def("connect", &CPS::EMT::Ph3::Resistor::connect);
249
250 py::class_<CPS::EMT::Ph3::Capacitor,
251 std::shared_ptr<CPS::EMT::Ph3::Capacitor>,
252 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "Capacitor",
253 py::multiple_inheritance())
254 .def(py::init<std::string>())
255 .def(py::init<std::string, CPS::Logger::Level>())
256 .def("set_parameters", &CPS::EMT::Ph3::Capacitor::setParameters, "C"_a)
257 .def("connect", &CPS::EMT::Ph3::Capacitor::connect);
258
259 py::class_<CPS::EMT::Ph3::Inductor, std::shared_ptr<CPS::EMT::Ph3::Inductor>,
260 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "Inductor",
261 py::multiple_inheritance())
262 .def(py::init<std::string>())
263 .def(py::init<std::string, CPS::Logger::Level>())
264 .def("set_parameters", &CPS::EMT::Ph3::Inductor::setParameters, "L"_a)
265 .def("connect", &CPS::EMT::Ph3::Inductor::connect);
266
268 std::shared_ptr<CPS::EMT::Ph3::NetworkInjection>,
269 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "NetworkInjection",
270 py::multiple_inheritance())
271 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
272 "loglevel"_a = CPS::Logger::Level::off)
273 .def("set_parameters",
274 py::overload_cast<CPS::MatrixComp, CPS::Real>(
276 "V_ref"_a, "f_src"_a = 50)
278
279 py::class_<CPS::EMT::Ph3::PiLine, std::shared_ptr<CPS::EMT::Ph3::PiLine>,
280 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "PiLine",
281 py::multiple_inheritance())
282 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
283 "loglevel"_a = CPS::Logger::Level::off)
284 .def("set_parameters", &CPS::EMT::Ph3::PiLine::setParameters,
285 "series_resistance"_a, "series_inductance"_a,
286 "parallel_capacitance"_a = zeroMatrix(3),
287 "parallel_conductance"_a = zeroMatrix(3))
288 .def("connect", &CPS::EMT::Ph3::PiLine::connect);
289
290 py::class_<CPS::EMT::Ph3::RXLoad, std::shared_ptr<CPS::EMT::Ph3::RXLoad>,
291 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "RXLoad",
292 py::multiple_inheritance())
293 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
294 "loglevel"_a = CPS::Logger::Level::off)
295 .def("set_parameters", &CPS::EMT::Ph3::RXLoad::setParameters,
296 "active_power"_a, "reactive_power"_a, "volt"_a,
297 // cppcheck-suppress assignBoolToPointer
298 "reactance_in_series"_a = false)
299 .def("connect", &CPS::EMT::Ph3::RXLoad::connect);
300
301 py::class_<CPS::EMT::Ph3::Switch, std::shared_ptr<CPS::EMT::Ph3::Switch>,
303 mEMTPh3, "Switch", py::multiple_inheritance())
304 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
305 "loglevel"_a = CPS::Logger::Level::off)
306 .def("set_parameters", &CPS::EMT::Ph3::Switch::setParameters,
307 "open_resistance"_a, "closed_resistance"_a,
308 // cppcheck-suppress assignBoolToPointer
309 "closed"_a = false)
310 .def("open", &CPS::EMT::Ph3::Switch::openSwitch)
311 .def("close", &CPS::EMT::Ph3::Switch::closeSwitch)
312 .def("connect", &CPS::EMT::Ph3::Switch::connect);
313
315 std::shared_ptr<CPS::EMT::Ph3::SynchronGeneratorDQTrapez>,
316 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "SynchronGeneratorDQTrapez",
317 py::multiple_inheritance())
318 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
319 "loglevel"_a = CPS::Logger::Level::off)
320 .def("set_parameters_operational_per_unit",
322 setParametersOperationalPerUnit,
323 "nom_power"_a, "nom_volt"_a, "nom_freq"_a, "pole_number"_a,
324 "nom_field_cur"_a, "Rs"_a, "Ld"_a, "Lq"_a, "Ld_t"_a, "Lq_t"_a,
325 "Ld_s"_a, "Lq_s"_a, "Ll"_a, "Td0_t"_a, "Tq0_t"_a, "Td0_s"_a,
326 "Tq0_s"_a, "inertia"_a)
327 .def("set_parameters_fundamental_per_unit",
329 setParametersFundamentalPerUnit,
330 "nom_power"_a, "nom_volt"_a, "nom_freq"_a, "pole_number"_a,
331 "nom_field_cur"_a, "Rs"_a, "Ll"_a, "Lmd"_a, "Lmq"_a, "Rfd"_a,
332 "Llfd"_a, "Rkd"_a, "Llkd"_a, "Rkq1"_a, "Llkq1"_a, "Rkq2"_a,
333 "Llkq2"_a, "inertia"_a, "init_active_power"_a,
334 "init_reactive_power"_a, "init_terminal_volt"_a, "init_volt_angle"_a,
335 "init_mech_power"_a)
336#ifdef WITH_JSON
337 .def("apply_parameters_from_json",
338 [](std::shared_ptr<CPS::EMT::Ph3::SynchronGeneratorDQTrapez> syngen,
339 const CPS::String json) {
340 DPsim::Utils::applySynchronousGeneratorParametersFromJson(
341 json::parse(json), syngen);
342 })
343#endif
344 .def("set_initial_values",
345 &CPS::EMT::Ph3::SynchronGeneratorDQTrapez::setInitialValues,
346 "init_active_power"_a, "init_reactive_power"_a,
347 "init_terminal_volt"_a, "init_volt_angle"_a, "init_mech_power"_a);
348
350 std::shared_ptr<CPS::EMT::Ph3::ReducedOrderSynchronGeneratorVBR>,
352 mEMTPh3, "ReducedOrderSynchronGeneratorVBR", py::multiple_inheritance());
353
355 std::shared_ptr<CPS::EMT::Ph3::SynchronGenerator3OrderVBR>,
357 mEMTPh3, "SynchronGenerator3OrderVBR", py::multiple_inheritance())
358 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
359 "loglevel"_a = CPS::Logger::Level::off)
360 .def("set_operational_parameters_per_unit",
361 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
362 CPS::Real, CPS::Real, CPS::Real, CPS::Real,
363 CPS::Real>(
365 setOperationalParametersPerUnit),
366 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
367 "Lq"_a, "L0"_a, "Ld_t"_a, "Td0_t"_a)
369
371 std::shared_ptr<CPS::EMT::Ph3::SynchronGenerator4OrderVBR>,
373 mEMTPh3, "SynchronGenerator4OrderVBR", py::multiple_inheritance())
374 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
375 "loglevel"_a = CPS::Logger::Level::off)
376 .def("set_operational_parameters_per_unit",
377 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
378 CPS::Real, CPS::Real, CPS::Real, CPS::Real,
379 CPS::Real, CPS::Real, CPS::Real>(
381 setOperationalParametersPerUnit),
382 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
383 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a)
385
387 std::shared_ptr<CPS::EMT::Ph3::SynchronGenerator5OrderVBR>,
389 mEMTPh3, "SynchronGenerator5OrderVBR", py::multiple_inheritance())
390 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
391 "loglevel"_a = CPS::Logger::Level::off)
392 .def("set_operational_parameters_per_unit",
393 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
394 CPS::Real, CPS::Real, CPS::Real, CPS::Real,
395 CPS::Real, CPS::Real, CPS::Real, CPS::Real,
396 CPS::Real, CPS::Real, CPS::Real, CPS::Real>(
398 setOperationalParametersPerUnit),
399 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
400 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a, "Ld_s"_a,
401 "Lq_s"_a, "Td0_s"_a, "Tq0_s"_a, "Taa"_a)
403
405 std::shared_ptr<CPS::EMT::Ph3::SynchronGenerator6aOrderVBR>,
407 mEMTPh3, "SynchronGenerator6aOrderVBR", py::multiple_inheritance())
408 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
409 "loglevel"_a = CPS::Logger::Level::off)
410 .def("set_operational_parameters_per_unit",
411 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
412 CPS::Real, CPS::Real, CPS::Real, CPS::Real,
413 CPS::Real, CPS::Real, CPS::Real, CPS::Real,
414 CPS::Real, CPS::Real, CPS::Real, CPS::Real>(
416 setOperationalParametersPerUnit),
417 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
418 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a, "Ld_s"_a,
419 "Lq_s"_a, "Td0_s"_a, "Tq0_s"_a, "Taa"_a)
421
423 std::shared_ptr<CPS::EMT::Ph3::SynchronGenerator6bOrderVBR>,
425 mEMTPh3, "SynchronGenerator6bOrderVBR", py::multiple_inheritance())
426 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
427 "loglevel"_a = CPS::Logger::Level::off)
428 .def("set_operational_parameters_per_unit",
429 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
430 CPS::Real, CPS::Real, CPS::Real, CPS::Real,
431 CPS::Real, CPS::Real, CPS::Real, CPS::Real,
432 CPS::Real, CPS::Real, CPS::Real, CPS::Real>(
434 setOperationalParametersPerUnit),
435 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
436 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a, "Ld_s"_a,
437 "Lq_s"_a, "Td0_s"_a, "Tq0_s"_a, "Taa"_a = 0)
439
440#ifdef WITH_SUNDIALS
441
443 std::shared_ptr<CPS::EMT::Ph3::SynchronGeneratorDQODE>,
444 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "SynchronGeneratorDQODE",
445 py::multiple_inheritance())
446 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
447 "loglevel"_a = CPS::Logger::Level::off)
448 .def("set_parameters_operational_per_unit",
450 setParametersOperationalPerUnit,
451 "nom_power"_a, "nom_volt"_a, "nom_freq"_a, "pole_number"_a,
452 "nom_field_cur"_a, "Rs"_a, "Ld"_a, "Lq"_a, "Ld_t"_a, "Lq_t"_a,
453 "Ld_s"_a, "Lq_s"_a, "Ll"_a, "Td0_t"_a, "Tq0_t"_a, "Td0_s"_a,
454 "Tq0_s"_a, "inertia"_a)
455 .def("set_parameters_fundamental_per_unit",
457 setParametersFundamentalPerUnit,
458 "nom_power"_a, "nom_volt"_a, "nom_freq"_a, "pole_number"_a,
459 "nom_field_cur"_a, "Rs"_a, "Ll"_a, "Lmd"_a, "Lmq"_a, "Rfd"_a,
460 "Llfd"_a, "Rkd"_a, "Llkd"_a, "Rkq1"_a, "Llkq1"_a, "Rkq2"_a,
461 "Llkq2"_a, "inertia"_a, "init_active_power"_a,
462 "init_reactive_power"_a, "init_terminal_volt"_a, "init_volt_angle"_a,
463 "init_mech_power"_a)
464#ifdef WITH_JSON
465 .def("apply_parameters_from_json",
466 [](std::shared_ptr<CPS::EMT::Ph3::SynchronGeneratorDQODE> syngen,
467 const CPS::String json) {
468 DPsim::Utils::applySynchronousGeneratorParametersFromJson(
469 json::parse(json), syngen);
470 })
471#endif
472 .def("set_initial_values",
473 &CPS::EMT::Ph3::SynchronGeneratorDQODE::setInitialValues,
474 "init_active_power"_a, "init_reactive_power"_a,
475 "init_terminal_volt"_a, "init_volt_angle"_a, "init_mech_power"_a);
476
477#endif
478
480 std::shared_ptr<CPS::EMT::Ph3::AvVoltageSourceInverterDQ>,
481 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "AvVoltageSourceInverterDQ",
482 py::multiple_inheritance())
483 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
484 "loglevel"_a = CPS::Logger::Level::off)
485 .def(py::init<std::string, std::string, CPS::Logger::Level, CPS::Bool>(),
486 "uid"_a, "name"_a, "loglevel"_a = CPS::Logger::Level::off,
487 // cppcheck-suppress assignBoolToPointer
488 "with_trafo"_a = false)
489 .def("set_parameters",
491 "sys_omega"_a, "sys_volt_nom"_a, "p_ref"_a, "q_ref"_a)
492 .def("set_filter_parameters",
494 "Lf"_a, "Cf"_a, "Rf"_a, "Rc"_a)
495 .def("set_controller_parameters",
497 "Kp_pll"_a, "Ki_pll"_a, "Kp_power_ctrl"_a, "Ki_power_ctrl"_a,
498 "Kp_curr_ctrl"_a, "Ki_curr_ctrl"_a, "omega_cutoff"_a)
499 .def("set_transformer_parameters",
501 "nom_voltage_end_1"_a, "nom_voltage_end_2"_a, "rated_power"_a,
502 "ratio_abs"_a, "ratio_phase"_a, "resistance"_a, "inductance"_a,
503 "omega"_a)
504 .def("set_initial_state_values",
506 "p_init"_a, "q_init"_a, "phi_d_init"_a, "phi_q_init"_a,
507 "gamma_d_init"_a, "gamma_q_init"_a)
508 .def("with_control",
509 &CPS::EMT::Ph3::AvVoltageSourceInverterDQ::withControl)
511
513 std::shared_ptr<CPS::EMT::Ph3::Transformer>,
514 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "Transformer",
515 py::multiple_inheritance())
516 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
517 "loglevel"_a = CPS::Logger::Level::off)
518 .def(py::init<std::string, std::string, CPS::Logger::Level, CPS::Bool>(),
519 "uid"_a, "name"_a, "loglevel"_a = CPS::Logger::Level::off,
520 // cppcheck-suppress assignBoolToPointer
521 "with_resistive_losses"_a = false)
522 .def("set_parameters", &CPS::EMT::Ph3::Transformer::setParameters,
523 "nom_voltage_end_1"_a, "nom_voltage_end_2"_a, "rated_power"_a,
524 "ratio_abs"_a, "ratio_phase"_a, "resistance"_a, "inductance"_a)
525 .def("connect", &CPS::EMT::Ph3::Transformer::connect);
526
528 std::shared_ptr<CPS::EMT::Ph3::SeriesResistor>,
529 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "SeriesResistor",
530 py::multiple_inheritance())
531 .def(py::init<std::string>())
532 .def(py::init<std::string, CPS::Logger::Level>())
533 .def("set_parameters", &CPS::EMT::Ph3::SeriesResistor::setParameters,
534 "R"_a)
536
538 std::shared_ptr<CPS::EMT::Ph3::SeriesSwitch>,
540 mEMTPh3, "SeriesSwitch", py::multiple_inheritance())
541 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
542 "loglevel"_a = CPS::Logger::Level::off)
543 .def("set_parameters", &CPS::EMT::Ph3::SeriesSwitch::setParameters,
544 "open_resistance"_a, "closed_resistance"_a,
545 // cppcheck-suppress assignBoolToPointer
546 "closed"_a = false)
549 .def("connect", &CPS::EMT::Ph3::SeriesSwitch::connect);
550
552 std::shared_ptr<CPS::EMT::Ph3::SSN::Full_Serial_RLC>,
553 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "Full_Serial_RLC",
554 py::multiple_inheritance())
555 .def(py::init<std::string>())
556 .def(py::init<std::string, CPS::Logger::Level>())
557 .def("set_parameters",
558 &CPS::EMT::Ph3::SSN::Full_Serial_RLC::setParameters, "R"_a, "L"_a,
559 "C"_a)
561 .def_property("R", createAttributeGetter<CPS::Matrix>("R"),
562 createAttributeSetter<CPS::Matrix>("R"))
563 .def_property("L", createAttributeGetter<CPS::Matrix>("L"),
564 createAttributeSetter<CPS::Matrix>("L"))
565 .def_property("C", createAttributeGetter<CPS::Matrix>("C"),
566 createAttributeSetter<CPS::Matrix>("C"));
567}
void setParameters(Real capacitance)
Sets model specific parameters.
void setParameters(Real inductance)
Sets model specific parameters.
Dynamic Phasor Three-Phase Switch.
void close()
Close switch.
void open()
Open switch.
void setParameters(Matrix capacitance)
Sets model specific parameters.
void setParameters(Matrix inductance)
Sets model specific parameters.
void setParameters(Matrix resistance)
Sets model specific parameters.
Dynamic Phasor Three-Phase Switch.
Ideal current source model.
SSNTypeI2T Model for a one phase, two terminal I-type SSN component which can be represented using a ...
SSNTypeV2T Model for a one phase, two terminal V-type SSN component which can be represented using a ...
Ideal Voltage source model.
void setControllerParameters(Real Kp_pll, Real Ki_pll, Real Kp_powerCtrl, Real Ki_powerCtrl, Real Kp_currCtrl, Real Ki_currCtrl, Real Omega_cutoff)
Setter for parameters of control loops.
void setTransformerParameters(Real nomVoltageEnd1, Real nomVoltageEnd2, Real ratedPower, Real ratioAbs, Real ratioPhase, Real resistance, Real inductance, Real omega)
Setter for parameters of transformer.
void setInitialStateValues(Real pInit, Real qInit, Real phi_dInit, Real phi_qInit, Real gamma_dInit, Real gamma_qInit)
Setter for initial values applied in controllers.
void setFilterParameters(Real Lf, Real Cf, Real Rf, Real Rc)
Setter for parameters of filter.
void setParameters(Real sysOmega, Real sysVoltNom, Real Pref, Real Qref)
Setter for gengit eral parameters of inverter.
Ideal current source model.
void setParameters(MatrixComp currentRef, Real srcFreq=50.0)
Setter for reference current.
void setParameters(MatrixComp voltageRef, Real srcFreq=50.0)
Setter for reference voltage parameters.
Base class for EMT VBR simplefied synchronous generator models.
Voltage-Behind-Reactance (VBR) implementation of 3rd order synchronous generator model.
Voltage-Behind-Reactance (VBR) implementation of 4th order synchronous generator model.
Voltage-Behind-Reactance (VBR) implementation of 5th type 2 order synchronous generator model Ref: Mi...
Voltage-Behind-Reactance (VBR) implementation of 6th order synchronous generator model Marconato's mo...
Voltage-Behind-Reactance (VBR) implementation of 6th order synchronous generator model Anderson - Fou...
Transformer that includes an inductance and resistance.
void setParameters(Real nomVoltageEnd1, Real nomVoltageEnd2, Real ratedPower, Real ratioAbs, Real ratioPhase, Matrix resistance, Matrix inductance)
Defines component parameters.
Ideal Voltage source model.
void setParameters(MatrixComp voltageRef, Real srcFreq=50.0)
Setter for reference voltage and frequency with a sine wave generator.
Base class for all components that are transmitting power.
void connect(typename SimNode< Real >::List nodes)