## Implementation of an Algorithm for a Layered Soil Submodel with Application to the CENTURY Model

Thomas E. Hilinski
Department of Soil and Crop Sciences

February 2001

### Summary

A new algorithm for managing layered soil information allows for an unlimited number of vertically distributed soil components over an unlimited number of layers. Operations include erosion and deposition, layer homogenization and splitting, and relevant statistical functions applied over depth and layer ranges. A soil component is any soil information which has a vertical distribution by layer. The algorithm includes a manager for the list of components, and the ability to insert and extract soil information in either a vertical or horizontal dimension. A soil base object provides the essential operations. Specific derivation of a soil object from this base object, for any modeling scheme must provide the implementation details for the kind of soil information required for the particular model. An example of the implementation of a soil object for the CENTURY version 5 model provides for texture, bulk density, water storage properties and amount, and soil organic matter.

### Algorithm

The layered soil algorithm consists of vertically distributed soil components, a list manager for these components, and a base soil class for managing both the list and provide by-layer operations (see figure 1). Both the number of components and layers are not constrained by the algorithm. Soil information can be addressed in either a vertical dimension (a range of depths or layers) and a horizontal dimension (across components, that is, by layer). The application of this algorithm is to a one-dimensional, vertical view of a soil; no spatial information is managed.

 Figure 1. Class diagram for the layered soil algorithm.

A soil component is any soil information which has a vertical distribution by layer. This information can be categorized into properties and pools. Properties have values that are independent of the depth dimension, for example, bulk density and field capacity. Pools are values which are dependent upon the spatial dimension, such as the amount of water or organic C within a layer, or over a depth range. Basic statistics regarding the magnitude of a component are provided for each type of information. For properties, the weighted mean can be calculated over a layer or a depth range. For pools, the total amount can be calculated over a layer or a depth range. The soil component object does not store the depth information for the layers (this information is in the soil base object). Data for a soil component consists of the following:

• Information type (property or pool)
• Name (any text, e.g., horizon designation)
• Values (one value per soil layer)
• Valid Range: minimum and maximum acceptable values

Operations provided by the component object include data access, comparison, and queries:

• Assignment of values by layer.
• Boolean comparison with another component.
• Queries (pool or property; number of layers; minimum and maximum valid values).
• Set all layer's values to zero.
• Remove all values.
• Get the layer number, given a depth.
• If a pool, sum over the depth or layer range.
• If a property, calculate the weighted sum over a depth or layer range.

The component list manager handles the addition and removal of components. The manager contains zero or more soil components. There is only one component list manager per soil object. The manager is not accessed directly but through the soil base object. A derived object type, the soil layer, manages a list of components exactly one layer thick, and knows the layer thickness. There can be zero or more layers, however layers are independent of a soil object. Layers are intended for communication of information between soil objects (e.g., erosion and deposition), and for use in operations which view layer information. Operations provided by the component list manager are:

• Add and delete a component.
• Set all values of a component to zero.
• Delete the entire list of components.
• Provide the number of components in the list.

In addition to the operations provided by the component list manager, the soil layer object provides the following operations:

• Comparison of the layer properties with another layer.

The soil base object contains management operations by layer, contains the component list manager, and provides the essential algorithms for managing the soil profile. This object is a base object only; there should never an instance of this object. Rather, its use is intended as the base for custom soil objects, which inherit all the features of the soil base object, and add their specialized data and operations for the particular modeling scenario in which they are used. Depth and layer thickness information is maintained by this object, and are constant for all soil components (but not for layer objects, which are independent of the soil base object). Operations provided by the soil object include:

• Assign and retrieve layer thickness and depths, and layer designators (e.g., layer names or horizon designations).
• Add and delete soil components (via the component list manager).
• Access a component value (in a specified layer).
• Queries regarding various aspects of the soil.
• Add, copy, and create a new layer, and remove a surface layer.
• Fundamental soil management operations:
• Homogenize, or combine two layers;.
• Split a layer into two layers.
• Erode from and deposit onto the surface layer.
• Delete all soil information.
• Copy the soil base object.
• Manage and provide error information.

