Keywords: grassland, vegetation growth model, graphic user interface, CAPSIS III

The aim of this thesis is to set up a field-scale system which investigates and analyzes the spatial structure and dynamics of managed, permanent grassland. Biologists will use this system to monitor the biomass and traits (main characteristics for species) of the pasture, to simulate agricultural management activity, to determine efficient agriculture strategy and to predict the future trends of the pasture under changing climatic conditions.

In order to carry out spatially-explicit analysis, the present vegetation growth model deals with a large plot of grassland and divides it into many small cells. Each cell has the same area (0.1 m 2 ; considered to be a bit-size area of vegetation for a domestic herbivore) but not necessarily same traits. These traits are grouped into patches, which are the combination of many common species in a same cell. Four common patches are described into the literature and are used to describe the grassland plot. Each cell is divided in four compartments depending on their developmental stage: green vegetative, green reproductive, dead vegetative and dead reproductive. This model not only considers the permanent structure of the pasture but also the agriculture activities which are simulated as three types of events: cut, fertilization, and grazing by animals. These events occur according to the management described by the biologist.

To maintain and utilize this model, a graphic user interface which is programmed in JAVA is implemented. This GUI interface is to specify the input of users and parameters from files. Meanwhile, it provides the methods to set the structure of the pasture. Finally, the output data is produced into the format CSV or NetCDF and displayed with a graphic chart. In the future, this model will be integrated into CAPSIS (Computer-Aided Projection of Strategies In Silviculture) platform which simulates the forest growth and presents a better result display (3D distribution graph chart).

The research of the UREP addresses the ecology, functioning and ecosystem services provided by permanent grasslands in a context of global change. This topical research area meets both theoretical (front line science) and applied, societal needs. The UREP project uses a pluridisciplinary approach at local and national levels via French (ANR) and European projects. It builds on experimental installations in situ (SOERE-ACBB, phenotyping platform) and on UREP expertise in functional ecology and the analysis of greenhouse gas balances.

The purpose of this project is to investigate seasonal and annual interactions between management and grassland dynamics. So a mechanistic system of the dynamics of production, and spatial structure in permanent pastures was constructed to fulfill the demand. The system is designed to respond to various defoliation regimes, perform multiple-year simulations and produce simple outputs that are easy to treat in order to extract spatial statistics. Some events (grazing, fertilization or cut) can occur during the simulation and allow simulating heterogeneity onto the grassland and biomass produced is computed at a daily time step. Output data is produced in different formats in order to carry out statistics, graphical representation, etc.

The status of related research

Research of UREP

The research theme of UREP is grassland ecology in response to global change.

UREP uses a multidisciplinary research approach combining knowledge on grassland ecosystem structure, function and dynamics. UREP's three main areas of research in the last research period (January 2008-June 2010) were:

Carbon and nitrogen cycling in grasslands and their consequences for the greenhouse gas balance;

Linking grassland diversity and ecosystem processes; Grassland community dynamics under global change.

Significant advances were made in all three research areas over the last research period. These include improved understanding of the microbial processes controlling soil organic matter dynamics, the role of plant and soil community diversity in soil carbon sequestration and greenhouse gas emissions, the importance of grasslands as carbon sinks in Europe the links between above-and below-ground plant traits, the identification of plant strategies for the dominant grassland species.

Phenotypic plasticity in aboveground traits has been demonstrated in response to defoliation and nitrogen addition. Other works on extreme climate events in grasslands suggests that forbs have a greater resistance to drought compared with grasses or legumes. Findings over the research period have also led to advances in the understanding of Community assembly rules for grassland species, Community structure (species/ functional traits) of grasslands in response to environmental and management changes, and Consequences of community structure for grassland production and feed quality. In grazed grasslands, the importance of herbivores and foraging behavior for the creation of short or high vegetation patches has been established.

For the next research period (2011-2014), the goal of UREP still is the same: contribute to sustainable ecosystem management in a changing environment. In order to achieve this, UREP is developing an integrated and predictive approach combining observation, experiments and modeling. The current research consists of two themed sections, linked by three cross initiatives.

Section 1 "C/N cycles & Greenhouse gases" focuses on the study of carbon and nitrogen cycling in grasslands in a context of climate change and sustainable agricultural practices. The two main objectives are Quantify C sequestration, N losses and emission of greenhouse gases from grasslands Identify the key mechanisms underlying C/N cycling in grasslands. This section comprises four subsections according to the scale of the study, ranging from the molecular level to the regional scale.

Section 2 "Biodiversity, dynamics and grassland function" focuses on functional ecology and community ecology. It consists of four subsections examining functional strategies of organisms and community structure, along with the role of plant-animal and plant-soil interactions. A key objective is to identify response traits of species and communities to management and climate factors, and to understand the role of these traits foe ecosystem processes.

The cross initiatives are designed to encourage interactions between the two themed sections, and to promote research synergies. These initiatives are: Strategic policy: progress in frontline science and scientific excellence; Development of innovative methods and shared research tools; Information transfer to stakeholders and farmers.

In conclusion, the current project for UREP over the next four years aims to develop widely-recognized scientific expertise and research specificity which meets the needs of sustainable agro-ecosystems under global change."

Management and Grassland pastures

