iLand
resourceunit.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
20#ifndef RESOURCEUNIT_H
21#define RESOURCEUNIT_H
22
23#include "tree.h"
24#include "resourceunitspecies.h"
25#include "standstatistics.h"
26#include <QtCore/QVector>
27#include <QtCore/QRectF>
28// forward declarations
29class SpeciesSet;
30class Climate;
31class WaterCycle;
32class Snag;
33class Soil;
34struct SaplingCell;
35class SVDStates; class SVDStateOut;
36
38{
43 double cumNEP;
45 static double nitrogenAvailableDelta;
46};
47
49{
50public:
51 ResourceUnit(const int index);
53 // setup/maintenance
54 void setup();
55 void setSpeciesSet(SpeciesSet *set);
56 void setClimate(Climate* climate) { mClimate = climate; }
57 void setBoundingBox(const QRectF &bb);
58 void setID(const int id) { mID = id; }
59
60 // access to elements
61 const Climate *climate() const { return mClimate; }
62 SpeciesSet *speciesSet() const { return mSpeciesSet; }
63 const WaterCycle *waterCycle() const { return mWater; }
64 Snag *snag() const { return mSnag; }
65 Soil *soil() const { return mSoil; }
66 SaplingCell *saplingCellArray() const { return mSaplings; }
67 SaplingCell *saplingCell(const QPoint &lifCoords) const;
71 double saplingCoveredArea(bool below130cm) const;
72
74 const ResourceUnitSpecies *constResourceUnitSpecies(const Species *species) const;
75 ResourceUnitSpecies *resourceUnitSpecies(const int species_index) const { return mRUSpecies[species_index]; }
76 const QList<ResourceUnitSpecies*> &ruSpecies() const { return mRUSpecies; }
77 QVector<Tree> &trees() { return mTrees; }
78 const QVector<Tree> &constTrees() const { return mTrees; }
79 Tree *tree(const int index) { return &(mTrees[index]);}
80 const ResourceUnitVariables &resouceUnitVariables() const { return mUnitVariables; }
81 const StandStatistics &statistics() const {return mStatistics; }
82
83 // properties
84 int index() const { return mIndex; }
85 int id() const { return mID; }
86 const QRectF &boundingBox() const { return mBoundingBox; }
87 const QPoint &cornerPointOffset() const { return mCornerOffset; }
88 double area() const { return mPixelCount*100; }
89 double stockedArea() const { return mStockedArea; }
90 double stockableArea() const { return mStockableArea; }
91 double productiveArea() const { return mEffectiveArea; }
93 double leafAreaIndex() const { return stockableArea()?mAggregatedLA / stockableArea():0.; }
94 double leafArea() const { return mAggregatedLA; }
95 double interceptedArea(const double LA, const double LightResponse) { return mEffectiveArea_perWLA * LA * LightResponse; }
96 const double &LRImodifier() const { return mLRI_modification; }
97 double averageAging() const { return mAverageAging; }
99 double topHeight(bool &rIrregular) const;
101 int svdStateId() const { return mSVDState.stateId; }
103 int svdPreviousStateId() const { return mSVDState.previousStateId; }
105 int svdStateTime() const {return mSVDState.time; }
107 int svdPreviousTime() const {return mSVDState.previousTime; }
108
109 // actions
110 Tree &newTree();
111 int newTreeIndex();
112 void cleanTreeList();
113 void treeDied() { mHasDeadTrees = true; }
114 bool hasDiedTrees() const { return mHasDeadTrees; }
116 void addWLA(const float LA, const float LRI) { mAggregatedWLA += LA*LRI; mAggregatedLA += LA; }
117 void addLR(const float LA, const float LightResponse) { mAggregatedLR += LA*LightResponse; }
120 void addTreeAging(const double leaf_area, const double aging_factor) { mAverageAging += leaf_area*aging_factor; }
122 // stocked area calculation
123 void countStockedPixel(bool pixelIsStocked) { mPixelCount++; if (pixelIsStocked) mStockedPixelCount++; }
124 void createStandStatistics();
125 void recreateStandStatistics(bool recalculate_stats);
126 void setStockableArea(const double area) { mStockableArea = area; }
127 void setCreateDebugOutput(const bool do_dbg) { mCreateDebugOutput = do_dbg; }
128 bool shouldCreateDebugOutput() const { return mCreateDebugOutput; }
129
130 // snag / snag dynamics
131 // snag dynamics, soil carbon and nitrogen cycle
132 void snagNewYear() { if (snag()) snag()->newYear(); }
133 void calculateCarbonCycle();
134 // model flow
135 void newYear();
136 // LIP/LIF-cylcle -> Model
137 void production();
138 void beforeGrow();
139 // the growth of individuals -> Model
140 void afterGrow();
141 void yearEnd();
142
143private:
144 void updateSVDState();
145 int mIndex;
146 int mID;
147 bool mHasDeadTrees;
148 Climate *mClimate;
149 SpeciesSet *mSpeciesSet;
150 WaterCycle *mWater;
151 Snag *mSnag;
152 Soil *mSoil;
153 QList<ResourceUnitSpecies*> mRUSpecies;
154 QVector<Tree> mTrees;
155 SaplingCell *mSaplings;
156 QRectF mBoundingBox;
157 QPoint mCornerOffset;
158 double mAggregatedLA;
159 double mAggregatedWLA;
160 double mAggregatedLR;
161 double mEffectiveArea;
162 double mEffectiveArea_perWLA;
163 double mLRI_modification;
164 double mAverageAging;
165 float *mSaplingHeightMap;
166 struct RUSVDState {
167 RUSVDState(): localComposition(0), midDistanceComposition(0) {}
168 ~RUSVDState() { if (localComposition) {delete localComposition; delete midDistanceComposition; } }
169 qint16 stateId;
170 qint16 previousStateId;
171 qint16 time;
172 qint16 previousTime;
173 QVector<float> *localComposition;
174 QVector<float> *midDistanceComposition;
175
176 void clear() { stateId=previousStateId=time=previousTime=0; }
177 } mSVDState;
178
179
180 int mPixelCount;
181 int mStockedPixelCount;
182 double mStockedArea;
183 double mStockableArea;
184 StandStatistics mStatistics;
185 ResourceUnitVariables mUnitVariables;
186 bool mCreateDebugOutput;
187
188 friend class RUWrapper;
189 friend class SVDStates;
190 friend class SVDStateOut;
191 friend class SVDIndicatorOut;
192};
193
194
195#endif // RESOURCEUNIT_H
Climate handles climate input data and performs some basic related calculations on that data.
Definition: climate.h:66
Definition: expressionwrapper.h:58
ResourceUnit is the spatial unit that encapsulates a forest stand and links to several environmental ...
Definition: resourceunit.h:49
const StandStatistics & statistics() const
Definition: resourceunit.h:81
double interceptedArea(const double LA, const double LightResponse)
Definition: resourceunit.h:95
const QRectF & boundingBox() const
Definition: resourceunit.h:86
int newTreeIndex()
returns the index of a newly inserted tree
Definition: resourceunit.cpp:253
int svdStateId() const
the Id of the state the resource unit is in
Definition: resourceunit.h:101
bool hasDiedTrees() const
if true, the resource unit has dead trees and needs maybe some cleanup
Definition: resourceunit.h:114
void yearEnd()
called at the end of a year (after regeneration??)
Definition: resourceunit.cpp:441
void addTreeAgingForAllTrees()
calculate average tree aging for all trees of a RU. Used directly after stand initialization.
Definition: resourceunit.cpp:506
void recreateStandStatistics(bool recalculate_stats)
re-build stand statistics after some change happened to the resource unit
Definition: resourceunit.cpp:555
void setClimate(Climate *climate)
Definition: resourceunit.h:56
const QPoint & cornerPointOffset() const
coordinates on the LIF grid of the upper left corner of the RU
Definition: resourceunit.h:87
void addLR(const float LA, const float LightResponse)
Definition: resourceunit.h:117
void countStockedPixel(bool pixelIsStocked)
Definition: resourceunit.h:123
Snag * snag() const
access the snag object
Definition: resourceunit.h:64
SaplingCell * saplingCell(const QPoint &lifCoords) const
return a pointer to the 2x2m SaplingCell located at 'lif'
Definition: resourceunit.cpp:151
double topHeight(bool &rIrregular) const
calculate the top tree height (as 90th percentile of the top heights on the 10m pixels),...
Definition: resourceunit.cpp:220
void beforeGrow()
called before growth of individuals
Definition: resourceunit.cpp:426
Tree & newTree()
returns a modifiable reference to a free space inside the tree-vector. should be used for tree-init.
Definition: resourceunit.cpp:244
void addTreeAging(const double leaf_area, const double aging_factor)
aggregate the tree aging values (weighted by leaf area)
Definition: resourceunit.h:120
int svdPreviousStateId() const
the Id of the state the resource unit was previously in
Definition: resourceunit.h:103
void treeDied()
sets the flag that indicates that the resource unit contains dead trees
Definition: resourceunit.h:113
void setID(const int id)
Definition: resourceunit.h:58
void calculateCarbonCycle()
calculate snag dynamics at the end of a year
Definition: resourceunit.cpp:582
const QList< ResourceUnitSpecies * > & ruSpecies() const
Definition: resourceunit.h:76
QVector< Tree > & trees()
reference to the tree list.
Definition: resourceunit.h:77
double averageAging() const
leaf area weighted average aging
Definition: resourceunit.h:97
void setCreateDebugOutput(const bool do_dbg)
enable/disable output generation for RU
Definition: resourceunit.h:127
double stockedArea() const
get the stocked area in m2
Definition: resourceunit.h:89
SaplingCell * saplingCellArray() const
access the array of sapling-cells
Definition: resourceunit.h:66
const WaterCycle * waterCycle() const
water model of the unit
Definition: resourceunit.h:63
void snagNewYear()
clean transfer pools
Definition: resourceunit.h:132
double area() const
get the resource unit area in m2
Definition: resourceunit.h:88
double productiveArea() const
TotalArea - Unstocked Area - loss due to BeerLambert (m2)
Definition: resourceunit.h:91
bool shouldCreateDebugOutput() const
is debug output enabled for the RU?
Definition: resourceunit.h:128
const ResourceUnitVariables & resouceUnitVariables() const
access to variables that are specific to resourceUnit (e.g. nitrogenAvailable)
Definition: resourceunit.h:80
void calculateInterceptedArea()
function that distributes effective interception area according to the weight of Light response and L...
Definition: resourceunit.cpp:414
ResourceUnit(const int index)
Definition: resourceunit.cpp:69
double leafArea() const
total leaf area of resource unit (m2)
Definition: resourceunit.h:94
void setSpeciesSet(SpeciesSet *set)
set species and setup the species-per-RU-data
Definition: resourceunit.cpp:188
Tree * tree(const int index)
get pointer to a tree
Definition: resourceunit.h:79
const Climate * climate() const
link to the climate on this resource unit
Definition: resourceunit.h:61
ResourceUnitSpecies * resourceUnitSpecies(const int species_index) const
get RU-Species-container with index 'species_index' from the RU
Definition: resourceunit.h:75
void setStockableArea(const double area)
set stockable area (m2)
Definition: resourceunit.h:126
~ResourceUnit()
Definition: resourceunit.cpp:49
int id() const
Definition: resourceunit.h:85
int svdStateTime() const
the number of years the RU is already in the current state svdStateId()
Definition: resourceunit.h:105
const ResourceUnitSpecies * constResourceUnitSpecies(const Species *species) const
get RU-Species-container of species from the RU
Definition: resourceunit.cpp:215
void addWLA(const float LA, const float LRI)
addWLA() is called by each tree to aggregate the total weighted leaf area on a unit
Definition: resourceunit.h:116
Soil * soil() const
access the soil model
Definition: resourceunit.h:65
void newYear()
reset values for a new simulation year
Definition: resourceunit.cpp:302
void production()
called after the LIP/LIF calc, before growth of individual trees. Production (3PG),...
Definition: resourceunit.cpp:336
ResourceUnitSpecies & resourceUnitSpecies(const Species *species)
get RU-Species-container of species from the RU
Definition: resourceunit.cpp:210
int index() const
Definition: resourceunit.h:84
const QVector< Tree > & constTrees() const
reference to the (const) tree list.
Definition: resourceunit.h:78
void afterGrow()
called after the growth of individuals
Definition: resourceunit.cpp:432
double saplingCoveredArea(bool below130cm) const
return the area (m2) which is covered by saplings (cells >0 saplings) if below130cm is false,...
Definition: resourceunit.cpp:161
void setup()
setup operations after the creation of the model space.
Definition: resourceunit.cpp:95
SpeciesSet * speciesSet() const
get SpeciesSet this RU links to.
Definition: resourceunit.h:62
int svdPreviousTime() const
the number of years that the RU was in the previous state svdPreviousStateId()
Definition: resourceunit.h:107
double stockableArea() const
total stockable area in m2
Definition: resourceunit.h:90
void cleanTreeList()
remove dead trees from the tree storage.
Definition: resourceunit.cpp:264
void createStandStatistics()
helping function to create an initial state for stand statistics
Definition: resourceunit.cpp:518
double leafAreaIndex() const
Total Leaf Area Index (m2/m2) of trees>4m.
Definition: resourceunit.h:93
const double & LRImodifier() const
Definition: resourceunit.h:96
void setBoundingBox(const QRectF &bb)
Definition: resourceunit.cpp:144
The class contains data available at ResourceUnit x Species scale.
Definition: resourceunitspecies.h:34
SVDIndicatorOut saves (compressed) indicator data for SVD.
Definition: svdout.h:63
SVDStateOut saves state changes for SVD.
Definition: svdout.h:35
Definition: svdstate.h:49
Snag deals with carbon / nitrogen fluxes from the forest until the reach soil pools.
Definition: snag.h:79
void newYear()
to be executed at the beginning of a simulation year. This cleans up the transfer pools.
Definition: snag.cpp:184
implementation of the ICBM/2N soil carbon and nitrogen dynamics model.
Definition: soil.h:29
The behavior and general properties of tree species.
Definition: species.h:75
A SpeciesSet acts as a container for individual Species objects.
Definition: speciesset.h:30
Collects information on stand level for each tree species.
Definition: standstatistics.h:28
A tree is the basic simulation entity of iLand and represents a single tree.
Definition: tree.h:44
simulates the water cycle on a ResourceUnit.
Definition: watercycle.h:106
Definition: resourceunit.h:38
double cumCarbonUptake
NPP (kg C/ha)
Definition: resourceunit.h:41
double carbonUptake
Definition: resourceunit.h:44
double carbonToAtm
Definition: resourceunit.h:44
double cumNEP
cumulative ecosystem productivity (kg C/ha), i.e. cumulative(NPP-losses(atm,harvest)
Definition: resourceunit.h:43
double NEP
values of the current year (NPP, flux to atmosphere, net ecosystem prod., all values in kgC/ha)
Definition: resourceunit.h:44
static double nitrogenAvailableDelta
delta which is added to nitrogenAvailable every year (and can be changed via Time Events)
Definition: resourceunit.h:45
ResourceUnitVariables()
Definition: resourceunit.h:39
double nitrogenAvailable
nitrogen content (kg/m2/year)
Definition: resourceunit.h:40
double cumCarbonToAtm
total flux of carbon to atmosphere (kg C/ha)
Definition: resourceunit.h:42
Definition: saplings.h:53