FUZZY LOGIC APPLIED TO THE MODELING OF WATER DYNAMICS IN AN OXISOL IN NORTHEASTERN BRAZIL

SUMMARY Modeling of water movement in non-saturated soil usually requires a large number of parameters and variables, such as initial soil water content, saturated water content and saturated hydraulic conductivity, which can be assessed relatively easily. Dimensional flow of water in the soil is usually modeled by a nonlinear partial differential equation, known as the Richards equation. Since this equation cannot be solved analytically in certain cases, one way to approach its solution is by numerical algorithms. The success of numerical models in describing the dynamics of water in the soil is closely related to the accuracy with which the water-physical parameters are determined. That has been a big challenge in the use of numerical models because these parameters are generally difficult to determine since they present great spatial variability in the soil. Therefore, it is necessary to develop and use methods that properly incorporate the uncertainties inherent to water displacement in soils. In this paper, a model based on fuzzy logic is used as an alternative to describe water flow in the vadose zone. This fuzzy model was developed to simulate the displacement of water in a non-vegetated crop soil during the period called the emergency phase. The principle of this model consists of a Mamdani fuzzy rule-based system in which the rules are based on the moisture content of adjacent soil layers. The performances of the results modeled by the fuzzy system were evaluated by the evolution of moisture profiles over time as compared to those obtained in the field. The results obtained through use of the fuzzy model provided satisfactory reproduction of soil moisture profiles. na do Esse modelo desenvolvido vegetado, o O princípio desse modelo consiste de um sistema com do Mamdani, em que as regas se baseiam no de umidade das camadas adjacentes do solo. O desempenho dos resultados modelados pelo sistema fuzzy avaliados pela evolução dos perfis de umidade, ao longo do comparado com os obtidos em campo. Os resultados pelo uso do modelo fuzzy apresentaram uma reprodução dos perfis de umidade volumétrica.


INTRODUCTION
Water consumption and the indiscriminate use of chemicals (fertilizers and pesticides) have been increasing in agricultural activities so as to meet growing demands for food, thus contributing to the degradation in the quality of surface water and groundwater. Within this context of environmental pollution, urban areas also stand out, with their wastewater, solid waste and storm drain systems that carry along waste from various sources and pollution from industrial effluents, both inorganic and organic. In the face of this problem of pollution from various sources, it is important to develop tools to understand integrated management of the water cycle in different scales of time and space. This fact has drawn attention to the importance of modeling processes that involve the soil for better monitoring of systems and the groundwater. One of the most important physical processes in the soil is the movement of water through the vadose zone, especially through the layers near the surface (Hillel, 1998).
The success of numerical models in describing the dynamics of soil water is closely related to the precision with which the water-physical parameters are determined. This has been the greatest challenge in the use of numerical models since, according to Bárdossy & Duckstein (1995), the modeling of soil physical processes usually requires a large number of variables and parameters. Because of the complexity of these processes and the soil system, it is very laborious to estimate many of these variables and parameters. Therefore, it is necessary to develop and use methods that properly incorporate the uncertainties inherent to water displacement in soils.
Fuzzy Logic based on the fuzzy sets theory (Zadeh, 1965) is the logic that underpins modes of reasoning which are approximate rather than exact. The concepts of fuzzy logic can be used to translate the inaccurate information contained in sentences expressed in natural language (such as "slightly damp," "very hot", etc.) into mathematical terms. It provides a mathematical tool for processing information of an imprecise or vague character (Tanscheit, 1998).
An alternative approach to numerical models based on fuzzy logic and fuzzy sets can be expressed in a non-probabilistic sense to assess the inaccuracies in determination of parameters related to water transfer and transport of solutes in soils. Due to production capacity calculations and inferences from fuzzy information, use of the fuzzy sets theory has been disseminated within the soil sciences (McBratney & Odeh, 1997). Bárdossy (1996) and Dou et al. (1999) affirm that a model based on fuzzy rules constructed to describe the dynamics of water and solutes in a given region with a particular type of soil can easily be extrapolated to describe these phenomena in other regions with another type of soil. This extrapolation depends only on determination of parameters which are relatively easy to obtain, such as saturated hydraulic conductivity, K s , and saturated soil-water content, θ s . This work aims to develop a fuzzy rule-based model as an alternative approach to numerical models using a simpler method to describe and calculate water movement in the vertical direction in an unsaturated Oxisol, analyzing the error in comparison of the values obtained in the field and the solution provided by the fuzzy model.