Until the 1980s, French and European agricultural policies, by supporting certain products, encouraged intensification. The elimination of limiting growth factors resulted in a standardization of production systems, which also facilitated management practices. Furthermore, this is to field abandonment, depending on access or labor constraints (distance, slope, etc.) (Bignal and McCracken, 2000; Tasser and Tappeiner, 2002) [3] . Since the 1990s, agricultural policies have evolved and encouraged extensification by subsidies per hectare, such as a premium for grassland on livestock farms which limit their stocking rate in order to maintain or increase the biological diversity, which has become an important issue (Kirchmann and Thorvaldsson, 2000). In grassland zones dominated by natural pastures, an important component of this biological diversity is attributable to the diversity of grassland species. This evolution is particularly relevant in mountainous zones where the areas used for farming are made up almost exclusively of natural grasslands (Flamant et al., 1999) [5] . In these situations, grazing or cutting operations make it possible to feed domestic herbivores, but are also a means of preventing woody species from colonizing these environments (Landsberg et al., 2003;Cole´no et al., 2005). Diversity of grassland species is generally assessed on the within-field scale (Grime et al., 1988;Bakker et al., 2004), or between farms and across regions (Thenail and Baudry, 2004) [7] . To allocate a field for a given use, farmers coordinate their decisions at the farm level (Papy, 1999; Cole´no and [START_REF] Haj | Variation in leaf traits through seasons and N-availability levels and its consequences for ranking grassland species [J][END_REF]. Thus, evaluating and predicting the impact of such policies on the diversity of grassland vegetation necessitate considering the farm level and assessing this diversity on the between-field scale. These policies led to the emergence of new areas of research and need the renewal of the reference data established for homogenous systems (van Keulen, 2006). In these complex systems, the farmer has to manage the diversity of his farmland. In this context, field characteristics have an effect on the distribution of practices. Studies showed the influence of distance to the cowshed, the surface area or the slope on the distribution of cutting and grazing practices (Morlon and Benoit, 1990;Josien et al., 1994;Fleury et al., 1996;Mottet et al., 2006). But field characteristics can also play a role on grassland vegetation diversity. The altitude or the aspect of the field can potentially influence plant species (Bornard et al., 2004) leading to differences in growing conditions (temperature and radiation) for a particular field (Legros et al., 1997). Farmers can themselves influence grassland vegetation by choosing management practices relevant for production or environmental purposes (Ronchi and Nardone, 2003;Cole´no et al., 2005). However, these studies are partial; none of them taking into account the main characteristics that play a role both in land use management practices and in the plant species found in natural grasslands. In other words, they do not really assess the complexity of the relationships involved in these livestock systems [1] Numerous studies have shown that the chemical composition of grass is influenced by the season of growth and age of regrowth (Wilman et al., 1976;Demarquilly and Andrieu, 1988), as well as by the time of day (Holt and Hilst, 1969;Lechtenberg et al., 1972). Under strip-grazing management, defoliation of the sward takes place by successive layers from the top of the canopy (Wade, 1991), so the chemical composition of the selected grass is a function of the vertical distribution of the chemical constituents in the sward. In order to predict the chemical composition of the ingested herbage, it is necessary to know this vertical distribution and the main factors controlling its variation. In grass species, it is well established that the bulk density of the sward increases with the depth of the sward, as well as the proportion of sheaths, stems and dead tissue (Wilkinson et al., 1970;Clark et al., 1974) [10] . The leaf blades are generally more digestible, richer in crude protein and poorer in cell-wall constituents than sheaths and stems (Deinum and Dirven, 1975;Wilman et al., 1976). There is, thus, an increasing or a decreasing vertical gradient of composition according to the chemical constituent. Such a vertical gradient in composition has been described in tropical grasses (Wilkinson et al., 1970;Stobbs, 1975;Hendricksen and Minson, 1980;Herrera et al., 1984) and on grass/legume mixtures (Clark et al., 1974;Holmes et al., 1992;Johnston et al., 1993;Wilkins et al., 1995). Very few data are available on pure temperate grasses under rotational grazing. In particular, there are few descriptions in the literature concerning the vertical gradient of chemical constituents in swards of perennial ryegrass (Lolium perenne L.), which is certainly the most widely used grass species for grazing in temperate environments. Similarly, the factors controlling the vertical variation of chemical composition in swards have often been the subject of separate studies (Wilkinson et al., 1970;Herrera et al., 1984;Johnston et al., 1993). The aim of the present study is to describe the changes in sward structure (biomass, chemical composition) of a perennial ryegrass sward over the growth season for grasslands subjected to different management and climatic conditions.

Dynamic modeling of pastures

Dynamic, mechanistic and deterministic models can greatly assist ecological investigation. Dynamic models of managed grasslands already exist. They usually predict daily growth as the product of potential growth and a number of functions of environmental factors (temperature, water, nutrient supply and season). In the earliest models, potential growth was determined empirically from the plant's genetic potential or from field measurements. More recent models have used a mechanistic approach, based on light-utilization efficiency, which enables a better understanding of seasonal dynamics of production. Several models predict the quality of the forage by estimating either the proportion of green and dead material or the digestibility of herbage, often in relation to the proportion of green leaves, stem and senescent material. [4] The existing models are based on single species or growth forms, and the models that predict the behavior of diverse pastures consider each species or growth form separately, which brings in a great complexity in inputs and outputs for highly diverse pastures. The objective here was to develop a spatially-explicit model of permanent pasture, capable of simulating the effects of management (type and intensity) on biomass and sward structure at the field scale.

The model had to be as simple as possible and had to produce outputs that could be used directly as inputs for spatial statistics. To keep the model simple, a functional approach rather than a species-based approach was chosen; it was assumed that the dynamics of permanent pastures could be explained by the average biological attributes (functional traits) of the plant community making up the grassland. The present model builds on a simpler, pre-existing vegetation model described in the papers of Jouven et al ( 2006) [1] .

Main content and organization of the thesis

This thesis implements an analytical system to investigate and analyze the spatial structure and the biomass of a permanent pasture dynamically. The work is divided into two parts: an analytical model which simulates the spatial structure and the flows of biomass and a graphical user interface to run and use easily by providing means to choose input files and generate output data in a correct format.

The organization of the thesis is as following. Chapter 1 describes the background of this system, its purpose and the related research in its field.

Chapter 2 presents the vegetation growth model and relations between variables in this model.

Chapter 3 indicates the system requirement analysis including general system requirements, the functional and un-functional requirements.

Chapter 4 specializes the system design which is separated into several parts: system structure design, IO part specific design, GUI module specific design and Logic module specific design. Chapter 5 narrates system implementation and testing including the environment of system implementation, implementation of modules, key interface of the software system and system testing.

Chapter 2 Vegetation Growth Model

The aim of this system is to investigate and analyze the dynamic of grassland biomass production and its spatial structure. It simulates management events applied to the grassland and computes flows of biomass inside the pasture. This system consists of a model which describes methods to analysis the structure and the biomass of the pasture and a graphic user interface which provides methods of determining the structure of the pasture. Meanwhile, this user interface maintains and runs the simulation of the model. In this chapter, the vegetation growth model is presented in terms of computer science.

Model description

The original vegetation growth model is based on biological principles. To implement the model integrated into the software, the biological description needs to be translated into the language of computer science. This is achieved using the process description tool "Berkeley Madonna". In addition, "Berkeley Madonna" can set the value of variables and display the result of these variables through the process which has been set up. Thanks to "Berkeley Madonna", this vegetation growth model has been described in computer science terms.

Given that this model strongly relates to the biology and agriculture, there are many specialized words and abbreviations. Table 2-1 shows all the abbreviations needed in this thesis. Chart 2-2 Biomass flow within the life cycle of the grassland [1] Chart 2-3 shows the relationship and the diversion of the variables in the compartment GV and GR. Some other variables are not input data neither output data. They correspond to the intermediate results, such as ALLOC, AN, etc. The biological basis for the growth functions is described in the papers of Jouven et al (2006) [1] .

Step by step, the processes of computation show below. These constraints and equations are presented and used in Berkeley Madonna to simulate the vegetation growth model.

1)

To compute AN, the equation is as follows.

( 2)To compute ALLOC, the equation is as follows.

(

1) ALLOC = F_IN*Cut

To compute Cut, the pseudo codes are as following.

(2)

IF(SUM_Temperature < ST1) Cut = 0 ELSE IF (SUM_Temperature > ST2) Cut = 0 ELSE Cut = 1
Then BM_GV and BM_GR are computed as following.

3)To compute BM_GV, the equations are as below.

(1) BM_GV + = new growth GV To compute function_age_GR: (7)

IF (Age_GR/LLS < 1/3) function_age_GR = 1 ELSE IF (Age_VS/LLS < 2/3) function_age_GR = 2 ELSE function_age_GR = 3
To compute abscission GR:

Brief summary

This chapter presents methods which transfer the biologic rules to the language of computer science and describes main functions of this model. First, this chapter presents the logic structure of the pasture then specifically illustrates methods of computing the biomass of these four compartments with the flow charts and pseudo codes.

Chapter 3 System Requirement Analysis

General system requirements

The task of this chapter is to analysis the requirements for the model described in Chapter 2. This chapter focuses on the computer science method which presents demands of the system supporting the model. This system implements functions which are described by the model and receives the input information from users.

After computation following the rules of the model, the system will record the final result into the files and display it on the interface. Chart 3-1 shows the use-case diagram of the system.

Chart 3-1 Use-case diagram of the system For initializing the grassland, several patch (vegetation) types are used to determine the initial traits of cells. Users firstly decide site distribution and the patch type of these sites. Then users load files which contain all the parameters needed to initialize traits of patches and environment variables. Next, they determine sequences of events (event types and functions are described in "3.2.2

Events description"). When everything is ready, users run simulations and get

User

Set site strategies

Load parameter files

Set events sequences

Run simulation

Dispatch events

Analysis

Output data <<include>> <<include>> <<include>> results. During the time that the software is running, actions are done in three steps. First, the system dispatches events which are determined by users. Second, when certain types of event are executed, the data corresponding to this type event is analyzed by the system and updates the data pool. Finally, when data is successfully updated, system outputs data into output files and shows data on the interface.

The functional requirements

Vegetation phase

Main methods of this phase are already described in Chapter 2 and the task of software is to implement these methods to program and use them to compute the biomass of the pasture. So the requirements of the vegetation phase is to implement the model which is described in Chapter 2 and handle the input and the output of the system.

All the input variables can be measured by field measurements or practical experiment. For every compartment, the amount of biomass compartment can be computed as a function of time. Table 3-1 shows the input and the output of the system in biological terms. This table illustrates all the possible inputs, the intermediate results and all the outputs needed but not the exact relationship between the inputs and the outputs.

Event description

To simulate real situations of the grassland, some actions of agricultural management should be considered. In this system, these actions of agriculture are determined as events. So the process of simulation is creating events, dispatching events and executing events. Events involved into this system are as following.

1. Cut: "Cut" means cut all the plants on the grassland and considered as a harvest action. There are some constraints of cut in the system.

(1) Cut date is defined at start in the interface.

(2) Biomass is considered to be cut X m above ground level in all cells on that date. The default value is 0.05 m in line with local management practices.

(3) Residual biomass in each structural compartment is calculated using vegetation bulk densities (BD). For example, for compartment GV: 2. Fertilization: As suggested by its name, fertilization means the application of inorganic nitrogen-based fertilizer to the grassland. The effect of fertilization is not immediate influence on the grassland but a constant effect. The rules of fertilization are as following.

(1) Fertilization date is defined at start.

(2) Inorganic fertilizer is considered to be applied to all cells on one date.

(3) Fertilizer is assumed to increase NI after 7 days where water is non-limiting i.e. W > threshold value (to be defined in parameter file). (4) Fertilizer is assumed to be sufficient to shift NI status of cell from low (0.55) to medium (0.75), from medium to high (0.85) and from high to non-limiting (1).

(5) In the absence of fertilizer addition, NI is assumed to stay constant over course of 1 year 3. Grazing: Grazing refers to the presence of domestic herbivores on the grassland, which graze the grass and put excreta (named as "Dung" in the system) on the grassland. The grazing event is composed of 2 parts, defoliation and dung.

(1) Defoliation: Animals will graze swards and movements of animals will cause defoliant of swards. The rules of defoliation are described as following.

A. Start date is defined for grazing (GRAZ = 1) and the same as finishing date.

B. Biomass is considered to be removed daily for a proportion of cells (proportion to be defined in a parameter file, dependent on animal stocking rate) C. For each grazed cell, biomass is considered to be removed to 0.05m above ground level. . Residual biomass is calculated as above and CUT function is modified (ingested biomass can be calculated and stored as 'Cut'). e. Defoliation will not occur for cells with dung or for cells immediately next to dung (size of buffer zone to be defined in parameter file, cells need to be flagged) (2) Dung: Dung refers to solid animal returns discharged on the grassland during the presence of animals. These wastes fertilize swards as fertilization, but to a lesser extent because they provide an organic rather than inorganic source of nitrogen. There are some disciplines to constrain actions of Dung as following.

F. Assume shift NI status of cells influenced by dung after 7 days

where water is non-limiting i.e. W < threshold value (to be defined in parameter file).

G. Dung is assumed to shift NI status to 1/3 that of fertilizer increases (i.e. +7 rather than +21) for cells under dung and in buffer zone.

Additional requirements

1) Handling the numerous data of the pasture effectively.

