Two-Tank System
Two tanks are connected in series.
The inflow of tank 1 is controlable by a pump with the voltage
,
whereby the inflow
and the outflow
of tank 2 are adjustable by valves.
Moreover, the height
of tank 2 is measured and the height
of tank 1 is unknown.
Both tanks have the same overall height
and the same base area
.

For the mathematical represenation both tanks are considered seperatly.
For the first tank:
assuming the inflow
with the proportional factor and the flow between the tanks with Torricelli’s law
For the second tank:
assuming the linear resistance to flow
The complete nonlinear system with the system vector
is given by
Violations of the model’s boundary conditions are the water levels of both tanks exceed the maximal height
The height of tank 2
is chosen as output.
The example comes with two controllers.
The CppPIDController implemenents a PID controller in C++ and uses pybind11 as
binding between C++ and python.
The py:class:CppStateController linearizes the nonlinear model in a chosen steady state and applies static state
feedback.
The state feedback is implemented in C++ and uses pybind11 as binding between C++ and Python.
The example comes with one observers. The py:class:CppHighGainObserver implements a High-Gain observer for the nonlinear system in C++, which uses pybind11 as binding between C++ and python.
A 3D visualizer isn’t implemented, but a 2D visualization can be used instead.
An external py:data:settings.py file contains all parameters. All implemented classes import their initial values from here.
At program start, the main loads two regimes from the file default.sreg.
controller-PID is a setting using a PID controller to stabilize the water level of tank 2 at a specific
height.
controller-State is a settings using a nonlinear observer and a linearized state feedback to stabilize the
water level of tank 2 at a specific height.
The structure of __main__.py allows starting the example without navigating to the directory and using an
__init__.py file to outsource the import commands for additionl files.