LandscapeDNDC 1.37.0
Loading...
Searching...
No Matches
soilchemistry-metrx.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#ifndef LM_SOILCHEMISTRYMETRX_H_
8#define LM_SOILCHEMISTRYMETRX_H_
9
10#include "mbe_legacymodel.h"
11#include "soilchemistry/ld_tillage.h"
12#include "state/mbe_state.h"
13#include "ld_shared.h"
14
15#include "models/soilchemistry/metrx/output-soilchemistry-metrx.h"
16#include "models/soilchemistry/ld_transport.h"
17#include "models/soilchemistry/ld_enhanced_efficiency_nitrogen_fertilizers.h"
18
19#include "eventhandler/fertilize/fertilize.h"
20#include "eventhandler/till/till.h"
21
22#include <math/lmath-tdma.h>
23#include <vector>
24#include <logging/cbm_logging.h>
25
26namespace ldndc {
27
28extern cbm::logger_t * SoilChemistryMeTrXLogger;
29
30/* isotope tracing (SIMONE), see soilchemistry-metrx-isotopes.cpp */
31struct metrx_isotopes_t;
32struct metrx_iso_process_t;
33
34/* phosphorus (option "phosphorus"), see soilchemistry-metrx-phosphorus.cpp */
35struct metrx_phosphorus_t;
36struct metrx_p_carbon_t;
37
42class LDNDC_API SoilChemistryMeTrX : public MBE_LegacyModel
43{
45 static const double TNORM;
46
47 static const double PH_MAX;
48 static const double PH_MIN;
49
51 static const double FACT_PH_MIN;
52
54 static const double C_SATURATION;
56 static const double RHO_ORGANIC_MATTER;
57 static const double RHO_MINERAL_MATTER;
59 static const double PEAT_ORGANIC_VOLUME_1;
60 static const double PEAT_ORGANIC_VOLUME_2;
61 static const double SURFACE_DEPTH;
62
63 LMOD_EXPORT_MODULE_INFO(SoilChemistryMeTrX,"soilchemistry:metrx","Soilchemistry MeTrX");
64public:
65 SoilChemistryMeTrX(
66 MoBiLE_State *,
67 cbm::io_kcomm_t *,
68 timemode_e);
69
70 ~SoilChemistryMeTrX();
71
72 lerr_t configure( ldndc::config_file_t const *);
73 lerr_t register_ports( cbm::io_kcomm_t *);
74 lerr_t initialize();
75
76 lerr_t solve();
77 lerr_t integrate();
78
79 lerr_t unregister_ports( cbm::io_kcomm_t *);
80 lerr_t finalize();
81
82 lerr_t sleep() { return LDNDC_ERR_OK; }
83 lerr_t wake() { return LDNDC_ERR_OK; }
84
85private:
86 cbm::io_kcomm_t * io_kcomm;
87
88 input_class_groundwater_t const * gw_;
89 input_class_siteparameters_t const & sipar_;
90 input_class_soillayers_t const & sl_;
91 input_class_setup_t const & se_;
92
93 substate_surfacebulk_t & sb_;
94 substate_airchemistry_t & ac_;
95
96 substate_microclimate_t const & mc_;
97 substate_physiology_t & ph_;
98 substate_soilchemistry_t & sc_;
99 substate_watercycle_t & wc_;
100
101 MoBiLE_PlantVegetation * m_veg;
102
103 SubscribedEvent<LD_EventHandlerQueue> m_FertilizeEvents;
104 SubscribedEvent<LD_EventHandlerQueue> m_IrrigationEvents;
105 SubscribedEvent<LD_EventHandlerQueue> m_FloodEvents;
106 SubscribedEvent<LD_EventHandlerQueue> m_LimingEvents;
107 SubscribedEvent<LD_EventHandlerQueue> m_ManureEvents;
108 SubscribedEvent<LD_EventHandlerQueue> m_PlantEvents;
109 SubscribedEvent<LD_EventHandlerQueue> m_TillEvents;
110
111 Transport transport_;
112 ControlledReleaseNitrogenFertilizer crnf_;
113 NitrogenTransformationInhibitors inh_;
114
115 timemode_e const timemode_;
116
117 OutputSoilchemistryMeTrX output_writer_;
118 ldndc_flt64_t * output_data_;
119
120 int const TOTAL_TIME_STEPS;
121 int const INTERNAL_TIME_STEPS;
122 double const FTS_TOT_;
123
124 /* Molar weights scaled from [g mol-1] to [kg mol-1] */
125
126 double const M_C_SCALE; // Molar weigth of C [kg mol-1]
127 double const M_2C_SCALE; // Molar weigth of C [kg mol-1]
128 double const M_N_SCALE; // Molar weigth of N [kg mol-1]
129 double const M_2H_SCALE; // Molar weigth of H2 [kg mol-1]
130 double const M_2N_SCALE; // Molar weigth of N2 [kg mol-1]
131 double const M_O_SCALE; // Molar weigth of O2 [kg mol-1]
132 double const M_2O_SCALE; // Molar weight of SO4 in [kg mol-1]
133 double const M_FE_SCALE; // Molar weight of Fe in [kg mol-1]
134
135 double const N_O2_RATIO_NITRIFICATION;
136 double const ACETATE_RATIO_FERM_SYN; // Ratio of acetate production from glucose via fermentative/syntrophic pathway. [-]
137
138 double const H2_MOL_CH4_KG_CONVERSION; // Converts from mol H2 consumed for CH4 production to kg CO2 needed
139 double const H2_KG_CH4_KG_CONVERSION; // Converts from kg H2 consumed for CH4 production to kg CO2 needed
140 double const H2_KG_CH4_MOL_CONVERSION; // Converts from kg H2 consumed for CH4 production to mol CO2 needed
141
142 double const FE3_ACETATE_REDUCTION_RATIO; // CHCOO(-) + 8Fe(3+) + 4 H2O -> 2 HCO3(-) + 8 Fe(2+) + 9 H(+) (Brock Biology of Microorganisms)
143 double const FE3_HYDROGEN_REDUCTION_RATIO; // H2 + 2 Fe(3+) + 4 H+ -> 2 Fe2+ + 6 H2O
144 double const M_S_SCALE; // Molar weight of S [kg mol-1]
145 double const SO4_ACETATE_REDUCTION_RATIO; // CH3COO(-) + SO4(2-) -> 2 HCO3(-) + HS(-)
146 double const SO4_HYDROGEN_REDUCTION_RATIO; // 4 H2 + SO4(2-) + H(+) -> HS(-) + 4 H2O
147 double const O2_S2_RATIO; // HS(-) + 2 O2 -> SO4(2-) + H(+)
148
149 double const O2_CONVERSION_FOR_CH4_OX;
150
151 double const NO3_MOLAR_MAX_FE_RED; // NO3-threshold concentration. No Fe3-reduction possible for no3 > NO3_MOLAR_MAX_FE_RED. [mol m-3]
152 double const FE3_MOLAR_MAX_CH4_PROD; // Fe3-threshold concentration. No CH4-production possible for fe3 > FE3_MOLAR_MAX_CH4_PROD. [mol m-3]
153 double const O2_FE2_RATIO; // 2 Fe(2+) + 0.5 O2 + 2 H(+) -> 2 Fe(3+) + H2O
154
155 double const MICRO_C_MIN;
156
157 double const KI_HAC; // Inhibition of anaerobic hydrolysis and fermenter growth by undissociated acetic acid. [mol L-1]
158
159 // PEAT PROTOTYPE: selectively preserved, aged organic matter of peat layers (see MeTrX_peat_layer)
160 double const K_DC_AGED; // Decomposition constant of aged organic matter (peat). [timestep-1]
161 double const AGED_F_AN; // Factor for anaerobic relative to aerobic decomposition of peat. [-]
162
163 double const MC_MO2_RATIO; // Factor that transforms O2-consumption to CO2-production
164 double const RGAS_M_O2_BAR_PA; // Conversion factor for anaerobic volume calculation.
165
166 double const K_HU_DOC;
167
168 double const K_DC_AORG;
169 double const K_HU_AORG_HUM1;
170 double const K_HU_AORG_HUM2;
171
172 double const K_DC_SOL;
173 double const K_HU_SOL;
174
175 double const K_DC_CEL;
176 double const K_HU_CEL;
177
178 double const K_DC_LIG;
179 double const K_HU_LIG;
180
181 double const K_DC_HUM1;
182 double const K_HU_HUM1;
183
184 double const K_DC_HUM2;
185 double const K_HU_HUM2;
186
187 double const K_DC_HUM3;
188 double const KR_DENIT_CHEMO;
189
190 double const K_FRAG_STUBBLE;
191 double const K_FRAG_ALGAE;
192 double const K_FRAG_RAW_LITTER;
193 double const K_FRAG_WOOD;
194
195 double const KMM_O2_ROOT_RESPIRATION;
196
197 double const MUE_MAX_C_MICRO_1; // Maximal microbial growth rate for mic_1. [kg C timestep-1]
198 double const MUE_MAX_C_MICRO_2; // Maximal microbial growth rate for mic_2. [kg C timestep-1]
199 double const MUE_MAX_C_MICRO_3; // Maximal microbial growth rate for mic_3. [kg C timestep-1]
200
201 double const METRX_MUEMAX_C_CH4_PROD;
202 double const METRX_MUEMAX_H2_CH4_PROD;
203 double const METRX_MUEMAX_C_CH4_OX_HA;
204 double const METRX_MUEMAX_C_CH4_OX_LA;
205
206 double const METRX_MUEMAX_C_FE_RED;
207 double const METRX_MUEMAX_C_SO4_RED;
208 double const METRX_KR_OX_FE;
209
210 double const MUE_MAX_N_ASSI;
211
212 double const PH_SURFACE_WATER;
213
215 double const PH_MAX_CHEMODENIT;
216
217 double const A_MAX_ALGAE;
218 double const A_MAX_MICRO_1;
219 double const A_MAX_MICRO_2;
220 double const A_MAX_MICRO_3;
221
222 double const METRX_F_DENIT_N2_MIN;
223 double const METRX_F_DENIT_N2_DELTA;
224
226 double const ANVF_ATM;
227
228 double const D_NO_WATER_SCALE;
229 double const D_N2O_WATER_SCALE;
230 double const D_O2_WATER_SCALE;
231 double const D_CO2_WATER_SCALE;
232 double const D_CH4_WATER_SCALE;
233 double const D_NH3_WATER_SCALE;
234 double const D_NH4_WATER_SCALE;
235 double const D_NO3_WATER_SCALE;
236 double const D_NO2_WATER_SCALE;
237 double const D_DOC_WATER_SCALE;
238
239 double const D_O2_AIR_SCALE;
240 double const D_N2_AIR_SCALE;
241 double const D_N2O_AIR_SCALE;
242 double const D_NO_AIR_SCALE;
243 double const D_CH4_AIR_SCALE;
244 double const D_CO2_AIR_SCALE;
245 double const D_NH3_AIR_SCALE;
246 double const D_RADON_AIR_SCALE;
247
248 double const METRX_V_EBULLITION;
249 double const GROUNDWATER_NUTRIENT_ACCESS_RATE;
250
251 size_t SL_SURFACE_DISTRIBUTION; // number of soil layers for surface matter allocation to soil domaine
252 double SL_SURFACE_DISTRIBUTION_INVERSE; // inverse of SL_SURFACE_DISTRIBUTION
253
254 //wind speed
255 double const *mc_wind;
256
257 // soil temperature
258 double const *mc_temp_atm;
259 lvector_t< double > const &mc_temp_sl;
260
261 // water flux
262 double *waterflux_sl;
263 double *accumulated_waterflux_old_sl;
266 double *accumulated_gw_exchange_old_sl;
267
268 // infiltration flux
269 double infiltration;
270 double accumulated_infiltration_old;
271 // flood water (automatic irrigation of flood events) that has already received its solutes
272 double accumulated_irrigation_automatic_old;
273
278 void
279 MeTrX_add_water_solutes( double /* NO3 */, double /* NH4 */, double /* DON */, double /* DOC */,
280 double /* water amount x unit conversion */);
281
282private:
283
284 PublishedField<double> StubbleCarbon;
285
286 /*****/
287 /* */
288 /*****/
289
291 std::vector< char > peat_layer_sl_;
293 std::vector< char > organic_layer_sl_;
295 std::vector< double > peat_weight_sl_;
296 bool have_algae;
297 bool have_dry_wet;
298 cbm::string_t freeze_thaw_method;
299 bool have_surface_bulk;
300 bool have_canopy_transport;
301 bool have_river_connection;
302 bool have_litter_height_change;
303 cbm::string_t d_eff_method;
304 bool have_radon_diffusion;
305 double spinup_delta_c;
306 double spinup_delta_c_depth;
307 bool spinup_floor;
308 bool spinup_conserve;
311 double k_dc_biochar_;
312
313 /* option humusinit = cnratio (default): humus pools are initialized by turnover, their nitrogen by C/N ratios */
314 bool humus_init_cn_;
315 double cn_maom_; // target C/N ratio of mineral associated organic matter (humus pools 2 and 3)
316 double cn_pom_init_; // C/N ratio of particulate organic matter for the initial pom/maom split
317 double cn_pom_max_; // maximum C/N ratio of particulate organic matter (humus pool 1)
318 double f_maom_active_; // initial fraction of maom in the active pool (humus pool 2) // Decomposition constant of biochar. [timestep-1]
319
320 cbm::string_t anvf_method;
321
322 /* options as flags, set once in configure() (string comparisons are expensive in the time loop) */
323 bool ft_yes_;
332
333 /* automatic liming (options "autoliming", "autolimingphmin", "autolimingphtarget", "autolimingdepth") */
334 bool have_auto_liming;
335 double auto_liming_ph_min;
336 double auto_liming_ph_target;
337 double auto_liming_depth;
338
339 bool have_plant_diffusion;
340 bool have_water_table; // True for timespan with surface water
341
342 double h_wl; // heigth of each watertable layer [m]
343
344 double c_algae;
345 double c_dead_algae;
346 double n_algae;
347 double n_dead_algae;
348
349 double *o2_concentration;
350 lvector_t< double > ts_co2_concentration_fl;
351 lvector_t< double > ts_ch4_concentration_fl;
352 lvector_t< double > ts_no_concentration_fl;
353 lvector_t< double > ts_radon_concentration_fl;
354 lvector_t< double > nh3_fl;
355
356 /*********************/
357 /* balance variables */
358 /*********************/
359
360 double tot_c_balance_1;
361 double tot_n_balance_1;
362
363 /************************/
364 /* daily rate variables */
365 /************************/
366
367 // Groundwater access
368 double day_no3_groundwater_access;
369
370 // Mineralisation
371 double day_min_n_decomp;
372 double day_min_n_aorg;
373 double day_min_n_mic_1;
374 double day_min_n_mic_2;
375 double day_min_n_mic_3;
376
377 // Assimilation
378 double day_assi_n_mic_1;
379 double day_assi_n_mic_2;
380 double day_assi_n_mic_3;
381 double day_assi_c_mic_1;
382 double day_assi_c_mic_2;
383 double day_assi_c_mic_3;
384
385 // Nitrification
386 double day_nit_nh4_no2;
387 double day_nit_no2_no;
388 double day_nit_no2_n2o;
389
390 // Denitrification
391 double day_denit_no3_no2;
392 double day_denit_no2_no;
393 double day_denit_no2_n2o;
394 double day_denit_no2_n2;
395 double day_denit_no_n2o;
396 double day_denit_no_n2;
397 double day_denit_n2o_n2;
398 double day_chemodenit_no2_no;
399
400 // Respiration / Fermentation / Methanogenesis
401 double day_co2_prod_mic_1_growth;
402 double day_co2_prod_mic_1_maintenance;
403 double day_co2_prod_mic_2;
404 double day_co2_prod_mic_3_acetate_prod;
405 double day_co2_prod_mic_3_acetate_cons;
406 double day_co2_prod_ch4_prod;
407 double day_co2_prod_ch4_cons;
408
409 // Leaching
410 double day_leach_o2;
411 double day_leach_n2o;
412 double day_leach_n2;
413 double day_leach_no;
414 double day_leach_nh3;
415 double day_leach_urea;
416 double day_leach_radon;
417
418 // litter and algae
419 double accumulated_c_litter_above_old;
420 double accumulated_c_litter_below_old;
421
422 double dC_root_exsudates;
423 double dC_litter_algae;
424
425 // Decomposition
426 double day_decomp_c_lit_1;
427 double day_decomp_c_lit_2;
428 double day_decomp_c_lit_3;
429 double day_decomp_n_lit_1;
430 double day_decomp_n_lit_2;
431 double day_decomp_n_lit_3;
432 lvector_t< double > day_decomp_c_hum_1_sl;
433 lvector_t< double > day_decomp_c_hum_2_sl;
434 lvector_t< double > day_decomp_c_hum_3_sl;
435 lvector_t< double > day_decay_c_mic_sl;
436 double day_decomp_n_hum_1;
437 double day_decomp_n_hum_2;
438 double day_decomp_n_hum_3;
439
440 // Humification
441 lvector_t< double > day_c_humify_doc_hum_2_sl;
442 lvector_t< double > day_c_humify_sol_hum_1_sl;
443 lvector_t< double > day_c_humify_cel_hum_1_sl;
444 lvector_t< double > day_c_humify_lig_hum_1_sl;
445 lvector_t< double > day_c_humify_lig_hum_2_sl;
446 lvector_t< double > day_c_humify_mic_hum_1_sl;
447 lvector_t< double > day_c_humify_mic_hum_2_sl;
448 lvector_t< double > day_c_humify_hum_1_hum_2_sl;
449 lvector_t< double > day_c_humify_hum_2_hum_3_sl;
450
451 // Algae
452 double day_n_fix_algae;
453 double day_c_fix_algae;
454
455 // DOC production
456 double day_doc_prod_decomp_litter; // daily doc production by litter decomposition
457 double day_doc_prod_decomp_humus; // daily doc production by humus decomposition
458 double day_doc_prod_decomp_aorg; // daily doc production by active organic material decomposition
459
460
461 /*****************************/
462 /* Litter C- and N-fractions */
463 /*****************************/
464
465 enum atm_eq_liq{ nh3_atm_eq_liq, o2_atm_eq_liq, co2_atm_eq_liq, ch4_atm_eq_liq, n2o_atm_eq_liq, no_atm_eq_liq, radon_atm_eq_liq };
466
467 size_t subdaily_time_step_;
468
469 // Respiration
470 lvector_t< double > co2_auto_sl;
471 lvector_t< double > co2_hetero_sl;
472
473 lvector< double > cn_hum_1_sl;
474 lvector< double > cn_hum_2_sl;
475 lvector< double > cn_hum_3_sl;
476
477 lvector< double > freeze_thaw_fact_sl;
478 lvector< double > litter_type_fact_sl;
479
480 // Iron, sulfate, ...
481 lvector_t< double > day_acetate_cons_fe3_sl;
482 lvector_t< double > day_h2_c_eq_cons_fe3_sl;
483 lvector_t< double > day_fe2_oxidation_sl;
484 lvector_t< double > day_sulfate_reduction_sl;
485 lvector_t< double > day_sulfide_oxidation_sl;
486
487 // Nitrification
488 lvector_t< double > day_nitrify_n2o_sl;
489 lvector_t< double > day_nit_no2_no3_sl;
490
491 // Microbes
492 lvector_t< double > cn_opt_mic_sl;
493
494 // Pool variables
495 lvector_t< double > h2_sl;
496
497 lvector_t< double > o2_liq_sl;
498 lvector_t< double > o2_gas_sl;
499 lvector_t< double > o2_consumption_sl;
500
501 lvector_t< double > ae_acetate_sl;
502 lvector_t< double > an_acetate_sl;
503
504 lvector_t< double > ch4_liq_sl;
505 lvector_t< double > ch4_gas_sl;
506 lvector_t< double > co2_liq_sl;
507 lvector_t< double > co2_gas_sl;
508
509 lvector_t< double > nh4_ae_sl;
510 lvector_t< double > nh4_an_sl;
511
512 lvector_t< double > don_ae_sl;
513 lvector_t< double > don_an_sl;
514
515 lvector_t< double > no3_ae_sl;
516 lvector_t< double > no3_an_sl;
517
518 lvector_t< double > doc_ice_sl;
519 lvector_t< double > acetate_ice_sl;
520 lvector_t< double > no3_ice_sl;
521 lvector_t< double > nh4_ice_sl;
522 lvector_t< double > don_ice_sl;
523
524 lvector_t< double > n2o_liq_sl;
525 lvector_t< double > n2o_gas_sl;
526 lvector_t< double > an_n2o_liq_sl;
527 lvector_t< double > an_n2o_gas_sl;
528 lvector_t< double > n2_gas_sl;
529
530 lvector_t< double > no_liq_sl;
531 lvector_t< double > no_gas_sl;
532 lvector_t< double > an_no_liq_sl;
533 lvector_t< double > an_no_gas_sl;
534
535 lvector_t< double > radon_liq_sl;
536 lvector_t< double > radon_gas_sl;
537
538 lvector_t< double > c_microbial_necromass_sl; // carbon content of microbial necromass
539 lvector_t< double > n_microbial_necromass_sl; // nitrogen content of microbial necromass
540
541 lvector_t< double > c_aged_sl; // carbon content of aged organic matter (peat of peat layers, aged organic matter of the forest floor)
542 lvector_t< double > n_aged_sl; // nitrogen content of aged organic matter (peat of peat layers, aged organic matter of the forest floor)
543
544 lvector_t< double > c_biochar_sl; // carbon content of biochar
545 lvector_t< double > n_biochar_sl; // nitrogen content of biochar
546
547 lvector_t< double > c_humus_1_sl; // carbon content of pom pool
548 lvector_t< double > c_humus_2_sl; // carbon content of maom pool 1
549 lvector_t< double > c_humus_3_sl; // carbon content of maom pool 2
550
551 lvector_t< double > n_humus_1_sl; // nitrogen content of pom pool
552 lvector_t< double > n_humus_2_sl; // nitrogen content of maom pool 1
553 lvector_t< double > n_humus_3_sl; // nitrogen content of maom pool 2
554
555 lvector_t< double > n_micro_1_sl; // nitrogen content of micro_1 pool
556 lvector_t< double > n_micro_2_sl; // nitrogen content of micro_2 pool
557 lvector_t< double > n_micro_3_sl; // nitrogen content of micro_3 pool
558
559
560 // Diffusion
561 lvector_t< double > D_eff_air_fl; // Effective gas diffusion coefficient in atmosphere.
562 lvector_t< double > D_eff_air_sl; // Effective gas diffusion coefficient in soils after WARRICK.
563 lvector_t< double > D_eff_water_sl;
564 lvector_t< double > D_eff_dailyturbation_sl;
565 lvector_t< double > D_eff_plant_sl; // Effective O2 diffusion coefficient in plants
566
567 lvector_t< double > interface_air_sl; // interface of air content between two soil layers
568 lvector_t< double > interface_delta_x_air_sl; // interface of air content between two soil layers divided by distance
569 lvector_t< double > interface_delta_x_water_sl; // interface of water content between two soil layers divided by distance
570 lvector_t< double > interface_delta_x_soil_sl;
571
572 lvector_t< double > delta_x; // interface of water content between two soil layers
573 lvector_t< double > pore_connectivity_sl; // connectivity of pores
574
575 // Soil environment
576 double ph_delta_pab_wl;
577 double ph_delta_urea_wl;
578
579 lvector_t< double > ph_delta_urea_sl;
580 lvector_t< double > ph_delta_manure_sl; // temporary pH offset from manure, reset at start of next day
581
582 lvector_t< double > soil_gas_advection_sl; // soil gas advection [m:s-1]
583 lvector_t< double > v_water_sl; // water volume of soillayer [m3]
584 lvector_t< double > v_air_sl; // air volume of soillayer [m3]
585 lvector_t< double > v_air_diffusion_sl; // air-filled pore volume of soillayer available for gas diffusion (without the minimum air volume) [m3]
586 lvector_t< double > v_ice_sl; // ice volume of soillayer [m3]
587
588 lvector_t< double > communicate_sl;
589 lvector_t< double > communicate_fsl;
590 lvector_t< double > day_denit_factor_c_sl;
591 lvector_t< double > day_denit_factor_n_sl;
592
593 // Methanogenesis
594 lvector_t< double > day_ch4_production_hydrogen_sl;
595 lvector_t< double > day_ch4_production_acetate_sl;
596 lvector_t< double > day_ch4_oxidation_sl; // Layerspecific daily CH4-Oxidation in soil. [kg C-CH4 day-1]
597 double day_ch4_oxidation_la; // CH4-Oxidation in soil. [kg C-CH4 day-1]
598 double day_ch4_oxidation_ha; // CH4-Oxidation in soil. [kg C-CH4 day-1]
599
600 lvector< double > subdaily_ch4_bubbling; // Subdaily CH4 emission rate via bubbling. [kg C m-2 timestep-1]
601 lvector< double > subdaily_ch4_plant; // Subdaily CH4 emission rate via plant diffusion. [kg C m-2 timestep-1]
602 lvector< double > subdaily_ch4_soil; // Subdaily CH4 emission rate via soil diffusion. [kg C m-2 timestep-1]
603 lvector< double > subdaily_ch4_water; // Subdaily CH4 emission rate via water table diffusion. [kg C m-2 timestep-1]
604
605 lvector< double > subdaily_ch4_leach; // Subdaily CH4 leaching rate. [kg C m-2 timestep-1]
606 lvector< double > subdaily_ch4_prod; // Subdaily CH4 production rate. [kg C m-2 timestep-1]
607 lvector< double > subdaily_ch4_ox; // Subdaily CH4 oxidation rate. [kg C m-2 timestep-1]
608 lvector< double > subdaily_ch4_content; // Subdaily CH4 oxidation rate. [kg C m-2 timestep-1]
609
610 lvector< double > subdaily_co2_bubbling; // Subdaily CH4 emission rate via bubbling. [kg C m-2 timestep-1]
611 lvector< double > subdaily_co2_plant; // Subdaily CH4 emission rate via plant diffusion. [kg C m-2 timestep-1]
612 lvector< double > subdaily_co2_soil; // Subdaily CH4 emission rate via soil diffusion. [kg C m-2 timestep-1]
613 lvector< double > subdaily_co2_water; // Subdaily CH4 emission rate via water table diffusion. [kg C m-2 timestep-1]
614 lvector< double > subdaily_co2_leach; // Subdaily CH4 leaching rate. [kg C m-2 timestep-1]
615
616 // Others
617 lvector< double > subdaily_acetate_prod;
618 lvector< double > subdaily_doc_prod;
619
620 lvector< double > subdaily_o2_bubbling;
621 lvector< double > subdaily_o2_plant;
622 lvector< double > subdaily_o2_soil;
623 lvector< double > subdaily_o2_water;
624
625 lvector< double > subdaily_n2o_bubbling;
626 lvector< double > subdaily_n2o_plant;
627 lvector< double > subdaily_n2o_soil;
628 lvector< double > subdaily_n2o_water;
629
630 lvector< double > subdaily_no_bubbling;
631 lvector< double > subdaily_no_plant;
632 lvector< double > subdaily_no_soil;
633 lvector< double > subdaily_no_water;
634
635 lvector< double > subdaily_nh3_bubbling;
636 lvector< double > subdaily_nh3_plant;
637 lvector< double > subdaily_nh3_soil;
638 lvector< double > subdaily_nh3_water;
639
640 lvector< double > subdaily_plant_o2_cons;
641 lvector< double > subdaily_flood_o2_conc;
642 lvector< double > subdaily_algae_o2_prod;
643
644 lvector< double > subdaily_radon_soil;
645 lvector< double > subdaily_radon_plant;
646 lvector< double > subdaily_radon_water;
647
648 lvector< double > day_doc_prod_sl;
649 lvector< double > day_acetate_prod_sl;
650 lvector< double > day_h2_c_eq_prod_sl;
651
652 lvector< double > plant_o2_consumption_sl; // O2 consumption of oxygen per time step. [kg O2 m-2]
653
654 lvector< double > accumulated_n_nh4_throughfall_sl;
655 lvector< double > accumulated_n_no3_throughfall_sl;
656 lvector< double > accumulated_n_nh4_throughfall_sbl;
657 lvector< double > accumulated_n_no3_throughfall_sbl;
658 double accumulated_n_nh4_throughfall_old;
659 double accumulated_n_no3_throughfall_old;
660
661 // N by planting and fixation
662 lvector< double > accumulated_n_to_living_plant_and_algae_from_extern_sl;
663
664 lvector< double > accumulated_n_algae_nh4_uptake_sbl;
665 lvector< double > accumulated_n_algae_no3_uptake_sbl;
666 lvector< double > accumulated_n_algae_nh3_uptake_sbl;
667 lvector< double > accumulated_n_algae_fixation_sbl; // N2 fixation of algae (part of ..._from_extern_sl)
668 lvector< double > accumulated_n_algae_fixation_extra_sbl; // algae N gain without uptake when mineral N is exhausted
669
670 lvector< double > accumulated_n_litter_from_plants_below_rawlitter_sl;
671 lvector< double > accumulated_n_litter_from_plants_below_wood_sl;
672 double accumulated_n_litter_from_plants_above_rawlitter;
673 double accumulated_n_litter_from_plants_above_wood;
674 double accumulated_n_litter_from_plants_above_stubble;
675 lvector< double > accumulated_n_aboveground_raw_litter_fragmentation_sl;
676 lvector< double > accumulated_n_belowground_raw_litter_fragmentation_sl;
677 lvector< double > accumulated_n_litter_from_algae_sl;
678 lvector< double > accumulated_n_litter_from_dung_sl;
679 lvector< double > accumulated_n_urea_from_dung_sl;
680
681 double accumulated_n_export_harvest_cutting_grazing;
682 double accumulated_n_export_harvest_old;
683
684 lvector< double > accumulated_n_nh4_fertilization_sl;
685 lvector< double > accumulated_n_no3_fertilization_sl;
686 lvector< double > accumulated_n_nh3_fertilization_sl;
687 lvector< double > accumulated_n_don_fertilization_sl;
688 lvector< double > accumulated_n_urea_fertilization_sl;
689 lvector< double > accumulated_n_litter_fertilization_sl;
690 lvector< double > accumulated_n_aorg_fertilization_sl;
691 lvector< double > accumulated_n_nh4_fertilization_sbl;
692 lvector< double > accumulated_n_no3_fertilization_sbl;
693 lvector< double > accumulated_n_nh3_fertilization_sbl;
694 lvector< double > accumulated_n_urea_fertilization_sbl;
695
696 /* organic fertilisation (manure events) is counted separately from mineral fertilisation,
697 * so that isotope tracing can tell the two sources apart; the output columns of the
698 * fluxes sink keep reporting the sum of both (see soilchemistry-metrx-output.cpp) */
699 lvector< double > accumulated_n_nh4_manure_sl;
700 lvector< double > accumulated_n_no3_manure_sl;
701 lvector< double > accumulated_n_don_manure_sl;
702 lvector< double > accumulated_n_urea_manure_sl;
703 lvector< double > accumulated_n_litter_manure_sl;
704 lvector< double > accumulated_n_aorg_manure_sl;
705
706 lvector< double > accumulated_n_surface_litter_incorporation_via_tilling_sl;
707 lvector< double > accumulated_n_litter_tilling_sl;
708 lvector< double > accumulated_n_aorg_tilling_sl;
709 lvector< double > accumulated_n_humus_1_tilling_sl;
710 lvector< double > accumulated_n_humus_2_tilling_sl;
711 lvector< double > accumulated_n_humus_3_tilling_sl;
712 lvector< double > accumulated_n_no3_tilling_sl;
713 lvector< double > accumulated_n_no2_tilling_sl;
714 lvector< double > accumulated_n_no_tilling_sl;
715 lvector< double > accumulated_n_n2o_tilling_sl;
716 lvector< double > accumulated_n_urea_tilling_sl;
717 lvector< double > accumulated_n_don_tilling_sl;
718 lvector< double > accumulated_n_nh4_tilling_sl;
719 lvector< double > accumulated_n_nh3_tilling_sl;
720 lvector< double > accumulated_n_microbes_tilling_sl;
721
722 lvector< double > accumulated_n_humus_1_spinup_sl;
723 lvector< double > accumulated_n_humus_2_spinup_sl;
724 lvector< double > accumulated_n_humus_3_spinup_sl;
725 lvector< double > accumulated_n_surface_litter_spinup_sl;
726 lvector< double > accumulated_n_litter_spinup_sl;
727
728 lvector< double > accumulated_n_urea_nh4_hydrolysis_sl;
729 lvector< double > accumulated_n_urea_nh4_hydrolysis_sbl;
730
731 lvector< double > accumulated_n_nh4_assimilation_sl;
732 lvector< double > accumulated_n_no3_assimilation_sl;
733 lvector< double > accumulated_n_don_assimilation_sl;
734
735 lvector< double > accumulated_n_nh4_nh3_conversion_sl;
736 lvector< double > accumulated_n_nh3_nh4_conversion_sl;
737 lvector< double > accumulated_n_nh4_nh3_conversion_sbl;
738 lvector< double > accumulated_n_nh3_nh4_conversion_sbl;
739
740 lvector< double > accumulated_n_micro_leaching_sl;
741 lvector< double > accumulated_n_aorg_leaching_sl;
742 lvector< double > accumulated_n_litter_leaching_sl;
743 lvector< double > accumulated_n_humus_1_leaching_sl;
744 lvector< double > accumulated_n_humus_2_leaching_sl;
745 lvector< double > accumulated_n_humus_3_leaching_sl;
746 lvector< double > accumulated_n_nh4_leaching_sl;
747 lvector< double > accumulated_n_nh3_leaching_sl;
748 lvector< double > accumulated_n_don_leaching_sl;
749 lvector< double > accumulated_n_urea_leaching_sl;
750 lvector< double > accumulated_n_no_leaching_sl;
751 lvector< double > accumulated_n_n2o_leaching_sl;
752
753 lvector< double > accumulated_n_urea_liq_diffusion_sl;
754 lvector< double > accumulated_n_nh3_liq_diffusion_sl;
755 lvector< double > accumulated_n_nh4_liq_diffusion_sl;
756 lvector< double > accumulated_n_no3_liq_diffusion_sl;
757
758 lvector< double > accumulated_n_nh4_infiltration_phys_sl;
759 lvector< double > accumulated_n_nh3_infiltration_phys_sl;
760 lvector< double > accumulated_n_urea_infiltration_phys_sl;
761 lvector< double > accumulated_n_no3_infiltration_phys_sl;
762 lvector< double > accumulated_n_don_infiltration_phys_sl;
763 lvector< double > accumulated_n_aorg_infiltration_phys_sl;
764
765 lvector< double > accumulated_n_nh4_infiltration_leach_sl;
766 lvector< double > accumulated_n_nh3_infiltration_leach_sl;
767 lvector< double > accumulated_n_urea_infiltration_leach_sl;
768 lvector< double > accumulated_n_no3_infiltration_leach_sl;
769 lvector< double > accumulated_n_don_infiltration_leach_sl;
770 lvector< double > accumulated_n_no_infiltration_leach_sl;
771 lvector< double > accumulated_n_n2o_infiltration_leach_sl;
772
773 lvector< double > accumulated_n_nh4_infiltration_liqdif_sl;
774 lvector< double > accumulated_n_nh3_infiltration_liqdif_sl;
775 lvector< double > accumulated_n_urea_infiltration_liqdif_sl;
776 lvector< double > accumulated_n_no3_infiltration_liqdif_sl;
777
778 lvector< double > accumulated_c_ch4_bubbling_sl;
779 lvector< double > accumulated_c_ch4_bubbling_sbl;
780
781 lvector< double > accumulated_n_nh3_bubbling_sl;
782 lvector< double > accumulated_n_no_bubbling_sl;
783 lvector< double > accumulated_n_n2o_bubbling_sl;
784 lvector< double > accumulated_n_nh3_bubbling_sbl;
785 lvector< double > accumulated_n_no_bubbling_sbl;
786 lvector< double > accumulated_n_n2o_bubbling_sbl;
787
788 lvector< double > accumulated_n_nh3_dissolution_sbl;
789 lvector< double > accumulated_n_no_dissolution_sbl;
790 lvector< double > accumulated_n_n2o_dissolution_sbl;
791
792 lvector< double > accumulated_n_nh3_phys_diffusion_sl;
793 lvector< double > accumulated_n_no_phys_diffusion_sl;
794 lvector< double > accumulated_n_n2o_phys_diffusion_sl;
795 lvector< double > accumulated_n_nh3_gas_diffusion_sl;
796 lvector< double > accumulated_n_no_gas_diffusion_sl;
797 lvector< double > accumulated_n_n2o_gas_diffusion_sl;
798
799 lvector< double > accumulated_n_micro_perturbation_sl;
800 lvector< double > accumulated_n_aorg_perturbation_sl;
801 lvector< double > accumulated_n_litter_perturbation_sl;
802 lvector< double > accumulated_n_humus_1_perturbation_sl;
803 lvector< double > accumulated_n_humus_2_perturbation_sl;
804 lvector< double > accumulated_n_humus_3_perturbation_sl;
805
806 lvector< double > accumulated_n_nh4_no2_nitrification_sl;
807 lvector< double > accumulated_n_nh4_no_nitrification_sl;
808 lvector< double > accumulated_n_nh4_n2o_nitrification_sl;
809 lvector< double > accumulated_n_no2_no3_nitrification_sl;
810
811 lvector< double > accumulated_n_no3_no2_denitrification_sl;
812 lvector< double > accumulated_n_no3_no_denitrification_sl;
813 lvector< double > accumulated_n_no3_n2o_denitrification_sl;
814 lvector< double > accumulated_n_no3_n2_denitrification_sl;
815 lvector< double > accumulated_n_no2_no_denitrification_sl;
816 lvector< double > accumulated_n_no2_n2o_denitrification_sl;
817 lvector< double > accumulated_n_no2_n2_denitrification_sl;
818 lvector< double > accumulated_n_no_n2o_denitrification_sl;
819 lvector< double > accumulated_n_no_n2_denitrification_sl;
820 lvector< double > accumulated_n_n2o_n2_denitrification_sl;
821
822 lvector< double > accumulated_n_no2_chemodenitrification_sl;
823
824 lvector< double > accumulated_n_mic_naorg_decay_sl;
825 lvector< double > accumulated_n_mic_nh4_mineral_sl;
826 lvector< double > accumulated_n_mic_don_dissolve_sl;
827
828 lvector< double > accumulated_n_aorg_nh4_mineral_sl;
829 lvector< double > accumulated_n_aorg_don_dissolve_sl;
830
831 lvector< double > accumulated_n_humus_1_don_dissolve_sl;
832 lvector< double > accumulated_n_humus_1_nh4_mineral_sl;
833 lvector< double > accumulated_n_humus_2_don_dissolve_sl;
834 lvector< double > accumulated_n_humus_2_nh4_mineral_sl;
835 lvector< double > accumulated_n_humus_3_don_dissolve_sl;
836 lvector< double > accumulated_n_humus_3_nh4_mineral_sl;
837
838 lvector< double > accumulated_n_litter_don_dissolve_sl;
839 lvector< double > accumulated_n_litter_nh4_mineral_sl;
840
841 lvector< double > accumulated_n_don_humus_1_humify_sl;
842 lvector< double > accumulated_n_don_humus_2_humify_sl;
843 lvector< double > accumulated_n_don_humus_3_humify_sl;
844 lvector< double > accumulated_n_litter_humus_1_humify_sl;
845 /* aged organic matter (not in the metrxfluxes output; aged decomposition is also contained in
846 * the humus_1 decomposition counters) */
847 lvector< double > accumulated_n_humus_1_aged_sl;
848 lvector< double > accumulated_n_aged_don_dissolve_sl;
849 lvector< double > accumulated_n_aged_nh4_mineral_sl;
850
851 lvector< double > accumulated_c_root_exsudates_old_sl;
852
853 lvector_t< double > ranvf_sl;
854 lvector_t< double > cumulative_freezing_degree_days_sl;
855 lvector_t< double > cfdd_turnover_sl;
856
857 class SpinUp
858 {
859 public:
860
861 SpinUp( size_t _y, size_t _sl_cnt) : spinup_type_( 0),
862 spinup_years_( 0),
863 executed_months_( 0),
864 months_delta_c_exceeds_input_( 0),
865 execute_( false),
866 sl_cnt_( _sl_cnt),
867 window_( SPINUP_WINDOW * SPINUP_FLUX_CNT * _sl_cnt, 0.0),
868 c_to_humus_1_sl( _sl_cnt, 0.0),
869 c_to_humus_2_sl( _sl_cnt, 0.0),
870 c_to_humus_3_sl( _sl_cnt, 0.0),
871 k_humify_hum_1_2_sl( _sl_cnt, 0.0),
872 k_humify_hum_2_3_sl( _sl_cnt, 0.0),
873 k_decomp_hum_1_sl( _sl_cnt, 0.0),
874 k_decomp_hum_2_sl( _sl_cnt, 0.0),
875 k_decomp_hum_3_sl( _sl_cnt, 0.0),
876
877 k_loss_lit_1_sl( _sl_cnt, 0.0),
878 k_loss_lit_2_sl( _sl_cnt, 0.0),
879 k_loss_lit_3_sl( _sl_cnt, 0.0),
880
881 c_to_lit_1_sl( _sl_cnt, 0.0),
882 c_to_lit_2_sl( _sl_cnt, 0.0),
883 c_to_lit_3_sl( _sl_cnt, 0.0),
884
885 k_loss_aorg_sl( _sl_cnt, 0.0),
886 c_to_aorg_sl( _sl_cnt, 0.0),
887 kd_lit_1_sl( _sl_cnt, 0.0),
888 kd_lit_2_sl( _sl_cnt, 0.0),
889 kd_lit_3_sl( _sl_cnt, 0.0),
890 khu_lit_1_sl( _sl_cnt, 0.0),
891 khu_lit_2_sl( _sl_cnt, 0.0),
892 khu_lig_hum_1_sl( _sl_cnt, 0.0),
893 khu_lig_hum_2_sl( _sl_cnt, 0.0),
894 kd_aorg_sl( _sl_cnt, 0.0),
895 khu_aorg_hum_1_sl( _sl_cnt, 0.0),
896 khu_aorg_hum_2_sl( _sl_cnt, 0.0),
897 kd_hum_1_sl( _sl_cnt, 0.0),
898 kd_hum_2_sl( _sl_cnt, 0.0),
899 kd_hum_3_sl( _sl_cnt, 0.0),
900 c_doc_decomp_sl( _sl_cnt, 0.0),
901 c_doc_ext_sl( _sl_cnt, 0.0),
902 c_mic_aorg_sl( _sl_cnt, 0.0),
903 c_doc_hum_2_sl( _sl_cnt, 0.0),
904 c_tr_aorg_sl( _sl_cnt, 0.0),
905 c_tr_hum_1_sl( _sl_cnt, 0.0),
906 c_tr_hum_2_sl( _sl_cnt, 0.0),
907 c_doc_aged_sl( _sl_cnt, 0.0),
908 k_age_hum_1_sl( _sl_cnt, 0.0),
909 k_dc_aged_sl( _sl_cnt, 0.0),
910
911 have_reference_( false),
912 c_change_raw_( 0.0),
913 c_to_aged_( 0.0),
914 c_aged_refill_( 0.0),
915 c_change_floor_( 0.0),
916 c_aged_decomp_sl( _sl_cnt, 0.0),
917 n_aged_decomp_sl( _sl_cnt, 0.0),
918 window_raw_( SPINUP_WINDOW * RAW_FLUX_CNT * (_sl_cnt + 1), 0.0),
919 k_loss_raw( _sl_cnt + 1, 0.0),
920 c_loss_raw( 3 * (_sl_cnt + 1), 0.0),
921 n_loss_raw( 3 * (_sl_cnt + 1), 0.0),
922 c_ref_raw( 3 * (_sl_cnt + 1), 0.0),
923 n_ref_raw( 3 * (_sl_cnt + 1), 0.0),
924 c_floor_ref_sl( _sl_cnt, 0.0),
925 n_floor_ref_sl( _sl_cnt, 0.0)
926 {
927 this->set_spinup_years( _y);
928 }
929
930 ~SpinUp()
931 {}
932
933 public:
934
936 static size_t const SPINUP_WINDOW = 12;
938 static size_t const SPINUP_FLUX_CNT = 39;
939
941 lvector< double > & flux( size_t _f)
942 {
943 switch ( _f)
944 {
945 case 0: return c_to_humus_1_sl;
946 case 1: return c_to_humus_2_sl;
947 case 2: return c_to_humus_3_sl;
948 case 3: return k_humify_hum_1_2_sl;
949 case 4: return k_humify_hum_2_3_sl;
950 case 5: return k_decomp_hum_1_sl;
951 case 6: return k_decomp_hum_2_sl;
952 case 7: return k_decomp_hum_3_sl;
953 case 8: return k_loss_lit_1_sl;
954 case 9: return k_loss_lit_2_sl;
955 case 10: return k_loss_lit_3_sl;
956 case 11: return c_to_lit_1_sl;
957 case 12: return c_to_lit_2_sl;
958 case 13: return c_to_lit_3_sl;
959 case 14: return k_loss_aorg_sl;
960 case 15: return c_to_aorg_sl;
961 case 16: return kd_lit_1_sl;
962 case 17: return kd_lit_2_sl;
963 case 18: return kd_lit_3_sl;
964 case 19: return khu_lit_1_sl;
965 case 20: return khu_lit_2_sl;
966 case 21: return khu_lig_hum_1_sl;
967 case 22: return khu_lig_hum_2_sl;
968 case 23: return kd_aorg_sl;
969 case 24: return khu_aorg_hum_1_sl;
970 case 25: return khu_aorg_hum_2_sl;
971 case 26: return kd_hum_1_sl;
972 case 27: return kd_hum_2_sl;
973 case 28: return kd_hum_3_sl;
974 case 29: return c_doc_decomp_sl;
975 case 30: return c_doc_ext_sl;
976 case 31: return c_mic_aorg_sl;
977 case 32: return c_doc_hum_2_sl;
978 case 33: return c_tr_aorg_sl;
979 case 34: return c_tr_hum_1_sl;
980 case 35: return c_tr_hum_2_sl;
981 case 36: return c_doc_aged_sl;
982 case 37: return k_age_hum_1_sl;
983 case 38: return k_dc_aged_sl;
984 default: return c_to_aorg_sl;
985 }
986 }
987
989 void store_month()
990 {
991 size_t const slot( executed_months_ % SPINUP_WINDOW);
992 for ( size_t f = 0; f < SPINUP_FLUX_CNT; ++f)
993 {
994 lvector< double > & flux_f( flux( f));
995 for ( size_t sl = 0; sl < sl_cnt_; ++sl)
996 {
997 window_[(slot * SPINUP_FLUX_CNT + f) * sl_cnt_ + sl] = flux_f[sl];
998 }
999 }
1000 }
1001
1003 double window_sum( size_t _f, size_t _sl) const
1004 {
1005 double sum( 0.0);
1006 for ( size_t slot = 0; slot < SPINUP_WINDOW; ++slot)
1007 {
1008 sum += window_[(slot * SPINUP_FLUX_CNT + _f) * sl_cnt_ + _sl];
1009 }
1010 return sum;
1011 }
1012
1014 size_t window_months() const
1015 {
1016 return ( executed_months_ < SPINUP_WINDOW) ? executed_months_ : SPINUP_WINDOW;
1017 }
1018
1020 size_t pos_cnt() const
1021 {
1022 return sl_cnt_ + 1;
1023 }
1024
1026 static size_t const RAW_FLUX_CNT = 7;
1027 enum { RAW_C_IN_1, RAW_C_IN_2, RAW_C_IN_3, RAW_N_IN_1, RAW_N_IN_2, RAW_N_IN_3, RAW_K_LOSS};
1028
1030 void store_month_raw( size_t _f, size_t _pos, double _value)
1031 {
1032 size_t const slot( executed_months_ % SPINUP_WINDOW);
1033 window_raw_[(slot * RAW_FLUX_CNT + _f) * pos_cnt() + _pos] = _value;
1034 }
1035
1037 double window_sum_raw( size_t _f, size_t _pos) const
1038 {
1039 double sum( 0.0);
1040 for ( size_t slot = 0; slot < SPINUP_WINDOW; ++slot)
1041 {
1042 sum += window_raw_[(slot * RAW_FLUX_CNT + _f) * pos_cnt() + _pos];
1043 }
1044 return sum;
1045 }
1046
1048 bool active() const
1049 {
1050 return execute_ && (spinup_type_ != 0);
1051 }
1052
1054 void reset()
1055 {
1056 c_to_humus_1_sl = 0.0;
1057 c_to_humus_2_sl = 0.0;
1058 c_to_humus_3_sl = 0.0;
1059 k_humify_hum_1_2_sl = 0.0;
1060 k_humify_hum_2_3_sl = 0.0;
1061 k_decomp_hum_1_sl = 0.0;
1062 k_decomp_hum_2_sl = 0.0;
1063 k_decomp_hum_3_sl = 0.0;
1064
1065 k_loss_lit_1_sl = 0.0;
1066 k_loss_lit_2_sl = 0.0;
1067 k_loss_lit_3_sl = 0.0;
1068
1069 c_to_lit_1_sl = 0.0;
1070 c_to_lit_2_sl = 0.0;
1071 c_to_lit_3_sl = 0.0;
1072
1073 k_loss_aorg_sl = 0.0;
1074 c_to_aorg_sl = 0.0;
1075 kd_lit_1_sl = 0.0;
1076 kd_lit_2_sl = 0.0;
1077 kd_lit_3_sl = 0.0;
1078 khu_lit_1_sl = 0.0;
1079 khu_lit_2_sl = 0.0;
1080 khu_lig_hum_1_sl = 0.0;
1081 khu_lig_hum_2_sl = 0.0;
1082 kd_aorg_sl = 0.0;
1083 khu_aorg_hum_1_sl = 0.0;
1084 khu_aorg_hum_2_sl = 0.0;
1085 kd_hum_1_sl = 0.0;
1086 kd_hum_2_sl = 0.0;
1087 kd_hum_3_sl = 0.0;
1088 c_doc_decomp_sl = 0.0;
1089 c_doc_ext_sl = 0.0;
1090 c_mic_aorg_sl = 0.0;
1091 c_doc_hum_2_sl = 0.0;
1092 c_tr_aorg_sl = 0.0;
1093 c_tr_hum_1_sl = 0.0;
1094 c_tr_hum_2_sl = 0.0;
1095 c_doc_aged_sl = 0.0;
1096 k_age_hum_1_sl = 0.0;
1097 k_dc_aged_sl = 0.0;
1098
1099 std::fill( k_loss_raw.begin(), k_loss_raw.end(), 0.0);
1100 std::fill( c_loss_raw.begin(), c_loss_raw.end(), 0.0);
1101 std::fill( n_loss_raw.begin(), n_loss_raw.end(), 0.0);
1102 }
1103
1104 inline size_t spinup_type() const
1105 {
1106 return this->spinup_type_;
1107 }
1108
1109 inline size_t spinup_months() const
1110 {
1111 return this->spinup_years_ * 12;
1112 }
1113
1114 inline size_t spinup_years() const
1115 {
1116 return this->spinup_years_;
1117 }
1118
1119 lerr_t stop_spinup()
1120 {
1121 execute_ = false;
1122 return LDNDC_ERR_OK;
1123 }
1124
1125 void set_spinup_type( size_t _t)
1126 {
1127 this->spinup_type_ = _t;
1128 }
1129
1130 void set_spinup_years( size_t _y)
1131 {
1132 this->spinup_years_ = _y;
1133 if ( this->spinup_years_ > 0)
1134 {
1135 this->execute_ = true;
1136 }
1137 }
1138
1139 size_t simulated_years( cbm::sclock_t const *) const;
1140
1141 bool spinup_stage( cbm::sclock_t const *) const;
1142
1143 bool execute_spinup( cbm::sclock_t const *);
1144
1145 size_t spinup_type_;
1146 size_t spinup_years_;
1147 size_t executed_months_;
1148
1150 size_t months_delta_c_exceeds_input_;
1151
1152 private:
1153
1154 bool execute_;
1155
1156 size_t sl_cnt_;
1158 std::vector< double > window_;
1159
1160 public:
1161
1162 /* accumulated values of the current month for each soil layer:
1163 * - c_to_*: carbon fluxes into a pool [kg C m-2]
1164 * - k_*: fractional loss rates of a pool summed over all time steps [-],
1165 * i.e., the corresponding carbon flux is given by k * pool */
1166 lvector< double > c_to_humus_1_sl;
1167 lvector< double > c_to_humus_2_sl;
1168 lvector< double > c_to_humus_3_sl;
1169
1170 lvector< double > k_humify_hum_1_2_sl;
1171 lvector< double > k_humify_hum_2_3_sl;
1172
1173 lvector< double > k_decomp_hum_1_sl;
1174 lvector< double > k_decomp_hum_2_sl;
1175 lvector< double > k_decomp_hum_3_sl;
1176
1177 lvector< double > k_loss_lit_1_sl;
1178 lvector< double > k_loss_lit_2_sl;
1179 lvector< double > k_loss_lit_3_sl;
1180
1181 lvector< double > c_to_lit_1_sl;
1182 lvector< double > c_to_lit_2_sl;
1183 lvector< double > c_to_lit_3_sl;
1184
1185 lvector< double > k_loss_aorg_sl;
1186 lvector< double > c_to_aorg_sl;
1187
1188 /* separated rates and fluxes for the joint equilibrium of the labile pools (see MeTrX_spinup):
1189 * - kd_*: fractional decomposition rates (transfer to DOC) [-]
1190 * - khu_*: fractional humification rates, e.g., khu_lig_hum_2: lignin to humus pool 2 [-]
1191 * - c_doc_decomp / c_doc_ext: DOC production by decomposition / external DOC (root exudation) [kg C m-2]
1192 * - c_mic_aorg: microbial necromass production [kg C m-2]
1193 * - c_doc_hum_2: humification of DOC and acetate to humus pool 2 [kg C m-2]
1194 * - c_tr_*: transport (leaching) from the layer above [kg C m-2] */
1195 lvector< double > kd_lit_1_sl;
1196 lvector< double > kd_lit_2_sl;
1197 lvector< double > kd_lit_3_sl;
1198 lvector< double > khu_lit_1_sl;
1199 lvector< double > khu_lit_2_sl;
1200 lvector< double > khu_lig_hum_1_sl;
1201 lvector< double > khu_lig_hum_2_sl;
1202 lvector< double > kd_aorg_sl;
1203 lvector< double > khu_aorg_hum_1_sl;
1204 lvector< double > khu_aorg_hum_2_sl;
1205 lvector< double > kd_hum_1_sl;
1206 lvector< double > kd_hum_2_sl;
1207 lvector< double > kd_hum_3_sl;
1208 lvector< double > c_doc_decomp_sl;
1209 lvector< double > c_doc_ext_sl;
1210 lvector< double > c_mic_aorg_sl;
1211 lvector< double > c_doc_hum_2_sl;
1212 lvector< double > c_tr_aorg_sl;
1213 lvector< double > c_tr_hum_1_sl;
1214 lvector< double > c_tr_hum_2_sl;
1216 lvector< double > c_doc_aged_sl;
1218 lvector< double > k_age_hum_1_sl;
1219 lvector< double > k_dc_aged_sl;
1220
1222 bool have_reference_;
1224 double c_change_raw_;
1226 double c_to_aged_;
1228 double c_aged_refill_;
1230 double c_change_floor_;
1232 lvector< double > c_aged_decomp_sl;
1233 lvector< double > n_aged_decomp_sl;
1234
1235 private:
1236
1238 std::vector< double > window_raw_;
1239
1240 public:
1241
1242 /* raw litter, index: soil layer or aboveground (pos_cnt()-1);
1243 * raw litter fractions are stored as [3 * position + fraction]:
1244 * - k_loss_*: fractional fragmentation rates of current month summed over all time steps [-]
1245 * - c/n_loss_*: carbon and nitrogen fragmentation of current month [kg m-2]
1246 * - c/n_ref_*: pool size after last spinup update [kg m-2] */
1247 std::vector< double > k_loss_raw;
1248 std::vector< double > c_loss_raw;
1249 std::vector< double > n_loss_raw;
1250 std::vector< double > c_ref_raw;
1251 std::vector< double > n_ref_raw;
1252
1253 /* carbon and nitrogen of forest floor layers at the start of the spinup [kg m-2] */
1254 std::vector< double > c_floor_ref_sl;
1255 std::vector< double > n_floor_ref_sl;
1256 };
1257
1258 SpinUp spinup_;
1259
1260
1261 /*****************/
1262 /*** methods ***/
1263 /*****************/
1264
1270 lerr_t
1271 MeTrX_write_output();
1272
1278 lerr_t
1279 MeTrX_write_output_daily();
1280
1286 lerr_t
1287 MeTrX_write_output_yearly();
1288
1294 lerr_t
1295 MeTrX_write_output_layer_daily();
1296
1302 lerr_t
1303 MeTrX_write_output_layer_yearly();
1304
1310 lerr_t
1311 MeTrX_write_output_fluxes();
1312
1318 lerr_t
1319 MeTrX_write_output_pools();
1320
1326 lerr_t
1327 MeTrX_write_output_subdaily();
1328
1334 lerr_t
1335 MeTrX_write_rates();
1336
1342 lerr_t
1344
1345 lerr_t
1346 MeTrX_irrigate();
1347
1353 lerr_t
1354 MeTrX_liming();
1355
1361 {
1362 cbm::string_t type; /* lime type, "auto" for automatic liming */
1363 double amount; /* amount [kg:ha-1], invalid if not given */
1364 double depth; /* layers starting above this depth are limed [m] */
1365 double ph_target; /* target pH [-], invalid if not given */
1366 };
1367
1374 lerr_t
1376 lime_request_t const & /* liming request */);
1377
1383 double
1385 double /* depth [m] */);
1386
1392 lerr_t
1394
1400 lerr_t
1401 MeTrX_till();
1402
1410 lerr_t
1411 MeTrX_till_typed( tillage_properties_t const &, size_t);
1412
1413 /* isotope tracing (SIMONE), active only with option "isotopes" (iso_ != NULL) */
1414 metrx_isotopes_t * iso_;
1415 lerr_t MeTrX_isotopes_configure( char const * /*configuration file*/);
1416 void MeTrX_isotopes_checkpoint( int /*group*/);
1417 void MeTrX_isotopes_apply( metrx_iso_process_t &);
1418 void MeTrX_isotopes_anchor( int /*group*/);
1419 double MeTrX_isotopes_model_mass( int /*pool*/, size_t /*layer*/);
1420 void MeTrX_isotopes_till_pre();
1421 void MeTrX_isotopes_till_post( tillage_properties_t const &, size_t);
1422 void MeTrX_isotopes_end_of_day();
1423 lerr_t MeTrX_isotopes_register_ports( cbm::io_kcomm_t *);
1424 void MeTrX_isotopes_unregister_ports();
1425 void MeTrX_isotopes_send();
1426 void MeTrX_isotopes_receive_lateral();
1427 void MeTrX_isotopes_incorporation( size_t, size_t, double, double);
1428 void MeTrX_isotopes_initialize();
1429 void MeTrX_isotopes_finalize();
1430 lerr_t MeTrX_write_output_isotopes();
1431 lerr_t MeTrX_write_output_isotope_sources();
1432 lerr_t MeTrX_write_output_isotope_sources_yearly();
1433
1434 /* phosphorus, active only with option "phosphorus" (p_ != NULL) */
1435 metrx_phosphorus_t * p_;
1436 lerr_t MeTrX_phosphorus_configure();
1439 void MeTrX_phosphorus_checkpoint( int /*checkpoint*/);
1440 metrx_p_carbon_t MeTrX_phosphorus_carbon();
1441 double MeTrX_phosphorus_total();
1442 void MeTrX_phosphorus_publish();
1443 void MeTrX_phosphorus_add_labile( double /*kg P m-2*/, size_t /*first layer*/, size_t /*last layer + 1*/);
1444 void MeTrX_phosphorus_fertilize( EventAttributes const &, cbm::string_t const & /*type*/, double /*amount*/, size_t, size_t);
1445 void MeTrX_phosphorus_manure( EventAttributes const &, cbm::string_t const & /*type*/, double /*carbon*/, size_t, size_t);
1446 double MeTrX_phosphorus_solution( size_t /*layer*/);
1450 void MeTrX_phosphorus_end_of_day();
1451 void MeTrX_phosphorus_finalize();
1452 lerr_t MeTrX_write_output_phosphorus();
1453
1459 lerr_t
1460 MeTrX_reset();
1461
1467 lerr_t
1469
1475 lerr_t
1477
1483 lerr_t
1484 MeTrX_update();
1485
1491 lerr_t
1493 char const * /*name*/);
1494
1500 lerr_t
1502
1504 double &
1505 MeTrX_spinup_raw_litter( bool /* carbon */, size_t /* position */, size_t /* fraction */);
1506
1510 lerr_t
1511 MeTrX_balance_check(
1512 unsigned int);
1513
1519 lerr_t
1521
1526 lerr_t
1528
1533 lerr_t
1535
1541 void
1542 MeTrX_advection_move_gas( size_t _from, int _to, double _frac);
1543
1549 void
1551
1557 void
1559 void
1560 MeTrX_groundwater_lateral_solutes();
1561
1565 lerr_t
1566 MeTrX_plant_respiration( int /* time step */);
1567
1568 double
1569 MeTrX_get_wfps(
1570 size_t /* soil layer */);
1571
1575 double
1576 MeTrX_get_wfps_eff(
1577 size_t,
1578 double const &);
1579
1585 lerr_t
1587
1593 lerr_t
1595
1599 double
1600 radon_emanation_coeff(
1601 unsigned int,
1602 const double &,
1603 const double &,
1604 const double &,
1605 const double &);
1606
1612 lerr_t
1614
1618 void
1620 double const &,
1621 double const &,
1622 double const &,
1623 double const &,
1624 double const &,
1625 double const &,
1626 lvector< double > &accumulated_litter_sl);
1627
1633 lerr_t
1635
1641 void
1643
1644 void
1645 MeTrX_liq_diffusion_scale( double &_out, lvector_t< double > &_scale);
1646
1652 void
1654
1660 lerr_t
1662
1666 void
1668
1674 lerr_t
1676
1682 lerr_t
1684
1685 void
1686 MeTrX_ebullition_transfer(
1687 double &,
1688 double &,
1689 double ,
1690 double );
1691
1697 void
1699
1705 void
1707
1713 void
1715
1721 void
1723
1729 void
1731
1737 void
1739
1745 void
1747
1753 void
1755
1761 void
1763
1769 void
1771
1777 lerr_t
1779
1783 double
1784 MeTrX_get_mineral_efficiency(
1785 double,
1786 double);
1787
1791 double
1792 MeTrX_get_micro_c_decay_max(
1793 double &,
1794 size_t const &);
1795
1799 double
1800 MeTrX_get_micro_n_decay_max(
1801 double &,
1802 size_t const &);
1803
1807 void
1808 MeTrX_dead_microbial_biomass_allocation(
1809 size_t /* soil layer */,
1810 double const & /* carbon transfer amount*/,
1811 double const & /* nitrogen transfer amount*/,
1812 double &,
1813 double &);
1814
1818 void
1819 MeTrX_execute_c_growth(
1820 size_t const &,
1821 double ,
1822 double const &,
1823 double &,
1824 double &);
1825
1829 void
1831 double const &,
1832 size_t const &,
1833 bool const &,
1834 double &,
1835 double &,
1836 double &);
1837
1841 double
1842 MeTrX_get_n_growth(
1843 double const &,
1844 double const &,
1845 double const &,
1846 double const &,
1847 double const &);
1848
1854 void
1856
1862 void
1864
1872 lerr_t
1874
1875 void
1876 MeTrX_inhibitor_decay();
1877
1883 void
1885
1891 void
1893
1899 void
1901
1907 void
1909
1915 void
1917
1923 void
1925
1929 double
1931 size_t /* soil layer */);
1932
1938 double
1940
1950 static double
1952 double /* pH */,
1953 double /* pH with 50% response */,
1954 double /* width */);
1955
1965 static double
1967 double /* response factor */,
1968 double /* pH with 50% response */,
1969 double /* width */);
1970
1980 static double
1982 double /* pH */,
1983 double /* pH with optimum response */,
1984 double /* half width */,
1985 double /* exponent */);
1986
1992 double
1993 MeTrX_get_fact_t_microbial( double const &, double const &, double const &,
1994 double const &, double const &);
1995 double
1996 MeTrX_get_fact_t_decomp( size_t const &);
1997 double
1998 MeTrX_get_fact_tm_decomp( size_t const &);
1999 double
2000 MeTrX_get_fact_clay_decomp( size_t const &);
2001 double
2002 MeTrX_get_fact_clay_humify( size_t const &);
2003 double
2004 MeTrX_get_fact_t_mic( size_t const &);
2005 double
2006 MeTrX_get_fact_m_mic( size_t const &);
2007 double
2008 MeTrX_get_fact_tm_mic( size_t const &);
2009
2010 double
2011 MeTrX_get_fact_t_denit( size_t const &);
2012 double
2013 MeTrX_get_fact_m_denit( size_t const &);
2014 double
2015 MeTrX_get_fact_tm_denit( size_t const &);
2016
2020 inline double MeTrX_get_fact_mm( double const &_conc,
2021 double const &_k)
2022 {
2023 return _conc / (_k + _conc);
2024 };
2025
2030 inline double MeTrX_get_k_mm_x_sl( size_t const &_sl,
2031 double const &_k_mm)
2032 {
2033 return _k_mm * sc_.h_sl[_sl];
2034 };
2035
2036
2042 double
2043 MeTrX_get_c_tot();
2044
2050 double
2051 MeTrX_get_n_tot();
2052
2056 double
2057 MeTrX_get_atm_eq_liq( atm_eq_liq const &,
2058 double const &);
2059
2065 lerr_t
2066 MeTrX_receive_state();
2067
2073 lerr_t
2074 MeTrX_send_state();
2075
2082 lerr_t
2083 MeTrX_dissolution_soil( double const &,
2084 double &,
2085 double &);
2086
2092 lerr_t
2093 MeTrX_update_soil_discretization( bool);
2094
2095 bool
2096 MeTrX_forest_ecosytem();
2097
2099 bool
2100 MeTrX_peat_layer( size_t const &);
2101
2103 double
2104 MeTrX_peat_weight( size_t const &);
2105
2107 double
2108 MeTrX_peat_blend( size_t const &, double, double);
2109
2111 double
2112 MeTrX_get_fact_minprot_aged( size_t const &);
2113
2115 double
2116 MeTrX_maom_fine_fraction( size_t const &);
2117
2119 bool
2120 MeTrX_humus_nitrogen( size_t const &, double);
2121
2123 bool
2124 MeTrX_organic_layer( size_t const &);
2125
2127 double
2128 MeTrX_get_hac( size_t const &);
2129};
2130
2131} /*namespace ldndc*/
2132
2133#endif /* LM_SOILCHEMISTRYMETRX_H_ */
void MeTrX_litter_distribution(double const &, double const &, double const &, double const &, double const &, double const &, lvector< double > &accumulated_litter_sl)
Adds carbon and nitrogen litter to soil litter pools.
Definition soilchemistry-metrx-fragmentation.cpp:296
double MeTrX_get_mean_base_ph(double)
Layer-thickness weighted mean of the base pH from the surface to given depth.
Definition soilchemistry-metrx-liming.cpp:126
lerr_t MeTrX_radon_source_sink()
Definition soilchemistry-metrx-physics-chemistry.cpp:563
bool d_eff_millington_quirk_
Definition soilchemistry-metrx.h:326
void MeTrX_gas_liq_diffusion()
coupled diffusion of gaseous and dissolved O2, N2O, NO, CH4, CO2 (and NH3 with surface water) (option...
Definition soilchemistry-metrx-transport.cpp:1362
static double MeTrX_get_fact_ph_logistic(double, double, double)
Logistic pH response 1 / (1 + exp(-(pH - pH_50) / width)), increasing with pH for width > 0,...
Definition soilchemistry-metrx-physics-chemistry.cpp:697
double * gw_exchange_sl
Definition soilchemistry-metrx.h:265
static const double C_SATURATION
Definition soilchemistry-metrx.h:54
void MeTrX_incorporation_floor()
earthworm incorporation of forest floor organic matter into the mineral soil (scaled with the deciduo...
Definition soilchemistry-metrx-transport.cpp:1964
lerr_t MeTrX_reset_subdaily()
Definition soilchemistry-metrx-reset.cpp:221
static double MeTrX_get_ph_of_fact_ph_logistic(double, double, double)
Inverse of MeTrX_get_fact_ph_logistic: pH at which the logistic pH response equals _fact,...
Definition soilchemistry-metrx-physics-chemistry.cpp:704
lerr_t MeTrX_pertubation()
Definition soilchemistry-metrx-transport.cpp:2044
lerr_t MeTrX_advection_equilibrium()
Advection of soil air as instantaneous pressure equilibration (option advection = "equilibrium")
Definition soilchemistry-metrx-transport.cpp:623
double const PH_MAX_CHEMODENIT
Definition soilchemistry-metrx.h:215
void MeTrX_pH_calculation()
Definition soilchemistry-metrx-physics-chemistry.cpp:768
void MeTrX_add_water_solutes(double, double, double, double, double)
Adds solutes of irrigation or flood water to the upper soil layers.
Definition soilchemistry-metrx-management.cpp:418
double & MeTrX_spinup_raw_litter(bool, size_t, size_t)
Carbon (_c = true) or nitrogen of raw litter fraction _f (0: solubles, 1: cellulose,...
Definition soilchemistry-metrx-spinup.cpp:823
void MeTrX_phosphorus_turnover(metrx_p_carbon_t const &)
net mineralisation (shadow balance of the organic pools) and its distribution among the layers
Definition soilchemistry-metrx-phosphorus.cpp:539
static const double PEAT_ORGANIC_VOLUME_1
Definition soilchemistry-metrx.h:59
lerr_t MeTrX_reset_daily()
Definition soilchemistry-metrx-reset.cpp:273
void MeTrX_phosphorus_leaching()
downward transport of solution phosphorus with the water flux of the time step
Definition soilchemistry-metrx-phosphorus.cpp:694
double MeTrX_get_fact_tm_denit(size_t const &)
The temperature and moisture dependency of denitrifying microbes is given by the harmonic mean of a s...
Definition soilchemistry-metrx-denitrification.cpp:736
lerr_t MeTrX_plant_respiration(int)
Updates o2 and co2 concentrations in soil layers. There is no o2 mass conservation guaranteed because...
Definition soilchemistry-metrx-management.cpp:1384
bool anvf_default_
Definition soilchemistry-metrx.h:327
bool d_eff_parameter_
Definition soilchemistry-metrx.h:325
bool ch4_depth_factor_
Definition soilchemistry-metrx.h:331
static const double RHO_ORGANIC_MATTER
Definition soilchemistry-metrx.h:56
void MeTrX_advection_move_gas(size_t _from, int _to, double _frac)
Moves the fraction _frac of all gas phase pools of layer _from to layer _to (_to < 0: emission to the...
Definition soilchemistry-metrx-transport.cpp:548
lerr_t MeTrX_update()
Definition soilchemistry-metrx-communicate.cpp:67
static const double FACT_PH_MIN
Definition soilchemistry-metrx.h:51
double MeTrX_get_fact_m_denit(size_t const &)
The soil moisture response of denitrification is given by a logistic function of the water filled po...
Definition soilchemistry-metrx-denitrification.cpp:713
void MeTrX_phosphorus_fertilize(EventAttributes const &, cbm::string_t const &, double, size_t, size_t)
phosphorus of a fertilizer event: attribute p_amount [kg P ha-1]; for diammonium phosphate (nh4hpo4) ...
Definition soilchemistry-metrx-phosphorus.cpp:325
lerr_t MeTrX_freeze_thaw()
Definition soilchemistry-metrx-physics-chemistry.cpp:502
double const ANVF_ATM
Definition soilchemistry-metrx.h:226
void MeTrX_clay_nh4_equilibrium()
Definition soilchemistry-metrx-physics-chemistry.cpp:100
void MeTrX_phosphorus_manure(EventAttributes const &, cbm::string_t const &, double, size_t, size_t)
phosphorus of a manure event: attributes cp [kg C kg-1 P] and availp [0-1] (inorganic fraction),...
Definition soilchemistry-metrx-phosphorus.cpp:364
void MeTrX_phosphorus_initialize_organic()
organic phosphorus from the carbon pools (first time step, after soil initialization)
Definition soilchemistry-metrx-phosphorus.cpp:236
double MeTrX_get_ph_wl()
Definition soilchemistry-metrx-physics-chemistry.cpp:683
lerr_t MeTrX_metabolism()
Definition soilchemistry-metrx-microbial-dynamics.cpp:261
void MeTrX_soil_organic_matter_turnover()
void MeTrX_phosphorus_sorption()
transfers labile <-> active <-> stable (EPIC/SWAT) or labile <-> stable (Langmuir only)
Definition soilchemistry-metrx-phosphorus.cpp:650
bool advection_equilibrium_
Definition soilchemistry-metrx.h:329
void MeTrX_phosphorus_add_labile(double, size_t, size_t)
adds phosphorus to the labile pools of layers [l_0, l_1) [kg P m-2]
Definition soilchemistry-metrx-phosphorus.cpp:305
bool gas_liq_coupled_
Definition soilchemistry-metrx.h:330
static const double TNORM
Definition soilchemistry-metrx.h:45
std::vector< double > peat_weight_sl_
Definition soilchemistry-metrx.h:295
double MeTrX_get_k_mm_x_sl(size_t const &_sl, double const &_k_mm)
Scales Michaelis-Menten constant according to spatial discretization.
Definition soilchemistry-metrx.h:2030
std::vector< char > organic_layer_sl_
Definition soilchemistry-metrx.h:293
static double MeTrX_get_fact_ph_bell(double, double, double, double)
Bell-shaped pH response 1 / (1 + (|pH - pH_opt| / half_width)^exponent)
Definition soilchemistry-metrx-physics-chemistry.cpp:711
double MeTrX_get_fact_tm_decomp(size_t const &)
Response function for decomposition of organic matter depeding on temperature and moisture.
Definition soilchemistry-metrx-decomposition.cpp:978
lerr_t MeTrX_till_typed(tillage_properties_t const &, size_t)
Tilling with a given tillage type (partial mixing and incorporation, inversion), see Tilling.
Definition soilchemistry-metrx-management.cpp:1050
bool ft_processes_
Definition soilchemistry-metrx.h:324
double MeTrX_get_fact_t_microbial(double const &, double const &, double const &, double const &, double const &)
Definition soilchemistry-metrx-physics-chemistry.cpp:741
lerr_t MeTrX_nitrogen_fertilizer_release()
Transforms nitrogen from slow release nitrogen fertilizer to nh4.
Definition soilchemistry-metrx-management.cpp:1291
lerr_t MeTrX_till()
Definition soilchemistry-metrx-management.cpp:842
double MeTrX_get_ph_sl(size_t)
Returns dynamic pH-value of given soil layer, i.e., the base pH plus temporary changes from urea hydr...
Definition soilchemistry-metrx-physics-chemistry.cpp:668
void MeTrX_nh3_nh4_equilibrium()
Definition soilchemistry-metrx-physics-chemistry.cpp:37
lerr_t MeTrX_check_for_negative_value(char const *)
iterates over complete soilchemistry state and checks for negative values
Definition soilchemistry-metrx-balance-check.cpp:180
lerr_t MeTrX_reset()
Definition soilchemistry-metrx-reset.cpp:193
double MeTrX_get_fact_t_denit(size_t const &)
The soil temperature response of denitrification is based on the temperature dependency of general m...
Definition soilchemistry-metrx-denitrification.cpp:662
std::vector< char > peat_layer_sl_
Definition soilchemistry-metrx.h:291
lerr_t solve()
Definition soilchemistry-metrx-solve.cpp:26
lerr_t MeTrX_apply_lime(lime_request_t const &)
Applies liming to the base pH of the soil layers (currently target mode: raises base pH to target pH)
Definition soilchemistry-metrx-liming.cpp:95
lerr_t MeTrX_liming()
Definition soilchemistry-metrx-liming.cpp:34
lerr_t MeTrX_advection()
Advection of soil air as instantaneous pressure equilibration (option advection = "equilibrium")
Definition soilchemistry-metrx-transport.cpp:406
void MeTrX_isotopes_incorporation(size_t, size_t, double, double)
Definition soilchemistry-metrx-isotopes.cpp:720
lerr_t MeTrX_phosphorus_initialize()
layer properties and inorganic phosphorus from the site input (called in initialize,...
Definition soilchemistry-metrx-phosphorus.cpp:134
double MeTrX_phosphorus_solution(size_t)
Langmuir isotherm: solution concentration [mg P l-1] of the labile pool of a layer.
Definition soilchemistry-metrx-phosphorus.cpp:404
lerr_t MeTrX_fragmentation()
Definition soilchemistry-metrx-fragmentation.cpp:45
bool spinup_aged_
Definition soilchemistry-metrx.h:310
bool anvf_wfps_
Definition soilchemistry-metrx.h:328
bool have_balance_check_
Definition soilchemistry-metrx.h:331
void MeTrX_urea_hydrolysis()
Definition soilchemistry-metrx-management.cpp:1198
bool ft_yes_
Definition soilchemistry-metrx.h:323
void MeTrX_groundwater_access()
Definition soilchemistry-metrx-transport.cpp:847
void MeTrX_execute_n_assimilation(double const &, size_t const &, bool const &, double &, double &, double &)
Microbial nitrogen assimilation (immobilisation) from NH4, NO3 and DON.
Definition soilchemistry-metrx-microbial-dynamics.cpp:431
Spatially explicit groundwater model.
Definition airchemistryput.h:21
Liming request, either from lime event or from automatic liming.
Definition soilchemistry-metrx.h:1361
Definition soilchemistry-metrx-phosphorus.h:62
Properties of a tillage operation. All values except legacy can be overwritten by the corresponding a...
Definition ld_tillage.h:29