Subversion Repositories public iLand

Rev

Rev 639 | Rev 779 | 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"
626 werner 9
#include "helper.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
{
438 werner 53
    if (mLastYear == GlobalSettings::instance()->currentYear())
54
        return;
55
 
518 werner 56
    // the call *not* from establishment
57
    if (!fromEstablishment)
58
        statistics().clear();
513 werner 59
 
440 werner 60
    if (mLAIfactor>0 || fromEstablishment==true) {
496 werner 61
        // execute the water calculation...
62
        if (fromEstablishment)
63
            const_cast<WaterCycle*>(mRU->waterCycle())->run(); // run the water sub model (only if this has not be done already)
626 werner 64
        DebugTimer rst("response+3pg");
496 werner 65
        mResponse.calculate();// calculate environmental responses per species (vpd, temperature, ...)
66
        m3PG.calculate();// production of NPP
513 werner 67
        mLastYear = GlobalSettings::instance()->currentYear(); // mark this year as processed
369 werner 68
    } else {
69
        // if no LAI is present, then just clear the respones.
70
        mResponse.clear();
71
        m3PG.clear();
72
    }
226 werner 73
}
277 werner 74
 
75
 
76
void ResourceUnitSpecies::updateGWL()
77
{
78
    // removed growth is the running sum of all removed
79
    // tree volume. the current "GWL" therefore is current volume (standing) + mRemovedGrowth.
278 werner 80
    mRemovedGrowth+=statisticsDead().volume() + statisticsMgmt().volume();
277 werner 81
}
440 werner 82
 
83
void ResourceUnitSpecies::calclulateEstablishment()
84
{
85
    mEstablishment.calculate();
442 werner 86
    //DBGMODE(
87
        if (GlobalSettings::instance()->isDebugEnabled(GlobalSettings::dEstablishment)) {
88
            DebugList &out = GlobalSettings::instance()->debugList(ru()->index(), GlobalSettings::dEstablishment);
89
            // establishment details
605 werner 90
            out << mSpecies->id() << ru()->index() << ru()->id();
442 werner 91
            out << mEstablishment.avgSeedDensity();
92
            out << mEstablishment.TACAminTemp() << mEstablishment.TACAchill() << mEstablishment.TACAfrostFree() << mEstablishment.TACgdd();
93
            out << mEstablishment.TACAfrostDaysAfterBudBirst() << mEstablishment.abioticEnvironment();
94
            out << m3PG.fEnvYear() << mEstablishment.avgLIFValue() << mEstablishment.numberEstablished();
466 werner 95
            out << mSapling.livingSaplings() << mSapling.averageHeight() << mSapling.averageAge() << mSapling.averageDeltaHPot() << mSapling.averageDeltaHRealized();
471 werner 96
            out << mSapling.newSaplings() << mSapling.diedSaplings() << mSapling.recruitedSaplings() << mSpecies->saplingGrowthParameters().referenceRatio;
442 werner 97
        }
98
    //); // DBGMODE()
440 werner 99
 
442 werner 100
 
440 werner 101
    if ( logLevelDebug() )
102
        qDebug() << "establishment of RU" << mRU->index() << "species" << species()->id()
103
        << "seeds density:" << mEstablishment.avgSeedDensity()
104
        << "abiotic environment:" << mEstablishment.abioticEnvironment()
105
        << "f_env,yr:" << m3PG.fEnvYear()
106
        << "N(established):" << mEstablishment.numberEstablished();
107
 
108
}
450 werner 109
 
110
void ResourceUnitSpecies::calclulateSaplingGrowth()
111
{
112
    mSapling.calculateGrowth();
113
}
453 werner 114
 
115
void ResourceUnitSpecies::visualGrid(Grid<float> &grid) const
116
{
564 werner 117
    mSapling.fillMaxHeightGrid(grid);
453 werner 118
}
462 werner 119
 
475 werner 120