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>
16#include <dpsim/Simulation.h>
18#include <dpsim/pybind/Utils.h>
19
20namespace py = pybind11;
21using namespace pybind11::literals;
22
23void addDPComponents(py::module_ mDP) {
24 py::class_<CPS::DP::SimNode, std::shared_ptr<CPS::DP::SimNode>,
25 CPS::TopologicalNode>(mDP, "SimNode", py::module_local())
26 .def(py::init<std::string>())
27 .def(py::init<std::string, CPS::PhaseType>())
28 .def(py::init<std::string, CPS::PhaseType,
29 const std::vector<CPS::Complex>>())
30 .def("set_initial_voltage",
31 py::overload_cast<CPS::MatrixComp>(
33 .def("set_initial_voltage",
34 py::overload_cast<CPS::Complex>(&CPS::DP::SimNode::setInitialVoltage,
35 py::const_))
36 .def("set_initial_voltage",
37 py::overload_cast<CPS::Complex, int>(
39 .def("set_complex_initial_voltage_scale",
41 .def("single_voltage", &CPS::DP::SimNode::singleVoltage,
42 "phase_type"_a = CPS::PhaseType::Single)
43 .def_readonly_static("gnd", &CPS::DP::SimNode::GND);
44
45 py::module mDPPh1 =
46 mDP.def_submodule("ph1", "single phase dynamic phasor models");
47 addDPPh1Components(mDPPh1);
48
49 py::module mDPPh3 =
50 mDP.def_submodule("ph3", "triple phase dynamic phasor models");
51 addDPPh3Components(mDPPh3);
52}
53
54void addDPPh1Components(py::module_ mDPPh1) {
56 std::shared_ptr<CPS::DP::Ph1::VoltageSource>,
57 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "VoltageSource",
58 py::multiple_inheritance())
59 .def(py::init<std::string>())
60 .def(py::init<std::string, CPS::Logger::Level>())
61 .def("set_parameters",
62 py::overload_cast<CPS::Complex, CPS::Real>(
64 "V_ref"_a, "f_src"_a = 0)
66 .def_property("V_ref", createAttributeGetter<CPS::Complex>("V_ref"),
68 .def_property("f_src", createAttributeGetter<CPS::Real>("f_src"),
70
72 std::shared_ptr<CPS::DP::Ph1::VoltageSourceNorton>,
73 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "VoltageSourceNorton",
74 py::multiple_inheritance())
75 .def(py::init<std::string>())
76 .def(py::init<std::string, CPS::Logger::Level>())
77 .def("set_parameters",
78 static_cast<void (CPS::Base::Ph1::VoltageSource::*)(CPS::Complex,
79 CPS::Real)>(
81 py::arg("voltageRef"), py::arg("srcFreq") = -1)
82 .def("set_parameters",
83 static_cast<void (CPS::DP::Ph1::VoltageSourceNorton::*)(
86 py::arg("voltageRef"), py::arg("srcFreq") = -1,
87 py::arg("resistance") = 1e9)
89
91 std::shared_ptr<CPS::DP::Ph1::CurrentSource>,
92 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "CurrentSource",
93 py::multiple_inheritance())
94 .def(py::init<std::string>())
95 .def(py::init<std::string, CPS::Logger::Level>())
96 .def("set_parameters", &CPS::DP::Ph1::CurrentSource::setParameters,
97 "I_ref"_a)
99 .def_property("I_ref", createAttributeGetter<CPS::Complex>("I_ref"),
101
102 py::class_<CPS::DP::Ph1::Resistor, std::shared_ptr<CPS::DP::Ph1::Resistor>,
103 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "Resistor",
104 py::multiple_inheritance())
105 .def(py::init<std::string>())
106 .def(py::init<std::string, CPS::Logger::Level>())
107 .def("set_parameters", &CPS::DP::Ph1::Resistor::setParameters, "R"_a)
108 .def("connect", &CPS::DP::Ph1::Resistor::connect)
109 .def_property("R", createAttributeGetter<CPS::Real>("R"),
111
112 py::class_<CPS::DP::Ph1::Capacitor, std::shared_ptr<CPS::DP::Ph1::Capacitor>,
113 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "Capacitor",
114 py::multiple_inheritance())
115 .def(py::init<std::string>())
116 .def(py::init<std::string, CPS::Logger::Level>())
117 .def("set_parameters", &CPS::DP::Ph1::Capacitor::setParameters, "C"_a)
118 .def("connect", &CPS::DP::Ph1::Capacitor::connect)
119 .def_property("C", createAttributeGetter<CPS::Real>("C"),
121
122 py::class_<CPS::DP::Ph1::Inductor, std::shared_ptr<CPS::DP::Ph1::Inductor>,
123 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "Inductor",
124 py::multiple_inheritance())
125 .def(py::init<std::string>())
126 .def(py::init<std::string, CPS::Logger::Level>())
127 .def("set_parameters", &CPS::DP::Ph1::Inductor::setParameters, "L"_a)
128 .def("connect", &CPS::DP::Ph1::Inductor::connect)
129 .def_property("L", createAttributeGetter<CPS::Real>("L"),
131
133 std::shared_ptr<CPS::DP::Ph1::NetworkInjection>,
134 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "NetworkInjection",
135 py::multiple_inheritance())
136 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
137 "loglevel"_a = CPS::Logger::Level::off)
138 .def("set_parameters",
139 py::overload_cast<CPS::Complex, CPS::Real>(
141 "V_ref"_a, "f_src"_a = 0)
143
144 py::class_<CPS::DP::Ph1::PiLine, std::shared_ptr<CPS::DP::Ph1::PiLine>,
145 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "PiLine",
146 py::multiple_inheritance())
147 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
148 "loglevel"_a = CPS::Logger::Level::off)
149 .def("set_parameters", &CPS::DP::Ph1::PiLine::setParameters,
150 "series_resistance"_a, "series_inductance"_a,
151 "parallel_capacitance"_a = 0, "parallel_conductance"_a = 0)
152 .def("connect", &CPS::DP::Ph1::PiLine::connect);
153
154 py::class_<CPS::DP::Ph1::RXLoad, std::shared_ptr<CPS::DP::Ph1::RXLoad>,
155 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "RXLoad",
156 py::multiple_inheritance())
157 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
158 "loglevel"_a = CPS::Logger::Level::off)
159 .def("set_parameters", &CPS::DP::Ph1::RXLoad::setParameters,
160 "active_power"_a, "reactive_power"_a, "volt"_a)
161 .def("connect", &CPS::DP::Ph1::RXLoad::connect);
162
163 py::class_<CPS::DP::Ph1::Shunt, std::shared_ptr<CPS::DP::Ph1::Shunt>,
164 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "Shunt",
165 py::multiple_inheritance())
166 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
167 "loglevel"_a = CPS::Logger::Level::off)
168 .def("set_parameters", &CPS::DP::Ph1::Shunt::setParameters, "G"_a, "B"_a)
169 .def("connect", &CPS::DP::Ph1::Shunt::connect);
170
171 py::class_<CPS::DP::Ph1::Switch, std::shared_ptr<CPS::DP::Ph1::Switch>,
173 mDPPh1, "Switch", py::multiple_inheritance())
174 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
175 "loglevel"_a = CPS::Logger::Level::off)
176 .def("set_parameters", &CPS::DP::Ph1::Switch::setParameters,
177 "open_resistance"_a, "closed_resistance"_a,
178 // cppcheck-suppress assignBoolToPointer
179 "closed"_a = false)
180 .def("open", &CPS::DP::Ph1::Switch::open)
181 .def("close", &CPS::DP::Ph1::Switch::close)
182 .def("connect", &CPS::DP::Ph1::Switch::connect);
183
185 std::shared_ptr<CPS::DP::Ph1::varResSwitch>,
187 mDPPh1, "varResSwitch", py::multiple_inheritance())
188 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
189 "loglevel"_a = CPS::Logger::Level::off)
190 .def("set_parameters", &CPS::DP::Ph1::varResSwitch::setParameters,
191 "open_resistance"_a, "closed_resistance"_a,
192 // cppcheck-suppress assignBoolToPointer
193 "closed"_a = false)
196 .def("set_init_parameters",
198 .def("connect", &CPS::DP::Ph1::varResSwitch::connect);
199
201 std::shared_ptr<CPS::DP::Ph1::SSN::Full_Serial_RLC>,
202 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "Full_Serial_RLC",
203 py::multiple_inheritance())
204 .def(py::init<std::string>())
205 .def(py::init<std::string, CPS::Logger::Level>())
207 "R"_a, "L"_a, "C"_a)
209
211 std::shared_ptr<CPS::DP::Ph1::AvVoltSourceInverterStateSpace>,
213 mDPPh1, "AvVoltSourceInverterStateSpace", py::multiple_inheritance())
214 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
215 "loglevel"_a = CPS::Logger::Level::off)
216 .def(py::init<std::string, std::string, CPS::Logger::Level>(), "uid"_a,
217 "name"_a, "loglevel"_a = CPS::Logger::Level::off)
218 .def("set_parameters",
220 "Cf"_a, "Rf"_a, "Rc"_a, "omega_n"_a, "Kp_pll"_a, "Ki_pll"_a,
221 "omega_cutoff"_a, "p_ref"_a, "q_ref"_a, "Kp_power_ctrl"_a,
222 "Ki_power_ctrl"_a, "Kp_curr_ctrl"_a, "Ki_curr_ctrl"_a)
224 .def_property_readonly("x", createAttributeGetter<CPS::Matrix>("x"))
225 .def_property_readonly("vc_d", createAttributeGetter<CPS::Real>("vc_d"))
226 .def_property_readonly("vc_q", createAttributeGetter<CPS::Real>("vc_q"))
227 .def_property_readonly("irc_d", createAttributeGetter<CPS::Real>("irc_d"))
228 .def_property_readonly("irc_q", createAttributeGetter<CPS::Real>("irc_q"))
229 .def_property_readonly("p_inst",
231 .def_property_readonly("q_inst",
233 .def_property_readonly("omega_pll",
235
237 std::shared_ptr<CPS::DP::Ph1::GenericTwoTerminalVTypeSSN>,
239 mDPPh1, "GenericTwoTerminalVTypeSSN", py::multiple_inheritance())
240 .def(py::init<std::string>())
241 .def(py::init<std::string, CPS::Logger::Level>())
242 .def("set_parameters",
244 "B"_a, "C"_a, "D"_a, "D1"_a = CPS::Matrix())
246 .def_property_readonly("x", createAttributeGetter<CPS::MatrixComp>("x"));
247
249 std::shared_ptr<CPS::DP::Ph1::GenericTwoTerminalITypeSSN>,
251 mDPPh1, "GenericTwoTerminalITypeSSN", py::multiple_inheritance())
252 .def(py::init<std::string>())
253 .def(py::init<std::string, CPS::Logger::Level>())
254 .def("set_parameters",
256 "B"_a, "C"_a, "D"_a, "D1"_a = CPS::Matrix())
258 .def_property_readonly("x", createAttributeGetter<CPS::MatrixComp>("x"));
259
261 std::shared_ptr<CPS::DP::Ph1::SynchronGeneratorIdeal>,
262 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "SynchronGeneratorIdeal",
263 py::multiple_inheritance())
264 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
265 "loglevel"_a = CPS::Logger::Level::off)
267
269 std::shared_ptr<CPS::DP::Ph1::SynchronGeneratorTrStab>,
270 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "SynchronGeneratorTrStab",
271 py::multiple_inheritance())
272 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
273 "loglevel"_a = CPS::Logger::Level::off)
274 .def("set_standard_parameters_PU",
276 "nom_power"_a, "nom_volt"_a, "nom_freq"_a, "Xpd"_a, "inertia"_a,
277 "Rs"_a = 0, "D"_a = 0)
278 .def("set_fundamental_parameters_PU",
280 "nom_power"_a, "nom_volt"_a, "nom_freq"_a, "Ll"_a, "Lmd"_a, "Llfd"_a,
281 "H"_a, "D"_a = 0)
282 .def("set_initial_values",
284 "elec_power"_a, "mech_power"_a)
286 .def("set_model_flags",
288 "convert_with_omega_mech"_a)
289 .def(
290 "set_reference_omega",
292 std::string refOmegaName, CPS::IdentifiedObject::Ptr refOmegaComp,
293 std::string refDeltaName,
294 CPS::IdentifiedObject::Ptr refDeltaComp) {
296 refOmegaComp->attributeTyped<CPS::Real>(refOmegaName),
297 refDeltaComp->attributeTyped<CPS::Real>(refDeltaName));
298 },
299 "ref_omega_name"_a = "w_r", "ref_omage_comp"_a,
300 "ref_delta_name"_a = "delta_r", "ref_delta_comp"_a);
301
303 std::shared_ptr<CPS::DP::Ph1::ReducedOrderSynchronGeneratorVBR>,
305 mDPPh1, "ReducedOrderSynchronGeneratorVBR", py::multiple_inheritance());
306
308 std::shared_ptr<CPS::DP::Ph1::SynchronGenerator3OrderVBR>,
310 mDPPh1, "SynchronGenerator3OrderVBR", py::multiple_inheritance())
311 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
312 "loglevel"_a = CPS::Logger::Level::off)
313 .def("set_operational_parameters_per_unit",
314 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
316 CPS::Real>(
318 setOperationalParametersPerUnit),
319 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
320 "Lq"_a, "L0"_a, "Ld_t"_a, "Td0_t"_a)
322
324 std::shared_ptr<CPS::DP::Ph1::SynchronGenerator4OrderVBR>,
326 mDPPh1, "SynchronGenerator4OrderVBR", py::multiple_inheritance())
327 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
328 "loglevel"_a = CPS::Logger::Level::off)
329 .def("set_operational_parameters_per_unit",
330 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
334 setOperationalParametersPerUnit),
335 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
336 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a)
338 "damping"_a)
340
342 std::shared_ptr<CPS::DP::Ph1::SynchronGenerator5OrderVBR>,
344 mDPPh1, "SynchronGenerator5OrderVBR", py::multiple_inheritance())
345 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
346 "loglevel"_a = CPS::Logger::Level::off)
347 .def("set_operational_parameters_per_unit",
348 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
353 setOperationalParametersPerUnit),
354 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
355 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a, "Ld_s"_a,
356 "Lq_s"_a, "Td0_s"_a, "Tq0_s"_a, "Taa"_a)
358
360 std::shared_ptr<CPS::DP::Ph1::SynchronGenerator6aOrderVBR>,
362 mDPPh1, "SynchronGenerator6aOrderVBR", py::multiple_inheritance())
363 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
364 "loglevel"_a = CPS::Logger::Level::off)
365 .def("set_operational_parameters_per_unit",
366 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
371 setOperationalParametersPerUnit),
372 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
373 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a, "Ld_s"_a,
374 "Lq_s"_a, "Td0_s"_a, "Tq0_s"_a, "Taa"_a)
376
378 std::shared_ptr<CPS::DP::Ph1::SynchronGenerator6bOrderVBR>,
380 mDPPh1, "SynchronGenerator6bOrderVBR", py::multiple_inheritance())
381 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
382 "loglevel"_a = CPS::Logger::Level::off)
383 .def("set_operational_parameters_per_unit",
384 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
389 setOperationalParametersPerUnit),
390 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
391 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a, "Ld_s"_a,
392 "Lq_s"_a, "Td0_s"_a, "Tq0_s"_a, "Taa"_a = 0)
394
396 std::shared_ptr<CPS::DP::Ph1::SynchronGenerator4OrderTPM>,
398 CPS::MNASyncGenInterface>(mDPPh1, "SynchronGenerator4OrderTPM",
399 py::multiple_inheritance())
400 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
401 "loglevel"_a = CPS::Logger::Level::off)
402 .def("set_operational_parameters_per_unit",
403 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
407 setOperationalParametersPerUnit),
408 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
409 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a)
411
413 std::shared_ptr<CPS::DP::Ph1::AvVoltageSourceInverterDQ>,
415 mDPPh1, "AvVoltageSourceInverterDQ", py::multiple_inheritance())
416 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
417 "loglevel"_a = CPS::Logger::Level::off)
418 .def(py::init<std::string, std::string, CPS::Logger::Level, CPS::Bool>(),
419 "uid"_a, "name"_a, "loglevel"_a = CPS::Logger::Level::off,
420 // cppcheck-suppress assignBoolToPointer
421 "with_trafo"_a = false)
422 .def("set_parameters",
424 "sys_omega"_a, "sys_volt_nom"_a, "p_ref"_a, "q_ref"_a)
425 .def("set_filter_parameters",
427 "Lf"_a, "Cf"_a, "Rf"_a, "Rc"_a)
428 .def("set_controller_parameters",
430 "Kp_pll"_a, "Ki_pll"_a, "Kp_power_ctrl"_a, "Ki_power_ctrl"_a,
431 "Kp_curr_ctrl"_a, "Ki_curr_ctrl"_a, "omega_cutoff"_a)
432 .def("set_transformer_parameters",
434 "nom_voltage_primary"_a, "nom_voltage_secondary"_a, "rated_power"_a,
435 "ratio_abs"_a, "ratio_phase"_a, "resistance"_a, "inductance"_a)
436 .def("set_initial_state_values",
438 "p_init"_a, "q_init"_a, "phi_d_init"_a, "phi_q_init"_a,
439 "gamma_d_init"_a, "gamma_q_init"_a)
440 .def("with_control",
443
444 py::class_<CPS::DP::Ph1::Inverter, std::shared_ptr<CPS::DP::Ph1::Inverter>,
445 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "Inverter",
446 py::multiple_inheritance())
447 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
448 "loglevel"_a = CPS::Logger::Level::off)
449 .def("set_parameters", &CPS::DP::Ph1::Inverter::setParameters,
450 "carrier_harms"_a, "modul_harms"_a, "input_voltage"_a, "ratio"_a,
451 "phase"_a)
452 .def("connect", &CPS::DP::Ph1::Inverter::connect);
453
454 py::class_<CPS::DP::Ph1::Transformer,
455 std::shared_ptr<CPS::DP::Ph1::Transformer>,
456 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "Transformer",
457 py::multiple_inheritance())
458 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
459 "loglevel"_a = CPS::Logger::Level::off)
460 .def(py::init<std::string, std::string, CPS::Logger::Level, CPS::Bool>(),
461 "uid"_a, "name"_a, "loglevel"_a = CPS::Logger::Level::off,
462 // cppcheck-suppress assignBoolToPointer
463 "with_resistive_losses"_a = false)
464 .def("set_parameters",
465 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
468 "nom_voltage_primary"_a, "nom_voltage_secondary"_a, "ratio_abs"_a,
469 "ratio_phase"_a, "resistance"_a, "inductance"_a)
470 .def("set_parameters",
471 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
474 "nom_voltage_primary"_a, "nom_voltage_secondary"_a, "rated_power"_a,
475 "ratio_abs"_a, "ratio_phase"_a, "resistance"_a, "inductance"_a)
476 .def("set_reference_winding",
478 "reference_winding"_a)
479 .def("set_tap_ratio", &CPS::DP::Ph1::Transformer::setTapRatio,
480 "tap_ratio"_a)
481 .def_property("tap_ratio", &CPS::DP::Ph1::Transformer::tapRatio,
483 .def("set_magnetizing_branch",
485 "no_load_current"_a, "no_load_loss"_a)
486 .def("connect", &CPS::DP::Ph1::Transformer::connect);
487}
488
489void addDPPh3Components(py::module_ mDPPh3) {
490 py::class_<CPS::DP::Ph3::Transformer,
491 std::shared_ptr<CPS::DP::Ph3::Transformer>,
492 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "Transformer",
493 py::multiple_inheritance())
494 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
495 "loglevel"_a = CPS::Logger::Level::off)
496 .def(py::init<std::string, std::string, CPS::Logger::Level, CPS::Bool>(),
497 "uid"_a, "name"_a, "loglevel"_a = CPS::Logger::Level::off,
498 // cppcheck-suppress assignBoolToPointer
499 "with_resistive_losses"_a = false)
500 .def("set_parameters", &CPS::DP::Ph3::Transformer::setParameters,
501 "nom_voltage_primary"_a, "nom_voltage_secondary"_a, "rated_power"_a,
502 "ratio_abs"_a, "ratio_phase"_a, "resistance"_a, "inductance"_a)
503 .def("set_reference_winding",
505 "reference_winding"_a)
506 .def("set_tap_ratio", &CPS::DP::Ph3::Transformer::setTapRatio,
507 "tap_ratio"_a)
508 .def_property("tap_ratio", &CPS::DP::Ph3::Transformer::tapRatio,
510 .def("set_magnetizing_branch",
512 "no_load_current"_a, "no_load_loss"_a)
513 .def("connect", &CPS::DP::Ph3::Transformer::connect);
514
516 std::shared_ptr<CPS::DP::Ph3::VoltageSource>,
517 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "VoltageSource",
518 py::multiple_inheritance())
519 .def(py::init<std::string>())
520 .def(py::init<std::string, CPS::Logger::Level>())
521 .def("set_parameters", &CPS::DP::Ph3::VoltageSource::setParameters,
522 "V_ref"_a, "f_src"_a = 0.0)
524 .def_property("V_ref", createAttributeGetter<CPS::MatrixComp>("V_ref"),
526 .def_property("f_src", createAttributeGetter<CPS::Real>("f_src"),
528
530 std::shared_ptr<CPS::DP::Ph3::NetworkInjection>,
531 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "NetworkInjection",
532 py::multiple_inheritance())
533 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
534 "loglevel"_a = CPS::Logger::Level::off)
535 .def("set_parameters", &CPS::DP::Ph3::NetworkInjection::setParameters,
536 "V_ref"_a, "f_src"_a = 0.0)
538
539 py::class_<CPS::DP::Ph3::PiLine, std::shared_ptr<CPS::DP::Ph3::PiLine>,
540 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "PiLine",
541 py::multiple_inheritance())
542 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
543 "loglevel"_a = CPS::Logger::Level::off)
544 .def("set_parameters", &CPS::DP::Ph3::PiLine::setParameters,
545 "series_resistance"_a, "series_inductance"_a,
546 "parallel_capacitance"_a = zeroMatrix(3),
547 "parallel_conductance"_a = zeroMatrix(3))
548 .def("connect", &CPS::DP::Ph3::PiLine::connect);
549
550 py::class_<CPS::DP::Ph3::SSN::PiLine,
551 std::shared_ptr<CPS::DP::Ph3::SSN::PiLine>,
552 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "SSN_PiLine",
553 py::multiple_inheritance())
554 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
555 "loglevel"_a = CPS::Logger::Level::off)
556 .def("set_parameters", &CPS::DP::Ph3::SSN::PiLine::setParameters,
557 "series_resistance"_a, "series_inductance"_a,
558 "parallel_capacitance"_a = zeroMatrix(3),
559 "parallel_conductance"_a = zeroMatrix(3))
560 .def("connect", &CPS::DP::Ph3::SSN::PiLine::connect);
561
563 std::shared_ptr<CPS::DP::Ph3::SSN::ImpedanceLoad>,
564 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "SSN_ImpedanceLoad",
565 py::multiple_inheritance())
566 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
567 "loglevel"_a = CPS::Logger::Level::off)
569 "active_power"_a, "reactive_power"_a, "nominal_voltage"_a,
570 "shunt_conductance"_a = 0., "shunt_susceptance"_a = 0.)
572
574 std::shared_ptr<CPS::DP::Ph3::SSN::Transformer>,
575 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "SSN_Transformer",
576 py::multiple_inheritance())
577 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
578 "loglevel"_a = CPS::Logger::Level::off)
579 .def("set_parameters", &CPS::DP::Ph3::SSN::Transformer::setParameters,
580 "nom_voltage_primary"_a, "nom_voltage_secondary"_a, "rated_power"_a,
581 "ratio_abs"_a, "ratio_phase"_a, "resistance"_a, "inductance"_a)
582 .def("set_magnetizing_branch",
584 "no_load_current"_a, "no_load_loss"_a)
586
588 std::shared_ptr<CPS::DP::Ph3::CurrentSource>,
589 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "CurrentSource",
590 py::multiple_inheritance())
591 .def(py::init<std::string>())
592 .def(py::init<std::string, CPS::Logger::Level>())
593 .def("set_parameters", &CPS::DP::Ph3::CurrentSource::setParameters,
594 "I_ref"_a, "f_src"_a = 0.0)
596 .def_property("I_ref", createAttributeGetter<CPS::MatrixComp>("I_ref"),
598 .def_property("f_src", createAttributeGetter<CPS::Real>("f_src"),
600
601 py::class_<CPS::DP::Ph3::Resistor, std::shared_ptr<CPS::DP::Ph3::Resistor>,
602 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "Resistor",
603 py::multiple_inheritance())
604 .def(py::init<std::string>())
605 .def(py::init<std::string, CPS::Logger::Level>())
606 .def("set_parameters", &CPS::DP::Ph3::Resistor::setParameters, "R"_a)
607 .def("connect", &CPS::DP::Ph3::Resistor::connect);
608
609 py::class_<CPS::DP::Ph3::Inductor, std::shared_ptr<CPS::DP::Ph3::Inductor>,
610 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "Inductor",
611 py::multiple_inheritance())
612 .def(py::init<std::string>())
613 .def(py::init<std::string, CPS::Logger::Level>())
614 .def("set_parameters", &CPS::DP::Ph3::Inductor::setParameters, "L"_a)
615 .def("connect", &CPS::DP::Ph3::Inductor::connect);
616
617 py::class_<CPS::DP::Ph3::Capacitor, std::shared_ptr<CPS::DP::Ph3::Capacitor>,
618 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "Capacitor",
619 py::multiple_inheritance())
620 .def(py::init<std::string>())
621 .def(py::init<std::string, CPS::Logger::Level>())
622 .def("set_parameters", &CPS::DP::Ph3::Capacitor::setParameters, "C"_a)
623 .def("connect", &CPS::DP::Ph3::Capacitor::connect);
624
625#ifdef WITH_SUNDIALS
626
628 std::shared_ptr<CPS::DP::Ph3::SynchronGeneratorDQODE>,
629 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "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_fundamental_per_unit",
635 setParametersFundamentalPerUnit,
636 "nom_power"_a, "nom_volt"_a, "nom_freq"_a, "pole_number"_a,
637 "nom_field_cur"_a, "Rs"_a, "Ll"_a, "Lmd"_a, "Lmq"_a, "Rfd"_a,
638 "Llfd"_a, "Rkd"_a, "Llkd"_a, "Rkq1"_a, "Llkq1"_a, "Rkq2"_a,
639 "Llkq2"_a, "inertia"_a, "init_active_power"_a,
640 "init_reactive_power"_a, "init_terminal_volt"_a, "init_volt_angle"_a,
641 "init_mech_power"_a)
643
644#endif
645
647 std::shared_ptr<CPS::DP::Ph3::SynchronGeneratorDQTrapez>,
649 mDPPh3, "SynchronGeneratorDQTrapez", py::multiple_inheritance())
650 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
651 "loglevel"_a = CPS::Logger::Level::off)
652 .def("set_machine_parameters_fundamental_per_unit",
654 setMachineParametersFundamentalPerUnit,
655 "nom_power"_a, "nom_volt"_a, "nom_freq"_a, "pole_number"_a,
656 "nom_field_cur"_a, "Rs"_a, "Ll"_a, "Lmd"_a, "Lmq"_a, "Rfd"_a,
657 "Llfd"_a, "Rkd"_a, "Llkd"_a, "Rkq1"_a, "Llkq1"_a, "Rkq2"_a,
658 "Llkq2"_a, "inertia"_a)
659 .def("set_parameters_fundamental_per_unit",
661 setParametersFundamentalPerUnit,
662 "nom_power"_a, "nom_volt"_a, "nom_freq"_a, "pole_number"_a,
663 "nom_field_cur"_a, "Rs"_a, "Ll"_a, "Lmd"_a, "Lmq"_a, "Rfd"_a,
664 "Llfd"_a, "Rkd"_a, "Llkd"_a, "Rkq1"_a, "Llkq1"_a, "Rkq2"_a,
665 "Llkq2"_a, "inertia"_a, "init_active_power"_a,
666 "init_reactive_power"_a, "init_terminal_volt"_a, "init_volt_angle"_a,
667 "init_mech_power"_a)
669
671 std::shared_ptr<CPS::DP::Ph3::SynchronGenerator4OrderVBR>,
673 mDPPh3, "SynchronGenerator4OrderVBR", py::multiple_inheritance())
674 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
675 "loglevel"_a = CPS::Logger::Level::off)
676 .def("set_parameters_operational_per_unit",
678 setParametersOperationalPerUnit,
679 "nom_power"_a, "nom_volt"_a, "nom_freq"_a, "pole_number"_a,
680 "nom_field_cur"_a, "Rs"_a, "Ld"_a, "Lq"_a, "Ld_t"_a, "Lq_t"_a,
681 "Ll"_a, "Td0_t"_a, "Tq0_t"_a, "inertia"_a)
683
685 std::shared_ptr<CPS::DP::Ph3::SeriesResistor>,
686 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "SeriesResistor",
687 py::multiple_inheritance())
688 .def(py::init<std::string>())
689 .def(py::init<std::string, CPS::Logger::Level>())
690 .def("set_parameters", &CPS::DP::Ph3::SeriesResistor::setParameters,
691 "R"_a)
693
695 std::shared_ptr<CPS::DP::Ph3::SeriesSwitch>,
697 mDPPh3, "SeriesSwitch", py::multiple_inheritance())
698 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
699 "loglevel"_a = CPS::Logger::Level::off)
700 .def("set_parameters", &CPS::DP::Ph3::SeriesSwitch::setParameters,
701 "open_resistance"_a, "closed_resistance"_a,
702 // cppcheck-suppress assignBoolToPointer
703 "closed"_a = false)
706 .def("connect", &CPS::DP::Ph3::SeriesSwitch::connect);
707
708 py::class_<CPS::DP::Ph3::Switch, std::shared_ptr<CPS::DP::Ph3::Switch>,
710 mDPPh3, "Switch", py::multiple_inheritance())
711 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
712 "loglevel"_a = CPS::Logger::Level::off)
713 .def("set_parameters", &CPS::DP::Ph3::Switch::setParameters,
714 "open_resistance"_a, "closed_resistance"_a,
715 // cppcheck-suppress assignBoolToPointer
716 "closed"_a = false)
719 .def("connect", &CPS::DP::Ph3::Switch::connect);
720
722 std::shared_ptr<CPS::DP::Ph3::SSN::Full_Serial_RLC>,
723 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "Full_Serial_RLC",
724 py::multiple_inheritance())
725 .def(py::init<std::string>())
726 .def(py::init<std::string, CPS::Logger::Level>())
728 "R"_a, "L"_a, "C"_a)
730
732 std::shared_ptr<CPS::DP::Ph3::AvVoltSourceInverterStateSpace>,
734 mDPPh3, "AvVoltSourceInverterStateSpace", py::multiple_inheritance())
735 .def(py::init<std::string, CPS::Logger::Level, CPS::Bool>(), "name"_a,
736 "loglevel"_a = CPS::Logger::Level::off,
737 // cppcheck-suppress assignBoolToPointer
738 "enable_neg_seq_control"_a = false)
739 .def(py::init<std::string, std::string, CPS::Logger::Level, CPS::Bool>(),
740 "uid"_a, "name"_a, "loglevel"_a = CPS::Logger::Level::off,
741 // cppcheck-suppress assignBoolToPointer
742 "enable_neg_seq_control"_a = false)
743 .def("set_parameters",
745 "Cf"_a, "Rf"_a, "Rc"_a, "omega_n"_a, "Kp_pll"_a, "Ki_pll"_a,
746 "omega_cutoff"_a, "p_ref"_a, "q_ref"_a, "Kp_power_ctrl"_a,
747 "Ki_power_ctrl"_a, "Kp_curr_ctrl"_a, "Ki_curr_ctrl"_a,
748 "i_ref_n_d"_a = 0.0, "i_ref_n_q"_a = 0.0)
750 .def_property_readonly("x", createAttributeGetter<CPS::Matrix>("x"))
751 .def_property_readonly("vc_d", createAttributeGetter<CPS::Real>("vc_d"))
752 .def_property_readonly("vc_q", createAttributeGetter<CPS::Real>("vc_q"))
753 .def_property_readonly("irc_d", createAttributeGetter<CPS::Real>("irc_d"))
754 .def_property_readonly("irc_q", createAttributeGetter<CPS::Real>("irc_q"))
755 .def_property_readonly("irc_n_d",
757 .def_property_readonly("irc_n_q",
759 .def_property_readonly("p_inst",
761 .def_property_readonly("q_inst",
763 .def_property_readonly("omega_pll",
765
767 std::shared_ptr<CPS::DP::Ph3::GenericTwoTerminalVTypeSSN>,
769 mDPPh3, "GenericTwoTerminalVTypeSSN", py::multiple_inheritance())
770 .def(py::init<std::string>())
771 .def(py::init<std::string, CPS::Logger::Level>())
772 .def("set_parameters",
774 "B"_a, "C"_a, "D"_a, "D1"_a = CPS::Matrix())
776 .def_property_readonly("x", createAttributeGetter<CPS::MatrixComp>("x"));
777
779 std::shared_ptr<CPS::DP::Ph3::GenericTwoTerminalITypeSSN>,
781 mDPPh3, "GenericTwoTerminalITypeSSN", py::multiple_inheritance())
782 .def(py::init<std::string>())
783 .def(py::init<std::string, CPS::Logger::Level>())
784 .def("set_parameters",
786 "B"_a, "C"_a, "D"_a, "D1"_a = CPS::Matrix())
788 .def_property_readonly("x", createAttributeGetter<CPS::MatrixComp>("x"));
789}
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 setTapRatio(Real tapRatio)
Set a positive tap multiplier applied to the nominal complex ratio.
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.
Common base for three-phase switches.
void setParameters(Matrix openResistance, Matrix closedResistance, Bool closed=false)
void setTapRatio(Real tapRatio)
Set a positive tap multiplier applied to the nominal complex ratio.
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 setTransformerParameters(Real nomVoltagePrimary, Real nomVoltageSecondary, Real ratedPower, Real ratioAbs, Real ratioPhase, Real resistance, Real inductance)
Setter for parameters of transformer.
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 setFilterParameters(Real Lf, Real Cf, Real Rf, Real Rc)
Setter for parameters of filter.
Dynamic phasor ideal current source.
void setCurrentRef(Complex current)
Set the reference through the public attribute interface and mark it explicit.
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
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.
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 setReferenceWinding(WindingReference referenceWinding)
Selects the winding the nameplate impedance is referred to.
void setParameters(Real nomVoltagePrimary, Real nomVoltageSecondary, Real ratioAbs, Real ratioPhase, Real resistance, Real inductance)
Defines component parameters.
void setMagnetizingBranch(Real noLoadCurrent, Real noLoadLoss)
True after createSubComponents() runs; prevents double-construction.
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 setCurrentRef(MatrixComp currentRef)
Set the reference through the public attribute interface and mark it explicit.
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)
Balanced fixed-impedance load and bus shunt as one SSN MNA component.
void setParameters(Real activePower, Real reactivePower, Real nominalVoltage, Real shuntConductance=0., Real shuntSusceptance=0.)
void setParameters(const Matrix &seriesResistance, const Matrix &seriesInductance, const Matrix &parallelCapacitance=Matrix::Zero(3, 3), const Matrix &parallelConductance=Matrix::Zero(3, 3))
void setParameters(Real nomVoltagePrimary, Real nomVoltageSecondary, Real ratedPower, Real ratioAbs, Real ratioPhase, Matrix resistance, Matrix inductance)
void setMagnetizingBranch(Real noLoadCurrent, Real noLoadLoss)
Dynamic phasor three-phase switch.
void closeSwitch() override
void openSwitch() override
Synchronous generator model in dq-reference frame.
void setParameters(Real nomVoltagePrimary, Real nomVoltageSecondary, Real ratedPower, Real ratioAbs, Real ratioPhase, Matrix resistance, Matrix inductance)
Defines component parameters.
void setMagnetizingBranch(Real noLoadCurrent, Real noLoadLoss)
Sets the magnetizing branch from the no-load test quantities.
void setReferenceWinding(WindingReference referenceWinding)
Selects the winding the nameplate impedance is referred to.
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, const Matrix &D1=Matrix())
std::shared_ptr< IdentifiedObject > Ptr
Interface to be used by synchronous generators.
void setComplexInitialVoltageScale(Real scale)
Definition SimNode.h:74
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
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > Matrix
Dense matrix for real numbers.
Definition Definitions.h:79
double Real
Definition Definitions.h:60
std::complex< Real > Complex
Definition Definitions.h:61
CPS::Matrix zeroMatrix(int dim)
Definition Utils.cpp:11