Subversion Repositories public iLand

Rev

Rev 1221 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1221 Rev 1222
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
/********************************************************************************************
2
/********************************************************************************************
3
**    iLand - an individual based forest landscape and disturbance model
3
**    iLand - an individual based forest landscape and disturbance model
4
**    http://iland.boku.ac.at
4
**    http://iland.boku.ac.at
5
**    Copyright (C) 2009-  Werner Rammer, Rupert Seidl
5
**    Copyright (C) 2009-  Werner Rammer, Rupert Seidl
6
**
6
**
7
**    This program is free software: you can redistribute it and/or modify
7
**    This program is free software: you can redistribute it and/or modify
8
**    it under the terms of the GNU General Public License as published by
8
**    it under the terms of the GNU General Public License as published by
9
**    the Free Software Foundation, either version 3 of the License, or
9
**    the Free Software Foundation, either version 3 of the License, or
10
**    (at your option) any later version.
10
**    (at your option) any later version.
11
**
11
**
12
**    This program is distributed in the hope that it will be useful,
12
**    This program is distributed in the hope that it will be useful,
13
**    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
**    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
**    GNU General Public License for more details.
15
**    GNU General Public License for more details.
16
**
16
**
17
**    You should have received a copy of the GNU General Public License
17
**    You should have received a copy of the GNU General Public License
18
**    along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
**    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
********************************************************************************************/
19
********************************************************************************************/
20
20
21
21
22
#include "global.h"
22
#include "global.h"
23
#include "resourceunitspecies.h"
23
#include "resourceunitspecies.h"
24
24
25
#include "species.h"
25
#include "species.h"
26
#include "resourceunit.h"
26
#include "resourceunit.h"
27
#include "model.h"
27
#include "model.h"
28
#include "watercycle.h"
28
#include "watercycle.h"
29
#include "debugtimer.h"
29
#include "debugtimer.h"
30
30
31
/** @class ResourceUnitSpecies
31
/** @class ResourceUnitSpecies
32
  @ingroup core
32
  @ingroup core
33
    The class contains data available at ResourceUnit x Species scale.
33
    The class contains data available at ResourceUnit x Species scale.
34
    Data stored is either statistical (i.e. number of trees per species) or used
34
    Data stored is either statistical (i.e. number of trees per species) or used
35
    within the model (e.g. fraction of utilizable Radiation).
35
    within the model (e.g. fraction of utilizable Radiation).
36
    Important submodules are:
36
    Important submodules are:
37
    * 3PG production (Production3PG)
37
    * 3PG production (Production3PG)
38
    * Establishment
38
    * Establishment
39
    * Growth and Recruitment of Saplings
39
    * Growth and Recruitment of Saplings
40
    * Snag dynamics
40
    * Snag dynamics
41
  */
41
  */
