#include <VolumeCalculator.h>
Public Member Functions | |
clVolumeCalculator (clSimManager *p_oSimManager) | |
Constructor. | |
~clVolumeCalculator () | |
Destructor. | |
void | Action () |
Makes volume calculations. | |
void | GetData (xercesc::DOMDocument *p_oDoc) |
Does setup for this behavior. | |
void | RegisterTreeDataMembers () |
Registers the "Volume" float data member. | |
Protected Member Functions | |
float | GetTreeVolume (const float &fTreeHeight, const float &fDBH, const int &iSpecies) |
Gets the volume of a tree trunk. | |
void | FormatQueryString () |
Formats the string in m_cQuery. | |
Protected Attributes | |
float * | mp_fTaperA |
a in the taper equation. | |
float * | mp_fTaperB |
b in the taper equation. | |
float * | mp_fTaperC |
c in the taper equation. | |
float * | mp_fTaperD |
d in the taper equation. | |
float * | mp_fTaperF |
f in the taper equation. | |
float * | mp_fTaperG |
g in the taper equation. | |
float * | mp_fTaperI |
i in the taper equation. | |
float * | mp_fTaperJ |
j in the taper equation. | |
float * | mp_fTaperK |
k in the taper equation. | |
float * | mp_fBarkA |
a in the math library's AddBarkToDBH() function. | |
float * | mp_fBarkB |
b in the math library's AddBarkToDBH() function. | |
float * | mp_fBarkC |
c in the math library's AddBarkToDBH() function. | |
short int * | mp_iIndexes |
For quick access to the other arrays. | |
char * | m_cQuery |
String to pass to clTreePopulation::Find() in order to get the trees for which to calculate volume. | |
float | m_fStumpHeight |
Stump height, in m. | |
float | m_fMinUsableDiam |
Minimum usable diameter, in cm. | |
float | m_fSegmentLength |
Length of tree trunk volume segments, in m. | |
short int ** | mp_iVolumeCodes |
Holds data member codes for "Volume" float data member. |
This class calculates tree volume. It can be set up to specifically calculate merchantable volume. The volume value is stored in an float tree data member that this behavior adds as a value in cubic meters.
Volume is calculated by dividing the tree trunk into segments. The volume of each segment is calculated as:
A is just the plain old area of a circle:
where d is the diameter of the trunk inside the bark at that point in the trunk.
The diameter of the trunk inside the bark at a particular height on the trunk comes from the taper equation (the "2002 model", Kozak (2004) Forest Chronicle 80: 507 - 515). (The equation below probably has different parameter names from the user documentation because that one uses too many subscripts.) The equation is:
where:
To find the total volume, the trunk needs to be defined with a starting point and an ending point. For total trunk volume, the starting point is the ground and the ending point is the top of the tree. However, if one is trying to calculate merchantable volume, then the points are different. Both of these points are defined by the user. The starting point is given by the user as a "stump height" in cm off the ground (set into mp_fStumpHeight). The ending point is the point at which the trunk has narrowed to a diameter too small to be useful, and is given by the user as the "minimum usable diameter" in cm (set into mp_fMinUsableDiam). If both the stump height and minimum usable diameter are set to zero, then the total trunk volume is calculated.
As was described above, the volume of the trunk is determined by summing up the volumes of individual trunk segments. The length of these segments is set by the user. Thus the user is able to find their tradeoff point between accuracy (shorter segments) and quick processing time (longer segments). The volume calculation starts at the starting point of the trunk defined in the "stump height" parameter. It finds the volume of the segment defined by the segment length value. Then it moves to the end of the segment, using it as the starting point for the next segment. The calculation works its way down the tree until either 1) a segment starting or ending diameter is less than the minimum usable diameter or 2) the end of the tree is reached. A segment whose starting or ending diameter is less than the minimum usable is not used at all in the volume total.
Note: this behavior is VERY prone to math errors. There are a lot of X^Y types of calculations, with neither X nor Y known until runtime. There are so many parameters that you can't really validate them ahead of time either. I can't think of anything that I can do about it. I can't even figure out a way to catch math errors. So if the user chooses badly, crashy crashy.
This behavior adds an float data member called "Volume" to trees that holds the final volume calculation as a value in square meters.
This class's namestring and parameter call string are both "tree volume calculator".
This behavior may not be applied to seedlings.
clVolumeCalculator::clVolumeCalculator | ( | clSimManager * | p_oSimManager | ) |
clVolumeCalculator::~clVolumeCalculator | ( | ) |
Destructor.
Deletes arrays.
void clVolumeCalculator::Action | ( | ) | [virtual] |
Makes volume calculations.
A query is sent to the tree population to get all trees to which this behavior is applied. For each, the volume is calculated by GetTreeVolume(). This value is placed in the "Volume" float tree data member.
Reimplemented from clBehaviorBase.
void clVolumeCalculator::GetData | ( | xercesc::DOMDocument * | p_oDoc | ) | [virtual] |
Does setup for this behavior.
Reads values from the parameter file and validates them. It then calls FormatQueryString() to make our query string. Last, it calls Action() so that the initial conditions volume will be added.
p_oDoc | DOM tree of parsed input file. |
modelErr | if:
|
Implements clWorkerBase.
void clVolumeCalculator::RegisterTreeDataMembers | ( | ) | [virtual] |
Registers the "Volume" float data member.
The return codes are captured in the mp_iVolumeCodes array.
modelErr | if this behavior is being applied to any tree type except saplings, adults, and snags. |
Reimplemented from clBehaviorBase.
float clVolumeCalculator::GetTreeVolume | ( | const float & | fTreeHeight, | |
const float & | fDBH, | |||
const int & | iSpecies | |||
) | [protected] |
Gets the volume of a tree trunk.
This function divides the trunk into segments and sums over the volumes of each segment. The segments begin at the height in mp_fStumpHeight and are of length mp_fSegmentLength. Summing stops upon reaching a segment whose end diameter is less than mp_fMinUsableDiam, or until the end of the tree is reached.
fTreeHeight | Total tree height, in meters | |
fDBH | SORTIE's DBH value, in cm | |
iSpecies | Tree's species. |
void clVolumeCalculator::FormatQueryString | ( | ) | [protected] |
Formats the string in m_cQuery.
This value will be used in Action() to pass to clTreePopulation::Find() in order to get the trees to act on.
float* clVolumeCalculator::mp_fTaperA [protected] |
a in the taper equation.
Array size is # behavior species.
float* clVolumeCalculator::mp_fTaperB [protected] |
b in the taper equation.
Array size is # behavior species.
float* clVolumeCalculator::mp_fTaperC [protected] |
c in the taper equation.
Array size is # behavior species.
float* clVolumeCalculator::mp_fTaperD [protected] |
d in the taper equation.
Array size is # behavior species.
float* clVolumeCalculator::mp_fTaperF [protected] |
f in the taper equation.
Array size is # behavior species.
float* clVolumeCalculator::mp_fTaperG [protected] |
g in the taper equation.
Array size is # behavior species.
float* clVolumeCalculator::mp_fTaperI [protected] |
i in the taper equation.
Array size is # behavior species.
float* clVolumeCalculator::mp_fTaperJ [protected] |
j in the taper equation.
Array size is # behavior species.
float* clVolumeCalculator::mp_fTaperK [protected] |
k in the taper equation.
Array size is # behavior species.
float* clVolumeCalculator::mp_fBarkA [protected] |
a in the math library's AddBarkToDBH() function.
Array size is # behavior species.
float* clVolumeCalculator::mp_fBarkB [protected] |
b in the math library's AddBarkToDBH() function.
Array size is # behavior species.
float* clVolumeCalculator::mp_fBarkC [protected] |
c in the math library's AddBarkToDBH() function.
Array size is # behavior species.
short int* clVolumeCalculator::mp_iIndexes [protected] |
For quick access to the other arrays.
Array size is # total species.
char* clVolumeCalculator::m_cQuery [protected] |
String to pass to clTreePopulation::Find() in order to get the trees for which to calculate volume.
This will instigate a species/type search for all the species and types to which this behavior applies.
float clVolumeCalculator::m_fStumpHeight [protected] |
Stump height, in m.
Point at which to start summing trunk volume. This is read in as in cm, and then converted to m.
float clVolumeCalculator::m_fMinUsableDiam [protected] |
Minimum usable diameter, in cm.
Point at which to stop summing trunk volume.
float clVolumeCalculator::m_fSegmentLength [protected] |
Length of tree trunk volume segments, in m.
short int** clVolumeCalculator::mp_iVolumeCodes [protected] |
Holds data member codes for "Volume" float data member.
First array index is # behavior species, second is number types (3 - sapling, adult, snag)