SORTIE Core C++ Documentation
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
clWeibullSnagMort Class Reference

Snag mortality using Weibull function, V 1.1. More...

#include <WeibullSnagMort.h>

Inheritance diagram for clWeibullSnagMort:
clMortalityBase clBehaviorBase clWorkerBase

Public Member Functions

 clWeibullSnagMort (clSimManager *p_oSimManager)
 Constructor. More...
 
 ~clWeibullSnagMort ()
 Destructor. More...
 
void DoShellSetup (xercesc::DOMDocument *p_oDoc)
 Performs specific setup for this behavior. More...
 
deadCode DoMort (clTree *p_oTree, const float &fDbh, const short int &iSpecies)
 Calculates whether a snag lives or dies. More...
 
- Public Member Functions inherited from clMortalityBase
 clMortalityBase (clSimManager *p_oSimManager)
 Constructor. More...
 
virtual ~clMortalityBase ()
 Destructor. More...
 
void Action ()
 Performs mortality calculations. More...
 
clMortalityOrgGetMortOrg ()
 Gets the mortality org object. More...
 
void RegisterTreeDataMembers ()
 Triggers the mortality data member registrations. More...
 
short int GetNewTreeInts ()
 Overridden from clBehaviorBase. More...
 
bool UsesThisMortality (short int iSp, short int iTp)
 Whether or not a species/type combo uses this mortality object. More...
 
virtual void PreMortCalcs (clTreePopulation *p_oPop)
 Performs calculations before any trees have been killed. 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 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...
 
clSimManagerGetSimManager ()
 
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

void ReadParameterFile (xercesc::DOMDocument *p_oDoc)
 Reads required data from the parameter file. More...
 
void FillDeathProbArray ()
 Declares and populates the mp_fProbabilityOfDeath array. More...
 
float CalculateDeathProbability (int iSizeClass, int iSpecies, int iAge)
 Calculates a probability of death for snags of a certain age. More...
 
void GetAgeCodes ()
 Gets the data member return codes for the "age" snag data member. More...
 
void ValidateTypes ()
 Makes sure that this behavior has only been applied to snags. More...
 
- Protected Member Functions inherited from clMortalityBase
void GetData (xercesc::DOMDocument *p_oDoc)
 Triggers all mortality setup. More...
 
void PopulateUsesThisMortality ()
 Declares and populates the mp_bUsesThisMortality array. 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

float *** mp_fProbabilityOfDeath
 Pre-calculated probabilities of death. More...
 
double ** mp_fAParameter
 Parameter "a" in Weibull function. More...
 
double ** mp_fBParameter
 Parameter "b" in Weibull function. More...
 
double ** mp_fSnagSizeClasses
 Upper limit of DBH in each snag size class. More...
 
int m_iNumYearsPerTimestep
 Number of years per timestep. More...
 
short int * mp_iAgeCodes
 Data member codes for "age" snag member for each behavior species. More...
 
short int * mp_iIndexes
 For accessing arrays. More...
 
short int m_iMaxPrecalcAge
 Max age, in timesteps, that the probability of death is pre-calculated. More...
 
short int m_iNumSizeClasses
 Number of snag size classes for which separate parameters can be defined. More...
 
- Protected Attributes inherited from clMortalityBase
short int m_iNumTotalSpecies
 Keep a copy for the constructor. More...
 
bool m_bHooked
 Whether or not this shell object is hooked to clMortalityOrg. More...
 
bool ** mp_bUsesThisMortality
 2D array, species by type, of whether or not this mortality shell applies to a given species/type combo. 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...
 
stcSpeciesTypeCombomp_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...
 
clSimManagermp_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...
 

Additional Inherited Members

- Static Protected Attributes inherited from clMortalityBase
static clMortalityOrgmp_oMortalityOrg
 clMortalityOrg object. More...
 

Detailed Description

Snag mortality using Weibull function, V 1.1.

Snags are standing dead trees, and as such "mortality" is something of a misnomer. However, since this behavior fits in with the other mortality behaviors, we will continue to use that naming scheme.

Snag death really means that a snag falls over. The probability that this will happen to any one snag is a function of its age as a snag. The percentage standing of a snag population is:

Percent standing = 100 * e(-(a*Timeb))

where Time is in years.

The rate at which snags fall over changes with snag size. This behavior allows the definition of three snag size classes. Each size class can take a different set of a and b values.

This behavior can only be applied to snags.

The namestring for this behavior is "weibsnagmortshell". The parameter file call string is "WeibullSnagMortality".

Copyright 2011 Charles D. Canham.

Author
Lora E. Murphy


Edit history:
--------------—
October 20, 2011 - Wiped the slate clean for SORTIE 7.0 (LEM)

Constructor & Destructor Documentation

◆ clWeibullSnagMort()

clWeibullSnagMort::clWeibullSnagMort ( clSimManager p_oSimManager)

Constructor.

Sets the namestring and nulls all pointers.

◆ ~clWeibullSnagMort()

clWeibullSnagMort::~clWeibullSnagMort ( )

Destructor.

Frees memory.

Member Function Documentation

◆ CalculateDeathProbability()

