LandscapeDNDC 1.37.0
Loading...
Searching...
No Matches
grassland-dndc.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 */
9
10#ifndef LM_PHYSIOLOGY_GRASSLANDDNDC_H_
11#define LM_PHYSIOLOGY_GRASSLANDDNDC_H_
12
13#include "mbe_legacymodel.h"
14#include "state/mbe_state.h"
15#include "ld_shared.h"
16#include "ld_eventqueue.h"
17
18#include "eventhandler/graze/graze.h"
19#include "eventhandler/cut/cut.h"
20#include "physiology/ld_plantfunctions.h"
21
22#include <containers/lgrowarray.h>
23
24namespace ldndc {
25
27class LDNDC_API PhysiologyGrasslandDNDC : public MBE_LegacyModel
28{
29 LMOD_EXPORT_MODULE_INFO(PhysiologyGrasslandDNDC,"physiology:grasslanddndc","Physiology GrasslandDNDC");
30
31 /*** module specific constants ***/
32
34 static double const GROWTH_RESPIRATION_FRACTION;
35
37 static const double S_TLIMIT;
38
39public:
40 PhysiologyGrasslandDNDC(
41 MoBiLE_State *,
42 cbm::io_kcomm_t *,
43 timemode_e);
44
45 ~PhysiologyGrasslandDNDC();
46
47 lerr_t configure( ldndc::config_file_t const *);
48 lerr_t register_ports( cbm::io_kcomm_t *);
49 lerr_t initialize();
50
51 lerr_t solve();
52 lerr_t unregister_ports( cbm::io_kcomm_t *);
53 lerr_t finalize() { return LDNDC_ERR_OK; }
54
55 lerr_t sleep() { return LDNDC_ERR_OK; }
56 lerr_t wake() { return LDNDC_ERR_OK; }
57
58private:
59 MoBiLE_State * m_state;
60 cbm::io_kcomm_t * io_kcomm;
61
62 /* required input classes */
63 input_class_setup_t const * m_setup;
64 input_class_soillayers_t const * m_soillayers;
65 input_class_siteparameters_t const * m_sipar;
66 input_class_species_t const * m_species;
67
68 /* required state components */
69 substate_airchemistry_t const & ac_;
70 substate_microclimate_t & mc_;
71 substate_physiology_t & ph_;
72 substate_soilchemistry_t & sc_;
73 substate_watercycle_t & wc_;
74
75 MoBiLE_PlantVegetation * m_veg;
76
77 EventQueue m_HarvestEvents;
78 ldndc::EventHandle m_HarvestHandle;
79 EventQueue m_PlantEvents;
80 ldndc::EventHandle m_PlantHandle;
81
82 ldndc::growable_array < BaseRootSystemDNDC*, 1000, 1 > root_system;
83
84 double const *mc_temp;
85
86 double const FTS_TOT_;
87
92 LD_PlantFunctions m_pf;
93
94 double tot_c_;
95 double tot_n_;
96
97 EventHandlerGraze m_eventgraze;
98 EventHandlerCut m_eventcut;
99
100 lvector_t< double > n_demand_vt_;
101 lvector_t< double > n_uptake_vt_;
102 lvector_t< double > n_avail_tot_vt_;
103
108 lvector_t< unsigned int > root_q_vt_;
109
110 lvector_t< double > n2_fixation_vt;
111
112 lvector_t< double > dc_fol_vt;
113 lvector_t< double > dc_lst_vt;
114 lvector_t< double > dc_bud_vt;
115 lvector_t< double > dc_frt_vt;
116
117 lvector_t< double > r_res_vt;
118 lvector_t< double > r_gro_vt;
119 lvector_t< double > r_gro_below_vt;
120 lvector_t< double > r_fol_vt;
121 lvector_t< double > r_lst_vt;
122 lvector_t< double > r_bud_vt;
123 lvector_t< double > r_frt_vt;
124
125 lvector_t< double > s_fol_vt;
126 lvector_t< double > s_bud_vt;
127
128 lvector_t< double > n_lit_fol_vt;
129 lvector_t< double > n_lit_bud_vt;
130
131 lvector_t< double > exsuLoss_vt;
132
133 std::vector< std::vector< double > > s_frt_vtsl;
134 std::vector< std::vector< double > > n_lit_frt_vtsl;
135
136 std::vector< std::vector< double > > c_upt_vtfl;
137
138 lvector_t< double > temp_sl;
139 lvector_t< double > no3_sl;
140 lvector_t< double > nh4_sl;
141 lvector_t< double > don_sl;
142
143 lvector_t< double > nh4_uptake_sl;
144 lvector_t< double > don_uptake_sl;
145 lvector_t< double > no3_uptake_sl;
146
147 bool exponential_root_distribution;
148
153 double delta_c_at_planting;
154
155 /*** methods ***/
156
161 lerr_t step_init();
162 lerr_t step_out();
163
168 lerr_t GrasslandDNDCCuttingGrazing();
169
176 void update_species_related_state_items( MoBiLE_Plant *);
177
193 lerr_t event_plant( MoBiLE_Plant *, EventAttributes const &);
194
210 lerr_t event_harvest( MoBiLE_Plant *, EventAttributes const &);
211
217 lerr_t GrasslandDNDCPlantDevelopment();
218
219
220 void growth_respiration( MoBiLE_Plant *);
221
235 void maintenance_respiration( MoBiLE_Plant *);
236
250 double nitrogen_demand( MoBiLE_Plant *);
251
256 void nitrogen_uptake();
257
272 double nitrogen_fixation( MoBiLE_Plant *, double, double);
273 double total_fixed_nitrogen( MoBiLE_Plant *, double) const;
274
275
280 void
281 GrasslandDNDCPhotosynthesis( MoBiLE_Plant *, double);
282
283
284
295 void senescence( MoBiLE_Plant *);
296
297 /* coverage */
298 void update_canopy_coverage( MoBiLE_Plant *);
299
300 /* plant height */
301 void update_canopy_height( MoBiLE_Plant *);
302
303 /* canopy structure */
304 void update_canopy_items( MoBiLE_Plant *);
305
306
307 void GrasslandDNDCBalanceCheck( int /*stage*/);
308};
309} /*namespace ldndc*/
310
311#endif /* !LM_PHYSIOLOGY_GRASSLANDDNDC_H_ */
312
Spatially explicit groundwater model.
Definition airchemistryput.h:21
Interface of the fine root system of a plant: rooting depth, distribution of fine root mass and lengt...
Definition ld_rootsystem.h:34