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