SORTIE Core C++ Documentation
|
Tree Volume Calculator Version 1.0. More...
#include <VolumeCalculator.h>
Public Member Functions | |
clVolumeCalculator (clSimManager *p_oSimManager) | |
Constructor. More... | |
~clVolumeCalculator () | |
Destructor. More... | |
void | Action () |
Makes volume calculations. More... | |
void | GetData (xercesc::DOMDocument *p_oDoc) |
Does setup for this behavior. More... | |
void | RegisterTreeDataMembers () |
Registers the "Volume" float data member. More... | |
Public Member Functions inherited from clBehaviorBase | |
virtual float | GetBehaviorVersion () |
Gets the behavior version number. More... | |
clBehaviorBase (clSimManager *p_oSimManager) | |
Constructor. More... | |
virtual | ~clBehaviorBase () |
Destructor. More... | |
virtual short int | ValidateVersionNumber (float fTestVersion) |
Makes sure that the version number of a file passed is between the minimum and current version numbers. More... | |
virtual void | SetSpeciesTypeCombos (short int iNumCombos, stcSpeciesTypeCombo *p_whatCombos) |
Sets the species/type combos for a behavior. More... | |
virtual void | SetNameData (std::string sNameString) |
Sets the string for the parameter file behavior. More... | |
virtual short int | GetNewTreeInts () |
Gets the number of new tree integer data members this behavior wants to register. More... | |
virtual short int | GetNewTreeFloats () |
Gets the number of new tree float data members this behavior wants to register. More... | |
virtual short int | GetNewTreeChars () |
Gets the number of new tree character data members this behavior wants to register. More... | |
virtual short int | GetNewTreeBools () |
Gets the number of new tree bool data members this behavior wants to register. More... | |
virtual short int | GetNumSpeciesTypeCombos () |
Gets the number of species/type combos to which this behavior applies. More... | |
virtual short int | GetNumBehaviorSpecies () |
Gets the number of unique tree species to which this behavior applies. More... | |
struct stcSpeciesTypeCombo | GetSpeciesTypeCombo (short int iIndex) |
Gets one of this behavior's type/species combos. More... | |
virtual short int | GetBehaviorSpecies (short int iIndex) |
Gets one of the behavior's species. More... | |
short int | GetBehaviorListNumber () |
Gets the behavior list number for this behavior, which differentiates between multiple copies of the behavior in the behavior list. More... | |
void | SetBehaviorListNumber (short int iNumber) |
Sets the behavior list number for this behavior, which differentiates between multiple copies of the behavior in the behavior list. More... | |
std::string | FormatSpeciesTypeQueryString () |
Formats the string for species/types query. More... | |
virtual DOMElement * | GetParentParametersElement (xercesc::DOMDocument *p_oDoc) |
This will get the correct set of parameters for this behavior based on the behavior list position number. More... | |
Public Member Functions inherited from clWorkerBase | |
clWorkerBase (clSimManager *p_oSimManager) | |
Constructor. More... | |
virtual | ~clWorkerBase () |
Destructor. More... | |
std::string | GetName () |
Gets the object's namestring. More... | |
clSimManager * | GetSimManager () |
void | DoObjectSetup (xercesc::DOMDocument *p_oDoc, fileType iFileType) |
Triggers the setup process. More... | |
virtual void | TimestepCleanup () |
Performs any necessary cleanup operations at the end of a timestep. More... | |
virtual void | EndOfRunCleanup () |
Performs any necessary cleanup operations at the end of a run. More... | |
Protected Member Functions | |
float | GetTreeVolume (const float &fTreeHeight, const float &fDBH, const int &iSpecies) |
Gets the volume of a tree trunk. More... | |
void | FormatQueryString () |
Formats the string in m_cQuery. More... | |
Protected Member Functions inherited from clWorkerBase | |
void | AssembleFileCode (int iFileType, int iFileVersion, char *cCode) |
Creates the proper identifying filecode for an XML file. More... | |
Protected Attributes | |
double * | mp_fTaperA |
a in the taper equation. More... | |
double * | mp_fTaperB |
b in the taper equation. More... | |
double * | mp_fTaperC |
c in the taper equation. More... | |
double * | mp_fTaperD |
d in the taper equation. More... | |
double * | mp_fTaperF |
f in the taper equation. More... | |
double * | mp_fTaperG |
g in the taper equation. More... | |
double * | mp_fTaperI |
i in the taper equation. More... | |
double * | mp_fTaperJ |
j in the taper equation. More... | |
double * | mp_fTaperK |
k in the taper equation. More... | |
double * | mp_fBarkA |
a in the math library's AddBarkToDBH() function. More... | |
double * | mp_fBarkB |
b in the math library's AddBarkToDBH() function. More... | |
double * | mp_fBarkC |
c in the math library's AddBarkToDBH() function. More... | |
short int * | mp_iIndexes |
For quick access to the other arrays. More... | |
char * | m_cQuery |
String to pass to clTreePopulation::Find() in order to get the trees for which to calculate volume. More... | |
double | m_fStumpHeight |
Stump height, in m. More... | |
double | m_fMinUsableDiam |
Minimum usable diameter, in cm. More... | |
double | m_fSegmentLength |
Length of tree trunk volume segments, in m. More... | |
short int ** | mp_iVolumeCodes |
Holds data member codes for "Volume" float data member. More... | |
Protected Attributes inherited from clBehaviorBase | |
short int | m_iNumSpeciesTypeCombos |
How many type/species combos a behavior will act on. More... | |
short int | m_iNumBehaviorSpecies |
How many distinct species are in the combo list - important for filling species-specific values from parameter file. More... | |
short int * | mp_iWhatSpecies |
List of distinct species - for filling species-specific values from parameter file. More... | |
stcSpeciesTypeCombo * | mp_whatSpeciesTypeCombos |
Array of species/type combos that the behavior will act on. More... | |
short int | m_iNewTreeInts |
The number of new tree integer data members this behavior wants to add. More... | |
short int | m_iNewTreeFloats |
The number of new tree float data members this behavior wants to add. More... | |
short int | m_iNewTreeChars |
The number of new tree character data members this behavior wants to add. More... | |
short int | m_iNewTreeBools |
The number of new tree boolean data members this behavior wants to add. More... | |
short int | m_iBehaviorListNumber |
The number of this behavior in the behavior list, to differentiate between possible multiple copies of this behavior. More... | |
float | m_fVersionNumber |
Version number - this will be rounded to 2 digits after the decimal place. More... | |
std::string | m_sXMLRoot |
XML root that encloses the parameters for this behavior. More... | |
float | m_fMinimumVersionNumber |
Minimum version number - this behavior will run parameter data for a file marked between this number and the current version number, inclusive. More... | |
Protected Attributes inherited from clWorkerBase | |
std::string | m_sNameString |
If a behavior has registered a command line command with the sim manager, this allows it to be called. More... | |
clSimManager * | mp_oSimManager |
Pointer to the simulation manager object. More... | |
int * | mp_iAllowedFileTypes |
List of the input file types this object can handle. More... | |
int | m_iNumAllowedTypes |
Number of input file types this object can handle. More... | |
Tree Volume Calculator Version 1.0.
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:
where:
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 "TreeVolumeCalculator".
This behavior may not be applied to seedlings.
clVolumeCalculator::clVolumeCalculator | ( | clSimManager * | p_oSimManager | ) |
Constructor.
p_oSimManager | clSimManager object. |
clVolumeCalculator::~clVolumeCalculator | ( | ) |
Destructor.
Deletes arrays.
|
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.
|
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.
|
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.
|
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. |
|
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.
|
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.
|
protected |
Minimum usable diameter, in cm.
Point at which to stop summing trunk volume.
|
protected |
Length of tree trunk volume segments, in m.
|
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.
|
protected |
a in the math library's AddBarkToDBH() function.
Array size is
|
protected |
b in the math library's AddBarkToDBH() function.
Array size is
|
protected |
c in the math library's AddBarkToDBH() function.
Array size is
|
protected |
a in the taper equation.
Array size is # behavior species.
|
protected |
b in the taper equation.
Array size is # behavior species.
|
protected |
c in the taper equation.
Array size is # behavior species.
|
protected |
d in the taper equation.
Array size is # behavior species.
|
protected |
f in the taper equation.
Array size is # behavior species.
|
protected |
g in the taper equation.
Array size is # behavior species.
|
protected |
i in the taper equation.
Array size is # behavior species.
|
protected |
j in the taper equation.
Array size is # behavior species.
|
protected |
k in the taper equation.
Array size is # behavior species.
|
protected |
For quick access to the other arrays.
Array size is # total species.
|
protected |
Holds data member codes for "Volume" float data member.
First array index is # behavior species, second is number types (3 - sapling, adult, snag)