Rev 268 | Rev 276 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | |||
90 | Werner | 2 | #ifndef SPECIES_H |
3 | #define SPECIES_H |
||
38 | Werner | 4 | |
103 | Werner | 5 | |
91 | Werner | 6 | #include "expression.h" |
7 | |||
103 | Werner | 8 | #include "speciesset.h" |
102 | Werner | 9 | |
91 | Werner | 10 | class StampContainer; // forwards |
38 | Werner | 11 | class Stamp; |
91 | Werner | 12 | |
103 | Werner | 13 | |
90 | Werner | 14 | class Species |
38 | Werner | 15 | { |
16 | public: |
||
111 | Werner | 17 | Species(SpeciesSet *set) { mSet = set; mIndex=set->count(); } |
226 | werner | 18 | const SpeciesSet *speciesSet() const { return mSet; } |
91 | Werner | 19 | // properties |
20 | /// @property id 4-character unique identification of the tree species |
||
111 | Werner | 21 | const QString &id() const { return mId; } |
91 | Werner | 22 | /// the full name (e.g. Picea Abies) of the species |
111 | Werner | 23 | const QString &name() const { return mName; } |
145 | Werner | 24 | int index() const { return mIndex; } ///< unique index of species within current set |
179 | werner | 25 | bool active() const { return true; } ///< active??? todo! |
236 | werner | 26 | int phenologyClass() const { return mPhenologyClass; } ///< phenology class defined in project file. class 0 = evergreen |
27 | bool isConiferous() const { return mConiferous; } |
||
28 | bool isEvergreen() const { return mEvergreen; } |
||
136 | Werner | 29 | |
91 | Werner | 30 | // calculations: allometries |
145 | Werner | 31 | double biomassFoliage(const double dbh) const; |
32 | double biomassWoody(const double dbh) const; |
||
33 | double biomassRoot(const double dbh) const; |
||
34 | double allometricRatio_wf() const { return mWoody_b / mFoliage_b; } |
||
35 | double allometricFractionStem(const double dbh) const; |
||
136 | Werner | 36 | |
116 | Werner | 37 | // turnover rates |
145 | Werner | 38 | double turnoverLeaf() const { return mTurnoverLeaf; } |
39 | double turnoverRoot() const { return mTurnoverRoot; } |
||
119 | Werner | 40 | // hd-values |
41 | void hdRange(const double dbh, double &rMinHD, double &rMaxHD); |
||
125 | Werner | 42 | // growth |
145 | Werner | 43 | double volumeFactor() const { return mVolumeFactor; } ///< factor for volume calculation: V = factor * D^2*H (incorporates density and the form of the bole) |
44 | double density() const { return mWoodDensity; } ///< density of stem wood [kg/m3] |
||
45 | double specificLeafArea() const { return mSpecificLeafArea; } |
||
159 | werner | 46 | // mortality |
47 | double deathProb_intrinsic() const { return mDeathProb_intrinsic; } |
||
48 | double deathProb_stress() const { return mDeathProb_stress; } |
||
169 | werner | 49 | // aging |
50 | double aging(const float height, const int age); |
||
209 | werner | 51 | // environmental responses |
52 | double vpdResponse(const double &vpd) const; |
||
266 | werner | 53 | inline double temperatureResponse(const double &delayed_temp) const; |
209 | werner | 54 | double nitrogenResponse(const double &availableNitrogen) const { return mSet->nitrogenResponse(availableNitrogen, mRespNitrogenClass); } |
236 | werner | 55 | double canopyConductance() const { return mMaxCanopyConductance; } ///< maximum canopy conductance in m/s |
266 | werner | 56 | inline double soilwaterResponse(const double &psi_kPa) const; ///< input: matrix potential (kPa) (e.g. -15) |
274 | werner | 57 | double lightResponse(const double lightResourceIndex) {return mSet->lightResponse(lightResourceIndex, mLightResponseClass); } |
268 | werner | 58 | double psiMax() const { return mPsiMax; } |
110 | Werner | 59 | |
136 | Werner | 60 | const Stamp* stamp(const float dbh, const float height) const { return mLIPs.stamp(dbh, height);} |
39 | Werner | 61 | // maintenance |
91 | Werner | 62 | void setup(); |
38 | Werner | 63 | private: |
90 | Werner | 64 | Q_DISABLE_COPY(Species); |
265 | werner | 65 | QMutex mMutex; |
136 | Werner | 66 | // helpers during setup |
236 | werner | 67 | bool boolVar(const QString s) { return mSet->var(s).toBool(); } ///< during setup: get value of variable @p s as a boolean variable. |
136 | Werner | 68 | double doubleVar(const QString s) { return mSet->var(s).toDouble(); }///< during setup: get value of variable @p s as a double. |
236 | werner | 69 | int intVar(const QString s) { return mSet->var(s).toInt(); } ///< during setup: get value of variable @p s as an integer. |
136 | Werner | 70 | QString stringVar(const QString s) { return mSet->var(s).toString(); } ///< during setup: get value of variable @p s as a string. |
71 | |||
91 | Werner | 72 | SpeciesSet *mSet; ///< ptr. to the "parent" set |
136 | Werner | 73 | StampContainer mLIPs; ///< ptr to the container of the LIP-pattern |
91 | Werner | 74 | QString mId; |
75 | QString mName; |
||
111 | Werner | 76 | int mIndex; ///< internal index within the SpeciesSet |
236 | werner | 77 | bool mConiferous; ///< true if confierous species (vs. broadleaved) |
78 | bool mEvergreen; ///< true if evergreen species |
||
136 | Werner | 79 | // biomass allometries: |
80 | double mFoliage_a, mFoliage_b; ///< allometry (biomass = a * dbh^b) for foliage |
||
81 | double mWoody_a, mWoody_b; ///< allometry (biomass = a * dbh^b) for woody compartments aboveground |
||
82 | double mRoot_a, mRoot_b; ///< allometry (biomass = a * dbh^b) for roots (compound, fine and coarse roots as one pool) |
||
83 | double mBranch_a, mBranch_b; ///< allometry (biomass = a * dbh^b) for branches |
||
84 | |||
110 | Werner | 85 | double mSpecificLeafArea; ///< conversion factor from kg OTS to m2 LeafArea |
116 | Werner | 86 | // turnover rates |
87 | double mTurnoverLeaf; ///< yearly turnover rate leafs |
||
88 | double mTurnoverRoot; ///< yearly turnover rate root |
||
119 | Werner | 89 | // height-diameter-relationships |
90 | Expression mHDlow; ///< minimum HD-relation as f(d) (open grown tree) |
||
91 | Expression mHDhigh; ///< maximum HD-relation as f(d) |
||
125 | Werner | 92 | // stem density and taper |
93 | double mWoodDensity; ///< density of the wood [kg/m3] |
||
94 | double mFormFactor; ///< taper form factor of the stem [-] used for volume / stem-mass calculation calculation |
||
95 | double mVolumeFactor; ///< factor for volume calculation |
||
159 | werner | 96 | // mortality |
97 | double mDeathProb_intrinsic; ///< prob. of intrinsic death per year [0..1] |
||
98 | double mDeathProb_stress; ///< max. prob. of death per year when tree suffering maximum stress |
||
169 | werner | 99 | // Aging |
100 | double mMaximumAge; ///< maximum age of species (years) |
||
101 | double mMaximumHeight; ///< maximum height of species (m) for aging |
||
214 | werner | 102 | Expression mAging; |
209 | werner | 103 | // environmental responses |
104 | double mRespVpdExponent; ///< exponent in vpd response calculation (Mäkela 2008) |
||
105 | double mRespTempMin; ///< temperature response calculation offset |
||
106 | double mRespTempMax; ///< temperature response calculation: saturation point for temp. response |
||
107 | double mRespNitrogenClass; ///< nitrogen response class (1..3). fractional values (e.g. 1.2) are interpolated. |
||
266 | werner | 108 | double mPsiMax; ///< maximum water potential (MPa), i.e. wilting point (is below zero!) |
236 | werner | 109 | // water |
110 | double mMaxCanopyConductance; ///< maximum canopy conductance for transpiration (m/s) |
||
226 | werner | 111 | int mPhenologyClass; |
274 | werner | 112 | double mLightResponseClass; ///< light response class (1..5) (1=shade intolerant) |
38 | Werner | 113 | }; |
114 | |||
40 | Werner | 115 | |
119 | Werner | 116 | // inlined functions... |
117 | inline void Species::hdRange(const double dbh, double &rLowHD, double &rHighHD) |
||
118 | { |
||
265 | werner | 119 | QMutexLocker m(&mMutex); // serialize access |
119 | Werner | 120 | rLowHD = mHDlow.calculate(dbh); |
121 | rHighHD = mHDhigh.calculate(dbh); |
||
122 | } |
||
209 | werner | 123 | /** vpdResponse calculates response on vpd. |
124 | Input: vpd [kPa]*/ |
||
125 | inline double Species::vpdResponse(const double &vpd) const |
||
126 | { |
||
127 | return exp(mRespVpdExponent * vpd); |
||
128 | } |
||
119 | Werner | 129 | |
209 | werner | 130 | /** temperatureResponse calculates response on delayed daily temperature. |
131 | Input: average temperature [°C] |
||
132 | Note: slightly different from Mäkela 2008: the maximum parameter (Sk) in iLand is interpreted as the absolute |
||
133 | temperature yielding a response of 1; in Mäkela 2008, Sk is the width of the range (relative to the lower threhold) |
||
134 | */ |
||
135 | inline double Species::temperatureResponse(const double &delayed_temp) const |
||
136 | { |
||
137 | double x = qMax(delayed_temp-mRespTempMin, 0.); |
||
138 | x = qMin(x/(mRespTempMax-mRespTempMin), 1.); |
||
139 | return x; |
||
140 | } |
||
266 | werner | 141 | /** soilwaterResponse is a function of the current matrix potential of the soil. |
209 | werner | 142 | |
266 | werner | 143 | */ |
144 | inline double Species::soilwaterResponse(const double &psi_kPa) const |
||
145 | { |
||
146 | const double psi_mpa = psi_kPa / 1000.; // convert to MPa |
||
147 | double result = limit( 1. - psi_mpa / mPsiMax, 0., 1.); |
||
148 | return result; |
||
149 | } |
||
150 | |||
90 | Werner | 151 | #endif // SPECIES_H |