Subversion Repositories public iLand

Rev

Rev 466 | Rev 471 | 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"
8
#include "snag.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
    if (mSnag)
23
        delete mSnag;
24
    mSnag = 0;
25
}
440 werner 26
 
376 werner 27
double ResourceUnitSpecies::leafArea() const
28
{
29
    // Leaf area of the species:
30
    // total leaf area on the RU * fraction of leafarea
31
    return mLAIfactor * ru()->leafAreaIndex();
32
}
33
 
235 werner 34
void ResourceUnitSpecies::setup(Species *species, ResourceUnit *ru)
35
{
36
    mSpecies = species;
37
    mRU = ru;
38
    mResponse.setup(this);
39
    m3PG.setResponse(&mResponse);
440 werner 40
    mEstablishment.setup(ru->climate(), this);
452 werner 41
    mSapling.setup(this);
235 werner 42
    mStatistics.setResourceUnitSpecies(this);
277 werner 43
    mStatisticsDead.setResourceUnitSpecies(this);
278 werner 44
    mStatisticsMgmt.setResourceUnitSpecies(this);
468 werner 45
    if (mSnag)
46
        delete mSnag;
47
    mSnag=0;
48
    if (Model::settings().carbonCycleEnabled) {
49
       mSnag = new Snag;
50
       mSnag->setup();
51
    }
440 werner 52
 
277 werner 53
    mRemovedGrowth = 0.;
438 werner 54
    mLastYear = -1;
468 werner 55
 
235 werner 56
}
111 Werner 57
 
58
 
440 werner 59
void ResourceUnitSpecies::calculate(const bool fromEstablishment)
226 werner 60
{
438 werner 61
    if (mLastYear == GlobalSettings::instance()->currentYear())
62
        return;
63
    mLastYear = GlobalSettings::instance()->currentYear();
64
 
65
    statistics().clear();
440 werner 66
    if (mLAIfactor>0 || fromEstablishment==true) {
369 werner 67
        mResponse.calculate();///< calculate environmental responses per species (vpd, temperature, ...)
68
        m3PG.calculate();///< production of NPP
69
    } else {
70
        // if no LAI is present, then just clear the respones.
376 werner 71
        // note: subject to change when regeneration is added...
369 werner 72
        mResponse.clear();
73
        m3PG.clear();
74
    }
226 werner 75
}
277 werner 76
 
77
 
78
void ResourceUnitSpecies::updateGWL()
79
{
80
    // removed growth is the running sum of all removed
81
    // tree volume. the current "GWL" therefore is current volume (standing) + mRemovedGrowth.
278 werner 82
    mRemovedGrowth+=statisticsDead().volume() + statisticsMgmt().volume();
277 werner 83
}
440 werner 84
 
85
void ResourceUnitSpecies::calclulateEstablishment()
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
92
            out << mSpecies->id() << ru()->index();
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();
98
            out << mSapling.newSaplings() << mSapling.diedSaplings() << mSapling.recruitedSaplings();
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
{
119
    mSapling.fillHeightGrid(grid);
120
}
462 werner 121