Richards equation
Darcy's equation (Darcy, 1856), developed for the water flow in saturated porous media, has been generalized by Buckingham (1907) to describe the water flow in unsaturated porous media (q = vertical flow) through introduction of the concepts of matric potential and unsaturated hydraulic conductivity, described by: where K(θ) is the unsaturated hydraulic conductivity as a function of soil moisture θ, ψ is the total potential of soil water, and z is the vertical coordinate position.
The continuity equation expresses the principle of conservation of the mass of water contained in a representative elementary volume (REV) of soil. For a given REV of soil, the flux density entering the volume element as a vector can be decomposed in three orthogonal directions, x, y and z. Thus, considering only the z direction, the continuity equation can be expressed as: where S is the sink term and t is the time. Richards (1931) combined Buckingham-Darcy's equation (Equation 1), with the continuity equation, (Equation 2), resulting in: Richards equation is the most used mathematical expression to describe the phenomenon of water flow in a non-saturated soil. Equation 3 is a nonlinear partial differential equation that requires knowledge of the relationships ψ m (θ) and K(θ).
Various functional relationships are found in the literature; among them, the relationship: where equation 4 represents the soil-water retention curve, which represents the relationship between matric potential and soil moisture defined by van Genuchten (1980). In this equation, θ r is the residual water content, θ s is the saturated water content, α represents the inverse of the bubbling pressure (cm -1 ) at which the water begins to be drained from the soil which was previously saturated, ψ m is the matric potential, and m and n are the shape parameters, which may be related by the assumption of Mualem (1976) described as: Among the various functional relations for the hydraulic conductivity curve that highlights the equation described by van Genuchten (1980) with the hypothesis of Mualem (1976) is: where K s is the hydraulic conductivity of the soil and S e is the effective saturation given by equation 7: In the literature, there are several ways to estimate K s ; one of them is by conducting infiltration tests with a single ring infiltrometer (Lee et al., 2006), using the method proposed by Haverkamp et al. (1994).

Fuzzy Logic
In the 1980s, fuzzy logic (Zadeh, 1965) began to attract attention with the opening of the automatic operating system for the Sendai Subway in Japan. Modeling the characteristics of the trains, the fuzzy system was used to control speed, acceleration and braking without human supervision, i.e., there was no driver to control these variables during the trip made by the train between two stations. This can be regarded as a milestone for the widespread use of controllers based on fuzzy logic.
Fuzzy logic is one of the current techniques for successful development of sophisticated systems that control processes (Lee, 1990;Dutta, 1993;Castro, 1995). With its use, complex systems can be implemented in simple controllers, with easy maintenance and low cost. The use of systems built this way, called fuzzy systems, is especially applicable when the mathematical model is subject to uncertainties (Karr & Gentry, 1993;Sandri & Sibertin-Blanc et al., 2008).
The application of fuzzy theory is also found in the literature for detection of cases involving the resolution of differential equations of dependent parameters, thus approximating their solutions, such as those that require knowledge of water movement in the soil (Dou et al., 1999).

Fuzzy sets
The technological capabilities available when fuzzy logic was developed were unable to automate activities related to problems that encompass ambiguous situations, not subject to processing by Boolean logic. We need something more than just two possible true values. In conventional sets there are sharp boundaries between the elements belonging to the set and those outside it. In a fuzzy set the transition between the member and the non-member is in a progressive band, with an associating degree ranging from "0" (complete non-member) to "1" (full member) (Camargos, 2002).
A fuzzy set A in a universe U is defined by a degree of membership µ A (x): U [0,1] and is represented by a set of ordered pairs: where the degree of membership µ A (x) indicates the degree of compatibility between x and the concept expressed by A, such that µ A (x) = 1 indicates that x is completely compatible with A, µ A (x) = 0 indicates that x is completely incompatible with A, and 0 < µ A (x) <1 indicates that x is partially compatible with A by µ A (x).
The support of a fuzzy set A is the set comprising all the elements that have some degree of membership with a value greater than zero. It is represented as follows: In the study of fuzzy sets, fuzzy numbers are worth mentioning. They are special cases of fuzzy sets. A fuzzy subset A derived from a set of real numbers is called a fuzzy number if there is at least one number z such that µ A (z) = 1, in which for every real number a, b, c with a <c <b, we get: A fuzzy number A = (a1, a2, a3) with a1 a2 a3 is considered a triangular fuzzy number if its degree of membership is written as follows:

