Subversion Repositories public iLand

Rev

Rev 458 | Rev 466 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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