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>
22#include <dpsim/Simulation.h>
24#include <dpsim/pybind/Utils.h>
25
26#ifdef WITH_JSON
27#include <nlohmann/json.hpp>
28using json = nlohmann::json;
29#endif
30
32
33namespace py = pybind11;
34using namespace pybind11::literals;
35
36namespace {
37
38void addEMTDCComponents(py::module_ mEMTDC) {
40 std::shared_ptr<CPS::EMT::DC::VoltageSource>,
41 CPS::SimPowerComp<CPS::Real>>(mEMTDC, "VoltageSource",
42 py::multiple_inheritance())
43 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
44 "loglevel"_a = CPS::Logger::Level::off)
45 .def("set_parameters", &CPS::EMT::DC::VoltageSource::setParameters,
46 "voltage"_a)
48 .def_property_readonly("V_ref",
50
52 std::shared_ptr<CPS::EMT::DC::CurrentSource>,
53 CPS::SimPowerComp<CPS::Real>>(mEMTDC, "CurrentSource",
54 py::multiple_inheritance())
55 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
56 "loglevel"_a = CPS::Logger::Level::off)
57 .def("set_parameters", &CPS::EMT::DC::CurrentSource::setParameters,
58 "current"_a)
60 .def_property_readonly("I_ref",
62
63 py::class_<CPS::EMT::DC::Resistor, std::shared_ptr<CPS::EMT::DC::Resistor>,
64 CPS::SimPowerComp<CPS::Real>>(mEMTDC, "Resistor",
65 py::multiple_inheritance())
66 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
67 "loglevel"_a = CPS::Logger::Level::off)
68 .def("set_parameters", &CPS::EMT::DC::Resistor::setParameters,
69 "resistance"_a)
70 .def("connect", &CPS::EMT::DC::Resistor::connect)
71 .def_property_readonly("R", createAttributeGetter<CPS::Real>("R"));
72
73 py::class_<CPS::EMT::DC::Capacitor, std::shared_ptr<CPS::EMT::DC::Capacitor>,
74 CPS::SimPowerComp<CPS::Real>>(mEMTDC, "Capacitor",
75 py::multiple_inheritance())
76 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
77 "loglevel"_a = CPS::Logger::Level::off)
78 .def("set_parameters", &CPS::EMT::DC::Capacitor::setParameters,
79 "capacitance"_a)
80 .def("connect", &CPS::EMT::DC::Capacitor::connect)
81 .def_property_readonly("C", createAttributeGetter<CPS::Real>("C"))
82 .def_property_readonly("x", createAttributeGetter<CPS::Matrix>("x"));
83
84 py::class_<CPS::EMT::DC::Inductor, std::shared_ptr<CPS::EMT::DC::Inductor>,
85 CPS::SimPowerComp<CPS::Real>>(mEMTDC, "Inductor",
86 py::multiple_inheritance())
87 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
88 "loglevel"_a = CPS::Logger::Level::off)
89 .def("set_parameters", &CPS::EMT::DC::Inductor::setParameters,
90 "inductance"_a, "initial_current"_a = 0.0)
91 .def("connect", &CPS::EMT::DC::Inductor::connect)
92 .def_property_readonly("L", createAttributeGetter<CPS::Real>("L"))
93 .def_property_readonly("initial_current",
95 .def_property_readonly("x", createAttributeGetter<CPS::Matrix>("x"));
96
97 py::class_<CPS::EMT::DC::PiLine, std::shared_ptr<CPS::EMT::DC::PiLine>,
98 CPS::SimPowerComp<CPS::Real>>(mEMTDC, "PiLine",
99 py::multiple_inheritance())
100 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
101 "loglevel"_a = CPS::Logger::Level::off)
102 .def("set_parameters", &CPS::EMT::DC::PiLine::setParameters,
103 "series_resistance"_a, "series_inductance"_a,
104 "parallel_capacitance"_a = 0.0, "parallel_conductance"_a = 0.0,
105 "initial_current"_a = 0.0)
106 .def("connect", &CPS::EMT::DC::PiLine::connect)
107 .def_property_readonly("series_resistance",
109 .def_property_readonly("series_inductance",
111 .def_property_readonly("parallel_capacitance",
113 .def_property_readonly("parallel_conductance",
115 .def_property_readonly("initial_current",
117}
118
119} // namespace
120
121void addEMTComponents(py::module_ mEMT) {
122 py::class_<CPS::EMT::SimNode, std::shared_ptr<CPS::EMT::SimNode>,
123 CPS::TopologicalNode>(mEMT, "SimNode", py::module_local())
124 .def(py::init<std::string>())
125 .def(py::init<std::string, CPS::PhaseType>())
126 .def(py::init<std::string, CPS::PhaseType,
127 const std::vector<CPS::Complex>>())
128 .def("set_initial_voltage",
129 py::overload_cast<CPS::MatrixComp>(
131 .def("set_initial_voltage",
132 py::overload_cast<CPS::Complex>(
134 .def("set_initial_voltage",
135 py::overload_cast<CPS::Complex, int>(
137 .def_readonly_static("gnd", &CPS::EMT::SimNode::GND);
138
139 py::module_ mEMTDC =
140 mEMT.def_submodule("dc", "scalar electromagnetic-transient DC models");
141 addEMTDCComponents(mEMTDC);
142
143 py::module mEMTPh1 = mEMT.def_submodule(
144 "ph1", "single phase electromagnetic-transient models");
145 addEMTPh1Components(mEMTPh1);
146 py::module mEMTPh3 =
147 mEMT.def_submodule("ph3", "three phase electromagnetic-transient models");
148 addEMTPh3Components(mEMTPh3);
149}
150
151void addEMTPh1Components(py::module_ mEMTPh1) {
153 std::shared_ptr<CPS::EMT::Ph1::CurrentSource>,
154 CPS::SimPowerComp<CPS::Real>>(mEMTPh1, "CurrentSource",
155 py::multiple_inheritance())
156 .def(py::init<std::string>())
157 .def(py::init<std::string, CPS::Logger::Level>())
158 .def("set_parameters", &CPS::EMT::Ph1::CurrentSource::setParameters,
159 "I_ref"_a, "f_src"_a = -1)
161 .def_property("I_ref", createAttributeGetter<CPS::Complex>("I_ref"),
163 .def_property("f_src", createAttributeGetter<CPS::Real>("f_src"),
165
167 std::shared_ptr<CPS::EMT::Ph1::VoltageSource>,
168 CPS::SimPowerComp<CPS::Real>>(mEMTPh1, "VoltageSource",
169 py::multiple_inheritance())
170 .def(py::init<std::string>())
171 .def(py::init<std::string, CPS::Logger::Level>())
172 .def("set_parameters", &CPS::EMT::Ph1::VoltageSource::setParameters,
173 "V_ref"_a, "f_src"_a = -1)
175 .def_property("V_ref", createAttributeGetter<CPS::Complex>("V_ref"),
177 .def_property("f_src", createAttributeGetter<CPS::Real>("f_src"),
179
180 py::class_<CPS::EMT::Ph1::Resistor, std::shared_ptr<CPS::EMT::Ph1::Resistor>,
181 CPS::SimPowerComp<CPS::Real>>(mEMTPh1, "Resistor",
182 py::multiple_inheritance())
183 .def(py::init<std::string>())
184 .def(py::init<std::string, CPS::Logger::Level>())
185 .def("set_parameters", &CPS::EMT::Ph1::Resistor::setParameters, "R"_a)
186 .def("connect", &CPS::EMT::Ph1::Resistor::connect)
187 .def_property("R", createAttributeGetter<CPS::Real>("R"),
189
190 py::class_<CPS::EMT::Ph1::Capacitor,
191 std::shared_ptr<CPS::EMT::Ph1::Capacitor>,
192 CPS::SimPowerComp<CPS::Real>>(mEMTPh1, "Capacitor",
193 py::multiple_inheritance())
194 .def(py::init<std::string>())
195 .def(py::init<std::string, CPS::Logger::Level>())
196 .def("set_parameters", &CPS::EMT::Ph1::Capacitor::setParameters, "C"_a)
197 .def("connect", &CPS::EMT::Ph1::Capacitor::connect)
198 .def_property("C", createAttributeGetter<CPS::Real>("C"),
200
201 py::class_<CPS::EMT::Ph1::Inductor, std::shared_ptr<CPS::EMT::Ph1::Inductor>,
202 CPS::SimPowerComp<CPS::Real>>(mEMTPh1, "Inductor",
203 py::multiple_inheritance())
204 .def(py::init<std::string>())
205 .def(py::init<std::string, CPS::Logger::Level>())
206 .def("set_parameters", &CPS::EMT::Ph1::Inductor::setParameters, "L"_a)
207 .def("connect", &CPS::EMT::Ph1::Inductor::connect)
208 .def_property("L", createAttributeGetter<CPS::Real>("L"),
210
211 py::class_<CPS::EMT::Ph1::Switch, std::shared_ptr<CPS::EMT::Ph1::Switch>,
213 mEMTPh1, "Switch", py::multiple_inheritance())
214 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
215 "loglevel"_a = CPS::Logger::Level::off)
216 .def("set_parameters", &CPS::EMT::Ph1::Switch::setParameters,
217 "open_resistance"_a, "closed_resistance"_a,
218 "closed"_a = false) // cppcheck-suppress assignBoolToPointer
219 .def("open", &CPS::EMT::Ph1::Switch::open)
220 .def("close", &CPS::EMT::Ph1::Switch::close)
221 .def("connect", &CPS::EMT::Ph1::Switch::connect);
222
224 std::shared_ptr<CPS::EMT::Ph1::SSN::Full_Serial_RLC>,
225 CPS::SimPowerComp<CPS::Real>>(mEMTPh1, "Full_Serial_RLC",
226 py::multiple_inheritance())
227 .def(py::init<std::string>())
228 .def(py::init<std::string, CPS::Logger::Level>())
229 .def("set_parameters",
231 "C"_a)
233 .def_property("R", createAttributeGetter<CPS::Real>("R"),
235 .def_property("L", createAttributeGetter<CPS::Real>("L"),
237 .def_property("C", createAttributeGetter<CPS::Real>("C"),
239
240 py::class_<CPS::EMT::Ph1::SSNTypeI2T,
241 std::shared_ptr<CPS::EMT::Ph1::SSNTypeI2T>,
242 CPS::SimPowerComp<CPS::Real>>(mEMTPh1, "SSNTypeI2T",
243 py::multiple_inheritance())
244 .def(py::init<std::string>())
245 .def(py::init<std::string, CPS::Logger::Level>())
246 .def("set_parameters", &CPS::EMT::Ph1::SSNTypeI2T::setParameters, "A"_a,
247 "B"_a, "C"_a, "D"_a)
248 .def("manual_init", &CPS::EMT::Ph1::SSNTypeI2T::manualInit,
249 "initialState"_a, "initialInput"_a, "initialOldInput"_a,
250 "initCurr"_a, "initVol"_a)
251 .def("connect", &CPS::EMT::Ph1::SSNTypeI2T::connect)
252 .def_property("mA", createAttributeGetter<CPS::Matrix>("mA"),
254 .def_property("mB", createAttributeGetter<CPS::Matrix>("mB"),
256 .def_property("mC", createAttributeGetter<CPS::Matrix>("mC"),
258 .def_property("mD", createAttributeGetter<CPS::Matrix>("mD"),
260 .def_property("mdA", createAttributeGetter<CPS::Matrix>("mdA"),
262 .def_property("mdB", createAttributeGetter<CPS::Matrix>("mdB"),
264 .def_property("mdC", createAttributeGetter<CPS::Matrix>("mdC"),
266
267 py::class_<CPS::EMT::Ph1::SSNTypeV2T,
268 std::shared_ptr<CPS::EMT::Ph1::SSNTypeV2T>,
269 CPS::SimPowerComp<CPS::Real>>(mEMTPh1, "SSNTypeV2T",
270 py::multiple_inheritance())
271 .def(py::init<std::string>())
272 .def(py::init<std::string, CPS::Logger::Level>())
273 .def("set_parameters", &CPS::EMT::Ph1::SSNTypeV2T::setParameters, "A"_a,
274 "B"_a, "C"_a, "D"_a)
275 .def("manual_init", &CPS::EMT::Ph1::SSNTypeV2T::manualInit,
276 "initialState"_a, "initialInput"_a, "initialOldInput"_a,
277 "initCurr"_a, "initVol"_a)
278 .def("connect", &CPS::EMT::Ph1::SSNTypeV2T::connect)
279 .def_property("mA", createAttributeGetter<CPS::Matrix>("mA"),
281 .def_property("mB", createAttributeGetter<CPS::Matrix>("mB"),
283 .def_property("mC", createAttributeGetter<CPS::Matrix>("mC"),
285 .def_property("mD", createAttributeGetter<CPS::Matrix>("mD"),
287 .def_property("mdA", createAttributeGetter<CPS::Matrix>("mdA"),
289 .def_property("mdB", createAttributeGetter<CPS::Matrix>("mdB"),
291 .def_property("mdC", createAttributeGetter<CPS::Matrix>("mdC"),
293}
294
295void addEMTPh3Components(py::module_ mEMTPh3) {
297 std::shared_ptr<CPS::EMT::Ph3::VoltageSource>,
298 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "VoltageSource",
299 py::multiple_inheritance())
300 .def(py::init<std::string>())
301 .def(py::init<std::string, CPS::Logger::Level>())
302 .def("set_parameters",
303 py::overload_cast<CPS::MatrixComp, CPS::Real>(
305 "V_ref"_a, "f_src"_a = 50)
307 .def_property("V_ref", createAttributeGetter<CPS::MatrixComp>("V_ref"),
309 .def_property("f_src", createAttributeGetter<CPS::Real>("f_src"),
311
313 std::shared_ptr<CPS::EMT::Ph3::ControlledVoltageSource>,
314 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "ControlledVoltageSource",
315 py::multiple_inheritance())
316 .def(py::init<std::string>())
317 .def(py::init<std::string, CPS::Logger::Level>())
318 .def("set_parameters",
319 py::overload_cast<CPS::Matrix>(
321 "V_ref"_a)
323 .def_property("V_ref", createAttributeGetter<CPS::MatrixComp>("V_ref"),
325
327 std::shared_ptr<CPS::EMT::Ph3::CurrentSource>,
328 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "CurrentSource",
329 py::multiple_inheritance())
330 .def(py::init<std::string>())
331 .def(py::init<std::string, CPS::Logger::Level>())
332 .def("set_parameters",
333 py::overload_cast<CPS::MatrixComp, CPS::Real>(
335 "I_ref"_a, "f_src"_a = 50)
337 .def_property("I_ref", createAttributeGetter<CPS::MatrixComp>("I_ref"),
339 .def_property("f_src", createAttributeGetter<CPS::Real>("f_src"),
341
342 py::class_<CPS::EMT::Ph3::Resistor, std::shared_ptr<CPS::EMT::Ph3::Resistor>,
343 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "Resistor",
344 py::multiple_inheritance())
345 .def(py::init<std::string>())
346 .def(py::init<std::string, CPS::Logger::Level>())
347 .def("set_parameters", &CPS::EMT::Ph3::Resistor::setParameters, "R"_a)
348 .def("connect", &CPS::EMT::Ph3::Resistor::connect);
349
350 py::class_<CPS::EMT::Ph3::Capacitor,
351 std::shared_ptr<CPS::EMT::Ph3::Capacitor>,
352 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "Capacitor",
353 py::multiple_inheritance())
354 .def(py::init<std::string>())
355 .def(py::init<std::string, CPS::Logger::Level>())
356 .def("set_parameters", &CPS::EMT::Ph3::Capacitor::setParameters, "C"_a)
357 .def("connect", &CPS::EMT::Ph3::Capacitor::connect);
358
359 py::class_<CPS::EMT::Ph3::Inductor, std::shared_ptr<CPS::EMT::Ph3::Inductor>,
360 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "Inductor",
361 py::multiple_inheritance())
362 .def(py::init<std::string>())
363 .def(py::init<std::string, CPS::Logger::Level>())
364 .def("set_parameters", &CPS::EMT::Ph3::Inductor::setParameters, "L"_a)
365 .def("connect", &CPS::EMT::Ph3::Inductor::connect);
366
368 std::shared_ptr<CPS::EMT::Ph3::NetworkInjection>,
369 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "NetworkInjection",
370 py::multiple_inheritance())
371 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
372 "loglevel"_a = CPS::Logger::Level::off)
373 .def("set_parameters",
374 py::overload_cast<CPS::MatrixComp, CPS::Real>(
376 "V_ref"_a, "f_src"_a = 50)
378
379 py::class_<CPS::EMT::Ph3::PiLine, std::shared_ptr<CPS::EMT::Ph3::PiLine>,
380 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "PiLine",
381 py::multiple_inheritance())
382 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
383 "loglevel"_a = CPS::Logger::Level::off)
384 .def("set_parameters", &CPS::EMT::Ph3::PiLine::setParameters,
385 "series_resistance"_a, "series_inductance"_a,
386 "parallel_capacitance"_a = zeroMatrix(3),
387 "parallel_conductance"_a = zeroMatrix(3))
388 .def("connect", &CPS::EMT::Ph3::PiLine::connect);
389
391 std::shared_ptr<CPS::EMT::Ph3::HalfDecouplingLine>,
392 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "HalfDecouplingLine",
393 py::multiple_inheritance())
394 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
395 "loglevel"_a = CPS::Logger::Level::off)
397 "resistance"_a, "inductance"_a, "capacitance"_a)
398 .def("set_coupling_source",
400 "receiving_volt"_a, "receiving_cur"_a)
402
403 py::class_<CPS::EMT::Ph3::RXLoad, std::shared_ptr<CPS::EMT::Ph3::RXLoad>,
404 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "RXLoad",
405 py::multiple_inheritance())
406 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
407 "loglevel"_a = CPS::Logger::Level::off)
408 .def("set_parameters", &CPS::EMT::Ph3::RXLoad::setParameters,
409 "active_power"_a, "reactive_power"_a, "volt"_a,
410 // cppcheck-suppress assignBoolToPointer
411 "reactance_in_series"_a = false)
412 .def("connect", &CPS::EMT::Ph3::RXLoad::connect);
413
414 py::class_<CPS::EMT::Ph3::PQLoad, std::shared_ptr<CPS::EMT::Ph3::PQLoad>,
416 mEMTPh3, "PQLoad", py::multiple_inheritance())
417 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
418 "loglevel"_a = CPS::Logger::Level::off)
419 .def("set_parameters", &CPS::EMT::Ph3::PQLoad::setParameters,
420 "active_power"_a, "reactive_power"_a, "nominal_voltage"_a,
421 "minimum_voltage_per_unit"_a = 0.1)
422 .def("connect", &CPS::EMT::Ph3::PQLoad::connect)
423 .def_property("P", createAttributeGetter<CPS::Real>("P"),
425 .def_property("Q", createAttributeGetter<CPS::Real>("Q"),
427 .def_property("V_nom", createAttributeGetter<CPS::Real>("V_nom"),
429 .def_property("V_min_pu", createAttributeGetter<CPS::Real>("V_min_pu"),
431 .def_property_readonly("p_inst",
433 .def_property_readonly("q_inst",
435
436 py::class_<CPS::EMT::Ph3::Shunt, std::shared_ptr<CPS::EMT::Ph3::Shunt>,
437 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "Shunt",
438 py::multiple_inheritance())
439 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
440 "loglevel"_a = CPS::Logger::Level::off)
441 .def("set_parameters",
442 static_cast<void (CPS::EMT::Ph3::Shunt::*)(CPS::Real, CPS::Real)>(
444 "G"_a, "B"_a)
445 .def("connect", &CPS::EMT::Ph3::Shunt::connect);
446
447 py::class_<CPS::EMT::Ph3::Switch, std::shared_ptr<CPS::EMT::Ph3::Switch>,
449 mEMTPh3, "Switch", py::multiple_inheritance())
450 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
451 "loglevel"_a = CPS::Logger::Level::off)
452 .def("set_parameters", &CPS::EMT::Ph3::Switch::setParameters,
453 "open_resistance"_a, "closed_resistance"_a,
454 // cppcheck-suppress assignBoolToPointer
455 "closed"_a = false)
458 .def("connect", &CPS::EMT::Ph3::Switch::connect);
459
461 std::shared_ptr<CPS::EMT::Ph3::SynchronGeneratorIdeal>,
462 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "SynchronGeneratorIdeal",
463 py::multiple_inheritance())
464 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
465 "loglevel"_a = CPS::Logger::Level::off)
467
469 std::shared_ptr<CPS::EMT::Ph3::SynchronGeneratorDQTrapez>,
470 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "SynchronGeneratorDQTrapez",
471 py::multiple_inheritance())
472 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
473 "loglevel"_a = CPS::Logger::Level::off)
474 .def("set_parameters_operational_per_unit",
476 setParametersOperationalPerUnit,
477 "nom_power"_a, "nom_volt"_a, "nom_freq"_a, "pole_number"_a,
478 "nom_field_cur"_a, "Rs"_a, "Ld"_a, "Lq"_a, "Ld_t"_a, "Lq_t"_a,
479 "Ld_s"_a, "Lq_s"_a, "Ll"_a, "Td0_t"_a, "Tq0_t"_a, "Td0_s"_a,
480 "Tq0_s"_a, "inertia"_a)
481 .def("set_parameters_fundamental_per_unit",
483 setParametersFundamentalPerUnit,
484 "nom_power"_a, "nom_volt"_a, "nom_freq"_a, "pole_number"_a,
485 "nom_field_cur"_a, "Rs"_a, "Ll"_a, "Lmd"_a, "Lmq"_a, "Rfd"_a,
486 "Llfd"_a, "Rkd"_a, "Llkd"_a, "Rkq1"_a, "Llkq1"_a, "Rkq2"_a,
487 "Llkq2"_a, "inertia"_a, "init_active_power"_a,
488 "init_reactive_power"_a, "init_terminal_volt"_a, "init_volt_angle"_a,
489 "init_mech_power"_a)
490#ifdef WITH_JSON
491 .def("apply_parameters_from_json",
492 [](std::shared_ptr<CPS::EMT::Ph3::SynchronGeneratorDQTrapez> syngen,
493 const CPS::String json) {
494 DPsim::Utils::applySynchronousGeneratorParametersFromJson(
495 json::parse(json), syngen);
496 })
497#endif
498 .def("set_initial_values",
500 "init_active_power"_a, "init_reactive_power"_a,
501 "init_terminal_volt"_a, "init_volt_angle"_a, "init_mech_power"_a);
502
504 std::shared_ptr<CPS::EMT::Ph3::VSIVoltageControlVCO>,
505 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "VSIVoltageControlVCO",
506 py::multiple_inheritance())
507 .def(py::init<std::string>())
508 .def(py::init<std::string, CPS::Logger::Level>())
509 .def(py::init<std::string, std::string, CPS::Logger::Level, CPS::Bool>(),
510 "uid"_a, "name"_a, "log_level"_a = CPS::Logger::Level::off,
511 py::arg("with_trafo") = false)
512 .def("set_parameters",
514 "vd_ref"_a, "vq_ref"_a)
515 .def("set_controller_parameters",
517 "kp_voltage_ctrl"_a, "ki_voltage_ctrl"_a, "kp_curr_ctrl"_a,
518 "ki_curr_ctrl"_a, "omega_nominal"_a)
519 .def("set_transformer_parameters",
521 "nom_voltage_end1"_a, "nom_voltage_end2"_a, "rated_power"_a,
522 "ratio_abs"_a, "ratio_phase"_a, "resistance"_a, "inductance"_a,
523 "omega"_a)
524 .def("set_filter_parameters",
526 "cf"_a, "rf"_a, "rc"_a)
527 .def("set_initial_state_values",
529 "phi_d_init"_a, "phi_q_init"_a, "gamma_d_init"_a, "gamma_q_init"_a)
531 "control_on"_a)
533
535 std::shared_ptr<CPS::EMT::Ph3::ReducedOrderSynchronGeneratorVBR>,
537 mEMTPh3, "ReducedOrderSynchronGeneratorVBR", py::multiple_inheritance());
538
540 std::shared_ptr<CPS::EMT::Ph3::SynchronGenerator3OrderVBR>,
542 mEMTPh3, "SynchronGenerator3OrderVBR", py::multiple_inheritance())
543 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
544 "loglevel"_a = CPS::Logger::Level::off)
545 .def("set_operational_parameters_per_unit",
546 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
548 CPS::Real>(
550 setOperationalParametersPerUnit),
551 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
552 "Lq"_a, "L0"_a, "Ld_t"_a, "Td0_t"_a)
554
556 std::shared_ptr<CPS::EMT::Ph3::SynchronGenerator4OrderVBR>,
558 mEMTPh3, "SynchronGenerator4OrderVBR", py::multiple_inheritance())
559 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
560 "loglevel"_a = CPS::Logger::Level::off)
561 .def("set_operational_parameters_per_unit",
562 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
566 setOperationalParametersPerUnit),
567 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
568 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a)
570
572 std::shared_ptr<CPS::EMT::Ph3::SynchronGenerator5OrderVBR>,
574 mEMTPh3, "SynchronGenerator5OrderVBR", py::multiple_inheritance())
575 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
576 "loglevel"_a = CPS::Logger::Level::off)
577 .def("set_operational_parameters_per_unit",
578 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
583 setOperationalParametersPerUnit),
584 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
585 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a, "Ld_s"_a,
586 "Lq_s"_a, "Td0_s"_a, "Tq0_s"_a, "Taa"_a)
588
590 std::shared_ptr<CPS::EMT::Ph3::SynchronGenerator6aOrderVBR>,
592 mEMTPh3, "SynchronGenerator6aOrderVBR", py::multiple_inheritance())
593 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
594 "loglevel"_a = CPS::Logger::Level::off)
595 .def("set_operational_parameters_per_unit",
596 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
601 setOperationalParametersPerUnit),
602 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
603 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a, "Ld_s"_a,
604 "Lq_s"_a, "Td0_s"_a, "Tq0_s"_a, "Taa"_a)
606
608 std::shared_ptr<CPS::EMT::Ph3::SynchronGenerator6bOrderVBR>,
610 mEMTPh3, "SynchronGenerator6bOrderVBR", py::multiple_inheritance())
611 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
612 "loglevel"_a = CPS::Logger::Level::off)
613 .def("set_operational_parameters_per_unit",
614 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
619 setOperationalParametersPerUnit),
620 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
621 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a, "Ld_s"_a,
622 "Lq_s"_a, "Td0_s"_a, "Tq0_s"_a, "Taa"_a = 0)
624
625#ifdef WITH_SUNDIALS
626
628 std::shared_ptr<CPS::EMT::Ph3::SynchronGeneratorDQODE>,
629 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "SynchronGeneratorDQODE",
630 py::multiple_inheritance())
631 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
632 "loglevel"_a = CPS::Logger::Level::off)
633 .def("set_parameters_operational_per_unit",
635 setParametersOperationalPerUnit,
636 "nom_power"_a, "nom_volt"_a, "nom_freq"_a, "pole_number"_a,
637 "nom_field_cur"_a, "Rs"_a, "Ld"_a, "Lq"_a, "Ld_t"_a, "Lq_t"_a,
638 "Ld_s"_a, "Lq_s"_a, "Ll"_a, "Td0_t"_a, "Tq0_t"_a, "Td0_s"_a,
639 "Tq0_s"_a, "inertia"_a)
640 .def("set_parameters_fundamental_per_unit",
642 setParametersFundamentalPerUnit,
643 "nom_power"_a, "nom_volt"_a, "nom_freq"_a, "pole_number"_a,
644 "nom_field_cur"_a, "Rs"_a, "Ll"_a, "Lmd"_a, "Lmq"_a, "Rfd"_a,
645 "Llfd"_a, "Rkd"_a, "Llkd"_a, "Rkq1"_a, "Llkq1"_a, "Rkq2"_a,
646 "Llkq2"_a, "inertia"_a, "init_active_power"_a,
647 "init_reactive_power"_a, "init_terminal_volt"_a, "init_volt_angle"_a,
648 "init_mech_power"_a)
649#ifdef WITH_JSON
650 .def("apply_parameters_from_json",
651 [](std::shared_ptr<CPS::EMT::Ph3::SynchronGeneratorDQODE> syngen,
652 const CPS::String json) {
653 DPsim::Utils::applySynchronousGeneratorParametersFromJson(
654 json::parse(json), syngen);
655 })
656#endif
657 .def("set_initial_values",
659 "init_active_power"_a, "init_reactive_power"_a,
660 "init_terminal_volt"_a, "init_volt_angle"_a, "init_mech_power"_a);
661
662#endif
663
665 std::shared_ptr<CPS::EMT::Ph3::AvVoltageSourceInverterDQ>,
666 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "AvVoltageSourceInverterDQ",
667 py::multiple_inheritance())
668 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
669 "loglevel"_a = CPS::Logger::Level::off)
670 .def(py::init<std::string, std::string, CPS::Logger::Level, CPS::Bool>(),
671 "uid"_a, "name"_a, "loglevel"_a = CPS::Logger::Level::off,
672 // cppcheck-suppress assignBoolToPointer
673 "with_trafo"_a = false)
674 .def("set_parameters",
676 "sys_omega"_a, "sys_volt_nom"_a, "p_ref"_a, "q_ref"_a)
677 .def("set_filter_parameters",
679 "Lf"_a, "Cf"_a, "Rf"_a, "Rc"_a)
680 .def("set_controller_parameters",
682 "Kp_pll"_a, "Ki_pll"_a, "Kp_power_ctrl"_a, "Ki_power_ctrl"_a,
683 "Kp_curr_ctrl"_a, "Ki_curr_ctrl"_a, "omega_cutoff"_a)
684 .def("set_transformer_parameters",
686 "nom_voltage_end_1"_a, "nom_voltage_end_2"_a, "rated_power"_a,
687 "ratio_abs"_a, "ratio_phase"_a, "resistance"_a, "inductance"_a,
688 "omega"_a)
689 .def("set_initial_state_values",
691 "p_init"_a, "q_init"_a, "phi_d_init"_a, "phi_q_init"_a,
692 "gamma_d_init"_a, "gamma_q_init"_a)
693 .def("with_control",
696
698 std::shared_ptr<CPS::EMT::Ph3::Transformer>,
699 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "Transformer",
700 py::multiple_inheritance())
701 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
702 "loglevel"_a = CPS::Logger::Level::off)
703 .def(py::init<std::string, std::string, CPS::Logger::Level, CPS::Bool>(),
704 "uid"_a, "name"_a, "loglevel"_a = CPS::Logger::Level::off,
705 // cppcheck-suppress assignBoolToPointer
706 "with_resistive_losses"_a = false)
707 .def("set_parameters", &CPS::EMT::Ph3::Transformer::setParameters,
708 "nom_voltage_end_1"_a, "nom_voltage_end_2"_a, "rated_power"_a,
709 "ratio_abs"_a, "ratio_phase"_a, "resistance"_a, "inductance"_a)
710 .def("connect", &CPS::EMT::Ph3::Transformer::connect);
711
713 std::shared_ptr<CPS::EMT::Ph3::SeriesResistor>,
714 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "SeriesResistor",
715 py::multiple_inheritance())
716 .def(py::init<std::string>())
717 .def(py::init<std::string, CPS::Logger::Level>())
718 .def("set_parameters", &CPS::EMT::Ph3::SeriesResistor::setParameters,
719 "R"_a)
721
723 std::shared_ptr<CPS::EMT::Ph3::SeriesSwitch>,
725 mEMTPh3, "SeriesSwitch", py::multiple_inheritance())
726 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
727 "loglevel"_a = CPS::Logger::Level::off)
728 .def("set_parameters", &CPS::EMT::Ph3::SeriesSwitch::setParameters,
729 "open_resistance"_a, "closed_resistance"_a,
730 // cppcheck-suppress assignBoolToPointer
731 "closed"_a = false)
734 .def("connect", &CPS::EMT::Ph3::SeriesSwitch::connect);
735
737 std::shared_ptr<CPS::EMT::Ph3::SSN::Full_Serial_RLC>,
738 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "Full_Serial_RLC",
739 py::multiple_inheritance())
740 .def(py::init<std::string>())
741 .def(py::init<std::string, CPS::Logger::Level>())
742 .def("set_parameters",
744 "C"_a)
746 .def_property("R", createAttributeGetter<CPS::Matrix>("R"),
748 .def_property("L", createAttributeGetter<CPS::Matrix>("L"),
750 .def_property("C", createAttributeGetter<CPS::Matrix>("C"),
752
754 std::shared_ptr<CPS::EMT::Ph3::GenericTwoTerminalVTypeSSN>,
756 mEMTPh3, "GenericTwoTerminalVTypeSSN", py::multiple_inheritance())
757 .def(py::init<std::string>())
758 .def(py::init<std::string, CPS::Logger::Level>())
759 .def("set_parameters",
761 "B"_a, "C"_a, "D"_a)
763 .def_property_readonly("x", createAttributeGetter<CPS::Matrix>("x"));
764
766 std::shared_ptr<CPS::EMT::Ph3::GenericTwoTerminalITypeSSN>,
768 mEMTPh3, "GenericTwoTerminalITypeSSN", py::multiple_inheritance())
769 .def(py::init<std::string>())
770 .def(py::init<std::string, CPS::Logger::Level>())
771 .def("set_parameters",
773 "B"_a, "C"_a, "D"_a)
775 .def_property_readonly("x", createAttributeGetter<CPS::Matrix>("x"));
776
778 std::shared_ptr<CPS::EMT::Ph3::PiecewiseLinearInductor>,
779 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "PiecewiseLinearInductor",
780 py::multiple_inheritance())
781 .def(py::init<std::string>())
782 .def(py::init<std::string, CPS::Logger::Level>())
783 .def("set_parameters",
785 "flux_breakpoints"_a, "current_breakpoints"_a)
787 .def_property_readonly("x", createAttributeGetter<CPS::Matrix>("x"));
788
789 // -----------------------------------------------------------------------
790 // Grid-following converter models
791 // -----------------------------------------------------------------------
792
793 py::class_<CPS::EMT::Ph3::GFL, std::shared_ptr<CPS::EMT::Ph3::GFL>,
794 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "GFL",
795 py::multiple_inheritance())
796 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
797 "loglevel"_a = CPS::Logger::Level::off)
798 .def(py::init<std::string, std::string, CPS::Logger::Level>(), "uid"_a,
799 "name"_a, "loglevel"_a = CPS::Logger::Level::off)
800 .def("set_parameters", &CPS::EMT::Ph3::GFL::setParameters, "sys_omega"_a,
801 "sys_volt_nom"_a, "p_ref"_a, "q_ref"_a)
802 .def("set_controller_parameters",
803 &CPS::EMT::Ph3::GFL::setControllerParameters, "kp_pll"_a, "ki_pll"_a,
804 "kp_power_ctrl"_a, "ki_power_ctrl"_a, "kp_curr_ctrl"_a,
805 "ki_curr_ctrl"_a, "omega_cutoff"_a)
806 .def("set_filter_parameters", &CPS::EMT::Ph3::GFL::setFilterParameters,
807 "lf"_a, "cf"_a, "rf"_a)
808 .def("set_initial_state_values",
809 &CPS::EMT::Ph3::GFL::setInitialStateValues, "p_init"_a, "q_init"_a,
810 "phi_d_init"_a, "phi_q_init"_a, "gamma_d_init"_a, "gamma_q_init"_a)
811 .def("with_control", &CPS::EMT::Ph3::GFL::withControl, "control_on"_a)
812 .def("connect", &CPS::EMT::Ph3::GFL::connect)
813 .def_property_readonly("vc_d", createAttributeGetter<CPS::Real>("vc_d"))
814 .def_property_readonly("vc_q", createAttributeGetter<CPS::Real>("vc_q"))
815 .def_property_readonly("igrid_d",
817 .def_property_readonly("igrid_q",
819 .def_property_readonly("p_inst",
821 .def_property_readonly("q_inst",
823 .def_property_readonly("omega_pll",
825 .def_property_readonly("vs_ref",
827 .def_property_readonly("vs", createAttributeGetter<CPS::Matrix>("vs"))
828 .def_property_readonly("pll_output",
830 .def_property_readonly(
831 "powerctrl_inputs",
832 createAttributeGetter<CPS::Matrix>("powerctrl_inputs"))
833 .def_property_readonly(
834 "powerctrl_states",
835 createAttributeGetter<CPS::Matrix>("powerctrl_states"))
836 .def_property_readonly(
837 "powerctrl_outputs",
838 createAttributeGetter<CPS::Matrix>("powerctrl_outputs"));
839
840 py::class_<CPS::EMT::Ph3::SSN_GFL, std::shared_ptr<CPS::EMT::Ph3::SSN_GFL>,
841 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "SSN_GFL",
842 py::multiple_inheritance())
843 .def(py::init<std::string, std::string, CPS::Logger::Level>(), "uid"_a,
844 "name"_a, "loglevel"_a = CPS::Logger::Level::off)
845 .def("set_parameters", &CPS::EMT::Ph3::SSN_GFL::setParameters, "lf"_a,
846 "cf"_a, "rf"_a, "rc"_a, "omega_n"_a, "kp_pll"_a, "ki_pll"_a,
847 "omega_cutoff"_a, "p_ref"_a, "q_ref"_a, "kp_power_ctrl"_a,
848 "ki_power_ctrl"_a, "kp_curr_ctrl"_a, "ki_curr_ctrl"_a)
849 .def("connect", &CPS::EMT::Ph3::SSN_GFL::connect)
850 .def("get_state_names", &CPS::EMT::Ph3::SSN_GFL::getLocalStateNames)
851 .def("get_state", &CPS::EMT::Ph3::SSN_GFL::getState)
852 .def("get_state_derivative", &CPS::EMT::Ph3::SSN_GFL::getStateDerivative)
853 .def("get_interface_voltage",
855 .def("get_interface_current",
857 .def_property_readonly("vc_d", createAttributeGetter<CPS::Real>("vc_d"))
858 .def_property_readonly("vc_q", createAttributeGetter<CPS::Real>("vc_q"))
859 .def_property_readonly("irc_d", createAttributeGetter<CPS::Real>("irc_d"))
860 .def_property_readonly("irc_q", createAttributeGetter<CPS::Real>("irc_q"))
861 .def_property_readonly("p_inst",
863 .def_property_readonly("q_inst",
865 .def_property_readonly("omega_pll",
867
869 std::shared_ptr<CPS::EMT::Ph3::SSN_GFL_Split>,
870 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "SSN_GFL_Split",
871 py::multiple_inheritance())
872 .def(py::init<std::string, std::string, CPS::Logger::Level>(), "uid"_a,
873 "name"_a, "loglevel"_a = CPS::Logger::Level::off)
874 .def("set_parameters", &CPS::EMT::Ph3::SSN_GFL_Split::setParameters,
875 "lf"_a, "cf"_a, "rf"_a, "rc"_a, "omega_n"_a, "kp_pll"_a, "ki_pll"_a,
876 "omega_cutoff"_a, "p_ref"_a, "q_ref"_a, "kp_power_ctrl"_a,
877 "ki_power_ctrl"_a, "kp_curr_ctrl"_a, "ki_curr_ctrl"_a)
879
880 // Combined controller + network state.
882 .def("get_state_derivative",
884
885 // Split state access.
886 .def("get_controller_state",
888 .def("get_network_state", &CPS::EMT::Ph3::SSN_GFL_Split::getNetworkState)
889 .def("get_network_state_names",
891
892 // Electrical interface / delayed forcing.
893 .def("get_interface_voltage",
895 .def("get_interface_current",
897 .def("get_converter_voltage_reference",
899 .def("get_delayed_converter_voltage",
901
902 // Controller affine model.
903 .def("get_controller_A", &CPS::EMT::Ph3::SSN_GFL_Split::getControllerA)
904 .def("get_controller_B", &CPS::EMT::Ph3::SSN_GFL_Split::getControllerB)
905 .def("get_controller_C", &CPS::EMT::Ph3::SSN_GFL_Split::getControllerC)
906 .def("get_controller_D", &CPS::EMT::Ph3::SSN_GFL_Split::getControllerD)
907 .def("get_controller_E", &CPS::EMT::Ph3::SSN_GFL_Split::getControllerE)
908 .def("get_controller_F", &CPS::EMT::Ph3::SSN_GFL_Split::getControllerF)
909
910 // Fixed electrical SSN plant.
911 .def("get_network_A", &CPS::EMT::Ph3::SSN_GFL_Split::getNetworkA)
912 .def("get_network_B", &CPS::EMT::Ph3::SSN_GFL_Split::getNetworkB)
913 .def("get_network_C", &CPS::EMT::Ph3::SSN_GFL_Split::getNetworkC)
914 .def("get_network_D", &CPS::EMT::Ph3::SSN_GFL_Split::getNetworkD)
915 .def("get_equivalent_conductance",
917
918 // Logged scalar quantities.
919 .def_property_readonly("vc_d", createAttributeGetter<CPS::Real>("vc_d"))
920 .def_property_readonly("vc_q", createAttributeGetter<CPS::Real>("vc_q"))
921 .def_property_readonly("irc_d", createAttributeGetter<CPS::Real>("irc_d"))
922 .def_property_readonly("irc_q", createAttributeGetter<CPS::Real>("irc_q"))
923 .def_property_readonly("p_inst",
925 .def_property_readonly("q_inst",
927 .def_property_readonly("omega_pll",
929 .def_property_readonly("vinv_ref_a",
931 .def_property_readonly("vinv_ref_b",
933 .def_property_readonly("vinv_ref_c",
935
937 std::shared_ptr<CPS::EMT::Ph3::AvVoltSourceInverterStateSpace>,
939 mEMTPh3, "AvVoltSourceInverterStateSpace", py::multiple_inheritance())
940 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
941 "loglevel"_a = CPS::Logger::Level::off)
942 .def(py::init<std::string, std::string, CPS::Logger::Level>(), "uid"_a,
943 "name"_a, "loglevel"_a = CPS::Logger::Level::off)
944 .def("set_parameters",
946 "Lf"_a, "Cf"_a, "Rf"_a, "Rc"_a, "omega_n"_a, "Kp_pll"_a, "Ki_pll"_a,
947 "omega_cutoff"_a, "p_ref"_a, "q_ref"_a, "Kp_power_ctrl"_a,
948 "Ki_power_ctrl"_a, "Kp_curr_ctrl"_a, "Ki_curr_ctrl"_a)
950 .def_property_readonly("x", createAttributeGetter<CPS::Matrix>("x"))
951 .def_property_readonly("vc_d", createAttributeGetter<CPS::Real>("vc_d"))
952 .def_property_readonly("vc_q", createAttributeGetter<CPS::Real>("vc_q"))
953 .def_property_readonly("irc_d", createAttributeGetter<CPS::Real>("irc_d"))
954 .def_property_readonly("irc_q", createAttributeGetter<CPS::Real>("irc_q"))
955 .def_property_readonly("p_inst",
957 .def_property_readonly("q_inst",
959 .def_property_readonly("omega_pll",
961
962 py::class_<CPS::EMT::Ph3::SSN_GFM, std::shared_ptr<CPS::EMT::Ph3::SSN_GFM>,
963 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "SSN_GFM",
964 py::multiple_inheritance())
965 .def(py::init<std::string, std::string, CPS::Logger::Level>(), "uid"_a,
966 "name"_a, "log_level"_a = CPS::Logger::Level::off)
967 .def("set_parameters", &CPS::EMT::Ph3::SSN_GFM::setParameters, "lf"_a,
968 "cf"_a, "rf"_a, "rc"_a, "nominal_voltage"_a, "omega_nominal"_a,
969 "p_ref"_a, "q_ref"_a, "virtual_inertia"_a, "damping_coefficient"_a,
970 "voltage_droop_gain"_a, "reactive_integral_gain"_a, "kp_voltage"_a,
971 "ki_voltage"_a, "kp_current"_a, "ki_current"_a,
972 "active_damping_gain"_a, "power_filter_cutoff"_a,
973 "delay_bandwidth"_a)
974 .def("set_numerical_linearization_parameters",
976 "relative_step"_a = 1e-6, "absolute_step"_a = 1e-8)
977 .def("set_virtual_impedance",
978 &CPS::EMT::Ph3::SSN_GFM::setVirtualImpedance, "virtual_resistance"_a,
979 "virtual_reactance"_a = 0.0)
980 .def("set_grid_current_feedforward",
982 .def("set_reactive_power_droop",
984 "cutoff"_a)
985 .def("connect", &CPS::EMT::Ph3::SSN_GFM::connect)
986 .def("get_state_names", &CPS::EMT::Ph3::SSN_GFM::getLocalStateNames)
987 .def("get_state", &CPS::EMT::Ph3::SSN_GFM::getState)
988 .def("get_state_derivative", &CPS::EMT::Ph3::SSN_GFM::getStateDerivative)
989 .def("get_interface_voltage",
991 .def("get_interface_current",
993 .def_property_readonly("p_inst",
995 .def_property_readonly("q_inst",
997 .def_property_readonly("omega_gfm",
999 .def_property_readonly("theta_gfm",
1001 .def_property_readonly(
1002 "voltage_magnitude_gfm",
1003 createAttributeGetter<CPS::Real>("voltage_magnitude_gfm"))
1004 .def_property_readonly("vc_d", createAttributeGetter<CPS::Real>("vc_d"))
1005 .def_property_readonly("vc_q", createAttributeGetter<CPS::Real>("vc_q"))
1006 .def_property_readonly("i_grid_d",
1008 .def_property_readonly("i_grid_q",
1010 .def_property_readonly("if_d", createAttributeGetter<CPS::Real>("if_d"))
1011 .def_property_readonly("if_q", createAttributeGetter<CPS::Real>("if_q"))
1012 .def_property_readonly("v_ref_d",
1014 .def_property_readonly("v_ref_q",
1016
1018 std::shared_ptr<CPS::EMT::Ph3::SSN::Capacitor>,
1019 CPS::SimPowerComp<CPS::Real>>(mEMTPh3, "SSN_Capacitor",
1020 py::multiple_inheritance())
1021 .def(py::init<std::string>())
1022 .def(py::init<std::string, CPS::Logger::Level>())
1023 .def("set_parameters", &CPS::EMT::Ph3::SSN::Capacitor::setParameters,
1024 "C"_a)
1026 .def_property("C", createAttributeGetter<CPS::Matrix>("C"),
1028
1030 std::shared_ptr<CPS::EMT::Ph3::GenericFourTerminalVTypeSSN>,
1032 mEMTPh3, "GenericFourTerminalVTypeSSN", py::multiple_inheritance())
1033 .def(py::init<std::string>())
1034 .def(py::init<std::string, CPS::Logger::Level>())
1035 .def("set_parameters",
1037 "B"_a, "C"_a, "D"_a)
1039 .def_property_readonly("x", createAttributeGetter<CPS::Matrix>("x"));
1040}
PYBIND11_DECLARE_HOLDER_TYPE(T, CPS::AttributePointer< T >)
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.
Common base for three-phase switches.
void setParameters(Matrix openResistance, Matrix closedResistance, Bool closed=false)
void setInitialValues(Real initActivePower, Real initReactivePower, Real initTerminalVolt, Real initVoltAngle, Real initMechPower)
void setParameters(Real capacitance)
void setParameters(Real inductance, Real initialCurrent=0.0)
void setParameters(Real seriesResistance, Real seriesInductance, Real parallelCapacitance=0.0, Real parallelConductance=0.0, Real initialCurrent=0.0)
void setParameters(Real resistance)
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.
void setInitialStateValues(Real pInit, Real qInit, Real phiDInit, Real phiQInit, Real gammaDInit, Real gammaQInit)
void setFilterParameters(Real lf, Real cf, Real rf)
Filter parameters. No Rc exists in this model.
void setControllerParameters(Real kpPLL, Real kiPLL, Real kpPowerCtrl, Real kiPowerCtrl, Real kpCurrCtrl, Real kiCurrCtrl, Real omegaCutoff)
Controller parameters.
void setParameters(Real sysOmega, Real sysVoltNom, Real pRef, Real qRef)
General operating parameters.
void withControl(Bool controlOn)
Concrete generic three-phase, two-terminal I-type SSN component.
Concrete generic three-phase, two-terminal V-type SSN component.
One end of a Bergeron travelling-wave line. Two of these replace a single Signal::DecouplingLineEMT_P...
void setParameters(Matrix resistance, Matrix inductance, Matrix capacitance)
Line data. Give the parameters of the whole line, not of this half.
void setCouplingSource(Attribute< Matrix >::Ptr receivingVolt, Attribute< Matrix >::Ptr receivingCur)
void setParameters(MatrixComp voltageRef, Real srcFreq=50.0)
Setter for reference voltage parameters.
void setParameters(Real activePower, Real reactivePower, Real nominalVoltage, Real minimumVoltagePerUnit=0.1)
Sets total three-phase P/Q, nominal line-to-line voltage and voltage floor.
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)
Partitioned three-phase grid-following inverter.
Matrix getState() const
Combined state in the same logical order as the former monolithic GFL: 8 controller states followed b...
Matrix getEquivalentConductance() const
Constant SSN Norton conductance G = mW.
std::vector< String > getLocalStateNames() const override final
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)
Configure the filter, PLL, power controller and current controller.
Matrix getInterfaceVoltage() const
std::vector< String > getLocalStateNames() const override final
Matrix getInterfaceCurrent() const
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)
Configure the GFL filter, PLL, power loop and current loop.
Matrix getStateDerivative() const
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.
void closeSwitch() override
void openSwitch() override
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)
Interface to be used by synchronous generators.
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