Fuzzy rules
Fuzzy rules can be provided by experts in the linguistic form of sentences, and they constitute a fundamental aspect in the performance of a fuzzy inference system. In this regard, one important aspect is the definition of the fuzzy sets corresponding to input variables (antecedents) and output variables (consequents) because system performance will depend on the number of fuzzy sets and their form (Tanscheit, 2003).
The fuzzy rule-based model is created by structures such as "IF ... THEN ...", as shown below in a generic way and for a set of n rules: R j : IF x 1 is A 1j and . . . and x n is A nj , THEN y j is B j (8) j = 1, 2, ..., n in which R j is the j th rule; x 1 , x 2 , ..., x n are input variables; A 1j , A 2j , ..., A nj are fuzzy sets corresponding to the input variables; y j is the output variable; and B j is the set corresponding to the fuzzy output variable. Figure 1 illustrates a fuzzy rule.
A fuzzy system will only have a better performance if the rules which define the control strategy are consistent. Extracting rules from experts in the form of sentences such as "IF ... THEN" may not be an easy task, no matter how knowledgeable they are about the problem in question. As an alternative to the use of experts in defining the basis of the rules, there are methods for extracting rules from numerical data. These methods are particularly useful in problems of classification and forecasting of time series.

Fuzzy systems
Fuzzy systems are robust and highly adaptable, thus incorporating knowledge that other systems cannot always accommodate (Guerra, 1998). They are also versatile, especially when the physical model is a complex and difficult mathematical representation. Moreover, even in systems where uncertainty is present in an intrinsic way, they add a feature of robustness. The fuzzy systems found in the literature are the classic models, such as those of Mamdani & Larsen, and the interpolation models, including the models of Takagi-Sugeno & Tsukamoto (Lee, 1990;Driankov et al., 1993). The models differ in their form of representation in terms of premise, as well as in the representation of control and the operators used for implementation of the system. The Mamdani model is a fuzzy inference method that was for many years a standard for the use of concepts of fuzzy logic in knowledge processing. The production a fuzzy rule-based model of Mamdani is fuzzy relationships, both in their background and in their consequences. The semantic rule traditionally used for processing of inferences for the Mamdani model is called maximum-minimum inference. To mathematically model the fuzzy rules, Mamdani & Assilian (1975) proposed a fuzzy binary relationship (M) between inputs x outputs (u), with the degree of membership being described as follows: in each of the rules that form the basis of fuzzy rules, the minimum mathematical operator and the logical connector "and" are adopted, and so is the maximum operator and the logical connector "or", since the sentences "IF ... THEN ... " are modeled by applying the minimum operator.
In formal terms, the fuzzy relation M is the fuzzy subset x U in which the degree of membership is given by: where n is the number of rules φ Aj (x) and φ Bj (u) are the degrees to which x and u belong to the fuzzy sets A j and B j , corresponding to the input and output variables, respectively. Figure 2 illustrates the maximum-minimum inference for the Mamdani model with only two general rules.
Once the output fuzzy set is established by means of a process of inference in the stage of defuzzification, an interpretation is made of this information. This is necessary because, in practical applications, accurate outputs are generally required. There are several methods for defuzzification in the literature. Two of the most used are the Center of Gravity and the Maximum Average method, in which the output needs are obtained by taking the average between the two extreme elements in the universe that correspond to the highest values of the degree of membership of the consequent. As for the Center of Gravity, the output is the value in the universe that divides the area under the curve of the degree of membership into two equal parts (Tanscheit, 2003). An example of the defuzzification adopted is the Center of Gravity, which can be seen in figure 3.
The Center of Gravity method (Jager, 1995;Babuska, 1996) is similar to the arithmetical means for data distribution, taking into account that the weights are values f B (u i ) that indicate the degree of compatibility of the value of u i with its concept modeled by the fuzzy set output B. The defuzzification B for a discrete domain is given by: And for a continuous domain:

Study area and measurement period
The experimental data were obtained on the Chã de Jardim farm, a 4.0 ha area belonging to the Agricultural Science Center (CCA) of the Universidade Federal de Paraiba [Federal University of Paraíba] (UFPB), located in the Brejo microregion of Paraiba, in Areia, State of Paraiba (6 o 58' 12'' S and 35 o 42' 15'' W). The altitude is about 620 m asl. The climate in the region, according to Köppen, is of the As' type (hot and humid), with a rainy season during autumn-winter and the occurrence of heavy rainfall in June and July (Brasil, 1972). According to data from the meteorological station of the CCA UFPB (30-year average), the average annual temperature is 24.5 o C, the annual relative humidity is 85 % and the total annual rainfall is 1,400 mm. The soil in the region is classified as an Oxisol -Latossolo Amarelo (