2) Collecting the information needed to predict the biomass production and the structure of the pasture.

3) Illustrating the result of predictions and accumulations of biomass of the pasture over the year/growing season.

4) Simplifying the input data of the model.

5) Output data format can be produced as NetCDF (Network Common Data

Form) which is a kind of file format for science computation and analysis and CSV (Comma Separated Values) which is another file format to show results in a simple way.

Brief summary

This chapter describes the general system requirements, functional requirements and additional requirements. It provides its basic structure and describes its features. It ensures all the functions needed to implement of this system and the demands of the graphic user interface which maintains and runs the agriculture analysis model.

Chapter 4 System Design

The aim of this chapter is to present the design of the system according to the requirement described by chapter 3. System logical structure design is given first to illustrate whole system. Then the structure of logic module, GUI module and IO part are described. XML file is used to load user input data, site setting data, paths of input parameter files and format of output files (CSV, NetCDF or the both). Site strategy setting helps users to determine the structure of pasture and the distribution of patches.

System logical structure design

Parameter file paths can be inputted into the XML configuration data file or given by users' manipulation. Event sequences are the same as parameter files. They can be fulfilled by the XML configuration file or via GUI. When a simulation is finished, output data is showed in the final result table and there is a special screen which displays the situation of each cell. Logic module executes events according to the event sequence. When executing each event, the computation of biomass is done according to the type of events.

IO part specific design

IO part is a method pool which provides input and output methods for GUI module and Logic module. Input tasks include inputting information files which files' type is CSV and inputting XML configuration files. Output tasks include outputting XML configuration files, outputting result data in CSV file format and outputting result data in NetCDF file format.

Input specific design

There are 5 kinds of information files which provide different and necessary data to the system. All these files are in CSV format and are used as the initial input of the system to initialize variables of the pasture. 1) Constant file: Contain constant variables of soil and radiation. The specific description of each variable is illustrated in table 4-1.

GUI module specific design

Graphical User Interface module is the only module which is in charge of communicating with users and showing them results. Following user demands, the aim of the GUI design is focused on providing a convenient control of inputting and showing the result in a graphic way. So to be user friendly and as simple as possible, the interface is designed as a common Windows program. Each function is arranged in different tab, ordered like this: To clearly classify functions, the method of interface arrangement is as following.

1) Menus: it contains main functions concerning the manipulation of XML files and selecting output file types.

Menu File: Save actual configuration to a XML file already created or not; load a XML file in order to parameterize a simulation Menu Run: Run loaded simulation or select output file format (CSV, NetCDF or both).

2) General Tab: Allow to specify the start day and the duration of simulation. the interface in the screen is in this class as well. It submits the location of the interface to the graphic painting class in order to correct the start painting point for each graphic panel.

3) Set patch

3) EventPanel class: This class generates the interface of event management.

It consists of a list which represents the event sequences. Users are able to create a new event by choosing the event type and fill the information concerning this event. Clicking on some event on the event list, users are able to modify that event or delete it. For modification, the detailed information of that event is shown in the interface. The variables of each kind of event are described as following.

(1) Cut event: Cut start time and height of grasses after cutting.

(2) Fertilization event: Fertilization start time

(3) Grazing event: Graze start time, graze end time and stocking rate. The stocking rate describe the number of animals that are present in the plot.

Stocking rate means that how many animals are distributed in some scale of grassland. Its unit is lu/ha which lu (Livestock Unit) stands for a constant rate depending on the type of animals. For example, a dry medium cow means 0.8 lu. If there are 10 of these cows in a grassland of 10 hectares, the stocking rate is 0.8*10/10 = 0.8 lu/ha. In the system, 1 hectare means that there are 100,000 cells.

Logic module specific design

The logic module deals with event dispatching and biomass computing by using vegetation growth model. Input of this module comes from GUI and IO method.

Output is displayed via the GUI and stored files (CSV and/or NetCDF format).

Relationships between the GUI module and the logic module are illustrated by chart 4-3. EventDispatcher is in charge of managing event sequences and Parcelle receives data from input files and computes the biomass according to the present event type.

They are all encompassed by GUI class, receiving input data from GUI and transferring results to GUI for displaying or storing output data to files.

Event dispatcher specific design

Based on user demands, there are 5 kinds of events which should be considered in this part.

1) Vegetation event: This event has low priority so it is executed after all other events occur. This event updates the vegetation (biomass, age of compartments).

2) Cut event: Only occur at the time of "Cut start day". At this time, grasses in the plot are cut at the height given in the parameter.

3) Fertilization: This event only occurs at the time of "Fertilization start day".

The effect of fertilization influences NI value for a long period.

GUI EventDispatcher Parcelle

4) Grazing: This event starts at the "Grazing start day" and finishes at the "Grazing end day". The distribution of grazing is according to the priority of cells. According to the demands of grazing, the rules of priority are given as following.

(1) Eliminate ungraspable cells.

In order to allow defoliation, cells must have a vegetation height taller than 0.05 centimeter (the height is calculated using BD as with "Cut" event) and biomass of GV compartment must be greater or equals to 50% of the total cell biomass. Cells must not have dung or be flagged as the dung buffer zone. Here are the cases where there should be no The priority is classified into 4 levels. To calculate the priority 1-4 for cells which meet the defoliation criteria, we take into account: patch type, nutritional index and proportion of vegetative green biomass (GV). Each factor has a score. Table 4-5 shows the rules of setting scores. This array list binds EventHandler object to generate the other type of objects. EventDispatcher class gets names of events and implements adding method, deleting method and modifying method for all the events.

This structure of class diagram can be considered as a kind of event-driven programming. The flow of system is determined by events and all the actions and analysis of the system is based on events type. All the actions are encapsulated into events and system just deals with their execution. It simplifies the structure of the system and enhances its stability. Superior hierarchy applications do not need to be in charge of the details of methods of inferior hierarchy program but just dispatch event sequences and execute events.

Vegetation specific design

The vegetation part is in charge of analyzing input data, generating intermediate

Key techniques

CSV file format

The comma-separated values (CSV) pseudo-file format is a set of file formats used to store tabular data in which numbers and text are stored in plain-text form that can be easily written and read in a text editor. It is a delimited data format that has fields/columns separated by the comma character and records/rows terminated by newlines. Fields that contains a special character (comma, newline, or double quote) must be enclosed in double quotes. If a line contains a single entry which is the empty string, it may be enclosed in double quotes. If a field's value contains a double quote character it is escaped by placing another double quote character next to it. The CSV file format does not require a specific character encoding, byte order, or line terminator format.

In this system, CSV file format is used in the input and output file. The library "Open CSV" is used to manipulate CSV file format. It provides a simply and efficient way to check data values and helps ecologist to analyze the situation of the pasture.

NetCDF file format

NetCDF (network Common Data Form) is a set of interfaces for array-oriented data access and a freely-distributed collection of data access libraries for C, Fortran, C++, Java, and other languages. The NetCDF libraries support a machine-independent format for representing scientific data. Together, the interfaces, libraries, and format support the creation, access, and sharing of scientific data. NetCDF has plenty of properties that can be used in the field of scientific computation and analysis. 1) A NetCDF file includes information about the data it contains.

2) A NetCDF file can be accessed by computers with different ways of storing integers, characters, and floating-point numbers.

3) A small subset of a large dataset may be accessed efficiently. 4) Data may be appended to a properly structured NetCDF file without copying the dataset or redefining its structure. 5) One writer and multiple readers may simultaneously access the same NetCDF file. 6) Access to all earlier forms of NetCDF data will be supported by current and future versions of the software.

In the system, NetCDF file format is used in the output file. The library from the group of NetCDF is used to manipulate NetCDF file format. NetCDF format provides a professional science way to compose data. Outputting NetCDF is capable to manage the output data more orderliness and facile to analyze and predict the future trend.

XML file configuration

Extensible Markup Language (XML) is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards. Goals of XML emphasize simplicity, generality, and usability over the Internet. It is a textual data format with strong support via Unicode for the languages of the world. XML documents consist entirely of characters from the Unicode repertoire. Except for a small number of specifically excluded control characters, any character defined by Unicode may appear within the content of an XML document. The selection of characters that may appear within markup is somewhat more limited but still large.

XML includes facilities for identifying the encoding of the Unicode characters that make up the document, and for expressing characters that, for one reason or another, cannot be used directly.

In this system, XML is used to store configuration data of one simulation. The configuration data includes input of users, site setting data, paths of input parameter files and format of output files.

Doxygen and Graphviz

