Model of a drinking water treatment process and the variables involved using Coloured Petri Nets

A model that represents the behavior of a critical system or process, such as the drinking water treatment process, is vital for the evaluation of new procedures or their optimization without affecting the real system or risking the population, avoiding economic losses. Due to the complexity in the dynamics of drinking water treatment plants, the use of Coloured Petri Nets is recommended to model the behavior of the variables involved in the process. In this context, this work presents a structured procedure that allows to obtain a model considering a dynamic driven by the occurrence of discrete events and that allows the generation of useful information that can later be used to verify the effectiveness and efficiency of new operating strategies. To evaluate this proposal, a model of the drinking water treatment process of Puerto Mallarino located in Cali, Colombia was developed. Modeling, both the stages of the purification process, and the approximate behavior of the variables involved under the assumption that the changes obey only to the intensity of the raining season.


INTRODUCTION
Currently, the population growth in the cities demand a great amount of resources to meet their basic needs, e.g. drinking water, which is vital to the development and welfare. In this context, the performance and efficiency of the processes required to purify the liquid, demand tasks that are specialized in order to meet the requirement for larger amounts of drinking water with an optimal quality.
Consequently, it is advisable to develop different strategies to provide an adequate response to the exigent demands related to potable water production.
One approach to this problem would be to develop a model of drinking water treatment plant, which allows the simulation the system's behavior.
Based in the information provided for the administrative department of planning, Cali-Colombia, the city's population of Cali will grow steadily, approaching 2,496,396 citizens by 2018. Which have as main source of drinking water supply, the "Puerto Mallarino" treatment plant, with a capacity of 6.6 m3/s. Throughout the year, the treatment plant must deal with various factors that affect the quality of the drinking water supplied to the population, for example, the increase in the volume of rainwater. Reason why it is critical to monitor the water properties throughout the purification process during different times of the year.
With the purpose of guarantee an adequate quality of the water supplied to the city, it is necessary a purification process model to simulate its behavior and the variables involved in the process.
Currently, the plant uses the variables to make decisions regarding the resources consumption to perform the purification process, considering the changes present in the physicochemical properties of water during the whole process of potabilization. However, the variability of the physicochemical properties of water at the beginning of the process makes the modeling of this process difficult. Different tools could be used to develop models with different approaches to the water purification process, therefore, considering the stages of the purification process from a discrete approach, Petri nets are presented as a tool that allows modeling aspects of the system behavior, providing an intuitive interpretation of the processes due to their iconographic representation.
Several authors report studies related to potable water treatment. In [1] was evaluated the system effectiveness integrating a film activated sludge in the synthetic treatment of greywater and the elimination of nutrients for different organic loads; in [2] was presented theoretical models with a chemical and microbiological point of view. The study made by [3] presents a model of processing wastewater using a formal tool called "Petri nets" in order to make a model of the process of treatment of water contaminated with oil in petroleum and petrochemical processes, in [4][5] models of the purification process of water treatment plants are presented using Petri nets, in [6] a supervisory system for the detection and diagnosis of failures in a water treatment plant using fuzzy engine is presented. However, in references consulted has not been found related information to approaches of this type of system using Coloured Petri Nets modeling (CPN). The advantage offered by the models developed with CPN compared to other types of Petri nets is the possibility of interpreting the values of the variables (such as pH, oxygen, turbidity, etc.) at each change of state during the process of water purification.
Moreover, the use of this formal tool for system modeling improves its understandding, identifies its main features, facilitates improvement strategies with a discrete approach, among others [7]. Additionally, it facilitates an interdisciplinary approach in the evaluation and design stages of the system. Thus, considering the dynamics of the water treatment process from a discrete approach, the model was developed using Coloured Petri Nets. For this, a systematic structure to identify, simulate and analyze the system is proposed. This paper presents a first approach to a quantitative analysis of the variation of water properties as a function of the processes carried out at the Puerto Mallarino potabilization plant, through the use of CPN. Future related projects could use this model as a support tool to evaluate the behavior of the variables involved in the purification process and thereby define the amount of resources required for water treatment in different scenarios to ensure high water supply quality. This work presents scenarios where water properties are affected only by climatic variations throughout the year (rain and drought seasons), taking into account the historical data provided by the water treatment plant and by the Institute of Hydrology, Meteorology and Environmental Studies (IDEAM). It is structured as follows: Section two describes the conceptual framework. Section three the modeling procedure is presented. Section four shows the obtained model of water treatment plant and finally in section five conclusions are exposed.