Instrumentation
Six TDR (Time Domain Reflectometry) sensors from Campbell Scientific CS 615 were set up at the depths of 20, 40, 60, 80, 100 and 120 cm. These sensors were connected to a datalogger from Campbell Scientific CR 10X, with readings taken every minute and the averages stored every half hour (Lee et al., 2006). For the TDR sensors used, the calibration curve was applied according to manufacturer instructions (Campbell Scientific, 1996).

Case study
The experimental data were obtained in the field with bare soil, over the period of March 13 to March 23, 2010, during the emergence of cowpea. Therefore, the simulations carried out here seek to reproduce the phenomenology occurring in this interval.

Determination of the fuzzy rules
A fuzzy rule-based model adapted to soil conditions was developed, consisting of 27 rules. Up to definition of this final number, several tests were used to determine which rules were not exerting any contribution to the system. Just as in Bárdossy & Disse (1993), , Bárdossy (1996) and Dou et al. (1999), the main purpose made for the creation of rules that describe soil water dynamics, which is the vertical movement of soil water at a given time and at a certain point along the profile, depends almost exclusively on the soil moisture of the region immediately close to it. In general, the fuzzy rules developed to describe the soil water dynamics used in this paper have the following configuration: "IF the soil moisture at a point (A) is high, and the soil moisture in an adjacent section (B) low is high, THEN the flux density q v between the two points is high." A fuzzy rule consists of two premises, which are the relative soil moisture of the upper cell (θ/θ s ) up , and the relative moisture of the adjacent lower cell (θ/θ s ) low . The consequence of the rule consists of the vertical flow q v between the two cells. The premises and its consequences are in the form of fuzzy sets. For the present model, triangular fuzzy numbers are chosen.

Fuzzy model based on Richards equation
The procedure for using a fuzzy rule-based model for the vertical dynamics of water in an unsaturated soil profile was carried out in the same way as the work of Bárdossy & Disse (1993),  and Bárdossy (1996). The difference is that this study highlights the construction of the fuzzy rule-based model and was based on data obtained from experimental measurements performed in the field, which were used as a training set. The outputs of the fuzzy model were generated for The outputs of the fuzzy model were generated for a time intervals of 12 h, for a total of 240h. The vertical resolution was 5 cm.
The fuzzy model has two equal entries in the form of fuzzy sets, corresponding to the degree of saturation of the profile between two points of a given homogeneous soil. The output of the system, also in the form of fuzzy sets, is given by the flow between adjacent layers of the same ground. From the flow values measured by the fuzzy system, the indices recalculate volumetric water content step by step. The results of this model are compared with results obtained from experimental measurements performed in the field. The following sequence of steps shows greater details of how this was accomplished by applying the fuzzy rule-based model for the Richards equation: 1. The degree of saturation is determined by the ratio between soil water content and water content at saturation: 2. The degrees of saturation of the adjacent layers Θ j and Θ j+1 are provided as inputs to the fuzzy system. 3. The output of the fuzzy system, which is the defuzzified value, represents the flow Q j,j+1 between adjacent layers, and this is obtained by the center of gravity defuzzification method: where q i is the relative flow corresponding to role i. The saturated hydraulic conductivity K s is a proportional parameter in the model and the flow generated by the rules is multiplied by the ratio K s / K s * to get the actual flow.
4. The actual flow is then converted into corresponding values of the soil moisture layer.

5.
Steps 1-4 are repeated for each time step.
As in Bárdossy (1996), a specific K s value is selected for which the rules are specified. As the flow is proportional to the K s value, a simple multiplication makes the rule applicable in the case of a K s different from the selected reference value. Figure 4 illustrates a rule adopted in the fuzzy model.
In the stage of inference, we used the Mamdani inference method since, according to Dou et al. (1999), this method stands out for its effectiveness and simplicity. Initially, the Mamdani inference method combines the degrees of membership associated with the input values through the minimum operator (min) and adds the rules by the maximum operator (max). The Mamdani fuzzy set provides a unique response, called fuzzy topology (Barros & Bassanezi, 2001). The defuzzified value is calculated by combining all the rules. The calculation is performed for all layers of the flow field at each time step. The new values of soil moisture in each layer are calculated by applying the continuity equation (Equation 2).
According to , the fuzzy model indicated contains the two parameters, K s and θ s , i.e., it is not necessary to specify the nonlinear functions K(ψ) and ψ(θ) when applying the model. During the process of rule derivation, these nonlinear functions are used, i.e., the nonlinear behavior is implicitly incorporated in the rules.

