LandscapeDNDC 1.37.0
Loading...
Searching...
No Matches
soilchemistry-deconit.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 */
6
7
8#ifndef LM_SOILCHEMISTRY_DECONIT_H_
9#define LM_SOILCHEMISTRY_DECONIT_H_
10
11#include "soilchemistry/ld_enhanced_efficiency_nitrogen_fertilizers.h"
12#include "soilchemistry/ld_som_spinup.h"
13#include "mbe_legacymodel.h"
14#include "ld_eventqueue.h"
15#include "state/mbe_state.h"
16
17#include "eventhandler/fertilize/fertilize.h"
18#include "eventhandler/till/till.h"
19
20#include <input/event/events.h>
21
22namespace ldndc {
23
24class LDNDC_API SoilChemistryDECONIT : public MBE_LegacyModel
25{
26 LMOD_EXPORT_MODULE_INFO(SoilChemistryDECONIT,"soilchemistry:deconit","Soilchemistry DECONIT");
27 public:
28 SoilChemistryDECONIT(
29 MoBiLE_State *,
30 cbm::io_kcomm_t *,
31 timemode_e);
32
33 ~SoilChemistryDECONIT();
34
35 lerr_t configure( ldndc::config_file_t const *);
36
37 lerr_t register_ports( cbm::io_kcomm_t *);
38 lerr_t initialize();
39
40 lerr_t solve();
41
42 lerr_t unregister_ports( cbm::io_kcomm_t *);
43 lerr_t finalize() { return LDNDC_ERR_OK; }
44
45 lerr_t sleep() { return LDNDC_ERR_OK; }
46 lerr_t wake() { return LDNDC_ERR_OK; }
47
48 private:
49 input_class_siteparameters_t const & sipar_;
50 input_class_soillayers_t const & sl_;
51
52 substate_surfacebulk_t & sb_;
53 substate_airchemistry_t & ac_;
54 substate_microclimate_t & mc_;
55 substate_physiology_t & ph_;
56 substate_soilchemistry_t & sc_;
57 substate_watercycle_t & wc_;
58
59 MoBiLE_PlantVegetation * m_veg;
60
61 timemode_e const timemode_;
62
63 EventHandlerFertilize m_eventfertilize;
64 /* controlled-release nitrogen fertilizer (release only; inhibitors are not considered) */
65 ControlledReleaseNitrogenFertilizer crnf_;
66
67 /* spinup of the litter pools (option spinupyears) */
68 SomSpinup spinup_;
69 std::vector< double > spinup_c_sl, spinup_n_sl;
70 int spinup_month_;
71 void DECONIT_spinup();
72 void DECONIT_spinup_close();
73
74 EventQueue m_TillEvents;
75 ldndc::EventHandle m_TillHandle;
76
77 lvector_t< double > addC_lit1_Frt_sl;
78 lvector_t< double > addC_lit2_Frt_sl;
79 lvector_t< double > addC_lit3_Frt_sl;
80
81 lvector_t< double > addC_lit1_Fol_sl;
82 lvector_t< double > addC_lit2_Fol_sl;
83 lvector_t< double > addC_lit3_Fol_sl;
84
85 lvector_t< double > fact_m;
86 lvector_t< double > fact_t;
87 lvector_t< double > fact_tm;
88
89 lvector_t< double > fact_carbonQuality;
90
91 lvector_t< double > fdeniFROST_sl;
92 lvector_t< double > fdeni;
93 lvector_t< double > sumHeterotrophs;
94
95 lvector_t< double > const &mc_temp_sl;
96
97 double *waterflux_sl;
98 double *accumulated_waterflux_old_sl;
99
100 double tot_c_balance_1;
101 double tot_n_balance_1;
102
103 double K_LITTER_TYPE; // Decomposition reduction factor for coniferous. [-]
104 double ts_scale;
105
106 double DECONIT_Fact_T(size_t);
107 double DECONIT_Fact_M(size_t);
108
109 double DECONIT_afgen(
110 const double ,
111 const double ,
112 const double ,
113 const double );
114
115
116 void DECONIT_GasSpecDiffusion(
117 const int sl, // Soil layer counter (-)
118 double &chem_sl, // Concentration in the current soil layer (kgNm-2)
119 double &chem_last_sl); // Concentration in a deeper soil layer (kgNm-2)
120
121 lerr_t DECONIT_step_init();
122
123 void DECONIT_AnaerobicVolumeFraction();
124
125 void DECONIT_EmpiricalAnaerobicVolumeFraction();
126
127 lerr_t DECONIT_fertilize();
128 lerr_t DECONIT_manure();
129 lerr_t DECONIT_till();
130 lerr_t DECONIT_urea_hydrolysis();
131
132 void DECONIT_ArahVintenAnaerobicVolumeFraction();
133
134 void DECONIT_DenitrifierFraction();
135
136 void DECONIT_MicrobialGrowth();
137
138 void DECONIT_Denitrification();
139
140 void DECONIT_UpwardDiffusion();
141
142 void DECONIT_Leaching();
143
144 void DECONIT_MicrobialDecay();
145
146 void DECONIT_Chemodenitrification();
147
148 void DECONIT_CalcRootResp();
149
150 void DECONIT_AllocLitter();
151
152 void DECONIT_Decomposition();
153
154 void DECONIT_Fragmentation();
155
156 void DECONIT_UpdateTempMoist();
157
158 double DECONIT_get_wfps(
159 size_t /* soil layer */);
160
164 lerr_t
165 DECONIT_balance_check(
166 unsigned int);
167
171 double
172 DECONIT_get_c_tot();
173
177 double
178 DECONIT_get_n_tot();
179
180 lerr_t DECONIT_CHECK_FOR_NEGATIVE_VALUE(
181 char const * /* position */);
182};
183
184} /*namespace ldndc*/
185
186#endif /* LM_SOILCHEMISTRY_DECONIT_H_ */
187
Spatially explicit groundwater model.
Definition airchemistryput.h:21