Doxygen is a documentation system for C++, C, Java, Objective-C, Python, IDL (Corba and Microsoft flavors), VHDL, PHP, C#, and to some extent D. It can generate an on-line documentation browser (in HTML) and/or an off-line reference manual from a set of documented source files. There is also support for generating output in RTF (MS-Word), PostScript, hyperlinked PDF, compressed HTML, and UNIX man pages. The documentation is extracted directly from the sources, which makes it much easier to keep the documentation consistent with the source code. Doxygen can be configured to extract the code structure from undocumented source files. This is very useful to quickly find your way in large source distributions. You can also visualize the relations between the various elements by means of include dependency graphs, inheritance diagrams, and collaboration diagrams, which are all generated automatically.

Graphviz is open source graph visualization software. Graph visualization is a way of representing structural information as diagrams of abstract graphs and networks. It has important applications in networking, bioinformatics, software engineering, database and web design, machine learning, and in visual interfaces for other technical domains. The Graphviz layout programs take descriptions of graphs in a simple text language, and make diagrams in useful formats, such as images and SVG for web pages, PDF or Postscript for inclusion in other documents; or display in an interactive graph browser. Graphviz also supports GXL, an XML dialect.

Graphviz has many useful features for concrete diagrams, such as options for colors, fonts, tabular node layouts, line styles, hyperlinks, Rolland custom shapes.

In this system, all the codes should be documented following JAVA documentation rules. Graphviz is integrated into Doxygen to generate not only documents but also charts to illustrate the structure of codes.

Brief summary

This chapter describes the system logic structure design, IO part specific design, GUI module specific design, Logic module specific design and related technology.

In the system structure design part, the relationship of each module is illustrated and For writing the NetCDF file, first of all, some dimensions should be created because of the structure of NetCDF file. Then add specific attributes to dimensions as well as the recording data pool. When these configurations are finished, the structure of NetCDF file is established. Then add values to attributes of dimensions. Before writing data, an original data should be provided to initialize the data pool. At last output data from the NetCDF format array to the files.

2) Outputting final data: Because final data is gotten at the end of the simulation, the writing operation just runs once to finish outputting data.

For CSV file, it outputs the data of each cell as one line of CSV file. So the final amount of lines in the CSV file equals to the number of cells in line multiplying the number of cells in column. For NetCDF file, it records the data in an array then output the content of this array to the file.

The third part of IO is the XML configuration method. This part deals with the loading the XML file and outputting XML file. There are many ways to load and output XML file. In this system, DOM library is used to load and output XML file. This library is contained in the javax.xml package and it is the simplest way to operate XML file. Chart 5-3 shows the flow chart of creating XML configuration file.

panel which contains all the tabs of the interface. The other panels are added to the MainPanel. The layout managers of all the panels are GridBagLayout.

GridBagLayout is one of the most flexible -and complex -layout managers the Java platform provides. A GridBagLayout places components in a grid of rows and columns, allowing specified components to span multiple rows or columns. Not all rows necessarily have the same height. Similarly, not all columns necessarily have the same width. Essentially, GridBagLayout places components in rectangles (cells) in a grid, and then uses the components' preferred sizes to determine how big the cells should be. The main operation of the interface is adding components to panels such as text fields, labels, combo boxes…etc. Besides these adding component operation, GUI runs simulation when "run" button is clicked and sets patch distribution strategy.

For running simulation, Chart 5-4 shows run simulation flow chart of GUI module.

Chart 5-4 GUI module run simulation method flow chart

To run simulation, first of all, necessary variables are needed to be initialized.

Then there are some setting operations to set pasture statues to ready for the simulation operation. After that, events are executed recursively and the data is computed. Finally, the final data is outputted into the file format which is selected before running simulation. There are the major codes for running simulation. For setting the patch distribution strategy, the main points are selecting the method of strategy, operating that strategy and painting cells on the interface. Chart 5-5 shows the flow chart of set patch distribution strategy method in the GUI module. It takes aggregate method as an example. In the 4 compartment methods, the specific variables and constrains of computing the biomass for itself are created and initialized. For each compartment, AGE should be computed by its own constrains. For compartment_GV which stands for green vegetative, GRO and SEN of green vegetative are considered and computed.

For compartment_GR which stands for green reproductive, GRO and ABS of green reproductive are considered and computed. For compartment_DV which stands for dead vegetative, GRO and SEN of dead vegetative are considered and computed.

For compartment_DR which stands for dead reproductive, GRO and ABS of dead reproductive are considered and computed.

To accumulate the environment data, "Parcelle" creates an array for storing the environment information during the period of simulation. Because the number of environment data equals 365, the number of day in one year. Storing all the environment data wastes the memory space and no efficient.

To initialize the unique information of each cell, patch information is stored in the patch array which is created by "Parcelle" class and used by "Cellule" class.

This array contains 4 patch types and is never changed during the simulation.

Because there are enormous amounts of data, for easy-use and expansibility for the future, an enumeration inner class is created in "Facies" (patch) class to get the name of each variable of the patch type. The code of this enumeration class is as following.

public enum IndexVarFacies{ Facies("Facies"),ST1("ST1"),ST2("ST2"),Incell("INcell"),Wcell("Wcell"),Hce ll("Hcell"),WHC("WHC"),minSEA("minSEA"),maxSEA("maxSEA"),W_VV( The event information is modified in the event list.

Because this system is an analyzed system, it is needed to test whether it could output the right result. For testing the correctness of input and output, test cases should be established. Due to the enormous variables and the page limitation of this thesis, one group of experiment data is shown as following. Table 5-2 shows the values of input environment variables. Table 5- Event occurrence: Fertilization occurs in 4 th day. Grazing occurs from 5 th day to 10 th day.

Scale of pasture: 300 X 300

Conclusion

This thesis implements a system to analyze the spatial structure and biomass of a pasture. This system provides a model to do the analysis and a Graphical User Interface which is interfaced with the model. The result of pasture structure and biomass dynamic analyzing system is as following.

1) This system implements the pasture analyzing model which utilizes the program to investigate the ecological knowledge by transferring the biology method to computer science language.

2) The model deals with numerous variables and constraints in an efficient way and simulates the conditions of pastures not only the measurable traits but also the physical structure in a logical way.

3) A GUI which is programmed in JAVA is established in this system. This GUI provides an easy tool for ecologist to directly control species traits, to manage events occurred during the simulation and to get the analyzed result in multiple ways.

4)

This system provides the output file in two kinds of format for different objectives. CSV format is used frequently and easily for statistics by ecologist. NetCDF format is specialized in the domain of science analysis and is able to handle numerous amounts of data in a structured way.

There are also some defects of this system. In the original imagination, the analyzing model would be integrated into CAPSIS (Computer-Aided Projection of Strategies In Silviculture) platform to gain a better result display (3D distribution graph chart) and a better scalability. But the structure of CAPSIS platform is quite complex and it is difficult to adapt it to new needs in order to use the new model in a short time. From the result of pressure testing, the limitation and the memory allocation of this system is not ideal enough. It is needed to think further to optimize the system. The future tasks of this system are optimizing the memory allocation, increasing the computation efficiency and managing to integrate the model into CAPSIS platform.

1

 1 Background and purpose of projectThis project comes from UREP (Grassland Ecosystem Research Unit) which belongs to INRA (National Institute of Agronomic Research) in Clermont-Ferrand, France. INRA is ranked number one agriculture institute in Europe and number two in the world. INRA carries out mission-oriented research for high-quality and healthy foods, competitive and sustainable agriculture and a preserved and valorized environment. The Grassland Ecosystem Research Unit (UREP, UR874) is an INRA research unit attached to the Forest, Grassland and Aquatic Ecology Department (EFPA).

  photosynthetically active radiation, mean daily temperature, precipitation and potential evapotranspiration) and site characteristics (nitrogen nutrition index, soil water-holding capacity). The system can be applied at a field scale.The basis of the model is a vegetation growth model describing the natural life cycle of the pasture without considering agricultural management (for example: cut, fertilization, etc…). Vegetation growth and development occurs each day and we update the situation of the pasture on a daily timescale. To simulate the life cycle of the grassland, growth, senescence and abscission are described as continuous flows.So the pasture can be classified into 4 compartments within the whole life cycle of the grassland. Chart 2-2 shows the biomass flow through these 4 compartments within the life cycle of the grassland.

Chart 2 - 3

 23 Variables repartition flow of compartment GV and GRFrom the flow above, there are some processes to compute the biomass.BM_GV and BM_GR are the variables as the final output but they are also used in the processes to compute other variables. In fact, the initial biomass can be evaluated by the practical experiments or from the previous computation. For example, the biomasses of day 1 are already computed as BM_GV = A and BM_GR = B. These two variables will take part into the process of computing the biomasses of day 2. Like this kind of process, the values of biomasses are reused and updated time by time. AGE_GV and AGE_GR are in the same situation. Delta Age GV and Delta Age GR are the processes which reuse the previous values of AGE_GV and AGE_GR and update the values of AGE_GV and AGE_GR.

