iLand
permafrost.h
Go to the documentation of this file.
1#ifndef PERMAFROST_H
2#define PERMAFROST_H
3
4#include "layeredgrid.h"
5
6
7class WaterCycle; // forward
8struct ClimateDay; // forward
9class ResourceUnit; // forward
10class WaterOut; // forward
11
12namespace Water {
13
20{
21public:
22 Permafrost();
24 void setup(WaterCycle *wc);
25
26 //const SStats &stats() const { return stats; }
27
29 void newYear();
30
32 void run(const ClimateDay *clim_day);
33
35 void debugData(DebugList &out);
36
38 double mossLayerThickness() const { return mMossBiomass / mosspar.bulk_density; } // kg/m2 / rho [kg/m3] = m
40 double SOLLayerThickness() const {return mSOLDepth; }
42 double mossBiomass() const { return mMossBiomass; }
44 void burnMoss(const double biomass_kg) { mMossBiomass = mMossBiomass - biomass_kg/cRUArea;
45 mMossBiomass = std::max(mMossBiomass, cMinMossBiomass); }
46
47private:
48 const double cMinMossBiomass = 0.0001; // kg/m2
50 void setupMossLayer();
52 void calculateMoss();
53
54
56 void setupThermalConductivity();
57
59 double thermalConductivity(bool from_below) const;
60 double thermalConductivityFrozen() const;
61
62 struct FTResult {
63 FTResult(): delta_mm(0.), delta_soil(0.), new_depth(0.), orig_depth(0.) {}
64 double delta_mm; // change of water (mm within iLand water bucket), freezing is negative
65 double delta_soil; // change of ice layer (m) (within iLand water bucket), freezing is negative
66 double new_depth; // final depth (m)
67 double orig_depth; // starting depth (m)
68 };
69 FTResult calcFreezeThaw(double at, double temp, bool lowerIceEdge, bool fromAbove);
70 FTResult mResult;
71
72 WaterCycle *mWC;
74 double mCurrentSoilFrozen;
76 double mCurrentWaterFrozen;
78 double mSoilDepth;
79 double mPWP;
80 double mFC;
82 double mTop;
83 bool mTopFrozen;
86 double mBottom;
87 double mFreezeBack;
88
89 double mSOLDepth;
90
91 double mGroundBaseTemperature;
92
94 double mKdry;
96 double mKsat;
98 double mKice;
99 bool mSoilIsCoarse;
100
101 // moss related variables
102 double mMossBiomass;
103 // stats
104 struct SStats {
105 void reset() { maxSnowDepth=0.; daysSnowCover=0; maxFreezeDepth=0.; maxThawDepth=0.; }
106 double maxSnowDepth;
107 int daysSnowCover;
108 double maxFreezeDepth;
109 double maxThawDepth;
110 };
111 SStats stats;
112
113 // parameters of the permafrost model are stored in a static struct
114 // (and exist only once)
115 struct SParam {
116 void init() { EFusion = 0.333; // MJ/litre H20
117 maxPermafrostDepth = 2.; // 2m
118 }
119 // physical constants
120 double EFusion;
121 double maxPermafrostDepth;
122
123 double lambdaSnow;
124 double lambdaOrganicLayer;
125
126 double organicLayerDensity;
127 double SOLDefaultDepth = 0.1;
128
129 // parameters
130 double groundBaseDepth;
131 double maxFreezeThawPerDay;
132
133 bool onlySimulate;
134 };
135
136 struct SMossParam {
137 const double SLA=1.;
138 const double AMax=0.3;
139 double light_k;
140 double light_comp;
141 double light_sat;
142 double respiration_q, respiration_b;
143 double bulk_density;
144 // carbon cycle
145 double CNRatio;
146 double r_decomp;
147 };
148
149 static SParam par;
150 static SMossParam mosspar;
151
152 friend class PermafrostLayers;
153 friend class ::WaterOut;
154};
155
156class PermafrostLayers: public LayeredGrid<ResourceUnit*> {
157 public:
159 void setGrid(const Grid<ResourceUnit*> &grid) { mGrid = &grid; }
160 void clearGrid() { mGrid = nullptr; }
161 double value(ResourceUnit* const &data, const int index) const;
162 const QVector<LayeredGridBase::LayerElement> &names();
163 //bool onClick(const QPointF &world_coord) const;
164private:
165 QVector<LayeredGridBase::LayerElement> mNames;
166};
167
168
169} // end namespace
170
171#endif // PERMAFROST_H
Grid class (template).
Definition: grid.h:44
This is the base class for multi-layer grids in iLand.
Definition: layeredgrid.h:95
const Grid< ResourceUnit * > * mGrid
Definition: layeredgrid.h:130
ResourceUnit is the spatial unit that encapsulates a forest stand and links to several environmental ...
Definition: resourceunit.h:49
The Permafrost class simulates the permafrost layer of a resource unit.
Definition: permafrost.h:20
void debugData(DebugList &out)
add permafrost related debug output to the list 'out'
Definition: permafrost.cpp:224
void newYear()
start a new year
Definition: permafrost.cpp:99
void run(const ClimateDay *clim_day)
run the permafrost calculations for a given resource unit and day
Definition: permafrost.cpp:123
~Permafrost()
Definition: permafrost.cpp:28
void burnMoss(const double biomass_kg)
burn some of the life moss (kg / ha)
Definition: permafrost.h:44
void setup(WaterCycle *wc)
Definition: permafrost.cpp:33
double mossLayerThickness() const
thickness of the moss layer in meters
Definition: permafrost.h:38
double SOLLayerThickness() const
thickness of the soil organic layer (in meters)
Definition: permafrost.h:40
Permafrost()
Definition: permafrost.cpp:23
double mossBiomass() const
moss biomass (kg/m2)
Definition: permafrost.h:42
Definition: permafrost.h:156
~PermafrostLayers()
Definition: permafrost.h:158
const QVector< LayeredGridBase::LayerElement > & names()
list of stored layers
Definition: permafrost.cpp:497
double value(ResourceUnit *const &data, const int index) const
Definition: permafrost.cpp:481
void clearGrid()
Definition: permafrost.h:160
void setGrid(const Grid< ResourceUnit * > &grid)
Definition: permafrost.h:159
simulates the water cycle on a ResourceUnit.
Definition: watercycle.h:106
Definition: waterout.h:26
const double cRUArea
Definition: globalsettings.h:7
Water contains helper classes for the water cycle calculations.
Definition: permafrost.cpp:13
current climate variables of a day.
Definition: climate.h:28
QList< QVariant > DebugList
Definition: globalsettings.h:38