Petri nets
Petri nets are a graphical and mathematical representation used in modeling discrete event systems for expressing concurrent, distributed, asynchronous, parallel, deterministic and/or stochastic events [7], some applications in productive systems are shown in [8].
The structure of the petri nets are composed for places, transitions, directed arcs and the behavior of the marks that represent the system dynamics [7], as shown in Figure 1.
Where, places represent reachable states and the transitions the events that can occur under certain conditions according to the relationship defined by the arcs. These arcs have weights, which indicate the necessary amount for that transition to be fired simultaneously, and displays the number of marks generated when a transition leaves.
For example, consider Figure 1. The input places transition T0 are P1 and P2. The associated arc with P1 has a weight of 1 while the associated arc with P2 has a weight of 2. This means that to trigger a change in the system, it is necessary that P1 has at least one mark and P2 has at least two marks in order to enable T0. This transition produces an output in P0 with a weight equal to one when is fired. Figure 2 shows the system after the T0 activation. The Petri nets have few but powerful primitive models that create productive models with a discrete approach. For cases where there is a complex system, an explosion of states may occur and would compromise the advantages offered by the graphical environment of the tool. This approach has encouraged the extension of Petri nets to Coloured Petri Nets (CPN).

Coloured Petri Nets
The Coulored Petri Nets combine the advantages of classic Petri nets and high-level programming languages (Standard ML). Using this tool, it can be study the behavior of a modeled system through simulation, verifying properties through the state space method and conduct performance analysis [9] . [10] The "CPN" extends the content capacity of discrete information in marks, allowing its definition agree with the concept of color. That is, the colors define the data type of the marks' values, for example: integer, decimal, Boolean, string, unit (this mark is similar as the one use in ordinary networks), and combinations of them. Thus, a CPN model integrates the information in a structure based on regular components of a Petri net (place, transition and arc) while using a high-level abstraction based on the programming of marks' contents.
In addition, this tool allows the definition of hierarchies. Thus, it is possible to encapsulate different levels of abstraction from the model in Figure 1. Petri nets components. subnets, whereby a state explosion is avoided. In this work the potable water treatment plant model for Puerto Mallarino, located in Cali (Colombia), is developed and validated, using the freeware software "CPNTOOLS" [11].

MODELING METHODOLOGY
The development of the system model was based on a well-structured procedure proposed in [12], which orderly describes the steps to follow in order to develop a model of a productive system, the procedure is shown in Figure 3. This technique ensures the inclusion of progressive refinements, which are essential to achieve the level of detail required by the system's model.

Collection of information
Information to be modeled should be gathered, such as its performance and its components, the physical devices that are part of the process (sensors, actuators, specialized equipment, chemicals, expert staff, etc.), important variables involved in the process, the environment and the materials or goods to produce.
Also, field visits are necessary to have a roughly idea of the functional parameters of the system. Additionally, it is important to obtain all available documentation manuals, catalogs, books and internet references related to the type of process, specialized personnel, documents, etc.

Definition of variables and system behavior
After determining the required or desired process for the system, all collected information is analyzed and the system variables are set, such as the following example: • Which is the required procedure to tend the specification of the process. • Which devices are used in the execution of each process activity. • Information, signs and data related during activities. • Relationships between each device for tasks performing. • Relationship between the variables involved in the process that allows the evolution of states or make decisions to carry out a process. • Execution times, variables involved in the beginning and end of a process, etc.

