DPsim
Loading...
Searching...
No Matches
DPComponents.cpp
1/* Copyright 2017-2021 Institute for Automation of Complex Power Systems,
2 * EONERC, RWTH Aachen University
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7 *********************************************************************************/
8
9#include <DPsim.h>
10#include <dpsim-models/CSVReader.h>
11#include <dpsim-models/IdentifiedObject.h>
12#include <dpsim/RealTimeSimulation.h>
13#include <dpsim/Simulation.h>
14#include <dpsim/pybind/DPComponents.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>(
29 &CPS::DP::SimNode::setInitialVoltage, py::const_))
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>(
35 &CPS::DP::SimNode::setInitialVoltage, py::const_))
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"),
62 createAttributeSetter<CPS::Complex>("V_ref"))
63 .def_property("f_src", createAttributeGetter<CPS::Real>("f_src"),
64 createAttributeSetter<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::*)(
79 CPS::Complex, CPS::Real, CPS::Real)>(
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"),
95 createAttributeSetter<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"),
105 createAttributeSetter<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"),
115 createAttributeSetter<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"),
125 createAttributeSetter<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",
192 &CPS::DP::Ph1::varResSwitch::setInitParameters, "time_step"_a)
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>())
201 .def("set_parameters", &CPS::DP::Ph1::SSN::Full_Serial_RLC::setParameters,
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",
214 &CPS::DP::Ph1::AvVoltSourceInverterStateSpace::setParameters, "Lf"_a,
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",
225 createAttributeGetter<CPS::Real>("p_inst"))
226 .def_property_readonly("q_inst",
227 createAttributeGetter<CPS::Real>("q_inst"))
228 .def_property_readonly("omega_pll",
229 createAttributeGetter<CPS::Real>("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",
238 &CPS::DP::Ph1::GenericTwoTerminalVTypeSSN::setParameters, "A"_a,
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",
250 &CPS::DP::Ph1::GenericTwoTerminalITypeSSN::setParameters, "A"_a,
251 "B"_a, "C"_a, "D"_a)
253 .def_property_readonly("x", createAttributeGetter<CPS::MatrixComp>("x"));
254
256 std::shared_ptr<CPS::DP::Ph1::SynchronGeneratorTrStab>,
257 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "SynchronGeneratorTrStab",
258 py::multiple_inheritance())
259 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
260 "loglevel"_a = CPS::Logger::Level::off)
261 .def("set_standard_parameters_PU",
263 "nom_power"_a, "nom_volt"_a, "nom_freq"_a, "Xpd"_a, "inertia"_a,
264 "Rs"_a = 0, "D"_a = 0)
265 .def("set_fundamental_parameters_PU",
267 "nom_power"_a, "nom_volt"_a, "nom_freq"_a, "Ll"_a, "Lmd"_a, "Llfd"_a,
268 "H"_a, "D"_a = 0)
269 .def("set_initial_values",
270 &CPS::DP::Ph1::SynchronGeneratorTrStab::setInitialValues,
271 "elec_power"_a, "mech_power"_a)
273 .def("set_model_flags",
275 "convert_with_omega_mech"_a)
276 .def(
277 "set_reference_omega",
279 std::string refOmegaName, CPS::IdentifiedObject::Ptr refOmegaComp,
280 std::string refDeltaName,
281 CPS::IdentifiedObject::Ptr refDeltaComp) {
282 gen.setReferenceOmega(
283 refOmegaComp->attributeTyped<CPS::Real>(refOmegaName),
284 refDeltaComp->attributeTyped<CPS::Real>(refDeltaName));
285 },
286 "ref_omega_name"_a = "w_r", "ref_omage_comp"_a,
287 "ref_delta_name"_a = "delta_r", "ref_delta_comp"_a);
288
290 std::shared_ptr<CPS::DP::Ph1::ReducedOrderSynchronGeneratorVBR>,
292 mDPPh1, "ReducedOrderSynchronGeneratorVBR", py::multiple_inheritance());
293
295 std::shared_ptr<CPS::DP::Ph1::SynchronGenerator3OrderVBR>,
297 mDPPh1, "SynchronGenerator3OrderVBR", py::multiple_inheritance())
298 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
299 "loglevel"_a = CPS::Logger::Level::off)
300 .def("set_operational_parameters_per_unit",
301 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
302 CPS::Real, CPS::Real, CPS::Real, CPS::Real,
303 CPS::Real>(
305 setOperationalParametersPerUnit),
306 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
307 "Lq"_a, "L0"_a, "Ld_t"_a, "Td0_t"_a)
309
311 std::shared_ptr<CPS::DP::Ph1::SynchronGenerator4OrderVBR>,
313 mDPPh1, "SynchronGenerator4OrderVBR", py::multiple_inheritance())
314 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
315 "loglevel"_a = CPS::Logger::Level::off)
316 .def("set_operational_parameters_per_unit",
317 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
318 CPS::Real, CPS::Real, CPS::Real, CPS::Real,
319 CPS::Real, CPS::Real, CPS::Real>(
321 setOperationalParametersPerUnit),
322 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
323 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a)
325
327 std::shared_ptr<CPS::DP::Ph1::SynchronGenerator5OrderVBR>,
329 mDPPh1, "SynchronGenerator5OrderVBR", py::multiple_inheritance())
330 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
331 "loglevel"_a = CPS::Logger::Level::off)
332 .def("set_operational_parameters_per_unit",
333 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
334 CPS::Real, CPS::Real, CPS::Real, CPS::Real,
335 CPS::Real, CPS::Real, CPS::Real, CPS::Real,
336 CPS::Real, CPS::Real, CPS::Real, CPS::Real>(
338 setOperationalParametersPerUnit),
339 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
340 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a, "Ld_s"_a,
341 "Lq_s"_a, "Td0_s"_a, "Tq0_s"_a, "Taa"_a)
343
345 std::shared_ptr<CPS::DP::Ph1::SynchronGenerator6aOrderVBR>,
347 mDPPh1, "SynchronGenerator6aOrderVBR", py::multiple_inheritance())
348 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
349 "loglevel"_a = CPS::Logger::Level::off)
350 .def("set_operational_parameters_per_unit",
351 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
352 CPS::Real, CPS::Real, CPS::Real, CPS::Real,
353 CPS::Real, CPS::Real, CPS::Real, CPS::Real,
354 CPS::Real, CPS::Real, CPS::Real, CPS::Real>(
356 setOperationalParametersPerUnit),
357 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
358 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a, "Ld_s"_a,
359 "Lq_s"_a, "Td0_s"_a, "Tq0_s"_a, "Taa"_a)
361
363 std::shared_ptr<CPS::DP::Ph1::SynchronGenerator6bOrderVBR>,
365 mDPPh1, "SynchronGenerator6bOrderVBR", py::multiple_inheritance())
366 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
367 "loglevel"_a = CPS::Logger::Level::off)
368 .def("set_operational_parameters_per_unit",
369 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
370 CPS::Real, CPS::Real, CPS::Real, CPS::Real,
371 CPS::Real, CPS::Real, CPS::Real, CPS::Real,
372 CPS::Real, CPS::Real, CPS::Real, CPS::Real>(
374 setOperationalParametersPerUnit),
375 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
376 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a, "Ld_s"_a,
377 "Lq_s"_a, "Td0_s"_a, "Tq0_s"_a, "Taa"_a = 0)
379
381 std::shared_ptr<CPS::DP::Ph1::SynchronGenerator4OrderTPM>,
383 CPS::MNASyncGenInterface>(mDPPh1, "SynchronGenerator4OrderTPM",
384 py::multiple_inheritance())
385 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
386 "loglevel"_a = CPS::Logger::Level::off)
387 .def("set_operational_parameters_per_unit",
388 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
389 CPS::Real, CPS::Real, CPS::Real, CPS::Real,
390 CPS::Real, CPS::Real, CPS::Real>(
392 setOperationalParametersPerUnit),
393 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
394 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a)
396
398 std::shared_ptr<CPS::DP::Ph1::SynchronGenerator4OrderPCM>,
400 CPS::MNASyncGenInterface>(mDPPh1, "SynchronGenerator4OrderPCM",
401 py::multiple_inheritance())
402 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
403 "loglevel"_a = CPS::Logger::Level::off)
404 .def("set_operational_parameters_per_unit",
405 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
406 CPS::Real, CPS::Real, CPS::Real, CPS::Real,
407 CPS::Real, CPS::Real, CPS::Real>(
409 setOperationalParametersPerUnit),
410 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
411 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a)
413
415 std::shared_ptr<CPS::DP::Ph1::SynchronGenerator6OrderPCM>,
417 CPS::MNASyncGenInterface>(mDPPh1, "SynchronGenerator6OrderPCM",
418 py::multiple_inheritance())
419 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
420 "loglevel"_a = CPS::Logger::Level::off)
421 .def("set_operational_parameters_per_unit",
422 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
423 CPS::Real, CPS::Real, CPS::Real, CPS::Real,
424 CPS::Real, CPS::Real, CPS::Real, CPS::Real,
425 CPS::Real, CPS::Real, CPS::Real, CPS::Real>(
427 setOperationalParametersPerUnit),
428 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a, "H"_a, "Ld"_a,
429 "Lq"_a, "L0"_a, "Ld_t"_a, "Lq_t"_a, "Td0_t"_a, "Tq0_t"_a, "Ld_s"_a,
430 "Lq_s"_a, "Td0_s"_a, "Tq0_s"_a, "Taa"_a = 0)
432
434 std::shared_ptr<CPS::DP::Ph1::AvVoltageSourceInverterDQ>,
436 mDPPh1, "AvVoltageSourceInverterDQ", py::multiple_inheritance())
437 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
438 "loglevel"_a = CPS::Logger::Level::off)
439 .def(py::init<std::string, std::string, CPS::Logger::Level, CPS::Bool>(),
440 "uid"_a, "name"_a, "loglevel"_a = CPS::Logger::Level::off,
441 // cppcheck-suppress assignBoolToPointer
442 "with_trafo"_a = false)
443 .def("set_parameters",
445 "sys_omega"_a, "sys_volt_nom"_a, "p_ref"_a, "q_ref"_a)
446 .def("set_filter_parameters",
448 "Lf"_a, "Cf"_a, "Rf"_a, "Rc"_a)
449 .def("set_controller_parameters",
451 "Kp_pll"_a, "Ki_pll"_a, "Kp_power_ctrl"_a, "Ki_power_ctrl"_a,
452 "Kp_curr_ctrl"_a, "Ki_curr_ctrl"_a, "omega_cutoff"_a)
453 .def("set_transformer_parameters",
455 "nom_voltage_end_1"_a, "nom_voltage_end_2"_a, "rated_power"_a,
456 "ratio_abs"_a, "ratio_phase"_a, "resistance"_a, "inductance"_a)
457 .def("set_initial_state_values",
459 "p_init"_a, "q_init"_a, "phi_d_init"_a, "phi_q_init"_a,
460 "gamma_d_init"_a, "gamma_q_init"_a)
461 .def("with_control",
462 &CPS::DP::Ph1::AvVoltageSourceInverterDQ::withControl)
464
465 py::class_<CPS::DP::Ph1::Inverter, std::shared_ptr<CPS::DP::Ph1::Inverter>,
466 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "Inverter",
467 py::multiple_inheritance())
468 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
469 "loglevel"_a = CPS::Logger::Level::off)
470 .def("set_parameters", &CPS::DP::Ph1::Inverter::setParameters,
471 "carrier_harms"_a, "modul_harms"_a, "input_voltage"_a, "ratio"_a,
472 "phase"_a)
473 .def("connect", &CPS::DP::Ph1::Inverter::connect);
474
475 py::class_<CPS::DP::Ph1::Transformer,
476 std::shared_ptr<CPS::DP::Ph1::Transformer>,
477 CPS::SimPowerComp<CPS::Complex>>(mDPPh1, "Transformer",
478 py::multiple_inheritance())
479 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
480 "loglevel"_a = CPS::Logger::Level::off)
481 .def(py::init<std::string, std::string, CPS::Logger::Level, CPS::Bool>(),
482 "uid"_a, "name"_a, "loglevel"_a = CPS::Logger::Level::off,
483 // cppcheck-suppress assignBoolToPointer
484 "with_resistive_losses"_a = false)
485 .def("set_parameters",
486 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
487 CPS::Real, CPS::Real>(
489 "nom_voltage_end_1"_a, "nom_voltage_end_2"_a, "ratio_abs"_a,
490 "ratio_phase"_a, "resistance"_a, "inductance"_a)
491 .def("set_parameters",
492 py::overload_cast<CPS::Real, CPS::Real, CPS::Real, CPS::Real,
493 CPS::Real, CPS::Real, CPS::Real>(
495 "nom_voltage_end_1"_a, "nom_voltage_end_2"_a, "rated_power"_a,
496 "ratio_abs"_a, "ratio_phase"_a, "resistance"_a, "inductance"_a)
497 .def("connect", &CPS::DP::Ph1::Transformer::connect);
498}
499
500void addDPPh3Components(py::module_ mDPPh3) {
502 std::shared_ptr<CPS::DP::Ph3::VoltageSource>,
503 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "VoltageSource",
504 py::multiple_inheritance())
505 .def(py::init<std::string>())
506 .def(py::init<std::string, CPS::Logger::Level>())
507 .def("set_parameters", &CPS::DP::Ph3::VoltageSource::setParameters,
508 "V_ref"_a, "f_src"_a = 0.0)
510 .def_property("V_ref", createAttributeGetter<CPS::MatrixComp>("V_ref"),
511 createAttributeSetter<CPS::MatrixComp>("V_ref"))
512 .def_property("f_src", createAttributeGetter<CPS::Real>("f_src"),
513 createAttributeSetter<CPS::Real>("f_src"));
514
516 std::shared_ptr<CPS::DP::Ph3::CurrentSource>,
517 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "CurrentSource",
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::CurrentSource::setParameters,
522 "I_ref"_a, "f_src"_a = 0.0)
524 .def_property("I_ref", createAttributeGetter<CPS::MatrixComp>("I_ref"),
525 createAttributeSetter<CPS::MatrixComp>("I_ref"))
526 .def_property("f_src", createAttributeGetter<CPS::Real>("f_src"),
527 createAttributeSetter<CPS::Real>("f_src"));
528
529 py::class_<CPS::DP::Ph3::Resistor, std::shared_ptr<CPS::DP::Ph3::Resistor>,
530 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "Resistor",
531 py::multiple_inheritance())
532 .def(py::init<std::string>())
533 .def(py::init<std::string, CPS::Logger::Level>())
534 .def("set_parameters", &CPS::DP::Ph3::Resistor::setParameters, "R"_a)
535 .def("connect", &CPS::DP::Ph3::Resistor::connect);
536
537 py::class_<CPS::DP::Ph3::Inductor, std::shared_ptr<CPS::DP::Ph3::Inductor>,
538 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "Inductor",
539 py::multiple_inheritance())
540 .def(py::init<std::string>())
541 .def(py::init<std::string, CPS::Logger::Level>())
542 .def("set_parameters", &CPS::DP::Ph3::Inductor::setParameters, "L"_a)
543 .def("connect", &CPS::DP::Ph3::Inductor::connect);
544
545 py::class_<CPS::DP::Ph3::Capacitor, std::shared_ptr<CPS::DP::Ph3::Capacitor>,
546 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "Capacitor",
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::Capacitor::setParameters, "C"_a)
551 .def("connect", &CPS::DP::Ph3::Capacitor::connect);
552
553#ifdef WITH_SUNDIALS
554
556 std::shared_ptr<CPS::DP::Ph3::SynchronGeneratorDQODE>,
557 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "SynchronGeneratorDQODE",
558 py::multiple_inheritance())
559 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
560 "loglevel"_a = CPS::Logger::Level::off)
561 .def("set_parameters_fundamental_per_unit",
563 setParametersFundamentalPerUnit,
564 "nom_power"_a, "nom_volt"_a, "nom_freq"_a, "pole_number"_a,
565 "nom_field_cur"_a, "Rs"_a, "Ll"_a, "Lmd"_a, "Lmq"_a, "Rfd"_a,
566 "Llfd"_a, "Rkd"_a, "Llkd"_a, "Rkq1"_a, "Llkq1"_a, "Rkq2"_a,
567 "Llkq2"_a, "inertia"_a, "init_active_power"_a,
568 "init_reactive_power"_a, "init_terminal_volt"_a, "init_volt_angle"_a,
569 "init_mech_power"_a)
571
572#endif
573
575 std::shared_ptr<CPS::DP::Ph3::SynchronGeneratorDQTrapez>,
577 mDPPh3, "SynchronGeneratorDQTrapez", py::multiple_inheritance())
578 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
579 "loglevel"_a = CPS::Logger::Level::off)
580 .def("set_parameters_fundamental_per_unit",
582 setParametersFundamentalPerUnit,
583 "nom_power"_a, "nom_volt"_a, "nom_freq"_a, "pole_number"_a,
584 "nom_field_cur"_a, "Rs"_a, "Ll"_a, "Lmd"_a, "Lmq"_a, "Rfd"_a,
585 "Llfd"_a, "Rkd"_a, "Llkd"_a, "Rkq1"_a, "Llkq1"_a, "Rkq2"_a,
586 "Llkq2"_a, "inertia"_a, "init_active_power"_a,
587 "init_reactive_power"_a, "init_terminal_volt"_a, "init_volt_angle"_a,
588 "init_mech_power"_a)
590
592 std::shared_ptr<CPS::DP::Ph3::SeriesResistor>,
593 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "SeriesResistor",
594 py::multiple_inheritance())
595 .def(py::init<std::string>())
596 .def(py::init<std::string, CPS::Logger::Level>())
597 .def("set_parameters", &CPS::DP::Ph3::SeriesResistor::setParameters,
598 "R"_a)
600
602 std::shared_ptr<CPS::DP::Ph3::SeriesSwitch>,
604 mDPPh3, "SeriesSwitch", py::multiple_inheritance())
605 .def(py::init<std::string, CPS::Logger::Level>(), "name"_a,
606 "loglevel"_a = CPS::Logger::Level::off)
607 .def("set_parameters", &CPS::DP::Ph3::SeriesSwitch::setParameters,
608 "open_resistance"_a, "closed_resistance"_a,
609 // cppcheck-suppress assignBoolToPointer
610 "closed"_a = false)
613 .def("connect", &CPS::DP::Ph3::SeriesSwitch::connect);
614
616 std::shared_ptr<CPS::DP::Ph3::SSN::Full_Serial_RLC>,
617 CPS::SimPowerComp<CPS::Complex>>(mDPPh3, "Full_Serial_RLC",
618 py::multiple_inheritance())
619 .def(py::init<std::string>())
620 .def(py::init<std::string, CPS::Logger::Level>())
621 .def("set_parameters", &CPS::DP::Ph3::SSN::Full_Serial_RLC::setParameters,
622 "R"_a, "L"_a, "C"_a)
624
626 std::shared_ptr<CPS::DP::Ph3::GenericTwoTerminalVTypeSSN>,
628 mDPPh3, "GenericTwoTerminalVTypeSSN", py::multiple_inheritance())
629 .def(py::init<std::string>())
630 .def(py::init<std::string, CPS::Logger::Level>())
631 .def("set_parameters",
632 &CPS::DP::Ph3::GenericTwoTerminalVTypeSSN::setParameters, "A"_a,
633 "B"_a, "C"_a, "D"_a)
635 .def_property_readonly("x", createAttributeGetter<CPS::MatrixComp>("x"));
636
638 std::shared_ptr<CPS::DP::Ph3::GenericTwoTerminalITypeSSN>,
640 mDPPh3, "GenericTwoTerminalITypeSSN", py::multiple_inheritance())
641 .def(py::init<std::string>())
642 .def(py::init<std::string, CPS::Logger::Level>())
643 .def("set_parameters",
644 &CPS::DP::Ph3::GenericTwoTerminalITypeSSN::setParameters, "A"_a,
645 "B"_a, "C"_a, "D"_a)
647 .def_property_readonly("x", createAttributeGetter<CPS::MatrixComp>("x"));
648}
void setParameters(Real capacitance)
Sets model specific parameters.
void setParameters(Real inductance)
Sets model specific parameters.
Dynamic Phasor Three-Phase Switch.
void close()
Close switch.
void open()
Open switch.
void setParameters(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 resistance)
Sets model specific parameters.
Averaged grid-following VSI SSN port of EMT::Ph3::AvVoltSourceInverterStateSpace: 8 real control stat...
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.
Generic single-phase, two-terminal I-type SSN component.
Generic single-phase, two-terminal V-type SSN component.
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 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...
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 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.
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...
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.
Series RLC one-port as a three-phase DP V-type SSN component.
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.
Interface to be used by synchronous generators.
Base class for all components that are transmitting power.
void connect(typename SimNode< Complex >::List nodes)