Subversion Repositories public iLand

Rev

Rev 1221 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1
 
671 werner 2
/********************************************************************************************
3
**    iLand - an individual based forest landscape and disturbance model
4
**    http://iland.boku.ac.at
5
**    Copyright (C) 2009-  Werner Rammer, Rupert Seidl
6
**
7
**    This program is free software: you can redistribute it and/or modify
8
**    it under the terms of the GNU General Public License as published by
9
**    the Free Software Foundation, either version 3 of the License, or
10
**    (at your option) any later version.
11
**
12
**    This program is distributed in the hope that it will be useful,
13
**    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
**    GNU General Public License for more details.
16
**
17
**    You should have received a copy of the GNU General Public License
18
**    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
********************************************************************************************/
20
 
180 werner 21
#ifndef STANDSTATISTICS_H
22
#define STANDSTATISTICS_H
23
class Tree;
257 werner 24
struct TreeGrowthData;
234 werner 25
class ResourceUnitSpecies;
1158 werner 26
class SaplingStat;
180 werner 27
 
28
class StandStatistics
29
{
30
public:
234 werner 31
    StandStatistics() { mRUS=0; clear();}
32
    void setResourceUnitSpecies(const ResourceUnitSpecies *rus) { mRUS=rus; }
33
 
180 werner 34
    void add(const StandStatistics &stat); ///< add aggregates of @p stat to own aggregates
1157 werner 35
    void addAreaWeighted(const StandStatistics &stat, const double weight); ///< add aggregates of @p stat to this aggregate and scale using the weight (e.g. stockable area)
257 werner 36
    void add(const Tree *tree, const TreeGrowthData *tgd); ///< call for each tree within the domain
1158 werner 37
    void add(const SaplingStat *sapling); ///< call for regeneration layer of a species in resource unit
180 werner 38
    void clear(); ///< call before trees are aggregated
1202 werner 39
    void clearOnlyTrees(); ///< clear the statistics only for tree biomass (keep NPP, regen, ...)
234 werner 40
    void calculate(); ///< call after all trees are processed (postprocessing)
182 werner 41
    // getters
855 werner 42
    double count() const { return mCount; }
257 werner 43
    double dbh_avg() const { return mAverageDbh; } ///< average dbh (cm)
44
    double height_avg() const { return mAverageHeight; } ///< average tree height (m)
277 werner 45
    double volume() const { return mSumVolume; } ///< sum of tree volume (m3/ha)
46
    double gwl() const { return mGWL;} ///< total increment (m3/ha)
47
    double basalArea() const { return mSumBasalArea; } ///< sum of basal area of all trees (m2/ha)
377 werner 48
    double leafAreaIndex() const { return mLeafAreaIndex; } ///< [m2/m2]/ha stocked area.
1157 werner 49
    double npp() const { return mNPP; } ///< sum. of NPP (kg Biomass increment, above+belowground, trees >4m)/ha
277 werner 50
    double nppAbove() const { return mNPPabove; } ///< above ground NPP (kg Biomass increment)/ha
1157 werner 51
    double nppSaplings() const { return mNPPsaplings; } ///< carbon gain of saplings (kg Biomass increment)/ha
453 werner 52
    int cohortCount() const { return mCohortCount; } ///< number of cohorts of saplings / ha
53
    int saplingCount() const { return mSaplingCount; } ///< number individuals in regeneration layer (represented by "cohortCount" cohorts) N/ha
454 werner 54
    double saplingAge() const { return mAverageSaplingAge; } ///< average age of sapling (currenty not weighted with represented sapling numbers...)
587 werner 55
    // carbon/nitrogen cycle
56
    double cStem() const { return mCStem; }
57
    double nStem() const { return mNStem; }
58
    double cBranch() const { return mCBranch; }
59
    double nBranch() const { return mNBranch; }
60
    double cFoliage() const { return mCFoliage; }
61
    double nFoliage() const { return mNFoliage; }
62
    double cCoarseRoot() const { return mCCoarseRoot; }
63
    double nCoarseRoot() const { return mNCoarseRoot; }
64
    double cFineRoot() const { return mCFineRoot; }
65
    double nFineRoot() const { return mNFineRoot; }
66
    double cRegeneration() const { return mCRegeneration; }
67
    double nRegeneration() const { return mNRegeneration; }
1157 werner 68
    /// total carbon stock: sum of carbon of all living trees + regeneration layer
837 werner 69
    double totalCarbon() const { return mCStem + mCBranch + mCFoliage + mCFineRoot + mCCoarseRoot + mCRegeneration; }
182 werner 70
 
180 werner 71
private:
587 werner 72
    inline void addBiomass(const double biomass, const double CNRatio, double *C, double *N);
234 werner 73
    const ResourceUnitSpecies *mRUS; ///< link to the resource unit species
855 werner 74
    double mCount;
180 werner 75
    double mSumDbh;
76
    double mSumHeight;
77
    double mSumBasalArea;
78
    double mSumVolume;
277 werner 79
    double mGWL;
180 werner 80
    double mAverageDbh;
81
    double mAverageHeight;
234 werner 82
    double mLeafAreaIndex;
257 werner 83
    double mNPP;
261 werner 84
    double mNPPabove;
1157 werner 85
    double mNPPsaplings; // carbon gain of saplings
453 werner 86
    // regeneration layer
466 werner 87
    int mCohortCount; ///< number of cohrots
483 werner 88
    int mSaplingCount; ///< number of sapling (Reinekes Law)
454 werner 89
    double mSumSaplingAge;
90
    double mAverageSaplingAge;
587 werner 91
    // carbon and nitrogen pools
92
    double mCStem, mCFoliage, mCBranch, mCCoarseRoot, mCFineRoot;
93
    double mNStem, mNFoliage, mNBranch, mNCoarseRoot, mNFineRoot;
94
    double mCRegeneration, mNRegeneration;
180 werner 95
};
96
 
615 werner 97
 
98
/** holds a couple of system statistics primarily aimed for performance and memory analyis.
99
  */
100
class SystemStatistics
101
{
102
public:
103
    SystemStatistics() { reset(); }
104
    void reset() { treeCount=0; saplingCount=0; newSaplings=0;
105
                   tManagement = 0.; tApplyPattern=tReadPattern=tTreeGrowth=0.;
1158 werner 106
                   tSeedDistribution=tSapling=tEstablishment=tCarbonCycle=tWriteOutput=tTotalYear=0.; }
615 werner 107
    void writeOutput();
108
    // the system counters
109
    int treeCount;
110
    int saplingCount;
111
    int newSaplings;
112
    // timings
113
    double tManagement;
114
    double tApplyPattern;
115
    double tReadPattern;
116
    double tTreeGrowth;
117
    double tSeedDistribution;
1158 werner 118
    double tSapling;
119
    double tEstablishment;
615 werner 120
    double tCarbonCycle;
121
    double tWriteOutput;
122
    double tTotalYear;
123
 
124
};
125
 
180 werner 126
#endif // STANDSTATISTICS_H