Subversion Repositories public iLand

Rev

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