Subversion Repositories public iLand

Rev

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

Rev Author Line No. Line
1
 
92 Werner 2
/** @class RessourceUnit
3
  RessourceUnit is the spatial unit that encapsulates a forest stand and links to several environmental components
4
  (Climate, Soil, Water, ...).
5
 
6
  */
7
#include <QtCore>
8
#include "global.h"
9
 
10
#include "ressourceunit.h"
111 Werner 11
#include "speciesset.h"
12
#include "species.h"
113 Werner 13
#include "production3pg.h"
92 Werner 14
 
111 Werner 15
 
113 Werner 16
RessourceUnit::RessourceUnit(const int index)
92 Werner 17
{
94 Werner 18
    mSpeciesSet = 0;
113 Werner 19
    mIndex = index;
92 Werner 20
}
105 Werner 21
 
111 Werner 22
/// set species and setup the species-per-RU-data
23
void RessourceUnit::setSpeciesSet(SpeciesSet *set)
24
{
25
    mSpeciesSet = set;
26
    mRUSpecies.clear();
27
    for (int i=0;i<set->count();i++) {
28
        Species *s = const_cast<Species*>(mSpeciesSet->species(i));
29
        if (!s)
30
            throw IException("RessourceUnit::setSpeciesSet: invalid index!");
31
        RessourceUnitSpecies rus(s, this);
32
        mRUSpecies.append(rus);
33
    }
34
}
35
 
36
RessourceUnitSpecies &RessourceUnit::ressourceUnitSpecies(const Species *species)
37
{
38
    return mRUSpecies[species->index()];
39
}
40
 
105 Werner 41
Tree &RessourceUnit::newTree()
42
{
43
    // start simple: just append to the vector...
44
    mTrees.append(Tree());
45
    return mTrees.back();
46
}
107 Werner 47
 
48
 
49
void RessourceUnit::newYear()
50
{
51
    mAggregatedWLA = 0.f;
110 Werner 52
    mAggregatedLA = 0.f;
111 Werner 53
    // clear statistics global and per species...
107 Werner 54
}
110 Werner 55
 
112 Werner 56
/** production() is the "stand-level" part of the biomass production (3PG).
57
    - The amount of radiation intercepted by the stand is calculated
58
    - The 3PG production for each species and ressource unit is invoked  */
59
void RessourceUnit::production()
110 Werner 60
{
112 Werner 61
    if (mAggregatedWLA==0) {
62
        // nothing to do...
63
        return;
64
    }
65
    // calculate the leaf area index (LAI)
66
    const double stockedRUArea = 10000; // m2 of stocked area
67
    double LAI = mAggregatedLA / stockedRUArea;
68
    // calculate the intercepted radiation fraction using the law of Beer Lambert
69
    const double k = 0.6;
70
    double interception_fraction = 1. - exp(-k * LAI);
71
    // calculate the amount of radiation available on this ressource unit
113 Werner 72
    const double I_year_m2 = 3140; // incoming radiation sum of year in MJ/m2*year
112 Werner 73
    // incoming: I for the RU area (only stocked!) and reduced with beer-lambert
113 Werner 74
    mInterceptedRadiation = I_year_m2 * stockedRUArea * interception_fraction;
112 Werner 75
    mIntercepted_per_WLA = mInterceptedRadiation / mAggregatedWLA;
76
 
113 Werner 77
//    qDebug() << QString("production: LAI: %1 avg. WLA: %4 intercepted-fraction: %2 intercept per WLA: %3")
78
//            .arg(LAI).arg(interception_fraction)
79
//            .arg(mIntercepted_per_WLA)
80
//            .arg(mAggregatedWLA/mAggregatedLA);
112 Werner 81
 
82
    // invoke species specific calculation (3PG)
83
    QVector<RessourceUnitSpecies>::iterator i;
84
    QVector<RessourceUnitSpecies>::iterator iend = mRUSpecies.end();
113 Werner 85
 
115 Werner 86
 
113 Werner 87
    double raw_gpp_per_rad;
112 Werner 88
    for (i=mRUSpecies.begin(); i!=iend; ++i) {
115 Werner 89
        (*i).prod3PG().calculate();
113 Werner 90
//        qDebug() << "species" << (*i).species()->id() << "raw_gpp_per_rad" << raw_gpp_per_rad;
112 Werner 91
    }
110 Werner 92
}
93