Using the Object Oriented Component-Based Approach

1 Tank System with a Continuous PI Controller

Now we show the tank model using the object oriented component-based approach. The structure of the tank system model using this approach is clearly visible in Figure 1 below.


A tank system with a continuous PI controller and a source for liquid.


The three components of the tank system: the tank, the PI controller and the source of liquid are explicit in Figure 1 and in the declaration of the class
TankPI below. Tank instances of tank, source and piContinuous are connected to controllers and liquid sources through their connectors.



2 Tank

The tank has four connectors: qIn for input flow, qOut for output flow, tSensor for providing fluid level measurements, and tActuator for setting the position of the valve at the outlet of the tank.

The central equation regulating the behavior of the tank is the mass balance equation, which in the current simple form assumes constant pressure. The output flow is related to the valve position by a
flowGain parameter, and by a limiter that guarantees that the flow does not exceed what corresponds to the open/closed positions of the valve.



2.1 limitValue

A limiter function is needed in the model to reflect minimum and maximum flows through the output valve:



2.2 Connectors

As already stated, the tank has four connectors. These are instances of the following three connector classes:





2.3 LiquidSource

The fluid entering the tank must come from somewhere. Therefore we have a liquid source component in the tank system. The flow increases sharply at time = 150 to factor of three of the previous flow level, which creates an interesting control problem that the controller of the tank has to handle.



2.4 PIcontinuousController

The controller needs to be specified. We will initially choose a PI controller but later replace this by other kinds of controllers.



2.5 BaseController

Both the PI controller and the PID controller to be defined later inherit the partial controller class BaseController, containing common parameters, state variables, and two connectors: one to read the sensor and one to control the valve actuator.



3 Simulation of TankPI

We simulate the TankPI model and obtain the same response as for the FlatTank model, which is not surprising given that both models have the same basic equations.





4 Tank with PID Continuous Controller

We define a TankPID system which is the same as the TankPI system except that the PI controller has been the replaced by a PID controller. Here we see a clear advantage of the object oriented component-based approach over the traditional modeling approach, since system components can easily be replaced and changed in a plug-and-play manner.


The tank system with the PI controller replaced by a PID controller.


The Modelica class declaration for the
TankPID system appears as follows:




We create a
PIDcontinuousController class in Modelica containing the three defining equations:



5 Simulation of TankPID

We simulate the tank model once more but now including the PID controller:





6 Two Tanks Connected Together

Two connected tanks with PI controllers and a source for liquid connected to the first tank.


The Modelica model
TanksConnectedPI corresponding to Figure 3 appears as follows:




We simulate the connected tank system. We clearly see the tank level responses of the first and second tank to the changes in fluid flow from the source, where the response from the first tank of course appears earlier in time than the response of the second tank.


7 Simulation of TanksConnectedPI