iLand
windmodule.h
Go to the documentation of this file.
1/********************************************************************************************
2** iLand - an individual based forest landscape and disturbance model
3** http://iland-model.org
4** Copyright (C) 2009- Werner Rammer, Rupert Seidl
5**
6** This program is free software: you can redistribute it and/or modify
7** it under the terms of the GNU General Public License as published by
8** the Free Software Foundation, either version 3 of the License, or
9** (at your option) any later version.
10**
11** This program is distributed in the hope that it will be useful,
12** but WITHOUT ANY WARRANTY; without even the implied warranty of
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14** GNU General Public License for more details.
15**
16** You should have received a copy of the GNU General Public License
17** along with this program. If not, see <http://www.gnu.org/licenses/>.
18********************************************************************************************/
19#ifndef WINDMODULE_H
20#define WINDMODULE_H
21#include "grid.h"
22#include "layeredgrid.h"
23#include "expression.h"
24#include <QHash>
25
26class Tree; // forward
27class Species; // forward
28class ResourceUnit; // forward
29
34class WindCell {
35public:
37 void clear() {height = edge = 0.f; n_trees=0.f; tree=0; n_killed = 0; basal_area_killed = 0.f; cws_uproot = 0.; cws_break= crown_windspeed= 0.; n_iteration = 0;}
38 bool isValid() const { return height<9999.f; }
39 float topex;
40 float height;
41 float n_trees;
42 const Tree *tree;
43 float edge;
44 // statistics
49 double cws_uproot;
50 double cws_break;
54};
55// data structure for a resource unit
57public:
58 WindRUCell(): flag(0), soilIsFrozen(false) {}
59 int flag; // flag to indicate that the trees of the current resource are already processed
61};
62
66class WindLayers: public LayeredGrid<WindCell> {
67 public:
68 void setGrid(const Grid<WindCell> &grid) { mGrid = &grid; }
69 double value(const WindCell& data, const int index) const;
70 const QVector<LayerElement> &names();
71 // specifics for wind layers
72 void setRUGrid(const Grid<WindRUCell> *grid) { mRUGrid = grid; }
73private:
74 QVector<LayerElement> mNames;
75 double ruValueAt(const WindCell *cell, const int what) const; // get resource-unit level factor at cell "cell"
76 const Grid<WindRUCell> *mRUGrid;
77};
78
82{
84 double crown_area_factor; // empirical factor related to the crown shape (fraction of crown shape compared to rectangle)
85 double crown_length; // crown length of the tree (fraction of tree height)
86 double Creg; // Nm/kg, critical turning coefficient from tree pulling
87 double MOR; // MPa, modulus of rupture
88 double wet_biomass_factor; // conversion factor between dry and wet biomass (wet = dry*factor)
89};
90
95{
96public:
97 WindModule();
98 static double cellsize() { return 10.; }
100 void setup();
101 void setupResourceUnit(const ResourceUnit* ru);
102 WindLayers &layers() { return mWindLayers; }
103
105 void run(const int iteration=-1, const bool execute_from_script=false);
106
107 // test functions
108 void setWindProperties(const double direction_rad, const double speed_ms) { mWindDirection = direction_rad; mWindSpeed = speed_ms; }
109 void setSimulationMode(const bool mode) { mSimulationMode = mode; }
110 bool simulationMode() const { return mSimulationMode; }
111 void setMaximumIterations(const double maxit) { mMaxIteration = maxit; }
112
113 void testFetch(double degree_direction);
114 void testEffect();
115private:
116 // main functions
117 bool eventTriggered();
118 void initWindGrid();
119 void detectEdges(bool at_startup=false);
120 void calculateFetch();
121 int calculateWindImpact();
122
123 // details
125 bool checkFetch(const int startx, const int starty, const double direction, const double max_distance, const double threshold) ;
127 bool windImpactOnPixel(const QPoint position, WindCell *cell);
129 double calculateCrownWindSpeed(const Tree *tree, const WindSpeciesParameters &params, const double n_trees, const double wind_speed_10);
130 double calculateCrititalWindSpeed(const Tree *tree, const WindSpeciesParameters &params, const double gap_length, double &rCWS_uproot, double &rCWS_break);
132 bool isSoilFrozen(const ResourceUnit *ru, const int day_of_year) const;
133
134 // helping functions
135 void scanResourceUnitTrees(const QPoint &position);
136 void loadSpeciesParameter(const QString &table_name);
137 const WindSpeciesParameters &speciesParameter(const Species *s);
138 void initializeEdgeAge(const int years);
139 void incrementEdgeAge();
140
141 // variables
142 bool mTopexFromGrid;
143 double mWindDirection;
144 double mWindDirectionVariation;
145 double mWindSpeed;
146 double mEdgeDetectionThreshold;
147 double mFactorEdge;
148 int mWindDayOfYear;
149 bool mSimulationMode;
150 int mCurrentIteration;
151 int mMaxIteration;
152 double mGustModifier;
153 double mCurrentGustFactor;
154 enum ETopexFactorModificationType {gfMultiply, gfAdd} mTopexFactorModificationType;
155 double mIterationsPerMinute;
156 int mEdgeAgeBaseValue;
157 Expression mEdgeProbability;
158 double mEdgeBackgroundProbability;
159 // some statistics
160 int mPixelAffected;
161 int mTreesKilled;
162 double mTotalKilledBasalArea;
163 double mTotalKilledVolume;
164 enum ESoilFreezeMode {esfFrozen, esfNotFrozen, esfAuto, esfInvalid} mSoilFreezeMode;
165 Grid<WindCell> mGrid;
166 Grid<WindRUCell> mRUGrid;
167 WindLayers mWindLayers;
168 // species parameters for the wind module
169 QHash<const Species*, WindSpeciesParameters> mSpeciesParameters;
171 Expression mLRITransferFunction;
172
173 QString mAfterExecEvent;
174
175 friend class WindScript;
176 friend class WindOut;
177 friend void nc_calculateFetch(WindCell *begin, WindCell *end);
178 friend void nc_calculateWindImpact(ResourceUnit *unit);
179
180};
181
182
183
184#endif // WINDMODULE_H
An expression engine for mathematical expressions provided as strings.
Definition: expression.h:29
Grid class (template).
Definition: grid.h:44
This is the base class for multi-layer grids in iLand.
Definition: layeredgrid.h:95
const Grid< WindCell > * mGrid
Definition: layeredgrid.h:130
ResourceUnit is the spatial unit that encapsulates a forest stand and links to several environmental ...
Definition: resourceunit.h:49
The behavior and general properties of tree species.
Definition: species.h:75
A tree is the basic simulation entity of iLand and represents a single tree.
Definition: tree.h:44
data structure for a single wind cell (usually 10x10m).
Definition: windmodule.h:34
float height
top height (m).
Definition: windmodule.h:40
double crown_windspeed
wind speed (m/s) on the cecll
Definition: windmodule.h:51
double sum_volume_killed
running sum of killed tree volume on that pixel (m3)
Definition: windmodule.h:53
double cws_uproot
critital wind speed for uprooting (m/s)
Definition: windmodule.h:49
int edge_age
age of an edge (consecutive number of years of being an edge)
Definition: windmodule.h:47
int n_killed
number of trees killed on the pixel
Definition: windmodule.h:46
bool isValid() const
returns true if the pixel is on the valid project area
Definition: windmodule.h:38
WindCell()
Definition: windmodule.h:36
const Tree * tree
pointer to the tallest tree on the pixel (if already populated)
Definition: windmodule.h:42
float n_trees
number of trees on pixel
Definition: windmodule.h:41
void clear()
Definition: windmodule.h:37
double cws_break
critical wind speed for tree breakage (m/s)
Definition: windmodule.h:50
int n_iteration
number of iteration this pixel is processed (and trees are killed)
Definition: windmodule.h:45
double basal_area_killed
basal area of trees that died (m2) (during an event)
Definition: windmodule.h:48
int n_affected
number of storm that killed trees on that pixel.
Definition: windmodule.h:52
float edge
maximum difference to neighboring cells (m)
Definition: windmodule.h:43
float topex
topographic modifier for wind speed (-)
Definition: windmodule.h:39
Helper class manage and visualize data layers related to fire.
Definition: windmodule.h:66
double value(const WindCell &data, const int index) const
Definition: windmodule.cpp:55
void setGrid(const Grid< WindCell > &grid)
Definition: windmodule.h:68
const QVector< LayerElement > & names()
list of stored layers
Definition: windmodule.cpp:77
void setRUGrid(const Grid< WindRUCell > *grid)
Definition: windmodule.h:72
The WindModule is the main object of the iLand wind module.
Definition: windmodule.h:95
bool simulationMode() const
Definition: windmodule.h:110
void setWindProperties(const double direction_rad, const double speed_ms)
Definition: windmodule.h:108
WindModule()
Definition: windmodule.cpp:109
void setSimulationMode(const bool mode)
Definition: windmodule.h:109
friend void nc_calculateFetch(WindCell *begin, WindCell *end)
Definition: windmodule.cpp:463
static double cellsize()
Definition: windmodule.h:98
void setupResourceUnit(const ResourceUnit *ru)
setup of spatial explicit variables (e.g.
Definition: windmodule.cpp:193
void run(const int iteration=-1, const bool execute_from_script=false)
main function of the disturbance module
Definition: windmodule.cpp:295
void testFetch(double degree_direction)
Definition: windmodule.cpp:566
void setMaximumIterations(const double maxit)
Definition: windmodule.h:111
void setup()
the general setup routine after starting iland
Definition: windmodule.cpp:125
WindLayers & layers()
Definition: windmodule.h:102
void testEffect()
Definition: windmodule.cpp:585
friend void nc_calculateWindImpact(ResourceUnit *unit)
Definition: windmodule.cpp:518
Definition: windout.h:27
Definition: windmodule.h:56
bool soilIsFrozen
Definition: windmodule.h:60
WindRUCell()
Definition: windmodule.h:58
int flag
Definition: windmodule.h:59
Definition: windscript.h:29
Species parameters that are specific to the wind module.
Definition: windmodule.h:82
double wet_biomass_factor
Definition: windmodule.h:88
double MOR
Definition: windmodule.h:87
double crown_length
Definition: windmodule.h:85
WindSpeciesParameters()
Definition: windmodule.h:83
double crown_area_factor
Definition: windmodule.h:84
double Creg
Definition: windmodule.h:86