RESULTS AND DISCUSSION
Rainfall was measured at the meteorological station, corresponding to an interval of ten days  Figure 4. A fuzzy rule adopted for the vertical flow between two soil layers.
( Figure 5). During this period there was rainfall of 96.7 mm.
The fuzzy rule-based model was developed and adapted to the conditions observed from the analysis of experimental data. With the help of the fuzzy model, soil moisture profiles were simulated. Figure 6 compares the results of these simulations with experimental data obtained in the field. This figure illustrates the evolution of the moisture profile for the period under study. The correlation between the estimated results and experimental data can be observed; in general, the fuzzy rule-based model provided excellent agreement with the experimental profile of soil moisture.
This fact can be easily observed with the aid of figure 7, which compares the evolution between the experimental soil moisture and the soil moisture calculated by the fuzzy model for the depths of 20, 60 and 100 cm. Over the 240 h, the values simulated by the fuzzy model agreed well with those measured in the field. (14) Figure 8 shows the PE for each time step. According to the figure, one can observe that the PE grows rapidly and then fluctuates between very close values around a mean value until the end of the simulation. This can be explained by fitting of the fuzzy system to the processes and its development into a condition of stability. The PE showed maximum and minimum values of 1.275 and 0.009 %, respectively, and their average value was 0.878 %. These figures indicate that the fuzzy model worked satisfactorily.
In order to compare the experimental data with the simulation results presented in figure 6, the Root Mean Square Error (RMSE) was used as another tool of analysis, defined as follows: Where x i is the difference between the observed data and the fitted model for the i-th sample. Values of RMSE close to zero indicate perfect fitness and calibration of the model is considered satisfactory only when RMSE <3.0 (Kourgialas et al., 2010). The RMSE value used was 0.0092. This result is of the same order of magnitude as approximations by fuzzy models in the literature, as in Kukolj (2002). Therefore, this result likewise confirms that fuzzy modeling generated values in close agreement with those obtained in the field, and so the simulation can be considered quite satisfactory.
It is noteworthy that in this study the rainfall data were of great importance for proper fit of the fuzzy model presented. With proper use of this information in equation 2, it was possible to fit both membership functions, and certain rules were adapted to correct a few points of the moisture profiles simulated for the rainiest days. This fitting was also performed intuitively, using the inference system (Mamdani), and taking the analysis and judgment of experts into account.
Studies that also showed good approximations using fuzzy rule-based models, but using different tools, are found in the literature, for example, the work of , , Bárdossy (1996), and Vernieuwe et al. (2006;2007), who achieved satisfactory results in simulations similar to those in this work. However, all the authors cited built systems using the fuzzy inference method of Takagi-Sugeno.
According to , models based on fuzzy rules should not be thought of as a way of replacing models of partial differential equations based on numerical solutions, but rather should be used to simplify them. This study confirmed some advantages associated with the fuzzy models presented. Their simplicity, low computational cost, versatility and flexibility allow them to be adapted to new patterns by modifying the parameters that define the fuzzy inference system (FIS), i.e., the shapes of membership functions and their parameters, rules, and weights, as well as implication methods, aggregation and defuzzification.
This conclusion confirms the possibility of modeling other cases from the use of fuzzy logic, adopting the same methodology proposed and applied in this study. The use of fuzzy set theory is of interest and is useful for further research of this nature. It allows fluctuation of the parameters, obtaining results that agree with the rules established by experts.

CONCLUSIONS
1. According to the results, it was possible to assess the evolution of moisture profiles for the soil under study, using this fuzzy rule-based model. The results from fuzzy modeling were very satisfactory when compared with data from experimental measurements. This was confirmed by the results from calculation of Percent Error (PE) and Root Mean Square Error (RMSE) for the modeling.
2. The way in which membership functions were appropriate and the use of defuzzification method chosen (Center of Gravity) were of paramount importance to achieve the results presented by fuzzy rule-based model.
3. From the analysis of the results discussed above, it appears that fuzzy rule-based models provide an alternative for calculating water dynamics and for modeling different hydrological processes. They have the advantage of applying a few parameters instead of numerical models, and are also considerably faster and more robust.

ACKNOWLEDGEMENT
Our thanks to the CNPq (Processo nº 475462/2006-8) for the funding that allowed this study.