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