# Greenhouse Modeling Using Continuous Timed Petri Nets

Authors: José Luis Tovany; Roberto Ross-León; Javier Ruiz-León; Antonio Ramírez-Treviño; Ofelia Begovich
Journal: Mathematical Problems in Engineering
 (2013)

---

## Abstract

This paper presents a continuous timed Petri nets (ContPNs) based greenhouse modeling methodology. The presented methodology is based on the definition of elementary ContPN modules  which are designed to capture the components of a general energy and mass balance differential equation, like parts that are reducing or increasing variables, such as heat, CO2 concentration, and humidity. The semantics of ContPN is also extended in order to deal with variables depending on external greenhouse variables, such as solar radiation. Each external variable is represented by a place whose marking depends on an a priori known function, for instance, the solar radiation function of the greenhouse site, which can be obtained statistically. The modeling methodology is illustrated  with a greenhouse modeling example.


---

## Body

## 1. Introduction

Greenhouses allow increasing the quantity and improve the quality of the crops produced inside them. The automation of greenhouses has been one of the main topics regarding greenhouse functioning and production, since using control loops, tuned as the agronomist and biologist researchers propose, improves the use of water, energy, and fertilizers. Simultaneously, the volume and quality of crops are increased.One of the main problems in controlling greenhouses is obtaining a fine mathematical greenhouse model capturing the actual greenhouse behavior since the models are represented by nonlinear differential equations including disturbances where the parameters are time variant. The derived models lead to very complex differential equations and they are hard to obtain.In order to obtain a greenhouse model, researchers use many approaches; most of them are based on heat and mass balance equations. In [1], a greenhouse model, including natural ventilation and evaporative cooling, is presented. The authors use heat and mass balance equations to derive the model. Since that approach includes a linearization stage, the model is valid only around the operating point. Another approach deals with linear and nonlinear identification of the greenhouse behavior using neural networks [2]. This method uses, however, a large amount of data samples due to their large number of degrees of freedom, and it also requires a large computation time for training the neuronal network. In [3] a robust method for nonlinear identification of a climate system using evolutionary algorithms was proposed. Although the model is validated, the convergence of the algorithm could be too long. In [4] a fuzzy model of a greenhouse by taking heat and water measurements is proposed. However, the number of fuzzy rules needed to compute an actual greenhouse model is too large and it is not clear how to find out the rules.The approach herein presented uses  continuous timed Petri nets(ContPNs) [5, 6] to capture the greenhouse dynamics. We propose a bottom-up modeling methodology: first, ContPN elementary modules (balance, generation, consumption, and fluid balance) are defined to represent the basic components of an energy and mass balance equation such as storage, source, loss, generation, and consumption of mass or energy. A balance module representing any energy or mass balance equation is obtained by merging these elementary ContPN modules. Then, a ContPN model is constructed for each greenhouse state variable, adding as many elementary modules as components exist in the energy and mass balance equation. Afterwards the model parameters are identified and represented by the ContPN parameters, such as marking and transition firing rates.The greenhouseContPN modeling methodology presented in this paper provides a pictorial representation of variables which allows easy understanding of the interaction between places (variables). Also, the ContPN model allows having a modular model where elements can be added or removed as necessary. The lack of negative values in Petri nets does not affect the system modeling because the greenhouse climate (temperature, water vapor concentration, and CO2 concentration) is a positive system.This work is organized as follows. In Section2, some concepts about Petri nets are presented and the extended semantics is proposed. In Section 3, a Petri net modeling procedure for greenhouses is proposed. Section 4 presents an example of a greenhouse modeled with ContPN. Finally, in Section 5 some conclusions are given.


## 2. Preliminaries

### 2.1. Petri Nets Concepts

