DPsim
Loading...
Searching...
No Matches
DPComponents.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
17namespace py = pybind11;
18using namespace pybind11::literals;
19
20void addDPComponents(py::module_ mDP) {
21 py::class_<CPS::DP::SimNode, std::shared_ptr<CPS::DP::SimNode>,
22 CPS::TopologicalNode>(mDP, "SimNode", py::module_local())
23 .def(py::init<std::string>())
24 .def(py::init<std::string, CPS::PhaseType>())
25 .def(py::init<std::string, CPS::PhaseType,
26 const std::vector<CPS::Complex>>())
27 .def("set_initial_voltage",
28 py::overload_cast<CPS::MatrixComp>(
30 .def("set_initial_voltage",
31 py::overload_cast<CPS::Complex>(&CPS::DP::SimNode::setInitialVoltage,
32 py::const_))
33 .def("set_initial_voltage",
34 py::overload_cast<CPS::Complex, int>(
36 .def("single_voltage", &CPS::DP::SimNode::singleVoltage,
37 "phase_type"_a = CPS::PhaseType::Single)
38 .def_readonly_static("gnd", &CPS::DP::SimNode::GND);
39
40 py::module mDPPh1 =
41 mDP.def_submodule("ph1", "single phase dynamic phasor models");
42 addDPPh1Components(mDPPh1);
43
44 py::module mDPPh3 =
45 mDP.def_submodule("ph3", "triple phase dynamic phasor models");
46 addDPPh3Components(mDPPh3);
47}
48
49void addDPPh1Components(py::module_ mDPPh1) {
51 std::shared_ptr<CPS::DP::Ph1::VoltageSource>,
52 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "VoltageSource",
53 py::multiple_inheritance())
54 .def(py::init<std::string>())
55 .def(py::init<std::string, CPS::Logger::Level>())
56 .def("set_parameters",
57 py::overload_cast<CPS::Complex, CPS::Real>(
59 "V_ref"_a, "f_src"_a = 0)
61 .def_property("V_ref", createAttributeGetter<CPS::Complex>("V_ref"),
63 .def_property("f_src", createAttributeGetter<CPS::Real>("f_src"),
65
67 std::shared_ptr<CPS::DP::Ph1::VoltageSourceNorton>,
68 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "VoltageSourceNorton",
69 py::multiple_inheritance())
70 .def(py::init<std::string>())
71 .def(py::init<std::string, CPS::Logger::Level>())
72 .def("set_parameters",
73 static_cast<void (CPS::Base::Ph1::VoltageSource::*)(CPS::Complex,
74 CPS::Real)>(
76 py::arg("voltageRef"), py::arg("srcFreq") = -1)
77 .def("set_parameters",
78 static_cast<void (CPS::DP::Ph1::VoltageSourceNorton::*)(
81 py::arg("voltageRef"), py::arg("srcFreq") = -1,
82 py::arg("resistance") = 1e9)
84
86 std::shared_ptr<CPS::DP::Ph1::CurrentSource>,
87 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "CurrentSource",
88 py::multiple_inheritance())
89 .def(py::init<std::string>())
90 .def(py::init<std::string, CPS::Logger::Level>())
91 .def("set_parameters", &CPS::DP::Ph1::CurrentSource::setParameters,
92 "I_ref"_a)
94 .def_property("I_ref", createAttributeGetter<CPS::Complex>("I_ref"),
96
97 py::class_<CPS::DP::Ph1::Resistor, std::shared_ptr<CPS::DP::Ph1::Resistor>,
98 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "Resistor",
99 py::multiple_inheritance())
100 .def(py::init<std::string>())
101 .def(py::init<std::string, CPS::Logger::Level>())
102 .def("set_parameters", &CPS::DP::Ph1::Resistor::setParameters, "R"_a)
103 .def("connect", &CPS::DP::Ph1::Resistor::connect)
104 .def_property("R", createAttributeGetter<CPS::Real>("R"),
106
107 py::class_<CPS::DP::Ph1::Capacitor, std::shared_ptr<CPS::DP::Ph1::Capacitor>,
108 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "Capacitor",
109 py::multiple_inheritance())
110 .def(py::init<std::string>())
111 .def(py::init<std::string, CPS::Logger::Level>())
112 .def("set_parameters", &CPS::DP::Ph1::Capacitor::setParameters, "C"_a)
113 .def("connect", &CPS::DP::Ph1::Capacitor::connect)
114 .def_property("C", createAttributeGetter<CPS::Real>("C"),
116
117 py::class_<CPS::DP::Ph1::Inductor, std::shared_ptr<CPS::DP::Ph1::Inductor>,
118 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "Inductor",
119 py::multiple_inheritance())
120 .def(py::init<std::string>())
121 .def(py::init<std::string, CPS::Logger::Level>())
122 .def("set_parameters", &CPS::DP::Ph1::Inductor::setParameters, "L"_a)
123 .def("connect", &CPS::DP::Ph1::Inductor::connect)
124 .def_property("L", createAttributeGetter<CPS::Real>("L"),
126
128 std::shared_ptr<CPS::DP::Ph1::NetworkInjection>,
129 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "NetworkInjection",
130 py::multiple_inheritance())
131 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
132 "loglevel"_a = CPS::Logger::Level::off)
133 .def("set_parameters",
134 py::overload_cast<CPS::Complex, CPS::Real>(
136 "V_ref"_a, "f_src"_a = 0)
138
139 py::class_<CPS::DP::Ph1::PiLine, std::shared_ptr<CPS::DP::Ph1::PiLine>,
140 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "PiLine",
141 py::multiple_inheritance())
142 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
143 "loglevel"_a = CPS::Logger::Level::off)
144 .def("set_parameters", &CPS::DP::Ph1::PiLine::setParameters,
145 "series_resistance"_a, "series_inductance"_a,
146 "parallel_capacitance"_a = 0, "parallel_conductance"_a = 0)
147 .def("connect", &CPS::DP::Ph1::PiLine::connect);
148
149 py::class_<CPS::DP::Ph1::RXLoad, std::shared_ptr<CPS::DP::Ph1::RXLoad>,
150 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "RXLoad",
151 py::multiple_inheritance())
152 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
153 "loglevel"_a = CPS::Logger::Level::off)
154 .def("set_parameters", &CPS::DP::Ph1::RXLoad::setParameters,
155 "active_power"_a, "reactive_power"_a, "volt"_a)
156 .def("connect", &CPS::DP::Ph1::RXLoad::connect);
157
158 py::class_<CPS::DP::Ph1::Shunt, std::shared_ptr<CPS::DP::Ph1::Shunt>,
159 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "Shunt",
160 py::multiple_inheritance())
161 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
162 "loglevel"_a = CPS::Logger::Level::off)
163 .def("set_parameters", &CPS::DP::Ph1::Shunt::setParameters, "G"_a, "B"_a)
164 .def("connect", &CPS::DP::Ph1::Shunt::connect);
165
166 py::class_<CPS::DP::Ph1::Switch, std::shared_ptr<CPS::DP::Ph1::Switch>,
168 mDPPh1, "Switch", py::multiple_inheritance())
169 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
170 "loglevel"_a = CPS::Logger::Level::off)
171 .def("set_parameters", &CPS::DP::Ph1::Switch::setParameters,
172 "open_resistance"_a, "closed_resistance"_a,
173 // cppcheck-suppress assignBoolToPointer
174 "closed"_a = false)
175 .def("open", &CPS::DP::Ph1::Switch::open)
176 .def("close", &CPS::DP::Ph1::Switch::close)
177 .def("connect", &CPS::DP::Ph1::Switch::connect);
178
180 std::shared_ptr<CPS::DP::Ph1::varResSwitch>,
182 mDPPh1, "varResSwitch", py::multiple_inheritance())
183 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
184 "loglevel"_a = CPS::Logger::Level::off)
185 .def("set_parameters", &CPS::DP::Ph1::varResSwitch::setParameters,
186 "open_resistance"_a, "closed_resistance"_a,
187 // cppcheck-suppress assignBoolToPointer
188 "closed"_a = false)
191 .def("set_init_parameters",
193 .def("connect", &CPS::DP::Ph1::varResSwitch::connect);
194
196 std::shared_ptr<CPS::DP::Ph1::SSN::Full_Serial_RLC>,
197 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "Full_Serial_RLC",
198 py::multiple_inheritance())
199 .def(py::init<std::string>())
200 .def(py::init<std::string, CPS::Logger::Level>())
202 "R"_a, "L"_a, "C"_a)
204
206 std::shared_ptr<CPS::DP::Ph1::AvVoltSourceInverterStateSpace>,
208 mDPPh1, "AvVoltSourceInverterStateSpace", py::multiple_inheritance())
209 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
210 "loglevel"_a = CPS::Logger::Level::off)
211 .def(py::init<std::string, std::string, CPS::Logger::Level>(), "uid"_a,
212 "name"_a, "loglevel"_a = CPS::Logger::Level::off)
213 .def("set_parameters",
215 "Cf"_a, "Rf"_a, "Rc"_a, "omega_n"_a, "Kp_pll"_a, "Ki_pll"_a,
216 "omega_cutoff"_a, "p_ref"_a, "q_ref"_a, "Kp_power_ctrl"_a,
217 "Ki_power_ctrl"_a, "Kp_curr_ctrl"_a, "Ki_curr_ctrl"_a)
219 .def_property_readonly("x", createAttributeGetter<CPS::Matrix>("x"))
220 .def_property_readonly("vc_d", createAttributeGetter<CPS::Real>("vc_d"))
221 .def_property_readonly("vc_q", createAttributeGetter<CPS::Real>("vc_q"))
222 .def_property_readonly("irc_d", createAttributeGetter<CPS::Real>("irc_d"))
223 .def_property_readonly("irc_q", createAttributeGetter<CPS::Real>("irc_q"))
224 .def_property_readonly("p_inst",
226 .def_property_readonly("q_inst",
228 .def_property_readonly("omega_pll",
230
232 std::shared_ptr<CPS::DP::Ph1::GenericTwoTerminalVTypeSSN>,
234 mDPPh1, "GenericTwoTerminalVTypeSSN", py::multiple_inheritance())
235 .def(py::init<std::string>())
236 .def(py::init<std::string, CPS::Logger::Level>())
237 .def("set_parameters",
239 "B"_a, "C"_a, "D"_a)
241 .def_property_readonly("x", createAttributeGetter<CPS::MatrixComp>("x"));
242
244 std::shared_ptr<CPS::DP::Ph1::GenericTwoTerminalITypeSSN>,
246 mDPPh1, "GenericTwoTerminalITypeSSN", py::multiple_inheritance())
247 .def(py::init<std::string>())
248 .def(py::init<std::string, CPS::Logger::Level>())
249 .def("set_parameters",
251 "B"_a, "C"_a, "D"_a)
253 .def_property_readonly("x", createAttributeGetter<CPS::MatrixComp>("x"));
254
256 std::shared_ptr<CPS::DP::Ph1::SynchronGeneratorIdeal>,
257 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "SynchronGeneratorIdeal",
258 py::multiple_inheritance())
259 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
260 "loglevel"_a = CPS::Logger::Level::off)
262
264 std::shared_ptr<CPS::DP::Ph1::SynchronGeneratorTrStab>,
265 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "SynchronGeneratorTrStab",
266 py::multiple_inheritance())
267 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
268 "loglevel"_a = CPS::Logger::Level::off)
269 .def("set_standard_parameters_PU",
271 "nom_power"_a, "nom_volt"_a, "nom_freq"_a, "Xpd"_a, "inertia"_a,
272 "Rs"_a = 0, "D"_a = 0)
273 .def("set_fundamental_parameters_PU",
275 "nom_power"_a, "nom_volt"_a, "nom_freq"_a, "Ll"_a, "Lmd"_a, "Llfd"_a,
276 "H"_a, "D"_a = 0)
277 .def("set_initial_values",
279 "elec_power"_a, "mech_power"_a)
281 .def("set_model_flags",
283 "convert_with_omega_mech"_a)
284 .def(
285 "set_reference_omega",
287 std::string refOmegaName, CPS::IdentifiedObject::Ptr refOmegaComp,
288 std::string refDeltaName,
289 CPS::IdentifiedObject::Ptr refDeltaComp) {
291 refOmegaComp->attributeTyped<CPS::Real>(refOmegaName),
292 refDeltaComp->attributeTyped<CPS::Real>(refDeltaName));
293 },
294 "ref_omega_name"_a = "w_r", "ref_omage_comp"_a,
295 "ref_delta_name"_a = "delta_r", "ref_delta_comp"_a);
296
298 std::shared_ptr<CPS::DP::Ph1::ReducedOrderSynchronGeneratorVBR>,
300 mDPPh1, "ReducedOrderSynchronGeneratorVBR", py::multiple_inheritance());
301
303 std::shared_ptr<CPS::DP::Ph1::SynchronGenerator3OrderVBR>,
305 mDPPh1, "SynchronGenerator3OrderVBR", py::multiple_inheritance())
306 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
307 "loglevel"_a = CPS::Logger::Level::off)
308 .def("set_operational_parameters_per_unit",
309 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
311 CPS::Real>(
313 setOperationalParametersPerUnit),
314 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
315 "Lq"_a, "L0"_a, "Ld_t"_a, "Td0_t"_a)
317
319 std::shared_ptr<CPS::DP::Ph1::SynchronGenerator4OrderVBR>,
321 mDPPh1, "SynchronGenerator4OrderVBR", py::multiple_inheritance())
322 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
323 "loglevel"_a = CPS::Logger::Level::off)
324 .def("set_operational_parameters_per_unit",
325 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
329 setOperationalParametersPerUnit),
330 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
331 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a)
333
335 std::shared_ptr<CPS::DP::Ph1::SynchronGenerator5OrderVBR>,
337 mDPPh1, "SynchronGenerator5OrderVBR", py::multiple_inheritance())
338 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
339 "loglevel"_a = CPS::Logger::Level::off)
340 .def("set_operational_parameters_per_unit",
341 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
346 setOperationalParametersPerUnit),
347 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
348 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a, "Ld_s"_a,
349 "Lq_s"_a, "Td0_s"_a, "Tq0_s"_a, "Taa"_a)
351
353 std::shared_ptr<CPS::DP::Ph1::SynchronGenerator6aOrderVBR>,
355 mDPPh1, "SynchronGenerator6aOrderVBR", py::multiple_inheritance())
356 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
357 "loglevel"_a = CPS::Logger::Level::off)
358 .def("set_operational_parameters_per_unit",
359 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
364 setOperationalParametersPerUnit),
365 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
366 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a, "Ld_s"_a,
367 "Lq_s"_a, "Td0_s"_a, "Tq0_s"_a, "Taa"_a)
369
371 std::shared_ptr<CPS::DP::Ph1::SynchronGenerator6bOrderVBR>,
373 mDPPh1, "SynchronGenerator6bOrderVBR", 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,
382 setOperationalParametersPerUnit),
383 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
384 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a, "Ld_s"_a,
385 "Lq_s"_a, "Td0_s"_a, "Tq0_s"_a, "Taa"_a = 0)
387
389 std::shared_ptr<CPS::DP::Ph1::SynchronGenerator4OrderTPM>,
391 CPS::MNASyncGenInterface>(mDPPh1, "SynchronGenerator4OrderTPM",
392 py::multiple_inheritance())
393 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
394 "loglevel"_a = CPS::Logger::Level::off)
395 .def("set_operational_parameters_per_unit",
396 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
400 setOperationalParametersPerUnit),
401 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
402 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a)
404
406 std::shared_ptr<CPS::DP::Ph1::SynchronGenerator4OrderPCM>,
408 CPS::MNASyncGenInterface>(mDPPh1, "SynchronGenerator4OrderPCM",
409 py::multiple_inheritance())
410 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
411 "loglevel"_a = CPS::Logger::Level::off)
412 .def("set_operational_parameters_per_unit",
413 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
417 setOperationalParametersPerUnit),
418 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
419 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a)
421
423 std::shared_ptr<CPS::DP::Ph1::SynchronGenerator6OrderPCM>,
425 CPS::MNASyncGenInterface>(mDPPh1, "SynchronGenerator6OrderPCM",
426 py::multiple_inheritance())
427 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
428 "loglevel"_a = CPS::Logger::Level::off)
429 .def("set_operational_parameters_per_unit",
430 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
435 setOperationalParametersPerUnit),
436 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
437 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a, "Ld_s"_a,
438 "Lq_s"_a, "Td0_s"_a, "Tq0_s"_a, "Taa"_a = 0)
440
442 std::shared_ptr<CPS::DP::Ph1::AvVoltageSourceInverterDQ>,
444 mDPPh1, "AvVoltageSourceInverterDQ", py::multiple_inheritance())
445 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
446 "loglevel"_a = CPS::Logger::Level::off)
447 .def(py::init<std::string, std::string, CPS::Logger::Level, CPS::Bool>(),
448 "uid"_a, "name"_a, "loglevel"_a = CPS::Logger::Level::off,
449 // cppcheck-suppress assignBoolToPointer
450 "with_trafo"_a = false)
451 .def("set_parameters",
453 "sys_omega"_a, "sys_volt_nom"_a, "p_ref"_a, "q_ref"_a)
454 .def("set_filter_parameters",
456 "Lf"_a, "Cf"_a, "Rf"_a, "Rc"_a)
457 .def("set_controller_parameters",
459 "Kp_pll"_a, "Ki_pll"_a, "Kp_power_ctrl"_a, "Ki_power_ctrl"_a,
460 "Kp_curr_ctrl"_a, "Ki_curr_ctrl"_a, "omega_cutoff"_a)
461 .def("set_transformer_parameters",
463 "nom_voltage_end_1"_a, "nom_voltage_end_2"_a, "rated_power"_a,
464 "ratio_abs"_a, "ratio_phase"_a, "resistance"_a, "inductance"_a)
465 .def("set_initial_state_values",
467 "p_init"_a, "q_init"_a, "phi_d_init"_a, "phi_q_init"_a,
468 "gamma_d_init"_a, "gamma_q_init"_a)
469 .def("with_control",
472
473 py::class_<CPS::DP::Ph1::Inverter, std::shared_ptr<CPS::DP::Ph1::Inverter>,
474 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "Inverter",
475 py::multiple_inheritance())
476 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
477 "loglevel"_a = CPS::Logger::Level::off)
478 .def("set_parameters", &CPS::DP::Ph1::Inverter::setParameters,
479 "carrier_harms"_a, "modul_harms"_a, "input_voltage"_a, "ratio"_a,
480 "phase"_a)
481 .def("connect", &CPS::DP::Ph1::Inverter::connect);
482
483 py::class_<CPS::DP::Ph1::Transformer,
484 std::shared_ptr<CPS::DP::Ph1::Transformer>,
485 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "Transformer",
486 py::multiple_inheritance())
487 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
488 "loglevel"_a = CPS::Logger::Level::off)
489 .def(py::init<std::string, std::string, CPS::Logger::Level, CPS::Bool>(),
490 "uid"_a, "name"_a, "loglevel"_a = CPS::Logger::Level::off,
491 // cppcheck-suppress assignBoolToPointer
492 "with_resistive_losses"_a = false)
493 .def("set_parameters",
494 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
497 "nom_voltage_end_1"_a, "nom_voltage_end_2"_a, "ratio_abs"_a,
498 "ratio_phase"_a, "resistance"_a, "inductance"_a)
499 .def("set_parameters",
500 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
503 "nom_voltage_end_1"_a, "nom_voltage_end_2"_a, "rated_power"_a,
504 "ratio_abs"_a, "ratio_phase"_a, "resistance"_a, "inductance"_a)
505 .def("connect", &CPS::DP::Ph1::Transformer::connect);
506}
507
508void addDPPh3Components(py::module_ mDPPh3) {
510 std::shared_ptr<CPS::DP::Ph3::VoltageSource>,
511 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "VoltageSource",
512 py::multiple_inheritance())
513 .def(py::init<std::string>())
514 .def(py::init<std::string, CPS::Logger::Level>())
515 .def("set_parameters", &CPS::DP::Ph3::VoltageSource::setParameters,
516 "V_ref"_a, "f_src"_a = 0.0)
518 .def_property("V_ref", createAttributeGetter<CPS::MatrixComp>("V_ref"),
520 .def_property("f_src", createAttributeGetter<CPS::Real>("f_src"),
522
524 std::shared_ptr<CPS::DP::Ph3::NetworkInjection>,
525 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "NetworkInjection",
526 py::multiple_inheritance())
527 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
528 "loglevel"_a = CPS::Logger::Level::off)
529 .def("set_parameters", &CPS::DP::Ph3::NetworkInjection::setParameters,
530 "V_ref"_a, "f_src"_a = 0.0)
532
533 py::class_<CPS::DP::Ph3::PiLine, std::shared_ptr<CPS::DP::Ph3::PiLine>,
534 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "PiLine",
535 py::multiple_inheritance())
536 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
537 "loglevel"_a = CPS::Logger::Level::off)
538 .def("set_parameters", &CPS::DP::Ph3::PiLine::setParameters,
539 "series_resistance"_a, "series_inductance"_a,
540 "parallel_capacitance"_a = zeroMatrix(3),
541 "parallel_conductance"_a = zeroMatrix(3))
542 .def("connect", &CPS::DP::Ph3::PiLine::connect);
543
545 std::shared_ptr<CPS::DP::Ph3::CurrentSource>,
546 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "CurrentSource",
547 py::multiple_inheritance())
548 .def(py::init<std::string>())
549 .def(py::init<std::string, CPS::Logger::Level>())
550 .def("set_parameters", &CPS::DP::Ph3::CurrentSource::setParameters,
551 "I_ref"_a, "f_src"_a = 0.0)
553 .def_property("I_ref", createAttributeGetter<CPS::MatrixComp>("I_ref"),
555 .def_property("f_src", createAttributeGetter<CPS::Real>("f_src"),
557
558 py::class_<CPS::DP::Ph3::Resistor, std::shared_ptr<CPS::DP::Ph3::Resistor>,
559 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "Resistor",
560 py::multiple_inheritance())
561 .def(py::init<std::string>())
562 .def(py::init<std::string, CPS::Logger::Level>())
563 .def("set_parameters", &CPS::DP::Ph3::Resistor::setParameters, "R"_a)
564 .def("connect", &CPS::DP::Ph3::Resistor::connect);
565
566 py::class_<CPS::DP::Ph3::Inductor, std::shared_ptr<CPS::DP::Ph3::Inductor>,
567 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "Inductor",
568 py::multiple_inheritance())
569 .def(py::init<std::string>())
570 .def(py::init<std::string, CPS::Logger::Level>())
571 .def("set_parameters", &CPS::DP::Ph3::Inductor::setParameters, "L"_a)
572 .def("connect", &CPS::DP::Ph3::Inductor::connect);
573
574 py::class_<CPS::DP::Ph3::Capacitor, std::shared_ptr<CPS::DP::Ph3::Capacitor>,
575 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "Capacitor",
576 py::multiple_inheritance())
577 .def(py::init<std::string>())
578 .def(py::init<std::string, CPS::Logger::Level>())
579 .def("set_parameters", &CPS::DP::Ph3::Capacitor::setParameters, "C"_a)
580 .def("connect", &CPS::DP::Ph3::Capacitor::connect);
581
582#ifdef WITH_SUNDIALS
583
585 std::shared_ptr<CPS::DP::Ph3::SynchronGeneratorDQODE>,
586 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "SynchronGeneratorDQODE",
587 py::multiple_inheritance())
588 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
589 "loglevel"_a = CPS::Logger::Level::off)
590 .def("set_parameters_fundamental_per_unit",
592 setParametersFundamentalPerUnit,
593 "nom_power"_a, "nom_volt"_a, "nom_freq"_a, "pole_number"_a,
594 "nom_field_cur"_a, "Rs"_a, "Ll"_a, "Lmd"_a, "Lmq"_a, "Rfd"_a,
595 "Llfd"_a, "Rkd"_a, "Llkd"_a, "Rkq1"_a, "Llkq1"_a, "Rkq2"_a,
596 "Llkq2"_a, "inertia"_a, "init_active_power"_a,
597 "init_reactive_power"_a, "init_terminal_volt"_a, "init_volt_angle"_a,
598 "init_mech_power"_a)
600
601#endif
602
604 std::shared_ptr<CPS::DP::Ph3::SynchronGeneratorDQTrapez>,
606 mDPPh3, "SynchronGeneratorDQTrapez", py::multiple_inheritance())
607 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
608 "loglevel"_a = CPS::Logger::Level::off)
609 .def("set_parameters_fundamental_per_unit",
611 setParametersFundamentalPerUnit,
612 "nom_power"_a, "nom_volt"_a, "nom_freq"_a, "pole_number"_a,
613 "nom_field_cur"_a, "Rs"_a, "Ll"_a, "Lmd"_a, "Lmq"_a, "Rfd"_a,
614 "Llfd"_a, "Rkd"_a, "Llkd"_a, "Rkq1"_a, "Llkq1"_a, "Rkq2"_a,
615 "Llkq2"_a, "inertia"_a, "init_active_power"_a,
616 "init_reactive_power"_a, "init_terminal_volt"_a, "init_volt_angle"_a,
617 "init_mech_power"_a)
619
621 std::shared_ptr<CPS::DP::Ph3::SeriesResistor>,
622 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "SeriesResistor",
623 py::multiple_inheritance())
624 .def(py::init<std::string>())
625 .def(py::init<std::string, CPS::Logger::Level>())
626 .def("set_parameters", &CPS::DP::Ph3::SeriesResistor::setParameters,
627 "R"_a)
629
631 std::shared_ptr<CPS::DP::Ph3::SeriesSwitch>,
633 mDPPh3, "SeriesSwitch", py::multiple_inheritance())
634 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
635 "loglevel"_a = CPS::Logger::Level::off)
636 .def("set_parameters", &CPS::DP::Ph3::SeriesSwitch::setParameters,
637 "open_resistance"_a, "closed_resistance"_a,
638 // cppcheck-suppress assignBoolToPointer
639 "closed"_a = false)
642 .def("connect", &CPS::DP::Ph3::SeriesSwitch::connect);
643
644 py::class_<CPS::DP::Ph3::Switch, std::shared_ptr<CPS::DP::Ph3::Switch>,
646 mDPPh3, "Switch", py::multiple_inheritance())
647 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
648 "loglevel"_a = CPS::Logger::Level::off)
649 .def("set_parameters", &CPS::DP::Ph3::Switch::setParameters,
650 "open_resistance"_a, "closed_resistance"_a,
651 // cppcheck-suppress assignBoolToPointer
652 "closed"_a = false)
655 .def("connect", &CPS::DP::Ph3::Switch::connect);
656
658 std::shared_ptr<CPS::DP::Ph3::SSN::Full_Serial_RLC>,
659 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "Full_Serial_RLC",
660 py::multiple_inheritance())
661 .def(py::init<std::string>())
662 .def(py::init<std::string, CPS::Logger::Level>())
664 "R"_a, "L"_a, "C"_a)
666
668 std::shared_ptr<CPS::DP::Ph3::AvVoltSourceInverterStateSpace>,
670 mDPPh3, "AvVoltSourceInverterStateSpace", py::multiple_inheritance())
671 .def(py::init<std::string, CPS::Logger::Level, CPS::Bool>(), "name"_a,
672 "loglevel"_a = CPS::Logger::Level::off,
673 // cppcheck-suppress assignBoolToPointer
674 "enable_neg_seq_control"_a = false)
675 .def(py::init<std::string, std::string, CPS::Logger::Level, CPS::Bool>(),
676 "uid"_a, "name"_a, "loglevel"_a = CPS::Logger::Level::off,
677 // cppcheck-suppress assignBoolToPointer
678 "enable_neg_seq_control"_a = false)
679 .def("set_parameters",
681 "Cf"_a, "Rf"_a, "Rc"_a, "omega_n"_a, "Kp_pll"_a, "Ki_pll"_a,
682 "omega_cutoff"_a, "p_ref"_a, "q_ref"_a, "Kp_power_ctrl"_a,
683 "Ki_power_ctrl"_a, "Kp_curr_ctrl"_a, "Ki_curr_ctrl"_a,
684 "i_ref_n_d"_a = 0.0, "i_ref_n_q"_a = 0.0)
686 .def_property_readonly("x", createAttributeGetter<CPS::Matrix>("x"))
687 .def_property_readonly("vc_d", createAttributeGetter<CPS::Real>("vc_d"))
688 .def_property_readonly("vc_q", createAttributeGetter<CPS::Real>("vc_q"))
689 .def_property_readonly("irc_d", createAttributeGetter<CPS::Real>("irc_d"))
690 .def_property_readonly("irc_q", createAttributeGetter<CPS::Real>("irc_q"))
691 .def_property_readonly("irc_n_d",
693 .def_property_readonly("irc_n_q",
695 .def_property_readonly("p_inst",
697 .def_property_readonly("q_inst",
699 .def_property_readonly("omega_pll",
701
703 std::shared_ptr<CPS::DP::Ph3::GenericTwoTerminalVTypeSSN>,
705 mDPPh3, "GenericTwoTerminalVTypeSSN", py::multiple_inheritance())
706 .def(py::init<std::string>())
707 .def(py::init<std::string, CPS::Logger::Level>())
708 .def("set_parameters",
710 "B"_a, "C"_a, "D"_a)
712 .def_property_readonly("x", createAttributeGetter<CPS::MatrixComp>("x"));
713
715 std::shared_ptr<CPS::DP::Ph3::GenericTwoTerminalITypeSSN>,
717 mDPPh3, "GenericTwoTerminalITypeSSN", py::multiple_inheritance())
718 .def(py::init<std::string>())
719 .def(py::init<std::string, CPS::Logger::Level>())
720 .def("set_parameters",
722 "B"_a, "C"_a, "D"_a)
724 .def_property_readonly("x", createAttributeGetter<CPS::MatrixComp>("x"));
725}
void addDPComponents(py::module_ mDP)
void addDPPh1Components(py::module_ mDPPh1)
void addDPPh3Components(py::module_ mDPPh3)
void setParameters(Real capacitance)
Sets model specific parameters.
void setParameters(Real inductance)
Sets model specific parameters.
void setParameters(Real seriesResistance, Real seriesInductance, Real parallelCapacitance=0, Real parallelConductance=0) const
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(Complex voltageRef, Real srcFreq=-1)
Sets model specific parameters.
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)
Averaged grid-following VSI SSN port of EMT::Ph3::AvVoltSourceInverterStateSpace: 8 real control stat...
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 setParameters(Real sysOmega, Real sysVoltNom, Real Pref, Real Qref)
Setter for general parameters of inverter.
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 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)
Setter for parameters of transformer.
void setFilterParameters(Real Lf, Real Cf, Real Rf, Real Rc)
Setter for parameters of filter.
Dynamic phasor ideal current source.
void setParameters(Complex current)
Generic single-phase, two-terminal I-type SSN component.
Generic single-phase, two-terminal V-type SSN component.
void setParameters(const std::vector< Int > &carrierHarms, const std::vector< Int > &modulHarms, Real inputVoltage, Real ratio, Real phase)
void setParameters(Complex voltageRef, Real srcFreq=0.0)
void setParameters(Real activePower, Real ReactivePower, Real volt)
Set model specific parameters.
Base class for DP VBR synchronous generator model single phase.
Series RLC one-port as a DP V-type SSN component.
void setParameters(Real resistance, Real inductance, Real capacitance)
void setParameters(Real conductance, Real susceptance)
Set shunt specific parameters.
Voltage-Behind-Reactance (VBR) implementation of 3rd order synchronous generator model.
4 Order Synchronous generator model for transient stability analysis
4 Order Synchronous generator model for transient stability analysis
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...
6 Order Synchronous generator model for transient stability analysis
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.
Synchronous generator model for transient stability analysis.
void setStandardParametersPU(Real nomPower, Real nomVolt, Real nomFreq, Real Xpd, Real inertia, Real Rs=0, Real D=0)
Initializes the machine parameters.
void setInitialValues(Complex elecPower, Real mechPower)
void setModelFlags(Bool convertWithOmegaMech)
Flags to modify model behavior.
void setFundamentalParametersPU(Real nomPower, Real nomVolt, Real nomFreq, Real Ll, Real Lmd, Real Llfd, Real inertia, Real D=0)
Initializes the machine parameters.
void setReferenceOmega(Attribute< Real >::Ptr refOmegaPtr, Attribute< Real >::Ptr refDeltaPtr)
Transformer that includes an inductance and resistance.
void setParameters(Real nomVoltageEnd1, Real nomVoltageEnd2, Real ratioAbs, Real ratioPhase, Real resistance, Real inductance)
Defines component parameters.
Ideal Voltage source model.
void setParameters(Complex voltageRef, Real srcFreq=0.0)
Resistive dynamic phasor voltage source.
void setParameters(Complex voltage, Real srcFreq=-1, Real resistance=1e9)
THISISBAD: This declaration and Base::Ph1::VoltageSource::setParameters(Complex, Real) are ambiguous ...
Switch with variable resistance to avoid numerical oscillations, when an inductive current is suddenl...
void setInitParameters(Real timestep)
Averaged grid-following VSI (SSN), optional dual-sequence current control.
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, Real iRefNd=0.0, Real iRefNq=0.0)
Ideal current source model.
void setParameters(MatrixComp currentRef, Real srcFreq=0.0)
Setter for reference current per phase and offset from the carrier.
Generic three-phase, two-terminal I-type SSN component.
Generic three-phase, two-terminal V-type SSN component.
void setParameters(MatrixComp voltageRef, Real srcFreq=0.0)
Setter for reference voltage parameters.
Series RLC one-port as a three-phase DP V-type SSN component.
void setParameters(const Matrix &resistance, const Matrix &inductance, const Matrix &capacitance)
Dynamic phasor three-phase switch.
Ideal Voltage source model.
void setParameters(MatrixComp voltageRef, Real srcFreq=0.0)
Setter for reference voltage per phase and offset from the carrier.
void setParameters(const Matrix &A, const Matrix &B, const Matrix &C, const Matrix &D)
std::shared_ptr< IdentifiedObject > Ptr
Interface to be used by synchronous generators.
Complex singleVoltage(PhaseType phaseType=PhaseType::Single)
Base class for all components that are transmitting power.
void connect(typename SimNode< Complex >::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
double Real
Definition Definitions.h:62
std::complex< Real > Complex
Definition Definitions.h:63
CPS::Matrix zeroMatrix(int dim)
Definition Utils.cpp:11