Subversion Repositories public iLand

Rev

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

Rev 1220 Rev 1221
1
Redirecting to URL 'https://iland.boku.ac.at/svn/iland/tags/release_1.0/src/core/speciesset.h':
1
Redirecting to URL 'https://iland.boku.ac.at/svn/iland/tags/release_1.0/src/core/speciesset.h':
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
#ifndef SPECIESSET_H
21
#ifndef SPECIESSET_H
22
#define SPECIESSET_H
22
#define SPECIESSET_H
23
#include <QtSql>
23
#include <QtSql>
24
24
25
#include "stampcontainer.h"
25
#include "stampcontainer.h"
26
#include "expression.h"
26
#include "expression.h"
27
class Species;
27
class Species;
28
class SeedDispersal;
28
class SeedDispersal;
29
29
30
class SpeciesSet
30
class SpeciesSet
31
{
31
{
32
public:
32
public:
33
    SpeciesSet();
33
    SpeciesSet();
34
    ~SpeciesSet();
34
    ~SpeciesSet();
35
    const QString &name() const { return mName; } ///< table name of the species set
35
    const QString &name() const { return mName; } ///< table name of the species set
36
    // access
36
    // access
37
    QList<Species*> activeSpecies() { return mActiveSpecies; } ///< list of species that are "active" (flag active in database)
37
    QList<Species*> activeSpecies() { return mActiveSpecies; } ///< list of species that are "active" (flag active in database)
38
    Species *species(const QString &speciesId) const { return mSpecies.value(speciesId); }
38
    Species *species(const QString &speciesId) const { return mSpecies.value(speciesId); }
39
    const Species *species(const int &index); ///< get by arbirtray index (slower than using string-id!)
39
    const Species *species(const int &index); ///< get by arbirtray index (slower than using string-id!)
40
    const StampContainer &readerStamps() { return mReaderStamp; }
40
    const StampContainer &readerStamps() { return mReaderStamp; }
41
    QVariant var(const QString& varName);
41
    QVariant var(const QString& varName);
42
    int count() const { return mSpecies.count(); }
42
    int count() const { return mSpecies.count(); }
43
    /// return 2 iterators. The range between 'rBegin' and 'rEnd' are indices of the current species set (all species are included, order is random).
43
    /// return 2 iterators. The range between 'rBegin' and 'rEnd' are indices of the current species set (all species are included, order is random).
44
    void randomSpeciesOrder(QVector<int>::const_iterator &rBegin, QVector<int>::const_iterator &rEnd);
44
    void randomSpeciesOrder(QVector<int>::const_iterator &rBegin, QVector<int>::const_iterator &rEnd);
45
    // calculations
45
    // calculations
46
    double nitrogenResponse(const double availableNitrogen, const double &responseClass) const;
46
    double nitrogenResponse(const double availableNitrogen, const double &responseClass) const;
47
    double co2Response(const double ambientCO2, const double nitrogenResponse, const double soilWaterResponse) const;
47
    double co2Response(const double ambientCO2, const double nitrogenResponse, const double soilWaterResponse) const;
48
    double lightResponse(const double lightResourceIndex, const double lightResponseClass) const;
48
    double lightResponse(const double lightResourceIndex, const double lightResponseClass) const;
49
    double LRIcorrection(const double lightResourceIndex, const double relativeHeight) const  { return mLRICorrection.calculate(lightResourceIndex, relativeHeight);}
49
    double LRIcorrection(const double lightResourceIndex, const double relativeHeight) const  { return mLRICorrection.calculate(lightResourceIndex, relativeHeight);}
50
    // maintenance
50
    // maintenance
51
    void clear();
51
    void clear();
52
    int setup();
52
    int setup();
53
    void setupRegeneration(); ///< setup of regenartion related data
53
    void setupRegeneration(); ///< setup of regenartion related data
54
    // running
54
    // running
55
    void newYear(); ///< is called at the beginning of a year
55
    void newYear(); ///< is called at the beginning of a year
56
    void regeneration(); ///< run regeneration (after growth)
56
    void regeneration(); ///< run regeneration (after growth)
57
private:
57
private:
58
    QString mName;
58
    QString mName;
59
    double nitrogenResponse(const double &availableNitrogen, const double &NA, const double &NB) const;
59
    double nitrogenResponse(const double &availableNitrogen, const double &NA, const double &NB) const;
60
    void createRandomSpeciesOrder();
60
    void createRandomSpeciesOrder();
61
    QList<Species*> mActiveSpecies; ///< list of species that are "active" (flag active in database)
61
    QList<Species*> mActiveSpecies; ///< list of species that are "active" (flag active in database)
62
    QMap<QString, Species*> mSpecies;
62
    QMap<QString, Species*> mSpecies;
63
    static const int mNRandomSets = 20;
63
    static const int mNRandomSets = 20;
64
    QVector<int> mRandomSpeciesOrder;
64
    QVector<int> mRandomSpeciesOrder;
65
    QSqlQuery *mSetupQuery;
65
    QSqlQuery *mSetupQuery;
66
    StampContainer mReaderStamp;
66
    StampContainer mReaderStamp;
67
    // nitrogen response classes
67
    // nitrogen response classes
68
    double mNitrogen_1a, mNitrogen_1b; ///< parameters of nitrogen response class 1
68
    double mNitrogen_1a, mNitrogen_1b; ///< parameters of nitrogen response class 1
69
    double mNitrogen_2a, mNitrogen_2b; ///< parameters of nitrogen response class 2
69
    double mNitrogen_2a, mNitrogen_2b; ///< parameters of nitrogen response class 2
70
    double mNitrogen_3a, mNitrogen_3b; ///< parameters of nitrogen response class 3
70
    double mNitrogen_3a, mNitrogen_3b; ///< parameters of nitrogen response class 3
71
    // CO2 response
71
    // CO2 response
72
    double mCO2base, mCO2comp; ///< CO2 concentration of measurements (base) and CO2 compensation point (comp)
72
    double mCO2base, mCO2comp; ///< CO2 concentration of measurements (base) and CO2 compensation point (comp)
73
    double mCO2p0, mCO2beta0; ///< p0: production multiplier, beta0: relative productivity increase
73
    double mCO2p0, mCO2beta0; ///< p0: production multiplier, beta0: relative productivity increase
74
    // Light Response classes
74
    // Light Response classes
75
    Expression mLightResponseIntolerant; ///< light response function for the the most shade tolerant species
75
    Expression mLightResponseIntolerant; ///< light response function for the the most shade tolerant species
76
    Expression mLightResponseTolerant; ///< light response function for the most shade intolerant species
76
    Expression mLightResponseTolerant; ///< light response function for the most shade intolerant species
77
    Expression mLRICorrection; ///< function to modfiy LRI during read
77
    Expression mLRICorrection; ///< function to modfiy LRI during read
78
    /// container holding the seed maps
78
    /// container holding the seed maps
79
    QList<SeedDispersal*> mSeedDispersal;
79
    QList<SeedDispersal*> mSeedDispersal;
80
80
81
};
81
};
82
82
83
#endif // SPECIESSET_H
83
#endif // SPECIESSET_H
84
 
84