Structural modeling
A structural model of the system should be developed; using charts or graphs, the components such as machines and control devices are identified and located in its corresponding position. For this case, the program "CNPTOOLS" is used to represent the steps and components in the process.
The positions of all actuators and control devices are identified for each area in the system. Additionally, at this stage some of the control variables are analyzed and will be taken into account for the execution of each stage.

Functional and conceptual modeling
This stage describes the relationships between devices, signals and system components from a functional perspective. For the development of this model, the previously acquired information should be well-analyzed, in order to conduct an organized model that allows an easy description and understanding of the components. Also, it is important to analyze the variables and functions information that define a particular process.

Model analysis
At this stage, the model analysis through simulation is performed to observe its behavior in different environments and validate its performance with the real system.
The model is refined with processes' simplification that do not affect the model, but makes it more efficient. Through simulation different possible real scenarios are analyzed and then, it is proceeded with the relevant corrections after each scenario.

PUERTO MALLARINO'S POTABLE WATER TREATMENT PLANT MODEL
Following the procedure described in previous section, the model of the Puerto Mallarino treatment plant was developed in CPN showing how the process affects the properties of the water along its route in the plant.

Collection of information
According to the Municipal Companies of Cali (EMCALI), this plant supplies about 60% of Cali's population, where nearly 2,000,000 users depend on this plant to meet their need for drinking water; a process overview is shown in Figure 4.
Purification process starts in the intake next to the Cauca's river where thick bars stop solids waste from continuing. Then, the water is pumped to the stage of degritting, which has two structures in this process; at this stage activated carbon is applied to remove odors and unwanted flavors from water.
Subsequently, the water is sent through a distribution chamber (CADICAS "Cámara de Distribución de Caudales", in Spanish) to the reactors, where the process of water clarification is carried out using ferric chloride. This act as a coagulant that group particulate matter found in the water and then, in a filtering process with sludge, these grouped particles are caught, and thus cleaning or clarifying the water.
Then, the clarified water continues to the fast filters, which would retain small particles that failed to be caught in the previous process. In this stage, the water has a removal of 96.7% to 99.5% turbidity, the present turbidity should not be higher than 0.15 NTU.
Leaving the fast filters, the water enters the chlorination process allowing further decontamination water from harmful agents, the coagulation pH with ferric chloride range between 5.61 and 6.58 units. To complete the process, lime is applied to stabilize the pH of the water and then it is pumped to users. The model is developed on Coulored Petri Nets which represent the behavior of the system in a normal operation process.

DEFINITION OF VARIABLES AND SYSTEM BEHAVIOR
Relevant variables according to location are shown in Table 1.
With the previous data, the analysis of the variables is performed to establish relationship between them and how they affect the process of clarification and purification of water.
As described above, the most important process' variables for each step will be the input and output data of each sub-process held in the plant. Here, the plant operation and equipment are set. Also, actual values of historical records of previous processes are taken to establish the variation of the parameters within the process.
The variation of parameters at the plant entrance for this case is established from climate change in the region where the plant is located, as reported by the IDEAM (The Institute of Hydrology, Meteorology and Environmental Studies). With these climatic changes, it is obtained the turbidity variation and other variables also function of the turbidity, which are useful approximate results to feed the model.
After establishing correlations between variables based on statistical data and the personnel expertise, the structural model is developed.

Structural model
Once the variables to manage within the system and after locating the equipment and devices involved in the production process were obtained, a structural model was developed. It allows the identification of the stages in a previous model, see from Figure 5.

