Rev 808 | Rev 936 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 808 | Rev 863 | ||
---|---|---|---|
1 | Redirecting to URL 'https://iland.boku.ac.at/svn/iland/tags/release_1.0/src/core/resourceunitspecies.cpp': |
1 | Redirecting to URL 'https://iland.boku.ac.at/svn/iland/tags/release_1.0/src/core/resourceunitspecies.cpp': |
2 | #include "global.h"
|
2 | #include "global.h"
|
3 | #include "resourceunitspecies.h"
|
3 | #include "resourceunitspecies.h"
|
4 | 4 | ||
5 | #include "species.h"
|
5 | #include "species.h"
|
6 | #include "resourceunit.h"
|
6 | #include "resourceunit.h"
|
7 | #include "model.h"
|
7 | #include "model.h"
|
8 | #include "watercycle.h"
|
8 | #include "watercycle.h"
|
9 | #include "debugtimer.h"
|
9 | #include "debugtimer.h"
|
10 | 10 | ||
11 | /** @class ResourceUnitSpecies
|
11 | /** @class ResourceUnitSpecies
|
12 | @ingroup core
|
12 | @ingroup core
|
13 | The class contains data available at ResourceUnit x Species scale.
|
13 | The class contains data available at ResourceUnit x Species scale.
|
14 | Data stored is either statistical (i.e. number of trees per species) or used
|
14 | Data stored is either statistical (i.e. number of trees per species) or used
|
15 | within the model (e.g. fraction of utilizable Radiation).
|
15 | within the model (e.g. fraction of utilizable Radiation).
|
16 | Important submodules are:
|
16 | Important submodules are:
|
17 | * 3PG production (Production3PG)
|
17 | * 3PG production (Production3PG)
|
18 | * Establishment
|
18 | * Establishment
|
19 | * Growth and Recruitment of Saplings
|
19 | * Growth and Recruitment of Saplings
|
20 | * Snag dynamics
|
20 | * Snag dynamics
|
21 | */
|
21 | */
|
22 | ResourceUnitSpecies::~ResourceUnitSpecies() |
22 | ResourceUnitSpecies::~ResourceUnitSpecies() |
23 | {
|
23 | {
|
24 | }
|
24 | }
|
25 | 25 | ||
26 | double ResourceUnitSpecies::leafArea() const |
26 | double ResourceUnitSpecies::leafArea() const |
27 | {
|
27 | {
|
28 | // Leaf area of the species:
|
28 | // Leaf area of the species:
|
29 | // total leaf area on the RU * fraction of leafarea
|
29 | // total leaf area on the RU * fraction of leafarea
|
30 | return mLAIfactor * ru()->leafAreaIndex(); |
30 | return mLAIfactor * ru()->leafAreaIndex(); |
31 | }
|
31 | }
|
32 | 32 | ||
33 | void ResourceUnitSpecies::setup(Species *species, ResourceUnit *ru) |
33 | void ResourceUnitSpecies::setup(Species *species, ResourceUnit *ru) |
34 | {
|
34 | {
|
35 | mSpecies = species; |
35 | mSpecies = species; |
36 | mRU = ru; |
36 | mRU = ru; |
37 | mResponse.setup(this); |
37 | mResponse.setup(this); |
38 | m3PG.setResponse(&mResponse); |
38 | m3PG.setResponse(&mResponse); |
39 | mEstablishment.setup(ru->climate(), this); |
39 | mEstablishment.setup(ru->climate(), this); |
40 | mSapling.setup(this); |
40 | mSapling.setup(this); |
41 | mStatistics.setResourceUnitSpecies(this); |
41 | mStatistics.setResourceUnitSpecies(this); |
42 | mStatisticsDead.setResourceUnitSpecies(this); |
42 | mStatisticsDead.setResourceUnitSpecies(this); |
43 | mStatisticsMgmt.setResourceUnitSpecies(this); |
43 | mStatisticsMgmt.setResourceUnitSpecies(this); |
44 | 44 | ||
45 | mRemovedGrowth = 0.; |
45 | mRemovedGrowth = 0.; |
46 | mLastYear = -1; |
46 | mLastYear = -1; |
47 | 47 | ||
48 | }
|
48 | }
|
49 | 49 | ||
50 | 50 | ||
51 | void ResourceUnitSpecies::calculate(const bool fromEstablishment) |
51 | void ResourceUnitSpecies::calculate(const bool fromEstablishment) |
52 | {
|
52 | {
|
53 | if (mLastYear == GlobalSettings::instance()->currentYear()) |
53 | if (mLastYear == GlobalSettings::instance()->currentYear()) |
54 | return; |
54 | return; |
55 | 55 | ||
56 | // the call *not* from establishment
|
56 | // the call *not* from establishment
|
57 | if (!fromEstablishment) |
57 | if (!fromEstablishment) |
58 | statistics().clear(); |
58 | statistics().clear(); |
59 | 59 | ||
60 | if (mLAIfactor>0 || fromEstablishment==true) { |
60 | if (mLAIfactor>0 || fromEstablishment==true) { |
61 | // execute the water calculation...
|
61 | // execute the water calculation...
|
62 | if (fromEstablishment) |
62 | if (fromEstablishment) |
63 | const_cast<WaterCycle*>(mRU->waterCycle())->run(); // run the water sub model (only if this has not be done already) |
63 | const_cast<WaterCycle*>(mRU->waterCycle())->run(); // run the water sub model (only if this has not be done already) |
64 | DebugTimer rst("response+3pg"); |
64 | DebugTimer rst("response+3pg"); |
65 | mResponse.calculate();// calculate environmental responses per species (vpd, temperature, ...) |
65 | mResponse.calculate();// calculate environmental responses per species (vpd, temperature, ...) |
66 | m3PG.calculate();// production of NPP |
66 | m3PG.calculate();// production of NPP |
67 | mLastYear = GlobalSettings::instance()->currentYear(); // mark this year as processed |
67 | mLastYear = GlobalSettings::instance()->currentYear(); // mark this year as processed |
68 | } else { |
68 | } else { |
69 | // if no LAI is present, then just clear the respones.
|
69 | // if no LAI is present, then just clear the respones.
|
70 | mResponse.clear(); |
70 | mResponse.clear(); |
71 | m3PG.clear(); |
71 | m3PG.clear(); |
72 | }
|
72 | }
|
73 | }
|
73 | }
|
74 | 74 | ||
75 | 75 | ||
76 | void ResourceUnitSpecies::updateGWL() |
76 | void ResourceUnitSpecies::updateGWL() |
77 | {
|
77 | {
|
78 | // removed growth is the running sum of all removed
|
78 | // removed growth is the running sum of all removed
|
79 | // tree volume. the current "GWL" therefore is current volume (standing) + mRemovedGrowth.
|
79 | // tree volume. the current "GWL" therefore is current volume (standing) + mRemovedGrowth.
|
80 | mRemovedGrowth+=statisticsDead().volume() + statisticsMgmt().volume(); |
80 | mRemovedGrowth+=statisticsDead().volume() + statisticsMgmt().volume(); |
81 | }
|
81 | }
|
82 | 82 | ||
83 | void ResourceUnitSpecies::calclulateEstablishment() |
- | |
- | 83 | void ResourceUnitSpecies::calculateEstablishment() |
|
84 | {
|
84 | {
|
85 | mEstablishment.calculate(); |
85 | mEstablishment.calculate(); |
86 | //DBGMODE(
|
86 | //DBGMODE(
|
87 | if (GlobalSettings::instance()->isDebugEnabled(GlobalSettings::dEstablishment)) { |
87 | if (GlobalSettings::instance()->isDebugEnabled(GlobalSettings::dEstablishment)) { |
88 | DebugList &out = GlobalSettings::instance()->debugList(ru()->index(), GlobalSettings::dEstablishment); |
88 | DebugList &out = GlobalSettings::instance()->debugList(ru()->index(), GlobalSettings::dEstablishment); |
89 | // establishment details
|
89 | // establishment details
|
90 | out << mSpecies->id() << ru()->index() << ru()->id(); |
90 | out << mSpecies->id() << ru()->index() << ru()->id(); |
91 | out << mEstablishment.avgSeedDensity(); |
91 | out << mEstablishment.avgSeedDensity(); |
92 | out << mEstablishment.TACAminTemp() << mEstablishment.TACAchill() << mEstablishment.TACAfrostFree() << mEstablishment.TACgdd(); |
92 | out << mEstablishment.TACAminTemp() << mEstablishment.TACAchill() << mEstablishment.TACAfrostFree() << mEstablishment.TACgdd(); |
93 | out << mEstablishment.TACAfrostDaysAfterBudBirst() << mEstablishment.abioticEnvironment(); |
93 | out << mEstablishment.TACAfrostDaysAfterBudBirst() << mEstablishment.abioticEnvironment(); |
94 | out << m3PG.fEnvYear() << mEstablishment.avgLIFValue() << mEstablishment.numberEstablished(); |
94 | out << m3PG.fEnvYear() << mEstablishment.avgLIFValue() << mEstablishment.numberEstablished(); |
95 | out << mSapling.livingSaplings() << mSapling.averageHeight() << mSapling.averageAge() << mSapling.averageDeltaHPot() << mSapling.averageDeltaHRealized(); |
95 | out << mSapling.livingSaplings() << mSapling.averageHeight() << mSapling.averageAge() << mSapling.averageDeltaHPot() << mSapling.averageDeltaHRealized(); |
96 | out << mSapling.newSaplings() << mSapling.diedSaplings() << mSapling.recruitedSaplings() << mSpecies->saplingGrowthParameters().referenceRatio; |
96 | out << mSapling.newSaplings() << mSapling.diedSaplings() << mSapling.recruitedSaplings() << mSpecies->saplingGrowthParameters().referenceRatio; |
97 | }
|
97 | }
|
98 | //); // DBGMODE()
|
98 | //); // DBGMODE()
|
99 | 99 | ||
100 | 100 | ||
101 | if ( logLevelDebug() ) |
101 | if ( logLevelDebug() ) |
102 | qDebug() << "establishment of RU" << mRU->index() << "species" << species()->id() |
102 | qDebug() << "establishment of RU" << mRU->index() << "species" << species()->id() |
103 | << "seeds density:" << mEstablishment.avgSeedDensity() |
103 | << "seeds density:" << mEstablishment.avgSeedDensity() |
104 | << "abiotic environment:" << mEstablishment.abioticEnvironment() |
104 | << "abiotic environment:" << mEstablishment.abioticEnvironment() |
105 | << "f_env,yr:" << m3PG.fEnvYear() |
105 | << "f_env,yr:" << m3PG.fEnvYear() |
106 | << "N(established):" << mEstablishment.numberEstablished(); |
106 | << "N(established):" << mEstablishment.numberEstablished(); |
107 | 107 | ||
108 | }
|
108 | }
|
109 | 109 | ||
110 | void ResourceUnitSpecies::calclulateSaplingGrowth() |
110 | void ResourceUnitSpecies::calclulateSaplingGrowth() |
111 | {
|
111 | {
|
112 | mSapling.calculateGrowth(); |
112 | mSapling.calculateGrowth(); |
113 | }
|
113 | }
|
114 | 114 | ||
115 | void ResourceUnitSpecies::visualGrid(Grid<float> &grid) const |
115 | void ResourceUnitSpecies::visualGrid(Grid<float> &grid) const |
116 | {
|
116 | {
|
117 | mSapling.fillMaxHeightGrid(grid); |
117 | mSapling.fillMaxHeightGrid(grid); |
118 | }
|
118 | }
|
119 | 119 | ||
120 | 120 | ||
121 | 121 |