• Convert between organic matter weight percent and organic C weight percent.
• Convert from organic C g m-2 to organic matter weight percent.
• Convert from organic C g cm-2 to organic matter weight percent.
• Convert from organic C g cm-3 to organic matter weight percent.
• Calculate changes in a layer's bulk density and thickness based upon changes in organic C content. See below for details.

Changes in the bulk density and thickness of a soil layer are based upon changes in organic C content (g m-2). This calculation assumes a constant mean bulk density of soil organic matter equal to 0.224 g cm-3 ( Adams, 1973 ). The change in thickness (cm) is calculated as:

Dt = DC (g m-2) * OMCF / (10000 cm2 m-2 * OMBD)

where OMBD = 0.224 g cm-3 is the mean organic matter bulk density ( Adams, 1973 ), and OMCF = 1.9 is the conversion factor for organic C weight fraction to organic matter weight fraction (Broadbent, 1965; Allison, 1965). Change in the bulk density (g cm-3) is calculated as:

DBD = –DC * OMBD / (C0 + DC)

For example, given an initial organic C content of 2000 g m-2, an increase of 5 percent (100 g m-2) will increase the layer thickness by 0.085 cm, and decrease the bulk density by 0.011 g cm-3.

### Implementation

The layered soil algorithm is implemented in ANSI Standard C++, and uses extensively standard library containers and algorithms. Memory storage and speed is optimized through the use of smart, shared pointers in library containers in order to minimize copying of objects (an expensive operation) as the soil object is modified.

#### Features Planned but Not Implemented

Several features were planned for the layered soil algorithm but have not yet been implemented. These include the following features and operations:

• In the layer object, thinning and thickening of the layer.
• In the soil base object, thickening of layers upwards and downwards (e.g., during calcification and lessivage).
• Increasing and decreasing pool amounts over depth and layer ranges (e.g., plant root or lateral material input).
• Addition of a layer to the bottom of the profile (e.g., weathering of the parent material).
• Dimensional information storage and management (e.g. SI units).

#### Use in the CENTURY Model

The CENTURY model, version 5, requires information on soil texture fractions, bulk density, field capacity, wilting point, water content, and soil organic matter content over depth ranges. To implement this soil, a new soil object was derived from the soil base object. Several algorithms specific to Century's needs were added, modified from CENTURY version 4, including the following:

• Wilting point and field capacity estimates based upon soil texture and organic matter content.
• Bucket water flow algorithm.
• Calculation of plant-available water content and capacity.
• Organic C depth distribution.

#### Class and File Names

 Class Name Header File Name Description TSoilVDCompBase TSoilVDCompBase.h Base class for the soil profile classes which describe and manage a vertically-distributed component of soil. TSoilProperty TSoilProperty.h Describes and manages a vertically-distributed component of soil. Soil property is independent of the soil layer thickness. TSoilPool TSoilPool.h Describes and manages a vertically-distributed component of soil. Soil pool is a quantity of something in a layer. TSoilCompList SoilCompList.h List of vertically distributed soil components. Derived from std::vector. TSoilLayer TSoilLayer.h List of soil components representing one homogenous layer. Each component vector can contain only one element reporesenting one layer. Derived from TSoilCompList, which differs mainly in that each component vector can contain many layers. TSoilBase TSoilBase.h Base class to describe and manipulate soil physical characteristics. TSharedPtr TSharedPtr.h A smart pointer that can be shared, and therefore can be used in standard C++ containers. TCenturySoil TCenturySoil.h Soil object for the CENTURY model.

### Revision History

 Date Author/Editor Description Feb 2001 Thomas E. Hilinski First version. Nov 2001 Thomas E. Hilinski Added information on the conversion functions, and the calculation for change in bulk density and thickness due to changes in organic C content.