iLand
snag.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 SNAG_H
21#define SNAG_H
22#include <QList>
23#include <QVariant>
24class Tree; // forward
25class Species; // forward
26class ResourceUnit; // forward
27
30class CNPair
31{
32public:
33 CNPair(): C(0.), N(0.) {}
34 static void setCFraction(const double fraction) { biomassCFraction = fraction; }
35 CNPair(const double c, const double n) {C=c; N=n; }
36 bool isEmpty() const { return C==0.; }
37 bool isValid() const { return C>=0. && N>=0.; }
38 double C; // carbon pool (kg C/ha)
39 double N; // nitrogen pool (kg N/ha)
40 double CN() { return N>0?C/N:0.; }
41 void clear() {C=0.; N=0.; }
43 double biomass() const {return C / biomassCFraction; }
46 void addBiomass(const double biomass, const double CNratio) { C+=biomass*biomassCFraction; N+=biomass*biomassCFraction/CNratio; }
47 // some simple operators
48 void operator+=(const CNPair &s) { C+=s.C; N+=s.N; }
49 void operator*=(const double factor) { C*=factor; N*=factor; }
50 const CNPair operator+(const CNPair &p2) const { return CNPair(C+p2.C, N+p2.N); }
51 const CNPair operator-(const CNPair &p2) const { return CNPair(C-p2.C, N-p2.N); }
52 const CNPair operator*(const double factor) const { return CNPair(C*factor, N*factor); }
53protected:
54 static double biomassCFraction;
55};
56
58class CNPool: public CNPair
59{
60public:
61 CNPool(): CNPair(), mParameter(0.) {}
62 CNPool(const double c, const double n, const double param_value) {C=c; N=n; mParameter=param_value; }
63 double parameter() const { return mParameter; }
64 double parameter(const CNPool &s) const;
65 void clear() { CNPair::clear(); mParameter=0.; }
66
68 void addBiomass(const double biomass, const double CNratio, const double parameter_value);
69 void add(const CNPair &s, const double parameter_value) { operator+=(CNPool(s.C, s.N, parameter_value));}
70 void setParameter(const double value) { mParameter = value; }
71
72 void operator+=(const CNPool &s);
73 const CNPool operator*(const double factor) const { return CNPool(C*factor, N*factor, mParameter); }
74private:
75 double mParameter;
76};
77
78class Snag
79{
80public:
81 Snag();
82 static void setupThresholds(const double lower, const double upper);
83 void setup( const ResourceUnit *ru);
84 void scaleInitialState();
85 void newYear();
86 void calculateYear();
87 // access
88 bool isStateEmpty() const { return mTotalSnagCarbon == 0.; }
89 bool isEmpty() const { return mLabileFlux.isEmpty() && mRefractoryFlux.isEmpty() && isStateEmpty(); }
90 const CNPool &labileFlux() const { return mLabileFlux; }
91 const CNPool &refractoryFlux() const {return mRefractoryFlux; }
92 double labileFluxAbovegroundCarbon() const { return mLabileFluxAbovegroundCarbon; }
93 double refractoryFluxAbovegroundCarbon() const { return mRefrFluxAbovegroundCarbon; }
94 double climateFactor() const { return mClimateFactor; }
95 double totalCarbon() const { return mTotalSnagCarbon; }
96 const CNPair &totalSWD() const { return mTotalSWD; }
97 const CNPair &totalOtherWood() const { return mTotalOther; }
98 double otherWoodAbovegroundFraction() const { return mOtherWoodAbovegroundFrac; }
99 const CNPair &fluxToAtmosphere() const { return mTotalToAtm; }
100 const CNPair &fluxToExtern() const { return mTotalToExtern; }
101 const CNPair &fluxToDisturbance() const { return mTotalToDisturbance; }
102
104 double freshDeciduousFoliage() const { return mDeciduousFoliageLitter; }
105 // actions
107 void addTurnoverLitter(const Species *species, const double litter_foliage, const double litter_fineroot);
108 void addTurnoverWood(const Species *species, const double woody_biomass);
109
111 void addMortality(const Tree* tree);
112
116 void addHarvest(const Tree* tree, const double remove_stem_pct, const double remove_branch_pct, const double remove_foliage_pct );
117
125 void addDisturbance(const Tree *tree, const double stem_to_snag, const double stem_to_soil,
126 const double branch_to_snag, const double branch_to_soil,
127 const double foliage_to_soil) { addBiomassPools(tree, stem_to_snag, stem_to_soil, branch_to_snag, branch_to_soil, foliage_to_soil);}
128
130 void addToSoil(const Species *species, const CNPair &woody_pool, const CNPair &litter_pool, double woody_aboveground_C, double fine_aboveground_C);
131
133 void addBiomassToSoil(const CNPool &woody_pool, const CNPool &litter_pool);
134
136 void removeCarbon(const double factor);
138 void management(const double factor);
139 QList<QVariant> debugList();
140private:
142 void addBiomassPools(const Tree *tree, const double stem_to_snag, const double stem_to_soil, const double branch_to_snag, const double branch_to_soil, const double foliage_to_soil);
143 double calculateClimateFactors();
144 double mClimateFactor;
145 const ResourceUnit *mRU;
147 int poolIndex(const float dbh) { if (dbh<mDBHLower) return 0; if (dbh>mDBHHigher) return 2; return 1;}
148 CNPool mSWD[3];
149 CNPair mTotalSWD;
150 double mNumberOfSnags[3];
151 double mAvgDbh[3];
152 double mAvgHeight[3];
153 double mAvgVolume[3];
154 double mTimeSinceDeath[3];
155 double mKSW[3];
156 double mCurrentKSW[3];
157 double mHalfLife[3];
158 CNPool mToSWD[3];
159 CNPool mLabileFlux;
160 CNPool mRefractoryFlux;
161 CNPool mOtherWood[5];
162 CNPair mTotalOther;
163 int mBranchCounter;
164 double mDeciduousFoliageLitter;
165 double mLabileFluxAbovegroundCarbon;
166 double mRefrFluxAbovegroundCarbon;
167 double mOtherWoodAbovegroundFrac;
168 double mTotalSnagCarbon;
169 CNPair mTotalIn;
170 CNPair mSWDtoSoil;
171 CNPair mTotalToAtm;
172 CNPair mTotalToExtern;
173 CNPair mTotalToDisturbance;
174 static double mDBHLower, mDBHHigher;
175 static double mCarbonThreshold[3];
176
177 friend class Snapshot;
178};
179
180#endif // SNAG_H
CNPair stores a duple of carbon and nitrogen (kg/ha) use addBiomass(biomass, cnratio) to add biomass;...
Definition: snag.h:31
double CN()
current CN ratio
Definition: snag.h:40
const CNPair operator-(const CNPair &p2) const
return the difference of two pools
Definition: snag.h:51
static void setCFraction(const double fraction)
set the global fraction of carbon of biomass
Definition: snag.h:34
bool isEmpty() const
returns true if pool is empty
Definition: snag.h:36
void addBiomass(const double biomass, const double CNratio)
add biomass to the pool (kg dry mass/ha); CNratio is used to calculate the N-Content,...
Definition: snag.h:46
void operator+=(const CNPair &s)
add contents of a pool
Definition: snag.h:48
bool isValid() const
return true if pool is valid (content of C or N >=0)
Definition: snag.h:37
double C
Definition: snag.h:38
double N
Definition: snag.h:39
static double biomassCFraction
Definition: snag.h:54
CNPair()
Definition: snag.h:33
CNPair(const double c, const double n)
Definition: snag.h:35
double biomass() const
retrieve the amount of biomass (kg/ha). Uses the global C-fraciton. Soil pools are in t/ha!...
Definition: snag.h:43
const CNPair operator*(const double factor) const
return the pool multiplied with 'factor'
Definition: snag.h:52
void clear()
Definition: snag.h:41
const CNPair operator+(const CNPair &p2) const
return the sum of two pools
Definition: snag.h:50
void operator*=(const double factor)
Multiply pool with 'factor'.
Definition: snag.h:49
CNPool provides (in addition to CNPair) also a weighted parameter value (e.g.
Definition: snag.h:59
void setParameter(const double value)
Definition: snag.h:70
void operator+=(const CNPool &s)
Definition: snag.cpp:60
CNPool()
Definition: snag.h:61
double parameter() const
get weighting parameter
Definition: snag.h:63
void clear()
Definition: snag.h:65
void add(const CNPair &s, const double parameter_value)
convenience function
Definition: snag.h:69
void addBiomass(const double biomass, const double CNratio, const double parameter_value)
add biomass with a specific 'CNRatio' and 'parameter_value'
Definition: snag.cpp:49
CNPool(const double c, const double n, const double param_value)
Definition: snag.h:62
const CNPool operator*(const double factor) const
return the pool multiplied with 'factor'
Definition: snag.h:73
ResourceUnit is the spatial unit that encapsulates a forest stand and links to several environmental ...
Definition: resourceunit.h:49
Snag deals with carbon / nitrogen fluxes from the forest until the reach soil pools.
Definition: snag.h:79
void addHarvest(const Tree *tree, const double remove_stem_pct, const double remove_branch_pct, const double remove_foliage_pct)
add residual biomass of 'tree' after harvesting.
Definition: snag.cpp:527
void management(const double factor)
cut down swd and move to soil pools
Definition: snag.cpp:603
double otherWoodAbovegroundFraction() const
fraction of branches in 'other' pools (0..1)
Definition: snag.h:98
QList< QVariant > debugList()
return a debug output
Definition: snag.cpp:159
const CNPool & refractoryFlux() const
deadwood flux to the soil (kg/ha)
Definition: snag.h:91
void newYear()
to be executed at the beginning of a simulation year. This cleans up the transfer pools.
Definition: snag.cpp:184
const CNPair & totalOtherWood() const
sum of C and N in other woody pools (branches + coarse roots) kg/RU
Definition: snag.h:97
void removeCarbon(const double factor)
disturbance function: remove the fraction of 'factor' of biomass from the SWD pools; 0: remove nothin...
Definition: snag.cpp:581
const CNPair & fluxToAtmosphere() const
total kg/RU heterotrophic respiration / flux to atm
Definition: snag.h:99
double labileFluxAbovegroundCarbon() const
C input to the labile flux from aboveground sources (kg/ha)
Definition: snag.h:92
void scaleInitialState()
used to scale the input to the actual area of the resource unit
Definition: snag.cpp:145
void calculateYear()
to be called at the end of the year (after tree growth, harvesting). Calculates flow to the soil.
Definition: snag.cpp:239
double totalCarbon() const
total carbon in snags (kg/RU): not scaled to 1ha!!
Definition: snag.h:95
const CNPair & fluxToExtern() const
total kg/RU harvests
Definition: snag.h:100
Snag()
Definition: snag.cpp:96
double refractoryFluxAbovegroundCarbon() const
C input of the input to the refractory (woody) flux from aboveground sources (kg/ha)
Definition: snag.h:93
void addBiomassToSoil(const CNPool &woody_pool, const CNPool &litter_pool)
add non-tree biomass to soil (litter input). Inputs in kg/ha. decomposition rate in parameter value o...
Definition: snag.cpp:569
void addMortality(const Tree *tree)
adds the 'tree' to the appropriate Snag pools.
Definition: snag.cpp:478
double freshDeciduousFoliage() const
deciduous foliage litter (kg/ha) from the previous year
Definition: snag.h:104
bool isStateEmpty() const
Definition: snag.h:88
const CNPool & labileFlux() const
litter flux to the soil (kg/ha)
Definition: snag.h:90
bool isEmpty() const
Definition: snag.h:89
void addTurnoverWood(const Species *species, const double woody_biomass)
Definition: snag.cpp:375
void addDisturbance(const Tree *tree, const double stem_to_snag, const double stem_to_soil, const double branch_to_snag, const double branch_to_soil, const double foliage_to_soil)
a tree dies and the biomass of the tree is split between snags/soils/removals
Definition: snag.h:125
void setup(const ResourceUnit *ru)
initial setup routine.
Definition: snag.cpp:102
static void setupThresholds(const double lower, const double upper)
setup class thresholds, needs to be called only once... (static)
Definition: snag.cpp:79
const CNPair & fluxToDisturbance() const
total kg/RU due to disturbance (e.g. fire)
Definition: snag.h:101
const CNPair & totalSWD() const
sum of C and N in SWD pools (stems) kg/RU
Definition: snag.h:96
void addToSoil(const Species *species, const CNPair &woody_pool, const CNPair &litter_pool, double woody_aboveground_C, double fine_aboveground_C)
add (died) biomass from the regeneration layer
Definition: snag.cpp:557
void addTurnoverLitter(const Species *species, const double litter_foliage, const double litter_fineroot)
add for a tree with diameter
Definition: snag.cpp:362
double climateFactor() const
the 're' climate factor to modify decay rates (also used in ICBM/2N model)
Definition: snag.h:94
way to save/load the current state of the model to a database.
Definition: snapshot.h:35
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