42
ResourceUnitSpecies::~ResourceUnitSpecies()
42
ResourceUnitSpecies::~ResourceUnitSpecies()
43
{
43
{
44
}
44
}
45
45
46
double ResourceUnitSpecies::leafArea() const
46
double ResourceUnitSpecies::leafArea() const
47
{
47
{
48
    // Leaf area of the species:
48
    // Leaf area of the species:
49
    // total leaf area on the RU * fraction of leafarea
49
    // total leaf area on the RU * fraction of leafarea
50
    return mLAIfactor * ru()->leafAreaIndex();
50
    return mLAIfactor * ru()->leafAreaIndex();
51
}
51
}
52
52
53
void ResourceUnitSpecies::setup(Species *species, ResourceUnit *ru)
53
void ResourceUnitSpecies::setup(Species *species, ResourceUnit *ru)
54
{
54
{
55
    mSpecies = species;
55
    mSpecies = species;
56
    mRU = ru;
56
    mRU = ru;
57
    mResponse.setup(this);
57
    mResponse.setup(this);
58
    m3PG.setResponse(&mResponse);
58
    m3PG.setResponse(&mResponse);
59
    mEstablishment.setup(ru->climate(), this);
59
    mEstablishment.setup(ru->climate(), this);
60
    mStatistics.setResourceUnitSpecies(this);
60
    mStatistics.setResourceUnitSpecies(this);
61
    mStatisticsDead.setResourceUnitSpecies(this);
61
    mStatisticsDead.setResourceUnitSpecies(this);
62
    mStatisticsMgmt.setResourceUnitSpecies(this);
62
    mStatisticsMgmt.setResourceUnitSpecies(this);
63
63
64
    mRemovedGrowth = 0.;
64
    mRemovedGrowth = 0.;
65
    mLastYear = -1;
65
    mLastYear = -1;
66
66
67
    DBGMODE( if(mSpecies->index()>1000 || mSpecies->index()<0)
67
    DBGMODE( if(mSpecies->index()>1000 || mSpecies->index()<0)
68
             qDebug() << "suspicious species?? in RUS::setup()";
68
             qDebug() << "suspicious species?? in RUS::setup()";
69
                );
69
                );
70
70
71
}
71
}
72
72
73
73
74
void ResourceUnitSpecies::calculate(const bool fromEstablishment)
74
void ResourceUnitSpecies::calculate(const bool fromEstablishment)
75
{
75
{
76
76
77
    // if *not* called from establishment, clear the species-level-stats
77
    // if *not* called from establishment, clear the species-level-stats
78
    if (!fromEstablishment)
78
    if (!fromEstablishment)
79
        statistics().clear();
79
        statistics().clear();
80
80
81
    // if already processed in this year, do not repeat
81
    // if already processed in this year, do not repeat
82
    if (mLastYear == GlobalSettings::instance()->currentYear())
82
    if (mLastYear == GlobalSettings::instance()->currentYear())
83
        return;
83
        return;
84
84
85
    if (mLAIfactor>0. || fromEstablishment==true) {
85
    if (mLAIfactor>0. || fromEstablishment==true) {
86
        // execute the water calculation...
86
        // execute the water calculation...
87
        if (fromEstablishment)
87
        if (fromEstablishment)
88
            const_cast<WaterCycle*>(mRU->waterCycle())->run(); // run the water sub model (only if this has not be done already)
88
            const_cast<WaterCycle*>(mRU->waterCycle())->run(); // run the water sub model (only if this has not be done already)
89
        DebugTimer rst("response+3pg");
89
        DebugTimer rst("response+3pg");
90
        mResponse.calculate();// calculate environmental responses per species (vpd, temperature, ...)
90
        mResponse.calculate();// calculate environmental responses per species (vpd, temperature, ...)
91
        m3PG.calculate();// production of NPP
91
        m3PG.calculate();// production of NPP
92
        mLastYear = GlobalSettings::instance()->currentYear(); // mark this year as processed
92
        mLastYear = GlobalSettings::instance()->currentYear(); // mark this year as processed
93
    } else {
93
    } else {
94
        // if no LAI is present, then just clear the respones.
94
        // if no LAI is present, then just clear the respones.
95
        mResponse.clear();
95
        mResponse.clear();
96
        m3PG.clear();
96
        m3PG.clear();
97
    }
97
    }
98
}
98
}
99
99
100
100
101
void ResourceUnitSpecies::updateGWL()
101
void ResourceUnitSpecies::updateGWL()
102
{
102
{
103
    // removed growth is the running sum of all removed
103
    // removed growth is the running sum of all removed
104
    // tree volume. the current "GWL" therefore is current volume (standing) + mRemovedGrowth.
104
    // tree volume. the current "GWL" therefore is current volume (standing) + mRemovedGrowth.
105
    // important: statisticsDead() and statisticsMgmt() need to calculate() before -> volume() is already scaled to ha
105
    // important: statisticsDead() and statisticsMgmt() need to calculate() before -> volume() is already scaled to ha
106
    mRemovedGrowth+=statisticsDead().volume() + statisticsMgmt().volume();
106
    mRemovedGrowth+=statisticsDead().volume() + statisticsMgmt().volume();
107
}
107
}
108
108
109
109
110
110
111
 
111