Subversion Repositories public iLand

Rev

Rev 452 | Rev 458 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1
 
247 werner 2
/** @class ResourceUnitSpecies
3
    The class contains data available at ResourceUnit x Species scale.
111 Werner 4
    Data stored is either statistical (i.e. number of trees per species) or used
5
    within the model (e.g. fraction of utilizable Radiation)
6
  */
7
#include "global.h"
189 iland 8
#include "resourceunitspecies.h"
111 Werner 9
 
10
#include "species.h"
189 iland 11
#include "resourceunit.h"
376 werner 12
 
440 werner 13
 
376 werner 14
double ResourceUnitSpecies::leafArea() const
15
{
16
    // Leaf area of the species:
17
    // total leaf area on the RU * fraction of leafarea
18
    return mLAIfactor * ru()->leafAreaIndex();
19
}
20
 
235 werner 21
void ResourceUnitSpecies::setup(Species *species, ResourceUnit *ru)
22
{
23
    mSpecies = species;
24
    mRU = ru;
25
    mResponse.setup(this);
26
    m3PG.setResponse(&mResponse);
440 werner 27
    mEstablishment.setup(ru->climate(), this);
452 werner 28
    mSapling.setup(this);
235 werner 29
    mStatistics.setResourceUnitSpecies(this);
277 werner 30
    mStatisticsDead.setResourceUnitSpecies(this);
278 werner 31
    mStatisticsMgmt.setResourceUnitSpecies(this);
440 werner 32
 
277 werner 33
    mRemovedGrowth = 0.;
438 werner 34
    mLastYear = -1;
235 werner 35
}
111 Werner 36
 
37
 
440 werner 38
void ResourceUnitSpecies::calculate(const bool fromEstablishment)
226 werner 39
{
438 werner 40
    if (mLastYear == GlobalSettings::instance()->currentYear())
41
        return;
42
    mLastYear = GlobalSettings::instance()->currentYear();
43
 
44
    statistics().clear();
440 werner 45
    if (mLAIfactor>0 || fromEstablishment==true) {
369 werner 46
        mResponse.calculate();///< calculate environmental responses per species (vpd, temperature, ...)
47
        m3PG.calculate();///< production of NPP
48
    } else {
49
        // if no LAI is present, then just clear the respones.
376 werner 50
        // note: subject to change when regeneration is added...
369 werner 51
        mResponse.clear();
52
        m3PG.clear();
53
    }
226 werner 54
}
277 werner 55
 
56
 
57
void ResourceUnitSpecies::updateGWL()
58
{
59
    // removed growth is the running sum of all removed
60
    // tree volume. the current "GWL" therefore is current volume (standing) + mRemovedGrowth.
278 werner 61
    mRemovedGrowth+=statisticsDead().volume() + statisticsMgmt().volume();
277 werner 62
}
440 werner 63
 
64
void ResourceUnitSpecies::calclulateEstablishment()
65
{
66
    mEstablishment.calculate();
442 werner 67
    //DBGMODE(
68
        if (GlobalSettings::instance()->isDebugEnabled(GlobalSettings::dEstablishment)) {
69
            DebugList &out = GlobalSettings::instance()->debugList(ru()->index(), GlobalSettings::dEstablishment);
70
            // establishment details
71
            out << mSpecies->id() << ru()->index();
72
            out << mEstablishment.avgSeedDensity();
73
            out << mEstablishment.TACAminTemp() << mEstablishment.TACAchill() << mEstablishment.TACAfrostFree() << mEstablishment.TACgdd();
74
            out << mEstablishment.TACAfrostDaysAfterBudBirst() << mEstablishment.abioticEnvironment();
75
            out << m3PG.fEnvYear() << mEstablishment.avgLIFValue() << mEstablishment.numberEstablished();
451 werner 76
            out << mSapling.livingSaplings() << mSapling.averageHeight() << mSapling.newSaplings() << mSapling.diedSaplings() << mSapling.recruitedSaplings();
442 werner 77
        }
78
    //); // DBGMODE()
440 werner 79
 
442 werner 80
 
440 werner 81
    if ( logLevelDebug() )
82
        qDebug() << "establishment of RU" << mRU->index() << "species" << species()->id()
83
        << "seeds density:" << mEstablishment.avgSeedDensity()
84
        << "abiotic environment:" << mEstablishment.abioticEnvironment()
85
        << "f_env,yr:" << m3PG.fEnvYear()
86
        << "N(established):" << mEstablishment.numberEstablished();
87
 
88
}
450 werner 89
 
90
void ResourceUnitSpecies::calclulateSaplingGrowth()
91
{
92
    mSapling.calculateGrowth();
93
}
453 werner 94
 
95
void ResourceUnitSpecies::visualGrid(Grid<float> &grid) const
96
{
97
    mSapling.fillHeightGrid(grid);
98
}