DPsim
Loading...
Searching...
No Matches
EMTComponents.cpp
Go to the documentation of this file.
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>
13#include <dpsim/Simulation.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>(
35 .def("set_initial_voltage",
36 py::overload_cast<CPS::Complex>(
38 .def("set_initial_voltage",
39 py::overload_cast<CPS::Complex, int>(
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"),
63 .def_property("f_src", createAttributeGetter<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"),
77 .def_property("f_src", createAttributeGetter<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"),
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"),
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"),
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",
131 "C"_a)
133 .def_property("R", createAttributeGetter<CPS::Real>("R"),
135 .def_property("L", createAttributeGetter<CPS::Real>("L"),
137 .def_property("C", createAttributeGetter<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"),
154 .def_property("mB", createAttributeGetter<CPS::Matrix>("mB"),
156 .def_property("mC", createAttributeGetter<CPS::Matrix>("mC"),
158 .def_property("mD", createAttributeGetter<CPS::Matrix>("mD"),
160 .def_property("mdA", createAttributeGetter<CPS::Matrix>("mdA"),
162 .def_property("mdB", createAttributeGetter<CPS::Matrix>("mdB"),
164 .def_property("mdC", createAttributeGetter<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"),
181 .def_property("mB", createAttributeGetter<CPS::Matrix>("mB"),
183 .def_property("mC", createAttributeGetter<CPS::Matrix>("mC"),
185 .def_property("mD", createAttributeGetter<CPS::Matrix>("mD"),
187 .def_property("mdA", createAttributeGetter<CPS::Matrix>("mdA"),
189 .def_property("mdB", createAttributeGetter<CPS::Matrix>("mdB"),
191 .def_property("mdC", createAttributeGetter<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"),
209 .def_property("f_src", createAttributeGetter<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"),
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"),
239 .def_property("f_src", createAttributeGetter<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::Shunt, std::shared_ptr<CPS::EMT::Ph3::Shunt>,
302 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "Shunt",
303 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",
307 static_cast<void (CPS::EMT::Ph3::Shunt::*)(CPS::Real, CPS::Real)>(
309 "G"_a, "B"_a)
310 .def("connect", &CPS::EMT::Ph3::Shunt::connect);
311
312 py::class_<CPS::EMT::Ph3::Switch, std::shared_ptr<CPS::EMT::Ph3::Switch>,
314 mEMTPh3, "Switch", py::multiple_inheritance())
315 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
316 "loglevel"_a = CPS::Logger::Level::off)
317 .def("set_parameters", &CPS::EMT::Ph3::Switch::setParameters,
318 "open_resistance"_a, "closed_resistance"_a,
319 // cppcheck-suppress assignBoolToPointer
320 "closed"_a = false)
323 .def("connect", &CPS::EMT::Ph3::Switch::connect);
324
326 std::shared_ptr<CPS::EMT::Ph3::SynchronGeneratorIdeal>,
327 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "SynchronGeneratorIdeal",
328 py::multiple_inheritance())
329 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
330 "loglevel"_a = CPS::Logger::Level::off)
332
334 std::shared_ptr<CPS::EMT::Ph3::SynchronGeneratorDQTrapez>,
335 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "SynchronGeneratorDQTrapez",
336 py::multiple_inheritance())
337 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
338 "loglevel"_a = CPS::Logger::Level::off)
339 .def("set_parameters_operational_per_unit",
341 setParametersOperationalPerUnit,
342 "nom_power"_a, "nom_volt"_a, "nom_freq"_a, "pole_number"_a,
343 "nom_field_cur"_a, "Rs"_a, "Ld"_a, "Lq"_a, "Ld_t"_a, "Lq_t"_a,
344 "Ld_s"_a, "Lq_s"_a, "Ll"_a, "Td0_t"_a, "Tq0_t"_a, "Td0_s"_a,
345 "Tq0_s"_a, "inertia"_a)
346 .def("set_parameters_fundamental_per_unit",
348 setParametersFundamentalPerUnit,
349 "nom_power"_a, "nom_volt"_a, "nom_freq"_a, "pole_number"_a,
350 "nom_field_cur"_a, "Rs"_a, "Ll"_a, "Lmd"_a, "Lmq"_a, "Rfd"_a,
351 "Llfd"_a, "Rkd"_a, "Llkd"_a, "Rkq1"_a, "Llkq1"_a, "Rkq2"_a,
352 "Llkq2"_a, "inertia"_a, "init_active_power"_a,
353 "init_reactive_power"_a, "init_terminal_volt"_a, "init_volt_angle"_a,
354 "init_mech_power"_a)
355#ifdef WITH_JSON
356 .def("apply_parameters_from_json",
357 [](std::shared_ptr<CPS::EMT::Ph3::SynchronGeneratorDQTrapez> syngen,
358 const CPS::String json) {
359 DPsim::Utils::applySynchronousGeneratorParametersFromJson(
360 json::parse(json), syngen);
361 })
362#endif
363 .def("set_initial_values",
365 "init_active_power"_a, "init_reactive_power"_a,
366 "init_terminal_volt"_a, "init_volt_angle"_a, "init_mech_power"_a);
367
369 std::shared_ptr<CPS::EMT::Ph3::VSIVoltageControlVCO>,
370 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "VSIVoltageControlVCO",
371 py::multiple_inheritance())
372 .def(py::init<std::string>())
373 .def(py::init<std::string, CPS::Logger::Level>())
374 .def(py::init<std::string, std::string, CPS::Logger::Level, CPS::Bool>(),
375 "uid"_a, "name"_a, "log_level"_a = CPS::Logger::Level::off,
376 py::arg("with_trafo") = false)
377 .def("set_parameters",
379 "vd_ref"_a, "vq_ref"_a)
380 .def("set_controller_parameters",
382 "kp_voltage_ctrl"_a, "ki_voltage_ctrl"_a, "kp_curr_ctrl"_a,
383 "ki_curr_ctrl"_a, "omega_nominal"_a)
384 .def("set_transformer_parameters",
386 "nom_voltage_end1"_a, "nom_voltage_end2"_a, "rated_power"_a,
387 "ratio_abs"_a, "ratio_phase"_a, "resistance"_a, "inductance"_a,
388 "omega"_a)
389 .def("set_filter_parameters",
391 "cf"_a, "rf"_a, "rc"_a)
392 .def("set_initial_state_values",
394 "phi_d_init"_a, "phi_q_init"_a, "gamma_d_init"_a, "gamma_q_init"_a)
396 "control_on"_a)
398
400 std::shared_ptr<CPS::EMT::Ph3::ReducedOrderSynchronGeneratorVBR>,
402 mEMTPh3, "ReducedOrderSynchronGeneratorVBR", py::multiple_inheritance());
403
405 std::shared_ptr<CPS::EMT::Ph3::SynchronGenerator3OrderVBR>,
407 mEMTPh3, "SynchronGenerator3OrderVBR", 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,
413 CPS::Real>(
415 setOperationalParametersPerUnit),
416 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
417 "Lq"_a, "L0"_a, "Ld_t"_a, "Td0_t"_a)
419
421 std::shared_ptr<CPS::EMT::Ph3::SynchronGenerator4OrderVBR>,
423 mEMTPh3, "SynchronGenerator4OrderVBR", py::multiple_inheritance())
424 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
425 "loglevel"_a = CPS::Logger::Level::off)
426 .def("set_operational_parameters_per_unit",
427 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
431 setOperationalParametersPerUnit),
432 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
433 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a)
435
437 std::shared_ptr<CPS::EMT::Ph3::SynchronGenerator5OrderVBR>,
439 mEMTPh3, "SynchronGenerator5OrderVBR", py::multiple_inheritance())
440 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
441 "loglevel"_a = CPS::Logger::Level::off)
442 .def("set_operational_parameters_per_unit",
443 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
448 setOperationalParametersPerUnit),
449 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
450 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a, "Ld_s"_a,
451 "Lq_s"_a, "Td0_s"_a, "Tq0_s"_a, "Taa"_a)
453
455 std::shared_ptr<CPS::EMT::Ph3::SynchronGenerator6aOrderVBR>,
457 mEMTPh3, "SynchronGenerator6aOrderVBR", py::multiple_inheritance())
458 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
459 "loglevel"_a = CPS::Logger::Level::off)
460 .def("set_operational_parameters_per_unit",
461 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
466 setOperationalParametersPerUnit),
467 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
468 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a, "Ld_s"_a,
469 "Lq_s"_a, "Td0_s"_a, "Tq0_s"_a, "Taa"_a)
471
473 std::shared_ptr<CPS::EMT::Ph3::SynchronGenerator6bOrderVBR>,
475 mEMTPh3, "SynchronGenerator6bOrderVBR", py::multiple_inheritance())
476 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
477 "loglevel"_a = CPS::Logger::Level::off)
478 .def("set_operational_parameters_per_unit",
479 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
484 setOperationalParametersPerUnit),
485 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
486 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a, "Ld_s"_a,
487 "Lq_s"_a, "Td0_s"_a, "Tq0_s"_a, "Taa"_a = 0)
489
490#ifdef WITH_SUNDIALS
491
493 std::shared_ptr<CPS::EMT::Ph3::SynchronGeneratorDQODE>,
494 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "SynchronGeneratorDQODE",
495 py::multiple_inheritance())
496 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
497 "loglevel"_a = CPS::Logger::Level::off)
498 .def("set_parameters_operational_per_unit",
500 setParametersOperationalPerUnit,
501 "nom_power"_a, "nom_volt"_a, "nom_freq"_a, "pole_number"_a,
502 "nom_field_cur"_a, "Rs"_a, "Ld"_a, "Lq"_a, "Ld_t"_a, "Lq_t"_a,
503 "Ld_s"_a, "Lq_s"_a, "Ll"_a, "Td0_t"_a, "Tq0_t"_a, "Td0_s"_a,
504 "Tq0_s"_a, "inertia"_a)
505 .def("set_parameters_fundamental_per_unit",
507 setParametersFundamentalPerUnit,
508 "nom_power"_a, "nom_volt"_a, "nom_freq"_a, "pole_number"_a,
509 "nom_field_cur"_a, "Rs"_a, "Ll"_a, "Lmd"_a, "Lmq"_a, "Rfd"_a,
510 "Llfd"_a, "Rkd"_a, "Llkd"_a, "Rkq1"_a, "Llkq1"_a, "Rkq2"_a,
511 "Llkq2"_a, "inertia"_a, "init_active_power"_a,
512 "init_reactive_power"_a, "init_terminal_volt"_a, "init_volt_angle"_a,
513 "init_mech_power"_a)
514#ifdef WITH_JSON
515 .def("apply_parameters_from_json",
516 [](std::shared_ptr<CPS::EMT::Ph3::SynchronGeneratorDQODE> syngen,
517 const CPS::String json) {
518 DPsim::Utils::applySynchronousGeneratorParametersFromJson(
519 json::parse(json), syngen);
520 })
521#endif
522 .def("set_initial_values",
524 "init_active_power"_a, "init_reactive_power"_a,
525 "init_terminal_volt"_a, "init_volt_angle"_a, "init_mech_power"_a);
526
527#endif
528
530 std::shared_ptr<CPS::EMT::Ph3::AvVoltageSourceInverterDQ>,
531 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "AvVoltageSourceInverterDQ",
532 py::multiple_inheritance())
533 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
534 "loglevel"_a = CPS::Logger::Level::off)
535 .def(py::init<std::string, std::string, CPS::Logger::Level, CPS::Bool>(),
536 "uid"_a, "name"_a, "loglevel"_a = CPS::Logger::Level::off,
537 // cppcheck-suppress assignBoolToPointer
538 "with_trafo"_a = false)
539 .def("set_parameters",
541 "sys_omega"_a, "sys_volt_nom"_a, "p_ref"_a, "q_ref"_a)
542 .def("set_filter_parameters",
544 "Lf"_a, "Cf"_a, "Rf"_a, "Rc"_a)
545 .def("set_controller_parameters",
547 "Kp_pll"_a, "Ki_pll"_a, "Kp_power_ctrl"_a, "Ki_power_ctrl"_a,
548 "Kp_curr_ctrl"_a, "Ki_curr_ctrl"_a, "omega_cutoff"_a)
549 .def("set_transformer_parameters",
551 "nom_voltage_end_1"_a, "nom_voltage_end_2"_a, "rated_power"_a,
552 "ratio_abs"_a, "ratio_phase"_a, "resistance"_a, "inductance"_a,
553 "omega"_a)
554 .def("set_initial_state_values",
556 "p_init"_a, "q_init"_a, "phi_d_init"_a, "phi_q_init"_a,
557 "gamma_d_init"_a, "gamma_q_init"_a)
558 .def("with_control",
561
563 std::shared_ptr<CPS::EMT::Ph3::Transformer>,
564 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "Transformer",
565 py::multiple_inheritance())
566 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
567 "loglevel"_a = CPS::Logger::Level::off)
568 .def(py::init<std::string, std::string, CPS::Logger::Level, CPS::Bool>(),
569 "uid"_a, "name"_a, "loglevel"_a = CPS::Logger::Level::off,
570 // cppcheck-suppress assignBoolToPointer
571 "with_resistive_losses"_a = false)
572 .def("set_parameters", &CPS::EMT::Ph3::Transformer::setParameters,
573 "nom_voltage_end_1"_a, "nom_voltage_end_2"_a, "rated_power"_a,
574 "ratio_abs"_a, "ratio_phase"_a, "resistance"_a, "inductance"_a)
575 .def("connect", &CPS::EMT::Ph3::Transformer::connect);
576
578 std::shared_ptr<CPS::EMT::Ph3::SeriesResistor>,
579 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "SeriesResistor",
580 py::multiple_inheritance())
581 .def(py::init<std::string>())
582 .def(py::init<std::string, CPS::Logger::Level>())
583 .def("set_parameters", &CPS::EMT::Ph3::SeriesResistor::setParameters,
584 "R"_a)
586
588 std::shared_ptr<CPS::EMT::Ph3::SeriesSwitch>,
590 mEMTPh3, "SeriesSwitch", py::multiple_inheritance())
591 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
592 "loglevel"_a = CPS::Logger::Level::off)
593 .def("set_parameters", &CPS::EMT::Ph3::SeriesSwitch::setParameters,
594 "open_resistance"_a, "closed_resistance"_a,
595 // cppcheck-suppress assignBoolToPointer
596 "closed"_a = false)
599 .def("connect", &CPS::EMT::Ph3::SeriesSwitch::connect);
600
602 std::shared_ptr<CPS::EMT::Ph3::SSN::Full_Serial_RLC>,
603 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "Full_Serial_RLC",
604 py::multiple_inheritance())
605 .def(py::init<std::string>())
606 .def(py::init<std::string, CPS::Logger::Level>())
607 .def("set_parameters",
609 "C"_a)
611 .def_property("R", createAttributeGetter<CPS::Matrix>("R"),
613 .def_property("L", createAttributeGetter<CPS::Matrix>("L"),
615 .def_property("C", createAttributeGetter<CPS::Matrix>("C"),
617
619 std::shared_ptr<CPS::EMT::Ph3::GenericTwoTerminalVTypeSSN>,
621 mEMTPh3, "GenericTwoTerminalVTypeSSN", py::multiple_inheritance())
622 .def(py::init<std::string>())
623 .def(py::init<std::string, CPS::Logger::Level>())
624 .def("set_parameters",
626 "B"_a, "C"_a, "D"_a)
628 .def_property_readonly("x", createAttributeGetter<CPS::Matrix>("x"));
629
631 std::shared_ptr<CPS::EMT::Ph3::GenericTwoTerminalITypeSSN>,
633 mEMTPh3, "GenericTwoTerminalITypeSSN", py::multiple_inheritance())
634 .def(py::init<std::string>())
635 .def(py::init<std::string, CPS::Logger::Level>())
636 .def("set_parameters",
638 "B"_a, "C"_a, "D"_a)
640 .def_property_readonly("x", createAttributeGetter<CPS::Matrix>("x"));
641
643 std::shared_ptr<CPS::EMT::Ph3::PiecewiseLinearInductor>,
644 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "PiecewiseLinearInductor",
645 py::multiple_inheritance())
646 .def(py::init<std::string>())
647 .def(py::init<std::string, CPS::Logger::Level>())
648 .def("set_parameters",
650 "flux_breakpoints"_a, "current_breakpoints"_a)
652 .def_property_readonly("x", createAttributeGetter<CPS::Matrix>("x"));
653
655 std::shared_ptr<CPS::EMT::Ph3::AvVoltSourceInverterStateSpace>,
657 mEMTPh3, "AvVoltSourceInverterStateSpace", py::multiple_inheritance())
658 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
659 "loglevel"_a = CPS::Logger::Level::off)
660 .def(py::init<std::string, std::string, CPS::Logger::Level>(), "uid"_a,
661 "name"_a, "loglevel"_a = CPS::Logger::Level::off)
662 .def("set_parameters",
664 "Lf"_a, "Cf"_a, "Rf"_a, "Rc"_a, "omega_n"_a, "Kp_pll"_a, "Ki_pll"_a,
665 "omega_cutoff"_a, "p_ref"_a, "q_ref"_a, "Kp_power_ctrl"_a,
666 "Ki_power_ctrl"_a, "Kp_curr_ctrl"_a, "Ki_curr_ctrl"_a)
668 .def_property_readonly("x", createAttributeGetter<CPS::Matrix>("x"))
669 .def_property_readonly("vc_d", createAttributeGetter<CPS::Real>("vc_d"))
670 .def_property_readonly("vc_q", createAttributeGetter<CPS::Real>("vc_q"))
671 .def_property_readonly("irc_d", createAttributeGetter<CPS::Real>("irc_d"))
672 .def_property_readonly("irc_q", createAttributeGetter<CPS::Real>("irc_q"))
673 .def_property_readonly("p_inst",
675 .def_property_readonly("q_inst",
677 .def_property_readonly("omega_pll",
679
680 py::class_<CPS::EMT::Ph3::SSN_GFM, std::shared_ptr<CPS::EMT::Ph3::SSN_GFM>,
681 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "SSN_GFM",
682 py::multiple_inheritance())
683 .def(py::init<std::string, std::string, CPS::Logger::Level>(), "uid"_a,
684 "name"_a, "log_level"_a = CPS::Logger::Level::off)
685 .def("set_parameters", &CPS::EMT::Ph3::SSN_GFM::setParameters, "lf"_a,
686 "cf"_a, "rf"_a, "rc"_a, "nominal_voltage"_a, "omega_nominal"_a,
687 "p_ref"_a, "q_ref"_a, "virtual_inertia"_a, "damping_coefficient"_a,
688 "voltage_droop_gain"_a, "reactive_integral_gain"_a, "kp_voltage"_a,
689 "ki_voltage"_a, "kp_current"_a, "ki_current"_a,
690 "active_damping_gain"_a, "power_filter_cutoff"_a,
691 "delay_bandwidth"_a)
692 .def("set_numerical_linearization_parameters",
694 "relative_step"_a = 1e-6, "absolute_step"_a = 1e-8)
695 .def("set_virtual_impedance",
696 &CPS::EMT::Ph3::SSN_GFM::setVirtualImpedance, "virtual_resistance"_a,
697 "virtual_reactance"_a = 0.0)
698 .def("set_grid_current_feedforward",
700 .def("set_reactive_power_droop",
702 "cutoff"_a)
703 .def("connect", &CPS::EMT::Ph3::SSN_GFM::connect)
704 .def("get_state_names", &CPS::EMT::Ph3::SSN_GFM::getLocalStateNames)
705 .def("get_state", &CPS::EMT::Ph3::SSN_GFM::getState)
706 .def("get_state_derivative", &CPS::EMT::Ph3::SSN_GFM::getStateDerivative)
707 .def("get_interface_voltage",
709 .def("get_interface_current",
711 .def_property_readonly("p_inst",
713 .def_property_readonly("q_inst",
715 .def_property_readonly("omega_gfm",
717 .def_property_readonly("theta_gfm",
719 .def_property_readonly(
720 "voltage_magnitude_gfm",
721 createAttributeGetter<CPS::Real>("voltage_magnitude_gfm"))
722 .def_property_readonly("vc_d", createAttributeGetter<CPS::Real>("vc_d"))
723 .def_property_readonly("vc_q", createAttributeGetter<CPS::Real>("vc_q"))
724 .def_property_readonly("i_grid_d",
726 .def_property_readonly("i_grid_q",
728 .def_property_readonly("if_d", createAttributeGetter<CPS::Real>("if_d"))
729 .def_property_readonly("if_q", createAttributeGetter<CPS::Real>("if_q"))
730 .def_property_readonly("v_ref_d",
732 .def_property_readonly("v_ref_q",
734
736 std::shared_ptr<CPS::EMT::Ph3::SSN::Capacitor>,
737 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "SSN_Capacitor",
738 py::multiple_inheritance())
739 .def(py::init<std::string>())
740 .def(py::init<std::string, CPS::Logger::Level>())
741 .def("set_parameters", &CPS::EMT::Ph3::SSN::Capacitor::setParameters,
742 "C"_a)
744 .def_property("C", createAttributeGetter<CPS::Matrix>("C"),
746
748 std::shared_ptr<CPS::EMT::Ph3::GenericFourTerminalVTypeSSN>,
750 mEMTPh3, "GenericFourTerminalVTypeSSN", py::multiple_inheritance())
751 .def(py::init<std::string>())
752 .def(py::init<std::string, CPS::Logger::Level>())
753 .def("set_parameters",
755 "B"_a, "C"_a, "D"_a)
757 .def_property_readonly("x", createAttributeGetter<CPS::Matrix>("x"));
758}
void addEMTPh1Components(py::module_ mEMTPh1)
void addEMTPh3Components(py::module_ mEMTPh3)
void addEMTComponents(py::module_ mEMT)
void setParameters(Real capacitance)
Sets model specific parameters.
void setParameters(Real inductance)
Sets model specific parameters.
void setParameters(Real resistance)
Dynamic Phasor Three-Phase Switch.
void close()
Close switch.
void setParameters(Real openResistance, Real closedResistance, Bool closed=false)
void open()
Open switch.
void setParameters(Matrix capacitance)
Sets model specific parameters.
void setParameters(Matrix inductance)
Sets model specific parameters.
void setParameters(Matrix seriesResistance, Matrix seriesInductance, Matrix parallelCapacitance=Matrix::Zero(3, 3), Matrix parallelConductance=Matrix::Zero(3, 3)) const
void setParameters(Matrix resistance)
Sets model specific parameters.
Dynamic Phasor Three-Phase Switch.
void setParameters(Matrix openResistance, Matrix closedResistance, Bool closed=false)
void setInitialValues(Real initActivePower, Real initReactivePower, Real initTerminalVolt, Real initVoltAngle, Real initMechPower)
Ideal current source model.
void setParameters(Complex currentRef, Real srcFreq=-1)
void setParameters(Real resistance, Real inductance, Real capacitance)
SSNTypeI2T Model for a one phase, two terminal I-type SSN component which can be represented using a ...
void setParameters(const Matrix A, const Matrix B, const Matrix C, const Matrix D)
void manualInit(Matrix initialState, Matrix initialInput, Matrix initialOldInput, Real initCurrent, Real initVoltage)
SSNTypeV2T Model for a one phase, two terminal V-type SSN component which can be represented using a ...
void manualInit(Matrix initialState, Matrix initialInput, Matrix initialOldInput, Real initCurrent, Real initVoltage)
void setParameters(const Matrix A, const Matrix B, const Matrix C, const Matrix D)
Ideal Voltage source model.
void setParameters(Complex voltageRef, Real srcFreq=-1)
void setParameters(Real lf, Real cf, Real rf, Real rc, Real omegaN, Real kpPLL, Real kiPLL, Real omegaCutoff, Real pRef, Real qRef, Real kpPowerCtrl, Real kiPowerCtrl, Real kpCurrCtrl, Real kiCurrCtrl)
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.
Concrete generic three-phase, two-terminal I-type SSN component.
Concrete generic three-phase, two-terminal V-type SSN component.
void setParameters(MatrixComp voltageRef, Real srcFreq=50.0)
Setter for reference voltage parameters.
Three-phase, two-terminal, piecewise-linear flux-state inductor.
void setParameters(const std::vector< Real > &fluxBreakpoints, const std::vector< Real > &currentBreakpoints)
void setParameters(Matrix activePower, Matrix reactivePower, Real volt, bool reactanceInSeries=false)
Base class for EMT VBR simplefied synchronous generator models.
void setParameters(Matrix capacitance)
void setParameters(const Matrix &resistance, const Matrix &inductance, const Matrix &capacitance)
void setNumericalLinearizationParameters(Real relativeStep, Real absoluteStep)
Configure finite-difference steps for local linearization.
Matrix getStateDerivative() const
Matrix getInterfaceCurrent() const
Matrix getInterfaceVoltage() const
void setReactivePowerDroop(Real droopGain, Real cutoff)
Opt-in proportional Q-V droop replacing the integral excitation. droopGain is Dq [V/var]; cutoff [rad...
void setParameters(Real lf, Real cf, Real rf, Real rc, Real nominalVoltage, Real omegaN, Real pRef, Real qRef, Real virtualInertia, Real dampingCoefficient, Real voltageDroopGain, Real reactiveIntegralGain, Real kpVoltage, Real kiVoltage, Real kpCurrent, Real kiCurrent, Real activeDampingGain, Real powerFilterCutoff, Real delayBandwidth)
Configure the GFM model.
std::vector< String > getLocalStateNames() const override final
void setGridCurrentFeedforward(Real scale)
Scale on the voltage-loop grid-current feedforward (default 1).
void setVirtualImpedance(Real virtualResistance, Real virtualReactance=0.0)
Opt-in virtual output impedance Zv = Rv + jXv, subtracted from the EMF reference across the filter cu...
void setParameters(Real conductance, Real susceptance)
Set shunt specific parameters.
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...
Ideal voltage source representing a synchronous generator.
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.
void setParameters(Real sysOmega, Real VdRef, Real VqRef)
Setter for general parameters of the component.
void setFilterParameters(Real Lf, Real Cf, Real Rf, Real Rc)
Setter for parameters of filter.
void setControllerParameters(Real Kp_voltageCtrl, Real Ki_voltageCtrl, Real Kp_currCtrl, Real Ki_currCtrl, Real Omega_nominal)
Setter for parameters of control loops.
void setInitialStateValues(Real phi_dInit, Real phi_qInit, Real gamma_dInit, Real gamma_qInit)
Setter for initial values applied in controllers.
void setTransformerParameters(Real nomVoltageEnd1, Real nomVoltageEnd2, Real ratedPower, Real ratioAbs, Real ratioPhase, Real resistance, Real inductance, Real omega)
Setter for parameters of transformer.
Ideal Voltage source model.
void setParameters(MatrixComp voltageRef, Real srcFreq=50.0)
Setter for reference voltage and frequency with a sine wave generator.
void setParameters(const Matrix &A, const Matrix &B, const Matrix &C, const Matrix &D)
static Ptr GND
Definition SimNode.h:35
Base class for all components that are transmitting power.
void connect(typename SimNode< Real >::List nodes)
void setInitialVoltage(MatrixComp voltage) const
py::cpp_function createAttributeGetter(const std::string name)
Definition Utils.h:27
py::cpp_function createAttributeSetter(const std::string name)
Definition Utils.h:20
std::string String
Definition Definitions.h:65
double Real
Definition Definitions.h:62
CPS::Matrix zeroMatrix(int dim)
Definition Utils.cpp:11