( 3 ) 10 ( 7 )

 3107 ) AN = ENV*PGRO*SEA Then we need to compute ENV, PGRO and SEA. (2) PGRO = PAR*RUEmax*(1-exp(-k*LAI))*10); F Temperature = MAX(0,MIN(1,(Temperature-TB1)/(10-TB1))); (4) F PAR = MIN(1,1-0.0445 * (PAR-5)); (5) W = WR/WHC; To compute W, Chart 2-4 shows the variables needed and the diversion of these variables. Chart 2-4 Flow computing W (6) LAI = SLA*Percent_LAM*B_VG/AET = MIN(PET, PET*LAI/3) (8) J1 = PLUVIO-AET W is the variable showing the water stress to compute the ENV. When W is computed by the flow above, F_W should be computed by contrasting the value of PET. For easily understanding, the process of contrasting is showed in the way of pseudo code. computing the other variables. (10) F IN = 0.25+(0.75*(IN-0.35)) / 0.65 (11) ENV = F_PAR*F_W*F_IN*F_Temperature To compute SEA, the pseudo codes are as following.

( 2 )( 1 ) 6 )

 216 new growth GV = An*(1-ALLOC) 4)To compute BM_GR, the equations are as below. BM_GR + = new growth GR (2) new growth GR = (1-gamma)*sen_gv To compute sen_gv, the pseudo codes are as following. by following equations. (5) AGE_GV + = Delta age GV (Delta age GV = ((BM_GV-sen_gv) /(BM_GV-sen_vs+(An*(1-ALLOC)))*(Age_GV+Temperature)-Age_G V) Additional variables are needed to compute the AGE and abscission of compartment GR.

5

 5 Delta_age_gr = (BM_GR-abscission_GR) /(BM_GR-abscission_GR+new_growth_gr)*(Age_GR+Temperatur e)-Age_GR Compartment DV and DR have a similar structure to compartment GV and GR but there are some differences in using different variables, equations and conditions. Chart 2-5 shows the relationship of the variables in the compartment DV and DR. Because of the similarity in the structure and equations, the formulas which explain the method to compute the variables in the compartment DV and DR are not declared in detail. Variables repartition flow of compartment DV and DR

6 ) 7 )

 67 Res biomass VV = X * 10 * BD VV. (4) BD values are fixed for each patch type (need to be included in initial parameter file). (5) Harvested biomass = Standing biomass -Res biomass (Total harvested biomass = Sum of harvested biomass for each compartment (GV, GR, DV, DR). (When cut happens, need to modify CUT from 1 to 0 to affect reproductive growth (REP function), modify biomass in each compartment and store values for harvested biomass.

  D.Cell selection for grazing is not random and there are some rules to set priorities of defoliation actions. a. Defoliation only occurs for cells with > minimum biomass in GV and with > minimum GV/GR ratio (values to be defined in parameter file). b. Defoliation will not occur for cells with > maximum biomass in DV and DR (values to be defined in parameter file). c. Defoliation occurs preferentially for particular patches. d. Defoliation occurs preferentially for cells with a high NI.

  A. Dung is assumed to occur daily for GRAZ = 1. B. Number of dung patches depends on stocking rate (10 per day per animal): define animal number at start. C. Size of dung and dung buffer zone is defined at start (default value = 3 * 3 cells for dung with 3 cells buffer strip). D. Spatial distribution of dung patches is negative binomial. E. Assume that dung patch stops growth of cells under dung during x weeks (default value = 12 weeks), reduces cell biomass to a minimum value (to define) and stops reproductive growth (use CUT function).

  This system consists of 2 functional modules: GUI (graphic user interface) module and Logic module. IO provides methods to load file or output final data to files. IO part cannot exist without functional modules and methods of IO part are called and used by those two functional modules. The system structure is illustrated by Chart 4-1.

Chart 4 - 1

 41 System logical structure GUI module implements an interface which accepts manipulations of users and shows results of simulations. The variables of GUI can be configured by XML file.

2

 2 Beside these information files, XML configuration file is used as recording the configuration data of one simulation. The structure of XML configuration file is as following. file</ParameterFile> <PatchFile>Path of patch file</PatchFile> <EnvironmentFile>Path of environment file</EnvironmentFile> <ConstantFile>Path of constant file</ConstantFile> <CelSiteFile>Path of cel-site file</CelSiteFile> Output specific design According to the demands, two types of outputting files are needed to store simulation result. The first kind of file contains the final biomass for each cell. The second kind one records the temporary biomass of the entire pasture. In the last, the day number, sum of biomass in the plot, the minimum and maximum biomass for a cell in a plot and standard deviation of biomass between all the cells of the plot are recorded at a daily time step to show the vegetation dynamic during the year.

4 ) 5 ) 2 )

 452 Tab: There are four methods to set patches to cells.Manual: Users decide on the dimension of the plot by inputting the number of cells in vertical and horizontal directions. An initial simulated plot is drawn on the interface with the dimension the users enter. Then users choose a patch type and use a mouse to draw a rectangle. The entire cell in the rectangle switches their patch to the chosen patch. Users repeat the operation until they decide to finish deploying patches, click on save button to store the result into "Cel-site" files.Random: Firstly, users decide the percentage of each patch type. The sum of these percentages has to be naturally 100. Then users click on the launch button to get the result from the interface. The patch type randomly deploys onto cells according to the percentage. Aggregate: A Poisson distribution is used in this method. Poisson distribution is a discrete probability distribution that expresses the probability of a given number of events occurring in a fixed interval of time and/or space if these events occur with a known average rate and independently of the time since the last event. The Poisson distribution can also be used for the number of events in other specified intervals such as distance, area or volume. If the expected number of occurrences in this interval is λ, then the probability that there are exactly k occurrences (k being a non-negative integer, k = 0, 1, 2, ...is the base of the natural logarithm (e = 2.71828...) B. k is the number of occurrences of an event -the probability of which is given by the function C. k! is the factorial of k D. λ is a positive real number, equal to the expected number of occurrences during the given interval. For instance, if the events occur on average 4 times per minute, and one is interested in the probability of an event occurring k times in a 10 minute interval, one would use a Poisson distribution as the model with λ = 10×4 = 40. The first step is the same as the random method but the aggregate method used a radius around the points which is generated by Poisson distribution as the input variable. The process of aggregate method is as following. A. Randomly generate one point following Poison distributed constraints. B. Set the cell patch according to the percentage of patches given before. C. Once the center point is chosen in the first step, a rectangle is created around it which a fixed radius and the same patch is deployed in all the cells which belong to this rectangele. Load from file: Load the patches setting strategy from the file "Cel-site" and expose it on the interface. Graphic output Tab: This tab shows details of biomass distribution of each compartment. Cells are showed as polygon and are colored depending on their biomass relative to the average biomass standard. Final result Tab: This tab contains a table which presents the summary of final result, including: sum, minimum, maximum and standard deviation of biomass for total compartment and each compartment respectively. Chart 4-2 illustrates the UML class diagram of GUI module. It describes all the classes, main attributes and major methods of GUI module. Chart 4-2 class diagram of GUI module 1) GUI class: Top class of GUI module. It instigates the MainPanel object and Logic module objects. It generates the main frame of the GUI and allows loading XML files which are used for initializing the input simulation. MainPanel class: This class creates the main panel which is contained by the main frame. It encompasses the other classes of GUI module except GUI class. The structure of tabs is initialized by MainPanel. The location of

4 ) 5 ) 6 ) 7 )

 4567 LayoutShowPanel class: This panel layout is a bar under the graphic panel which compute basic statistics like minimum and maximum value of the biomass for one compartment. GraphicPanel class: Final results of biomass for each cell are shown in this panel in a graphical way. Each cell is painted as a polygon and colored depending on its final biomass among the average biomass standard. SiteStrategyPanel class: Users can set the dimension of the plot and coupling each cell to a patch type via an interface. Users just choose which method is used and enter corresponding information in order to create the patch-setting strategy. This strategy will be shown in the interface. SiteGraphicPanel class: This class is contained by SiteStrategyPanel class. It implements a panel which displays patch deployment strategy according to the users input on the site strategy panel or from XML file.

Chart 4 - 3

 43 UML class diagram which illustrates relations between GUI and Logic EventDispatcher and Parcelle are main classes of Logic module.