Functional and conceptual modeling
When the structural model was developed, the conceptual model is raised. This defines the behavior of the functional model and the activities it must perform. Figure 6 presents the conceptual model in a flowchart.
The model functional was developed using CPN, with the software CPNTOOLS. Un additional level of detailed is modeled, integrating internal process steps, see Figure 7. At this stage all the functional relationships of each process are defined, where the    behavior of variables and the operations performed on each system component are described.
The model shows the different stages that make up the water purification process and progressively the sub-processes and functions that allow describing the process are generated, such as the generation of variables according to climatic season in a month or the ignition of engines in pumping station according the required flow. In this model, the behavior of the variables will be defined taking into account only the rain seasons during a year, that is, other factors that can affect the physical and chemical properties of the water are not considered.
Due to space limitations effects, only were detailed the variables from the generation process, see Figure 8.
The Figure 8 shows, in a higher abstraction level, the transition "river conditions agent" and the subnets that it contains which are "climate agent" and "river agent", where "river" is a subnet of climate agent. In this case, the subnet "climate agent" defines the month to be modeled that could be a rainy month with high, medium or low intensity or dry weather. After selecting the climatic conditions of the month, the network assigns a number of rainy days with high, medium or low intensity and no rain days. All values assigned to the rainy days are taken from IDEAM's statistical data.
After classifying the type of month, the days and rainfalls, climatic agent enters data to the "river" subnet which is responsible for modeling the behavior of physical-chemical variables of the river. Such behavior was modeled by polynomial functions that fit actual values based on historical data collected on the plant for different rainy seasons. This approach was made due the variations of the variables associated with the physicochemical properties of water present a random behavior that cannot be defined by deterministic functions. At the end, the output variables for "river" will later be detected in the MILAN station, and by doing so, the process of water purification begins. All data were sent to the control room.

Model analysis
In this stage, the model is validated comparing the data obtained by the model with the data of the real system. The seasonal patterns of the variables were compared along time; this is because the experts use these patterns to make decisions All the properties of the model are verified to ensure that it is free of locks and all the states are reachable. The model allows to generate data of turbidity for different seasons along year with similar trends as the one reported for Puerto Mallarino treatment plant in its historical data, under the assumption that the change in turbidity obeys only to the intensity of the raining season.
The data of the model are extracted with a tool called monitor, which extracts the data and create a text file that can be exported to a spread sheet for data manipulation. Figure 9 shows the turbidity behavior for a seasonal pattern with average rainfall (600NTU) and high rainfall (1200NTU) reported in Puerto Mallarino in a given period of time. In a similar way, Figure 10 presents turbidity over a similar period of time thrown by the model in CPN. Where a similar behavior is observed in seasonal patterns for medium and high rainfall seasons. Multiple simulations were carried out to corroborate if the model showed seasonal behaviors similar to the real ones for high, medium and low rain temples for similar periods of time.
The results obtained showed that the model allows obtaining data that fit the real data under specific conditions. In this way, the model can be used in subsequent analysis of consumption of inputs for purification, decision making of projects related to the water purification process, etc. However, making a quantitative purchase between the data obtained in the model and the data of the real system is outside the scope of the project, because it is not possible to  determine an analytical or numerical solution that allows predicting the composition of the variables present in a river, because the physical-chemical properties of this depend on multiple factors over which there is no control.

CONCLUSIONS
Considering the importance of a water treatment system in society, a model that represents its dynamics is an important tool to develop strategies that improve its behavior and resources use, minimizing the risks of an inadequate specification. This article showed a procedure that generate a model to evaluate the variables behavior under different seasonal patterns (high, medium and low rainfall) and identify several stages of the purification process. In this sense, it was observed that the rainy season presents a greater demand in the system functioning with the objective of supplying drinking water. For instance, In case the water in the intake point has severe conditions that exceed the treatment capacity of the plant, it is necessary to close the gates at this point.
In this way, a tool was provided to forecast the inputs in response to certain behavior of the variables involved, failures diagnosis, among others.
In addition, this work could be integrated with other tools to form a simulator for operators training. This scenario will allow the new operator to carry out water purification procedures in diverse meteorological conditions, improving the operator's behavior in the operation of the water treatment system.