This subsection introduces basic concepts on  continuous timed Petri nets. In order to have more detailed information, an interested reader may also consult [7–10].Definition 1.
A continuous Petri net(CPN) is a pair (N,m0), where N=(P,T,Pre,Post) is a Petri net structure (PN) and m0∈{ℝ+∪0}|P| is the initial marking, and P={p1,…,pn} and T={t1,…,tk} are finite sets of elements named places and transitions, respectively. Pre,Post∈{ℕ∪0}|P|×|T| are the pre- and postincidence matrices, where Pre[i,j](Post[i,j]) represents the weight of the arc going from pi to tj (from tj to pi).
The incidence matrix denoted byC is defined by C=Post-Pre. Right and left annullers of C are called T- and P-flows, respectively.
Each placepi has a marking denoted by mi∈{ℝ+∪0}. Let xi,xj∈P∪T; then the set •xi={xj∣Pre[j,i]>0}, (xi•={xj∣Post[j,i]>0}) is the preset (postset) of xi.
A transitiontj∈T is enabled at marking m if and only if, forallpi∈•tj, mi>0. Its enabling degree is given by
(1)enab(tj,m)=minpi∈•tjm[pi]Pre[i,j].
The enabling degree determines the maximum amount oftj that can be fired at marking m leading to a new marking; thus m′=m+αC[•,j] where 0<α<enab(tj,m).
Ifm is reachable from m0 by firing the finite sequence σ of enabled transitions, then m=m0+Cσ→ is named the CPN state equation, where σ→∈{ℝ+∪0}|T| is the firing count vector; that is, σ→j is the cumulative amount of firing of tj in the sequence σ.
The set of all reachable markings fromm0 is called the reachability set and it is denoted by RS(N,m0). In the case of a CPN system, RS(N,m0) is a convex set [11].
ACPN is bounded when every place is bounded; that is, for allp∈P,∃bp∈ℝ s.t. m[p]≤bp at every reachable marking m, and it is live when every transition is live (it can ultimately be fired from every reachable marking) [8].Definition 2.
A continuous timed Petri net is a 3-tupleContPN=(N,λ,m0), where (N,m0) is a CPN and λ:T→{ℝ+}|T| is a function associating a firing rate with each transition.
The state equation of aContPN is
(2)m˙(τ)=Cf(τ),
where τ is the time variable, f(τ)=σ˙(τ).Definition 3.
AContPN is called infinite server semantic ContPN if the flow of a transition ti is
(3)fi=λi·enab(ti,m)=λi·minp∈•ti{m(p)Pre[p,ti]},
where fi is the flow of transition ti and the ith entry of the vector f.Notice thatContPN under infinite server semantics can actually be considered as a piecewise linear system (a class of hybrid systems) due to the minimum operator that appears in the enabling function in the flow definition. Equation (2) can be expressed as a piecewise linear system given by
(4)m˙=CΛΠ(m)·m.The firing rate matrix is denoted byΛ=diag(λ1,…,λ|T|). A configuration of a ContPN at m is a set of (p,t) arcs describing the effective flow of all transitions:
(5)Π(m)[i,j]={1Pre[i,j]ifpiisconstrainingtj0otherwise.Definition 4.
AContPN is called product server semanticContPN if the flow of a transition ti is
(6)fi=λi·∏p∈•ti‍{m(p)Pre[p,ti]}.
In order to apply a control action in (2), a subtracting term u, such that 0≤ui≤fi, is added to every transition ti to indicate that its flow can be reduced. This control action is adequate because it captures the real behavior that the maximum machine throughput can only be reduced. Thus, the controlled flow of transition ti becomes wi=fi-ui. Then, introducing f=ΛΠ(m)·m and u in (2) the forced state equation is
(7)m˙=C[f-u]=Cw0≤ui≤fi.
In order to obtain a simplified version of the state equation, the input vectoru is rewritten as u=IuΛΠ(m)·m, where Iu=diag(Iu1,…,Iu|T|) and 0≤Iui≤1. Then the matrix Ic=I-Iu is constructed and the state equation can be rewritten as
(8)m˙=CIcf=Cw.
Notice that 0≤Ici≤1. A transition is called noncontrollable when its flow cannot be reduced. Every non-controllable transition tj has associated a constant input control Icj=1.


### 2.2.ContPN with Extended Semantics

RegularContPN models do not include disturbances and nonlinearities; therefore it is required to add semantics that allow us to incorporate them.Definition 5.
A place is called afunction place if its marking at time τ is determined by the actual marking of other places or external disturbances. Thus, the marking of a function placep is described by
(9)m[p](τ)=h(m,D),
where m[p](τ) is the marking of place p at time τ, h(•) is a known function, and D is a measurable disturbance.Notice that the marking offunction places is not determined directly by the differential equations. Also, since function places are mainly seen as disturbances, their markings do not represent controllable variables.Definition 6.
AContPN that includes function places is called a ContPN with extended semantics.From now on, allContPNs in this paper are considered with extended semantics.


### 2.3. Mass and Energy Balance Equations

From experience, it is well known that matter and energy may change their form, but they cannot be created or destroyed. This notion is expressed in the general mass and energy balance equation:(10)Q=∫τ0τf(qin-qout+qgen-qcon)dτ,
where Q is the accumulated quantity (final amount of quantity minus initial amount of quantity) inside the system boundary during the time interval [τ0,τf], qin is the amount of quantity entering the system through the system boundary, qout is the amount of quantity leaving the system through the system boundary, qgen is the amount of quantity generated (i.e., formed) inside the system boundary, qcon is the amount of quantity consumed (i.e., converted to another form) inside the system boundary, and a quantity may be in any mass or heat unit.


## 2.1. Petri Nets Concepts

This subsection introduces basic concepts on  continuous timed Petri nets. In order to have more detailed information, an interested reader may also consult [7–10].Definition 1.
A continuous Petri net(CPN) is a pair (N,m0), where N=(P,T,Pre,Post) is a Petri net structure (PN) and m0∈{ℝ+∪0}|P| is the initial marking, and P={p1,…,pn} and T={t1,…,tk} are finite sets of elements named places and transitions, respectively. Pre,Post∈{ℕ∪0}|P|×|T| are the pre- and postincidence matrices, where Pre[i,j](Post[i,j]) represents the weight of the arc going from pi to tj (from tj to pi).
The incidence matrix denoted byC is defined by C=Post-Pre. Right and left annullers of C are called T- and P-flows, respectively.
Each placepi has a marking denoted by mi∈{ℝ+∪0}. Let xi,xj∈P∪T; then the set •xi={xj∣Pre[j,i]>0}, (xi•={xj∣Post[j,i]>0}) is the preset (postset) of xi.
A transitiontj∈T is enabled at marking m if and only if, forallpi∈•tj, mi>0. Its enabling degree is given by
(1)enab(tj,m)=minpi∈•tjm[pi]Pre[i,j].
The enabling degree determines the maximum amount oftj that can be fired at marking m leading to a new marking; thus m′=m+αC[•,j] where 0<α<enab(tj,m).
Ifm is reachable from m0 by firing the finite sequence σ of enabled transitions, then m=m0+Cσ→ is named the CPN state equation, where σ→∈{ℝ+∪0}|T| is the firing count vector; that is, σ→j is the cumulative amount of firing of tj in the sequence σ.
The set of all reachable markings fromm0 is called the reachability set and it is denoted by RS(N,m0). In the case of a CPN system, RS(N,m0) is a convex set [11].
ACPN is bounded when every place is bounded; that is, for allp∈P,∃bp∈ℝ s.t. m[p]≤bp at every reachable marking m, and it is live when every transition is live (it can ultimately be fired from every reachable marking) [8].Definition 2.
A continuous timed Petri net is a 3-tupleContPN=(N,λ,m0), where (N,m0) is a CPN and λ:T→{ℝ+}|T| is a function associating a firing rate with each transition.
The state equation of aContPN is
(2)m˙(τ)=Cf(τ),
where τ is the time variable, f(τ)=σ˙(τ).Definition 3.
AContPN is called infinite server semantic ContPN if the flow of a transition ti is
(3)fi=λi·enab(ti,m)=λi·minp∈•ti{m(p)Pre[p,ti]},
where fi is the flow of transition ti and the ith entry of the vector f.Notice thatContPN under infinite server semantics can actually be considered as a piecewise linear system (a class of hybrid systems) due to the minimum operator that appears in the enabling function in the flow definition. Equation (2) can be expressed as a piecewise linear system given by
(4)m˙=CΛΠ(m)·m.The firing rate matrix is denoted byΛ=diag(λ1,…,λ|T|). A configuration of a ContPN at m is a set of (p,t) arcs describing the effective flow of all transitions:
(5)Π(m)[i,j]={1Pre[i,j]ifpiisconstrainingtj0otherwise.Definition 4.
AContPN is called product server semanticContPN if the flow of a transition ti is
(6)fi=λi·∏p∈•ti‍{m(p)Pre[p,ti]}.
In order to apply a control action in (2), a subtracting term u, such that 0≤ui≤fi, is added to every transition ti to indicate that its flow can be reduced. This control action is adequate because it captures the real behavior that the maximum machine throughput can only be reduced. Thus, the controlled flow of transition ti becomes wi=fi-ui. Then, introducing f=ΛΠ(m)·m and u in (2) the forced state equation is
(7)m˙=C[f-u]=Cw0≤ui≤fi.
In order to obtain a simplified version of the state equation, the input vectoru is rewritten as u=IuΛΠ(m)·m, where Iu=diag(Iu1,…,Iu|T|) and 0≤Iui≤1. Then the matrix Ic=I-Iu is constructed and the state equation can be rewritten as
(8)m˙=CIcf=Cw.
Notice that 0≤Ici≤1. A transition is called noncontrollable when its flow cannot be reduced. Every non-controllable transition tj has associated a constant input control Icj=1.


## 2.2.ContPN with Extended Semantics

RegularContPN models do not include disturbances and nonlinearities; therefore it is required to add semantics that allow us to incorporate them.Definition 5.
A place is called afunction place if its marking at time τ is determined by the actual marking of other places or external disturbances. Thus, the marking of a function placep is described by
(9)m[p](τ)=h(m,D),
where m[p](τ) is the marking of place p at time τ, h(•) is a known function, and D is a measurable disturbance.Notice that the marking offunction places is not determined directly by the differential equations. Also, since function places are mainly seen as disturbances, their markings do not represent controllable variables.Definition 6.
AContPN that includes function places is called a ContPN with extended semantics.From now on, allContPNs in this paper are considered with extended semantics.


## 2.3. Mass and Energy Balance Equations

From experience, it is well known that matter and energy may change their form, but they cannot be created or destroyed. This notion is expressed in the general mass and energy balance equation:(10)Q=∫τ0τf(qin-qout+qgen-qcon)dτ,
where Q is the accumulated quantity (final amount of quantity minus initial amount of quantity) inside the system boundary during the time interval [τ0,τf], qin is the amount of quantity entering the system through the system boundary, qout is the amount of quantity leaving the system through the system boundary, qgen is the amount of quantity generated (i.e., formed) inside the system boundary, qcon is the amount of quantity consumed (i.e., converted to another form) inside the system boundary, and a quantity may be in any mass or heat unit.


## 3. Modeling Methodology

### 3.1. Greenhouse System

A greenhouse is a building which isolates the crop from the outside environment, preventing it from hazards such as extreme climate changes and plagues. Also, it improves the crop production by means of the greenhouse climate manipulation, provided through some components that can be added: temperature can be manipulated by means of ventilation, heating systems, and water sprinklers; water concentration can be manipulated by means of humidifiers, water sprinklers, ventilation, and fans; luminosity can be manipulated by means of shaded mesh and light bulbs; carbon dioxide concentration can be manipulated by means of CO2 injectors. Notice that some components affect more than one climate variable. The selection of components varies depending on the geographical area and economical factors.Nevertheless, all environmental influences over a greenhouse, manipulated or not, fulfill the energy and mass balance equation (10). For example, a simple heat balance equation is depicted in Figure 1, where the heat source, for instance, solar radiation, is the heat entering (qin) into a greenhouse system; the heat storage, the greenhouse itself, is the heat absorbed (Q) by the greenhouse system; and the heat to surroundings, for instance by ventilation, is the heat loss (qout) outside the greenhouse system.Figure 1
Heat balance.For the generated and consumed flows, some examples are as follows: the energy gained from condensation is part of the generated heatqgen; the energy consumed by evaporative cooling is part of the heat consumed qcon.Therefore, we propose a modeling approach based on the construction ofContPN modules that represent each component of the balance equation.


### 3.2. Elementary Modules

Some modules are defined in order to represent the flows in the balance equation. A first approach to a balance module is obtained from Figure2.Figure 2
ContPN representation of tokens exchange.TheContPN of Figure 2 has the following matrices:
(11)C=[-adc-c],Π=[1a001c],Λ=[λ100λ2].Thus, the marking equations are given by(12)m˙1=-λ1m1+dcλ2m2m˙2=baλ1m1-λ2m2.The balance of the marking is given when the steady state markings ofm1 and m2 are equal. So, the equilibrium points of the previous equations must be m1=m2. Thus, the required relationships are
(13)ba=cd=λ2λ1.Replacing the latter relationships, the equations of the marking are(14)m˙1=-λ1m1+λ1m2m˙2=λ2m1-λ2m2.For example, given a temperature inp1 and a different temperature in p2, the difference between λ1 and λ2 is given by the heat capacity of each system.In order to prove that the equilibrium points are stable, the Lyapunov functionV(m)=(1/2λ1)m12+(1/2λ2)m22 is used, where the derivative of V(m) is given by
(15)V˙(m)=1λ1m1m˙1+1λ2m2m˙2=-m12+2m2m1-m22=-(m1-m2)2
which is negative for any m1≠m2, so the equilibrium points are stable.The number of tokens in the steady state depends on the initial valuesm1(0) and m2(0). The marking at the equilibrium point can be separated in three cases: λ1<λ2, λ1>λ2, and λ1=λ2.Ifλ1<λ2, m1 gains (or losses) tokens faster thanm2 losses (or gains) them, so the steady state marking value is closer tom1(0). If λ1>λ2, m1 gains (or losses) tokens faster thanm2losses (or gains) them, so the steady state marking value is closer tom2(0). In case λ1=λ2, the steady state marking is given by (m1(0)+m2(0))/2.The balance module as presented in Figure2 with restrictions (13) can be represented as the ContPN of Figure 3 when one of the variables is measured (pd is a function place) and its dynamics are not modeled. In order to represent a balance, the transitions tb1 and tb2 have the same firing rate λb1=λb2. Thus, the equation of the ContPN of Figure 3 is
(16)m˙var=-λb1mvar+λb1md.Figure 3
Balance module.For generation and consumption flows, theContPNs of Figures 4 and 5 are used, respectively.Figure 4
Generation module.Figure 5
Consumption module.The heat and mass balance can be carried out by a fluid that affects proportionally the transfer between variables. In that case, aContPN as in Figure 6 is used. This ContPN is defined with product semantics in order to represent the product of the fluid pconv with the variables pvar and pd.Figure 6
Fluid balance module.There are modules dependent on a device, but the device dynamics is considered to be faster than the greenhouse dynamics, so the dynamics of the devices are not modeled. The only difference is that transitions related to devices are controllable; that is, the transitions of a device module have the formIciλi as stated in Section 2.


### 3.3. GreenhouseContPN Model

Since every greenhouse physical variable fulfills the energy and mass balance equation, we propose a modeling approach based on the construction of modules as described in the following.


#### 3.3.1. Modeling Procedure

(1)
Create places for variables andfunction places for disturbances.
Variable places capture the greenhouse variables (such as soil temperature, air temeprature, and CO2 concentration) and function places capture external variables (such as solar radiation and external temperature)
(2)
Construct a module for each variable of interest in the greenhouse.
(2a)
A balance module is associated with each physical exchange (heat or mass) affecting the corresponding variable (e.g., ventilation, conduction).
(2b)
A generator module is associated to each physical transformation inside the greenhouse which increases the corresponding variable (e.g., evapotranspiration).
(2c)
A consumption module is associated with each physical transformation inside the greenhouse which decreases the corresponding variable (e.g., condensation, evapotranspiration).
(2d)
A fluid balance module is associated with each physical exchange (heat or mass) affecting the corresponding variable with the proportional effect of a fluid (e.g., natural ventilation).
(3)
Merge all constructed balance modules.
(4)
Identify the model parameters.Following the previous procedure we obtain thegreenhouseContPNmodel. For a practical illustration, we show in the next section the greenhouse ContPN modeling of two climate variables: temperature and water vapor concentration.


## 3.1. Greenhouse System

A greenhouse is a building which isolates the crop from the outside environment, preventing it from hazards such as extreme climate changes and plagues. Also, it improves the crop production by means of the greenhouse climate manipulation, provided through some components that can be added: temperature can be manipulated by means of ventilation, heating systems, and water sprinklers; water concentration can be manipulated by means of humidifiers, water sprinklers, ventilation, and fans; luminosity can be manipulated by means of shaded mesh and light bulbs; carbon dioxide concentration can be manipulated by means of CO2 injectors. Notice that some components affect more than one climate variable. The selection of components varies depending on the geographical area and economical factors.Nevertheless, all environmental influences over a greenhouse, manipulated or not, fulfill the energy and mass balance equation (10). For example, a simple heat balance equation is depicted in Figure 1, where the heat source, for instance, solar radiation, is the heat entering (qin) into a greenhouse system; the heat storage, the greenhouse itself, is the heat absorbed (Q) by the greenhouse system; and the heat to surroundings, for instance by ventilation, is the heat loss (qout) outside the greenhouse system.Figure 1
Heat balance.For the generated and consumed flows, some examples are as follows: the energy gained from condensation is part of the generated heatqgen; the energy consumed by evaporative cooling is part of the heat consumed qcon.Therefore, we propose a modeling approach based on the construction ofContPN modules that represent each component of the balance equation.


## 3.2. Elementary Modules

Some modules are defined in order to represent the flows in the balance equation. A first approach to a balance module is obtained from Figure2.Figure 2
ContPN representation of tokens exchange.TheContPN of Figure 2 has the following matrices:
(11)C=[-adc-c],Π=[1a001c],Λ=[λ100λ2].Thus, the marking equations are given by(12)m˙1=-λ1m1+dcλ2m2m˙2=baλ1m1-λ2m2.The balance of the marking is given when the steady state markings ofm1 and m2 are equal. So, the equilibrium points of the previous equations must be m1=m2. Thus, the required relationships are
(13)ba=cd=λ2λ1.Replacing the latter relationships, the equations of the marking are(14)m˙1=-λ1m1+λ1m2m˙2=λ2m1-λ2m2.For example, given a temperature inp1 and a different temperature in p2, the difference between λ1 and λ2 is given by the heat capacity of each system.In order to prove that the equilibrium points are stable, the Lyapunov functionV(m)=(1/2λ1)m12+(1/2λ2)m22 is used, where the derivative of V(m) is given by
(15)V˙(m)=1λ1m1m˙1+1λ2m2m˙2=-m12+2m2m1-m22=-(m1-m2)2
which is negative for any m1≠m2, so the equilibrium points are stable.The number of tokens in the steady state depends on the initial valuesm1(0) and m2(0). The marking at the equilibrium point can be separated in three cases: λ1<λ2, λ1>λ2, and λ1=λ2.Ifλ1<λ2, m1 gains (or losses) tokens faster thanm2 losses (or gains) them, so the steady state marking value is closer tom1(0). If λ1>λ2, m1 gains (or losses) tokens faster thanm2losses (or gains) them, so the steady state marking value is closer tom2(0). In case λ1=λ2, the steady state marking is given by (m1(0)+m2(0))/2.The balance module as presented in Figure2 with restrictions (13) can be represented as the ContPN of Figure 3 when one of the variables is measured (pd is a function place) and its dynamics are not modeled. In order to represent a balance, the transitions tb1 and tb2 have the same firing rate λb1=λb2. Thus, the equation of the ContPN of Figure 3 is
(16)m˙var=-λb1mvar+λb1md.Figure 3
Balance module.For generation and consumption flows, theContPNs of Figures 4 and 5 are used, respectively.Figure 4
Generation module.Figure 5
Consumption module.The heat and mass balance can be carried out by a fluid that affects proportionally the transfer between variables. In that case, aContPN as in Figure 6 is used. This ContPN is defined with product semantics in order to represent the product of the fluid pconv with the variables pvar and pd.Figure 6
Fluid balance module.There are modules dependent on a device, but the device dynamics is considered to be faster than the greenhouse dynamics, so the dynamics of the devices are not modeled. The only difference is that transitions related to devices are controllable; that is, the transitions of a device module have the formIciλi as stated in Section 2.


## 3.3. GreenhouseContPN Model

Since every greenhouse physical variable fulfills the energy and mass balance equation, we propose a modeling approach based on the construction of modules as described in the following.


### 3.3.1. Modeling Procedure

(1)
Create places for variables andfunction places for disturbances.
Variable places capture the greenhouse variables (such as soil temperature, air temeprature, and CO2 concentration) and function places capture external variables (such as solar radiation and external temperature)
(2)
Construct a module for each variable of interest in the greenhouse.
(2a)
A balance module is associated with each physical exchange (heat or mass) affecting the corresponding variable (e.g., ventilation, conduction).
(2b)
A generator module is associated to each physical transformation inside the greenhouse which increases the corresponding variable (e.g., evapotranspiration).
(2c)
A consumption module is associated with each physical transformation inside the greenhouse which decreases the corresponding variable (e.g., condensation, evapotranspiration).
(2d)
A fluid balance module is associated with each physical exchange (heat or mass) affecting the corresponding variable with the proportional effect of a fluid (e.g., natural ventilation).
(3)
Merge all constructed balance modules.
(4)
Identify the model parameters.Following the previous procedure we obtain thegreenhouseContPNmodel. For a practical illustration, we show in the next section the greenhouse ContPN modeling of two climate variables: temperature and water vapor concentration.


## 3.3.1. Modeling Procedure

(1)
Create places for variables andfunction places for disturbances.
Variable places capture the greenhouse variables (such as soil temperature, air temeprature, and CO2 concentration) and function places capture external variables (such as solar radiation and external temperature)
(2)
Construct a module for each variable of interest in the greenhouse.
(2a)
A balance module is associated with each physical exchange (heat or mass) affecting the corresponding variable (e.g., ventilation, conduction).
(2b)
A generator module is associated to each physical transformation inside the greenhouse which increases the corresponding variable (e.g., evapotranspiration).
(2c)
A consumption module is associated with each physical transformation inside the greenhouse which decreases the corresponding variable (e.g., condensation, evapotranspiration).
(2d)
A fluid balance module is associated with each physical exchange (heat or mass) affecting the corresponding variable with the proportional effect of a fluid (e.g., natural ventilation).
(3)
Merge all constructed balance modules.
(4)
Identify the model parameters.Following the previous procedure we obtain thegreenhouseContPNmodel. For a practical illustration, we show in the next section the greenhouse ContPN modeling of two climate variables: temperature and water vapor concentration.


## 4. Greenhouse Modeling Example

Consider the greenhouse climate system of Figure7. We want to obtain the greenhouse temperature and water vapor concentration model. According to step 1 of the modeling procedure, we have to associate places for the involved variables: greenhouse temperature Tg, soil temperature Ts, and one for the vapor concentration CH2Oas shown in Table 1.Table 1
Relation between variables and places.
Variable
Place
T
g
p
1
T
s
p
2
C
H
2
O
p
3Figure 7
A greenhouse example.Thefunction places associated with the other variables are p4 to solar radiation Io, p5 to outside temperature To, p6 to subsoil temperature Tss, p7 to outside water vapor concentration CH2O,o, p8 for wind speed v, p9 to humidifier maximum water flow Fhum, and p10 to water condensation φcons.Following step 2, for the greenhouse temperatureTg we construct generation module for solar radiation (qinIo) and condensation φcons(qincons); consumption module for the humidifier Fhum(qconhum); balance module for soil temperature Ts(qbalTs), leaks nondependent on wind and conduction through cover (qbal,cTo); and fluid balance module for leaks dependent on wind (qfbal,v,inTo) and controlled natural ventilation (qfbal,v,cnTo).For the greenhouse humidityCH2O we construct: generation module for humidifier Fhum(φinhum); consumption module for condensation φcons(φconcond); balance module for outside humidity CH2O,o leaks nondependent on wind (φbalCH2O,o); and fluid balance module for leaks dependent on wind (φfbal,v,inCH2O,o) and controlled natural ventilation (φfbal,v,cnCH2O,o).Since soil temperature is also modeled, we construct balance module for greenhouse temperatureTg(qbalTg) and subsoil temperature (qbalTss). Then, modules for each variable are constructed as shown in Table 2.Table 2
Relation between variables andfunction places.
Module
P/Var
T
q
in
I
o
p
4/Io
t
1
q
fbal
,
v
,
in
T
o
p
5/To
t
2 and t5
q
fbal
,
v
,
cn
T
o
p
5/To
t
3 and t6
q
bal
,
c
T
o
p
5/To
t
4 and t7
q
bal
T
s
p
2/Ts
t
8 and t9
q
con
hum
p
9/Fhum
t
10
q
in
cons
p
10/φcons
t
11
q
bal
T
g
p
1/Tg
t
12 and t13
q
bal
T
ss
p
6/Tss
t
14 and t15
φ
in
hum
p
9/Fhum
t
16
φ
bal
C
H
2
O
,
o
p
7/CH2O,o
t
17 and t20
φ
fbal
,
v
,
in
C
H
2
O
,
o
p
7/CH2O,o
t
18 and t21
φ
fbal
,
v
,
cn
C
H
2
O
,
o
p
7/CH2O,o
t
19 and t22
φ
con
hum
p
10/φcons
t
23Then, we merge all constructed modules. Thus, we obtain theContPN depicted in Figure 8, with state equations:
(17)m˙1=-(λ7+λ9)m1-(Ic1λ6+λ5)m1m8+λ8m2+λ1m4+λ4m5+(Ic1λ3+λ2)m5m8+λ11mx-Ic2λ10my,m˙2=λ12m1-(λ13+λ15)m2+λ14m6,m˙3=-λ22m3-(Ic1λ21+λ20)m3m8+λ19m7+(Ic1λ18+λ17)m7m8-λ23mx+Ic2λ16my,mx=min(m1,m10),my=min(m1,m9),m4=Io(τ),m5=To,m6=Tss(τ),m7=CH2O,o(τ),m8=v(τ),m9=Fhum(τ),m10=φcons(τ).Figure 8
ContPN model of greenhouse temperature and water vapor concentration.Solar radiationIo, soil temperature Ts, outside temperature To, water vapor condensation φcons, humidifier Fhum, and outside humidity concentration CH2O,o are considered as random, albeit measurable. This is because, along the day, these environmental variables are changing; nevertheless, we can add sensors in order to measure them.It has to be noted that the energy balance betweenm1 and m2is related by-λ7m1+λ8m2 and, since a balance module is used, λ7=λ8, so the balance can be referred to as λ8(m2-m1) which is an energy exchange.A similar procedure can be done for the remaining terms ofm˙1, m4, and m1 are related by a balance module, m5 and m1 by two-fluid balance module (one is controllable, but the other is not); it gains energy from m4; it also gains and loses water because of mx and my, respectively. It has to be noted that, for a greenhouse temperature above 273°K, the tokens in m1 will be higher than the tokens in m9 and m10.In the case ofm˙2, the relations are only balance modules between m2 and m1 or m6. For m˙3, there is a balance module between m3 and m7; m7 and m3 are related by two-fluid balance module (one is controllable, but the other is not); it gains and loses water because of mx and my, respectively.The identification of the model parameters can be carried out according to the preferred method. In this example, the least square method is used. The model proposed in [12] is taken as the real system and the ContPN model depicted in Figure 8 will be the identified model. In order to simplify the method, the identification is carried out in two steps. In the first one the firing of controllable transitions is avoided (i.e., the parameters associated with noncontrollable transitions are computed). These parameters are fed to the second identification step. In this step the parameters associated with controllable transitions are derived and the whole ContPN model is obtained.We are using the parameters values presented in [12, Chapter 7, pp. 135–150] without any crop inside the greenhouse and heating pipes are not considered. Besides, we add humidifier dynamics and external weather variables are considered as a sine function at different frequencies and amplitudes. The identification was carried out using the least squares method. The simulation time for the original model is 8 hours, so the functions used to approximate the external variables are positive during the simulation time. The following external variables were considered for the identification:
(18)Io=400sin(0.00011t)W/m2,To=298+7sin(0.00011t)K,Tss=293.15+3sin(0.00011t)K,CH2O,o=0.0060692+0.002sin(2t)kg/m3,v={h(t)forh(t)=10sin(0.001t)≥11elsem/s,φcons=3×10-10+2×10-10sin(t)kg/m2s.The percentage of use of the actuators is presented as follows:(19)Ic1=0.5+0.5sin(0.001t),Ic2=0.133sin(0.00011t).The initial conditions are(20)Tg=288K,Ts=298K,CH2O=0.0026kg/m3.In order to validate the proposed modeling methodology, we now present a comparison between our model and the one proposed by [12]. All the simulations and identification were carried out in MATLAB and Simulink.In Figure9, a comparison between the ContPN greenhouse temperature model and the one used by [12] is presented. In Figure 10, a comparison between the ContPN greenhouse humidity model and the one used by [12] is presented. From these figures, it can be seen that the proposed modeling methodology shows a good agreement with the original system, capturing in an accurate way the dynamic behavior of the greenhouses variables. The error (eTg=Tg,or-Tg,id and eCH2O=CH2O,or-CH2O,id) between the original system and the identified system is less than 10-3.Figure 9
Greenhouse temperature dynamics using sine functions for disturbances.Figure 10
Water vapor concentration dynamics using sine functions for disturbances.In order to demonstrate the accuracy of the proposed modeling methodology under a real and severe scenario, another identification is carried out using real data forIo, To, CH2O,o, and v (see Figure 11), in the winter of 2012, from a greenhouse prototype located in Jalisco, Mexico. The other external disturbances φcons, Ic1, and Ic2 are taken as in (18) and (19). The initial conditions are the same as in (20). It can be seen in Figures 12 and 13 that the identified model has a small error in comparison to the original model which is still less than 10-3.Measured disturbances.
(a)
(b)
(c)
(d)Figure 12
Greenhouse temperature dynamics with measured disturbances.Figure 13
Water vapor concentration dynamics with measured disturbances.


## 5. Conclusions

The greenhouseContPN modeling methodology presented in this paper provides a pictorial representation of variables which allows easy understanding of the interaction between them. The bounds in actuators are represented naturally by the marking of a place as in the case of the humidifier. In the case of the humidifier, although the tokens flow from its place can be reduced with the control, the representing place is a source place because the tokens are constant and they represent the maximum capacity of water flow.The most important point is that it allows having a modular model. Thus, elements can be added or removed as necessary. Also, the lack of negative values inPN do not affect the system modeling because the greenhouse climate (temperature, water vapor concentration, and CO2 concentration) is a positive system.The simulation contains fixed parameters for the original system, but a greenhouse parameter may change according to certain variables which will provide bigger variations in the model and the need to identify constantly in order to change the model parameters that represent better the greenhouse. Future work will include the identification of a real greenhouse prototype and its control design.



---

*Source: 639306-2013-07-21.xml*