2 )

 2 with dung (or flagged as dung buffer zone) B. Cell with (DR + GR) biomass greater than fifty percent of total cell biomass C. Cell where vegetation height equals or less to 0.05 centimeter. (Set the priority rules.

  is the public attribute for all the children classes and it is the only attribute to classify children classes. Event_Cut class: This class extends Event class and implement the method of "Cut" event. Method excuteCut aggregates a Parcelle object to analyze the biomass through the method in Parcelle. Event_Fertilization class: Extends Event class and implement the method of "Fertilization" event. Method excuteFertilization aggregates a Parcelle object to analyze the biomass through the method in Parcelle. Event_Grazing class: Extends Event class and implement the method of "Grazing" event. Method excuteLoadAnimal aggregates a Parcelle object to analyze the biomass through the method in Parcelle. Event_MiseAJour class: Extends from Event class and implement the method of "Vegetation" event. Method excuteMiseAJour aggregates a Parcelle object to analyze the biomass through the method in Parcelle. This event is executed every day during the period of simulation. Event_RecordPerDay class: Extends from Event class and implement the method of the event which records the temporary data for per day. Method excuteRecordPerDay aggregates a Parcelle object to analyze the biomass through the method in Parcell. This event is executed every day during the period of simulation. EventHandler class: Extends from events and able to generate an object for Event_Cut, Event_Fertilization, Event_Grazing, Event_MiseAJour and Event_RecordPerDay. For managing events, event dispatcher utilizes an array list to contain different event objects but because of the technical reason, there should be only one kind of object contained in the array list. The purpose of the EventHandler class is to ensure the uniqueness of classes in the arraylist. At the same time, it initializes the other event objects and provides methods necessary for the other events. It classifies different event objects by knowing event names. EventDispatcher class: This class composes EventHandler class. There is an array list which records event sequences implemented in this class.

  results and outputting the final results. This part is designed with a hierarchy structure. The foundation part is the pasture which stands for all the information of the grassland including: environment variables, constant variables, patches variables and patch distribution variables. The pasture consists of many cells. Each cell has 4 compartments and a patch type which is used as initializing the variables of the cell. There are 4 types of patches in the system and variables of each patch cannot be changed during the simulation. Chart 4-5 illustrates the class diagram of the vegetation part. Chart 4-5 Vegetation class diagram

7 )

 7 +Init_VS(): void +MiseAJour(): void +GetAGE(): double -foncAge(): int Because this project comes from a French laboratory, the class names use French words. The main functions of each class are described as following. 1) Parcelle class: Parcelle, which stands for pasture, is the superior class of vegetation part. It communicates with event part and GUI modules. Event part and GUI modules just aware methods of Parcelle class but not the other classes of the vegetation part. It keeps the encapsulation of the structure of vegetation part. It composes cellule class, environment class and facies class. MiseAJour method means updating the situation of pasture and computing vegetation growth of the pasture corresponding to the vegetation growth model for each day during the period of simulation. Cut method is used as computing the biomass after cut. Fertilization method is used to change the variables of NI after fertilization. Grazing method is executed during the period of grazing and changes the distribution of grazing based on the distribution of dung. Initvariables method initializes all the variables needed in the Parcelle class. EcritFile method outputs the result data to the final result files by CSV format or NetCDF format. 2) Environment class: This class includes all the variables of environment data. It just provides the getting and setting methods to obtain and modify the value of these data. These methods are called in the Parcelle class. It is used to enhance the encapsulation of the system. 3) Facies class: Facies is a French word standing for vegetation patch type. So this class is in charge of defining all the variables of patch types. It provides the retrieval and setting methods to obtain and modify the value of these variables. These methods are called in the Parcelle class. It is used to enhance the encapsulation of the system. 4) Cellule class: Cellule is also a French word standing for cell. This class is in charge of managing the biomass of one cell. It aggregates Compartment classes and Facies class. Constructor method of Cellule class defines 4 objects of these 4 compartment classes. Init_Cellule method initializes all the variables of cells and calls initialization methods of 4 compartment objects. Cut method computes the harvest biomass and the reserved biomass of one cell at the time of cut event finishing. Fertilization method changes the value of variable NI after fertilization event. Grazing method computes the situation of this cell during the period of grazing. The elements which should be considered include: If this cell is grazed by animal, the height of the grass in this cell turns to the default lowest value. If this cell belongs to the dung area of dung buffer area, it cannot be grazed during the period of grazing. Shift NI status of cells influenced by dung after 7 days where water is non-limiting. 5) Compartment class: It is the super class of these 4 specific compartment classes. This class only contains the common variables and methods of these 4 specific compartments as the biomass, the height of the grass and the harvest biomass. Cut method, fertilization method and grazing method are generated in Compartment class because these 3 actions have not strong connection with the type of compartment. 6) Compartment_VV class: This class contains the necessary variables for computing the biomass of compartment green vegetation. It extends from Compartment class and there are some private methods to compute the intermediate values during the period of vegetation growth. These private methods are just called by Compartment_VV class and invisible to the other class. It is used to enhance the encapsulation of the system and keeps the safety of data. Init_VV method is called by Cellule class in the phase of initialization of Cellule class. MiseAJour class is used to update the variables of compartment green vegetation during the period of simulation. Compartment_VS class: The variables for analyzing the biomass of compartment green reproductive are contained in this class. It extends from Compartment class and it is the same as Compartment_VV class that it contains the private method to compute the intermediate values for Compartment_VS class itself. Init_VS method is called by Cellule class in the phase of initialization of Cellule class. MiseAJour class is used to update the variables of compartment green reproduction during the period of simulation. 8) Compartment_RV class: This class contains the necessary variables for computing the biomass of compartment Dead vegetation. It extends from Compartment class and there are also some private methods to compute the intermediate values during the period of vegetation growth. These private methods are just called by Compartment_RV class and invisible to the other classes. Init_RV method is called by Cellule class in the phase of initialization of Cellule class. MiseAJour class is used to update the variables of compartment dead vegetation during the period of simulation. 9) Compartment_RS class: It includes all the variables for computing the biomass of compartment Dead reproduction. It extends from Compartment class and bespoke methods are used to compute the intermediate values during the period of vegetation growth. These bespoke methods are just called by Compartment_RS class and invisible to the other class. Init_RS method is called by Cellule class in the phase of initialization of Cellule class. MiseAJour class is used to update the variables of compartment dead reproduction during the period of simulation. Chart 4-6 illustrates calling sequence of one time of simulation. In fact, this sequence diagram simplifies the process of one simulation and it just lists the main methods during the period of simulation.

4. 5 . 5

 55 Vegetation growth model This model is described in chapter 2 and is used in the vegetation part of the logic module. It is the foundation theory of the vegetation part. All the methods about computing biomass are based on this model. The computation is occurred in the classes of 4 compartments, updating variables of "Cellule" objects and in the "Parcelle" object, the final biomass will be computed corresponding to values of Cellule array. The Cellule array stands for the spatial structure of the grassland described the in chapter 2. Every element in this array represents each cell of the grassland. The variables of each elements accord to all the traits of each cell. The structure of vegetation part of the logic module is corresponding to the description of the vegetation growth model.

Chart 5 - 5 Chart 5 - 7

 5557 Set patch distribution strategy flow chart Aggregate method is a kind of method to set patch distribution strategy. Chart 5-6 shows the flow chart of aggregate method which is used in the setting patch distribution strategy method. Event dispatcher flow chart Event dispatcher gets the start time of simulation and the duration of simulation from the input file. Then it loops the event sequence to execute based on the time of 2) Vegetation part Main class of vegetation part is "Parcelle". It provides methods for the event dispatcher to execute different events, to initialize input variables and to output the final data. It generates a 2-dimention array to save the information of cells. The data format of this 2-dimention array is "Cellule" object and initialized in the "Parcelle" class. Each element stands for a cell object which contains all the information of a cell and computes the biomass of 4 compartments and total. In the "Cellule" class, objects of 4 compartments are initialized and join the common computation operations including computing LAI, fIN, AET, WR, W, CUT, ALLOC, PGRO, ENV and AN. As well, in the "Cellule" class, updating vegetation, cut, fertilization and grazing methods are provided to compute the biomass based on the event type.

Chart 5 - 9

 59 Set patch tab interface by choosing manual method Chart 5-10 Set patch tab interface by choosing aggregate method 5) Graphic output tab: This tab shows the result of each cell in a graphic way by choosing the compartment type. Chart 5-13 shows the graphic output tab interface. Chart 5-13 Graphic output tab interface 6) Summary output tab: This tab shows the summary of result data. Chart 5-14 shows the graphic summary output tab interface. Chart 5-14 Summary output tab interfaceTable 5distribution in the file. The content of file is the same to the graph.

  3 shows the values of input patch variables. Chart 5-15 shows the distribution of patch type. Start time: 3 rd day. Duration: 20 days.

Table 2 -

 2

		1 Abbreviations explanation
	Abbreviations	Explanation
	ABS	abscission
	AET	actual evapotranspiration
	AGE	age expressed in units of thermal time
	BM	biomass
	DR	dead reproductive
	DV	dead vegetative
	ENV	environmental variables related to soil and climate
		characteristics
	GV	green vegetative
	GR	green reproductive
	K_VS	coefficient of vegetative senescence
	KI_VS	coefficient of vegetative abscission
	K_RS	coefficient of reproductive senescence
	KI_RS	coefficient of reproductive abscission
	LAI	leaf area index
	LLS	leaf lifespan
	NI	nutrition index
	OMD	organic matter digestibility
	PAR	photosynthetically active radiation
	PET	potential evapotranspiration
	Percent LAM	percentage of laminae in GV
	PLUVIO	Precipitation
	REP	reproductive function
	RUEmax	max radiation use efficiency
	SEN	senescence
	SEA	reserve storage and mobilization
	SLA	specific leaf area
	ST	sum of temperatures
	W	water stress
	WR	ratio of water reserves
	WHC	soil water-holding capacity

