27#include <nlohmann/json.hpp>
28using json = nlohmann::json;
33namespace py = pybind11;
34using namespace pybind11::literals;
38void addEMTDCComponents(py::module_ mEMTDC) {
40 std::shared_ptr<CPS::EMT::DC::VoltageSource>,
42 py::multiple_inheritance())
43 .def(py::init<std::string, CPS::Logger::Level>(),
"name"_a,
44 "loglevel"_a = CPS::Logger::Level::off)
48 .def_property_readonly(
"V_ref",
52 std::shared_ptr<CPS::EMT::DC::CurrentSource>,
54 py::multiple_inheritance())
55 .def(py::init<std::string, CPS::Logger::Level>(),
"name"_a,
56 "loglevel"_a = CPS::Logger::Level::off)
60 .def_property_readonly(
"I_ref",
63 py::class_<CPS::EMT::DC::Resistor, std::shared_ptr<CPS::EMT::DC::Resistor>,
65 py::multiple_inheritance())
66 .def(py::init<std::string, CPS::Logger::Level>(),
"name"_a,
67 "loglevel"_a = CPS::Logger::Level::off)
73 py::class_<CPS::EMT::DC::Capacitor, std::shared_ptr<CPS::EMT::DC::Capacitor>,
75 py::multiple_inheritance())
76 .def(py::init<std::string, CPS::Logger::Level>(),
"name"_a,
77 "loglevel"_a = CPS::Logger::Level::off)
84 py::class_<CPS::EMT::DC::Inductor, std::shared_ptr<CPS::EMT::DC::Inductor>,
86 py::multiple_inheritance())
87 .def(py::init<std::string, CPS::Logger::Level>(),
"name"_a,
88 "loglevel"_a = CPS::Logger::Level::off)
90 "inductance"_a,
"initial_current"_a = 0.0)
93 .def_property_readonly(
"initial_current",
97 py::class_<CPS::EMT::DC::PiLine, std::shared_ptr<CPS::EMT::DC::PiLine>,
99 py::multiple_inheritance())
100 .def(py::init<std::string, CPS::Logger::Level>(),
"name"_a,
101 "loglevel"_a = CPS::Logger::Level::off)
103 "series_resistance"_a,
"series_inductance"_a,
104 "parallel_capacitance"_a = 0.0,
"parallel_conductance"_a = 0.0,
105 "initial_current"_a = 0.0)
107 .def_property_readonly(
"series_resistance",
109 .def_property_readonly(
"series_inductance",
111 .def_property_readonly(
"parallel_capacitance",
113 .def_property_readonly(
"parallel_conductance",
115 .def_property_readonly(
"initial_current",
122 py::class_<CPS::EMT::SimNode, std::shared_ptr<CPS::EMT::SimNode>,
124 .def(py::init<std::string>())
125 .def(py::init<std::string, CPS::PhaseType>())
127 const std::vector<CPS::Complex>>())
128 .def(
"set_initial_voltage",
129 py::overload_cast<CPS::MatrixComp>(
131 .def(
"set_initial_voltage",
132 py::overload_cast<CPS::Complex>(
134 .def(
"set_initial_voltage",
135 py::overload_cast<CPS::Complex, int>(
140 mEMT.def_submodule(
"dc",
"scalar electromagnetic-transient DC models");
141 addEMTDCComponents(mEMTDC);
143 py::module mEMTPh1 = mEMT.def_submodule(
144 "ph1",
"single phase electromagnetic-transient models");
147 mEMT.def_submodule(
"ph3",
"three phase electromagnetic-transient models");
153 std::shared_ptr<CPS::EMT::Ph1::CurrentSource>,
155 py::multiple_inheritance())
156 .def(py::init<std::string>())
157 .def(py::init<std::string, CPS::Logger::Level>())
159 "I_ref"_a,
"f_src"_a = -1)
167 std::shared_ptr<CPS::EMT::Ph1::VoltageSource>,
169 py::multiple_inheritance())
170 .def(py::init<std::string>())
171 .def(py::init<std::string, CPS::Logger::Level>())
173 "V_ref"_a,
"f_src"_a = -1)
180 py::class_<CPS::EMT::Ph1::Resistor, std::shared_ptr<CPS::EMT::Ph1::Resistor>,
182 py::multiple_inheritance())
183 .def(py::init<std::string>())
184 .def(py::init<std::string, CPS::Logger::Level>())
191 std::shared_ptr<CPS::EMT::Ph1::Capacitor>,
193 py::multiple_inheritance())
194 .def(py::init<std::string>())
195 .def(py::init<std::string, CPS::Logger::Level>())
201 py::class_<CPS::EMT::Ph1::Inductor, std::shared_ptr<CPS::EMT::Ph1::Inductor>,
203 py::multiple_inheritance())
204 .def(py::init<std::string>())
205 .def(py::init<std::string, CPS::Logger::Level>())
211 py::class_<CPS::EMT::Ph1::Switch, std::shared_ptr<CPS::EMT::Ph1::Switch>,
213 mEMTPh1,
"Switch", py::multiple_inheritance())
214 .def(py::init<std::string, CPS::Logger::Level>(),
"name"_a,
215 "loglevel"_a = CPS::Logger::Level::off)
217 "open_resistance"_a,
"closed_resistance"_a,
224 std::shared_ptr<CPS::EMT::Ph1::SSN::Full_Serial_RLC>,
226 py::multiple_inheritance())
227 .def(py::init<std::string>())
228 .def(py::init<std::string, CPS::Logger::Level>())
229 .def(
"set_parameters",
241 std::shared_ptr<CPS::EMT::Ph1::SSNTypeI2T>,
243 py::multiple_inheritance())
244 .def(py::init<std::string>())
245 .def(py::init<std::string, CPS::Logger::Level>())
249 "initialState"_a,
"initialInput"_a,
"initialOldInput"_a,
250 "initCurr"_a,
"initVol"_a)
268 std::shared_ptr<CPS::EMT::Ph1::SSNTypeV2T>,
270 py::multiple_inheritance())
271 .def(py::init<std::string>())
272 .def(py::init<std::string, CPS::Logger::Level>())
276 "initialState"_a,
"initialInput"_a,
"initialOldInput"_a,
277 "initCurr"_a,
"initVol"_a)
297 std::shared_ptr<CPS::EMT::Ph3::VoltageSource>,
299 py::multiple_inheritance())
300 .def(py::init<std::string>())
301 .def(py::init<std::string, CPS::Logger::Level>())
302 .def(
"set_parameters",
303 py::overload_cast<CPS::MatrixComp, CPS::Real>(
305 "V_ref"_a,
"f_src"_a = 50)
313 std::shared_ptr<CPS::EMT::Ph3::ControlledVoltageSource>,
315 py::multiple_inheritance())
316 .def(py::init<std::string>())
317 .def(py::init<std::string, CPS::Logger::Level>())
318 .def(
"set_parameters",
319 py::overload_cast<CPS::Matrix>(
327 std::shared_ptr<CPS::EMT::Ph3::CurrentSource>,
329 py::multiple_inheritance())
330 .def(py::init<std::string>())
331 .def(py::init<std::string, CPS::Logger::Level>())
332 .def(
"set_parameters",
333 py::overload_cast<CPS::MatrixComp, CPS::Real>(
335 "I_ref"_a,
"f_src"_a = 50)
342 py::class_<CPS::EMT::Ph3::Resistor, std::shared_ptr<CPS::EMT::Ph3::Resistor>,
344 py::multiple_inheritance())
345 .def(py::init<std::string>())
346 .def(py::init<std::string, CPS::Logger::Level>())
351 std::shared_ptr<CPS::EMT::Ph3::Capacitor>,
353 py::multiple_inheritance())
354 .def(py::init<std::string>())
355 .def(py::init<std::string, CPS::Logger::Level>())
359 py::class_<CPS::EMT::Ph3::Inductor, std::shared_ptr<CPS::EMT::Ph3::Inductor>,
361 py::multiple_inheritance())
362 .def(py::init<std::string>())
363 .def(py::init<std::string, CPS::Logger::Level>())
368 std::shared_ptr<CPS::EMT::Ph3::NetworkInjection>,
370 py::multiple_inheritance())
371 .def(py::init<std::string, CPS::Logger::Level>(),
"name"_a,
372 "loglevel"_a = CPS::Logger::Level::off)
373 .def(
"set_parameters",
374 py::overload_cast<CPS::MatrixComp, CPS::Real>(
376 "V_ref"_a,
"f_src"_a = 50)
379 py::class_<CPS::EMT::Ph3::PiLine, std::shared_ptr<CPS::EMT::Ph3::PiLine>,
381 py::multiple_inheritance())
382 .def(py::init<std::string, CPS::Logger::Level>(),
"name"_a,
383 "loglevel"_a = CPS::Logger::Level::off)
385 "series_resistance"_a,
"series_inductance"_a,
391 std::shared_ptr<CPS::EMT::Ph3::HalfDecouplingLine>,
393 py::multiple_inheritance())
394 .def(py::init<std::string, CPS::Logger::Level>(),
"name"_a,
395 "loglevel"_a = CPS::Logger::Level::off)
397 "resistance"_a,
"inductance"_a,
"capacitance"_a)
398 .def(
"set_coupling_source",
400 "receiving_volt"_a,
"receiving_cur"_a)
403 py::class_<CPS::EMT::Ph3::RXLoad, std::shared_ptr<CPS::EMT::Ph3::RXLoad>,
405 py::multiple_inheritance())
406 .def(py::init<std::string, CPS::Logger::Level>(),
"name"_a,
407 "loglevel"_a = CPS::Logger::Level::off)
409 "active_power"_a,
"reactive_power"_a,
"volt"_a,
411 "reactance_in_series"_a =
false)
414 py::class_<CPS::EMT::Ph3::PQLoad, std::shared_ptr<CPS::EMT::Ph3::PQLoad>,
416 mEMTPh3,
"PQLoad", py::multiple_inheritance())
417 .def(py::init<std::string, CPS::Logger::Level>(),
"name"_a,
418 "loglevel"_a = CPS::Logger::Level::off)
420 "active_power"_a,
"reactive_power"_a,
"nominal_voltage"_a,
421 "minimum_voltage_per_unit"_a = 0.1)
431 .def_property_readonly(
"p_inst",
433 .def_property_readonly(
"q_inst",
436 py::class_<CPS::EMT::Ph3::Shunt, std::shared_ptr<CPS::EMT::Ph3::Shunt>,
438 py::multiple_inheritance())
439 .def(py::init<std::string, CPS::Logger::Level>(),
"name"_a,
440 "loglevel"_a = CPS::Logger::Level::off)
441 .def(
"set_parameters",
447 py::class_<CPS::EMT::Ph3::Switch, std::shared_ptr<CPS::EMT::Ph3::Switch>,
449 mEMTPh3,
"Switch", py::multiple_inheritance())
450 .def(py::init<std::string, CPS::Logger::Level>(),
"name"_a,
451 "loglevel"_a = CPS::Logger::Level::off)
453 "open_resistance"_a,
"closed_resistance"_a,
461 std::shared_ptr<CPS::EMT::Ph3::SynchronGeneratorIdeal>,
463 py::multiple_inheritance())
464 .def(py::init<std::string, CPS::Logger::Level>(),
"name"_a,
465 "loglevel"_a = CPS::Logger::Level::off)
469 std::shared_ptr<CPS::EMT::Ph3::SynchronGeneratorDQTrapez>,
471 py::multiple_inheritance())
472 .def(py::init<std::string, CPS::Logger::Level>(),
"name"_a,
473 "loglevel"_a = CPS::Logger::Level::off)
474 .def(
"set_parameters_operational_per_unit",
476 setParametersOperationalPerUnit,
477 "nom_power"_a,
"nom_volt"_a,
"nom_freq"_a,
"pole_number"_a,
478 "nom_field_cur"_a,
"Rs"_a,
"Ld"_a,
"Lq"_a,
"Ld_t"_a,
"Lq_t"_a,
479 "Ld_s"_a,
"Lq_s"_a,
"Ll"_a,
"Td0_t"_a,
"Tq0_t"_a,
"Td0_s"_a,
480 "Tq0_s"_a,
"inertia"_a)
481 .def(
"set_parameters_fundamental_per_unit",
483 setParametersFundamentalPerUnit,
484 "nom_power"_a,
"nom_volt"_a,
"nom_freq"_a,
"pole_number"_a,
485 "nom_field_cur"_a,
"Rs"_a,
"Ll"_a,
"Lmd"_a,
"Lmq"_a,
"Rfd"_a,
486 "Llfd"_a,
"Rkd"_a,
"Llkd"_a,
"Rkq1"_a,
"Llkq1"_a,
"Rkq2"_a,
487 "Llkq2"_a,
"inertia"_a,
"init_active_power"_a,
488 "init_reactive_power"_a,
"init_terminal_volt"_a,
"init_volt_angle"_a,
491 .def(
"apply_parameters_from_json",
492 [](std::shared_ptr<CPS::EMT::Ph3::SynchronGeneratorDQTrapez> syngen,
494 DPsim::Utils::applySynchronousGeneratorParametersFromJson(
495 json::parse(json), syngen);
498 .def(
"set_initial_values",
500 "init_active_power"_a,
"init_reactive_power"_a,
501 "init_terminal_volt"_a,
"init_volt_angle"_a,
"init_mech_power"_a);
504 std::shared_ptr<CPS::EMT::Ph3::VSIVoltageControlVCO>,
506 py::multiple_inheritance())
507 .def(py::init<std::string>())
508 .def(py::init<std::string, CPS::Logger::Level>())
509 .def(py::init<std::string, std::string, CPS::Logger::Level, CPS::Bool>(),
510 "uid"_a,
"name"_a,
"log_level"_a = CPS::Logger::Level::off,
511 py::arg(
"with_trafo") =
false)
512 .def(
"set_parameters",
514 "vd_ref"_a,
"vq_ref"_a)
515 .def(
"set_controller_parameters",
517 "kp_voltage_ctrl"_a,
"ki_voltage_ctrl"_a,
"kp_curr_ctrl"_a,
518 "ki_curr_ctrl"_a,
"omega_nominal"_a)
519 .def(
"set_transformer_parameters",
521 "nom_voltage_end1"_a,
"nom_voltage_end2"_a,
"rated_power"_a,
522 "ratio_abs"_a,
"ratio_phase"_a,
"resistance"_a,
"inductance"_a,
524 .def(
"set_filter_parameters",
526 "cf"_a,
"rf"_a,
"rc"_a)
527 .def(
"set_initial_state_values",
529 "phi_d_init"_a,
"phi_q_init"_a,
"gamma_d_init"_a,
"gamma_q_init"_a)
535 std::shared_ptr<CPS::EMT::Ph3::ReducedOrderSynchronGeneratorVBR>,
537 mEMTPh3,
"ReducedOrderSynchronGeneratorVBR", py::multiple_inheritance());
540 std::shared_ptr<CPS::EMT::Ph3::SynchronGenerator3OrderVBR>,
542 mEMTPh3,
"SynchronGenerator3OrderVBR", py::multiple_inheritance())
543 .def(py::init<std::string, CPS::Logger::Level>(),
"name"_a,
544 "loglevel"_a = CPS::Logger::Level::off)
545 .def(
"set_operational_parameters_per_unit",
550 setOperationalParametersPerUnit),
551 "nom_power"_a,
"nom_voltage"_a,
"nom_frequency"_a,
"H"_a,
"Ld"_a,
552 "Lq"_a,
"L0"_a,
"Ld_t"_a,
"Td0_t"_a)
556 std::shared_ptr<CPS::EMT::Ph3::SynchronGenerator4OrderVBR>,
558 mEMTPh3,
"SynchronGenerator4OrderVBR", py::multiple_inheritance())
559 .def(py::init<std::string, CPS::Logger::Level>(),
"name"_a,
560 "loglevel"_a = CPS::Logger::Level::off)
561 .def(
"set_operational_parameters_per_unit",
566 setOperationalParametersPerUnit),
567 "nom_power"_a,
"nom_voltage"_a,
"nom_frequency"_a,
"H"_a,
"Ld"_a,
568 "Lq"_a,
"L0"_a,
"Ld_t"_a,
"Lq_t"_a,
"Td0_t"_a,
"Tq0_t"_a)
572 std::shared_ptr<CPS::EMT::Ph3::SynchronGenerator5OrderVBR>,
574 mEMTPh3,
"SynchronGenerator5OrderVBR", py::multiple_inheritance())
575 .def(py::init<std::string, CPS::Logger::Level>(),
"name"_a,
576 "loglevel"_a = CPS::Logger::Level::off)
577 .def(
"set_operational_parameters_per_unit",
583 setOperationalParametersPerUnit),
584 "nom_power"_a,
"nom_voltage"_a,
"nom_frequency"_a,
"H"_a,
"Ld"_a,
585 "Lq"_a,
"L0"_a,
"Ld_t"_a,
"Lq_t"_a,
"Td0_t"_a,
"Tq0_t"_a,
"Ld_s"_a,
586 "Lq_s"_a,
"Td0_s"_a,
"Tq0_s"_a,
"Taa"_a)
590 std::shared_ptr<CPS::EMT::Ph3::SynchronGenerator6aOrderVBR>,
592 mEMTPh3,
"SynchronGenerator6aOrderVBR", py::multiple_inheritance())
593 .def(py::init<std::string, CPS::Logger::Level>(),
"name"_a,
594 "loglevel"_a = CPS::Logger::Level::off)
595 .def(
"set_operational_parameters_per_unit",
601 setOperationalParametersPerUnit),
602 "nom_power"_a,
"nom_voltage"_a,
"nom_frequency"_a,
"H"_a,
"Ld"_a,
603 "Lq"_a,
"L0"_a,
"Ld_t"_a,
"Lq_t"_a,
"Td0_t"_a,
"Tq0_t"_a,
"Ld_s"_a,
604 "Lq_s"_a,
"Td0_s"_a,
"Tq0_s"_a,
"Taa"_a)
608 std::shared_ptr<CPS::EMT::Ph3::SynchronGenerator6bOrderVBR>,
610 mEMTPh3,
"SynchronGenerator6bOrderVBR", py::multiple_inheritance())
611 .def(py::init<std::string, CPS::Logger::Level>(),
"name"_a,
612 "loglevel"_a = CPS::Logger::Level::off)
613 .def(
"set_operational_parameters_per_unit",
619 setOperationalParametersPerUnit),
620 "nom_power"_a,
"nom_voltage"_a,
"nom_frequency"_a,
"H"_a,
"Ld"_a,
621 "Lq"_a,
"L0"_a,
"Ld_t"_a,
"Lq_t"_a,
"Td0_t"_a,
"Tq0_t"_a,
"Ld_s"_a,
622 "Lq_s"_a,
"Td0_s"_a,
"Tq0_s"_a,
"Taa"_a = 0)
628 std::shared_ptr<CPS::EMT::Ph3::SynchronGeneratorDQODE>,
630 py::multiple_inheritance())
631 .def(py::init<std::string, CPS::Logger::Level>(),
"name"_a,
632 "loglevel"_a = CPS::Logger::Level::off)
633 .def(
"set_parameters_operational_per_unit",
635 setParametersOperationalPerUnit,
636 "nom_power"_a,
"nom_volt"_a,
"nom_freq"_a,
"pole_number"_a,
637 "nom_field_cur"_a,
"Rs"_a,
"Ld"_a,
"Lq"_a,
"Ld_t"_a,
"Lq_t"_a,
638 "Ld_s"_a,
"Lq_s"_a,
"Ll"_a,
"Td0_t"_a,
"Tq0_t"_a,
"Td0_s"_a,
639 "Tq0_s"_a,
"inertia"_a)
640 .def(
"set_parameters_fundamental_per_unit",
642 setParametersFundamentalPerUnit,
643 "nom_power"_a,
"nom_volt"_a,
"nom_freq"_a,
"pole_number"_a,
644 "nom_field_cur"_a,
"Rs"_a,
"Ll"_a,
"Lmd"_a,
"Lmq"_a,
"Rfd"_a,
645 "Llfd"_a,
"Rkd"_a,
"Llkd"_a,
"Rkq1"_a,
"Llkq1"_a,
"Rkq2"_a,
646 "Llkq2"_a,
"inertia"_a,
"init_active_power"_a,
647 "init_reactive_power"_a,
"init_terminal_volt"_a,
"init_volt_angle"_a,
650 .def(
"apply_parameters_from_json",
651 [](std::shared_ptr<CPS::EMT::Ph3::SynchronGeneratorDQODE> syngen,
653 DPsim::Utils::applySynchronousGeneratorParametersFromJson(
654 json::parse(json), syngen);
657 .def(
"set_initial_values",
659 "init_active_power"_a,
"init_reactive_power"_a,
660 "init_terminal_volt"_a,
"init_volt_angle"_a,
"init_mech_power"_a);
665 std::shared_ptr<CPS::EMT::Ph3::AvVoltageSourceInverterDQ>,
667 py::multiple_inheritance())
668 .def(py::init<std::string, CPS::Logger::Level>(),
"name"_a,
669 "loglevel"_a = CPS::Logger::Level::off)
670 .def(py::init<std::string, std::string, CPS::Logger::Level, CPS::Bool>(),
671 "uid"_a,
"name"_a,
"loglevel"_a = CPS::Logger::Level::off,
673 "with_trafo"_a =
false)
674 .def(
"set_parameters",
676 "sys_omega"_a,
"sys_volt_nom"_a,
"p_ref"_a,
"q_ref"_a)
677 .def(
"set_filter_parameters",
679 "Lf"_a,
"Cf"_a,
"Rf"_a,
"Rc"_a)
680 .def(
"set_controller_parameters",
682 "Kp_pll"_a,
"Ki_pll"_a,
"Kp_power_ctrl"_a,
"Ki_power_ctrl"_a,
683 "Kp_curr_ctrl"_a,
"Ki_curr_ctrl"_a,
"omega_cutoff"_a)
684 .def(
"set_transformer_parameters",
686 "nom_voltage_end_1"_a,
"nom_voltage_end_2"_a,
"rated_power"_a,
687 "ratio_abs"_a,
"ratio_phase"_a,
"resistance"_a,
"inductance"_a,
689 .def(
"set_initial_state_values",
691 "p_init"_a,
"q_init"_a,
"phi_d_init"_a,
"phi_q_init"_a,
692 "gamma_d_init"_a,
"gamma_q_init"_a)
698 std::shared_ptr<CPS::EMT::Ph3::Transformer>,
700 py::multiple_inheritance())
701 .def(py::init<std::string, CPS::Logger::Level>(),
"name"_a,
702 "loglevel"_a = CPS::Logger::Level::off)
703 .def(py::init<std::string, std::string, CPS::Logger::Level, CPS::Bool>(),
704 "uid"_a,
"name"_a,
"loglevel"_a = CPS::Logger::Level::off,
706 "with_resistive_losses"_a =
false)
708 "nom_voltage_end_1"_a,
"nom_voltage_end_2"_a,
"rated_power"_a,
709 "ratio_abs"_a,
"ratio_phase"_a,
"resistance"_a,
"inductance"_a)
713 std::shared_ptr<CPS::EMT::Ph3::SeriesResistor>,
715 py::multiple_inheritance())
716 .def(py::init<std::string>())
717 .def(py::init<std::string, CPS::Logger::Level>())
723 std::shared_ptr<CPS::EMT::Ph3::SeriesSwitch>,
725 mEMTPh3,
"SeriesSwitch", py::multiple_inheritance())
726 .def(py::init<std::string, CPS::Logger::Level>(),
"name"_a,
727 "loglevel"_a = CPS::Logger::Level::off)
729 "open_resistance"_a,
"closed_resistance"_a,
737 std::shared_ptr<CPS::EMT::Ph3::SSN::Full_Serial_RLC>,
739 py::multiple_inheritance())
740 .def(py::init<std::string>())
741 .def(py::init<std::string, CPS::Logger::Level>())
742 .def(
"set_parameters",
754 std::shared_ptr<CPS::EMT::Ph3::GenericTwoTerminalVTypeSSN>,
756 mEMTPh3,
"GenericTwoTerminalVTypeSSN", py::multiple_inheritance())
757 .def(py::init<std::string>())
758 .def(py::init<std::string, CPS::Logger::Level>())
759 .def(
"set_parameters",
766 std::shared_ptr<CPS::EMT::Ph3::GenericTwoTerminalITypeSSN>,
768 mEMTPh3,
"GenericTwoTerminalITypeSSN", py::multiple_inheritance())
769 .def(py::init<std::string>())
770 .def(py::init<std::string, CPS::Logger::Level>())
771 .def(
"set_parameters",
778 std::shared_ptr<CPS::EMT::Ph3::PiecewiseLinearInductor>,
780 py::multiple_inheritance())
781 .def(py::init<std::string>())
782 .def(py::init<std::string, CPS::Logger::Level>())
783 .def(
"set_parameters",
785 "flux_breakpoints"_a,
"current_breakpoints"_a)
793 py::class_<CPS::EMT::Ph3::GFL, std::shared_ptr<CPS::EMT::Ph3::GFL>,
795 py::multiple_inheritance())
796 .def(py::init<std::string, CPS::Logger::Level>(),
"name"_a,
797 "loglevel"_a = CPS::Logger::Level::off)
798 .def(py::init<std::string, std::string, CPS::Logger::Level>(),
"uid"_a,
799 "name"_a,
"loglevel"_a = CPS::Logger::Level::off)
801 "sys_volt_nom"_a,
"p_ref"_a,
"q_ref"_a)
802 .def(
"set_controller_parameters",
804 "kp_power_ctrl"_a,
"ki_power_ctrl"_a,
"kp_curr_ctrl"_a,
805 "ki_curr_ctrl"_a,
"omega_cutoff"_a)
807 "lf"_a,
"cf"_a,
"rf"_a)
808 .def(
"set_initial_state_values",
810 "phi_d_init"_a,
"phi_q_init"_a,
"gamma_d_init"_a,
"gamma_q_init"_a)
815 .def_property_readonly(
"igrid_d",
817 .def_property_readonly(
"igrid_q",
819 .def_property_readonly(
"p_inst",
821 .def_property_readonly(
"q_inst",
823 .def_property_readonly(
"omega_pll",
825 .def_property_readonly(
"vs_ref",
828 .def_property_readonly(
"pll_output",
830 .def_property_readonly(
833 .def_property_readonly(
836 .def_property_readonly(
840 py::class_<CPS::EMT::Ph3::SSN_GFL, std::shared_ptr<CPS::EMT::Ph3::SSN_GFL>,
842 py::multiple_inheritance())
843 .def(py::init<std::string, std::string, CPS::Logger::Level>(),
"uid"_a,
844 "name"_a,
"loglevel"_a = CPS::Logger::Level::off)
846 "cf"_a,
"rf"_a,
"rc"_a,
"omega_n"_a,
"kp_pll"_a,
"ki_pll"_a,
847 "omega_cutoff"_a,
"p_ref"_a,
"q_ref"_a,
"kp_power_ctrl"_a,
848 "ki_power_ctrl"_a,
"kp_curr_ctrl"_a,
"ki_curr_ctrl"_a)
853 .def(
"get_interface_voltage",
855 .def(
"get_interface_current",
861 .def_property_readonly(
"p_inst",
863 .def_property_readonly(
"q_inst",
865 .def_property_readonly(
"omega_pll",
869 std::shared_ptr<CPS::EMT::Ph3::SSN_GFL_Split>,
871 py::multiple_inheritance())
872 .def(py::init<std::string, std::string, CPS::Logger::Level>(),
"uid"_a,
873 "name"_a,
"loglevel"_a = CPS::Logger::Level::off)
875 "lf"_a,
"cf"_a,
"rf"_a,
"rc"_a,
"omega_n"_a,
"kp_pll"_a,
"ki_pll"_a,
876 "omega_cutoff"_a,
"p_ref"_a,
"q_ref"_a,
"kp_power_ctrl"_a,
877 "ki_power_ctrl"_a,
"kp_curr_ctrl"_a,
"ki_curr_ctrl"_a)
882 .def(
"get_state_derivative",
886 .def(
"get_controller_state",
889 .def(
"get_network_state_names",
893 .def(
"get_interface_voltage",
895 .def(
"get_interface_current",
897 .def(
"get_converter_voltage_reference",
899 .def(
"get_delayed_converter_voltage",
915 .def(
"get_equivalent_conductance",
923 .def_property_readonly(
"p_inst",
925 .def_property_readonly(
"q_inst",
927 .def_property_readonly(
"omega_pll",
929 .def_property_readonly(
"vinv_ref_a",
931 .def_property_readonly(
"vinv_ref_b",
933 .def_property_readonly(
"vinv_ref_c",
937 std::shared_ptr<CPS::EMT::Ph3::AvVoltSourceInverterStateSpace>,
939 mEMTPh3,
"AvVoltSourceInverterStateSpace", py::multiple_inheritance())
940 .def(py::init<std::string, CPS::Logger::Level>(),
"name"_a,
941 "loglevel"_a = CPS::Logger::Level::off)
942 .def(py::init<std::string, std::string, CPS::Logger::Level>(),
"uid"_a,
943 "name"_a,
"loglevel"_a = CPS::Logger::Level::off)
944 .def(
"set_parameters",
946 "Lf"_a,
"Cf"_a,
"Rf"_a,
"Rc"_a,
"omega_n"_a,
"Kp_pll"_a,
"Ki_pll"_a,
947 "omega_cutoff"_a,
"p_ref"_a,
"q_ref"_a,
"Kp_power_ctrl"_a,
948 "Ki_power_ctrl"_a,
"Kp_curr_ctrl"_a,
"Ki_curr_ctrl"_a)
955 .def_property_readonly(
"p_inst",
957 .def_property_readonly(
"q_inst",
959 .def_property_readonly(
"omega_pll",
962 py::class_<CPS::EMT::Ph3::SSN_GFM, std::shared_ptr<CPS::EMT::Ph3::SSN_GFM>,
964 py::multiple_inheritance())
965 .def(py::init<std::string, std::string, CPS::Logger::Level>(),
"uid"_a,
966 "name"_a,
"log_level"_a = CPS::Logger::Level::off)
968 "cf"_a,
"rf"_a,
"rc"_a,
"nominal_voltage"_a,
"omega_nominal"_a,
969 "p_ref"_a,
"q_ref"_a,
"virtual_inertia"_a,
"damping_coefficient"_a,
970 "voltage_droop_gain"_a,
"reactive_integral_gain"_a,
"kp_voltage"_a,
971 "ki_voltage"_a,
"kp_current"_a,
"ki_current"_a,
972 "active_damping_gain"_a,
"power_filter_cutoff"_a,
974 .def(
"set_numerical_linearization_parameters",
976 "relative_step"_a = 1e-6,
"absolute_step"_a = 1e-8)
977 .def(
"set_virtual_impedance",
979 "virtual_reactance"_a = 0.0)
980 .def(
"set_grid_current_feedforward",
982 .def(
"set_reactive_power_droop",
989 .def(
"get_interface_voltage",
991 .def(
"get_interface_current",
993 .def_property_readonly(
"p_inst",
995 .def_property_readonly(
"q_inst",
997 .def_property_readonly(
"omega_gfm",
999 .def_property_readonly(
"theta_gfm",
1001 .def_property_readonly(
1002 "voltage_magnitude_gfm",
1006 .def_property_readonly(
"i_grid_d",
1008 .def_property_readonly(
"i_grid_q",
1012 .def_property_readonly(
"v_ref_d",
1014 .def_property_readonly(
"v_ref_q",
1018 std::shared_ptr<CPS::EMT::Ph3::SSN::Capacitor>,
1020 py::multiple_inheritance())
1021 .def(py::init<std::string>())
1022 .def(py::init<std::string, CPS::Logger::Level>())
1030 std::shared_ptr<CPS::EMT::Ph3::GenericFourTerminalVTypeSSN>,
1032 mEMTPh3,
"GenericFourTerminalVTypeSSN", py::multiple_inheritance())
1033 .def(py::init<std::string>())
1034 .def(py::init<std::string, CPS::Logger::Level>())
1035 .def(
"set_parameters",
1037 "B"_a,
"C"_a,
"D"_a)
PYBIND11_DECLARE_HOLDER_TYPE(T, CPS::AttributePointer< T >)
void addEMTPh1Components(py::module_ mEMTPh1)
void addEMTPh3Components(py::module_ mEMTPh3)
void addEMTComponents(py::module_ mEMT)
void setParameters(Real capacitance)
Sets model specific parameters.
void setParameters(Real inductance)
Sets model specific parameters.
void setParameters(Real resistance)
Dynamic Phasor Three-Phase Switch.
void close()
Close switch.
void setParameters(Real openResistance, Real closedResistance, Bool closed=false)
void setParameters(Matrix capacitance)
Sets model specific parameters.
void setParameters(Matrix inductance)
Sets model specific parameters.
void setParameters(Matrix seriesResistance, Matrix seriesInductance, Matrix parallelCapacitance=Matrix::Zero(3, 3), Matrix parallelConductance=Matrix::Zero(3, 3)) const
void setParameters(Matrix resistance)
Sets model specific parameters.
Common base for three-phase switches.
void setParameters(Matrix openResistance, Matrix closedResistance, Bool closed=false)
void setInitialValues(Real initActivePower, Real initReactivePower, Real initTerminalVolt, Real initVoltAngle, Real initMechPower)
void setParameters(Real capacitance)
void setParameters(Real current)
void setParameters(Real inductance, Real initialCurrent=0.0)
void setParameters(Real seriesResistance, Real seriesInductance, Real parallelCapacitance=0.0, Real parallelConductance=0.0, Real initialCurrent=0.0)
void setParameters(Real resistance)
void setParameters(Real voltage)
Ideal current source model.
void setParameters(Complex currentRef, Real srcFreq=-1)
void setParameters(Real resistance, Real inductance, Real capacitance)
SSNTypeI2T Model for a one phase, two terminal I-type SSN component which can be represented using a ...
void setParameters(const Matrix A, const Matrix B, const Matrix C, const Matrix D)
void manualInit(Matrix initialState, Matrix initialInput, Matrix initialOldInput, Real initCurrent, Real initVoltage)
SSNTypeV2T Model for a one phase, two terminal V-type SSN component which can be represented using a ...
void manualInit(Matrix initialState, Matrix initialInput, Matrix initialOldInput, Real initCurrent, Real initVoltage)
void setParameters(const Matrix A, const Matrix B, const Matrix C, const Matrix D)
Ideal Voltage source model.
void setParameters(Complex voltageRef, Real srcFreq=-1)
void setParameters(Real lf, Real cf, Real rf, Real rc, Real omegaN, Real kpPLL, Real kiPLL, Real omegaCutoff, Real pRef, Real qRef, Real kpPowerCtrl, Real kiPowerCtrl, Real kpCurrCtrl, Real kiCurrCtrl)
void setControllerParameters(Real Kp_pll, Real Ki_pll, Real Kp_powerCtrl, Real Ki_powerCtrl, Real Kp_currCtrl, Real Ki_currCtrl, Real Omega_cutoff)
Setter for parameters of control loops.
void setTransformerParameters(Real nomVoltageEnd1, Real nomVoltageEnd2, Real ratedPower, Real ratioAbs, Real ratioPhase, Real resistance, Real inductance, Real omega)
Setter for parameters of transformer.
void setInitialStateValues(Real pInit, Real qInit, Real phi_dInit, Real phi_qInit, Real gamma_dInit, Real gamma_qInit)
Setter for initial values applied in controllers.
void withControl(Bool controlOn)
void setFilterParameters(Real Lf, Real Cf, Real Rf, Real Rc)
Setter for parameters of filter.
void setParameters(Real sysOmega, Real sysVoltNom, Real Pref, Real Qref)
Setter for gengit eral parameters of inverter.
Controlled Ideal Voltage source model.
void setParameters(Matrix voltageRef)
Ideal current source model.
void setParameters(MatrixComp currentRef, Real srcFreq=50.0)
Setter for reference current.
void setInitialStateValues(Real pInit, Real qInit, Real phiDInit, Real phiQInit, Real gammaDInit, Real gammaQInit)
void setFilterParameters(Real lf, Real cf, Real rf)
Filter parameters. No Rc exists in this model.
void setControllerParameters(Real kpPLL, Real kiPLL, Real kpPowerCtrl, Real kiPowerCtrl, Real kpCurrCtrl, Real kiCurrCtrl, Real omegaCutoff)
Controller parameters.
void setParameters(Real sysOmega, Real sysVoltNom, Real pRef, Real qRef)
General operating parameters.
void withControl(Bool controlOn)
Concrete generic three-phase, two-terminal I-type SSN component.
Concrete generic three-phase, two-terminal V-type SSN component.
One end of a Bergeron travelling-wave line. Two of these replace a single Signal::DecouplingLineEMT_P...
void setParameters(Matrix resistance, Matrix inductance, Matrix capacitance)
Line data. Give the parameters of the whole line, not of this half.
void setCouplingSource(Attribute< Matrix >::Ptr receivingVolt, Attribute< Matrix >::Ptr receivingCur)
void setParameters(MatrixComp voltageRef, Real srcFreq=50.0)
Setter for reference voltage parameters.
void setParameters(Real activePower, Real reactivePower, Real nominalVoltage, Real minimumVoltagePerUnit=0.1)
Sets total three-phase P/Q, nominal line-to-line voltage and voltage floor.
Three-phase, two-terminal, piecewise-linear flux-state inductor.
void setParameters(const std::vector< Real > &fluxBreakpoints, const std::vector< Real > ¤tBreakpoints)
void setParameters(Matrix activePower, Matrix reactivePower, Real volt, bool reactanceInSeries=false)
Base class for EMT VBR simplefied synchronous generator models.
void setParameters(Matrix capacitance)
void setParameters(const Matrix &resistance, const Matrix &inductance, const Matrix &capacitance)
Partitioned three-phase grid-following inverter.
Matrix getState() const
Combined state in the same logical order as the former monolithic GFL: 8 controller states followed b...
Matrix getControllerB() const
Matrix getNetworkB() const
Matrix getControllerD() const
Matrix getDelayedConverterVoltage() const
Matrix getConverterVoltageReference() const
Matrix getControllerC() const
Matrix getEquivalentConductance() const
Constant SSN Norton conductance G = mW.
Matrix getControllerF() const
Matrix getControllerA() const
Matrix getNetworkState() const
Matrix getNetworkD() const
Matrix getInterfaceVoltage() const
std::vector< String > getLocalStateNames() const override final
Matrix getControllerE() const
Matrix getInterfaceCurrent() const
void setParameters(Real lf, Real cf, Real rf, Real rc, Real omegaN, Real kpPLL, Real kiPLL, Real omegaCutoff, Real pRef, Real qRef, Real kpPowerCtrl, Real kiPowerCtrl, Real kpCurrCtrl, Real kiCurrCtrl)
Configure the filter, PLL, power controller and current controller.
Matrix getControllerState() const
Matrix getStateDerivative() const
Matrix getNetworkA() const
Matrix getNetworkC() const
Matrix getInterfaceVoltage() const
std::vector< String > getLocalStateNames() const override final
Matrix getInterfaceCurrent() const
void setParameters(Real lf, Real cf, Real rf, Real rc, Real omegaN, Real kpPLL, Real kiPLL, Real omegaCutoff, Real pRef, Real qRef, Real kpPowerCtrl, Real kiPowerCtrl, Real kpCurrCtrl, Real kiCurrCtrl)
Configure the GFL filter, PLL, power loop and current loop.
Matrix getStateDerivative() const
void setNumericalLinearizationParameters(Real relativeStep, Real absoluteStep)
Configure finite-difference steps for local linearization.
Matrix getStateDerivative() const
Matrix getInterfaceCurrent() const
Matrix getInterfaceVoltage() const
void setReactivePowerDroop(Real droopGain, Real cutoff)
Opt-in proportional Q-V droop replacing the integral excitation. droopGain is Dq [V/var]; cutoff [rad...
void setParameters(Real lf, Real cf, Real rf, Real rc, Real nominalVoltage, Real omegaN, Real pRef, Real qRef, Real virtualInertia, Real dampingCoefficient, Real voltageDroopGain, Real reactiveIntegralGain, Real kpVoltage, Real kiVoltage, Real kpCurrent, Real kiCurrent, Real activeDampingGain, Real powerFilterCutoff, Real delayBandwidth)
Configure the GFM model.
std::vector< String > getLocalStateNames() const override final
void setGridCurrentFeedforward(Real scale)
Scale on the voltage-loop grid-current feedforward (default 1).
void setVirtualImpedance(Real virtualResistance, Real virtualReactance=0.0)
Opt-in virtual output impedance Zv = Rv + jXv, subtracted from the EMF reference across the filter cu...
EMT three-phase resistor.
void setParameters(Real conductance, Real susceptance)
Set shunt specific parameters.
void closeSwitch() override
void openSwitch() override
Voltage-Behind-Reactance (VBR) implementation of 3rd order synchronous generator model.
Voltage-Behind-Reactance (VBR) implementation of 4th order synchronous generator model.
Voltage-Behind-Reactance (VBR) implementation of 5th type 2 order synchronous generator model Ref: Mi...
Voltage-Behind-Reactance (VBR) implementation of 6th order synchronous generator model Marconato's mo...
Voltage-Behind-Reactance (VBR) implementation of 6th order synchronous generator model Anderson - Fou...
Ideal voltage source representing a synchronous generator.
void withControl(Bool controlOn)
void setParameters(Real sysOmega, Real VdRef, Real VqRef)
Setter for general parameters of the component.
void setFilterParameters(Real Lf, Real Cf, Real Rf, Real Rc)
Setter for parameters of filter.
void setControllerParameters(Real Kp_voltageCtrl, Real Ki_voltageCtrl, Real Kp_currCtrl, Real Ki_currCtrl, Real Omega_nominal)
Setter for parameters of control loops.
void setInitialStateValues(Real phi_dInit, Real phi_qInit, Real gamma_dInit, Real gamma_qInit)
Setter for initial values applied in controllers.
void setTransformerParameters(Real nomVoltageEnd1, Real nomVoltageEnd2, Real ratedPower, Real ratioAbs, Real ratioPhase, Real resistance, Real inductance, Real omega)
Setter for parameters of transformer.
Ideal Voltage source model.
void setParameters(MatrixComp voltageRef, Real srcFreq=50.0)
Setter for reference voltage and frequency with a sine wave generator.
void setParameters(const Matrix &A, const Matrix &B, const Matrix &C, const Matrix &D)
Interface to be used by synchronous generators.
Base class for all components that are transmitting power.
void connect(typename SimNode< Real >::List nodes)
void setInitialVoltage(MatrixComp voltage) const
py::cpp_function createAttributeGetter(const std::string name)
py::cpp_function createAttributeSetter(const std::string name)
CPS::Matrix zeroMatrix(int dim)