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

Storms version 3.0. More...

#include <Storm.h>

Inheritance diagram for clStorm:
clBehaviorBase clWorkerBase

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...
 
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 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

clGridmp_oStormGrid
 Storms grid This grid is named "Storm Damage" and it contains the severity of all storms that happened in the previous timestep. More...
 
clGridmp_oSusceptibilityMap
 Storm susceptibility map This grid is named "Storm Susceptibility". More...
 
struct clStorm::stcStormsmp_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...
 
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...
 

Detailed Description

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:

P'(Fi) = P(Fi) * ([d*sin(pi(x-g)/(2f))] + [mx + i])

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:

  1. Varying spatial distribution, deterministic. In this pattern, a static storm vulnerability map is supplied for the plot in the parameter file. The map is a set of values from 0 (no susceptibility) on up. The susceptibility value at a location is multiplied by the damage index of any storm that hits to arrive at a final damage index for that location.
  2. Varying spatial distribution, stochastic. In this pattern, a static storm vulnerability map is supplied for the plot in the parameter file. The map is a set of values from 0 (no susceptibility) to 1 (maximum susceptibility). The damage index of a storm is determined as for the "Uniform stochastic" method. Then the susceptibility value at a location is multiplied by this damage index to arrive at a final damage index for that location.
  3. Uniform deterministic. All plot locations receive the storm's designated damage index.
  4. Uniform stochastic. The storm's designated severity is used as the mean in a probability distribution function to arrive at a final damage index.

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)

Author
Lora E. Murphy

Member Enumeration Documentation

◆ distribution_func

Enum for listing probability distribution functions.

Poisson is not included because it creates integers only - not appropriate.

Enumerator
lognormal 

Lognormal distribution.

normal 

Normal distribution.

◆ stochasticity

enum clStorm::stochasticity
protected

Enum for stochasticity.

Enumerator
deterministic 

Deterministic damage index calculations.

stochastic 

Stochastic damage index calculations.

◆ susceptibility

enum clStorm::susceptibility
protected

Enum for describing the damage pattern.

This controls the method used to calculate final damage indexes.

Enumerator
mapped 

Susceptibility is entered via a map.

uniform 

Susceptibility is uniform across the plot.

Constructor & Destructor Documentation

◆ clStorm()

clStorm::clStorm ( clSimManager p_oSimManager)

Constructor.

Parameters
p_oSimManagerSim Manager object.

◆ ~clStorm()

clStorm::~clStorm ( )

Destructor.

Frees memory.

Member Function Documentation

◆ Action()

void clStorm::Action ( )
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.

◆ AdjustTimeSinceLastStormCounter()

void clStorm::AdjustTimeSinceLastStormCounter ( bool  bStormThisTimestep)
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.

◆ ApplyDamage()

void clStorm::ApplyDamage ( float  fMeanSeverity)
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:

  • If the storm stochasticity is deterministic and the susceptibility is uniform, the value of the storm damage index is added to each cell of the "Storm Damage" grid (up to a max of 1).
  • If the storm stochasticity is stochastic and the susceptibility is uniform, for each cell in the "Storm Damage" grid, the value of the storm damage index is fed as the mean to the appropriate random draw function in the math library to get a new storm damage index; then this value is added to the cell (up to a max of 1).
  • If the storm stochasticity is deterministic and the susceptibility is mapped, the storm damage index is multiplied by the appropriate cell value in the "Storm Susceptibility" grid and added to the cell of the "Storm Damage" grid (up to a max of 1).
  • If the storm stochasticity is stochastic and the susceptibility is mapped, for each cell in the "Storm Damage" grid, the value of the storm damage index is fed as the mean to the appropriate random draw function in the math library to get a new storm damage index. This index is multiplied by the appropriate cell value in the "Storm Susceptibility" grid and added to the cell of the "Storm Damage" grid (up to a max of 1).
Parameters
fMeanSeverityThe mean severity to use for this storm.

◆ CalculateStormProbabilities()

void clStorm::CalculateStormProbabilities ( )
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().

◆ DoGridSetup()

void clStorm::DoGridSetup ( )
protected

Does the grid setup fo the behavior.

Steps:

  1. Check to see if m_iSusceptibility is "mapped". If it is, get the "Storm Susceptibility" grid and verify that it has been created.
  2. Check for the existence of the "Storm Damage" grid. If it has been created in the parameter file, make sure the grid cell resolution matches "Storm Susceptibility", if that grid exists.
  3. If "Storm Damage" was not created in the parameter file, create it with "Storm Susceptibility"'s grid cell resolution if that grid exists, or the default grid cell resolution if it doesn't.
  4. Call TimestepCleanup() to make sure that all values in "Storm Damage" are 0.
Exceptions
modelErrif:
  • The damage pattern as read from the parameter file is "mapped" but there is no map in the parameter file for the grid "Storm Susceptibility"
  • Either grid is in the parameter file but not set up correctly
  • There is grid cell resolution data in the parameter file for both "Storm Damage" and "Storm Susceptibility" and they do not match

◆ DoSeverityAverages()

void clStorm::DoSeverityAverages ( )
protected

Calculates mean storm severity for each cell.