Table 3 -

 3 1 System input, intermediate result and output in the vegetation phase

	Input	Intermediate result	Output
	Gamma	AET	DV_BM
	Gamma prime	AGE	DR_BM
	IN	ALLOC	GV_BM
	K_VS	AN	GR_BM
	K_RS	CUT	Sum BM
	KI_VS	ENV	Mean_BM
	KI_RS	LAI	Standard deviation_BM
	LLS	PGRO
	PAR	SEA
	PET
	Percent LAM
	PLUVIO
	RUEmax
	ST

Table 4 -

 4 1 Variables of Constant file Environment file: Contain environment variables which are practical measured data in one year at a daily time step. The specific description of each variable is illustrated in table 4-2.

	Variables	Description	Unit
	S	Cell area	m -1
	RUEmax	Maximum radiation use	g MJ -1
		efficiency
	Sigma	Respiratory C loss during
		senescence (GR)
	Sigma prime	Respiratory C loss during
		senescence (DR)
	Hrv lim	Height of RV	m
	Int defol seuil	Defoliation threshold

Table 4

 4

		-2 Variables of Environment file
	Variables	Description	Unit
	Jour	Day	day
	Temperature	Average temperature of each	°C
		day
	PARi	Incident photosynthetically	MJ m -2
		active radiation
	PP	Precipitations
	PET	Potential evapotranspiration	mm

3) Parameter file: Contain parameters which are the information of scales of pasture and overall patch type. The specific description of each variable is illustrated in table 4-3.

Table 4 -

 4 3 Variables of Parameter file

	Variables	Description	Unit
	Nombre de lignes	Number of lines
	Nombre de colonnes	Number of columns
	Nombre de facies	Number of patches

4) Cel-site file: This structure of this file depends on the dimension of the plot and the distribution of patches. Each "table cell" of the table in this file records the patch type which corresponds to the plot cell of the same index in plot (i.e. if the cell line x column y of the file contains the number z, then it means that the cell (x, y) in the plot belongs to patch z). This file can be considered as a digital representation of the plot. 5) Patch file: Contain all the variables which describe traits of patches. The specific description of each variable is illustrated in table

4-4.

Table 4 -

 4 4 Variables of patch file

	Variables	Description	Unit
	ST1	Onset of reproductive growth	Degree/day
	ST2	End of reproductive growth	Degree/day
	INcell	Nutritional index of cell	-NNI
	Wcell	Cell biomass	kg ha-1
	Hcell	Height of cell	m
	WHC	Soil water-holding capacity	mm
	minSEA	Growth increase in winter
	maxSEA	Growth increase in summer
	W_VV	Biomass of GV	kg ha-1
	alphaPAR	Light extinction coefficient
	T0	Temperature threshold: photosynthesis	°C
		activation
	T1	Temp threshold: stable growth	°C
	T2	Temp threshold: growth decline	°C
	B_IN	Impact of IN on LUE at IN=0
	SLA	Specific leaf area	m2 g-1
	LLS	Leaf lifespan	Degree/day
	Rho_VV	Volume GV	g m-3
	Gam_min	% leaf lamina (min theshold)
	Gam_max	% leaf lamina (max theshold)
	gammaVV	% leaf lamina GV
	W_RV	Biomass of DV	kg ha-1
	A_IN	Value of ALLOC at IN=0
	Rho_RV	Volume RV	g m-3
	W_VS	Biomass of VS	kg ha-1
	K_VS	Senescence coefficient VS	Degree/day
	Kl_VS	Abscission coefficient VS	Degree/day
	Rho_VS	Volume VS	g m-3
	W_RS	Biomass of RS	kg ha-1
	K_RS	Senescence coefficient RS	Degree/day
	Kl_RS	Abscission coefficient RS	Degree/day

Table 4 -

 4

			5 Rules of setting priority scores
	Patch type	Score	IN	Score	%GV	Score
	A	4	No	4	70	4
			limitation/High
	B	3	Medium	2	60-70	2
	C	2	Low	1	50-60	1
	D	1
		The total score for the cell is calculated by multiplying the score of the
		cell patch, IN and %GV. Example: A cell is patch type A, with medium
		IN and %GV of 65. The total score is 4 * 2 * 2 = 16
		Total score determines the grazing priority.
		Priority 1: Total score >30
		Priority 2: Total score >15

class. It contains an attribute and a method. The attribute "eventName"

Table 5 -

 5

	1 (continued)

Table 5 -

 5

			2 Environment variable values
	Day	Temperature	PARi	PP	PET
	3	6.5	2.2656	3	0.5
	4	5	2.328	2	0.9
	5	4.4	1.6752	16.4	1
	6	6.2	1.7328	0.4	0.3
	7	7	2.1744	0.2	0.7
	8	6.3	2.8176	0	0.2
	9	7.4	2.8224	0	0.3
	10	8.3	2.8608	0	0.7
	11	7.1	2.3376	0	0.5
	12	6.8	1.4688	0	0.8
	13	7.1	1.2096	6	1
	14	3.5	2.1216	0.6	0.5
	15	2.7	0.8112	1.4	0.4
	16	3.4	0.96	11.8	0.5
	17	2.9	2.8896	0	0.5
	18	3	1.3968	24.2	2
	19	1.8	1.8528	4.6	0.2
	20	-2.8	1.0752	0.2	0.4

This thesis stems from research at UREP (Grassland Ecosystem Research Unit) at INRA (National Institute of Agronomic Research) in France.

Chart 4-6 Sequence diagram of one vegetation simulation

First of all, users configure of the system by inputting the start time and the duration of the simulation, deciding the input file path, arranging the structure of the patch distribution, creating the events and configuring the events, determining the output file format… After configurations, users click the "Run" button to run the simulation and GUI executes "RunSimulation" method. This method will call the event dispatcher to execute the arranged event sequences. Event dispatcher will instantiate the Parcelle object and Parcelle object analyzes the biomass of each cell based on the event type. Cells are initialized by instantiating variables of the patch and compute the biomass of each compartment. Compartments compute the biomass and update their status then send their information back. At the end of simulation, the final data is displayed on the interface. described to keep the encapsulation of the system. IO part specific design narrates the main functions of IO part and the methods to fulfill the demands. GUI module specific design describes the class diagram of the GUI part. Each class is specialized and the design of main methods is discussed. Logic module specific design indicates 2 main parts of logic module and the relationship with each part.

The class diagram of these 2 parts are showed and discussed specifically.

Experimental condition

This system is implemented in JAVA by using Eclipse. So the experiment condition is focus on the Eclipse and its running condition. As well, the amount of data can be numerous, so the experiment condition is just able to deal with the common amount of data and expected least overflow in the memory. CPU: Intel Core Duo T6500 @2.1GHz RAM : 2.0GB OS : Microsoft Windows 7 GPU : NVIDIA Geforce GT 130M @256MB Hard disk: 250G IDE: Eclipse

Implementation of modules

IO part implementation

From the description of design phase, the IO part is divided into 3 parts: input, output and XML configuration file handler. Input part is used to accumulate and record the data from input file. The format of input files is CSV so the input part is in charge of reading the file format CSV. There are many ways to read CSV file. In this system, a library named "Open CSV" is used and it is a jar package containing methods to read and write CSV file. For illustration more clearly, one method which deals with the input of patch type file is chosen to illustrate the main process of handling input files. Chart 5-1 shows the flow chart of input file method of inputting patch type. Using DOM to operate XML, first of all, a file reading factory is created to establish the foundation of the XML hierarchy structure. Then create the root element for the superior part. After that, the hierarchy is built according to the structure of data. Recursively create the children elements when there is no data to be added. At last output data into files.

GUI module implementation

The GUI module use JAVA swing tools to create the interface of the system.

GUI class initializes the frame of the interface and MainPanel class creates the main Chart 5-6 Aggregate method flow chart

To record the patch of each cell, there initialize an array with the same numbers of line and column with the pasture. According to the percentage of patch, the priority of each patch is set. High percentage means high priority. To set the priority of the patch, the percentage of patch is sorted from the maximum value to minimum value stored into an array. Then to get the random patch, a number from 1 to 100 is randomly selected. After that, it compares with the percentage stored in the priority array. This random number, depending on which percentage of the patch accords to its demand, will determine which patch type is selected. After setting the priority of patch, the aggregate method is used to generate the patch type. The major code of aggregate method is as following.

//Generate the number of cells aggregated according to the patch percentage simulation. During each day's loop, "Mise A Jour" event (update vegetation) and "Record per Day" event are created and added into the event list. "Mise A Jour" event is created in the front of the event list and "Record per Day" event is added at the end of the event list. The codes are as following.

