-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathST_mortality.h
More file actions
173 lines (148 loc) · 5.66 KB
/
ST_mortality.h
File metadata and controls
173 lines (148 loc) · 5.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/**
* \file ST_mortality.h
* \brief Functions and variables exported from the \ref MORTALITY module.
*
* \author Chandler Haukap
* \date February 12 2020
* \ingroup MORTALITY
*/
#ifndef MORTALITY_H
#define MORTALITY_H
#include "sw_src/include/generic.h"
#include "sw_src/include/SW_Defines.h"
/* --------------------------- Exported Structs ---------------------------- */
/**
* @brief 10 year running average climate information and 3 year average biomass for use in the wild fire probability model.
*
* 10 year simple moving averages of proportion of precipitation during the summer months, mean annual temperature,
* and annual precipitation are created using this structure, and stored in this structure. 3 year moving average
* of annual forbs and grasses biomass and perennial forbs an grasses biomass.
*
* @author Michael Novotny
* @date 17 October 2022
*
*/
typedef struct WildfireClimate_st {
// the past 10 years of proportion of precipitation during the summer months.
// the index of the oldest element is count % 10.
double propSummerPrecip[10];
double propSummerPrecipAvg;
double meanAnnTemp[10];
double meanAnnTempAvg;
double annPrecip[10];
double annPrecipAvg;
// annual forbs and grasses above ground biomass
double afgAGB[3];
double afgAGBAvg;
// perennial forbs and grasses above ground biomass
double pfgAGB[3];
double pfgAGBAvg;
// this value is incremented every time new values are added and new averages are calculated.
// it is used to index the arrays to update the oldest item in order to calculate
// a simple 10 year moving average.
int count;
// incrementer/indexer for the biomass arrays.
int biomassCount;
} WildfireClimate;
/**
* \brief Information used when simulating the cheatgrass-wildfire loop.
*
* The biggest determinant in cheatgrass driven wildfire is precipitation,
* specifically precipitation in Spring and Winter. This struct stores the
* values from previous Spring and Winter precipitation as well as the running
* averages of both.
*
* Note that "year" in this context refers to the water year, which runs from
* October to September.
*
* \sa _updateCheatgrassPrecip, where this struct is updated each year.
* \author Chandler Haukap
* \date 13 January 2020
* \ingroup MORTALITY
*/
typedef struct CheatgrassPrecip_st {
/** \brief The Spring precipitation in the previous 3 years.
* The array is indexed from newest to oldest, meaning prevSpring[0] is the
* most recent value. */
double prevSprings[3];
/** \brief The precipitation in the last Winter, meaning the Oct-Dec
* precipitation from 2 years ago and the Jan-Mar precipitation from last
* year. */
double lastWinter;
/** \brief The current year's Spring precipitation. */
double currentSpring;
/** \brief The running average of Spring precipitation. */
double springMean;
/** \brief The running average of Winter precipitation. */
double winterMean;
/** \brief The sum of October - December precipitation information from last
* year.
*
* The variable we use to get precipitation information, \ref SXW, stores
* values for the current year, but we need the values from 2 years ago to
* calculate last year's winter precipitation. We therefore store it here,
* even though it does make the struct a little more confusing.
*/
double lastOctThruDec;
/** \brief The sum of October - December precipitation information from the
* current year.
*
* The variable we use to get precipitation information, \ref SXW, stores
* values for the current year, but we need the values from 2 years ago to
* calculate last year's winter precipitation. We therefore store it here,
* even though it does make the struct a little more confusing.
*/
double thisOctThruDec;
/** \brief The sum of January - March precipitation information from last
* year.
*
* The variable we use to get precipitation information, \ref SXW, stores
* values for the current year, but we need the values from 1 year ago to
* calculate last year's winter precipitation. We therefore store it here,
* even though it does make the struct a little more confusing.
*/
double thisJanThruMar;
} CheatgrassPrecip;
/* -------------------------- Exported Functions --------------------------- */
// See ST_mortality.c for definitions and documentation of these functions.
void mort_Main(Bool *killed);
void mort_EndOfYear(void);
void freeMortalityMemory(void);
void proportion_Recovery(void);
void grazing_EndOfYear(void);
void killAnnuals(void);
void killMaxage(void);
void killExtraGrowth(void);
void initWildfireClimate(void);
WildfireClimate *getWildfireClimate(void);
void setWildfireClimate(WildfireClimate *newWildfireClimate);
void _updateWildfireClimate(double propSummerPrecip, double meanAnnualTemperature, double annualPrecipitation);
void _updateWildfireClimateBiomass(double afgAGB, double pfgAGB);
void _resetWildfireClimateBiomass(void);
void initCheatgrassPrecip(void);
void setCheatgrassPrecip(CheatgrassPrecip* newCheatgrassPrecip);
CheatgrassPrecip* getCheatgrassPrecip(void);
/* ---------------------------- Exported Enums ----------------------------- */
/**
* \brief All types of mortality.
*
* Used to record what killed an individual.
*
* \sa indiv_st which instantiates this enumerator.
*
* \ingroup MORTALITY
*/
typedef enum {
Slow,
NoResources,
Intrinsic,
Disturbance,
LastMort
} MortalityType;
/* =================================================== */
/* Externed Global Variables */
/* --------------------------------------------------- */
extern sw_random_t mortality_rng;
extern Bool *_SomeKillage;
extern Bool UseWildfire;
#endif