◆ GetData()

void clStorm::GetData ( xercesc::DOMDocument *  p_oDoc)
virtual

Does behavior setup.

It does the following:

  1. Calls ReadParFile() to read parameter file values
  2. Calls DoGridSetup() to set up the grids
  3. Calls CalculateStormProbabilities() to calculate the annual storm probabilities
  4. Calls SetStochFuncPointer() to set the stochastic function pointer, if appropriate
Parameters
p_oDocDOM tree of parsed input file.

Implements clWorkerBase.

◆ GetStormProbability()

float clStorm::GetStormProbability ( int  iReturnInterval)

Gets timestep probability of the occurence of a storm at a return interval.

Parameters
iReturnIntervalReturn interval.

◆ LognormalDraw()

float clStorm::LognormalDraw ( const float &  fMean)
inlineprotected

Performs a random draw on a lognormal distribution.

The standard deviation is mp_fStdDev.

Parameters
fMeanMean of the lognormal distribution.
Returns
Random number between 0 and 1.

◆ NormalDraw()

float clStorm::NormalDraw ( const float &  fMean)
inlineprotected

Performs a random draw on a normal distribution.

The standard deviation is mp_fStdDev.

Parameters
fMeanMean of the normal distribution.
Returns
Random number between 0 and 1.

◆ PackageCleanup()

void clStorm::PackageCleanup ( )
protected

Resets all values in the "Storm Damage" grid to 0.

◆ ReadParFile()

void clStorm::ReadParFile ( xercesc::DOMDocument *  p_oDoc)
protected

Reads in parameters from the parameter file.

Exceptions
modelErrif:
  • Any return interval is not greater than 0.
  • The susceptibility value is not recognized.
  • The stochasticity value is not recognized.
  • The stochasticity is "stochastic" and there is no value for probability distribution function, or that value is not recognized.
  • The stochasticity is "stochastic", the probability distribution function is "normal" or "lognormal", and there is no value for standard deviation.
Parameters
p_oDocDOM tree of parsed input file.

◆ SetStochFuncPointer()

void clStorm::SetStochFuncPointer ( )
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.

◆ SetStormProbability()

void clStorm::SetStormProbability ( int  iReturnInterval,
float  fValue 
)

Sets timestep probability of the occurence of a storm at a return interval.

Parameters
iReturnIntervalReturn interval.
fValueProbability.

Member Data Documentation

◆ m_fSineD

double clStorm::m_fSineD
protected

Sine function d.

◆ m_fSineF

double clStorm::m_fSineF
protected

Sine function f.

◆ m_fSineG

double clStorm::m_fSineG
protected

Sine function g.

◆ m_fSSTPeriod

double clStorm::m_fSSTPeriod
protected

SST periodicity (Sr)

◆ m_fStdDev

double clStorm::m_fStdDev
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.

◆ m_fTrendInterceptI

double clStorm::m_fTrendInterceptI
protected

Trend function intercept (i)

◆ m_fTrendSlopeM

double clStorm::m_fTrendSlopeM
protected

Trend function slope (m)

◆ m_i1DmgIndexCode

int clStorm::m_i1DmgIndexCode
protected

Return code for the "1dmg_index" data member of the "Storm Damage" grid.

◆ m_iDistribution

enum clStorm::distribution_func clStorm::m_iDistribution
protected

What probability distribution function to use if the value in m_iDamagePattern is "stochastic".

Value comes from the parameter file.

◆ m_iDmgIndexCode

int clStorm::m_iDmgIndexCode
protected

Return code for the "dmg_index" data member of the "Storm Damage" grid.

◆ m_iNumScheduledStorms

int clStorm::m_iNumScheduledStorms
protected

How many scheduled storms are in mp_stormsList.

◆ m_iNumSeverityClasses

int clStorm::m_iNumSeverityClasses
protected

The total number of storm return intervals.

Hardcoded.

◆ m_iStochasticity

enum clStorm::stochasticity clStorm::m_iStochasticity
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.

◆ m_iStormTimeCode

int clStorm::m_iStormTimeCode
protected

Return code for the "stormtime" data member of the "Storm Damage" grid.

◆ m_iSusceptibility

enum clStorm::susceptibility clStorm::m_iSusceptibility
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.

◆ m_iSusceptIndexCode

int clStorm::m_iSusceptIndexCode
protected

Return code for the "index" data member of the "Storm Susceptibility" grid.

◆ mp_fStormProbabilities

float* clStorm::mp_fStormProbabilities
protected

Timestep probability of the occurence of a storm of each return interval.

Array size is m_iNumSeverityClasses. These values are calculated in CalculateStormProbabilities().

◆ mp_oStormGrid

clGrid* clStorm::mp_oStormGrid
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".

◆ mp_oSusceptibilityMap

clGrid* clStorm::mp_oSusceptibilityMap
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.

◆ mp_stormsList

struct clStorm::stcStorms * clStorm::mp_stormsList
protected

List of scheduled storms - NULL if no storms.

◆ RandomDraw

float(clStorm::* clStorm::RandomDraw) (const float &fNumber)
protected

Function pointer for the appropriate RandomDraw function.


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