LandscapeDNDC 1.37.0
Loading...
Searching...
No Matches
pnet.h
1/*
2 * SPDX-FileCopyrightText: Karlsruhe Institute of Technology (KIT)
3 * SPDX-License-Identifier: LicenseRef-LandscapeDNDC
4 * This file is part of LandscapeDNDC. See LICENSE.
5 */
13#ifndef LM_PHYSIOLOGY_PNET_H_
14#define LM_PHYSIOLOGY_PNET_H_
15
16
17#include "mbe_legacymodel.h"
18#include "state/mbe_state.h"
19#include "ld_shared.h"
20#include "physiology/ld_plantfunctions.h"
21#include "physiology/ld_treedyn.h"
22
23#include <logging/cbm_logging.h>
24
25namespace ldndc {
26
27extern cbm::logger_t * PhysiologyPNETLogger;
28
37class LDNDC_API PhysiologyPNET : public MBE_LegacyModel
38{
39 LMOD_EXPORT_MODULE_INFO(PhysiologyPNET,"physiology:pnet","Physiology PNET");
40
41 /*** module specific constants ***/
42
44 static const double SRATEMAX;
45
47 static const double NUPTAIR;
48
50 static const double FDON_AVAILABLE;
51
53 static const double GROWMAX;
54
55
56 public:
57 PhysiologyPNET(
58 MoBiLE_State *,
59 cbm::io_kcomm_t *,
60 timemode_e);
61
62 ~PhysiologyPNET();
63
64 lerr_t register_ports( cbm::io_kcomm_t * );
65 lerr_t unregister_ports( cbm::io_kcomm_t * );
66
67 lerr_t configure( ldndc::config_file_t const *);
68
69 lerr_t initialize();
70
71 lerr_t solve();
72
73 lerr_t finalize() { return LDNDC_ERR_OK; }
74
83 lerr_t sleep() { return LDNDC_ERR_OK; }
84 lerr_t wake() { return LDNDC_ERR_OK; }
85
86 cbm::string_t crownlength_opt;
87 bool competition_opt;
88 bool don_uptake_opt;
89
90 private:
91
92 cbm::io_kcomm_t * io_kcomm;
93
94 input_class_soillayers_t const & sl_;
95 input_class_setup_t const & m_setup;
96 input_class_siteparameters_t const * m_sipar;
97 input_class_species_t const * m_species;
98
99 substate_airchemistry_t const & ac_;
100 substate_microclimate_t const & mc_;
101 substate_physiology_t & ph_;
102 substate_soilchemistry_t & sc_;
103 substate_watercycle_t & wc_;
104
105 MoBiLE_PlantVegetation * m_veg;
106
107 LD_PlantFunctions m_pf;
108 TreeDynamics m_treedyn;
109
110 SubscribedEvent<LD_EventHandlerQueue> m_HarvestEvents;
111 SubscribedEvent<LD_EventHandlerQueue> m_PlantEvents;
112
113 lvector_t< double > no3_sl; // nitrate in aerobic and anaerobic soil volume (kgN m-2)
114
115 double latitude;
116
117 double FolNCon; // foliage nitrogen concentration, limited to the optimum (%)
118 double accumulated_transpiration_old; // accumulated water uptake at the previous day (m)
119
120 unsigned int year_start_, year_end_; // first and last day of the vegetation year
121
122 lvector_t< double > LayerGrossPsn; // gross photosynthesis per canopy layer (gC m-2)
123 template < typename _E >
124 struct scalar_with_array_look_and_feel_t
125 {
126 _E value;
127 _E & operator=( _E const & _value)
128 { this->value = _value; return this->value; }
129 _E & operator[]( size_t)
130 { return this->value; }
131 _E & operator[]( MoBiLE_Plant *)
132 { return this->value; }
133 };
134
135 /* NOTE change this as soon as PNET becomes multi-species capable */
136 scalar_with_array_look_and_feel_t< double > mFolOld_vt; // saved initial foliage biomass for new nitrogen concentration calculations
137 scalar_with_array_look_and_feel_t< double > mFrtOld_vt; // saved initial fine root biomass for new nitrogen concentration calculations
138 scalar_with_array_look_and_feel_t< double > mBudOld_vt; // saved initial bud (reserve) biomass for new nitrogen concentration calculations
139 scalar_with_array_look_and_feel_t< double > mSapOld_vt; // saved initial sapwood biomass for new nitrogen concentration calculations
140 scalar_with_array_look_and_feel_t< double > mCorOld_vt; // saved initial core wood biomass for new nitrogen concentration calculations
141
142 lvector_t< double > mBudLoss_vt; // dry matter transferred from buds to foliage (kgDW m-2)
143 lvector_t< double > mSapLoss_vt; // dry matter transferred from sapwood to core wood and branch litter (kgDW m-2)
144 lvector_t< double > mSapTurnover_vt; // part of mSapLoss from age related sapwood senescence (kgDW m-2)
145 lvector_t< double > mSapExcess_vt; // part of mSapLoss from sapwood exceeding the structural demand (kgDW m-2)
146
147 double c_begin; // plant carbon at the beginning of the day (kgC m-2, balance check)
148 double n_begin; // plant and soil nitrogen at the beginning of the day (kgN m-2, balance check)
149
150 // - water and nitrogen variables
151 double DWater; // drought factor of photosynthesis and phenology (-)
152 double FolLitSum; // foliage litter of the day (gDW m-2)
153
154 double tra; // (currently not used)
155 double uptNAir; // canopy uptake of deposited nitrogen (kgN m-2) (currently always 0)
156
157 // - photosynthesis and respiration of the day (original names refer to the monthly time step)
158 double Dvpd; // vapour pressure deficit factor of photosynthesis (-)
159 double DayResp; // foliage respiration during daytime (gC gDW-1)
160 double NightResp; // foliage respiration during nighttime (gC gDW-1)
161 double CanopyNetPsn; // canopy net photosynthesis (gC m-2) (currently not used)
162 double CanopyGrossPsn; // canopy gross photosynthesis (gC m-2)
163 double FolProdCDay; // foliage growth (gC m-2)
164 double FolGRespDay; // foliage growth respiration (gC m-2)
165 double NetPsnDay; // canopy net photosynthesis after foliage respiration (gC m-2)
166 double CanopyGrossPsnDay; // canopy gross photosynthesis (gC m-2)
167 double RootCAddDay; // fine root carbon demand (gC m-2)
168
169 // - allocation and mass variables
170 double qwodfolact; // ratio of sapwood to foliage and bud biomass at the start of the year (-)
171 double transfDWbs; // annual transfer from buds to sapwood (kgDW m-2)
172 double transfDWsb; // annual transfer from sapwood to buds (kgDW m-2)
173 double WoodC; // sapwood carbon (gC m-2)
174 double BudC; // bud carbon, i.e., reserves for future foliage (gC m-2)
175 double RootC; // fine root carbon (gC m-2)
176 double FolMass; // foliage biomass (gDW m-2)
177 double FolMassMax; // expected maximum foliage biomass of the year (gDW m-2)
178 double FolMassMin; // expected minimum foliage biomass of the year (gDW m-2)
179 double FolReten; // foliage retention time (yr)
180
181 double WoodMRespDay; // wood maintenance respiration (gC m-2)
182 double WoodGRespDay; // wood growth respiration (gC m-2)
183 double RootMRespDay; // fine root maintenance respiration (gC m-2)
184 double RootGRespDay; // fine root growth respiration (gC m-2)
185 double WoodProdCDay; // wood growth from the carbon pool of the year (gC m-2)
186 double RootProdCDay; // fine root litter (gC m-2)
187
188 double PosCBalMass; // foliage biomass with positive carbon balance (gDW m-2)
189 double PosCBalMassTot; // sum of PosCBalMass during the vegetation period (currently not used)
190 double PosCBalMassIx; // number of days summed in PosCBalMassTot (currently not used)
191
192 double LightEffMin; // minimum light efficiency of the growing season (-)
193 double WoodCStart; // carbon pool for wood growth of the year (gC m-2)
194 double BudCStart; // carbon pool for foliage growth of the year (gC m-2)
195
196 // other variables
197 bool mature; // foliage flushing completed
198
199 // - daily fluxes distributed over the time steps of the day (time mode "subdaily")
200 double potential_transpiration_day; // potential transpiration of the day (m)
201 double rFol_day; // foliage respiration of the day (kgC m-2)
202 double rFrt_day; // fine root respiration of the day (kgC m-2)
203 double rSap_day; // sapwood respiration of the day (kgC m-2)
204 double rSapBelow_day; // belowground sapwood respiration of the day (kgC m-2)
205 double rBud_day; // bud respiration of the day (kgC m-2)
206 double rRes_day; // residual respiration of the day (kgC m-2)
207 double rTra_day; // transport respiration of the day (kgC m-2)
208 double rGro_day; // growth respiration of the day (kgC m-2)
209 double rGroBelow_day; // belowground growth respiration of the day (kgC m-2)
210 lvector_t< double > carbonuptake_day_fl; // gross carbon uptake of the day per canopy layer (kgC m-2)
211 double f_radiation_cum; // fraction of radiation driven fluxes distributed so far
212 double f_uniform_cum; // fraction of uniformly distributed fluxes distributed so far
213
214 /*** methods ***/
215
216 bool subdaily_timemode();
217
218 lerr_t solve_day();
219
220 void daily_to_subdaily();
221
222 void distribute_subdaily();
223
225 lerr_t step_init();
226
228 lerr_t step_out();
229
231 void balance_check( MoBiLE_Plant *p, unsigned int _i);
232
234 double sapwood_foliage_ratio( MoBiLE_Plant *);
235
237 double functional_sapwood( MoBiLE_Plant *);
238
240 void update_nitrogen_concentration( MoBiLE_Plant *);
241
243 void YearlyReset( MoBiLE_Plant *);
244
246 void Phenology(
247 MoBiLE_Plant *,
248 int /*GrowthPhase*/,
249 double /*DWater*/);
250
252 void Photosyn( MoBiLE_Plant *);
253
255 void AllocateDay( MoBiLE_Plant *);
256
258 void AllocateYr( MoBiLE_Plant *);
259
261 void N_uptake( MoBiLE_Plant *, double &);
262
264 void Update( MoBiLE_Plant *, double /*upt1_vt*/, double /*upt2_vt*/);
265
267 void TransformPhysiology( MoBiLE_Plant *);
268
270 lerr_t CalcVegStructure();
271
273 size_t get_na_max_pnet();
274
275};
276} /*namespace ldndc*/
277
278#endif /* !LM_PHYSIOLOGY_PNET_H_ */
279
lerr_t sleep()
Definition pnet.h:83
static const double FDON_AVAILABLE
Definition pnet.h:50
static const double NUPTAIR
Definition pnet.h:47
static const double SRATEMAX
Definition pnet.h:44
static const double GROWMAX
Definition pnet.h:53
Spatially explicit groundwater model.
Definition airchemistryput.h:21