iLand
speciesset.h
Go to the documentation of this file.
1/********************************************************************************************
2** iLand - an individual based forest landscape and disturbance model
3** http://iland-model.org
4** Copyright (C) 2009- Werner Rammer, Rupert Seidl
5**
6** This program is free software: you can redistribute it and/or modify
7** it under the terms of the GNU General Public License as published by
8** the Free Software Foundation, either version 3 of the License, or
9** (at your option) any later version.
10**
11** This program is distributed in the hope that it will be useful,
12** but WITHOUT ANY WARRANTY; without even the implied warranty of
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14** GNU General Public License for more details.
15**
16** You should have received a copy of the GNU General Public License
17** along with this program. If not, see <http://www.gnu.org/licenses/>.
18********************************************************************************************/
19
20#ifndef SPECIESSET_H
21#define SPECIESSET_H
22#include <QtSql>
23
24#include "stampcontainer.h"
25#include "expression.h"
26class Species;
27class SeedDispersal;
28
30{
31public:
32 SpeciesSet();
34 const QString &name() const { return mName; }
35 // access
36 QList<Species*> activeSpecies() const { return mActiveSpecies; }
37 Species *species(const QString &speciesId) const { return mSpecies.value(speciesId); }
38 const Species *species(const int &index);
39 const StampContainer &readerStamps() { return mReaderStamp; }
40 bool hasVar(const QString& varName);
41 QVariant var(const QString& varName);
42 int count() const { return mSpecies.count(); }
44 void randomSpeciesOrder(QVector<int>::const_iterator &rBegin, QVector<int>::const_iterator &rEnd);
45 // properties
46 // calculations
47 double nitrogenResponse(const double availableNitrogen, const double &responseClass) const;
48 double co2Response(const double ambientCO2, const double nitrogenResponse, const double soilWaterResponse) const;
49 double lightResponse(const double lightResourceIndex, const double lightResponseClass) const;
50 double LRIcorrection(const double lightResourceIndex, const double relativeHeight) const { return mLRICorrection.calculate(lightResourceIndex, relativeHeight);}
51 // maintenance
52 void clear();
53 int setup();
54 void setupRegeneration();
55 // running
56 void newYear();
57 void regeneration();
58 void clearSaplingSeedMap();
59private:
60 QString mName;
61 double nitrogenResponse(const double &availableNitrogen, const double &NA, const double &NB) const;
62 void createRandomSpeciesOrder();
63 QList<Species*> mActiveSpecies;
64 QMap<QString, Species*> mSpecies;
65 static const int mNRandomSets = 20;
66 QVector<int> mRandomSpeciesOrder;
67 QSqlQuery *mSetupQuery;
68 StampContainer mReaderStamp;
69 // nitrogen response classes
70 double mNitrogen_1a, mNitrogen_1b;
71 double mNitrogen_2a, mNitrogen_2b;
72 double mNitrogen_3a, mNitrogen_3b;
73 // CO2 response
74 double mCO2base, mCO2comp;
75 double mCO2p0, mCO2beta0;
76 // Light Response classes
77 Expression mLightResponseIntolerant;
78 Expression mLightResponseTolerant;
79 Expression mLRICorrection;
80
81};
82
83#endif // SPECIESSET_H
An expression engine for mathematical expressions provided as strings.
Definition: expression.h:29
double calculate(const double Val1=0., const double Val2=0., const bool forceExecution=false) const
calculate formula.
Definition: expression.cpp:487
The class encapsulates the dispersal of seeds of one species over the whole landscape.
Definition: seeddispersal.h:28
The behavior and general properties of tree species.
Definition: species.h:75
A SpeciesSet acts as a container for individual Species objects.
Definition: speciesset.h:30
bool hasVar(const QString &varName)
test if variable exists
Definition: speciesset.cpp:63
double co2Response(const double ambientCO2, const double nitrogenResponse, const double soilWaterResponse) const
calculation for the CO2 response for the ambientCO2 for the water- and nitrogen responses given.
Definition: speciesset.cpp:296
const QString & name() const
table name of the species set
Definition: speciesset.h:34
double lightResponse(const double lightResourceIndex, const double lightResponseClass) const
calculates the lightResponse based on a value for LRI and the species lightResponseClass.
Definition: speciesset.cpp:320
SpeciesSet()
Definition: speciesset.cpp:38
void setupRegeneration()
setup of regenartion related data
Definition: speciesset.cpp:159
void clearSaplingSeedMap()
clear the seed maps that collect leaf area for saplings
Definition: speciesset.cpp:189
~SpeciesSet()
Definition: speciesset.cpp:43
void newYear()
is called at the beginning of a year
Definition: speciesset.cpp:200
void regeneration()
run regeneration (after growth)
Definition: speciesset.cpp:176
void randomSpeciesOrder(QVector< int >::const_iterator &rBegin, QVector< int >::const_iterator &rEnd)
return 2 iterators. The range between 'rBegin' and 'rEnd' are indices of the current species set (all...
Definition: speciesset.cpp:229
int setup()
loads active species from a database table and creates/setups the species.
Definition: speciesset.cpp:76
QVariant var(const QString &varName)
return variable as QVariant
Definition: speciesset.cpp:211
Species * species(const QString &speciesId) const
Definition: speciesset.h:37
double nitrogenResponse(const double availableNitrogen, const double &responseClass) const
calculate nitrogen response for a given amount of available nitrogen and a respone class for fraction...
Definition: speciesset.cpp:266
int count() const
Definition: speciesset.h:42
QList< Species * > activeSpecies() const
list of species that are "active" (flag active in database)
Definition: speciesset.h:36
const StampContainer & readerStamps()
Definition: speciesset.h:39
double LRIcorrection(const double lightResourceIndex, const double relativeHeight) const
Definition: speciesset.h:50
void clear()
Definition: speciesset.cpp:48
Collection of Stamp for one tree species.
Definition: stampcontainer.h:33