float clWeibullSnagMort::CalculateDeathProbability ( int  iSizeClass,
int  iSpecies,
int  iAge 
)
protected

Calculates a probability of death for snags of a certain age.

The probability is calculated as since the last timestep. If Ft is the value of the function above at timestep t, then the probability Pt of mortality between timesteps t-1 and t is:

Pt = (1-(1-Ft)/(1-Ft-1))

Any probability value greater than 1 - 1.0E-5 is returned as one, and less than 1.0E-05 is returned as 0. This function will handle conversions of ages from years to timesteps.

If the age is within the first timestep, then the probability is the value of the function at time t.

Parameters
iSizeClassSize class number, as 0, 1, or 2. THIS NUMBER IS NOT CHECKED FOR VALIDITY.
iSpeciesSpecies number. NOT species index, just plain old species.
iAgeAge in years.
Returns
Probability of death, between 0 and 1 inclusive.

◆ DoMort()

deadCode clWeibullSnagMort::DoMort ( clTree p_oTree,
const float &  fDbh,
const short int &  iSpecies 
)
virtual

Calculates whether a snag lives or dies.

If the snag age in timesteps is less than m_iMaxPrecalcAge, then a random number is compared to the appropriate value in mp_fProbabilityOfDeath. If it is greater than that age, then its probability of death is calculated directly from the Weibull function. In each case, if the random number is less than or equal to the probability of death, then the snag dies.

Parameters
fDbhDBH of tree being evaluated
p_oTreeTree being evaluated
iSpeciesSpecies of the tree being evaluated
Returns
natural if the tree is to "die", notdead if it "lives".

Implements clMortalityBase.

◆ DoShellSetup()

void clWeibullSnagMort::DoShellSetup ( xercesc::DOMDocument *  p_oDoc)
virtual

Performs specific setup for this behavior.

  1. Calls ReadParameterFile() in order to get parameter file data.
  2. Calls CalculateDeathProbabilities().
  3. Calls GetAgeCodes().
Parameters
p_oDocParsed DOM tree of parameter file.

Reimplemented from clMortalityBase.

◆ FillDeathProbArray()

void clWeibullSnagMort::FillDeathProbArray ( )
protected

Declares and populates the mp_fProbabilityOfDeath array.

For each timestep t, it calculates the probability of mortality between t and t-1 using CalculateDeathProbability().

◆ GetAgeCodes()

void clWeibullSnagMort::GetAgeCodes ( )
protected

Gets the data member return codes for the "age" snag data member.

Return codes are captured in the mp_iAgeCodes array.

◆ ReadParameterFile()

void clWeibullSnagMort::ReadParameterFile ( xercesc::DOMDocument *  p_oDoc)
protected

Reads required data from the parameter file.

Parameters
p_oDocParsed DOM tree of parameter file.
Exceptions
modelErrif:
  • any of the parameters are missing
  • the size classes overlap
  • any value for "a" is zero (this will cause a math error if true)
  • any value for "a" is negative, if "b" is not a whole number (this will cause a math error if true)

Because of the need for backward compatibility with version 1.0, this will accept the size class definitions as single values if they are written this way.

◆ ValidateTypes()

void clWeibullSnagMort::ValidateTypes ( )
protected

Makes sure that this behavior has only been applied to snags.

Exceptions
modelErrif any tree type besides snags has been applied to this behavior.

Member Data Documentation

◆ m_iMaxPrecalcAge

short int clWeibullSnagMort::m_iMaxPrecalcAge
protected

Max age, in timesteps, that the probability of death is pre-calculated.

◆ m_iNumSizeClasses

short int clWeibullSnagMort::m_iNumSizeClasses
protected

Number of snag size classes for which separate parameters can be defined.

◆ m_iNumYearsPerTimestep

int clWeibullSnagMort::m_iNumYearsPerTimestep
protected

Number of years per timestep.

◆ mp_fAParameter

double** clWeibullSnagMort::mp_fAParameter
protected

Parameter "a" in Weibull function.

Array size is m_iNumSizeClasses by number of behavior species.

◆ mp_fBParameter

double** clWeibullSnagMort::mp_fBParameter
protected

Parameter "b" in Weibull function.

Array size is m_iNumSizeClasses by number of behavior species.

◆ mp_fProbabilityOfDeath

float*** clWeibullSnagMort::mp_fProbabilityOfDeath
protected

Pre-calculated probabilities of death.

Array is m_iNumSizeClasses by number of behavior species by m_iMaxPrecalcAge.

◆ mp_fSnagSizeClasses

double** clWeibullSnagMort::mp_fSnagSizeClasses
protected

Upper limit of DBH in each snag size class.

This array is sized m_iNumSizeClasses by number of behavior species. The value in the third size class bucket for each species is ignored since it is always effectively infinity.

◆ mp_iAgeCodes

short int* clWeibullSnagMort::mp_iAgeCodes
protected

Data member codes for "age" snag member for each behavior species.

◆ mp_iIndexes

short int* clWeibullSnagMort::mp_iIndexes
protected

For accessing arrays.

One per species.


The documentation for this class was generated from the following file: