• No results found

Simulating a Fault in the System

4.5 Validation of the Diagnosis with the Simulation of the system

4.5.1 Simulating a Fault in the System

The code is structured in different parts. A function of the code is used to simulate the functioning of the system for a period of time when a number of failures are induced on the water tank. This function is called Tank Functioning. The function has three inputs: - the structural parameters of the tank, such as the section of the pipes and the dimensions of the tank;

- the failures that are present in the system (any number of failures is allowed). After a period of time, decided by the user, the function returns two outputs: - the water level in the tank;

- the 5 sensor patterns observed on the system.

It is assumed that the failures have occurred before the system is started, this assumption is motivated by the fact that the BN system was designed with the same assumption. At each time step, the function calculates the water that enters the tank and the water that leaves the tank. The amount of water entering the tank depends only on section 1. If the valve is open and there are no failures such as blockages in the pipes, the flow rate through valve V1 is constant. The amount of water leaving the tank depends on the states of sections 2 and 3 and it also depends on the tank itself when a fracture or a leak are present. The flow rate through valves V2 and V3 depends on the level of water, since a larger volume of water produces a higher pressure and, as a consequence, it causes the flow rate to increase. At each time step, the amount of water that has entered the tank and the water that has left is calculated and the water level is updated. In a text file, the values of the flow rates for sensors VF1, VF2 and VF3 are stored together with the level of water in the tray and the level of water in the tank. Figure 4.18 shows an example of such an output file. The values at the top represent the structural parameter of the tank, these are read from an input file where the user can indicate the inputs for the code. In this example, two failures are supposed to have occurred in the system. For each time step, the tank and tray level and the flow rates through the valves are written in the file.

Figure 4.18–Example of an Output File generated by the simulation code (1).

At the end of the observation the sensors patterns are calculated based on these values, the output file will end with a few lines as in figure 4.19.

Figure 4.19– Example of an Output File generated by the simulation code (2).

A simple pattern recognition algorithm is performed to identify the patterns from the list of values generated. The possible patterns are known for each sensor, so the procedure is better

defined as a pattern matching problem. Since every sensor has different potential patterns, the algorithm is different for every sensor. For example, the patterns for VF2, measuring flow rate through valve V2, are either Flow or No Flow as all the possible flow patterns that are non zero are grouped together. Therefore, the pattern recognition for sensor VF2 is very simple as it consists in checking for any non zero values of the flow through valve V2. If such a value exists, then the pattern is Flow otherwise it is No Flow. As failures can only occur before the system is started, it is impossible that patterns change during observation. Regarding sensor VF1, measuring the flow rate through valve V1, there are 4 possible pat- terns:

1. Constant Flow 2. No Flow

3. From Constant Flow to No Flow 4. Oscillating Flow.

In order to match the behaviour on the system with one of these, the algorithm calculates for each time step the difference of the flow rate value with the previous one. If these differences remain zero, then patterns 1 or 2 are selected, if one of these is negative, then pattern 3 is considered and if they change sign, then the oscillating pattern is detected. In the example shown, the values of the first sensor (in the third column of figures 4.18 and 4.19) do not change and it is sufficient to check one of them to determine that the pattern is No Flow. A similar procedure is used for all patterns.

It has to be said that this simple patterns matching algorithm could not work on real sensors, as these are generally affected by noise and a small positive or negative change in the flow rate could be caused by a random variation error in the readings. However, for the purpose of our research, the intention is to use this only for the values generated by the simulation. Depending on the system parameters, the observation time to be able to correctly observe the patterns can change. For example, if the level in the tank is increasing due to a failure, but the system is not observed for a sufficient interval of time, the level in the tank may not reach the limit where valve V1 is set to close. For the structural parameters in the example, the observation time is set to 5 minutes as this is sufficient to correctly identify the faulty behaviours. By changing the physical structure of the tank, as the pipes sections or the tank volume, it is possible to change the minimum necessary observation time and adapt it to the requirements of a particular system.