if "W_VV"),alpha_PAR("alpha_PAR"),T0("T0"),T1("T1"),T2("T2"),beta_T("bet a_T"),b_IN("b_IN"),SLA("SLA"),LLS("LLS"),rho_VV("rho_VV"),gam_min( "gam_min"),gam_max("gam_max"),gammaVV("gammaVV"),W_RV("W_RV "),a_IN("a_IN"),max_fIN("max_fIN"),rho_RV("rho_RV"),W_VS("W_VS"),K _VS("K_VS"),Kl_VS("Kl_VS"),rho_VS("rho_VS"),W_RS("W_RS"),K_RS(" K_RS"),Kl_RS("Kl_RS"),rho_RS("rho_RS"),init_AGE_VV("init_AGE_VV"), init_AGE_RV("init_AGE_RV"),init_AGE_VS("init_AGE_VS"),init_AGE_RS ("init_AGE_RS"),BD_VV("BD_VV"),BD_VS("BD_VS"),BD_RV("BD_RV") ,BD_RS("BD_RS"); shows the set patch tab by choosing aggregate method.

System Testing

System functional testing

System functional testing is in charge of testing if all the functions of the system run in a good condition without any bug and from the exact input getting the correct output. Table 5-1 shows criteria points of functional testing. The result data shows the same trend of the curve chart of Berkeley Madonna.

So the result is correct.

Pressure testing

Because this system is aiming to enormous amount of data, the pressure test is necessary to measure the stability, run time, throughput and memory allocation of the system. There are some test cases to examine the system for pressure testing. To conclude the pressure testing, the limitation of this system deals with 1000 X 1000 scales of pasture in 200 days without outputting NetCDF file. Outputting NetCDF file will increase the overhead of the system not only the running time but also the memory allocation.

Brief summary

This chapter describes the implementation of the system according to the design method showed in Chapter 4. It narrates the implementation of each module especially for the major part of the module. The interface of the system is shown and at last the test part is discussed. At present, the system accords the demands of all the testing points. Because of the limitation of the length of the article, just one test case is selected to show the process of testing the correctness of the final result.

At last, the pressure testing is discussed to test the tolerance, reaction speed and memory allocation of the system.

Acknowledgement

Thanks to my Chinese tutor WANG Zhongjie. Thank you for your help and your advices during the period of writing the thesis. Thank you for patience.

Thanks to my supervisor Raphaël MARTAIN. Thank you for your patient guide always and thank you for your consideration during the period of my internship.

Thanks to my French tutor KunMean HOU. Thank you for your consideration during my study period in France.

Thanks to HIT and ISIMA. Because of the cooperation between them, I have the opportunity to become an exchange student and have the chance to study in France.

Thanks to everybody who helps me.

Resume

From


Principle i i i X b a Y ε + + = .
Fitting this equation consist in estimating parameters a and b. Usually, we use the least squared method which consist in finding parameters a and b that minimized the sum of squared errors :

The model is written as following: The covariance between a and b is not null (meaning that parameters of a given equation are nonindependent) An unbiased estimation of this covariance is given by :

model
2 ) . ( 2 2 - + - = ∑ n X b a Y s i i
The standard deviation of a and b is given by :

                   - + = - = ∑ ∑ _ 2 _ 2 2 _ 2 2 ) ( 1 ) ( ) ( ) ( X X X n s a ect X X s b ect i i
And their confidence interval by : -----------------------------------------------------------------------------

   - ± - ± ) ( ). 2 / , 2 ( ) ( ). 2 / ,
∑ -2 _ ) ( Y Y i ∑ = n i i 1 2 ε

Linear regression:

Analysis of variance



Linear Models

Can we do a linear regression ?

 Y X  Linear Models Y X  Ln Y Ln X  Y'=Ln Y X'=Ln X ?
Can we do a linear regression ?



Linear Models

Can we do a linear regression ?

 Y X   Y'=Ln Y X'=Ln X ? Ln Y Ln X

Linear Models

Can we do a linear regression ?

 Y X   Y'=Ln Y X'= X ? Ln Y X Linear Models Y X   X'=X Y'=ln(Y/(1-Y)) ? ln(Y/(1-Y)) X
Can we do a linear regression ?



Linear Models

Why transforming the data ?

  Power equation : ) exp(ε b X a Y = ε + + = ) ln( ln ' X b a Y  Exponential model : ) exp( ε + = X b a Y ε + + = X b a Y ' ln
 It is always interesting to get a linear relationship because the solution is explicit  And sometimes it permits also to stabilize the variance But, this is not always possible and it may not correspond to the data set…. So try and see !

The following equations are linear or can be transformed to get a linear equation ?

  ε + = X b Y  ε X b Y =  ) exp(ε X b Y =  ε + = 2 X b Y  ) exp(ε b X Y =  ε + = b X Y  ε + + = 2 X c X b Y      Yes but two highly correlated variables  ) ln( ln ln ln ln ε ε + + = = X b X b Y  ) ln( ln ε + = b X Y

Non -Linear Models

Non-Linear regression: Principle



For linear models, the solution is explicit because the derivative of the model toward each parameter is independent from the paramameters of the equation.

For non-linear models, it is not the case: the derivatives depend on the parameters. The resolution of the system is too much difficult. It is then necessary to use alternative methods.

ε α β + = X e Y . . 2 1 . ) . ( ∑ = - = n i X i res i e Y SS β α 0 ) )( . ( . 1 . = - - ∑ = i i X b n i X b i e e a Y 0 ) . . )( . ( . 1 . = - - ∑ = i X b n i X b i X e a e a Y i i

Non -Linear Models

To fit a non-linear model, it is necessary to proceed by iterations.

When the least square method is used, at each step (i.e. each estimation of a new set of parameters) the sum of squared errors is calculated. If the procedure is efficient, this SSE decrease at each step. At the end of the process, if this decrease is negligible, then it is said that the model converged.

The most used iterative procedure is the Gauss-Newton one. But a lot of other procedures are available. When there are problems in fitting a model, it is recommended to test several methods (ex: fractionnal iteration, Marquardt)

Heteroscedasticity

How to deal with heteroscedasticity ?

 Y X ε ε avec . + + = X b a Y ∼ ) , 0 ( X N σ Transformation of the variables, X Y Y / ' = X X / 1 ' = X / ' ε ε =
to get the following linear model :

' ' ' ' avec ε ε + + = b X a Y ∼ ) , 0 ( σ N This is

Heteroscedasticity

How to deal with heteroscedasticity ?  First option: a rough and simple method that can be used if there are enough data

z i i X w 2 1 ∝  step 1 = split the variable X into k classes centered on X k
Step 2 = calculate the variance

2 k σ of Y within each k classes Step 3 = linear regression of k σ log to logX k
The slope of this regression is z which is often rounded to 1 or 2

Heteroscedasticity

How to deal with heteroscedasticity ?

 z i i X w 2 1 ∝ 
Step 1 = fitting the weighted model by fixing z to a given value (often 0 at the beginning)

Step 2 = calculate the Furnival index (FI)

The optimum value for z corresponds to the minimum of the Furnival Index

∑         + +         - - = i z i i z i i i i X X Y ML ) . log( . 2 log . . 2 1 . 2 2 2 σ π σ µ

Fit by maximum likelihood instead of least squared methods

Model for the mean

Model for the variance

Model Choice

For nested models: F test using the sum of squares errors (SSE) of the two models

ε + + = D b a Y Nested in ε + + + = H D c D b a Y 2 ε + + = H D b a Y 2 Nested in ε + + + = H D c D b a Y 2 ε + + = D b a Y Non nested in ε + + = H D c a Y 2 If



  Example of normally distributed errors, to be verified with statistical tests(ex D'agostino et al, 1990) and quantile plots How to assess the goodness of fit (for linear and non-linear models)

  equivalent to performing a weighted linear regression:HeteroscedasticityHow to deal with heteroscedasticity ?



  >F tab , then model 1 is more suitable than model 2 F tab (p1-p2,n-p1)For non nested models: AIC, BIC using the maximum likelihood estimates If the number of parameters is the same between model 1 and model 2, then use the sum of square errors (SSE), the lowest SSE is the best 

  the number of parameters is different between model 1 and model 2, then Check if these two models are nested or not:

Importance of the initial values given to the parameters Non -Linear Models

		
	Dependent variable is Y
	Source	Sum-of-Squares	df Mean-Square
	Regression	1.79138E+04	3 5971.269443
	Residual	6.711670	20	0.335583
	Total	1.79205E+04	23
	Mean corrected 3284.344348	22
	Raw R-square (1-Residual/Total)	=	0.999625
	Mean corrected R-square (1-Residual/Corrected) =	0.997956
	R(observed vs predicted) square	=	0.997965
							Wald Confidence Interval
	Parameter	Estimate	A.S.E.	Param/ASE	Lower < 95%> Upper
	B1	40.269815	0.584758	68.865757	39.050031	41.489600
	B2	0.029815	0.001760	16.941467	0.026144	0.033486
	B3	1.454754	0.078017	18.646595	1.292013	1.617495
	Asymptotic Correlation Matrix of Parameters
		B1	B2		B3
	B1	1.000000
	B2	-0.910171	1.000000
	B3	-0.756906	0.939698		1.000000

It is strongly recommended to test several sets of initial values

Goodness of fit

Age effect was significant for most of the compartments, we then get a set of equations that can be used whatever the stand age (within the range of the calibration data set 11 to 135 months) Finally ready to simulate !