SORTIE Core C++ Documentation
|
Storms version 3.0. More...
#include <Storm.h>
Classes | |
struct | stcStorms |
Structure for holding scheduled storm events. More... | |
Public Member Functions | |
clStorm (clSimManager *p_oSimManager) | |
Constructor. More... | |
~clStorm () | |
Destructor. More... | |
void | GetData (xercesc::DOMDocument *p_oDoc) |
Does behavior setup. More... | |
void | Action () |
Performs the storm calculations. More... | |
float | GetStormProbability (int iReturnInterval) |
Gets timestep probability of the occurence of a storm at a return interval. More... | |
void | SetStormProbability (int iReturnInterval, float fValue) |
Sets timestep probability of the occurence of a storm at a return interval. 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 | RegisterTreeDataMembers () |
Registers tree data members. 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 Types | |
enum | susceptibility { mapped, uniform } |
Enum for describing the damage pattern. More... | |
enum | stochasticity { deterministic, stochastic } |
Enum for stochasticity. More... | |
enum | distribution_func { lognormal, normal } |
Enum for listing probability distribution functions. More... | |
Protected Member Functions | |
void | DoGridSetup () |
Does the grid setup fo the behavior. More... | |
void | CalculateStormProbabilities () |
Calculates the annual probability of a storm of each severity class. More... | |
void | ApplyDamage (float fMeanSeverity) |
Applies the damage for a storm of a given return interval. More... | |
void | ReadParFile (xercesc::DOMDocument *p_oDoc) |
Reads in parameters from the parameter file. More... | |
void | SetStochFuncPointer () |
Sets the function pointer for a stochastic damage pattern. More... | |
void | DoSeverityAverages () |
Calculates mean storm severity for each cell. More... | |
void | AdjustTimeSinceLastStormCounter (bool bStormThisTimestep) |
Adjusts the time-since-last-storm counter held in the "stormtime" data member of the "Storm Damage" grid. More... | |
void | PackageCleanup () |
Resets all values in the "Storm Damage" grid to 0. More... | |
float | NormalDraw (const float &fMean) |
Performs a random draw on a normal distribution. More... | |
float | LognormalDraw (const float &fMean) |
Performs a random draw on a lognormal distribution. 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 | |
clGrid * | mp_oStormGrid |
Storms grid This grid is named "Storm Damage" and it contains the severity of all storms that happened in the previous timestep. More... | |
clGrid * | mp_oSusceptibilityMap |
Storm susceptibility map This grid is named "Storm Susceptibility". More... | |
struct clStorm::stcStorms * | mp_stormsList |
List of scheduled storms - NULL if no storms. More... | |
float(clStorm::* | RandomDraw )(const float &fNumber) |
Function pointer for the appropriate RandomDraw function. More... | |
float * | mp_fStormProbabilities |
Timestep probability of the occurence of a storm of each return interval. More... | |
double | m_fStdDev |
Standard deviation for normal or lognormal probability distribution functions. More... | |
double | m_fSSTPeriod |
SST periodicity (Sr) More... | |
double | m_fSineD |
Sine function d. More... | |
double | m_fSineF |
Sine function f. More... | |
double | m_fSineG |
Sine function g. More... | |
double | m_fTrendSlopeM |
Trend function slope (m) More... | |
double | m_fTrendInterceptI |
Trend function intercept (i) More... | |
int | m_iNumSeverityClasses |
The total number of storm return intervals. More... | |
int | m_i1DmgIndexCode |
Return code for the "1dmg_index" data member of the "Storm Damage" grid. More... | |
int | m_iDmgIndexCode |
Return code for the "dmg_index" data member of the "Storm Damage" grid. More... | |
int | m_iStormTimeCode |
Return code for the "stormtime" data member of the "Storm Damage" grid. More... | |
int | m_iSusceptIndexCode |
Return code for the "index" data member of the "Storm Susceptibility" grid. More... | |
int | m_iNumScheduledStorms |
How many scheduled storms are in mp_stormsList. More... | |
enum clStorm::susceptibility | m_iSusceptibility |
Variable holding the susceptibility pattern value. More... | |
enum clStorm::stochasticity | m_iStochasticity |
Variable holding the stochasticity. More... | |
enum clStorm::distribution_func | m_iDistribution |
What probability distribution function to use if the value in m_iDamagePattern is "stochastic". 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... | |
Storms version 3.0.
The storm damage calculator's function is to assess whether or not one or more storms has occurred, and if so, what the damage pattern and amount of damage were. It creates a map of storm damage across the plot, with each location getting a damage index between 0 (no damage) and 1 (most damage).
Deciding when storms occur
The 0 - 1 interval of storm severity values is subdivided into ten storm severity classes. Each class is assigned a return interval in the parameter file by the user. Taking the reciprocal of the return interval gives us the annual probability of each type of storm.
To decide whether a given storm occurs, a random number is compared to the annual probability. Each storm severity class is decided individually. For multi-year timesteps, there is one random "coin flip" per year per severity class. This allows multiple storms to occur in the same timestep. For multi-year timesteps, multiple storms of the same severity class can occur, up to one per year. Each storm event creates a separate record in the storm damage grid. Storm severity is bounded between 0 and 1.
The frequency of storms can optionally be cyclical (sinusoidal), with an optional overall trend. The actual probability of any storm that uses a cyclical storm regime is:
where:
Storm events can also be specifically scheduled. In this case, they will occur in addition to any background storms. The user supplies a minimum and a maximum value for the storm intensity and a timestep.
Calculating damage when storms occur
The amount of damage caused by a timestep's storms is stored in the grid named "Storm Damage". Each cell in the grid can contain 0 or more packages. 0 packages indicates no storm occurred. There is one package for each storm that occurred that timestep, with a single value between 0 (no damage) and 1 (total damage). In addition, a counter is set containing the number of years since the last storm.
There are four damage patterns, and the value in the "Storm Damage" cells is calculated differently for each:
This behavior's call string and name string are both "Storm".
Copyright 2011 Charles D. Canham
Edit history:
--------------—
October 20, 2011 - Wiped the slate clean for SORTIE 7.0 (LEM)
|
protected |
|
protected |
|
protected |
clStorm::clStorm | ( | clSimManager * | p_oSimManager | ) |
Constructor.
p_oSimManager | Sim Manager object. |
clStorm::~clStorm | ( | ) |
Destructor.
Frees memory.
|
virtual |
Performs the storm calculations.
It loops through all of the storm severity classes and, for each class and for each year per timestep, uses a random number against the values in mp_fStormProbabilities to determine if a storm of a given severity has occurred. If a storm happens, ApplyDamage() is called.
Reimplemented from clBehaviorBase.
|
protected |
Adjusts the time-since-last-storm counter held in the "stormtime" data member of the "Storm Damage" grid.
If there was no storm this timestep, it adds the number of years per timestep to the value. If there was a storm, it sets the value to 0.
|
protected |
Applies the damage for a storm of a given return interval.
The storm's mean severity is calculated by taking a random draw on its severity interval. The damage is applied according to one of the following scenarios:
fMeanSeverity | The mean severity to use for this storm. |
|
protected |
Calculates the annual probability of a storm of each severity class.
The probability of a storm of a given return interval is calculated as 1/length of the return interval. The return interval values should already be in mp_fStormProbabilities, put there by ReadParFile().
|
protected |
Does the grid setup fo the behavior.
Steps:
modelErr | if:
|
|
protected |
Calculates mean storm severity for each cell.
|
virtual |
Does behavior setup.
It does the following:
p_oDoc | DOM tree of parsed input file. |
Implements clWorkerBase.
float clStorm::GetStormProbability | ( | int | iReturnInterval | ) |
Gets timestep probability of the occurence of a storm at a return interval.
iReturnInterval | Return interval. |
|
inlineprotected |
Performs a random draw on a lognormal distribution.
The standard deviation is mp_fStdDev.
fMean | Mean of the lognormal distribution. |
|
inlineprotected |
Performs a random draw on a normal distribution.
The standard deviation is mp_fStdDev.
fMean | Mean of the normal distribution. |
|
protected |
Resets all values in the "Storm Damage" grid to 0.
|
protected |
Reads in parameters from the parameter file.
modelErr | if:
|
p_oDoc | DOM tree of parsed input file. |
|
protected |
Sets the function pointer for a stochastic damage pattern.
If m_iDamagePattern is not "stochastic", nothing happens. If it is, this sets the value for clStorm::*RandomDraw depending on the value in m_iDistribution.
void clStorm::SetStormProbability | ( | int | iReturnInterval, |
float | fValue | ||
) |
Sets timestep probability of the occurence of a storm at a return interval.
iReturnInterval | Return interval. |
fValue | Probability. |
|
protected |
Sine function d.
|
protected |
Sine function f.
|
protected |
Sine function g.
|
protected |
SST periodicity (Sr)
|
protected |
Standard deviation for normal or lognormal probability distribution functions.
This is only used if m_iStochasticity = stochastic and m_iDistribution = lognormal or normal. Value comes from the parameter file.
|
protected |
Trend function intercept (i)
|
protected |
Trend function slope (m)
|
protected |
Return code for the "1dmg_index" data member of the "Storm Damage" grid.
|
protected |
What probability distribution function to use if the value in m_iDamagePattern is "stochastic".
Value comes from the parameter file.
|
protected |
Return code for the "dmg_index" data member of the "Storm Damage" grid.
|
protected |
How many scheduled storms are in mp_stormsList.
|
protected |
The total number of storm return intervals.
Hardcoded.
|
protected |
Variable holding the stochasticity.
Value comes from the parameter file. This controls how the damage pattern is applied - whether the same damage index is applied to all cells or whether it is randomized for each.
|
protected |
Return code for the "stormtime" data member of the "Storm Damage" grid.
|
protected |
Variable holding the susceptibility pattern value.
Value comes from parameter file. If the susceptibility is uniform, all locations have a susceptibility index of 1. If it is mapped, the "Storm Susceptibility" grid holds each location's susceptibility between 0 and 1.
|
protected |
Return code for the "index" data member of the "Storm Susceptibility" grid.
|
protected |
Timestep probability of the occurence of a storm of each return interval.
Array size is m_iNumSeverityClasses. These values are calculated in CalculateStormProbabilities().
|
protected |
Storms grid This grid is named "Storm Damage" and it contains the severity of all storms that happened in the previous timestep.
It is of user-settable resolution. It contains two float data members; one called "dmg_index", which is the mean of all storm severities for that grid cell, and one called "stormtime", which contains the time since the last storm, in years. For "stormtime", 0 means a storm occurred in the current timestep. It also can contain 1 or more packages, each with a float data member called "1dmg_index", which contains the damage index as a value from 0 (no damage) to 1 (total damage).
If there is a map for the "Storm Susceptibility" grid, and no other grid resolution information for this grid, then this grid will use the resolution of "Storm Susceptibility".
|
protected |
Storm susceptibility map This grid is named "Storm Susceptibility".
It has one float data member called "index". The value in "index" is a value from 0 (no storm susceptibility) to 1 (total storm susceptibility).
If the susceptibility = the enum value "mapped", then a grid map for this grid is expected in the parameter file. The values it contains will not be changed throughout the run. The grid resolution must match that of "Storm Damage" grid.
If the damage pattern is something other than "mapped", then this pointer is left as NULL and the grid is not initialized or used.
|
protected |
List of scheduled storms - NULL if no storms.
|
protected |
Function pointer for the appropriate RandomDraw function.