Subversion Repositories public iLand

Rev

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

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