LandscapeDNDC 1.37.0
soilchemistry-soildndc.h
1
16#ifndef LM_SOILCHEMISTRY_SOILDNDC_H_
17#define LM_SOILCHEMISTRY_SOILDNDC_H_
18
19#include "mbe_legacymodel.h"
20#include "state/mbe_state.h"
21#include "ld_shared.h"
22#include "ld_isotopes.h"
23
24#include "soilchemistry/dndc/output-soilchemistry-dndc.h"
25
26#include "soilchemistry/ld_transport.h"
27#include "soilchemistry/ld_enhanced_efficiency_nitrogen_fertilizers.h"
28
29#include "eventhandler/fertilize/fertilize.h"
30#include "eventhandler/till/till.h"
31
32#include <input/event/events.h>
33
34class solver_tridiagonal_t;
35
36namespace ldndc {
37
38 class LDNDC_API SoilchemistryDNDC : public MBE_LegacyModel
39 {
40 /*** module specific constants ***/
41
43 static const unsigned int NN;
44
46 static const double TNORM;
47
49 static const double HLIM;
50
52 static const double FRN2;
53
54 LMOD_EXPORT_MODULE_INFO(SoilchemistryDNDC,"soilchemistry:soilchemistrydndc","Soilchemistry SoilchemistryDNDC");
55 public:
56 SoilchemistryDNDC(
57 MoBiLE_State *,
58 cbm::io_kcomm_t *,
59 timemode_e);
60
61 ~SoilchemistryDNDC();
62
63 lerr_t configure( ldndc::config_file_t const *);
64 lerr_t register_ports( cbm::io_kcomm_t *);
65 lerr_t initialize();
66
67 lerr_t solve();
68 lerr_t unregister_ports( cbm::io_kcomm_t *);
69 lerr_t finalize();
70
71 lerr_t sleep() { return LDNDC_ERR_OK; }
72 lerr_t wake() { return LDNDC_ERR_OK; }
73
74 private:
75 cbm::io_kcomm_t * io_kcomm;
76
77 input_class_groundwater_t const * gw_;
78 input_class_siteparameters_t const & sipar_;
79 input_class_soillayers_t const & sl_;
80
81 substate_surfacebulk_t & sb_;
82 substate_airchemistry_t & ac_;
83 substate_microclimate_t const & mc_;
84 substate_physiology_t & ph_;
85 substate_soilchemistry_t & sc_;
86 substate_watercycle_t & wc_;
87
88 MoBiLE_PlantVegetation * m_veg;
89
90 CBM_Handle m_PlantHandle;
91 int m_PlantCounter;
92
93 timemode_e const timemode_;
94
95 OutputSoilchemistryDNDC output_writer;
96 ldndc_flt64_t * output_buffer;
97
98 unsigned int const INTERNAL_TIME_STEPS;
99 double const FTS_TOT_;
100
101 EventHandlerFertilize m_eventfertilize;
102 EventHandlerTill m_eventtill;
103
104 private:
105
106
107 double * d_soil_eff_;
108
109 solver_tridiagonal_t * tdma_solver_;
110 Transport transport_;
111
112 double *waterflux_sl;
113 double *accumulated_waterflux_old_sl;
114
115 lvector_t< double > crb_l; // very labile active organic carbon
116 lvector_t< double > crb_r; // labile active organic carbon
117 lvector_t< double > hdc_l; // recalcitrant active organic carbon
118 lvector_t< double > hdc_r; // very recalcitrant active organic carbon
119
120 lvector_t< double > p_o2_sl;
121 lvector_t< double > fdeni;
122 lvector_t< double > day_co2;
123 lvector_t< double > co2_auto_sl;
124 lvector_t< double > anvf_old;
125 lvector_t< double > nitrify_n2o;
126
127 lvector_t< double > communicate_sl;
128
129 /* variable for transport calculations between soil layers
130 * note:
131 * array size = number of soil layers + 1
132 * in order to allow in- and out-flow of soillayer domaine
133 */
134 lvector_t< double > flux_record_sl;
135
136 /* soil temperature */
137 lvector_t< double > const &mc_temp_sl;
138
139 double const KLRAW;
140 double const KLRAW_STUBBLE;
141
142 double const PERTVL;
143 double const PERTL;
144 double const PERTR;
145
146 double const KRCVL;
147 double const KRCL;
148 double const KRCR;
149
150 double const KRCH;
151
152 double const KCRB_L;
153 double const KCRB_R;
154
155 double const KHDC_L;
156 double const KHDC_R;
157
158 double const MUEMAX;
159 double const AMAXX;
160
161 double const KNIT;
162
163 double const D_NO_SCALE;
164 double const D_N2O_SCALE;
165 double const D_O2_AIR_SCALE;
166
167 double const MNO3;
168 double const MUE_NO3;
169
170 double const MNO2;
171 double const MUE_NO2;
172
173 double const MNO;
174 double const MUE_NO;
175
176 double const MN2O;
177 double const MUE_N2O;
178
179 double const KCHEM;
180
181 double const DIFF_C;
182 double const DIFF_N;
183
184 double const GROUNDWATER_NUTRIENT_ACCESS_RATE;
185
186
187 lvector_t< double > D_eff_plant_sl;
188 lvector_t< double > D_eff_air_sl;
189 lvector_t< double > v_air_sl;
190 lvector_t< double > v_water_sl;
191 lvector_t< double > v_ice_sl;
192 lvector_t< double > delta_x;
193 lvector_t< double > interface_delta_x_air_sl;
194 lvector_t< double > soil_gas_advection_sl; // soil gas advection [m:s-1]
195
196 double no_0;
197 double n2o_0;
198 double an_no_0;
199 double an_n2o_0;
200
201 double day_no3_groundwater_access;
202 double year_no3_groundwater_access;
203
204 double n2o_atm;
205 double no_atm;
206
207 double day_mineral_litter;
208 double day_mineral_humus;
209 double day_mineral_microbes;
210 double day_mineral_aorg;
211 double day_mineral_humads;
212
213 double day_denitrify_no3_growth;
214 double day_denitrify_no3_maintenance;
215
216 double day_denitrify_no2_growth;
217 double day_denitrify_no2_maintenance;
218
219 double day_denitrify_no_growth;
220 double day_denitrify_no_maintenance;
221
222 double day_denitrify_n2o_growth;
223 double day_denitrify_n2o_maintenance;
224
225 double const *cCO2;
226 lvector_t< double > co2_concentration_fl;
227 double const *cCH4;
228 lvector_t< double > ch4_concentration_fl;
229 double const *cNO;
230 lvector_t< double > no_concentration_fl;
231 double const *cNH3;
232
233 bool helper;
234
235 lerr_t SCDNDC2_step_initialize_();
236 lerr_t SCDNDC2_step_finalize_();
237
238
242 lerr_t
243 SCDNDC2_write_output();
244 lerr_t
245 SCDNDC2_write_output_daily();
246
248 void SCDNDC2_urea_hydrolysis();
249
251 void SCDNDC2_autotrophic_respiration();
252
254 void SCDNDC2_littering();
255
257 void SCDNDC2_pertubation();
258
273 void SCDNDC2_distribute_among_litter_layers(
274 double _add_c[],
275 double _n_diff);
276
278 void SCDNDC2_nh4_clay_equilibrium();
279
281 void SCDNDC2_split_aorg();
282
284 void SCDNDC2_combine_aorg();
285
287 void SCDNDC2_litter_decomposition();
288
290 void SCDNDC2_humus_decomposition();
291
293 void SCDNDC2_microbial_dynamics();
294
296 void SCDNDC2_humads_decomposition();
297
299 void SCDNDC2_nh4_nh3_dynamics();
300
302 void SCDNDC2_nitrification();
303
305 void SCDNDC2_denitrification();
306
308 void SCDNDC2_gas_diffusion();
309
311 void SCDNDC2_groundwater_access();
312
314 void SCDNDC2_leaching();
315
317 void SCDNDC2_o2_diffusion();
318
320 void SCDNDC2_anvf();
321
323 double SCDNDC2_temp_mois(
324 size_t);
325
327 void SCDNDC2_decomp_litter(
328 size_t sl,
329 double rcn,
330 double decoConstant,
331 double microUse,
332 double temp_mois_fact,
333 double &crb_l,
334 double &rc);
335
337 void SCDNDC2_wood_decomposition();
338
340 void SCDNDC2_nh4_nh3_equilibrium();
341
343 void SCDNDC2_nh3_volatilization();
344
346 void SCDNDC2_diffusion(
347 size_t,
348 double,
349 double,
350 double &,
351 double &);
352
354 void SCDNDC2_conversion(
355 double act,
356 double n_sum,
357 double doc_MM,
358 double fn,
359 double MAINTENANCE,
360 double MAXRGR,
361 double MAXYLD,
362 double phk,
363 double f_MM,
364 double deniC,
365 double &deniC_prod,
366 double & ,
367 double & ,
368 double &chem_from,
369 double &_assi_chem_from,
370 double &chem_to,
371 double &_denit_growth,
372 double &_denit_main);
373
375 void SCDNDC2_chemodenitrification(
376 size_t sl,
377 double /* time resolution */);
378
379 double SCDNDC2_get_fact_o2(size_t /* soil layer */);
380
381 double SCDNDC2_get_wfps(
382 size_t /* soil layer */);
383
384 /* balance check switch */
385 bool bc_warn;
386 double bc_tolerance;
387
388 lerr_t SCDNDC2_balance_check(
389 unsigned int /*stage*/, double * /*carbon*/, double * /*nitrogen*/);
390 double SCDNDC2_get_c_tot();
391 double SCDNDC2_get_n_tot();
392
398 lerr_t
399 SCDNDC2_check_for_negative_value(
400 char const * /*name*/);
401
402 Isotopes isotope;
403 };
404
405} /*namespace ldndc*/
406
407#endif /* LM_SOILCHEMISTRY_SOILDNDC_H_ */
408
Spatially explicit groundwater model.
Definition: airchemistryput.h:15