DPsim
Loading...
Searching...
No Matches
BaseComponents.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/Base/Base_Governor.h>
11#include <dpsim-models/Base/Base_PSS.h>
12#include <dpsim-models/Base/Base_Turbine.h>
13#include <dpsim-models/CSVReader.h>
14#include <dpsim-models/IdentifiedObject.h>
15#include <dpsim-models/Signal/PSS1A.h>
16#include <dpsim-models/Signal/TurbineGovernorType1.h>
17#include <dpsim/RealTimeSimulation.h>
18#include <dpsim/Simulation.h>
19#include <dpsim/pybind/BaseComponents.h>
20#include <dpsim/pybind/Utils.h>
21
22namespace py = pybind11;
23using namespace pybind11::literals;
24
25void addBaseComponents(py::module_ mBase) {
26 py::class_<CPS::Base::Ph1::Switch, std::shared_ptr<CPS::Base::Ph1::Switch>>(
27 mBase, "Switch");
28 py::class_<CPS::Base::Ph3::Switch, std::shared_ptr<CPS::Base::Ph3::Switch>>(
29 mBase, "SwitchPh3");
30
31 py::class_<CPS::MNASyncGenInterface,
32 std::shared_ptr<CPS::MNASyncGenInterface>>(
33 mBase, "MNASyncGenInterface", py::multiple_inheritance())
34 .def("set_max_iterations", &CPS::MNASyncGenInterface::setMaxIterations,
35 "max_iter"_a)
36 .def("set_tolerance", &CPS::MNASyncGenInterface::setTolerance,
37 "tolerance"_a);
38
39 py::class_<
41 std::shared_ptr<CPS::Base::ReducedOrderSynchronGenerator<CPS::Complex>>,
43 mBase, "ReducedOrderSynchronGeneratorComplex", py::multiple_inheritance())
44 .def("set_base_parameters",
46 CPS::Complex>::setBaseParameters,
47 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a)
48 .def("set_initial_values",
50 CPS::Complex>::setInitialValues,
51 "init_complex_electrical_power"_a, "init_mechanical_power"_a,
52 "init_complex_terminal_voltage"_a)
53 .def("scale_inertia_constant",
55 CPS::Complex>::scaleInertiaConstant,
56 "scaling_factor"_a)
57 .def("set_model_as_norton_source",
59 CPS::Complex>::setModelAsNortonSource,
60 "model_as_norton_source"_a)
61 .def(
62 "add_exciter",
64 std::shared_ptr<CPS::Base::Exciter> exciter,
65 std::shared_ptr<CPS::Base::ExciterParameters> parameters) {
66 self.addExciter(exciter, parameters);
67 },
68 "exciter"_a, "parameters"_a)
69 .def(
70 "add_exciter",
72 std::shared_ptr<CPS::Base::Exciter> exciter) {
73 self.addExciter(exciter);
74 },
75 "exciter"_a)
76 .def(
77 "add_exciter",
79 CPS::Real Ta, CPS::Real Ka, CPS::Real Te, CPS::Real Ke,
80 CPS::Real Tf, CPS::Real Kf,
81 CPS::Real Tr) { self.addExciter(Ta, Ka, Te, Ke, Tf, Kf, Tr); },
82 "Ta"_a, "Ka"_a, "Te"_a, "Ke"_a, "Tf"_a, "Kf"_a, "Tr"_a)
83 .def("add_pss",
84 py::overload_cast<std::shared_ptr<CPS::Base::PSS>,
85 std::shared_ptr<CPS::Base::PSSParameters>>(
87 "pss"_a, "parameters"_a)
88 .def("add_pss",
89 py::overload_cast<std::shared_ptr<CPS::Base::PSS>>(
91 "pss"_a)
92 .def(
93 "add_governor",
95 std::shared_ptr<CPS::Signal::TurbineGovernorType1> governor) {
96 self.addGovernor(governor);
97 },
98 "governor"_a)
99 .def(
100 "add_governor",
102 CPS::Real T3, CPS::Real T4, CPS::Real T5, CPS::Real Tc,
103 CPS::Real Ts, CPS::Real R, CPS::Real Pmin, CPS::Real Pmax,
104 CPS::Real OmRef, CPS::Real TmRef) {
105 self.addGovernor(T3, T4, T5, Tc, Ts, R, Pmin, Pmax, OmRef, TmRef);
106 },
107 "T3"_a, "T4"_a, "T5"_a, "Tc"_a, "Ts"_a, "R"_a, "Pmin"_a, "Pmax"_a,
108 "OmRef"_a, "TmRef"_a)
109 .def(
110 "add_governor_and_turbine",
112 std::shared_ptr<CPS::Base::Governor> governor,
113 std::shared_ptr<CPS::Base::GovernorParameters> govParams,
114 std::shared_ptr<CPS::Base::Turbine> turbine,
115 std::shared_ptr<CPS::Base::TurbineParameters> turbineParams) {
116 self.addGovernorAndTurbine(governor, govParams, turbine,
117 turbineParams);
118 },
119 "governor"_a, "gov_params"_a, "turbine"_a, "turbine_params"_a)
120 .def(
121 "add_governor_and_turbine",
123 std::shared_ptr<CPS::Base::Governor> governor,
124 std::shared_ptr<CPS::Base::Turbine> turbine) {
125 self.addGovernorAndTurbine(governor, turbine);
126 },
127 "governor"_a, "turbine"_a);
128
129 py::class_<
131 std::shared_ptr<CPS::Base::ReducedOrderSynchronGenerator<CPS::Real>>,
132 CPS::SimPowerComp<CPS::Real>>(mBase, "ReducedOrderSynchronGeneratorReal",
133 py::multiple_inheritance())
134 .def("set_base_parameters",
136 CPS::Real>::setBaseParameters,
137 "nom_power"_a, "nom_voltage"_a, "nom_frequency"_a)
138 .def("set_initial_values",
140 CPS::Real>::setInitialValues,
141 "init_complex_electrical_power"_a, "init_mechanical_power"_a,
142 "init_complex_terminal_voltage"_a)
143 .def("scale_inertia_constant",
145 CPS::Real>::scaleInertiaConstant,
146 "scaling_factor"_a)
147 .def("set_model_as_norton_source",
149 CPS::Real>::setModelAsNortonSource,
150 "model_as_norton_source"_a)
151 .def(
152 "add_exciter",
154 std::shared_ptr<CPS::Base::Exciter> exciter,
155 std::shared_ptr<CPS::Base::ExciterParameters> parameters) {
156 self.addExciter(exciter, parameters);
157 },
158 "exciter"_a, "parameters"_a)
159 .def(
160 "add_exciter",
162 std::shared_ptr<CPS::Base::Exciter> exciter) {
163 self.addExciter(exciter);
164 },
165 "exciter"_a)
166 .def(
167 "add_exciter",
169 CPS::Real Ta, CPS::Real Ka, CPS::Real Te, CPS::Real Ke,
170 CPS::Real Tf, CPS::Real Kf,
171 CPS::Real Tr) { self.addExciter(Ta, Ka, Te, Ke, Tf, Kf, Tr); },
172 "Ta"_a, "Ka"_a, "Te"_a, "Ke"_a, "Tf"_a, "Kf"_a, "Tr"_a)
173 .def("add_pss",
174 py::overload_cast<std::shared_ptr<CPS::Base::PSS>,
175 std::shared_ptr<CPS::Base::PSSParameters>>(
177 "pss"_a, "parameters"_a)
178 .def("add_pss",
179 py::overload_cast<std::shared_ptr<CPS::Base::PSS>>(
181 "pss"_a)
182 .def(
183 "add_governor",
185 std::shared_ptr<CPS::Signal::TurbineGovernorType1> governor) {
186 self.addGovernor(governor);
187 },
188 "governor"_a)
189 .def(
190 "add_governor",
192 CPS::Real T3, CPS::Real T4, CPS::Real T5, CPS::Real Tc,
193 CPS::Real Ts, CPS::Real R, CPS::Real Pmin, CPS::Real Pmax,
194 CPS::Real OmRef, CPS::Real TmRef) {
195 self.addGovernor(T3, T4, T5, Tc, Ts, R, Pmin, Pmax, OmRef, TmRef);
196 },
197 "T3"_a, "T4"_a, "T5"_a, "Tc"_a, "Ts"_a, "R"_a, "Pmin"_a, "Pmax"_a,
198 "OmRef"_a, "TmRef"_a)
199 .def(
200 "add_governor_and_turbine",
202 std::shared_ptr<CPS::Base::Governor> governor,
203 std::shared_ptr<CPS::Base::GovernorParameters> govParams,
204 std::shared_ptr<CPS::Base::Turbine> turbine,
205 std::shared_ptr<CPS::Base::TurbineParameters> turbineParams) {
206 self.addGovernorAndTurbine(governor, govParams, turbine,
207 turbineParams);
208 },
209 "governor"_a, "gov_params"_a, "turbine"_a, "turbine_params"_a)
210 .def(
211 "add_governor_and_turbine",
213 std::shared_ptr<CPS::Base::Governor> governor,
214 std::shared_ptr<CPS::Base::Turbine> turbine) {
215 self.addGovernorAndTurbine(governor, turbine);
216 },
217 "governor"_a, "turbine"_a);
218}
void addGovernorAndTurbine(std::shared_ptr< Base::Governor > governor, std::shared_ptr< Base::GovernorParameters > govParams, std::shared_ptr< Base::Turbine > turbine, std::shared_ptr< Base::TurbineParameters > turbineParams)
Add a modular governor + turbine pair (new API for SteamTurbineGovernor / SteamTurbine)
void addPSS(std::shared_ptr< Base::PSS > pss, std::shared_ptr< Base::PSSParameters > parameters)
Attach a PSS (initialises parameters) to this generator.
void addExciter(std::shared_ptr< Base::Exciter > exciter, std::shared_ptr< Base::ExciterParameters > params)
Add voltage regulator and exciter.
void addGovernor(Real T3, Real T4, Real T5, Real Tc, Real Ts, Real R, Real Pmin, Real Pmax, Real OmRef, Real TmRef)
Add governor and turbine (TurbineGovernorType1 legacy API)
Interface to be used by synchronous generators.
void setMaxIterations(Int maxIterations)
Base class for all components that are transmitting power.