LandscapeDNDC 1.37.0
Loading...
Searching...
No Matches
ldndc::SoilChemistryMeTrX Class Reference

Biogeochemical model MeTrx. More...

#include <models/soilchemistry/metrx/soilchemistry-metrx.h>

Collaboration diagram for ldndc::SoilChemistryMeTrX:

Classes

struct  lime_request_t
 Liming request, either from lime event or from automatic liming. More...
 

Public Member Functions

lerr_t solve ()
 

Private Member Functions

void MeTrX_add_water_solutes (double, double, double, double, double)
 Adds solutes of irrigation or flood water to the upper soil layers.
 
lerr_t MeTrX_write_output ()
 
lerr_t MeTrX_write_output_daily ()
 
lerr_t MeTrX_write_output_yearly ()
 
lerr_t MeTrX_write_output_layer_daily ()
 
lerr_t MeTrX_write_output_layer_yearly ()
 
lerr_t MeTrX_write_output_fluxes ()
 
lerr_t MeTrX_write_output_pools ()
 
lerr_t MeTrX_write_output_subdaily ()
 
lerr_t MeTrX_write_rates ()
 
lerr_t MeTrX_fertilize ()
 
lerr_t MeTrX_liming ()
 
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)
 
double MeTrX_get_mean_base_ph (double)
 Layer-thickness weighted mean of the base pH from the surface to given depth.
 
lerr_t MeTrX_manure ()
 
lerr_t MeTrX_till ()
 
lerr_t MeTrX_till_typed (tillage_properties_t const &, size_t)
 Tilling with a given tillage type (partial mixing and incorporation, inversion), see Tilling.
 
void MeTrX_isotopes_incorporation (size_t, size_t, double, double)
 
lerr_t MeTrX_phosphorus_initialize ()
 layer properties and inorganic phosphorus from the site input (called in initialize, before the iron pools are reduced to active iron)
 
void MeTrX_phosphorus_initialize_organic ()
 organic phosphorus from the carbon pools (first time step, after soil initialization)
 
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]
 
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) without p_amount 20.1/18 kg P per kg N; for phosphorus-only types (p, tsp, ssp) without p_amount the attribute amount is taken as phosphorus
 
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), defaults by manure type (starting values, to be checked)
 
double MeTrX_phosphorus_solution (size_t)
 Langmuir isotherm: solution concentration [mg P l-1] of the labile pool of a layer.
 
void MeTrX_phosphorus_turnover (metrx_p_carbon_t const &)
 net mineralisation (shadow balance of the organic pools) and its distribution among the layers
 
void MeTrX_phosphorus_sorption ()
 transfers labile <-> active <-> stable (EPIC/SWAT) or labile <-> stable (Langmuir only)
 
void MeTrX_phosphorus_leaching ()
 downward transport of solution phosphorus with the water flux of the time step
 
lerr_t MeTrX_reset ()
 
lerr_t MeTrX_reset_subdaily ()
 
lerr_t MeTrX_reset_daily ()
 
lerr_t MeTrX_update ()
 
lerr_t MeTrX_check_for_negative_value (char const *)
 iterates over complete soilchemistry state and checks for negative values
 
lerr_t MeTrX_spinup ()
 
double & MeTrX_spinup_raw_litter (bool, size_t, size_t)
 Carbon (_c = true) or nitrogen of raw litter fraction _f (0: solubles, 1: cellulose, 2: lignin) in soil layer _pos or aboveground (_pos = soil layer count)
 
lerr_t MeTrX_physics ()
 
lerr_t MeTrX_advection ()
 Advection of soil air as instantaneous pressure equilibration (option advection = "equilibrium")
 
lerr_t MeTrX_advection_equilibrium ()
 Advection of soil air as instantaneous pressure equilibration (option advection = "equilibrium")
 
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 atmosphere)
 
void MeTrX_leaching ()
 
void MeTrX_groundwater_access ()
 
lerr_t MeTrX_plant_respiration (int)
 Updates o2 and co2 concentrations in soil layers. There is no o2 mass conservation guaranteed because vegetation modules calculate autotrophic respiration without oxygen limitation. When oxygen demand in soil layers is not fullfilled o2_deff stores deficit and increases oxygen demand in following layers.
 
lerr_t MeTrX_freeze_thaw ()
 
lerr_t MeTrX_radon_source_sink ()
 
lerr_t MeTrX_fragmentation ()
 
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.
 
lerr_t MeTrX_gas_diffusion ()
 
void MeTrX_gas_liq_diffusion ()
 coupled diffusion of gaseous and dissolved O2, N2O, NO, CH4, CO2 (and NH3 with surface water) (option gasdiffusion = coupled)
 
void MeTrX_liq_diffusion ()
 
lerr_t MeTrX_pertubation ()
 
void MeTrX_incorporation_floor ()
 earthworm incorporation of forest floor organic matter into the mineral soil (scaled with the deciduous share)
 
lerr_t MeTrX_metabolism ()
 
lerr_t MeTrX_dissolution ()
 
void MeTrX_ebullition ()
 
void MeTrX_iron_reduction ()
 
void MeTrX_iron_oxidation ()
 
void MeTrX_sulfate_reduction ()
 
void MeTrX_sulfide_oxidation ()
 
void MeTrX_algae_dynamics ()
 
void MeTrX_ch4_production ()
 
void MeTrX_ch4_oxidation ()
 
void MeTrX_microbial_dynamics ()
 
void MeTrX_soil_organic_matter_turnover ()
 
lerr_t MeTrX_fermentation ()
 
void MeTrX_execute_n_assimilation (double const &, size_t const &, bool const &, double &, double &, double &)
 Microbial nitrogen assimilation (immobilisation) from NH4, NO3 and DON.
 
void MeTrX_urea_hydrolysis ()
 
void MeTrX_pH_calculation ()
 
lerr_t MeTrX_nitrogen_fertilizer_release ()
 Transforms nitrogen from slow release nitrogen fertilizer to nh4.
 
void MeTrX_nitrification ()
 
void MeTrX_denitrification ()
 
void MeTrX_chemodenitrification ()
 
void MeTrX_clay_nh4_equilibrium ()
 
void MeTrX_nh3_nh4_equilibrium ()
 
void MeTrX_anaerobic_volume ()
 
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 hydrolysis, manure application and iron reduction.
 
double MeTrX_get_ph_wl ()
 
double MeTrX_get_fact_t_microbial (double const &, double const &, double const &, double const &, double const &)
 
double MeTrX_get_fact_tm_decomp (size_t const &)
 Response function for decomposition of organic matter depeding on temperature and moisture.
 
double MeTrX_get_fact_t_denit (size_t const &)
 The soil temperature response \( \phi_{T}\) of denitrification is based on the temperature dependency of general microbial activity (Temperature response of microbial rates, with the same parameters), raised to the power \( \Omega_{MFDTE} \):
 
double MeTrX_get_fact_m_denit (size_t const &)
 The soil moisture response \( \phi_{\theta}\) of denitrification is given by a logistic function of the water filled pore space ( \( wfps = \theta / \theta_{sat} \)), i.e., the response increases up to water saturation:
 
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 soil temperature ( \( \phi_{T}\)) and a soil moisture ( \( \phi_{\theta}\)) response coefficient.
 
double MeTrX_get_k_mm_x_sl (size_t const &_sl, double const &_k_mm)
 Scales Michaelis-Menten constant according to spatial discretization.
 
double MeTrX_get_c_tot ()
 
double MeTrX_get_n_tot ()
 
lerr_t MeTrX_receive_state ()
 
lerr_t MeTrX_send_state ()
 
lerr_t MeTrX_dissolution_soil (double const &, double &, double &)
 
lerr_t MeTrX_update_soil_discretization (bool)
 
bool MeTrX_peat_layer (size_t const &)
 
double MeTrX_peat_weight (size_t const &)
 
double MeTrX_peat_blend (size_t const &, double, double)
 
double MeTrX_get_fact_minprot_aged (size_t const &)
 protection of aged organic matter by the mineral matrix (see metrx_decomposition), (1 - METRX_F_DC_AGED_MINPROT f_min) (1 - METRX_F_DC_AGED_MINPROT_2 f_min^METRX_F_DC_AGED_MINPROT_3), f_min = 1 - 2 corg
 
double MeTrX_maom_fine_fraction (size_t const &)
 
bool MeTrX_humus_nitrogen (size_t const &, double)
 
bool MeTrX_organic_layer (size_t const &)
 
double MeTrX_get_hac (size_t const &)
 

Static Private Member Functions

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, decreasing for width < 0.
 
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, i.e., pH_50 + width * ln(fact / (1 - fact))
 
static double MeTrX_get_fact_ph_bell (double, double, double, double)
 Bell-shaped pH response 1 / (1 + (|pH - pH_opt| / half_width)^exponent)
 

Private Attributes

double const PH_MAX_CHEMODENIT
 
double const ANVF_ATM
 
double * gw_exchange_sl
 
std::vector< char > peat_layer_sl_
 
std::vector< char > organic_layer_sl_
 
std::vector< double > peat_weight_sl_
 
bool spinup_aged_
 
bool ft_yes_
 
bool ft_processes_
 
bool d_eff_parameter_
 
bool d_eff_millington_quirk_
 
bool anvf_default_
 
bool anvf_wfps_
 
bool advection_equilibrium_
 
bool gas_liq_coupled_
 
bool ch4_depth_factor_
 
bool have_balance_check_
 

Static Private Attributes

static const double TNORM = 293.2
 
static const double FACT_PH_MIN = 0.01
 
static const double C_SATURATION = 82.0 * cbm::KG_IN_G
 
static const double RHO_ORGANIC_MATTER = 1.35
 
static const double PEAT_ORGANIC_VOLUME_1 = 0.2
 

Detailed Description

Biogeochemical model MeTrx.

Member Function Documentation

◆ MeTrX_algae_dynamics()

void ldndc::SoilChemistryMeTrX::MeTrX_algae_dynamics ( )
private
Parameters
[in]None
[out]None
Returns
void

Referenced by solve().

Here is the caller graph for this function:

◆ MeTrX_anaerobic_volume()

void ldndc::SoilChemistryMeTrX::MeTrX_anaerobic_volume ( )
private
Parameters
[in]None
[out]None
Returns
void

References MeTrX_get_fact_m_denit(), MeTrX_get_fact_ph_bell(), MeTrX_get_fact_ph_logistic(), MeTrX_get_fact_t_denit(), MeTrX_get_fact_t_microbial(), MeTrX_get_fact_tm_decomp(), MeTrX_get_fact_tm_denit(), MeTrX_get_ph_of_fact_ph_logistic(), MeTrX_get_ph_sl(), and MeTrX_get_ph_wl().

Referenced by solve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_apply_lime()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_apply_lime ( lime_request_t const & _lime)
private

Applies liming to the base pH of the soil layers (currently target mode: raises base pH to target pH)

Returns
error code
96{
97 if ( !cbm::flt_less( _lime.ph_target, PH_MAX))
98 {
99 KLOGERROR( "liming: target pH must be less than ", PH_MAX, " [ph_target=",_lime.ph_target,"]");
100 return LDNDC_ERR_FAIL;
101 }
102
103 //double const ph_before( MeTrX_get_mean_base_ph( _lime.depth));
104
105 //size_t n_limed( 0);
106 for ( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
107 {
108 /* layers starting above liming depth */
109 if ( !cbm::flt_less( sc_.depth_sl[sl] - sc_.h_sl[sl], _lime.depth))
110 {
111 break;
112 }
113 if ( cbm::flt_less( sc_.phi_sl[sl], _lime.ph_target))
114 {
115 sc_.phi_sl[sl] = _lime.ph_target;
116 sc_.ph_sl[sl] = MeTrX_get_ph_sl( sl);
117 //++n_limed;
118 }
119 }
120
121 return LDNDC_ERR_OK;
122}
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

References MeTrX_get_ph_sl().

Referenced by MeTrX_liming().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_ch4_oxidation()

void ldndc::SoilChemistryMeTrX::MeTrX_ch4_oxidation ( )
private
Parameters
[in]None
[out]None
Returns
void

Referenced by solve().

Here is the caller graph for this function:

◆ MeTrX_ch4_production()

void ldndc::SoilChemistryMeTrX::MeTrX_ch4_production ( )
private
Parameters
[in]None
[out]None
Returns
void

Referenced by solve().

Here is the caller graph for this function:

◆ MeTrX_chemodenitrification()

void ldndc::SoilChemistryMeTrX::MeTrX_chemodenitrification ( )
private
Parameters
[in]None
[out]None
Returns
void

References MeTrX_clay_nh4_equilibrium(), and MeTrX_nh3_nh4_equilibrium().

Referenced by solve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_clay_nh4_equilibrium()

void ldndc::SoilChemistryMeTrX::MeTrX_clay_nh4_equilibrium ( )
private
Parameters
[in]None
[out]None
Returns
void
101{
102 for( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
103 {
104 /* partitioning coefficient */
105 double const k_nh4( 1.0);
106
107 /* total mount of n-nh4 [1e3:g] */
108 double const nh4_sol_old( nh4_ae_sl[sl] + nh4_an_sl[sl]);
109 double const nh4_total( nh4_sol_old + sc_.clay_nh4_sl[sl]);
110
111 /* soil mass [1e3:g] */
112 double const m_soil( sc_.get_soil_mass( sl));
113
114 /* soil organic matter content [%] */
115 double const som_percentage( sc_.som_sl[sl] / m_soil * 100.0);
116
117 /* cation exchange capacity [1e-2:mol] */
118 double const cec( cation_exchange_capacity(
119 sc_.clay_sl[sl] * 100.0,
120 sc_.sand_sl[sl] * 100.0,
121 som_percentage,
122 sc_.ph_sl[sl],
123 ECOSYS_GRASSLAND) * m_soil);
124
125 /* nh4 exchange capacity [kg] */
126 double const nh4_capacity( cec * cbm::MN * 1.0e-5);
127
128 /* nh4 per soil mass [1e-5:mol:g] */
129 double const nh4_total_percentage( nh4_total * 1.0e5 / (cbm::MN * m_soil));
130
131 /* adsorbed nh4 percentage [%] */
132 double const nh4_clay_percentage( k_nh4 * nh4_total_percentage);
133
134 /* adsorbed nh4 */
135 double const nh4_clay( cbm::bound_max( nh4_clay_percentage * 1.0e-2 * nh4_capacity, nh4_total));
136
137 /* nh4 - clay_nh4 exchange */
138 double const delta_nh4( cbm::flt_greater( nh4_clay, sc_.clay_nh4_sl[sl]) ?
139 (nh4_clay - sc_.clay_nh4_sl[sl]) * MeTrX_get_wfps( sl) * FTS_TOT_ :
140 (nh4_clay - sc_.clay_nh4_sl[sl]) * MeTrX_get_wfps( sl) * 0.1 * FTS_TOT_);
141
142 sc_.clay_nh4_sl[sl] += delta_nh4;
143 double const nh4_sol_new( nh4_total - sc_.clay_nh4_sl[sl]);
144 if ( cbm::flt_greater_zero( nh4_sol_old))
145 {
146 nh4_ae_sl[sl] = nh4_ae_sl[sl] / nh4_sol_old * nh4_sol_new;
147 nh4_an_sl[sl] = nh4_sol_new - nh4_ae_sl[sl];
148 }
149 else
150 {
151 nh4_ae_sl[sl] = nh4_sol_new * (1.0 - sc_.anvf_sl[sl]);
152 nh4_an_sl[sl] = nh4_sol_new * sc_.anvf_sl[sl];
153 }
154 }
155}
double LDNDC_API cation_exchange_capacity(double _clay, double _sand, double _som, double _ph, ecosystem_type_e _ecosystem)
Detailed description provided here .

References ldndc::cation_exchange_capacity().

Referenced by MeTrX_chemodenitrification(), and solve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_denitrification()

void ldndc::SoilChemistryMeTrX::MeTrX_denitrification ( )
private
Parameters
[in]None
[out]None
Returns
void

Referenced by solve().

Here is the caller graph for this function:

◆ MeTrX_dissolution()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_dissolution ( )
private
Parameters
[in]None
[out]None
Returns
error code

Referenced by solve().

Here is the caller graph for this function:

◆ MeTrX_dissolution_soil()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_dissolution_soil ( double const & _henry,
double & _val_gas,
double & _val_liq )
private
Parameters
[in]_henryNone
[in,out]_gasgaseous species
[in,out]_liqdissolved substance
Returns
error code
759{
760 double const val_tot( _val_gas + _val_liq);
761 if ( cbm::flt_greater_zero( val_tot))
762 {
763 _val_liq = _henry / (1.0 + _henry) * val_tot;
764 _val_gas = val_tot - _val_liq;
765 }
766 return LDNDC_ERR_OK;
767}

◆ MeTrX_ebullition()

void ldndc::SoilChemistryMeTrX::MeTrX_ebullition ( )
private
Parameters
[in]None
[out]None
Returns
void

Referenced by solve().

Here is the caller graph for this function:

◆ MeTrX_execute_n_assimilation()

void ldndc::SoilChemistryMeTrX::MeTrX_execute_n_assimilation ( double const & _pot_n_growth,
size_t const & _sl,
bool const & _aerob,
double & _n_mic_x,
double & _day_n_min,
double & _day_n_assi )
private

Microbial nitrogen assimilation (immobilisation) from NH4, NO3 and DON.

Microbial nitrogen assimilation

The N demand of microbial growth \( N_{pot} \) is met from ammonium, nitrate and dissolved organic nitrogen of the aerobic or anaerobic soil fraction.

  • METRX_KR_NO3_ASSI \( < 0 \) (default): all three pools are used in proportion to their size, \( f = \min(N_{pot} / (NH_4 + NO_3 + DON), 0.9) \).
  • METRX_KR_NO3_ASSI \( = k \geq 0 \) [d-1]: NH4 and DON are used first, \( f = \min(N_{pot} / (NH_4 + DON), 0.9) \); nitrate covers only the remaining demand and is limited to a first-order rate, \( \Delta NO_3 = \min(N_{pot} - f (NH_4 + DON),\; NO_3 (1 - e^{-k \Delta t})) \). This represents the repression of assimilatory nitrate reduction by ammonium and the preference of heterotrophs for NH4 and organic N (Rice & Tiedje 1989; Recous et al. 1990); k = 0 switches nitrate assimilation off.
438{
439 //dot_metrx_nitrogen nh4_sl -> n_micro_sl [label="assi."];
440 //dot_metrx_nitrogen don_sl -> n_micro_sl [label="assi."];
441 //dot_metrx_nitrogen no3_sl -> n_micro_sl [label="assi."];
442 //dot_metrx_nitrogen no2_sl -> n_micro_sl [label="assi."];
443 double const kr_no3_assi( sipar_.METRX_KR_NO3_ASSI());
444 if ( kr_no3_assi >= 0.0 && cbm::flt_greater_zero( _pot_n_growth))
445 {
446 /* NO3 assimilation fraction per time step, exp only evaluated when k or the time step changes */
447 static thread_local double kr_last( -1.0), fts_last( -1.0), frac_last( 0.0);
448 if ( !cbm::flt_equal( kr_no3_assi, kr_last) || !cbm::flt_equal( FTS_TOT_, fts_last))
449 {
450 kr_last = kr_no3_assi;
451 fts_last = FTS_TOT_;
452 frac_last = 1.0 - std::exp( -kr_no3_assi * FTS_TOT_);
453 }
454 double nh4_use( 0.0), no3_use( 0.0), don_use( 0.0);
455 if ( _aerob)
456 {
457 metrx_n_assimilation_no3_limited( _pot_n_growth, frac_last, nh4_ae_sl[_sl], no3_ae_sl[_sl], don_ae_sl[_sl],
458 nh4_use, no3_use, don_use);
459 }
460 else
461 {
462 metrx_n_assimilation_no3_limited( _pot_n_growth, frac_last, nh4_an_sl[_sl], no3_an_sl[_sl], don_an_sl[_sl],
463 nh4_use, no3_use, don_use);
464 }
465 double const n_assi( nh4_use + no3_use + don_use);
466 _n_mic_x += n_assi;
467
468 // output
469 _day_n_assi += n_assi;
470 sc_.accumulated_n_immobilisation_sl[_sl] += n_assi;
471 accumulated_n_nh4_assimilation_sl[_sl] += nh4_use;
472 accumulated_n_no3_assimilation_sl[_sl] += no3_use;
473 accumulated_n_don_assimilation_sl[_sl] += don_use;
474 }
475 else if ( cbm::flt_greater_zero( _pot_n_growth))
476 {
477 /* Calculation of currently available N for assimilation */
478 if ( _aerob)
479 {
480 double const n_avail_assi_ae( nh4_ae_sl[_sl] + no3_ae_sl[_sl] + don_ae_sl[_sl]);
481 if ( cbm::flt_greater_zero( n_avail_assi_ae))
482 {
483 double const use_factor( std::min( _pot_n_growth / n_avail_assi_ae, 0.9));
484 double const nh4_use( nh4_ae_sl[_sl] * use_factor);
485 double const no3_use( no3_ae_sl[_sl] * use_factor);
486 double const don_use( don_ae_sl[_sl] * use_factor);
487
488 nh4_ae_sl[_sl] -= nh4_use;
489 no3_ae_sl[_sl] -= no3_use;
490 don_ae_sl[_sl] -= don_use;
491
492 double const n_assi( nh4_use + no3_use + don_use);
493 _n_mic_x += n_assi;
494
495 // output
496 _day_n_assi += n_assi;
497 sc_.accumulated_n_immobilisation_sl[_sl] += n_assi;
498 accumulated_n_nh4_assimilation_sl[_sl] += nh4_use;
499 accumulated_n_no3_assimilation_sl[_sl] += no3_use;
500 accumulated_n_don_assimilation_sl[_sl] += don_use;
501 }
502 }
503 else
504 {
505 double const n_avail_assi_an( nh4_an_sl[_sl] + no3_an_sl[_sl] + don_an_sl[_sl]);
506 if ( cbm::flt_greater_zero( n_avail_assi_an))
507 {
508 double const use_factor( std::min( _pot_n_growth / n_avail_assi_an, 0.9));
509 double const an_nh4_use( nh4_an_sl[_sl] * use_factor);
510 double const an_no3_use( no3_an_sl[_sl] * use_factor);
511 double const an_don_use( don_an_sl[_sl] * use_factor);
512
513 nh4_an_sl[_sl] -= an_nh4_use;
514 no3_an_sl[_sl] -= an_no3_use;
515 don_an_sl[_sl] -= an_don_use;
516
517 double const n_assi( an_nh4_use + an_no3_use + an_don_use);
518 _n_mic_x += n_assi;
519
520 // output
521 _day_n_assi += n_assi;
522 sc_.accumulated_n_immobilisation_sl[_sl] += n_assi;
523 accumulated_n_nh4_assimilation_sl[_sl] += an_nh4_use;
524 accumulated_n_no3_assimilation_sl[_sl] += an_no3_use;
525 accumulated_n_don_assimilation_sl[_sl] += an_don_use;
526 }
527 }
528 }
529 else
530 {
531 //dot_metrx_nitrogen n_micro_sl -> nh4_sl [label="mineral."];
532 //dot_metrx_nitrogen n_micro_sl -> don_sl [label="mineral."];
533 /* If microbial N is higher than current cn_opt suggests N-surplus is assumed to be mineralised to nh4 and released to soil */
534 /* Note: _pot_n_growth < 0.0 */
535 double const n_free( -1.0 * _pot_n_growth);
536 if ( cbm::flt_greater_zero( n_free))
537 {
538 double const mineral_n( sipar_.METRX_FRAC_MINERAL() * n_free);
539 nh4_ae_sl[_sl] += mineral_n * (1.0 - sc_.anvf_sl[_sl]);
540 nh4_an_sl[_sl] += mineral_n * sc_.anvf_sl[_sl];
541 don_ae_sl[_sl] += (n_free - mineral_n) * (1.0 - sc_.anvf_sl[_sl]);
542 don_an_sl[_sl] += (n_free - mineral_n) * sc_.anvf_sl[_sl];
543 _n_mic_x -= n_free;
544
545 // output
546 accumulated_n_mic_don_dissolve_sl[_sl] += n_free - mineral_n;
547 accumulated_n_mic_nh4_mineral_sl[_sl] += mineral_n;
548 sc_.accumulated_n_mineral_sl[_sl] += mineral_n;
549 _day_n_min += mineral_n;
550 }
551 }
552}

Referenced by MeTrX_fermentation().

Here is the caller graph for this function:

◆ MeTrX_fermentation()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_fermentation ( )
private
Parameters
[in]None
[out]None
Returns
error code

References MeTrX_execute_n_assimilation(), MeTrX_nitrogen_fertilizer_release(), MeTrX_pH_calculation(), and MeTrX_urea_hydrolysis().

Referenced by solve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_fertilize()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_fertilize ( )
private
Parameters
[in]None
[out]None
Returns
error code

References MeTrX_liming().

Referenced by solve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_fragmentation()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_fragmentation ( )
private
Parameters
[in]None
[out]None
Returns
error code
46{
47 /* wood / stubble / ... -> raw litter */
48
49 //rough estimates of dead wood constituents
50 double const extractives_wood( 0.05);
51 double const cellulose_wood( 0.60); // including hemicellulose
52 double const lignin_wood( 0.35);
53
54 /* spinup: fragmentation rates are accumulated independent of pool size */
55 bool const spinup_stage( spinup_.spinup_stage( this->lclock()));
56 size_t const sl_above( sl_.soil_layer_cnt());
57 if ( spinup_stage)
58 {
59 spinup_.k_loss_raw[sl_above] += K_FRAG_RAW_LITTER * MeTrX_get_fact_tm_decomp( 0);
60 for( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
61 {
62 spinup_.k_loss_raw[sl] += K_FRAG_RAW_LITTER * MeTrX_get_fact_tm_decomp( sl);
63 }
64 }
65
66 /* aboveground wood litter */
67 if ( cbm::flt_greater_zero( sc_.c_wood) ||
68 cbm::flt_greater_zero( sc_.n_wood))
69 {
70 double const k_decay_wood_tm( sipar_.METRX_KR_DC_WOOD_ABOVE() * FTS_TOT_ * MeTrX_get_fact_tm_decomp( 0));
71 double const decay_c_wood( k_decay_wood_tm * sc_.c_wood);
72 double const resp_c_wood( sipar_.METRX_F_RESP_WOOD() * decay_c_wood);
73 double const frag_c_wood( decay_c_wood - resp_c_wood);
74 double const frag_n_wood( k_decay_wood_tm * sc_.n_wood);
75
76 sc_.c_wood -= decay_c_wood;
77 sc_.n_wood -= frag_n_wood;
78
79 /* in-situ respiration of dead wood is emitted directly at the soil surface */
80 co2_hetero_sl[0] += resp_c_wood;
81 subdaily_co2_soil[subdaily_time_step_] += resp_c_wood;
82
83 sc_.c_raw_lit_1_above += extractives_wood * frag_c_wood;
84 sc_.c_raw_lit_2_above += cellulose_wood * frag_c_wood;
85 sc_.c_raw_lit_3_above += lignin_wood * frag_c_wood;
86
87 sc_.n_raw_lit_1_above += extractives_wood * frag_n_wood;
88 sc_.n_raw_lit_2_above += cellulose_wood * frag_n_wood;
89 sc_.n_raw_lit_3_above += lignin_wood * frag_n_wood;
90 }
91
92 /* belowground wood litter */
93 for( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
94 {
95 if ( cbm::flt_greater_zero( sc_.c_wood_sl[sl]) ||
96 cbm::flt_greater_zero( sc_.n_wood_sl[sl]))
97 {
98 double const k_frag_wood_tm( K_FRAG_WOOD * MeTrX_get_fact_tm_decomp( sl));
99 double const frag_c_wood( k_frag_wood_tm * sc_.c_wood_sl[sl]);
100 double const frag_n_wood( k_frag_wood_tm * sc_.n_wood_sl[sl]);
101
102 sc_.c_wood_sl[sl] -= frag_c_wood;
103 sc_.n_wood_sl[sl] -= frag_n_wood;
104
105 sc_.c_raw_lit_1_sl[sl] += extractives_wood * frag_c_wood;
106 sc_.c_raw_lit_2_sl[sl] += cellulose_wood * frag_c_wood;
107 sc_.c_raw_lit_3_sl[sl] += lignin_wood * frag_c_wood;
108
109 sc_.n_raw_lit_1_sl[sl] += extractives_wood * frag_n_wood;
110 sc_.n_raw_lit_2_sl[sl] += cellulose_wood * frag_n_wood;
111 sc_.n_raw_lit_3_sl[sl] += lignin_wood * frag_n_wood;
112 }
113 }
114
115
116 /* stubble litter */
117 if ( cbm::flt_greater_zero( sc_.c_stubble_lit1 + sc_.c_stubble_lit2 + sc_.c_stubble_lit3))
118 {
119 double const k_frag_stubble_tm( K_FRAG_STUBBLE * MeTrX_get_fact_tm_decomp( 0));
120 double const c_senescence_lit1( k_frag_stubble_tm * sc_.c_stubble_lit1);
121 double const c_senescence_lit2( k_frag_stubble_tm * sc_.c_stubble_lit2);
122 double const c_senescence_lit3( k_frag_stubble_tm * sc_.c_stubble_lit3);
123
124 double const n_senescence_lit1( k_frag_stubble_tm * sc_.n_stubble_lit1);
125 double const n_senescence_lit2( k_frag_stubble_tm * sc_.n_stubble_lit2);
126 double const n_senescence_lit3( k_frag_stubble_tm * sc_.n_stubble_lit3);
127
128 sc_.c_stubble_lit1 -= c_senescence_lit1;
129 sc_.c_stubble_lit2 -= c_senescence_lit2;
130 sc_.c_stubble_lit3 -= c_senescence_lit3;
131
132 sc_.n_stubble_lit1 -= n_senescence_lit1;
133 sc_.n_stubble_lit2 -= n_senescence_lit2;
134 sc_.n_stubble_lit3 -= n_senescence_lit3;
135
136 sc_.c_raw_lit_1_above += c_senescence_lit1;
137 sc_.c_raw_lit_2_above += c_senescence_lit2;
138 sc_.c_raw_lit_3_above += c_senescence_lit3;
139
140 sc_.n_raw_lit_1_above += n_senescence_lit1;
141 sc_.n_raw_lit_2_above += n_senescence_lit2;
142 sc_.n_raw_lit_3_above += n_senescence_lit3;
143 }
144
145
146 /* algae / dung / raw litter -> soil litter */
147
148 /* algae litter */
149 if ( cbm::flt_greater_zero( c_dead_algae) ||
150 cbm::flt_greater_zero( n_dead_algae))
151 {
152 //rough estimates of algae constituents
153 double const extractives_algae( 0.25);
154 double const cellulose_algae( 0.70); // including hemicellulose
155 double const lignin_algae( 0.05);
156
157 double const fact_decomp( K_FRAG_ALGAE * MeTrX_get_fact_tm_decomp( 0));
158 double const c_decomp_algae( fact_decomp * c_dead_algae);
159 double const n_decomp_algae( fact_decomp * n_dead_algae);
160
161 c_dead_algae -= c_decomp_algae;
162 n_dead_algae -= n_decomp_algae;
163
164 MeTrX_litter_distribution( extractives_algae * n_decomp_algae, cellulose_algae * n_decomp_algae, lignin_algae * n_decomp_algae,
165 extractives_algae * c_decomp_algae, cellulose_algae * c_decomp_algae, lignin_algae * c_decomp_algae,
166 accumulated_n_litter_from_algae_sl);
167
168 dC_litter_algae += c_decomp_algae;
169
170 if ( !cbm::flt_greater_zero( c_dead_algae))
171 {
172 c_dead_algae = 0.0;
173 }
174 if ( !cbm::flt_greater_zero( n_dead_algae))
175 {
176 n_dead_algae = 0.0;
177 }
178 }
179
180 /* dung and urine */
181 if ( cbm::flt_greater_zero( sc_.c_dung) ||
182 cbm::flt_greater_zero( sc_.n_dung) ||
183 cbm::flt_greater_zero( sc_.n_urine))
184 {
185 MeTrX_litter_distribution( 0.25 * sc_.n_dung, 0.7 * sc_.n_dung, 0.05 * sc_.n_dung,
186 0.25 * sc_.c_dung, 0.7 * sc_.c_dung, 0.05 * sc_.c_dung,
187 accumulated_n_litter_from_dung_sl);
188
189 for( size_t sl = 0; sl <= SL_SURFACE_DISTRIBUTION; ++sl)
190 {
191 sc_.urea_sl[sl] += sc_.n_urine * SL_SURFACE_DISTRIBUTION_INVERSE;
192 accumulated_n_urea_from_dung_sl[sl] += sc_.n_urine * SL_SURFACE_DISTRIBUTION_INVERSE;
193 }
194
195 sc_.accumulated_c_livestock_grazing += sc_.c_dung;
196 sc_.accumulated_n_livestock_grazing += sc_.n_dung + sc_.n_urine;
197
198 sc_.c_dung = 0.0;
199 sc_.n_dung = 0.0;
200 sc_.n_urine = 0.0;
201 }
202
203 /* aboveground raw litter */
204 if ( cbm::flt_greater_zero( sc_.c_raw_lit_1_above + sc_.c_raw_lit_2_above + sc_.c_raw_lit_3_above))
205 {
206 double const k_frag_raw_litter_tm( K_FRAG_RAW_LITTER * MeTrX_get_fact_tm_decomp( 0));
207 double const c_senescence_lit1( k_frag_raw_litter_tm * sc_.c_raw_lit_1_above);
208 double const c_senescence_lit2( k_frag_raw_litter_tm * sc_.c_raw_lit_2_above);
209 double const c_senescence_lit3( k_frag_raw_litter_tm * sc_.c_raw_lit_3_above);
210
211 double const n_senescence_lit1( k_frag_raw_litter_tm * sc_.n_raw_lit_1_above);
212 double const n_senescence_lit2( k_frag_raw_litter_tm * sc_.n_raw_lit_2_above);
213 double const n_senescence_lit3( k_frag_raw_litter_tm * sc_.n_raw_lit_3_above);
214
215 sc_.c_raw_lit_1_above -= c_senescence_lit1;
216 sc_.c_raw_lit_2_above -= c_senescence_lit2;
217 sc_.c_raw_lit_3_above -= c_senescence_lit3;
218
219 sc_.n_raw_lit_1_above -= n_senescence_lit1;
220 sc_.n_raw_lit_2_above -= n_senescence_lit2;
221 sc_.n_raw_lit_3_above -= n_senescence_lit3;
222
223 MeTrX_litter_distribution( n_senescence_lit1, n_senescence_lit2, n_senescence_lit3,
224 c_senescence_lit1, c_senescence_lit2, c_senescence_lit3,
225 accumulated_n_aboveground_raw_litter_fragmentation_sl);
226
227 if ( spinup_stage)
228 {
229 spinup_.c_loss_raw[3 * sl_above] += c_senescence_lit1;
230 spinup_.c_loss_raw[3 * sl_above + 1] += c_senescence_lit2;
231 spinup_.c_loss_raw[3 * sl_above + 2] += c_senescence_lit3;
232 spinup_.n_loss_raw[3 * sl_above] += n_senescence_lit1;
233 spinup_.n_loss_raw[3 * sl_above + 1] += n_senescence_lit2;
234 spinup_.n_loss_raw[3 * sl_above + 2] += n_senescence_lit3;
235 }
236 }
237
238 /* belowground raw litter */
239 for( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
240 {
241 double const c_raw_litter_tot( sc_.c_raw_lit_1_sl[sl] + sc_.c_raw_lit_2_sl[sl] + sc_.c_raw_lit_3_sl[sl]);
242 if ( cbm::flt_greater_zero( c_raw_litter_tot))
243 {
244 double const fact_decomp( K_FRAG_RAW_LITTER * MeTrX_get_fact_tm_decomp( sl));
245 double const c_decomp_lit1( fact_decomp * sc_.c_raw_lit_1_sl[sl]);
246 double const c_decomp_lit2( fact_decomp * sc_.c_raw_lit_2_sl[sl]);
247 double const c_decomp_lit3( fact_decomp * sc_.c_raw_lit_3_sl[sl]);
248
249 double const n_decomp_lit1( fact_decomp * sc_.n_raw_lit_1_sl[sl]);
250 double const n_decomp_lit2( fact_decomp * sc_.n_raw_lit_2_sl[sl]);
251 double const n_decomp_lit3( fact_decomp * sc_.n_raw_lit_3_sl[sl]);
252
253 sc_.c_raw_lit_1_sl[sl] -= c_decomp_lit1;
254 sc_.c_raw_lit_2_sl[sl] -= c_decomp_lit2;
255 sc_.c_raw_lit_3_sl[sl] -= c_decomp_lit3;
256
257 sc_.n_raw_lit_1_sl[sl] -= n_decomp_lit1;
258 sc_.n_raw_lit_2_sl[sl] -= n_decomp_lit2;
259 sc_.n_raw_lit_3_sl[sl] -= n_decomp_lit3;
260
261 sc_.C_lit1_sl[sl] += c_decomp_lit1;
262 sc_.C_lit2_sl[sl] += c_decomp_lit2;
263 sc_.C_lit3_sl[sl] += c_decomp_lit3;
264
265 sc_.N_lit1_sl[sl] += n_decomp_lit1;
266 sc_.N_lit2_sl[sl] += n_decomp_lit2;
267 sc_.N_lit3_sl[sl] += n_decomp_lit3;
268
269 accumulated_n_belowground_raw_litter_fragmentation_sl[sl] += n_decomp_lit1 + n_decomp_lit2 + n_decomp_lit3;
270
271 if ( spinup_stage)
272 {
273 spinup_.c_to_lit_1_sl[sl] += c_decomp_lit1;
274 spinup_.c_to_lit_2_sl[sl] += c_decomp_lit2;
275 spinup_.c_to_lit_3_sl[sl] += c_decomp_lit3;
276
277 spinup_.c_loss_raw[3 * sl] += c_decomp_lit1;
278 spinup_.c_loss_raw[3 * sl + 1] += c_decomp_lit2;
279 spinup_.c_loss_raw[3 * sl + 2] += c_decomp_lit3;
280 spinup_.n_loss_raw[3 * sl] += n_decomp_lit1;
281 spinup_.n_loss_raw[3 * sl + 1] += n_decomp_lit2;
282 spinup_.n_loss_raw[3 * sl + 2] += n_decomp_lit3;
283 }
284 }
285 }
286
287 return LDNDC_ERR_OK;
288}
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_fact_tm_decomp(size_t const &)
Response function for decomposition of organic matter depeding on temperature and moisture.
Definition soilchemistry-metrx-decomposition.cpp:978

References MeTrX_get_fact_tm_decomp(), and MeTrX_litter_distribution().

Referenced by MeTrX_leaching(), and solve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_freeze_thaw()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_freeze_thaw ( )
private
Parameters
[in]None
[out]None
Returns
error code
503{
504 if ( ft_processes_ || ft_yes_)
505 {
506 for( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
507 {
508 // ICE + NEG. TEMP.
509 if ( cbm::flt_greater_zero( v_ice_sl[sl]) &&
510 cbm::flt_less_equal( mc_temp_sl[sl], 0.0))
511 {
512 cumulative_freezing_degree_days_sl[sl] += std::abs( mc_temp_sl[sl]) * FTS_TOT_;
513 if ( cbm::flt_less_equal( mc_temp_sl[sl], -sipar_.METRX_CFDD_THRESHOLD()))
514 {
515 cfdd_turnover_sl[sl] += std::abs( mc_temp_sl[sl]) * FTS_TOT_;
516 }
517 }
518 else if ( cbm::flt_greater_equal( mc_temp_sl[sl], 0.0))
519 {
520 if ( cbm::flt_greater( cfdd_turnover_sl[sl], sipar_.METRX_CFDD_MIN()))
521 {
522 // linear function
523 // double c_decomp_aorg(cbm::bound(0.0, cfdd_turnover_sl[sl] / sipar_.METRX_CFDD_MAX(), 0.99) * sc_.C_aorg_sl[sl] * sipar_.METRX_CFDD_TURN_MAX());
524 // double n_decomp_aorg(cbm::bound(0.0, cfdd_turnover_sl[sl] / sipar_.METRX_CFDD_MAX(), 0.99) * sc_.N_aorg_sl[sl] * sipar_.METRX_CFDD_TURN_MAX());
525 // saturation function
526 double c_decomp_aorg( cbm::bound( 0.0, 1.0 /(1.0+ std::exp(-0.05 * (cfdd_turnover_sl[sl] - (sipar_.METRX_CFDD_MAX()/2.0)))), 0.99) * sc_.C_aorg_sl[sl] * sipar_.METRX_CFDD_TURN_MAX());
527 double n_decomp_aorg( cbm::bound( 0.0, 1.0 /(1.0+ std::exp(-0.05 * (cfdd_turnover_sl[sl] - (sipar_.METRX_CFDD_MAX()/2.0)))), 0.99) * sc_.N_aorg_sl[sl] * sipar_.METRX_CFDD_TURN_MAX());
528
529 sc_.C_aorg_sl[sl] -= c_decomp_aorg;
530 sc_.N_aorg_sl[sl] -= n_decomp_aorg;
531
532 sc_.an_doc_sl[sl] += c_decomp_aorg * sc_.anvf_sl[sl];
533 sc_.doc_sl[sl] += c_decomp_aorg * (1.0 - sc_.anvf_sl[sl]);
534
535 don_ae_sl[sl] += (1.0 - sipar_.METRX_FRAC_MINERAL()) * n_decomp_aorg * (1.0 - sc_.anvf_sl[sl]);
536 don_an_sl[sl] += (1.0 - sipar_.METRX_FRAC_MINERAL()) * n_decomp_aorg * sc_.anvf_sl[sl];
537
538 nh4_ae_sl[sl] += sipar_.METRX_FRAC_MINERAL() * n_decomp_aorg * (1.0 - sc_.anvf_sl[sl]);
539 nh4_an_sl[sl] += sipar_.METRX_FRAC_MINERAL() * n_decomp_aorg * sc_.anvf_sl[sl];
540 }
541
542 cumulative_freezing_degree_days_sl[sl] = 0.0;
543 cfdd_turnover_sl[sl] = 0.0;
544 }
545 }
546 }
547
548 return LDNDC_ERR_OK;
549}
bool ft_processes_
Definition soilchemistry-metrx.h:324
bool ft_yes_
Definition soilchemistry-metrx.h:323

References ft_processes_, and ft_yes_.

Referenced by MeTrX_leaching(), and solve().

Here is the caller graph for this function:

◆ MeTrX_gas_diffusion()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_gas_diffusion ( )
private
Parameters
[in]None
[out]None
Returns
error code

References MeTrX_gas_liq_diffusion().

Referenced by solve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_get_c_tot()

double ldndc::SoilChemistryMeTrX::MeTrX_get_c_tot ( )
private
Parameters
[in]None
[out]None
Returns
Total soil associated carbon
67{
68 double c_tot( c_algae + c_dead_algae + sc_.c_wood
69 + sc_.c_stubble_lit1 + sc_.c_stubble_lit2 + sc_.c_stubble_lit3
70 + sc_.c_raw_lit_1_above + sc_.c_raw_lit_2_above + sc_.c_raw_lit_3_above);
71
72 for (size_t sl = 0; sl < sl_.soil_layer_cnt(); sl++)
73 {
74 c_tot += ( sc_.c_wood_sl[sl]
75 + sc_.doc_sl[sl] + sc_.an_doc_sl[sl] + doc_ice_sl[sl]
76 + ae_acetate_sl[sl] + an_acetate_sl[sl] + acetate_ice_sl[sl]
77 + sc_.C_micro1_sl[sl] + sc_.C_micro2_sl[sl] + sc_.C_micro3_sl[sl]
78 + sc_.C_aorg_sl[sl] + c_microbial_necromass_sl[sl] + c_aged_sl[sl] + c_biochar_sl[sl]
79 + c_humus_1_sl[sl] + c_humus_2_sl[sl] + c_humus_3_sl[sl]
80 + sc_.C_lit1_sl[sl] + sc_.C_lit2_sl[sl] + sc_.C_lit3_sl[sl]
81 + sc_.c_raw_lit_1_sl[sl] + sc_.c_raw_lit_2_sl[sl] + sc_.c_raw_lit_3_sl[sl]
82 + ch4_gas_sl[sl] + ch4_liq_sl[sl]
83 + co2_gas_sl[sl] + co2_liq_sl[sl]);
84 }
85
86 for (size_t sbl = 0; sbl < sb_.surfacebulk_layer_cnt(); ++sbl)
87 {
88 c_tot += sb_.ch4_sbl[sbl] + sb_.co2_sbl[sbl] + sb_.doc_sbl[sbl];
89 }
90
91 return c_tot;
92}

◆ MeTrX_get_fact_m_denit()

double ldndc::SoilChemistryMeTrX::MeTrX_get_fact_m_denit ( size_t const & _sl)
private

The soil moisture response \( \phi_{\theta}\) of denitrification is given by a logistic function of the water filled pore space ( \( wfps = \theta / \theta_{sat} \)), i.e., the response increases up to water saturation:

\[ \phi_{\theta} = 1 - \frac{1}{1 + e^{(wfps - \Omega_{MFDMW1}) \cdot \Omega_{MFDMW2}}} \]

  • \( \Omega_{MFDMW1} \): METRX_F_DENIT_M_WEIBULL_1 (water filled pore space with 50% response)
  • \( \Omega_{MFDMW2} \): METRX_F_DENIT_M_WEIBULL_2 (steepness of the response)
Response function depending on soilwater
714{
715 return ldndc::meteo::F_weibull( MeTrX_get_wfps( _sl),
716 sipar_.METRX_F_DENIT_M_WEIBULL_1(),
717 sipar_.METRX_F_DENIT_M_WEIBULL_2(),
718 1.0);
719}

Referenced by MeTrX_anaerobic_volume(), and MeTrX_get_fact_tm_denit().

Here is the caller graph for this function:

◆ MeTrX_get_fact_minprot_aged()

double ldndc::SoilChemistryMeTrX::MeTrX_get_fact_minprot_aged ( size_t const & _sl)
private

protection of aged organic matter by the mineral matrix (see metrx_decomposition), (1 - METRX_F_DC_AGED_MINPROT f_min) (1 - METRX_F_DC_AGED_MINPROT_2 f_min^METRX_F_DC_AGED_MINPROT_3), f_min = 1 - 2 corg

decomposition of aged organic matter: protection by the mineral matrix

1792{
1793 double const f_min( cbm::bound( 0.0, 1.0 - 2.0 * sc_.fcorg_sl[_sl], 1.0));
1794 /* additional protection in mineral soils, weighted with 1 - peat weight (see MeTrX_peat_weight) */
1795 double const fact_mineral_soil( MeTrX_peat_blend( _sl, 1.0,
1796 cbm::bound( 1.0e-3, 1.0 - sipar_.METRX_F_DC_AGED_MINPROT_2() * std::pow( f_min, sipar_.METRX_F_DC_AGED_MINPROT_3()), 1.0)));
1797 return (1.0 - sipar_.METRX_F_DC_AGED_MINPROT() * f_min) * fact_mineral_soil;
1798}
double MeTrX_peat_blend(size_t const &, double, double)
Definition soilchemistry-metrx-init.cpp:1975

References MeTrX_get_fact_minprot_aged(), and MeTrX_peat_blend().

Referenced by MeTrX_get_fact_minprot_aged().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_get_fact_ph_bell()

double ldndc::SoilChemistryMeTrX::MeTrX_get_fact_ph_bell ( double _ph,
double _ph_opt,
double _half_width,
double _exponent )
staticprivate

Bell-shaped pH response 1 / (1 + (|pH - pH_opt| / half_width)^exponent)

Parameters
[in]_phpH value
[in]_ph_optpH with maximum response
[in]_half_widthdistance from pH_opt with 50% response [pH units]
[in]_exponentsteepness of the response
Returns
response factor [0, 1]
712{
713 return 1.0 / (1.0 + std::pow( std::abs( _ph - _ph_opt) / _half_width, _exponent));
714}

Referenced by MeTrX_anaerobic_volume().

Here is the caller graph for this function:

◆ MeTrX_get_fact_ph_logistic()

double ldndc::SoilChemistryMeTrX::MeTrX_get_fact_ph_logistic ( double _ph,
double _ph_50,
double _width )
staticprivate

Logistic pH response 1 / (1 + exp(-(pH - pH_50) / width)), increasing with pH for width > 0, decreasing for width < 0.

Parameters
[in]_phpH value
[in]_ph_50pH with 50% response
[in]_widthwidth of response [pH units] (10% to 90% within 4.4 |width|)
Returns
response factor [0, 1]
698{
699 return 1.0 / (1.0 + std::exp( -(_ph - _ph_50) / _width));
700}

Referenced by MeTrX_anaerobic_volume().

Here is the caller graph for this function:

◆ MeTrX_get_fact_t_denit()

double ldndc::SoilChemistryMeTrX::MeTrX_get_fact_t_denit ( size_t const & _sl)
private

The soil temperature response \( \phi_{T}\) of denitrification is based on the temperature dependency of general microbial activity (Temperature response of microbial rates, with the same parameters), raised to the power \( \Omega_{MFDTE} \):

\[\phi_{T} = \left( \phi_{T,mic}( T, \Omega_{MFMTE2}, \Omega_{MFMTE1}) \right)^{\Omega_{MFDTE}} \]

  • \( \Omega_{MFMTE1} \): METRX_F_MIC_T_EXP_1
  • \( \Omega_{MFMTE2} \): METRX_F_MIC_T_EXP_2
  • \( \Omega_{MFDTE} \): METRX_F_DENIT_T_EXP (1: same response as general microbial activity)

With \( \Omega_{MFDTE} > 1 \) denitrification is reduced more strongly in cool soil than general microbial activity. This lowers the denitrification background in spring, autumn and winter, while N2O emissions after fertilisation in warm and wet soil are hardly affected (calibrated against daily N2O series of arable and grassland sites, including freeze-thaw periods).

Response function depending on temperature

If the option freezethaw is set to ft_processes, \( \Omega_{MFMTE1} \) is replaced by a temperature dependent coefficient that shifts between \( \Omega_{MFMTEC} \) and \( \Omega_{MFMTE1} \):

\[\Omega_{MFMTEC} + \frac{\Omega_{MFMTE1} - \Omega_{MFMTEC}}{1 + e^{-\Omega_{MFMTE1} (T - \Omega_{MFMTE2})}} \]

  • \( \Omega_{MFMTEC} \): METRX_F_MIC_T_EXP_COLD
663{
664 double const help( std::pow(1.0 - mc_temp_sl[_sl] / sipar_.METRX_F_MIC_T_EXP_2(), 2.0));
665 // modification of temp.-dependency of denitrifying microbes
666 // NOTE: the freezethaw branch below bypasses the shared kernel; its cold-shifted exponent
667 // has no counterpart in the Lloyd-Taylor form and is kept as it was
668 if ( ft_processes_)
669 {
670 return std::pow( std::exp( -(sipar_.METRX_F_MIC_T_EXP_COLD() +
671 (sipar_.METRX_F_MIC_T_EXP_1() - sipar_.METRX_F_MIC_T_EXP_COLD()) /
672 (1.0 + std::exp(-sipar_.METRX_F_MIC_T_EXP_1() *
673 (mc_temp_sl[_sl] - sipar_.METRX_F_MIC_T_EXP_2())))) * help),
674 sipar_.METRX_F_DENIT_T_EXP());
675 }
676 else
677 {
678 /* goes through the shared kernel, but with its own METRX_F_DENIT_T_E0, default 0: denitrification
679 deliberately keeps the gaussian, because METRX_F_DENIT_T_EXP was calibrated against it and the two
680 levers work against each other. Lloyd & Taylor is 1.83 times the gaussian at 0 degC, and the
681 exponent squares that, so frost period denitrification rose by a factor 3.3: tested 2026-11-20,
682 QA Forest|N2O frost 0.453 -> 0.239 (bias 1.10 -> 2.09), Grassland|N2O frost bias 12.7 -> 25.3,
683 skill 0.5129 -> 0.5001. Until 2026-11-20 this line rebuilt the gaussian itself, so the difference
684 to microbial activity was an accident of copied code rather than a stated choice; now it is one.
685 Open: with Lloyd & Taylor an exponent near 2.4 would restore the frost end, which needs its own
686 calibration against the daily N2O series. */
687 return std::pow( MeTrX_get_fact_t_microbial( mc_temp_sl[_sl],
688 sipar_.METRX_F_MIC_T_EXP_2(),
689 sipar_.METRX_F_MIC_T_EXP_1(),
690 sipar_.METRX_F_DENIT_T_E0(),
691 0.0),
692 sipar_.METRX_F_DENIT_T_EXP());
693 }
694}
double MeTrX_get_fact_t_microbial(double const &, double const &, double const &, double const &, double const &)
Definition soilchemistry-metrx-physics-chemistry.cpp:741

References ft_processes_, and MeTrX_get_fact_t_microbial().

Referenced by MeTrX_anaerobic_volume(), and MeTrX_get_fact_tm_denit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_get_fact_t_microbial()

double ldndc::SoilChemistryMeTrX::MeTrX_get_fact_t_microbial ( double const & _t,
double const & _t_opt,
double const & _gauss_exp,
double const & _e0,
double const & _q10 )
private
Parameters
[in]_slsoil layer
[out]None
Returns
requested factor
744{
745 static double const T_ZERO_MICROBIAL( -46.02);
746
747 if ( cbm::flt_less_equal( _t, _t_opt))
748 {
749 if ( cbm::flt_greater_zero( _q10))
750 {
751 return std::pow( _q10, (_t - _t_opt) / 10.0);
752 }
753 if ( cbm::flt_greater_zero( _e0))
754 {
755 if ( cbm::flt_less_equal( _t, T_ZERO_MICROBIAL + 1.0))
756 {
757 return 0.0;
758 }
759 return std::exp( _e0 * (1.0 / (_t_opt - T_ZERO_MICROBIAL) - 1.0 / (_t - T_ZERO_MICROBIAL)));
760 }
761 }
762
763 return std::exp( -_gauss_exp * std::pow( 1.0 - _t / _t_opt, 2.0));
764}

Referenced by MeTrX_anaerobic_volume(), and MeTrX_get_fact_t_denit().

Here is the caller graph for this function:

◆ MeTrX_get_fact_tm_denit()

double ldndc::SoilChemistryMeTrX::MeTrX_get_fact_tm_denit ( size_t const & _sl)
private

The temperature and moisture dependency of denitrifying microbes is given by the harmonic mean of a soil temperature ( \( \phi_{T}\)) and a soil moisture ( \( \phi_{\theta}\)) response coefficient.

\[a_{mic} = \frac{2}{\frac{1}{\phi_{T}} + \frac{1}{\phi_{\theta}}} \]

The soil temperature response \( \phi_{T}\) of denitrification is based on the temperature dependency of general microbial activity (Temperature response of microbial rates, with the same parameters), raised to the power \( \Omega_{MFDTE} \):

\[\phi_{T} = \left( \phi_{T,mic}( T, \Omega_{MFMTE2}, \Omega_{MFMTE1}) \right)^{\Omega_{MFDTE}} \]

  • \( \Omega_{MFMTE1} \): METRX_F_MIC_T_EXP_1
  • \( \Omega_{MFMTE2} \): METRX_F_MIC_T_EXP_2
  • \( \Omega_{MFDTE} \): METRX_F_DENIT_T_EXP (1: same response as general microbial activity)

With \( \Omega_{MFDTE} > 1 \) denitrification is reduced more strongly in cool soil than general microbial activity. This lowers the denitrification background in spring, autumn and winter, while N2O emissions after fertilisation in warm and wet soil are hardly affected (calibrated against daily N2O series of arable and grassland sites, including freeze-thaw periods).

Response function depending on temperature

If the option freezethaw is set to ft_processes, \( \Omega_{MFMTE1} \) is replaced by a temperature dependent coefficient that shifts between \( \Omega_{MFMTEC} \) and \( \Omega_{MFMTE1} \):

\[\Omega_{MFMTEC} + \frac{\Omega_{MFMTE1} - \Omega_{MFMTEC}}{1 + e^{-\Omega_{MFMTE1} (T - \Omega_{MFMTE2})}} \]

  • \( \Omega_{MFMTEC} \): METRX_F_MIC_T_EXP_COLD

The soil moisture response \( \phi_{\theta}\) of denitrification is given by a logistic function of the water filled pore space ( \( wfps = \theta / \theta_{sat} \)), i.e., the response increases up to water saturation:

\[ \phi_{\theta} = 1 - \frac{1}{1 + e^{(wfps - \Omega_{MFDMW1}) \cdot \Omega_{MFDMW2}}} \]

  • \( \Omega_{MFDMW1} \): METRX_F_DENIT_M_WEIBULL_1 (water filled pore space with 50% response)
  • \( \Omega_{MFDMW2} \): METRX_F_DENIT_M_WEIBULL_2 (steepness of the response)
Response function depending on soilwater
737{
738 return cbm::harmonic_mean2( MeTrX_get_fact_t_denit( _sl),
740}
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
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

References MeTrX_get_fact_m_denit(), and MeTrX_get_fact_t_denit().

Referenced by MeTrX_anaerobic_volume().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_get_hac()

double ldndc::SoilChemistryMeTrX::MeTrX_get_hac ( size_t const & _sl)
private

concentration of undissociated acetic acid in the anaerobic soil water [mol L-1]

2001{
2002 double const water_l( wc_.wc_sl[_sl] * sc_.h_sl[_sl] * 1000.0); // [L m-2]
2003 return cbm::flt_greater_zero( water_l) ?
2004 an_acetate_sl[_sl] / 0.024022 / water_l / (1.0 + std::pow( 10.0, sc_.ph_sl[_sl] - 4.76))
2005 : 0.0; // [mol L-1]
2006}

References MeTrX_get_hac().

Referenced by MeTrX_get_hac().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_get_mean_base_ph()

double ldndc::SoilChemistryMeTrX::MeTrX_get_mean_base_ph ( double _depth)
private

Layer-thickness weighted mean of the base pH from the surface to given depth.

Returns
mean base pH, invalid if no layer is within depth
127{
128 double ph_sum( 0.0);
129 double h_sum( 0.0);
130 for ( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
131 {
132 double const top( sc_.depth_sl[sl] - sc_.h_sl[sl]);
133 if ( !cbm::flt_less( top, _depth))
134 {
135 break;
136 }
137 double const h( std::min( sc_.depth_sl[sl], _depth) - top);
138 ph_sum += sc_.phi_sl[sl] * h;
139 h_sum += h;
140 }
141 return cbm::flt_greater_zero( h_sum) ? ph_sum / h_sum : sc_.phi_sl[0];
142}

Referenced by MeTrX_liming().

Here is the caller graph for this function:

◆ MeTrX_get_n_tot()

double ldndc::SoilChemistryMeTrX::MeTrX_get_n_tot ( )
private
Parameters
[in]None
[out]None
Returns
Total soil associated nitrogen
24{
25 double n_tot( n_algae + n_dead_algae + sc_.n_wood
26 + sc_.n_stubble_lit1 + sc_.n_stubble_lit2 + sc_.n_stubble_lit3
27 + sc_.n_raw_lit_1_above + sc_.n_raw_lit_2_above + sc_.n_raw_lit_3_above);
28
29 for (size_t sl = 0; sl < sl_.soil_layer_cnt(); sl++)
30 {
31 n_tot += ( sc_.n_wood_sl[sl]
32 + nh4_ae_sl[sl] + nh4_an_sl[sl] + sc_.clay_nh4_sl[sl] + sc_.coated_nh4_sl[sl] + nh4_ice_sl[sl]
33 + sc_.nh3_liq_sl[sl] + sc_.nh3_gas_sl[sl] + sc_.urea_sl[sl]
34 + no3_ae_sl[sl] + no3_an_sl[sl] + no3_ice_sl[sl]
35 + sc_.no2_sl[sl] + sc_.an_no2_sl[sl]
36 + don_ae_sl[sl] + don_an_sl[sl] + don_ice_sl[sl]
37 + no_gas_sl[sl] + an_no_gas_sl[sl] + no_liq_sl[sl] + an_no_liq_sl[sl]
38 + n2o_gas_sl[sl] + an_n2o_gas_sl[sl] + n2o_liq_sl[sl] + an_n2o_liq_sl[sl]
39 + sc_.N_lit1_sl[sl] + sc_.N_lit2_sl[sl] + sc_.N_lit3_sl[sl]
40 + sc_.n_raw_lit_1_sl[sl] + sc_.n_raw_lit_2_sl[sl] + sc_.n_raw_lit_3_sl[sl]
41 + n_micro_1_sl[sl] + n_micro_2_sl[sl] + n_micro_3_sl[sl]
42 + sc_.N_aorg_sl[sl] + n_microbial_necromass_sl[sl] + n_aged_sl[sl] + n_biochar_sl[sl]
43 + n_humus_1_sl[sl] + n_humus_2_sl[sl] + n_humus_3_sl[sl]);
44 }
45
46 for (size_t sbl = 0; sbl < sb_.surfacebulk_layer_cnt(); ++sbl)
47 {
48 n_tot += sb_.nh4_sbl[sbl] + sb_.coated_nh4_sbl[sbl]
49 + sb_.no3_sbl[sbl] + sb_.don_sbl[sbl]
50 + sb_.nh3_sbl[sbl] + sb_.urea_sbl[sbl]
51 + sb_.n2o_sbl[sbl] + sb_.no_sbl[sbl];
52 }
53
54 n_tot += nh3_fl.sum();
55
56 return n_tot;
57}

◆ MeTrX_get_ph_of_fact_ph_logistic()

double ldndc::SoilChemistryMeTrX::MeTrX_get_ph_of_fact_ph_logistic ( double _fact,
double _ph_50,
double _width )
staticprivate

Inverse of MeTrX_get_fact_ph_logistic: pH at which the logistic pH response equals _fact, i.e., pH_50 + width * ln(fact / (1 - fact))

Parameters
[in]_factresponse factor (0, 1)
[in]_ph_50pH with 50% response
[in]_widthwidth of response [pH units]
Returns
pH value
705{
706 return _ph_50 + _width * std::log( _fact / (1.0 - _fact));
707}

Referenced by MeTrX_anaerobic_volume().

Here is the caller graph for this function:

◆ MeTrX_get_ph_wl()

double ldndc::SoilChemistryMeTrX::MeTrX_get_ph_wl ( )
private
Parameters
[in]None
[out]None
Returns
double
684{
685 if ( cbm::flt_greater_zero( wc_.surface_water))
686 {
687 return cbm::bound( PH_SURFACE_WATER, PH_SURFACE_WATER + ph_delta_pab_wl + ph_delta_urea_wl, PH_MAX);
688 }
689 else
690 {
691 return 7.0;
692 }
693}

Referenced by MeTrX_anaerobic_volume(), MeTrX_nh3_nh4_equilibrium(), MeTrX_write_output_daily(), MeTrX_write_output_layer_daily(), and MeTrX_write_output_subdaily().

Here is the caller graph for this function:

◆ MeTrX_groundwater_access()

void ldndc::SoilChemistryMeTrX::MeTrX_groundwater_access ( )
private
Parameters
[in]None
[out]None
Returns
void
848{
849 if ( gw_ != NULL)
850 {
851 for ( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
852 {
853 if ( sc_.depth_sl[sl] > gw_->watertable_subday( lclock_ref()))
854 {
855 double const no3_gw( gw_->no3_day(lclock_ref()) //given in (mg n-no3 L-1)
856 * cbm::KG_IN_MG //converts (mg n-no3) -> (kg n-no3)
857 * (wc_.wc_sl[sl] + wc_.ice_sl[sl]) * sc_.h_sl[sl] * cbm::DM3_IN_M3); //converts water (m3) -> (L)
858
859 if ( cbm::flt_greater_zero( no3_gw))
860 {
861 double const no3_diff( GROUNDWATER_NUTRIENT_ACCESS_RATE * (no3_gw - no3_an_sl[sl]));
862 no3_an_sl[sl] += no3_diff;
863 day_no3_groundwater_access += no3_diff;
864 sc_.accumulated_no3_leach -= no3_diff;
865 sc_.accumulated_n_no3_leaching_sl[sl] -= no3_diff;
866 }
867 }
868 }
869
870 if ( have_river_connection)
871 {
872 if ( have_water_table)
873 {
874 for (size_t sbl = 0; sbl < sb_.surfacebulk_layer_cnt(); ++sbl)
875 {
876 DISSOLUTION_ATMOSPHERE( MeTrX_get_atm_eq_liq( o2_atm_eq_liq, h_wl), sb_.o2_sbl[sbl], subdaily_o2_water[subdaily_time_step_]);
877 DISSOLUTION_ATMOSPHERE( MeTrX_get_atm_eq_liq( ch4_atm_eq_liq, h_wl), sb_.ch4_sbl[sbl], subdaily_ch4_water[subdaily_time_step_]);
878 DISSOLUTION_ATMOSPHERE( MeTrX_get_atm_eq_liq( co2_atm_eq_liq, h_wl), sb_.co2_sbl[sbl], subdaily_co2_water[subdaily_time_step_]);
879 DISSOLUTION_ATMOSPHERE( MeTrX_get_atm_eq_liq( nh3_atm_eq_liq, h_wl), sb_.nh3_sbl[sbl], subdaily_nh3_water[subdaily_time_step_]);
880 DISSOLUTION_ATMOSPHERE( MeTrX_get_atm_eq_liq( no_atm_eq_liq, h_wl), sb_.no_sbl[sbl], subdaily_no_water[subdaily_time_step_]);
881 DISSOLUTION_ATMOSPHERE( MeTrX_get_atm_eq_liq( n2o_atm_eq_liq, h_wl), sb_.n2o_sbl[sbl], subdaily_n2o_water[subdaily_time_step_]);
882 if ( have_radon_diffusion)
883 {
884 DISSOLUTION_ATMOSPHERE( MeTrX_get_atm_eq_liq( radon_atm_eq_liq, h_wl) * cbm::RGAS * mc_.ts_airtemperature, sb_.radon_sbl[sbl], subdaily_radon_water[subdaily_time_step_]);
885 }
886 }
887 }
888 }
889 }
890}

Referenced by MeTrX_leaching(), and solve().

Here is the caller graph for this function:

◆ MeTrX_humus_nitrogen()

bool ldndc::SoilChemistryMeTrX::MeTrX_humus_nitrogen ( size_t const & _sl,
double _n_hum )
private

distributes the humus nitrogen of a layer to the humus pools (option humusinit = cnratio)

1898{
1899 double const c_pom( c_humus_1_sl[_sl]);
1900 double const c_maom( c_humus_2_sl[_sl] + c_humus_3_sl[_sl]);
1901 double const c_hum( c_pom + c_maom);
1902 if ( !( c_hum > 0.0) || !( _n_hum > 0.0))
1903 {
1904 return false;
1905 }
1906
1907 double const cn_hum( c_hum / _n_hum);
1908 double cn_pom( cn_hum);
1909 double cn_maom( cn_hum);
1910 if ( cbm::flt_greater( cn_hum, cn_maom_) && cbm::flt_greater_zero( c_pom) && cbm::flt_greater_zero( c_maom))
1911 {
1912 cn_maom = cn_maom_;
1913 double const n_pom( _n_hum - c_maom / cn_maom);
1914 cn_pom = cn_pom_max_;
1915 if ( cbm::flt_greater( n_pom, c_pom / cn_pom_max_))
1916 {
1917 cn_pom = c_pom / n_pom;
1918 }
1919 else
1920 {
1921 double const n_maom( _n_hum - c_pom / cn_pom_max_);
1922 if ( cbm::flt_greater_zero( n_maom))
1923 {
1924 cn_pom = cn_pom_max_;
1925 cn_maom = c_maom / n_maom;
1926 }
1927 else
1928 {
1929 cn_pom = cn_maom = cn_hum;
1930 }
1931 }
1932 }
1933
1934 /* peat layers: pom (from which aged organic matter is initialized) is not more nitrogen rich than
1935 METRX_F_HUMUS_POM_CN_MIN; the nitrogen in excess is taken by maom, whose C/N may then fall below humusinitcnmaom
1936 down to METRX_F_HUMUS_MAOM_CN_MIN (see @ref metrx_humus_nitrogen). Bogs (wide C/N) and mineral soils are not affected. */
1937 double const t_pom_cn_min( sipar_.METRX_F_HUMUS_POM_CN_MIN());
1938 double const t_maom_cn_min( sipar_.METRX_F_HUMUS_MAOM_CN_MIN());
1939 if ( t_pom_cn_min > 0.0 && cbm::flt_greater_zero( MeTrX_peat_weight( _sl)) && cbm::flt_greater_zero( c_pom) && cbm::flt_greater_zero( c_maom) &&
1940 cbm::flt_less( cn_pom, t_pom_cn_min) && cbm::flt_less( cn_hum, t_pom_cn_min))
1941 {
1942 double const cn_pom_mineral( cn_pom);
1943 double const cn_maom_req( c_maom / ( _n_hum - c_pom / t_pom_cn_min));
1944 cn_maom = cbm::bound( t_maom_cn_min, cn_maom_req, cn_maom);
1945 cn_pom = c_pom / ( _n_hum - c_maom / cn_maom);
1946
1947 /* nitrogen of pom weighted with the peat weight, humus nitrogen conserved */
1948 double const w( MeTrX_peat_weight( _sl));
1949 double const n_pom( w * c_pom / cn_pom + (1.0 - w) * c_pom / cn_pom_mineral);
1950 cn_pom = c_pom / n_pom;
1951 cn_maom = c_maom / ( _n_hum - n_pom);
1952 }
1953
1954 cn_hum_1_sl[_sl] = cn_pom;
1955 cn_hum_2_sl[_sl] = cn_maom;
1956 cn_hum_3_sl[_sl] = cn_maom;
1957 n_humus_1_sl[_sl] = c_humus_1_sl[_sl] / cn_pom;
1958 n_humus_2_sl[_sl] = c_humus_2_sl[_sl] / cn_maom;
1959 n_humus_3_sl[_sl] = c_humus_3_sl[_sl] / cn_maom;
1960
1961 return true;
1962}
double MeTrX_peat_weight(size_t const &)
Definition soilchemistry-metrx-init.cpp:1966

References MeTrX_humus_nitrogen(), and MeTrX_peat_weight().

Referenced by MeTrX_humus_nitrogen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_iron_oxidation()

void ldndc::SoilChemistryMeTrX::MeTrX_iron_oxidation ( )
private
Parameters
[in]None
[out]None
Returns
void

Referenced by solve().

Here is the caller graph for this function:

◆ MeTrX_iron_reduction()

void ldndc::SoilChemistryMeTrX::MeTrX_iron_reduction ( )
private
Parameters
[in]None
[out]None
Returns
void

Referenced by solve().

Here is the caller graph for this function:

◆ MeTrX_isotopes_incorporation()

void ldndc::SoilChemistryMeTrX::MeTrX_isotopes_incorporation ( size_t _n_floor,
size_t _n_target,
double _k,
double _h_target )
private

after MeTrX_incorporation_floor moved the fraction _k of litter, aorg and humus N of the floor layers into the mineral layers below (weights h_sl / _h_target)

722{
723 metrx_isotopes_t & I = *iso_;
724 if ( !I.active || !( _k > 0.0) || !( _k < 1.0) || !( _h_target > 0.0)) { return; }
725 simone::Engine & E = I.eng;
726 double const f( _k / ( 1.0 - _k)); /* moved / remaining */
727 for ( size_t l = 0; l < _n_floor; ++l)
728 {
729 double const moved[5] =
730 {
731 f * ( sc_.N_lit1_sl[l] + sc_.N_lit2_sl[l] + sc_.N_lit3_sl[l] +
732 sc_.n_raw_lit_1_sl[l] + sc_.n_raw_lit_2_sl[l] + sc_.n_raw_lit_3_sl[l]),
733 f * sc_.N_aorg_sl[l], f * n_humus_1_sl[l], f * n_humus_2_sl[l], f * n_humus_3_sl[l]
734 };
735 int const pools[5] = { I.litter, I.aorg, I.humus1, I.humus2, I.humus3 };
736 for ( size_t p = 0; p < 5; ++p)
737 {
738 if ( !( moved[p] > 0.0)) { continue; }
739 for ( size_t t = _n_floor; t < _n_floor + _n_target; ++t)
740 {
741 E.react( pools[p], l, pools[p], t, moved[p] * sc_.h_sl[t] / _h_target, -1, NAN);
742 }
743 }
744 }
745}

Referenced by MeTrX_incorporation_floor(), and MeTrX_manure().

Here is the caller graph for this function:

◆ MeTrX_leaching()

void ldndc::SoilChemistryMeTrX::MeTrX_leaching ( )
private
Parameters
[in]None
[out]None
Returns
void

References MeTrX_fragmentation(), MeTrX_freeze_thaw(), MeTrX_groundwater_access(), MeTrX_litter_distribution(), MeTrX_plant_respiration(), and MeTrX_radon_source_sink().

Referenced by solve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_liming()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_liming ( )
private
Parameters
[in]None
[out]None
Returns
error code
35{
36 EventAttributes const * ev_liming = NULL;
37 while (( ev_liming = m_LimingEvents.pop()) != NULL)
38 {
39 lime_request_t lime;
40 lime.type = ev_liming->get( "/type", "-");
41 lime.amount = ev_liming->get( "/amount", invalid_dbl);
42 lime.depth = ev_liming->get( "/depth", invalid_dbl);
43 lime.ph_target = ev_liming->get( "/ph_target", invalid_dbl);
44
45 if ( !cbm::is_valid( lime.depth) || !cbm::flt_greater_zero( lime.depth))
46 {
47 lime.depth = 0.3;
48 }
49 if ( !cbm::is_valid( lime.ph_target) || !cbm::flt_greater_zero( lime.ph_target))
50 {
51 KLOGERROR( "lime event: attribute \"ph_target\" is required, liming by \"amount\" is not yet supported",
52 " [type=",lime.type,",amount=",lime.amount,"]");
53 return LDNDC_ERR_FAIL;
54 }
55 if ( cbm::is_valid( lime.amount))
56 {
57 KLOGWARN( "lime event: \"amount\" is not yet considered, liming to \"ph_target\"",
58 " [type=",lime.type,",amount=",lime.amount,",ph_target=",lime.ph_target,"]");
59 }
60
61 lerr_t rc = MeTrX_apply_lime( lime);
62 if ( rc)
63 {
64 return rc;
65 }
66 }
67
68 /* automatic liming: check once per day */
69 if ( have_auto_liming &&
70 ((lclock()->subday() == 1) || (timemode_ != TMODE_SUBDAILY)))
71 {
72 double const ph_mean( MeTrX_get_mean_base_ph( auto_liming_depth));
73 if ( cbm::is_valid( ph_mean) &&
74 cbm::flt_less( ph_mean, auto_liming_ph_min))
75 {
76 lime_request_t lime;
77 lime.type = "auto";
78 lime.amount = invalid_dbl;
79 lime.depth = auto_liming_depth;
80 lime.ph_target = auto_liming_ph_target;
81
82 lerr_t rc = MeTrX_apply_lime( lime);
83 if ( rc)
84 {
85 return rc;
86 }
87 }
88 }
89
90 return LDNDC_ERR_OK;
91}
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_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
Liming request, either from lime event or from automatic liming.
Definition soilchemistry-metrx.h:1361

References MeTrX_apply_lime(), and MeTrX_get_mean_base_ph().

Referenced by MeTrX_fertilize(), and solve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_liq_diffusion()

void ldndc::SoilChemistryMeTrX::MeTrX_liq_diffusion ( )
private
Parameters
[in]None
[out]None
Returns
void

References MeTrX_incorporation_floor(), MeTrX_metabolism(), and MeTrX_pertubation().

Referenced by solve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_manure()

◆ MeTrX_maom_fine_fraction()

double ldndc::SoilChemistryMeTrX::MeTrX_maom_fine_fraction ( size_t const & _sl)
private

clay + silt fraction that sets the capacity for mineral associated organic matter (organic soil types: at least METRX_F_ORGANIC_FINE_FRACTION times the mineral fraction)

1855{
1856 double const given( sc_.clay_sl[_sl] + sc_.silt_sl[_sl]);
1857 if ( !cbm::flt_greater_zero( sipar_.METRX_F_ORGANIC_FINE_FRACTION()))
1858 {
1859 return given;
1860 }
1861 soillayers::soil_type_e const soil_type( sl_.soil_type());
1862 bool const organic_soil_type( (soil_type == soillayers::SOIL_ORGANIC_MATERIAL) ||
1863 ((soil_type >= soillayers::PEAT) && (soil_type <= soillayers::PEAT_PINEFOREST_OMBROTROPHIC)));
1864 if ( !organic_soil_type)
1865 {
1866 return given;
1867 }
1868 double const f_min( cbm::bound( 0.0, 1.0 - 2.0 * sc_.fcorg_sl[_sl], 1.0));
1869 return std::max( given, sipar_.METRX_F_ORGANIC_FINE_FRACTION() * f_min);
1870}

References MeTrX_maom_fine_fraction().

Referenced by MeTrX_maom_fine_fraction(), and MeTrX_peat_layer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_metabolism()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_metabolism ( )
private
Parameters
[in]None
[out]None
Returns
error code
262{
263 for( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
264 {
265 double const metabolism_rate( 0.1 * FTS_TOT_);
266
267 double const mic_12( sc_.C_micro1_sl[sl] + sc_.C_micro2_sl[sl]);
268 double const mic_23( sc_.C_micro2_sl[sl] + sc_.C_micro3_sl[sl]);
269
270 if ( cbm::flt_greater_zero( mic_12))
271 {
272 double const fact_mic_12( sc_.anvf_sl[sl]);
273 double trans_12( (fact_mic_12 * mic_12 - sc_.C_micro2_sl[sl]) * metabolism_rate);
274 if ( cbm::flt_greater_zero( trans_12))
275 {
276 double const trans_max( cbm::bound_min( 0.0, sc_.C_micro1_sl[sl] - MICRO_C_MIN * sc_.h_sl[sl]));
277 trans_12 = cbm::bound_max( trans_12, trans_max);
278 sc_.C_micro1_sl[sl] -= trans_12;
279 sc_.C_micro2_sl[sl] += trans_12;
280 }
281 else
282 {
283 double const trans_max( cbm::bound_min( 0.0, sc_.C_micro2_sl[sl] - MICRO_C_MIN * sc_.h_sl[sl]));
284 trans_12 = cbm::bound_max( -trans_12, trans_max);
285 sc_.C_micro2_sl[sl] -= trans_12;
286 sc_.C_micro1_sl[sl] += trans_12;
287 }
288 }
289
290 if ( cbm::flt_greater_zero( mic_23))
291 {
292 double const fact_mic_23( 1.0 - no3_an_sl[sl] / (no3_an_sl[sl] + (NO3_MOLAR_MAX_FE_RED * sc_.h_sl[sl] * M_N_SCALE)));
293 double trans_23( (fact_mic_23 * mic_23 - sc_.C_micro3_sl[sl]) * metabolism_rate);
294 if ( cbm::flt_greater_zero( trans_23))
295 {
296 double const trans_max( cbm::bound_min( 0.0, sc_.C_micro2_sl[sl] - MICRO_C_MIN * sc_.h_sl[sl]));
297 trans_23 = cbm::bound_max( trans_23, trans_max);
298 sc_.C_micro2_sl[sl] -= trans_23;
299 sc_.C_micro3_sl[sl] += trans_23;
300 }
301 else
302 {
303 double const trans_max( cbm::bound_min( 0.0, sc_.C_micro3_sl[sl] - MICRO_C_MIN * sc_.h_sl[sl]));
304 trans_23 = cbm::bound_max( -trans_23, trans_max);
305 sc_.C_micro3_sl[sl] -= trans_23;
306 sc_.C_micro2_sl[sl] += trans_23;
307 }
308 }
309 }
310 return LDNDC_ERR_OK;
311}

Referenced by MeTrX_liq_diffusion(), and solve().

Here is the caller graph for this function:

◆ MeTrX_microbial_dynamics()

void ldndc::SoilChemistryMeTrX::MeTrX_microbial_dynamics ( )
private
Parameters
[in]None
[out]None
Returns
void

Referenced by solve().

Here is the caller graph for this function:

◆ MeTrX_nh3_nh4_equilibrium()

void ldndc::SoilChemistryMeTrX::MeTrX_nh3_nh4_equilibrium ( )
private
Parameters
[in]None
[out]None
Returns
void
38{
39 if ( have_water_table)
40 {
41 double ph( MeTrX_get_ph_wl());
42 for ( size_t wl = 0; wl < sb_.surfacebulk_layer_cnt(); wl++)
43 {
44 double const k_a( pow( 10.0,(-2728.3 / (mc_temp_sl[0] + cbm::D_IN_K) - 0.094219))); // Sadeghi et al. (1988) (for 5 < ph < 10)
45
46 double const n_tot( sb_.nh4_sbl[wl] + sb_.nh3_sbl[wl]);
47 double const frac_nh3( cbm::bound_max( 1.0 / (1.0 + (pow(10.0, - ph) / k_a)), 0.99));
48
49 double const delta_nh3( frac_nh3 * n_tot - sb_.nh3_sbl[wl]);
50 if( cbm::flt_greater( delta_nh3, 0.0))
51 {
52 sb_.nh3_sbl[wl] += delta_nh3;
53 sb_.nh4_sbl[wl] = cbm::bound_min( 0.0, sb_.nh4_sbl[wl] - delta_nh3);
54 accumulated_n_nh4_nh3_conversion_sbl[wl] += delta_nh3;
55 }
56 else if( cbm::flt_less( delta_nh3, 0.0))
57 {
58 sb_.nh3_sbl[wl] = cbm::bound_min( 0.0, sb_.nh3_sbl[wl] + delta_nh3);
59 sb_.nh4_sbl[wl] -= delta_nh3;
60 accumulated_n_nh3_nh4_conversion_sbl[wl] -= delta_nh3;
61 }
62 }
63 }
64
65 for( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
66 {
67 double const k_a( pow( 10.0, -2728.3 / (mc_temp_sl[sl] + cbm::D_IN_K) - 0.094219));
68 double const nh4_tot( nh4_ae_sl[sl] + nh4_an_sl[sl]);
69 double const n_tot( nh4_tot + sc_.nh3_liq_sl[sl]);
70 double const frac_nh3( cbm::bound_max( 1.0 / (1.0 + (pow(10.0, - sc_.ph_sl[sl]) / k_a)), 0.99));
71
72 double const delta_nh3( frac_nh3 * n_tot - sc_.nh3_liq_sl[sl]);
73 if ( cbm::flt_greater( delta_nh3, 0.0))
74 {
75 sc_.nh3_liq_sl[sl] += delta_nh3;
76 double const delta_nh4_ae( nh4_ae_sl[sl] / nh4_tot * delta_nh3);
77 double const delta_nh4_an( delta_nh3 - delta_nh4_ae);
78 nh4_ae_sl[sl] = cbm::bound_min( 0.0, nh4_ae_sl[sl] - delta_nh4_ae);
79 nh4_an_sl[sl] = cbm::bound_min( 0.0, nh4_an_sl[sl] - delta_nh4_an);
80 accumulated_n_nh4_nh3_conversion_sl[sl] += delta_nh3;
81 }
82 else if ( cbm::flt_less( delta_nh3, 0.0))
83 {
84 sc_.nh3_liq_sl[sl] = cbm::bound_min( 0.0, sc_.nh3_liq_sl[sl] + delta_nh3);
85 nh4_ae_sl[sl] -= delta_nh3 * (1.0 - sc_.anvf_sl[sl]);
86 nh4_an_sl[sl] -= delta_nh3 * sc_.anvf_sl[sl];
87 accumulated_n_nh3_nh4_conversion_sl[sl] -= delta_nh3;
88 }
89
90 }
91}
double MeTrX_get_ph_wl()
Definition soilchemistry-metrx-physics-chemistry.cpp:683

References MeTrX_get_ph_wl().

Referenced by MeTrX_chemodenitrification(), and solve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_nitrification()

void ldndc::SoilChemistryMeTrX::MeTrX_nitrification ( )
private
Parameters
[in]None
[out]None
Returns
void

Referenced by solve().

Here is the caller graph for this function:

◆ MeTrX_nitrogen_fertilizer_release()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_nitrogen_fertilizer_release ( )
private

Transforms nitrogen from slow release nitrogen fertilizer to nh4.

Parameters
[in]None
[out]None
Returns
void
1292{
1293 double const coated_nh4_sbl_sum( sb_.coated_nh4_sbl.sum());
1294 double const coated_nh4_sl_sum( sc_.coated_nh4_sl.sum());
1295 double const coated_nh4_sum( coated_nh4_sbl_sum + coated_nh4_sl_sum);
1296 if ( !cbm::flt_greater_zero( coated_nh4_sum))
1297 { return LDNDC_ERR_OK; }
1298
1299 if ( cbm::flt_greater_zero( coated_nh4_sbl_sum))
1300 {
1301 for ( size_t sbl = 0; sbl < sb_.surfacebulk_layer_cnt(); ++sbl)
1302 {
1303 crnf_.update_crnf( 1.0, mc_temp_sl[0], FTS_TOT_, sb_.coated_nh4_sbl[sbl] / coated_nh4_sum);
1304 }
1305 }
1306
1307 if ( cbm::flt_greater_zero( coated_nh4_sl_sum))
1308 {
1309 for( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
1310 {
1311 crnf_.update_crnf( MeTrX_get_wfps( sl), mc_temp_sl[sl], FTS_TOT_, sc_.coated_nh4_sl[sl] / coated_nh4_sum);
1312 }
1313 }
1314
1315 double coated_nh4_release( crnf_.get_crnf_release( coated_nh4_sum));
1316 if ( !cbm::flt_greater_zero( coated_nh4_release))
1317 { return LDNDC_ERR_OK; }
1318
1319 double const scale( coated_nh4_release / coated_nh4_sum);
1320
1321 if ( cbm::flt_greater( scale, 0.99))
1322 {
1323 if ( cbm::flt_greater_zero( coated_nh4_sbl_sum))
1324 {
1325 for ( size_t sbl = 0; sbl < sb_.surfacebulk_layer_cnt(); ++sbl)
1326 {
1327 sb_.nh4_sbl[sbl] += sb_.coated_nh4_sbl[sbl];
1328 sb_.coated_nh4_sbl[sbl] = 0.0;
1329 }
1330 }
1331
1332 if ( cbm::flt_greater_zero( coated_nh4_sl_sum))
1333 {
1334 for( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
1335 {
1336 nh4_ae_sl[sl] += sc_.coated_nh4_sl[sl] * (1.0 - sc_.anvf_sl[sl]);
1337 nh4_an_sl[sl] += sc_.coated_nh4_sl[sl] * sc_.anvf_sl[sl];
1338 sc_.coated_nh4_sl[sl] = 0.0;
1339 }
1340 }
1341 }
1342 else
1343 {
1344 if ( cbm::flt_greater_zero( coated_nh4_sbl_sum))
1345 {
1346 for ( size_t sbl = 0; sbl < sb_.surfacebulk_layer_cnt(); ++sbl)
1347 {
1348 if ( cbm::flt_greater_zero( sb_.coated_nh4_sbl[sbl]))
1349 {
1350 double const n_transform( scale * sb_.coated_nh4_sbl[sbl]);
1351 sb_.coated_nh4_sbl[sbl] -= n_transform;
1352 sb_.nh4_sbl[sbl] += n_transform;
1353 }
1354 }
1355 }
1356
1357 if ( cbm::flt_greater_zero( coated_nh4_sl_sum))
1358 {
1359 for( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
1360 {
1361 if ( cbm::flt_greater_zero( sc_.coated_nh4_sl[sl]))
1362 {
1363 double const n_transform( scale * sc_.coated_nh4_sl[sl]);
1364 sc_.coated_nh4_sl[sl] -= n_transform;
1365 nh4_ae_sl[sl] += n_transform * (1.0 - sc_.anvf_sl[sl]);
1366 nh4_an_sl[sl] += n_transform * sc_.anvf_sl[sl];
1367 }
1368 }
1369 }
1370 }
1371
1372 return LDNDC_ERR_OK;
1373}

Referenced by MeTrX_fermentation(), and solve().

Here is the caller graph for this function:

◆ MeTrX_organic_layer()

bool ldndc::SoilChemistryMeTrX::MeTrX_organic_layer ( size_t const & _sl)
private

organic soil layer: peat layer or organic litter layer of forests

1985{
1986 MeTrX_peat_layer( _sl);
1987 return organic_layer_sl_[_sl] != 0;
1988}
std::vector< char > organic_layer_sl_
Definition soilchemistry-metrx.h:293
bool MeTrX_peat_layer(size_t const &)
Definition soilchemistry-metrx-init.cpp:1803

References MeTrX_organic_layer(), MeTrX_peat_layer(), and organic_layer_sl_.

Referenced by MeTrX_incorporation_floor(), and MeTrX_organic_layer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_peat_blend()

double ldndc::SoilChemistryMeTrX::MeTrX_peat_blend ( size_t const & _sl,
double _v_peat,
double _v_mineral )
private

value of a peat layer and value of a mineral layer, weighted with the peat weight

1976{
1977 double const w( MeTrX_peat_weight( _sl));
1978 return w * _v_peat + (1.0 - w) * _v_mineral;
1979}

References MeTrX_peat_blend(), and MeTrX_peat_weight().

Referenced by MeTrX_get_fact_minprot_aged(), and MeTrX_peat_blend().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_peat_layer()

bool ldndc::SoilChemistryMeTrX::MeTrX_peat_layer ( size_t const & _sl)
private

peat layer: layer of a peat or organic material soil whose soil organic carbon exceeds the capacity of mineral surfaces

1804{
1805 if ( peat_layer_sl_.size() != sl_.soil_layer_cnt())
1806 {
1807 soillayers::soil_type_e const soil_type( sl_.soil_type());
1808 bool const organic_soil_type( (soil_type == soillayers::SOIL_ORGANIC_MATERIAL) ||
1809 ((soil_type >= soillayers::PEAT) && (soil_type <= soillayers::PEAT_PINEFOREST_OMBROTROPHIC)));
1810 bool const forest( MeTrX_forest_ecosytem());
1811 size_t const sl_litter_cnt( sl_.soil_layers_in_litter_cnt());
1812
1813 peat_layer_sl_.assign( sl_.soil_layer_cnt(), 0);
1814 organic_layer_sl_.assign( sl_.soil_layer_cnt(), 0);
1815 peat_weight_sl_.assign( sl_.soil_layer_cnt(), 0.0);
1816 for ( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
1817 {
1818 bool const above_capacity( cbm::flt_greater( sc_.fcorg_sl[sl], C_SATURATION * MeTrX_maom_fine_fraction( sl)));
1819 bool const litter_layer( sl < sl_litter_cnt);
1820 peat_layer_sl_[sl] = ( !litter_layer && organic_soil_type && above_capacity) ? 1 : 0;
1821 organic_layer_sl_[sl] = ( peat_layer_sl_[sl] || (forest && litter_layer)) ? 1 : 0;
1822
1823 /* peat weight: organic volume share of the solids (organic matter = 2 corg) */
1824 if ( !litter_layer)
1825 {
1826 double const m_om( cbm::bound( 0.0, 2.0 * sc_.fcorg_sl[sl], 1.0));
1827 double const v_om( m_om / RHO_ORGANIC_MATTER);
1828 double const phi_om( v_om / (v_om + (1.0 - m_om) / RHO_MINERAL_MATTER));
1829 double const x_om( cbm::bound( 0.0, (phi_om - PEAT_ORGANIC_VOLUME_1) / (PEAT_ORGANIC_VOLUME_2 - PEAT_ORGANIC_VOLUME_1), 1.0));
1830 peat_weight_sl_[sl] = x_om * x_om * (3.0 - 2.0 * x_om);
1831 }
1832 }
1833 }
1834
1835 return peat_layer_sl_[_sl] != 0;
1836}
static const double C_SATURATION
Definition soilchemistry-metrx.h:54
static const double PEAT_ORGANIC_VOLUME_1
Definition soilchemistry-metrx.h:59
static const double RHO_ORGANIC_MATTER
Definition soilchemistry-metrx.h:56
std::vector< double > peat_weight_sl_
Definition soilchemistry-metrx.h:295
std::vector< char > peat_layer_sl_
Definition soilchemistry-metrx.h:291
double MeTrX_maom_fine_fraction(size_t const &)
Definition soilchemistry-metrx-init.cpp:1854

References C_SATURATION, MeTrX_maom_fine_fraction(), MeTrX_peat_layer(), organic_layer_sl_, peat_layer_sl_, PEAT_ORGANIC_VOLUME_1, peat_weight_sl_, and RHO_ORGANIC_MATTER.

Referenced by MeTrX_incorporation_floor(), MeTrX_organic_layer(), MeTrX_peat_layer(), and MeTrX_peat_weight().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_peat_weight()

double ldndc::SoilChemistryMeTrX::MeTrX_peat_weight ( size_t const & _sl)
private

peat weight of a soil layer from the organic volume share of its solids, 0 (mineral) to 1 (peat)

1967{
1968 MeTrX_peat_layer( _sl);
1969 return peat_weight_sl_[_sl];
1970}

References MeTrX_peat_layer(), MeTrX_peat_weight(), and peat_weight_sl_.

Referenced by MeTrX_humus_nitrogen(), MeTrX_peat_blend(), and MeTrX_peat_weight().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_pertubation()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_pertubation ( )
private
Parameters
[in]None
[out]None
Returns
error code
2045{
2046 /* Pertubation is only calculated once per day since it is a very slow process.
2047 * It is called within the loop over internal time steps; in daily time mode all 24 internal
2048 * steps have subday() == 1, therefore the first internal step of the day is used. */
2049 if ( subdaily_time_step_ == 0)
2050 {
2052
2053 size_t sl_max_1( sl_.soil_layer_cnt()-1);
2054 double nmicro1_lowest_sl(n_micro_1_sl[sl_max_1]);
2055 double nmicro2_lowest_sl(n_micro_2_sl[sl_max_1]);
2056 double nmicro3_lowest_sl(n_micro_3_sl[sl_max_1]);
2057 double naorg_lowest_sl(sc_.N_aorg_sl[sl_max_1]);
2058 double nlit1_lowest_sl(sc_.N_lit1_sl[sl_max_1]);
2059 double nlit2_lowest_sl(sc_.N_lit2_sl[sl_max_1]);
2060 double nlit3_lowest_sl(sc_.N_lit3_sl[sl_max_1]);
2061 double nhum1_lowest_sl(n_humus_1_sl[sl_max_1]);
2062 double nhum2_lowest_sl(n_humus_2_sl[sl_max_1]);
2063 double nhum3_lowest_sl(n_humus_3_sl[sl_max_1]);
2064
2065 lerr_t rc = transport_.pertubation(1.0, D_eff_dailyturbation_sl, sc_.C_micro1_sl, sc_.h_sl, interface_delta_x_soil_sl);
2066 if ( rc){ return rc; }
2067 rc = transport_.pertubation(1.0, D_eff_dailyturbation_sl, n_micro_1_sl, sc_.h_sl, interface_delta_x_soil_sl);
2068 if ( rc){ return rc; }
2069
2070 rc = transport_.pertubation(1.0, D_eff_dailyturbation_sl, sc_.C_micro2_sl, sc_.h_sl, interface_delta_x_soil_sl);
2071 if ( rc){ return rc; }
2072 rc = transport_.pertubation(1.0, D_eff_dailyturbation_sl, n_micro_2_sl, sc_.h_sl, interface_delta_x_soil_sl);
2073 if ( rc){ return rc; }
2074
2075 rc = transport_.pertubation(1.0, D_eff_dailyturbation_sl, sc_.C_micro3_sl, sc_.h_sl, interface_delta_x_soil_sl);
2076 if ( rc){ return rc; }
2077 rc = transport_.pertubation(1.0, D_eff_dailyturbation_sl, n_micro_3_sl, sc_.h_sl, interface_delta_x_soil_sl);
2078 if ( rc){ return rc; }
2079
2080 rc = transport_.pertubation(1.0, D_eff_dailyturbation_sl, sc_.C_aorg_sl, sc_.h_sl, interface_delta_x_soil_sl);
2081 if ( rc){ return rc; }
2082 rc = transport_.pertubation(1.0, D_eff_dailyturbation_sl, sc_.N_aorg_sl, sc_.h_sl, interface_delta_x_soil_sl);
2083 if ( rc){ return rc; }
2084
2085 rc = transport_.pertubation(1.0, D_eff_dailyturbation_sl, sc_.C_lit1_sl, sc_.h_sl, interface_delta_x_soil_sl);
2086 if ( rc){ return rc; }
2087 rc = transport_.pertubation(1.0, D_eff_dailyturbation_sl, sc_.N_lit1_sl, sc_.h_sl, interface_delta_x_soil_sl);
2088 if ( rc){ return rc; }
2089
2090 rc = transport_.pertubation(1.0, D_eff_dailyturbation_sl, sc_.C_lit2_sl, sc_.h_sl, interface_delta_x_soil_sl);
2091 if ( rc){ return rc; }
2092 rc = transport_.pertubation(1.0, D_eff_dailyturbation_sl, sc_.N_lit2_sl, sc_.h_sl, interface_delta_x_soil_sl);
2093 if ( rc){ return rc; }
2094
2095 rc = transport_.pertubation(1.0, D_eff_dailyturbation_sl, sc_.C_lit3_sl, sc_.h_sl, interface_delta_x_soil_sl);
2096 if ( rc){ return rc; }
2097 rc = transport_.pertubation(1.0, D_eff_dailyturbation_sl, sc_.N_lit3_sl, sc_.h_sl, interface_delta_x_soil_sl);
2098 if ( rc){ return rc; }
2099
2100 rc = transport_.pertubation(1.0, D_eff_dailyturbation_sl, c_humus_1_sl, sc_.h_sl, interface_delta_x_soil_sl);
2101 if ( rc){ return rc; }
2102 rc = transport_.pertubation(1.0, D_eff_dailyturbation_sl, n_humus_1_sl, sc_.h_sl, interface_delta_x_soil_sl);
2103 if ( rc){ return rc; }
2104
2105 rc = transport_.pertubation(1.0, D_eff_dailyturbation_sl, c_humus_2_sl, sc_.h_sl, interface_delta_x_soil_sl);
2106 if ( rc){ return rc; }
2107 rc = transport_.pertubation(1.0, D_eff_dailyturbation_sl, n_humus_2_sl, sc_.h_sl, interface_delta_x_soil_sl);
2108 if ( rc){ return rc; }
2109
2110 rc = transport_.pertubation(1.0, D_eff_dailyturbation_sl, c_humus_3_sl, sc_.h_sl, interface_delta_x_soil_sl);
2111 if ( rc){ return rc; }
2112 rc = transport_.pertubation(1.0, D_eff_dailyturbation_sl, n_humus_3_sl, sc_.h_sl, interface_delta_x_soil_sl);
2113 if ( rc){ return rc; }
2114
2115 rc = transport_.pertubation(1.0, D_eff_dailyturbation_sl, c_biochar_sl, sc_.h_sl, interface_delta_x_soil_sl);
2116 if ( rc){ return rc; }
2117 rc = transport_.pertubation(1.0, D_eff_dailyturbation_sl, n_biochar_sl, sc_.h_sl, interface_delta_x_soil_sl);
2118 if ( rc){ return rc; }
2119
2120 if ( output_writer_.write_fluxes() || iso_)
2121 {
2122 /* nmicro */
2123 transport_.calculate_soil_perturbation_fluxes( sl_.soil_layer_cnt(), 1.0, sc_.h_sl, interface_delta_x_soil_sl, D_eff_dailyturbation_sl, n_micro_1_sl, nmicro1_lowest_sl, communicate_sl);
2124 for (size_t sl = 0; sl < sl_.soil_layer_cnt(); sl++)
2125 {
2126 accumulated_n_micro_perturbation_sl[sl] += communicate_sl[sl];
2127 }
2128 transport_.calculate_soil_perturbation_fluxes( sl_.soil_layer_cnt(), 1.0, sc_.h_sl, interface_delta_x_soil_sl, D_eff_dailyturbation_sl, n_micro_2_sl, nmicro2_lowest_sl, communicate_sl);
2129 for (size_t sl = 0; sl < sl_.soil_layer_cnt(); sl++)
2130 {
2131 accumulated_n_micro_perturbation_sl[sl] += communicate_sl[sl];
2132 }
2133 transport_.calculate_soil_perturbation_fluxes( sl_.soil_layer_cnt(), 1.0, sc_.h_sl, interface_delta_x_soil_sl, D_eff_dailyturbation_sl, n_micro_3_sl, nmicro3_lowest_sl, communicate_sl);
2134 for (size_t sl = 0; sl < sl_.soil_layer_cnt(); sl++)
2135 {
2136 accumulated_n_micro_perturbation_sl[sl] += communicate_sl[sl];
2137 }
2138
2139 /* naorg */
2140 transport_.calculate_soil_perturbation_fluxes( sl_.soil_layer_cnt(), 1.0, sc_.h_sl, interface_delta_x_soil_sl, D_eff_dailyturbation_sl, sc_.N_aorg_sl, naorg_lowest_sl, communicate_sl);
2141 for (size_t sl = 0; sl < sl_.soil_layer_cnt(); sl++)
2142 {
2143 accumulated_n_aorg_perturbation_sl[sl] += communicate_sl[sl];
2144 }
2145
2146 /*litter*/
2147 transport_.calculate_soil_perturbation_fluxes( sl_.soil_layer_cnt(), 1.0, sc_.h_sl, interface_delta_x_soil_sl, D_eff_dailyturbation_sl, sc_.N_lit1_sl, nlit1_lowest_sl, communicate_sl);
2148 for (size_t sl = 0; sl < sl_.soil_layer_cnt(); sl++)
2149 {
2150 accumulated_n_litter_perturbation_sl[sl] += communicate_sl[sl];
2151 }
2152 transport_.calculate_soil_perturbation_fluxes( sl_.soil_layer_cnt(), 1.0, sc_.h_sl, interface_delta_x_soil_sl, D_eff_dailyturbation_sl, sc_.N_lit2_sl, nlit2_lowest_sl, communicate_sl);
2153 for (size_t sl = 0; sl < sl_.soil_layer_cnt(); sl++)
2154 {
2155 accumulated_n_litter_perturbation_sl[sl] += communicate_sl[sl];
2156 }
2157 transport_.calculate_soil_perturbation_fluxes( sl_.soil_layer_cnt(), 1.0, sc_.h_sl, interface_delta_x_soil_sl, D_eff_dailyturbation_sl, sc_.N_lit3_sl, nlit3_lowest_sl, communicate_sl);
2158 for (size_t sl = 0; sl < sl_.soil_layer_cnt(); sl++)
2159 {
2160 accumulated_n_litter_perturbation_sl[sl] += communicate_sl[sl];
2161 }
2162
2163 /*humus*/
2164 transport_.calculate_soil_perturbation_fluxes( sl_.soil_layer_cnt(), 1.0, sc_.h_sl, interface_delta_x_soil_sl, D_eff_dailyturbation_sl, n_humus_1_sl, nhum1_lowest_sl, communicate_sl);
2165 for (size_t sl = 0; sl < sl_.soil_layer_cnt(); sl++)
2166 {
2167 accumulated_n_humus_1_perturbation_sl[sl] += communicate_sl[sl];
2168 }
2169 transport_.calculate_soil_perturbation_fluxes( sl_.soil_layer_cnt(), 1.0, sc_.h_sl, interface_delta_x_soil_sl, D_eff_dailyturbation_sl, n_humus_2_sl, nhum2_lowest_sl, communicate_sl);
2170 for (size_t sl = 0; sl < sl_.soil_layer_cnt(); sl++)
2171 {
2172 accumulated_n_humus_2_perturbation_sl[sl] += communicate_sl[sl];
2173 }
2174 transport_.calculate_soil_perturbation_fluxes( sl_.soil_layer_cnt(), 1.0, sc_.h_sl, interface_delta_x_soil_sl, D_eff_dailyturbation_sl, n_humus_3_sl, nhum3_lowest_sl, communicate_sl);
2175 for (size_t sl = 0; sl < sl_.soil_layer_cnt(); sl++)
2176 {
2177 accumulated_n_humus_3_perturbation_sl[sl] += communicate_sl[sl];
2178 }
2179 }
2180 }
2181 return LDNDC_ERR_OK;
2182}
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

References MeTrX_incorporation_floor().

Referenced by MeTrX_liq_diffusion(), and solve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_pH_calculation()

void ldndc::SoilChemistryMeTrX::MeTrX_pH_calculation ( )
private
Parameters
[in]None
[out]None
Returns
void
769{
770 for ( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
771 {
772 sc_.ph_sl[sl] = MeTrX_get_ph_sl( sl);
773 }
774}

References MeTrX_get_ph_sl().

Referenced by MeTrX_fermentation(), and solve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_physics()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_physics ( )
private
Parameters
[in]None
[out]None
Returns
error code

References MeTrX_advection(), MeTrX_advection_equilibrium(), and MeTrX_advection_move_gas().

Referenced by solve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_radon_source_sink()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_radon_source_sink ( )
private
Parameters
[in]None
[out]None
Returns
error code
564{
565 if ( have_radon_diffusion)
566 {
567 for( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
568 {
569 //timestep in seconds
570 double const Delta_t( 3600 * 24.0 / (double)TOTAL_TIME_STEPS );
571
572 //emanation coefficient
573 double emanation_coeff( sc_.sand_sl[sl] * radon_emanation_coeff( sl,
574 sipar_.METRX_RADON_EMANATION_SAND_EPS0(),
575 sipar_.METRX_RADON_EMANATION_SAND_A(),
576 sipar_.METRX_RADON_EMANATION_SAND_B(),
577 sipar_.METRX_RADON_EMANATION_SAND_C())
578 + sc_.silt_sl[sl] * radon_emanation_coeff( sl,
579 sipar_.METRX_RADON_EMANATION_SILT_EPS0(),
580 sipar_.METRX_RADON_EMANATION_SILT_A(),
581 sipar_.METRX_RADON_EMANATION_SILT_B(),
582 sipar_.METRX_RADON_EMANATION_SILT_C())
583 + sc_.clay_sl[sl] * radon_emanation_coeff( sl, sipar_.METRX_RADON_EMANATION_CLAY_EPS0(),
584 sipar_.METRX_RADON_EMANATION_CLAY_A(),
585 sipar_.METRX_RADON_EMANATION_CLAY_B(),
586 sipar_.METRX_RADON_EMANATION_CLAY_C()));
587
588 //radon source/sink term: creation of radon-222 via the decay of radium-226
589 // and its radioactive decay
590 radon_gas_sl[sl] += sipar_.METRX_RADON_DECAY_CONST() * Delta_t * sc_.radium_sl[sl] * sc_.get_soil_mass( sl) * emanation_coeff
591 - Delta_t * sipar_.METRX_RADON_DECAY_CONST() * radon_gas_sl[sl];
592
593 //radon sink term: radioactive decay of radon
594 //radon_gas_sl[sl] -= Delta_t * sipar_.METRX_RADON_DECAY_CONST() * radon_gas_sl[sl];
595 radon_liq_sl[sl] -= Delta_t * sipar_.METRX_RADON_DECAY_CONST() * radon_liq_sl[sl];
596 }
597 }
598 return LDNDC_ERR_OK;
599}

Referenced by MeTrX_leaching(), and solve().

Here is the caller graph for this function:

◆ MeTrX_receive_state()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_receive_state ( )
private
Parameters
[in]None
[out]None
Returns
error code
263{
264 /* pyrogenic (black) carbon deposited by fires (eventhandler:spitfire) enters the biochar pool */
265 for ( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
266 {
267 if ( cbm::flt_greater_zero( sc_.black_carbon_sl[sl]))
268 {
269 c_biochar_sl[sl] += sc_.black_carbon_sl[sl];
270 sc_.black_carbon_sl[sl] = 0.0;
271 }
272 }
273
274 for ( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
275 {
276 if ( cbm::flt_greater_zero( sc_.nh4_sl[sl]))
277 {
278 double const nh4_old( nh4_ae_sl[sl] + nh4_an_sl[sl]);
279 if ( cbm::flt_greater_zero( nh4_old))
280 {
281 nh4_ae_sl[sl] = cbm::bound_min( 0.0, nh4_ae_sl[sl] / nh4_old * sc_.nh4_sl[sl]);
282 nh4_an_sl[sl] = cbm::bound_min( 0.0, sc_.nh4_sl[sl] - nh4_ae_sl[sl]);
283 }
284 else
285 {
286 nh4_ae_sl[sl] = (1.0 - sc_.anvf_sl[sl]) * sc_.nh4_sl[sl];
287 nh4_an_sl[sl] = sc_.anvf_sl[sl] * sc_.nh4_sl[sl];
288 }
289 }
290 else
291 {
292 nh4_ae_sl[sl] = 0.0;
293 nh4_an_sl[sl] = 0.0;
294 }
295
296 if ( cbm::flt_greater_zero( sc_.don_sl[sl]))
297 {
298 double const don_old( don_ae_sl[sl] + don_an_sl[sl]);
299 if ( cbm::flt_greater_zero( don_old))
300 {
301 don_ae_sl[sl] = cbm::bound_min( 0.0, don_ae_sl[sl] / don_old * sc_.don_sl[sl]);
302 don_an_sl[sl] = cbm::bound_min( 0.0, sc_.don_sl[sl] - don_ae_sl[sl]);
303 }
304 else
305 {
306 don_ae_sl[sl] = (1.0 - sc_.anvf_sl[sl]) * sc_.don_sl[sl];
307 don_an_sl[sl] = sc_.anvf_sl[sl] * sc_.don_sl[sl];
308 }
309 }
310 else
311 {
312 don_ae_sl[sl] = 0.0;
313 don_an_sl[sl] = 0.0;
314 }
315
316 double no3_tot( sc_.no3_sl[sl] + sc_.an_no3_sl[sl]);
317 if ( cbm::flt_greater_zero( no3_tot))
318 {
319 double const no3_old( no3_ae_sl[sl] + no3_an_sl[sl]);
320 if ( cbm::flt_greater_zero( no3_old))
321 {
322 no3_ae_sl[sl] = cbm::bound_min( 0.0, no3_ae_sl[sl] / no3_old * no3_tot);
323 no3_an_sl[sl] = cbm::bound_min( 0.0, no3_tot - no3_ae_sl[sl]);
324 }
325 else
326 {
327 no3_ae_sl[sl] = (1.0 - sc_.anvf_sl[sl]) * no3_tot;
328 no3_an_sl[sl] = sc_.anvf_sl[sl] * no3_tot;
329 }
330 }
331 else
332 {
333 no3_ae_sl[sl] = 0.0;
334 no3_an_sl[sl] = 0.0;
335 }
336 }
337
338 return LDNDC_ERR_OK;
339}

Referenced by MeTrX_update().

Here is the caller graph for this function:

◆ MeTrX_reset()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_reset ( )
private
Parameters
[in]None
[out]None
Returns
void
194{
195 co2_auto_sl = 0.0;
196 co2_hetero_sl = 0.0;
197
198 if ( timemode_ == TMODE_SUBDAILY)
199 {
200 if ( lclock()->is_position( TMODE_PRE_DAILY))
201 {
204 }
205 }
206 else
207 {
210 }
211
212 return LDNDC_ERR_OK;
213}
lerr_t MeTrX_reset_subdaily()
Definition soilchemistry-metrx-reset.cpp:221
lerr_t MeTrX_reset_daily()
Definition soilchemistry-metrx-reset.cpp:273

References MeTrX_reset_daily(), and MeTrX_reset_subdaily().

Referenced by MeTrX_manure(), and solve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_reset_daily()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_reset_daily ( )
private
Parameters
[in]None
[out]None
Returns
void
274{
275 /* Soil layer variables */
276 for (size_t sl = 0; sl < sl_.soil_layer_cnt(); sl++)
277 {
278 plant_o2_consumption_sl[sl] = 0.0;
279
280 day_nitrify_n2o_sl[sl] = 0.0;
281 day_nit_no2_no3_sl[sl] = 0.0;
282
283 day_acetate_cons_fe3_sl[sl] = 0.0;
284 day_h2_c_eq_cons_fe3_sl[sl] = 0.0;
285 day_fe2_oxidation_sl[sl] = 0.0;
286 day_sulfate_reduction_sl[sl] = 0.0;
287 day_sulfide_oxidation_sl[sl] = 0.0;
288
289 day_acetate_prod_sl[sl] = 0.0;
290
291 day_ch4_oxidation_sl[sl] = 0.0;
292
293 day_h2_c_eq_prod_sl[sl] = 0.0;
294 day_ch4_production_acetate_sl[sl] = 0.0;
295 day_ch4_production_hydrogen_sl[sl] = 0.0;
296
297 day_doc_prod_sl[sl] = 0.0;
298 day_denit_factor_c_sl[sl] = 0.0;
299 day_denit_factor_n_sl[sl] = 0.0;
300 }
301
302 // Groundwater access
303 day_no3_groundwater_access = 0.0;
304
305 // Mineralisation
306 day_min_n_decomp = 0.0;
307 day_min_n_aorg = 0.0;
308 day_min_n_mic_1 = 0.0;
309 day_min_n_mic_2 = 0.0;
310 day_min_n_mic_3 = 0.0;
311
312 // Assimilation
313 day_assi_n_mic_1 = 0.0;
314 day_assi_n_mic_2 = 0.0;
315 day_assi_n_mic_3 = 0.0;
316 day_assi_c_mic_1 = 0.0;
317 day_assi_c_mic_2 = 0.0;
318 day_assi_c_mic_3 = 0.0;
319
320 // Nitrification
321 day_nit_nh4_no2 = 0.0;
322 day_nit_no2_no = 0.0;
323 day_nit_no2_n2o = 0.0;
324 day_nit_no2_no3_sl = 0.0;
325
326 // Denitrification
327 day_denit_no3_no2 = 0.0;
328 day_denit_no2_no = 0.0;
329 day_denit_no2_n2o = 0.0;
330 day_denit_no2_n2 = 0.0;
331 day_denit_no_n2o = 0.0;
332 day_denit_no_n2 = 0.0;
333 day_denit_n2o_n2 = 0.0;
334 day_chemodenit_no2_no = 0.0;
335
336 // Respiration / Fermentation / Methanogenesis
337 day_co2_prod_mic_1_growth = 0.0;
338 day_co2_prod_mic_1_maintenance = 0.0;
339 day_co2_prod_mic_2 = 0.0;
340 day_co2_prod_mic_3_acetate_prod = 0.0;
341 day_co2_prod_mic_3_acetate_cons = 0.0;
342 day_co2_prod_ch4_prod = 0.0;
343 day_co2_prod_ch4_cons = 0.0;
344
345 // Leaching
346 day_leach_o2 = 0.0;
347 day_leach_n2o = 0.0;
348 day_leach_n2 = 0.0;
349 day_leach_no = 0.0;
350 day_leach_nh3 = 0.0;
351 day_leach_urea = 0.0;
352 day_leach_radon = 0.0;
353
354 // litter
355 dC_root_exsudates = 0.0;
356 dC_litter_algae = 0.0;
357
358 // Decomposition
359 day_decomp_c_lit_1 = 0.0;
360 day_decomp_c_lit_2 = 0.0;
361 day_decomp_c_lit_3 = 0.0;
362 day_decomp_n_lit_1 = 0.0;
363 day_decomp_n_lit_2 = 0.0;
364 day_decomp_n_lit_3 = 0.0;
365 day_decomp_c_hum_1_sl = 0.0;
366 day_decomp_c_hum_2_sl = 0.0;
367 day_decomp_c_hum_3_sl = 0.0;
368 day_decay_c_mic_sl = 0.0;
369 day_decomp_n_hum_1 = 0.0;
370 day_decomp_n_hum_2 = 0.0;
371 day_decomp_n_hum_3 = 0.0;
372
373 // Humification
374 day_c_humify_doc_hum_2_sl = 0.0;
375 day_c_humify_sol_hum_1_sl = 0.0;
376 day_c_humify_cel_hum_1_sl = 0.0;
377 day_c_humify_lig_hum_1_sl = 0.0;
378 day_c_humify_lig_hum_2_sl = 0.0;
379 day_c_humify_mic_hum_1_sl = 0.0;
380 day_c_humify_mic_hum_2_sl = 0.0;
381 day_c_humify_hum_1_hum_2_sl = 0.0;
382 day_c_humify_hum_2_hum_3_sl = 0.0;
383
384 // Algae
385 day_n_fix_algae = 0.0;
386 day_c_fix_algae = 0.0;
387
388 //CH4 oxidation
389 day_ch4_oxidation_la = 0.0;
390 day_ch4_oxidation_ha = 0.0;
391
392 // DOC production
393 day_doc_prod_decomp_litter = 0.0;
394 day_doc_prod_decomp_humus = 0.0;
395 day_doc_prod_decomp_aorg = 0.0;
396
397 return LDNDC_ERR_OK;
398}

Referenced by MeTrX_manure(), and MeTrX_reset().

Here is the caller graph for this function:

◆ MeTrX_reset_subdaily()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_reset_subdaily ( )
private
Parameters
[in]None
[out]None
Returns
void
222{
223 for ( size_t ts = 0; ts < static_cast< size_t >( TOTAL_TIME_STEPS); ts++)
224 {
225 subdaily_co2_bubbling[ts] = 0.0;
226 subdaily_co2_plant[ts] = 0.0;
227 subdaily_co2_soil[ts] = 0.0;
228 subdaily_co2_water[ts] = 0.0;
229 subdaily_co2_leach[ts] = 0.0;
230
231 subdaily_ch4_bubbling[ts] = 0.0;
232 subdaily_ch4_plant[ts] = 0.0;
233 subdaily_ch4_soil[ts] = 0.0;
234 subdaily_ch4_water[ts] = 0.0;
235 subdaily_ch4_leach[ts] = 0.0;
236 subdaily_ch4_prod[ts] = 0.0;
237 subdaily_ch4_ox[ts] = 0.0;
238 subdaily_acetate_prod[ts] = 0.0;
239 subdaily_doc_prod[ts] = 0.0;
240 subdaily_plant_o2_cons[ts] = 0.0;
241 subdaily_flood_o2_conc[ts] = 0.0;
242 subdaily_algae_o2_prod[ts] = 0.0;
243 subdaily_o2_bubbling[ts] = 0.0;
244 subdaily_o2_plant[ts] = 0.0;
245 subdaily_o2_soil[ts] = 0.0;
246 subdaily_o2_water[ts] = 0.0;
247 subdaily_n2o_bubbling[ts] = 0.0;
248 subdaily_n2o_plant[ts] = 0.0;
249 subdaily_n2o_soil[ts] = 0.0;
250 subdaily_n2o_water[ts] = 0.0;
251 subdaily_no_bubbling[ts] = 0.0;
252 subdaily_no_plant[ts] = 0.0;
253 subdaily_no_soil[ts] = 0.0;
254 subdaily_no_water[ts] = 0.0;
255 subdaily_nh3_bubbling[ts] = 0.0;
256 subdaily_nh3_plant[ts] = 0.0;
257 subdaily_nh3_soil[ts] = 0.0;
258 subdaily_nh3_water[ts] = 0.0;
259 subdaily_radon_soil[ts] = 0.0;
260 subdaily_radon_plant[ts] = 0.0;
261 subdaily_radon_water[ts] = 0.0;
262 }
263
264 return LDNDC_ERR_OK;
265}

Referenced by MeTrX_manure(), and MeTrX_reset().

Here is the caller graph for this function:

◆ MeTrX_send_state()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_send_state ( )
private
Parameters
[in]None
[out]None
Returns
error code
348{
349 for( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
350 {
351 sc_.nh4_sl[sl] = nh4_ae_sl[sl] + nh4_an_sl[sl];
352 sc_.don_sl[sl] = don_ae_sl[sl] + don_an_sl[sl];
353 sc_.no3_sl[sl] = no3_ae_sl[sl] + no3_an_sl[sl];
354 sc_.an_no3_sl[sl] = 0.0;
355 }
356
357 return LDNDC_ERR_OK;
358}

Referenced by MeTrX_write_rates().

Here is the caller graph for this function:

◆ MeTrX_soil_organic_matter_turnover()

void ldndc::SoilChemistryMeTrX::MeTrX_soil_organic_matter_turnover ( )
private
Parameters
[in]None
[out]None
Returns
void

Referenced by solve().

Here is the caller graph for this function:

◆ MeTrX_spinup()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_spinup ( )
private
Parameters
[in]None
[out]None
Returns
void

References MeTrX_spinup_raw_litter().

Referenced by solve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_spinup_raw_litter()

double & ldndc::SoilChemistryMeTrX::MeTrX_spinup_raw_litter ( bool _c,
size_t _pos,
size_t _f )
private

Carbon (_c = true) or nitrogen of raw litter fraction _f (0: solubles, 1: cellulose, 2: lignin) in soil layer _pos or aboveground (_pos = soil layer count)

raw litter carbon or nitrogen of soil layer or aboveground (_pos = soil layer count)

824{
825 if ( _pos == sl_.soil_layer_cnt())
826 {
827 if ( _f == 0) { return _c ? sc_.c_raw_lit_1_above : sc_.n_raw_lit_1_above; }
828 else if ( _f == 1) { return _c ? sc_.c_raw_lit_2_above : sc_.n_raw_lit_2_above; }
829 else { return _c ? sc_.c_raw_lit_3_above : sc_.n_raw_lit_3_above; }
830 }
831 if ( _f == 0) { return _c ? sc_.c_raw_lit_1_sl[_pos] : sc_.n_raw_lit_1_sl[_pos]; }
832 else if ( _f == 1) { return _c ? sc_.c_raw_lit_2_sl[_pos] : sc_.n_raw_lit_2_sl[_pos]; }
833 else { return _c ? sc_.c_raw_lit_3_sl[_pos] : sc_.n_raw_lit_3_sl[_pos]; }
834}

Referenced by MeTrX_spinup().

Here is the caller graph for this function:

◆ MeTrX_sulfate_reduction()

void ldndc::SoilChemistryMeTrX::MeTrX_sulfate_reduction ( )
private
Parameters
[in]None
[out]None
Returns
void

Referenced by solve().

Here is the caller graph for this function:

◆ MeTrX_sulfide_oxidation()

void ldndc::SoilChemistryMeTrX::MeTrX_sulfide_oxidation ( )
private
Parameters
[in]None
[out]None
Returns
void

Referenced by solve().

Here is the caller graph for this function:

◆ MeTrX_till()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_till ( )
private
Parameters
[in]None
[out]None
Returns
error code
843{
844 if ( cbm::flt_greater( sc_.till_effect_sl[0], 1.01))
845 {
846 for( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
847 {
848 sc_.till_effect_sl[sl] = cbm::bound_min( 1.0, sc_.till_effect_sl[sl] * (1.0 - (sipar_.METRX_TILL_STIMULATION_2() / lclock()->time_resolution())));
849 }
850 }
851 else if ( cbm::flt_greater( sc_.till_effect_sl[0], 1.0))
852 {
853 for( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
854 {
855 sc_.till_effect_sl[sl] = 1.0;
856 }
857 }
858
859 EventAttributes const * ev_till = NULL;
860 while (( ev_till = m_TillEvents.pop()) != NULL)
861 {
862 /***************************/
863 /* tilling depth and layer */
864 /***************************/
865
866 double till_depth( ev_till->get( "/depth", 0.0));
867 if ( till_depth > 0.5)
868 {
869 KLOGINFO( "tilling depth greater than 0.5m, reset to 0.5m [depth=",till_depth, "m,time=",lclock_ref().to_string(),"]");
870 till_depth = 0.5;
871 }
872
873 /* tillage type (none: original tilling) */
874 tillage_properties_t tp;
875 if ( tillage_properties( ev_till->get( "/type", ""), ev_till->get( "/mixing", invalid_dbl),
876 ev_till->get( "/incorporation", invalid_dbl), ev_till->get( "/inversion", invalid_dbl), tp))
877 {
878 return LDNDC_ERR_FAIL;
879 }
880 double const till_stimulation( tp.legacy ? sipar_.METRX_TILL_STIMULATION_1()
881 : 1.0 + (sipar_.METRX_TILL_STIMULATION_1() - 1.0) * tp.stimulation);
882
883 // number of soil layers mixed by tilling (at least the surface distribution layers 0..SL_SURFACE_DISTRIBUTION)
884 size_t till_layer_cnt( SL_SURFACE_DISTRIBUTION + 1);
885 if ( cbm::flt_greater_zero( till_depth))
886 {
887 for( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
888 {
889 if ( cbm::flt_less_equal( sc_.depth_sl[sl], till_depth))
890 {
891 sc_.till_effect_sl[sl] = till_stimulation;
892 till_layer_cnt = std::max( SL_SURFACE_DISTRIBUTION + 1, sl + 1);
893 }
894 else { break; }
895 }
896 }
897
898 if ( iso_) { MeTrX_isotopes_till_pre(); }
899
900 if ( !tp.legacy)
901 {
902 lerr_t rc_till( MeTrX_till_typed( tp, till_layer_cnt));
903 if ( rc_till)
904 {
905 return rc_till;
906 }
907 if ( iso_) { MeTrX_isotopes_till_post( tp, till_layer_cnt); }
908 continue;
909 }
910
911 /**************************************************/
912 /* stubble, root and surface litter incorporation */
913 /**************************************************/
914
915 /* incorporated carbon (input of the soil litter pools for the spinup, distributed as by the mixing below) */
916 double const c_incorporate_lit_1( sc_.c_stubble_lit1 + sc_.c_raw_lit_1_sl.sum());
917 double const c_incorporate_lit_2( sc_.c_stubble_lit2 + sc_.c_raw_lit_2_sl.sum());
918 double const c_incorporate_lit_3( sc_.c_stubble_lit3 + sc_.c_raw_lit_3_sl.sum());
919
920 bool todo( true);
921 if ( todo)
922 {
923 sc_.C_lit1_sl[0] += sc_.c_stubble_lit1 + sc_.c_raw_lit_1_sl.sum();
924 sc_.C_lit2_sl[0] += sc_.c_stubble_lit2 + sc_.c_raw_lit_2_sl.sum();
925 sc_.C_lit3_sl[0] += sc_.c_stubble_lit3 + sc_.c_raw_lit_3_sl.sum();
926
927 sc_.N_lit1_sl[0] += sc_.n_stubble_lit1 + sc_.n_raw_lit_1_sl.sum();
928 sc_.N_lit2_sl[0] += sc_.n_stubble_lit2 + sc_.n_raw_lit_2_sl.sum();
929 sc_.N_lit3_sl[0] += sc_.n_stubble_lit3 + sc_.n_raw_lit_3_sl.sum();
930 }
931 else
932 {
933 sc_.c_raw_lit_1_sl[0] += sc_.c_stubble_lit1;
934 sc_.c_raw_lit_2_sl[0] += sc_.c_stubble_lit2;
935 sc_.c_raw_lit_3_sl[0] += sc_.c_stubble_lit3;
936
937 sc_.n_raw_lit_1_sl[0] += sc_.n_stubble_lit1;
938 sc_.n_raw_lit_2_sl[0] += sc_.n_stubble_lit2;
939 sc_.n_raw_lit_3_sl[0] += sc_.n_stubble_lit3;
940 }
941
942 accumulated_n_surface_litter_incorporation_via_tilling_sl[0] += sc_.n_stubble_lit1 + sc_.n_stubble_lit2 + sc_.n_stubble_lit3 ;
943 accumulated_n_litter_tilling_sl[0] += sc_.n_raw_lit_1_sl.sum() + sc_.n_raw_lit_2_sl.sum() + sc_.n_raw_lit_3_sl.sum();
944
945 sc_.c_stubble_lit1 = sc_.c_stubble_lit2 = sc_.c_stubble_lit3 = 0.0;
946 sc_.n_stubble_lit1 = sc_.n_stubble_lit2 = sc_.n_stubble_lit3 = 0.0;
947
948 for( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
949 {
950 accumulated_n_litter_tilling_sl[sl] -= sc_.N_lit1_sl[sl] + sc_.N_lit2_sl[sl] + sc_.N_lit3_sl[sl] + sc_.n_raw_lit_1_sl[sl] + sc_.n_raw_lit_2_sl[sl] + sc_.n_raw_lit_3_sl[sl];
951 accumulated_n_aorg_tilling_sl[sl] -= sc_.N_aorg_sl[sl];
952 accumulated_n_humus_1_tilling_sl[sl] -= n_humus_1_sl[sl];
953 accumulated_n_humus_2_tilling_sl[sl] -= n_humus_2_sl[sl];
954 accumulated_n_humus_3_tilling_sl[sl] -= n_humus_3_sl[sl] + n_biochar_sl[sl];
955 accumulated_n_no3_tilling_sl[sl] -= no3_ae_sl[sl] + no3_an_sl[sl];
956 accumulated_n_no2_tilling_sl[sl] -= sc_.no2_sl[sl] + sc_.an_no2_sl[sl];
957 accumulated_n_no_tilling_sl[sl] -= no_gas_sl[sl] + no_liq_sl[sl] + an_no_gas_sl[sl] + an_no_liq_sl[sl];
958 accumulated_n_n2o_tilling_sl[sl] -= n2o_gas_sl[sl] + n2o_liq_sl[sl] + an_n2o_gas_sl[sl] + an_n2o_liq_sl[sl];
959 accumulated_n_urea_tilling_sl[sl] -= sc_.urea_sl[sl];
960 accumulated_n_don_tilling_sl[sl] -= don_ae_sl[sl] + don_an_sl[sl];
961 accumulated_n_nh4_tilling_sl[sl] -= nh4_ae_sl[sl] + nh4_an_sl[sl] + sc_.clay_nh4_sl[sl];
962 accumulated_n_nh3_tilling_sl[sl] -= sc_.nh3_gas_sl[sl] + sc_.nh3_liq_sl[sl];
963 accumulated_n_microbes_tilling_sl[sl] -= n_micro_1_sl[sl] + n_micro_2_sl[sl] + n_micro_3_sl[sl];
964 }
965
966 if ( todo)
967 {
968 sc_.c_raw_lit_1_sl = sc_.c_raw_lit_2_sl = sc_.c_raw_lit_3_sl = 0.0;
969 sc_.n_raw_lit_1_sl = sc_.n_raw_lit_2_sl = sc_.n_raw_lit_3_sl = 0.0;
970 }
971
972 /****************************************/
973 /* rearranging soil pools after tilling */
974 /****************************************/
975
976 lvector_t< double > pool_buf[] =
977 {
978 sc_.fe2_sl, sc_.fe3_sl,
979 sc_.c_raw_lit_1_sl, sc_.c_raw_lit_2_sl, sc_.c_raw_lit_3_sl,
980 sc_.n_raw_lit_1_sl, sc_.n_raw_lit_2_sl, sc_.n_raw_lit_3_sl,
981 sc_.C_lit1_sl, sc_.C_lit2_sl, sc_.C_lit3_sl,
982 sc_.N_lit1_sl, sc_.N_lit2_sl, sc_.N_lit3_sl,
983 sc_.C_aorg_sl, sc_.N_aorg_sl,
984 sc_.C_micro1_sl, sc_.C_micro2_sl, sc_.C_micro3_sl,
985 n_micro_1_sl, n_micro_2_sl, n_micro_3_sl,
986 c_humus_1_sl, c_humus_2_sl, c_humus_3_sl,
987 n_humus_1_sl, n_humus_2_sl, n_humus_3_sl,
988 c_biochar_sl, n_biochar_sl,
989 sc_.doc_sl, sc_.an_doc_sl,
990 ae_acetate_sl, an_acetate_sl,
991 no3_ae_sl, no3_an_sl,
992 sc_.no2_sl, sc_.an_no2_sl,
993 don_ae_sl, don_an_sl,
994 nh4_ae_sl, nh4_an_sl, sc_.clay_nh4_sl,
995 sc_.urea_sl, sc_.nh3_gas_sl, sc_.nh3_liq_sl,
996 no_gas_sl, no_liq_sl, an_no_gas_sl, an_no_liq_sl,
997 n2o_gas_sl, n2o_liq_sl, an_n2o_gas_sl, an_n2o_liq_sl
998 };
999
1000 /* spinup: incorporated stubble and raw litter are inputs of the soil litter pools of the tilled layers
1001 * (see @ref metrx_spinup); without them, the litter equilibrium of arable soils is close to zero */
1002 if ( todo && ( till_layer_cnt > 0) && spinup_.spinup_stage( this->lclock()))
1003 {
1004 for ( size_t l = 0; l < till_layer_cnt; l++)
1005 {
1006 double const f_layer( sc_.h_sl[l] / sc_.depth_sl[till_layer_cnt-1]);
1007 spinup_.c_to_lit_1_sl[l] += c_incorporate_lit_1 * f_layer;
1008 spinup_.c_to_lit_2_sl[l] += c_incorporate_lit_2 * f_layer;
1009 spinup_.c_to_lit_3_sl[l] += c_incorporate_lit_3 * f_layer;
1010 }
1011 }
1012
1013 size_t const pools_cnt( sizeof( pool_buf) / sizeof(lvector_t< double >));
1014 for ( size_t k = 0; ( till_layer_cnt > 0) && ( k < pools_cnt); ++k)
1015 {
1016 // summing up pool down to tilling depth
1017 double pool_sum( pool_buf[k].sum( till_layer_cnt) / sc_.depth_sl[till_layer_cnt-1]);
1018 for ( size_t l = 0; l < till_layer_cnt; l++)
1019 {
1020 pool_buf[k][l] = pool_sum * sc_.h_sl[l];
1021 }
1022 }
1023
1024 for( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
1025 {
1026 accumulated_n_litter_tilling_sl[sl] += sc_.N_lit1_sl[sl] + sc_.N_lit2_sl[sl] + sc_.N_lit3_sl[sl] + sc_.n_raw_lit_1_sl[sl] + sc_.n_raw_lit_2_sl[sl] + sc_.n_raw_lit_3_sl[sl];
1027 accumulated_n_aorg_tilling_sl[sl] += sc_.N_aorg_sl[sl];
1028 accumulated_n_humus_1_tilling_sl[sl] += n_humus_1_sl[sl];
1029 accumulated_n_humus_2_tilling_sl[sl] += n_humus_2_sl[sl];
1030 accumulated_n_humus_3_tilling_sl[sl] += n_humus_3_sl[sl] + n_biochar_sl[sl];
1031 accumulated_n_no3_tilling_sl[sl] += no3_ae_sl[sl] + no3_an_sl[sl];
1032 accumulated_n_no2_tilling_sl[sl] += sc_.no2_sl[sl] + sc_.an_no2_sl[sl];
1033 accumulated_n_no_tilling_sl[sl] += no_gas_sl[sl] + no_liq_sl[sl] + an_no_gas_sl[sl] + an_no_liq_sl[sl];
1034 accumulated_n_n2o_tilling_sl[sl] += n2o_gas_sl[sl] + n2o_liq_sl[sl] + an_n2o_gas_sl[sl] + an_n2o_liq_sl[sl];
1035 accumulated_n_urea_tilling_sl[sl] += sc_.urea_sl[sl];
1036 accumulated_n_don_tilling_sl[sl] += don_ae_sl[sl] + don_an_sl[sl];
1037 accumulated_n_nh4_tilling_sl[sl] += nh4_ae_sl[sl] + nh4_an_sl[sl] + sc_.clay_nh4_sl[sl];
1038 accumulated_n_nh3_tilling_sl[sl] += sc_.nh3_gas_sl[sl] + sc_.nh3_liq_sl[sl];
1039 accumulated_n_microbes_tilling_sl[sl] += n_micro_1_sl[sl] + n_micro_2_sl[sl] + n_micro_3_sl[sl];
1040 }
1041
1042 if ( iso_) { MeTrX_isotopes_till_post( tp, till_layer_cnt); }
1043 }
1044
1045 return LDNDC_ERR_OK;
1046}
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

References ldndc::tillage_properties_t::legacy, MeTrX_till_typed(), and ldndc::tillage_properties_t::stimulation.

Referenced by MeTrX_manure(), and solve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_till_typed()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_till_typed ( tillage_properties_t const & _tp,
size_t _till_layer_cnt )
private

Tilling with a given tillage type (partial mixing and incorporation, inversion), see Tilling.

Parameters
[in]tillageproperties, number of tilled layers
Returns
error code
1053{
1054 size_t const nt( _till_layer_cnt);
1055 if ( nt == 0)
1056 {
1057 return LDNDC_ERR_OK;
1058 }
1059
1060 lvector_t< double > pool_buf[] =
1061 {
1062 sc_.fe2_sl, sc_.fe3_sl,
1063 sc_.c_raw_lit_1_sl, sc_.c_raw_lit_2_sl, sc_.c_raw_lit_3_sl,
1064 sc_.n_raw_lit_1_sl, sc_.n_raw_lit_2_sl, sc_.n_raw_lit_3_sl,
1065 sc_.C_lit1_sl, sc_.C_lit2_sl, sc_.C_lit3_sl,
1066 sc_.N_lit1_sl, sc_.N_lit2_sl, sc_.N_lit3_sl,
1067 sc_.C_aorg_sl, sc_.N_aorg_sl,
1068 sc_.C_micro1_sl, sc_.C_micro2_sl, sc_.C_micro3_sl,
1069 n_micro_1_sl, n_micro_2_sl, n_micro_3_sl,
1070 c_humus_1_sl, c_humus_2_sl, c_humus_3_sl,
1071 n_humus_1_sl, n_humus_2_sl, n_humus_3_sl,
1072 c_biochar_sl, n_biochar_sl,
1073 sc_.doc_sl, sc_.an_doc_sl,
1074 ae_acetate_sl, an_acetate_sl,
1075 no3_ae_sl, no3_an_sl,
1076 sc_.no2_sl, sc_.an_no2_sl,
1077 don_ae_sl, don_an_sl,
1078 nh4_ae_sl, nh4_an_sl, sc_.clay_nh4_sl,
1079 sc_.urea_sl, sc_.nh3_gas_sl, sc_.nh3_liq_sl,
1080 no_gas_sl, no_liq_sl, an_no_gas_sl, an_no_liq_sl,
1081 n2o_gas_sl, n2o_liq_sl, an_n2o_gas_sl, an_n2o_liq_sl
1082 };
1083 size_t const pools_cnt( sizeof( pool_buf) / sizeof(lvector_t< double >));
1084
1085 /* diagnostics: state of the tilled layers before tilling */
1086 for ( size_t l = 0; l < nt; ++l)
1087 {
1088 accumulated_n_litter_tilling_sl[l] -= sc_.N_lit1_sl[l] + sc_.N_lit2_sl[l] + sc_.N_lit3_sl[l] + sc_.n_raw_lit_1_sl[l] + sc_.n_raw_lit_2_sl[l] + sc_.n_raw_lit_3_sl[l];
1089 accumulated_n_aorg_tilling_sl[l] -= sc_.N_aorg_sl[l];
1090 accumulated_n_humus_1_tilling_sl[l] -= n_humus_1_sl[l];
1091 accumulated_n_humus_2_tilling_sl[l] -= n_humus_2_sl[l];
1092 accumulated_n_humus_3_tilling_sl[l] -= n_humus_3_sl[l] + n_biochar_sl[l];
1093 accumulated_n_no3_tilling_sl[l] -= no3_ae_sl[l] + no3_an_sl[l];
1094 accumulated_n_no2_tilling_sl[l] -= sc_.no2_sl[l] + sc_.an_no2_sl[l];
1095 accumulated_n_no_tilling_sl[l] -= no_gas_sl[l] + no_liq_sl[l] + an_no_gas_sl[l] + an_no_liq_sl[l];
1096 accumulated_n_n2o_tilling_sl[l] -= n2o_gas_sl[l] + n2o_liq_sl[l] + an_n2o_gas_sl[l] + an_n2o_liq_sl[l];
1097 accumulated_n_urea_tilling_sl[l] -= sc_.urea_sl[l];
1098 accumulated_n_don_tilling_sl[l] -= don_ae_sl[l] + don_an_sl[l];
1099 accumulated_n_nh4_tilling_sl[l] -= nh4_ae_sl[l] + nh4_an_sl[l] + sc_.clay_nh4_sl[l];
1100 accumulated_n_nh3_tilling_sl[l] -= sc_.nh3_gas_sl[l] + sc_.nh3_liq_sl[l];
1101 accumulated_n_microbes_tilling_sl[l] -= n_micro_1_sl[l] + n_micro_2_sl[l] + n_micro_3_sl[l];
1102 }
1103
1104 /* incorporation: fraction of stubble and of the raw litter of the tilled layers */
1105 double const f_inc( _tp.incorporation);
1106 double const c_inc_1( f_inc * (sc_.c_stubble_lit1 + sc_.c_raw_lit_1_sl.sum( nt)));
1107 double const c_inc_2( f_inc * (sc_.c_stubble_lit2 + sc_.c_raw_lit_2_sl.sum( nt)));
1108 double const c_inc_3( f_inc * (sc_.c_stubble_lit3 + sc_.c_raw_lit_3_sl.sum( nt)));
1109 double const n_inc_1( f_inc * (sc_.n_stubble_lit1 + sc_.n_raw_lit_1_sl.sum( nt)));
1110 double const n_inc_2( f_inc * (sc_.n_stubble_lit2 + sc_.n_raw_lit_2_sl.sum( nt)));
1111 double const n_inc_3( f_inc * (sc_.n_stubble_lit3 + sc_.n_raw_lit_3_sl.sum( nt)));
1112 double const n_stubble_inc( f_inc * (sc_.n_stubble_lit1 + sc_.n_stubble_lit2 + sc_.n_stubble_lit3));
1113
1114 sc_.c_stubble_lit1 *= (1.0 - f_inc); sc_.c_stubble_lit2 *= (1.0 - f_inc); sc_.c_stubble_lit3 *= (1.0 - f_inc);
1115 sc_.n_stubble_lit1 *= (1.0 - f_inc); sc_.n_stubble_lit2 *= (1.0 - f_inc); sc_.n_stubble_lit3 *= (1.0 - f_inc);
1116 for ( size_t l = 0; l < nt; ++l)
1117 {
1118 sc_.c_raw_lit_1_sl[l] *= (1.0 - f_inc); sc_.c_raw_lit_2_sl[l] *= (1.0 - f_inc); sc_.c_raw_lit_3_sl[l] *= (1.0 - f_inc);
1119 sc_.n_raw_lit_1_sl[l] *= (1.0 - f_inc); sc_.n_raw_lit_2_sl[l] *= (1.0 - f_inc); sc_.n_raw_lit_3_sl[l] *= (1.0 - f_inc);
1120 }
1121
1122 /* partial homogenization of all pools of the tilled layers */
1123 double const z( sc_.depth_sl[nt-1]);
1124 for ( size_t k = 0; k < pools_cnt; ++k)
1125 {
1126 tillage_mix( pool_buf[k], nt, _tp.mixing, sc_.h_sl, z);
1127 }
1128
1129 /* placement of the incorporated litter (uppermost layer and mixed, or buried by inversion) */
1130 bool const spinup_stage( spinup_.spinup_stage( this->lclock()));
1131 for ( size_t l = 0; l < nt; ++l)
1132 {
1133 double const f_l( tillage_placement( l, nt, _tp, sc_.h_sl, sc_.depth_sl));
1134 sc_.C_lit1_sl[l] += c_inc_1 * f_l;
1135 sc_.C_lit2_sl[l] += c_inc_2 * f_l;
1136 sc_.C_lit3_sl[l] += c_inc_3 * f_l;
1137 sc_.N_lit1_sl[l] += n_inc_1 * f_l;
1138 sc_.N_lit2_sl[l] += n_inc_2 * f_l;
1139 sc_.N_lit3_sl[l] += n_inc_3 * f_l;
1140
1141 /* spinup: incorporated stubble and raw litter are inputs of the soil litter pools (see @ref metrx_spinup) */
1142 if ( spinup_stage)
1143 {
1144 spinup_.c_to_lit_1_sl[l] += c_inc_1 * f_l;
1145 spinup_.c_to_lit_2_sl[l] += c_inc_2 * f_l;
1146 spinup_.c_to_lit_3_sl[l] += c_inc_3 * f_l;
1147 }
1148
1149 /* diagnostics: stubble N is reported as surface litter incorporation, not as litter tilling */
1150 accumulated_n_litter_tilling_sl[l] -= n_stubble_inc * f_l;
1151 }
1152 accumulated_n_surface_litter_incorporation_via_tilling_sl[0] += n_stubble_inc;
1153
1154 /* diagnostics: state of the tilled layers after tilling */
1155 for ( size_t l = 0; l < nt; ++l)
1156 {
1157 accumulated_n_litter_tilling_sl[l] += sc_.N_lit1_sl[l] + sc_.N_lit2_sl[l] + sc_.N_lit3_sl[l] + sc_.n_raw_lit_1_sl[l] + sc_.n_raw_lit_2_sl[l] + sc_.n_raw_lit_3_sl[l];
1158 accumulated_n_aorg_tilling_sl[l] += sc_.N_aorg_sl[l];
1159 accumulated_n_humus_1_tilling_sl[l] += n_humus_1_sl[l];
1160 accumulated_n_humus_2_tilling_sl[l] += n_humus_2_sl[l];
1161 accumulated_n_humus_3_tilling_sl[l] += n_humus_3_sl[l] + n_biochar_sl[l];
1162 accumulated_n_no3_tilling_sl[l] += no3_ae_sl[l] + no3_an_sl[l];
1163 accumulated_n_no2_tilling_sl[l] += sc_.no2_sl[l] + sc_.an_no2_sl[l];
1164 accumulated_n_no_tilling_sl[l] += no_gas_sl[l] + no_liq_sl[l] + an_no_gas_sl[l] + an_no_liq_sl[l];
1165 accumulated_n_n2o_tilling_sl[l] += n2o_gas_sl[l] + n2o_liq_sl[l] + an_n2o_gas_sl[l] + an_n2o_liq_sl[l];
1166 accumulated_n_urea_tilling_sl[l] += sc_.urea_sl[l];
1167 accumulated_n_don_tilling_sl[l] += don_ae_sl[l] + don_an_sl[l];
1168 accumulated_n_nh4_tilling_sl[l] += nh4_ae_sl[l] + nh4_an_sl[l] + sc_.clay_nh4_sl[l];
1169 accumulated_n_nh3_tilling_sl[l] += sc_.nh3_gas_sl[l] + sc_.nh3_liq_sl[l];
1170 accumulated_n_microbes_tilling_sl[l] += n_micro_1_sl[l] + n_micro_2_sl[l] + n_micro_3_sl[l];
1171 }
1172
1173 return LDNDC_ERR_OK;
1174}
void tillage_mix(lvector_t< double > &_pool, size_t _cnt, double _mixing, lvector_t< double > const &_h, double _depth)
Partial homogenization of a pool over the first _cnt layers: pool_l = (1 - m) pool_l + m h_l / z * su...
Definition ld_tillage.cpp:103

References ldndc::tillage_properties_t::incorporation, ldndc::tillage_properties_t::mixing, and ldndc::tillage_mix().

Referenced by MeTrX_manure(), and MeTrX_till().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_update()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_update ( )
private
Parameters
[in]None
[out]None
Returns
error code
68{
69 lerr_t rc = MeTrX_receive_state();
70 if ( rc)
71 {
72 return LDNDC_ERR_FAIL;
73 }
74
75 /* vertical discretization */
76 MeTrX_update_soil_discretization( have_litter_height_change);
77
78 /* module specific variables from global state */
79 for( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
80 {
81 /* use liq/gas distribution from previous time step */
82 UPDATE_STATE( no_liq_sl[sl], no_gas_sl[sl], sc_.no_sl[sl]);
83 UPDATE_STATE( an_no_liq_sl[sl], an_no_gas_sl[sl], sc_.an_no_sl[sl]);
84 UPDATE_STATE( n2o_liq_sl[sl], n2o_gas_sl[sl], sc_.n2o_sl[sl]);
85 UPDATE_STATE( an_n2o_liq_sl[sl], an_n2o_gas_sl[sl], sc_.an_n2o_sl[sl]);
86
87 CHECK_FOR_ZERO( sc_.C_lit1_sl[sl]);
88 CHECK_FOR_ZERO( sc_.C_lit2_sl[sl]);
89 CHECK_FOR_ZERO( sc_.C_lit3_sl[sl]);
90 CHECK_FOR_ZERO( sc_.N_lit1_sl[sl]);
91 CHECK_FOR_ZERO( sc_.N_lit2_sl[sl]);
92 CHECK_FOR_ZERO( sc_.N_lit3_sl[sl]);
93 }
94
95 /* water table */
96 if ( cbm::flt_greater( wc_.surface_water, 0.01) &&
97 (sb_.surfacebulk_layer_cnt() > 0))
98 {
99 have_water_table = true;
100
101 // for simplicity of calculations changing watertable
102 // alters heigth of single waterlayer and not number of layers
103 h_wl = (wc_.surface_water / (double)sb_.surfacebulk_layer_cnt());
104 }
105 else if ( !cbm::flt_greater( wc_.surface_ice, 0.0))
106 {
107 have_water_table = false;
108 h_wl = 0.0;
109
110 double const clear_ch4( sb_.ch4_sbl.sum());
111 sb_.ch4_sbl = 0.0;
112 double const clear_o2( sb_.o2_sbl.sum());
113 sb_.o2_sbl = 0.0;
114 double const clear_nh4( sb_.nh4_sbl.sum());
115 sb_.nh4_sbl = 0.0;
116 double const clear_nh3( sb_.nh3_sbl.sum());
117 sb_.nh3_sbl = 0.0;
118 double const clear_urea( sb_.urea_sbl.sum());
119 sb_.urea_sbl = 0.0;
120 double const clear_no3( sb_.no3_sbl.sum());
121 sb_.no3_sbl = 0.0;
122 double const clear_don( sb_.don_sbl.sum());
123 sb_.don_sbl = 0.0;
124 double const clear_doc( sb_.doc_sbl.sum());
125 sb_.doc_sbl = 0.0;
126 double const clear_co2( sb_.co2_sbl.sum());
127 sb_.co2_sbl = 0.0;
128 double const clear_so4( sb_.so4_sbl.sum());
129 sb_.so4_sbl = 0.0;
130
131 for( size_t sl = 0; sl <= SL_SURFACE_DISTRIBUTION; ++sl)
132 {
133 ch4_liq_sl[sl] += clear_ch4 * SL_SURFACE_DISTRIBUTION_INVERSE;
134 o2_liq_sl[sl] += clear_o2 * SL_SURFACE_DISTRIBUTION_INVERSE;
135 nh4_ae_sl[sl] += clear_nh4 * SL_SURFACE_DISTRIBUTION_INVERSE;
136 sc_.nh3_liq_sl[sl] += clear_nh3 * SL_SURFACE_DISTRIBUTION_INVERSE;
137 sc_.urea_sl[sl] += clear_urea * SL_SURFACE_DISTRIBUTION_INVERSE;
138 no3_ae_sl[sl] += clear_no3 * SL_SURFACE_DISTRIBUTION_INVERSE;
139 don_ae_sl[sl] += clear_don * SL_SURFACE_DISTRIBUTION_INVERSE;
140 sc_.doc_sl[sl] += clear_doc * SL_SURFACE_DISTRIBUTION_INVERSE;
141 co2_liq_sl[sl] += clear_co2 * SL_SURFACE_DISTRIBUTION_INVERSE;
142 sc_.so4_sl[sl] += clear_so4 * SL_SURFACE_DISTRIBUTION_INVERSE;
143
144 accumulated_n_nh4_infiltration_phys_sl[sl] += clear_nh4 * SL_SURFACE_DISTRIBUTION_INVERSE;
145 accumulated_n_nh3_infiltration_phys_sl[sl] += clear_nh3 * SL_SURFACE_DISTRIBUTION_INVERSE;
146 accumulated_n_urea_infiltration_phys_sl[sl] += clear_urea * SL_SURFACE_DISTRIBUTION_INVERSE;
147 accumulated_n_no3_infiltration_phys_sl[sl] += clear_no3 * SL_SURFACE_DISTRIBUTION_INVERSE;
148 accumulated_n_don_infiltration_phys_sl[sl] += clear_don * SL_SURFACE_DISTRIBUTION_INVERSE;
149 }
150 }
151
152 /* water fluxes */
153 infiltration = wc_.accumulated_infiltration - accumulated_infiltration_old;
154 accumulated_infiltration_old = wc_.accumulated_infiltration;
155 for( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
156 {
157 waterflux_sl[sl] = wc_.accumulated_waterflux_sl[sl] - accumulated_waterflux_old_sl[sl];
158 accumulated_waterflux_old_sl[sl] = wc_.accumulated_waterflux_sl[sl];
159 gw_exchange_sl[sl] = wc_.accumulated_groundwater_exchange_sl[sl] - accumulated_gw_exchange_old_sl[sl];
160 accumulated_gw_exchange_old_sl[sl] = wc_.accumulated_groundwater_exchange_sl[sl];
161 }
162
163 /* nitrogen deposition */
164 if ( cbm::flt_greater_zero( wc_.surface_water) || cbm::flt_greater_zero( wc_.surface_ice))
165 {
166 accumulated_n_nh4_throughfall_sbl[0] += ph_.accumulated_nh4_throughfall - accumulated_n_nh4_throughfall_old;
167 accumulated_n_no3_throughfall_sbl[0] += ph_.accumulated_no3_throughfall - accumulated_n_no3_throughfall_old;
168 }
169 else
170 {
171 accumulated_n_nh4_throughfall_sl[0] += ph_.accumulated_nh4_throughfall - accumulated_n_nh4_throughfall_old;
172 accumulated_n_no3_throughfall_sl[0] += ph_.accumulated_no3_throughfall - accumulated_n_no3_throughfall_old;
173 }
174 accumulated_n_nh4_throughfall_old = ph_.accumulated_nh4_throughfall;
175 accumulated_n_no3_throughfall_old = ph_.accumulated_no3_throughfall;
176
177 /* carbon/nitrogen flux planting */
178 EventAttributes const * ev_plant = NULL;
179 while (( ev_plant = this->m_PlantEvents.pop()) != NULL)
180 {
181 MoBiLE_Plant *p = m_veg->get_plant( ev_plant->get( "/name", "?"));
182 if ( p)
183 {
184 accumulated_n_to_living_plant_and_algae_from_extern_sl[0] += p->total_nitrogen();
185
186 if ( spinup_.spinup_stage( this->lclock()))
187 {
188 site::input_class_site_t const *s_site( io_kcomm->get_input_class< site::input_class_site_t >());
189 ldndc::wood_initialization(sl_, p, sc_, s_site->soil_use_history());
190 }
191 }
192 }
193
194 /* carbon/nitrogen flux harvest/cutting */
195 accumulated_n_export_harvest_cutting_grazing += ph_.accumulated_n_export_harvest - accumulated_n_export_harvest_old;
196 accumulated_n_export_harvest_old = ph_.accumulated_n_export_harvest;
197
198 /* carbon/nitrogen flux litterfall */
199 accumulated_n_litter_from_plants_above_wood = sc_.accumulated_n_litter_wood_above;
200 accumulated_n_litter_from_plants_above_rawlitter = sc_.accumulated_n_litter_above;
201 accumulated_n_litter_from_plants_above_stubble = sc_.accumulated_n_litter_stubble;
202 for ( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
203 {
204 accumulated_n_litter_from_plants_below_rawlitter_sl[sl] = sc_.accumulated_n_litter_below_sl[sl];
205 accumulated_n_litter_from_plants_below_wood_sl[sl] = sc_.accumulated_n_litter_wood_below_sl[sl];
206 }
207
208 /* carbon/nitrogen flux root exsudation */
209 double const delta_c_exsudation( sc_.accumulated_c_root_exsudates_sl.sum() -
210 accumulated_c_root_exsudates_old_sl.sum());
211 if ( cbm::flt_greater_zero( delta_c_exsudation))
212 {
213 dC_root_exsudates += delta_c_exsudation;
214 subdaily_doc_prod[subdaily_time_step_] += delta_c_exsudation;
215 for( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
216 {
217 double const delta_c_exsudation_sl( sc_.accumulated_c_root_exsudates_sl[sl] - accumulated_c_root_exsudates_old_sl[sl]);
218 day_doc_prod_sl[sl] += delta_c_exsudation_sl;
219 if ( spinup_.spinup_stage( this->lclock()))
220 {
221 spinup_.c_doc_ext_sl[sl] += delta_c_exsudation_sl;
222 }
223 accumulated_c_root_exsudates_old_sl[sl] = sc_.accumulated_c_root_exsudates_sl[sl];
224 }
225 }
226
227 /* litter layer characterization */
228 double bio_coniferous( 0.0);
229 double bio_deciduous( 0.0);
230 for ( PlantIterator vt = this->m_veg->begin(); vt != this->m_veg->end(); ++vt)
231 {
232 MoBiLE_Plant *p( *vt);
233 if ( (*p)->DECIDUOUS())
234 {
235 bio_deciduous += p->aboveground_biomass();
236 }
237 else
238 {
239 bio_coniferous += p->aboveground_biomass();
240 }
241 }
242 double const bio_tot( bio_deciduous + bio_coniferous);
243 if ( cbm::flt_greater_zero( bio_tot))
244 {
245 double const frac_deciduous( bio_deciduous / bio_tot);
246 double const frac_coniferous( 1.0 - frac_deciduous);
247 for (size_t sl = 0; sl <= SL_SURFACE_DISTRIBUTION; ++sl)
248 {
249 litter_type_fact_sl[sl] = (frac_deciduous + sipar_.METRX_KR_REDUCTION_CONIFEROUS() * frac_coniferous);
250 }
251 }
252
253 return LDNDC_ERR_OK;
254}
double * gw_exchange_sl
Definition soilchemistry-metrx.h:265
lerr_t MeTrX_update_soil_discretization(bool)
Definition soilchemistry-metrx-reset.cpp:24
lerr_t MeTrX_receive_state()
Definition soilchemistry-metrx-communicate.cpp:262
lerr_t wood_initialization(soillayers::input_class_soillayers_t const &, MoBiLE_Plant *, substate_soilchemistry_t &, ecosystem_type_e)
Initialization of aboveground and belowground wood debris, derived from existing vegetation.
Definition ld_wood_initialization.cpp:23

References gw_exchange_sl, MeTrX_receive_state(), MeTrX_update_soil_discretization(), and ldndc::wood_initialization().

Referenced by MeTrX_manure(), and solve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_update_soil_discretization()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_update_soil_discretization ( bool _update_litter)
private
Parameters
[in]None
[out]None
Returns
error code
25{
26 if ( _update_litter && (sl_.soil_layers_in_litter_cnt() > 0))
27 {
28 double const raw_litter_above( (sc_.c_raw_lit_1_above +
29 sc_.c_raw_lit_2_above +
30 sc_.c_raw_lit_3_above)
31 /(cbm::CCDM * sl_.soil_layer_cnt()));
32
33 double * h_litter_neq_sl = new double[sl_.soil_layers_in_litter_cnt()];
34 double h_litter_tot( 0.0);
35 double volume_water_tot( 0.0);
36 double volume_ice_tot( 0.0);
37 for( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
38 {
39 if ( sl < sl_.soil_layers_in_litter_cnt())
40 {
41 if ( cbm::flt_greater_zero( sc_.dens_sl[sl] * sc_.fcorg_sl[sl]) &&
42 cbm::flt_greater_zero( sc_.som_sl[sl]))
43 {
44 double const volume_water( wc_.wc_sl[sl] * sc_.h_sl[sl]);
45 volume_water_tot += volume_water;
46
47 double const volume_ice( wc_.ice_sl[sl] * sc_.h_sl[sl]);
48 volume_ice_tot += volume_ice;
49
50 double const mass_soil( sc_.min_sl[sl] + sc_.get_soil_organic_matter( sl) + raw_litter_above);
51 double const density_soil( cbm::DM3_IN_M3 * sc_.dens_sl[sl]);
52
53 h_litter_neq_sl[sl] = mass_soil / density_soil;
54 h_litter_tot += mass_soil / density_soil;
55 }
56 }
57 }
58 double const h_litter_eq( h_litter_tot / sl_.soil_layers_in_litter_cnt());
59
60 if ( false)
61 {
62 // Create a list of pool arrays (all same size)
63 std::vector<lvector_t<double>*> pools = {
64 &c_humus_1_sl,
65 &c_humus_2_sl,
66 &c_humus_3_sl,
67 &n_humus_1_sl,
68 &n_humus_2_sl,
69 &n_humus_3_sl,
70 &sc_.c_wood_sl,
71 &sc_.n_wood_sl,
72 &sc_.c_raw_lit_1_sl,
73 &sc_.c_raw_lit_2_sl,
74 &sc_.c_raw_lit_3_sl,
75 &sc_.n_raw_lit_1_sl,
76 &sc_.n_raw_lit_2_sl,
77 &sc_.n_raw_lit_3_sl,
78 &sc_.C_lit1_sl,
79 &sc_.C_lit2_sl,
80 &sc_.C_lit3_sl,
81 &sc_.N_lit1_sl,
82 &sc_.N_lit2_sl,
83 &sc_.N_lit3_sl,
84 &sc_.C_aorg_sl,
85 &sc_.N_aorg_sl
86 };
87
88 std::vector<double> distribute_total( pools.size(), 0.0);
89
90 size_t n = sl_.soil_layers_in_litter_cnt();
91
92 for ( size_t sl = 0; sl < n; ++sl)
93 {
94 if ( h_litter_neq_sl[sl] > h_litter_eq)
95 {
96 double fraction = 1.0 - h_litter_eq / h_litter_neq_sl[sl];
97
98 for (size_t p = 0; p < pools.size(); ++p)
99 {
100 double value_sl = (*pools[p])[sl];
101 double distribute_sl = fraction * value_sl;
102
103 (*pools[p])[sl] -= distribute_sl;
104 distribute_total[p] += distribute_sl;
105 }
106 }
107 }
108
109 for ( size_t sl = 0; sl < n; ++sl)
110 {
111 if ( h_litter_neq_sl[sl] < h_litter_eq)
112 {
113 double fraction = h_litter_eq / h_litter_neq_sl[sl] - 1.0;
114
115 for ( size_t p = 0; p < pools.size(); ++p)
116 {
117 double value_sl = (*pools[p])[sl];
118 double need_sl = fraction * value_sl;
119
120 // Limit by remaining pool-level supply
121 double distribute_sl = cbm::bound_max(need_sl, distribute_total[p]);
122
123 (*pools[p])[sl] += distribute_sl;
124 distribute_total[p] -= distribute_sl;
125 }
126 }
127 }
128
129 for ( size_t p = 0; p < pools.size(); ++p)
130 {
131 if ( cbm::flt_greater_zero( distribute_total[p]))
132 {
133 for ( size_t sl = 0; sl < n; ++sl)
134 {
135 (*pools[p])[sl] += distribute_total[p] / n;
136 }
137 distribute_total[p] = 0.0;
138 }
139 }
140 }
141
142 double h_cum( 0.0);
143 for( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
144 {
145 if ( sl < sl_.soil_layers_in_litter_cnt())
146 {
147 sc_.h_sl[sl] = h_litter_eq;
148
149 double pore_vol_avail( 0.99 * sc_.poro_sl[sl] * sc_.h_sl[sl]);
150 double const ice_vol( (1.0 / sl_.soil_layers_in_litter_cnt() * volume_ice_tot));
151 if ( cbm::flt_greater( ice_vol, pore_vol_avail))
152 {
153 wc_.surface_ice += ice_vol - pore_vol_avail;
154 wc_.ice_sl[sl] = pore_vol_avail / sc_.h_sl[sl];
155 }
156 else
157 {
158 wc_.ice_sl[sl] = ice_vol / sc_.h_sl[sl];
159 }
160
161 pore_vol_avail = cbm::bound_min( 0.0, 0.99 * sc_.poro_sl[sl] * sc_.h_sl[sl] - ice_vol);
162 double const water_vol( (1.0 / sl_.soil_layers_in_litter_cnt() * volume_water_tot));
163 if ( cbm::flt_greater( water_vol, pore_vol_avail))
164 {
165 wc_.surface_water += water_vol - pore_vol_avail;
166 wc_.wc_sl[sl] = pore_vol_avail / sc_.h_sl[sl];
167 }
168 else
169 {
170 wc_.wc_sl[sl] = water_vol / sc_.h_sl[sl];
171 }
172 }
173 h_cum += sc_.h_sl[sl];
174 sc_.depth_sl[sl] = h_cum;
175 }
176 }
177
178 for( size_t sl = 0; sl < sl_.soil_layer_cnt()-1; ++sl)
179 {
180 delta_x[sl] = cbm::arithmetic_mean2( sc_.h_sl[sl], sc_.h_sl[sl+1]);
181 }
182 delta_x[sl_.soil_layer_cnt()-1] = sc_.h_sl[sl_.soil_layer_cnt()-1];
183
184 return LDNDC_ERR_OK;
185}

Referenced by MeTrX_update().

Here is the caller graph for this function:

◆ MeTrX_urea_hydrolysis()

void ldndc::SoilChemistryMeTrX::MeTrX_urea_hydrolysis ( )
private
Parameters
[in]None
[out]None
Returns
void
1199{
1200 if ( have_water_table)
1201 {
1202 double urea_hydrolysis_sum( 0.0);
1203 for ( size_t wl = 0; wl < sb_.surfacebulk_layer_cnt(); ++wl)
1204 {
1205 if ( cbm::flt_greater_zero( sb_.urea_sbl[wl]))
1206 {
1207 double const fact_t( MeTrX_get_fact_t_decomp( 0));
1208 double const urease_inhibition( inh_.urease_inhibition( sb_.ui_sbl[wl], h_wl));
1209 double const k_mm( sipar_.METRX_KMM_UREA_HYDROLYSIS() * h_wl);
1210 double const fact_urea( sb_.urea_sbl[wl] / (sb_.urea_sbl[wl] + k_mm));
1211 double const fact_ui( cbm::bound( 0.0, 1.0 - urease_inhibition, 1.0));
1212 double const urea_hydrolysis( cbm::bound_max( sipar_.METRX_KR_UREA_HYDROLYSIS() * fact_urea * fact_t * fact_ui * sb_.urea_sbl[wl] * FTS_TOT_,
1213 0.99 * sb_.urea_sbl[wl]));
1214
1215 sb_.urea_sbl[wl] -= urea_hydrolysis;
1216 sb_.nh4_sbl[wl] += urea_hydrolysis;
1217 accumulated_n_urea_nh4_hydrolysis_sbl[0] += urea_hydrolysis;
1218 urea_hydrolysis_sum += urea_hydrolysis;
1219 }
1220 else
1221 {
1222 sb_.urea_sbl[wl] = 0.0;
1223 }
1224 }
1225 ph_delta_urea_wl = cbm::bound( 0.0, urea_hydrolysis_sum / (sipar_.METRX_KMM_PH_INCREASE_FROM_UREA() * wc_.surface_water), PH_MAX-PH_SURFACE_WATER);
1226 }
1227
1228 for ( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
1229 {
1230 if ( cbm::flt_greater_zero( sc_.urea_sl[sl]))
1231 {
1232 double const fact_t( MeTrX_get_fact_t_decomp( sl));
1233 double const urease_inhibition( inh_.urease_inhibition( sc_.ui_sl[sl], sc_.h_sl[sl]));
1234 double const k_mm( sipar_.METRX_KMM_UREA_HYDROLYSIS() * sc_.h_sl[sl]);
1235 double const fact_urea( sc_.urea_sl[sl] / (sc_.urea_sl[sl] + k_mm));
1236 double const fact_ui( cbm::bound( 0.0, 1.0 - urease_inhibition, 1.0));
1237 double const urea_hydrolysis( cbm::bound_max( sipar_.METRX_KR_UREA_HYDROLYSIS() * fact_urea * fact_t * fact_ui * sc_.urea_sl[sl] * FTS_TOT_, 0.99 * sc_.urea_sl[sl]));
1238
1239 sc_.urea_sl[sl] -= urea_hydrolysis;
1240 nh4_ae_sl[sl] += urea_hydrolysis * (1.0 - sc_.anvf_sl[sl]);
1241 nh4_an_sl[sl] += urea_hydrolysis * sc_.anvf_sl[sl];
1242 accumulated_n_urea_nh4_hydrolysis_sl[sl] += urea_hydrolysis;
1243 ph_delta_urea_sl[sl] = cbm::bound( 0.0, urea_hydrolysis / (sipar_.METRX_KMM_PH_INCREASE_FROM_UREA() * sc_.h_sl[sl]), PH_MAX-sc_.phi_sl[sl]);
1244 }
1245 else
1246 {
1247 sc_.urea_sl[sl] = 0.0;
1248 ph_delta_urea_sl[sl] = 0.0;
1249 }
1250 }
1251}

Referenced by MeTrX_fermentation(), and solve().

Here is the caller graph for this function:

◆ MeTrX_write_output()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_write_output ( )
private
Parameters
[in]None
[out]None
Returns
error code
23{
24 if ( iso_ && lclock()->is_position( TMODE_POST_DAILY))
25 {
26 if ( output_data_ && output_writer_.active() && output_writer_.write_isotopes())
27 {
28 lerr_t rc_out = MeTrX_write_output_isotopes();
29 if ( rc_out){ return LDNDC_ERR_FAIL; }
30 }
31 if ( output_data_ && output_writer_.active() && output_writer_.write_isotope_sources())
32 {
33 lerr_t rc_out = MeTrX_write_output_isotope_sources();
34 if ( rc_out){ return LDNDC_ERR_FAIL; }
35 }
36 MeTrX_isotopes_end_of_day();
37 }
38
39 if ( p_ && lclock()->is_position( TMODE_POST_DAILY))
40 {
41 if ( output_data_ && output_writer_.active() && output_writer_.write_phosphorus())
42 {
43 lerr_t rc_out = MeTrX_write_output_phosphorus();
44 if ( rc_out){ return LDNDC_ERR_FAIL; }
45 }
46 MeTrX_phosphorus_end_of_day();
47 }
48
49 if ( !output_data_ || !this->output_writer_.active())
50 {
51 return LDNDC_ERR_OK;
52 }
53
54 if ( output_writer_.write_subdaily())
55 {
56 lerr_t rc_out = MeTrX_write_output_subdaily();
57 if ( rc_out){ return LDNDC_ERR_FAIL; }
58 }
59
60 if ( output_writer_.write_fluxes())
61 {
62 lerr_t rc_out = MeTrX_write_output_fluxes();
63 if ( rc_out){ return LDNDC_ERR_FAIL; }
64 }
65
66 if ( lclock()->is_position( TMODE_POST_DAILY))
67 {
68 if ( output_writer_.write_pools())
69 {
70 lerr_t rc_out = MeTrX_write_output_pools();
71 if ( rc_out){ return LDNDC_ERR_FAIL; }
72 }
73
74 if ( output_writer_.write_daily())
75 {
76 lerr_t rc_out = MeTrX_write_output_daily();
77 if ( rc_out){ return LDNDC_ERR_FAIL; }
78 }
79
80 if ( output_writer_.write_layer_daily())
81 {
82 lerr_t rc_out = MeTrX_write_output_layer_daily();
83 if ( rc_out){ return LDNDC_ERR_FAIL; }
84 }
85 }
86
87 if ( lclock()->is_position( TMODE_POST_YEARLY))
88 {
89 if ( output_writer_.write_yearly())
90 {
91 lerr_t rc_out = MeTrX_write_output_yearly();
92 if ( rc_out){ return LDNDC_ERR_FAIL; }
93 }
94
95 if ( output_writer_.write_layer_yearly())
96 {
97 lerr_t rc_out = MeTrX_write_output_layer_yearly();
98 if ( rc_out){ return LDNDC_ERR_FAIL; }
99 }
100
101 if ( iso_ && output_writer_.write_isotope_sources_yearly())
102 {
103 lerr_t rc_out = MeTrX_write_output_isotope_sources_yearly();
104 if ( rc_out){ return LDNDC_ERR_FAIL; }
105 }
106 }
107
108 return LDNDC_ERR_OK;
109}
lerr_t MeTrX_write_output_fluxes()
Definition soilchemistry-metrx-output.cpp:766
lerr_t MeTrX_write_output_layer_yearly()
Definition soilchemistry-metrx-output.cpp:670
lerr_t MeTrX_write_output_yearly()
Definition soilchemistry-metrx-output.cpp:445
lerr_t MeTrX_write_output_layer_daily()
Definition soilchemistry-metrx-output.cpp:489
lerr_t MeTrX_write_output_daily()
Definition soilchemistry-metrx-output.cpp:113
lerr_t MeTrX_write_output_subdaily()
Definition soilchemistry-metrx-output.cpp:1012
lerr_t MeTrX_write_output_pools()
Definition soilchemistry-metrx-output.cpp:697

References MeTrX_write_output_daily(), MeTrX_write_output_fluxes(), MeTrX_write_output_layer_daily(), MeTrX_write_output_layer_yearly(), MeTrX_write_output_pools(), MeTrX_write_output_subdaily(), and MeTrX_write_output_yearly().

Referenced by solve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_write_output_daily()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_write_output_daily ( )
private
Parameters
[in]None
[out]None
Returns
error code
114{
115#define METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT(__val__) LDNDC_OUTPUT_SET_COLUMN_((__val__),=,output_data_,1)
116 LDNDC_OUTPUT_SET_COLUMN_INDEX(0);
117
118 double const c_stub( sc_.c_stubble_lit1 + sc_.c_stubble_lit2 + sc_.c_stubble_lit3);
119 double const n_stub( sc_.n_stubble_lit1 + sc_.n_stubble_lit2 + sc_.n_stubble_lit3);
120
121 double const c_litter_above( sc_.c_raw_lit_1_above + sc_.c_raw_lit_2_above + sc_.c_raw_lit_3_above);
122 double const n_litter_above( sc_.n_raw_lit_1_above + sc_.n_raw_lit_2_above + sc_.n_raw_lit_3_above);
123
124 double const c_litter_soil_1( sc_.C_lit1_sl.sum() + sc_.c_raw_lit_1_sl.sum());
125 double const c_litter_soil_2( sc_.C_lit2_sl.sum() + sc_.c_raw_lit_2_sl.sum());
126 double const c_litter_soil_3( sc_.C_lit3_sl.sum() + sc_.c_raw_lit_3_sl.sum());
127 double const n_litter_soil_1( sc_.N_lit1_sl.sum() + sc_.n_raw_lit_1_sl.sum());
128 double const n_litter_soil_2( sc_.N_lit2_sl.sum() + sc_.n_raw_lit_2_sl.sum());
129 double const n_litter_soil_3( sc_.N_lit3_sl.sum() + sc_.n_raw_lit_3_sl.sum());
130
131 double const c_mic_1( sc_.C_micro1_sl.sum());
132 double const c_mic_2( sc_.C_micro2_sl.sum());
133 double const c_mic_3( sc_.C_micro3_sl.sum());
134 double const n_mic_1( n_micro_1_sl.sum());
135 double const n_mic_2( n_micro_2_sl.sum());
136 double const n_mic_3( n_micro_3_sl.sum());
137
138 double const c_hum_1( c_humus_1_sl.sum());
139 double const c_hum_2( c_humus_2_sl.sum());
140 double const c_hum_3( c_humus_3_sl.sum());
141 double const n_hum_1( n_humus_1_sl.sum());
142 double const n_hum_2( n_humus_2_sl.sum());
143 double const n_hum_3( n_humus_3_sl.sum());
144 double const c_aged( c_aged_sl.sum());
145 double const n_aged( n_aged_sl.sum());
146 double const c_biochar( c_biochar_sl.sum());
147 double const n_biochar( n_biochar_sl.sum());
148
149 double const c_aorg( sc_.C_aorg_sl.sum());
150 double const n_aorg( sc_.N_aorg_sl.sum());
151
152 double const c_wood( sc_.c_wood_sl.sum() + sc_.c_wood);
153 double const n_wood( sc_.n_wood_sl.sum() + sc_.n_wood);
154
155 double const n_algae_tot( n_algae + n_dead_algae);
156 double const don_sum( don_ae_sl.sum()+don_an_sl.sum()+sb_.don_sbl.sum());
157 double const nh4_sum( nh4_ae_sl.sum()+nh4_an_sl.sum()+sb_.nh4_sbl.sum());
158 double const nh4_clay_sum( sc_.clay_nh4_sl.sum());
159 double const coated_nh4_sum( sc_.coated_nh4_sl.sum());
160 double const urea_sum( sc_.urea_sl.sum()+sb_.urea_sbl.sum());
161 double const no2_sum( sc_.no2_sl.sum());
162 double const an_no2_sum( sc_.an_no2_sl.sum());
163 double const no3_sum( no3_ae_sl.sum());
164 double const an_no3_sum( no3_an_sl.sum()+sb_.no3_sbl.sum());
165 double const n2o_sum( n2o_gas_sl.sum()+n2o_liq_sl.sum());
166 double const an_n2o_sum( an_n2o_gas_sl.sum()+an_n2o_liq_sl.sum());
167 double const no_sum( no_gas_sl.sum()+no_liq_sl.sum());
168 double const an_no_sum( an_no_gas_sl.sum()+an_no_liq_sl.sum());
169 double const nh3_gas_sum( sc_.nh3_gas_sl.sum());
170 double const nh3_liq_sum( sc_.nh3_liq_sl.sum()+sb_.nh3_sbl.sum());
171
172 double const n_sbl( sb_.don_sbl.sum() + sb_.nh4_sbl.sum()
173 + sb_.urea_sbl.sum() + sb_.no3_sbl.sum() + sb_.nh3_sbl.sum());
174 double const n_sol( nh4_sum + nh4_clay_sum + don_sum
175 + nh3_gas_sum + nh3_liq_sum + urea_sum
176 + no3_sum + an_no3_sum + no2_sum + an_no2_sum
177 + n2o_sum + an_n2o_sum + no_sum + an_no_sum);
178
179 double const c_algae_tot( c_algae + c_dead_algae);
180 double const doc_sum( sc_.doc_sl.sum());
181 double const an_doc_sum( sc_.an_doc_sl.sum());
182 double const acetate_sum( ae_acetate_sl.sum() + an_acetate_sl.sum());
183 double const ch4_gas_sum( ch4_gas_sl.sum());
184 double const ch4_liq_sum( ch4_liq_sl.sum());
185
186 double const c_sol( doc_sum + an_doc_sum + acetate_sum + ch4_gas_sum + ch4_liq_sum);
187
188 double soc20( 0.0);
189 double soc40( 0.0);
190 double totn20( 0.0);
191 double totn40( 0.0);
192 double soilmass20( 0.0);
193 double soilmass40( 0.0);
194 double anvf_avg( 0.0);
195 /* anaerobic volume fraction of the uppermost 30 cm (layers weighted by their overlap with 0-30 cm) */
196 double const depth_top( 0.3);
197 double anvf_top( 0.0);
198 double depth_top_sum( 0.0);
199 double pore_connect_avg( 0.0);
200 double d_eff_avg( 0.0);
201 double wfps_avg( 0.0);
202 double air_avg( 0.0);
203 double root_conduct_avg( 0.0);
204 double o2_sum( 0.0);
205 double depth_sum( 0.0);
206
207 double nitrification_inhibition( 0.0);
208 double urease_inhibition( 0.0);
209
210 double mineral_efficiency_scale_sum( 0.0);
211 double mineral_efficiency( 0.0);
212 for( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
213 {
214 double const c_mic_sl( sc_.C_micro1_sl[sl] + sc_.C_micro2_sl[sl] + sc_.C_micro3_sl[sl]);
215 double const n_mic_sl( n_micro_1_sl[sl] + n_micro_2_sl[sl] + n_micro_3_sl[sl]);
216 mineral_efficiency += MeTrX_get_mineral_efficiency( c_mic_sl / n_mic_sl, cn_opt_mic_sl[sl]) * c_mic_sl;
217 mineral_efficiency_scale_sum += c_mic_sl;
218
219 anvf_avg += sc_.anvf_sl[sl] * sc_.h_sl[sl];
220 double const h_top( cbm::bound_min( 0.0, std::min( sc_.depth_sl[sl], depth_top) - (sc_.depth_sl[sl] - sc_.h_sl[sl])));
221 anvf_top += sc_.anvf_sl[sl] * h_top;
222 depth_top_sum += h_top;
223 pore_connect_avg += pore_connectivity_sl[sl] * sc_.h_sl[sl];
224 d_eff_avg += D_eff_air_sl[sl] * sc_.h_sl[sl];
225 wfps_avg += MeTrX_get_wfps( sl) * sc_.h_sl[sl];
226 air_avg += (v_air_sl[sl] / sc_.h_sl[sl]) * sc_.h_sl[sl];
227 root_conduct_avg += D_eff_plant_sl[sl] * sc_.h_sl[sl];
228 o2_sum += o2_gas_sl[sl] + o2_liq_sl[sl];
229 depth_sum += sc_.h_sl[sl];
230
231 if ( cbm::flt_less_equal( sc_.depth_sl[sl], 0.2))
232 {
233 soc20 += sc_.C_aorg_sl[sl] +c_humus_1_sl[sl]+c_humus_2_sl[sl]+c_humus_3_sl[sl]+c_biochar_sl[sl]
234 + sc_.C_micro1_sl[sl]+sc_.C_micro2_sl[sl]+sc_.C_micro3_sl[sl]
235 + sc_.C_lit1_sl[sl]+sc_.C_lit2_sl[sl]+sc_.C_lit3_sl[sl];
236 totn20 += sc_.N_aorg_sl[sl] +n_humus_1_sl[sl]+n_humus_2_sl[sl]+n_humus_3_sl[sl]+n_biochar_sl[sl]
237 + sc_.N_micro_sl[sl] +sc_.N_lit1_sl[sl]+sc_.N_lit2_sl[sl]+sc_.N_lit3_sl[sl];
238 soilmass20 += sc_.dens_sl[sl] * cbm::DM3_IN_M3 * sc_.h_sl[sl];
239 }
240
241 if ( cbm::flt_less_equal( sc_.depth_sl[sl], 0.4))
242 {
243 soc40 += sc_.C_aorg_sl[sl] +c_humus_1_sl[sl]+c_humus_2_sl[sl]+c_humus_3_sl[sl]+c_biochar_sl[sl]
244 + sc_.C_micro1_sl[sl]+sc_.C_micro2_sl[sl]+sc_.C_micro3_sl[sl]
245 + sc_.C_lit1_sl[sl]+sc_.C_lit2_sl[sl]+sc_.C_lit3_sl[sl];
246 totn40 += sc_.N_aorg_sl[sl] +n_humus_1_sl[sl]+n_humus_2_sl[sl]+n_humus_3_sl[sl]+n_biochar_sl[sl]
247 + sc_.N_micro_sl[sl] +sc_.N_lit1_sl[sl]+sc_.N_lit2_sl[sl]+sc_.N_lit3_sl[sl];
248 soilmass40 += sc_.dens_sl[sl] * cbm::DM3_IN_M3 * sc_.h_sl[sl];
249 }
250 }
251
252 int ui_counter( 0);
253 int ni_counter( 0);
254 for( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
255 {
256 double const ui_inhibition( inh_.urease_inhibition( sc_.ui_sl[sl], sc_.h_sl[sl]));
257 if ( cbm::flt_greater_zero( ui_inhibition))
258 {
259 ui_counter += 1;
260 urease_inhibition += ui_inhibition;
261 }
262 double const ni_inhibition( inh_.nitrification_inhibition( sc_.ni_sl[sl], sc_.h_sl[sl]));
263 if ( cbm::flt_greater_zero( ni_inhibition))
264 {
265 ni_counter += 1;
266 nitrification_inhibition += ni_inhibition;
267 }
268 }
269
270 if ( ui_counter > 0)
271 {
272 urease_inhibition /= ui_counter;
273 }
274 if ( ni_counter > 0)
275 {
276 nitrification_inhibition /= ni_counter;
277 }
278
279 double const litter_height( (sl_.soil_layers_in_litter_cnt() > 0) ? sc_.depth_sl[sl_.soil_layers_in_litter_cnt()-1] : 0.0);
280 anvf_avg /= depth_sum;
281 anvf_top = cbm::flt_greater_zero( depth_top_sum) ? anvf_top / depth_top_sum : anvf_avg;
282 pore_connect_avg /= depth_sum;
283 d_eff_avg /= depth_sum;
284 wfps_avg /= depth_sum;
285 air_avg /= depth_sum;
286 root_conduct_avg /= depth_sum;
287
288 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( anvf_avg);
289 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( anvf_top);
290 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( pore_connect_avg);
291 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( d_eff_avg);
292 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( wfps_avg * 100.0); // [%]
293 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( air_avg * 100.0); // [%]
294 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( root_conduct_avg);
295 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( o2_sum * cbm::M2_IN_HA);
296 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( crnf_.get_crnf_teff_mean());
297 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( crnf_.get_crnf_release_fraction_mean());
298 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( nitrification_inhibition);
299 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( urease_inhibition);
300 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( mineral_efficiency / mineral_efficiency_scale_sum);
301 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( don_sum * cbm::M2_IN_HA);
302 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( nh4_sum * cbm::M2_IN_HA);
303 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( nh4_clay_sum * cbm::M2_IN_HA);
304 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( coated_nh4_sum * cbm::M2_IN_HA);
305 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( urea_sum * cbm::M2_IN_HA);
306 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( no2_sum * cbm::M2_IN_HA);
307 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( an_no2_sum * cbm::M2_IN_HA);
308 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( no3_sum * cbm::M2_IN_HA);
309 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( an_no3_sum * cbm::M2_IN_HA);
310 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( n2o_sum * cbm::M2_IN_HA);
311 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( an_n2o_sum * cbm::M2_IN_HA);
312 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( no_sum * cbm::M2_IN_HA);
313 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( an_no_sum * cbm::M2_IN_HA);
314 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( nh3_gas_sum * cbm::M2_IN_HA);
315 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( nh3_liq_sum * cbm::M2_IN_HA);
316 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( doc_sum * cbm::M2_IN_HA);
317 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( an_doc_sum * cbm::M2_IN_HA);
318 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( acetate_sum * cbm::M2_IN_HA);
319 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( ch4_gas_sum * cbm::M2_IN_HA);
320 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( ch4_liq_sum * cbm::M2_IN_HA);
321 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( c_aorg * cbm::M2_IN_HA);
322 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( n_aorg * cbm::M2_IN_HA);
323 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( c_mic_1 * cbm::M2_IN_HA);
324 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( c_mic_2 * cbm::M2_IN_HA);
325 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( c_mic_3 * cbm::M2_IN_HA);
326 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( n_mic_1 * cbm::M2_IN_HA);
327 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( n_mic_2 * cbm::M2_IN_HA);
328 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( n_mic_3 * cbm::M2_IN_HA);
329 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( c_hum_1 * cbm::M2_IN_HA);
330 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( c_hum_2 * cbm::M2_IN_HA);
331 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( c_hum_3 * cbm::M2_IN_HA);
332 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( n_hum_1 * cbm::M2_IN_HA);
333 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( n_hum_2 * cbm::M2_IN_HA);
334 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( n_hum_3 * cbm::M2_IN_HA);
335 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( c_aged * cbm::M2_IN_HA);
336 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( n_aged * cbm::M2_IN_HA);
337 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( c_biochar * cbm::M2_IN_HA);
338 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( n_biochar * cbm::M2_IN_HA);
339 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( c_litter_soil_1 * cbm::M2_IN_HA);
340 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( c_litter_soil_2 * cbm::M2_IN_HA);
341 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( c_litter_soil_3 * cbm::M2_IN_HA);
342 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( n_litter_soil_1 * cbm::M2_IN_HA);
343 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( n_litter_soil_2 * cbm::M2_IN_HA);
344 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( n_litter_soil_3 * cbm::M2_IN_HA);
345 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( c_algae_tot * cbm::M2_IN_HA);
346 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( n_algae_tot * cbm::M2_IN_HA);
347 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( c_stub * cbm::M2_IN_HA);
348 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( n_stub * cbm::M2_IN_HA);
349 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( c_litter_above * cbm::M2_IN_HA);
350 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( n_litter_above * cbm::M2_IN_HA);
351 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( (c_wood + c_aorg + c_mic_1 + c_mic_2 + c_mic_3 +
352 c_hum_1 + c_hum_2 + c_hum_3 + c_aged + c_biochar + c_litter_soil_1 + c_litter_soil_2 + c_litter_soil_3 +
353 c_algae + c_stub + c_sol) * cbm::M2_IN_HA);
354 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( (n_wood + n_aorg + n_mic_1 + n_mic_2 + n_mic_3 +
355 n_hum_1 + n_hum_2 + n_hum_3 + n_aged + n_biochar + n_litter_soil_1 + n_litter_soil_2 + n_litter_soil_3 +
356 n_algae + n_stub + n_sol) * cbm::M2_IN_HA);
357
358 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( n_sbl * cbm::M2_IN_HA);
359
360 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( soc20 / soilmass20);
361 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( soc40 / soilmass40);
362 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( totn20 / soilmass20);
363 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( totn40 / soilmass40);
364 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sc_.fe2_sl.sum() * cbm::M2_IN_HA);
365 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sc_.fe3_sl.sum() * cbm::M2_IN_HA);
366 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sc_.till_effect_sl.sum() / sl_.soil_layer_cnt());
367 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( freeze_thaw_fact_sl.sum());
368 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( litter_height);
369 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( MeTrX_get_ph_wl());
370 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sc_.ph_sl[0]);
371 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_no3_groundwater_access * cbm::M2_IN_HA);
372 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( (day_assi_n_mic_1+day_assi_n_mic_2+day_assi_n_mic_3) * cbm::M2_IN_HA);
373 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_nit_nh4_no2 * cbm::M2_IN_HA);
374 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_nit_no2_no3_sl.sum() * cbm::M2_IN_HA);
375 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_nit_no2_no * cbm::M2_IN_HA);
376 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_nit_no2_n2o * cbm::M2_IN_HA);
377 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_denit_no3_no2 * cbm::M2_IN_HA);
378 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_denit_no2_no * cbm::M2_IN_HA);
379 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_denit_no2_n2o * cbm::M2_IN_HA);
380 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_denit_no2_n2 * cbm::M2_IN_HA);
381 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_denit_no_n2o * cbm::M2_IN_HA);
382 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_denit_no_n2 * cbm::M2_IN_HA);
383 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_denit_n2o_n2 * cbm::M2_IN_HA);
384 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_chemodenit_no2_no * cbm::M2_IN_HA);
385 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_ch4_oxidation_sl.sum() * cbm::M2_IN_HA);
386 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_ch4_oxidation_la * cbm::M2_IN_HA);
387 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_ch4_oxidation_ha * cbm::M2_IN_HA);
388 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_ch4_production_hydrogen_sl.sum() * cbm::M2_IN_HA);
389 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_ch4_production_acetate_sl.sum() * cbm::M2_IN_HA);
390 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_ch4_plant.sum() * cbm::M2_IN_HA);
391 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_ch4_soil.sum() * cbm::M2_IN_HA);
392 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_ch4_water.sum() * cbm::M2_IN_HA);
393 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_ch4_bubbling.sum() * cbm::M2_IN_HA);
394 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_ch4_leach.sum() * cbm::M2_IN_HA);
395 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_o2_plant.sum() * cbm::M2_IN_HA);
396
397 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( (sc_.accumulated_c_litter_stubble + sc_.accumulated_c_litter_wood_above - accumulated_c_litter_above_old) * cbm::M2_IN_HA);
398 accumulated_c_litter_above_old = sc_.accumulated_c_litter_stubble + sc_.accumulated_c_litter_wood_above;
399
400 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( (sc_.accumulated_c_litter_below_sl.sum() + sc_.accumulated_c_litter_wood_below_sl.sum() - accumulated_c_litter_below_old) * cbm::M2_IN_HA);
401 accumulated_c_litter_below_old = sc_.accumulated_c_litter_below_sl.sum() + sc_.accumulated_c_litter_wood_below_sl.sum();
402
403 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_c_fix_algae * cbm::M2_IN_HA);
404 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_n_fix_algae * cbm::M2_IN_HA);
405 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( (day_decomp_c_lit_1+day_decomp_c_lit_2+day_decomp_c_lit_3) * cbm::M2_IN_HA);
406 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_decay_c_mic_sl.sum()*cbm::M2_IN_HA);
407 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_co2_prod_mic_1_growth * cbm::M2_IN_HA);
408 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_co2_prod_mic_1_maintenance * cbm::M2_IN_HA);
409 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_co2_prod_mic_2 * cbm::M2_IN_HA);
410 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_co2_prod_mic_3_acetate_prod * cbm::M2_IN_HA);
411 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_co2_prod_mic_3_acetate_cons * cbm::M2_IN_HA);
412 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_co2_prod_ch4_prod * cbm::M2_IN_HA);
413 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_co2_prod_ch4_cons * cbm::M2_IN_HA);
414 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_h2_c_eq_prod_sl.sum() * cbm::M2_IN_HA);
415 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_acetate_prod_sl.sum() * cbm::M2_IN_HA);
416 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_acetate_cons_fe3_sl.sum() * cbm::M2_IN_HA/FE3_ACETATE_REDUCTION_RATIO);
417 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_h2_c_eq_cons_fe3_sl.sum() * cbm::M2_IN_HA/FE3_ACETATE_REDUCTION_RATIO);
418 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_doc_prod_decomp_litter * cbm::M2_IN_HA);
419 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_doc_prod_decomp_humus * cbm::M2_IN_HA);
420 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_doc_prod_decomp_aorg * cbm::M2_IN_HA);
421 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( dC_root_exsudates * cbm::M2_IN_HA);
422 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_c_humify_doc_hum_2_sl.sum() * cbm::M2_IN_HA);
423 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_c_humify_sol_hum_1_sl.sum() * cbm::M2_IN_HA);
424 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_c_humify_cel_hum_1_sl.sum() * cbm::M2_IN_HA);
425 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_c_humify_lig_hum_1_sl.sum() * cbm::M2_IN_HA);
426 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_c_humify_lig_hum_2_sl.sum() * cbm::M2_IN_HA);
427 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_c_humify_mic_hum_1_sl.sum() * cbm::M2_IN_HA);
428 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_c_humify_mic_hum_2_sl.sum() * cbm::M2_IN_HA);
429 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_c_humify_hum_1_hum_2_sl.sum() * cbm::M2_IN_HA);
430 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_c_humify_hum_2_hum_3_sl.sum() * cbm::M2_IN_HA);
431 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_min_n_decomp * cbm::M2_IN_HA);
432 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_min_n_aorg * cbm::M2_IN_HA);
433 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_min_n_mic_1 * cbm::M2_IN_HA);
434 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_min_n_mic_2 * cbm::M2_IN_HA);
435 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_min_n_mic_3 * cbm::M2_IN_HA);
436 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_assi_c_mic_1 * cbm::M2_IN_HA);
437 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_assi_c_mic_2 * cbm::M2_IN_HA);
438 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_assi_c_mic_3 * cbm::M2_IN_HA);
439
440 return output_writer_.write_daily( output_data_);
441}

References MeTrX_get_ph_wl().

Referenced by MeTrX_write_output().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_write_output_fluxes()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_write_output_fluxes ( )
private
Parameters
[in]None
[out]None
Returns
error code
767{
768#define METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH(__val__) \
769{ \
770double const delta_val( __val__ - output_writer_.output_writer_fluxes.__val__); \
771LDNDC_OUTPUT_SET_COLUMN_((delta_val),=,output_data_,1); \
772output_writer_.output_writer_fluxes.__val__ = __val__; \
773} \
774
775#define METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH_2(__val1__,__val2__) \
776{ \
777double const delta_val( __val1__ - output_writer_.output_writer_fluxes.__val2__); \
778LDNDC_OUTPUT_SET_COLUMN_((delta_val),=,output_data_,1); \
779output_writer_.output_writer_fluxes.__val2__ = __val1__; \
780} \
781
782 for ( size_t l = 0; l < sl_.soil_layer_cnt(); ++l)
783 {
784 LDNDC_OUTPUT_SET_COLUMN_INDEX(0);
785 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( -sc_.depth_sl[l]);
786
787 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh4_throughfall_sl[l]);
788 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no3_throughfall_sl[l]);
789 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh4_throughfall_sbl[l]);
790 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no3_throughfall_sbl[l]);
791
792 //N fluxes in plant/algae
793 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_to_living_plant_and_algae_from_extern_sl[l]);
794 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH_2( ph_.accumulated_nh4_uptake_sl[l], accumulated_n_plant_nh4_uptake_sl[l]);
795 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH_2( ph_.accumulated_no3_uptake_sl[l], accumulated_n_plant_no3_uptake_sl[l]);
796 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH_2( ph_.accumulated_nh3_uptake_sl[l], accumulated_n_plant_nh3_uptake_sl[l]);
797 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH_2( ph_.accumulated_don_uptake_sl[l], accumulated_n_plant_don_uptake_sl[l]);
798 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_algae_nh4_uptake_sbl[l]);
799 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_algae_no3_uptake_sbl[l]);
800 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_algae_nh3_uptake_sbl[l]);
801
802 //N fluxes from plant to raw litter, stubble and wood
803 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_litter_from_plants_below_rawlitter_sl[l]);
804 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_litter_from_plants_below_wood_sl[l]);
805 if ( l == 0)
806 {
807 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_litter_from_plants_above_rawlitter);
808 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_litter_from_plants_above_wood);
809 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_litter_from_plants_above_stubble);
810 }
811 else
812 {
813 LDNDC_OUTPUT_SET_COLUMN_(0.0,=,output_data_,1);
814 LDNDC_OUTPUT_SET_COLUMN_(0.0,=,output_data_,1);
815 LDNDC_OUTPUT_SET_COLUMN_(0.0,=,output_data_,1);
816 }
817
818 //N fluxes from raw litter to soil litter
819 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_aboveground_raw_litter_fragmentation_sl[l]);
820 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_belowground_raw_litter_fragmentation_sl[l]);
821
822 //N fluxes from grazer and algae
823 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_litter_from_algae_sl[l]);
824 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_litter_from_dung_sl[l]);
825 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_urea_from_dung_sl[l]);
826
827 //N exported via harvesting, cutting and grazing
828 if ( l == 0)
829 {
830 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_export_harvest_cutting_grazing);
831 }
832 else
833 {
834 LDNDC_OUTPUT_SET_COLUMN_(0.0,=,output_data_,1);
835 }
836
837 //N fluxes from fertilization and manuring
838 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH_2( accumulated_n_nh4_fertilization_sl[l] + accumulated_n_nh4_manure_sl[l], accumulated_n_nh4_fertilization_sl[l]);
839 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH_2( accumulated_n_no3_fertilization_sl[l] + accumulated_n_no3_manure_sl[l], accumulated_n_no3_fertilization_sl[l]);
840 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh3_fertilization_sl[l]);
841 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH_2( accumulated_n_don_fertilization_sl[l] + accumulated_n_don_manure_sl[l], accumulated_n_don_fertilization_sl[l]);
842 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH_2( accumulated_n_urea_fertilization_sl[l] + accumulated_n_urea_manure_sl[l], accumulated_n_urea_fertilization_sl[l]);
843 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH_2( accumulated_n_litter_fertilization_sl[l] + accumulated_n_litter_manure_sl[l], accumulated_n_litter_fertilization_sl[l]);
844 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH_2( accumulated_n_aorg_fertilization_sl[l] + accumulated_n_aorg_manure_sl[l], accumulated_n_aorg_fertilization_sl[l]);
845 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh4_fertilization_sbl[l]);
846 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no3_fertilization_sbl[l]);
847 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh3_fertilization_sbl[l]);
848 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_urea_fertilization_sbl[l]);
849
850 //N redistribution during tilling
851 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_surface_litter_incorporation_via_tilling_sl[l]);
852 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_litter_tilling_sl[l]);
853 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_aorg_tilling_sl[l]);
854 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_humus_1_tilling_sl[l]);
855 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_humus_2_tilling_sl[l]);
856 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_humus_3_tilling_sl[l]);
857 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no3_tilling_sl[l]);
858 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no2_tilling_sl[l]);
859 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no_tilling_sl[l]);
860 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_n2o_tilling_sl[l]);
861 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_urea_tilling_sl[l]);
862 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_don_tilling_sl[l]);
863 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh4_tilling_sl[l]);
864 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh3_tilling_sl[l]);
865 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_microbes_tilling_sl[l]);
866
867 //N redistribution during spin up
868 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_humus_1_spinup_sl[l]);
869 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_humus_2_spinup_sl[l]);
870 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_humus_3_spinup_sl[l]);
871 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_surface_litter_spinup_sl[l]);
872 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_litter_spinup_sl[l]);
873
874 //N fluxes due to water movement
875 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_micro_leaching_sl[l]);
876 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_aorg_leaching_sl[l]);
877 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_litter_leaching_sl[l]);
878 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_humus_1_leaching_sl[l]);
879 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_humus_2_leaching_sl[l]);
880 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_humus_3_leaching_sl[l]);
881 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh4_leaching_sl[l]);
882 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH_2( sc_.accumulated_n_no3_leaching_sl[l], accumulated_n_no3_leaching_sl[l]);
883 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh3_leaching_sl[l]);
884 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_don_leaching_sl[l]);
885 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_urea_leaching_sl[l]);
886 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no_leaching_sl[l]);
887 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_n2o_leaching_sl[l]);
888
889 //N fluxes via liquid diffusion
890 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_urea_liq_diffusion_sl[l]);
891 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh3_liq_diffusion_sl[l]);
892 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh4_liq_diffusion_sl[l]);
893 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no3_liq_diffusion_sl[l]);
894
895 // incoming N from leaching from surface water
896 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh4_infiltration_phys_sl[l]);
897 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh3_infiltration_phys_sl[l]);
898 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_urea_infiltration_phys_sl[l]);
899 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no3_infiltration_phys_sl[l]);
900 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_don_infiltration_phys_sl[l]);
901 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_aorg_infiltration_phys_sl[l]);
902
903 //incoming N fluxes from disappearing water table
904 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh4_infiltration_leach_sl[l]);
905 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh3_infiltration_leach_sl[l]);
906 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_urea_infiltration_leach_sl[l]);
907 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no3_infiltration_leach_sl[l]);
908 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_don_infiltration_leach_sl[l]);
909 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no_infiltration_leach_sl[l]);
910 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_n2o_infiltration_leach_sl[l]);
911
912 //incoming N flux via liquid diffusion from surface water
913 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh4_infiltration_liqdif_sl[l]);
914 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh3_infiltration_liqdif_sl[l]);
915 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_urea_infiltration_liqdif_sl[l]);
916 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no3_infiltration_liqdif_sl[l]);
917
918 //ebullition fluxes
919 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh3_bubbling_sl[l]);
920 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no_bubbling_sl[l]);
921 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_n2o_bubbling_sl[l]);
922 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh3_bubbling_sbl[l]);
923 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no_bubbling_sbl[l]);
924 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_n2o_bubbling_sbl[l]);
925
926 //N fluxes due to dissolution between atmosphere and surface water
927 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh3_dissolution_sbl[l]);
928 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no_dissolution_sbl[l]);
929 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_n2o_dissolution_sbl[l]);
930
931 //N fluxes from urea to nh4
932 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_urea_nh4_hydrolysis_sl[l]);
933 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_urea_nh4_hydrolysis_sbl[l]);
934
935 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh4_assimilation_sl[l]);
936 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no3_assimilation_sl[l]);
937 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_don_assimilation_sl[l]);
938
939 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh4_nh3_conversion_sl[l]);
940 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh3_nh4_conversion_sl[l]);
941 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh4_nh3_conversion_sbl[l]);
942 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh3_nh4_conversion_sbl[l]);
943
944 //gaseous diffusion
945 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh3_phys_diffusion_sl[l]);
946 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no_phys_diffusion_sl[l]);
947 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_n2o_phys_diffusion_sl[l]);
948 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh3_gas_diffusion_sl[l]);
949 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no_gas_diffusion_sl[l]);
950 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_n2o_gas_diffusion_sl[l]);
951
952 //perturbation
953 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_micro_perturbation_sl[l]);
954 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_aorg_perturbation_sl[l]);
955 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_litter_perturbation_sl[l]);
956 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_humus_1_perturbation_sl[l]);
957 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_humus_2_perturbation_sl[l]);
958 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_humus_3_perturbation_sl[l]);
959
960 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh4_no2_nitrification_sl[l]);
961 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh4_no_nitrification_sl[l]);
962 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_nh4_n2o_nitrification_sl[l]);
963 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no2_no3_nitrification_sl[l]);
964
965 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no3_no2_denitrification_sl[l]);
966 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no3_no_denitrification_sl[l]);
967 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no3_n2o_denitrification_sl[l]);
968 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no3_n2_denitrification_sl[l]);
969 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no2_no_denitrification_sl[l]);
970 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no2_n2o_denitrification_sl[l]);
971 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no2_n2_denitrification_sl[l]);
972 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no_n2o_denitrification_sl[l]);
973 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no_n2_denitrification_sl[l]);
974 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_n2o_n2_denitrification_sl[l]);
975
976 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_no2_chemodenitrification_sl[l]);
977
978 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_mic_naorg_decay_sl[l]);
979 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_mic_nh4_mineral_sl[l]);
980 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_mic_don_dissolve_sl[l]);
981
982 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_aorg_nh4_mineral_sl[l]);
983 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_aorg_don_dissolve_sl[l]);
984
985 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_humus_1_don_dissolve_sl[l]);
986 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_humus_1_nh4_mineral_sl[l]);
987 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_humus_2_don_dissolve_sl[l]);
988 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_humus_2_nh4_mineral_sl[l]);
989 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_humus_3_don_dissolve_sl[l]);
990 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_humus_3_nh4_mineral_sl[l]);
991
992 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_litter_don_dissolve_sl[l]);
993 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_litter_nh4_mineral_sl[l]);
994
995 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_don_humus_1_humify_sl[l]);
996 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_don_humus_2_humify_sl[l]);
997 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_don_humus_3_humify_sl[l]);
998 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT_AND_SWITCH( accumulated_n_litter_humus_1_humify_sl[l]);
999
1000 lerr_t rc_write = output_writer_.write_fluxes( l, output_data_);
1001 if ( rc_write)
1002 {
1003 return LDNDC_ERR_FAIL;
1004 }
1005 }
1006
1007 return LDNDC_ERR_OK;
1008}

Referenced by MeTrX_write_output().

Here is the caller graph for this function:

◆ MeTrX_write_output_layer_daily()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_write_output_layer_daily ( )
private
Parameters
[in]None
[out]None
Returns
error code
490{
491 size_t fl_cnt( m_veg->canopy_layers_used());
492 size_t sbl_cnt( sb_.surfacebulk_layer_cnt());
493
494 for ( size_t fl = fl_cnt; fl > 0; --fl)
495 {
496 size_t l( fl-1);
497 LDNDC_OUTPUT_SET_COLUMN_INDEX(0);
498 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //depth
499 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( ph_.h_fl[l]); //extension
500 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //pH
501 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //pore_connectivity
502 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( D_eff_air_fl[l]); //air permeability
503 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //aerenchym_permeability
504 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //cfdd
505 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //water_content
506 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //air_content
507 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //porosity
508 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //fe2
509 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //fe3
510 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( ts_co2_concentration_fl[l]*cbm::M2_IN_HA);
511 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( ts_ch4_concentration_fl[l]*cbm::M2_IN_HA);
512 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //ch4 bubbling
513 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //ch4 production
514 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //ch4 oxidation
515 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //doc production
516 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //acetate production
517 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //mic decay
518 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //doc
519 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //doc
520 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //acetate
521 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //no3
522 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //no3
523 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //nh4
524 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //urea
525 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( nh3_fl[l]*cbm::M2_IN_HA);
526 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //o2
527 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //o2 consumption
528 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( ts_no_concentration_fl[l]*cbm::M2_IN_HA);
529 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //n2o
530 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //c_humus_0
531 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //c_humus_1
532 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //c_humus_2
533 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //no3_cons_denit
534 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //denit_factor_c
535 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //denit_factor_n
536 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //no3_prod_nit
537 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //no3_leaching
538
539 lerr_t rc_write = output_writer_.write_layer_daily( -static_cast< int >( fl+sbl_cnt+1), output_data_);
540 if ( rc_write)
541 {
542 return LDNDC_ERR_FAIL;
543 }
544 }
545
546 for (size_t sbl = sbl_cnt; sbl > 0; --sbl)
547 {
548 double depth_sbl( sbl_cnt * 0.01 - 0.5 * 0.01 - (sbl-1) * 0.01);
549 size_t l( sbl-1);
550 LDNDC_OUTPUT_SET_COLUMN_INDEX(0);
551 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( depth_sbl); //depth
552 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //extension
553 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( MeTrX_get_ph_wl()); //pH
554 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //pore_connectivity
555 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //air permeability
556 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //aerenchym_permeability
557 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //cfdd
558 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //water_content
559 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //air_content
560 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //porosity
561 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //fe2
562 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //fe3
563 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sb_.co2_sbl[l]*cbm::M2_IN_HA);
564 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sb_.ch4_sbl[l]*cbm::M2_IN_HA);
565
566 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( (accumulated_c_ch4_bubbling_sbl[l]-
567 output_writer_.output_writer_layer_daily.accumulated_c_ch4_bubbling_sbl[l])*cbm::M2_IN_HA);
568 output_writer_.output_writer_layer_daily.accumulated_c_ch4_bubbling_sbl[l] = accumulated_c_ch4_bubbling_sbl[l];
569
570 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //ch4 production
571 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //ch4 oxidation
572 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //doc production
573 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //acetate production
574 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //mic decay
575 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //doc
576 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sb_.doc_sbl[l]*cbm::M2_IN_HA);
577 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //acetate
578 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //no3 ae
579 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sb_.no3_sbl[l]*cbm::M2_IN_HA);
580 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sb_.nh4_sbl[l]*cbm::M2_IN_HA);
581 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sb_.urea_sbl[l]*cbm::M2_IN_HA);
582 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sb_.nh3_sbl[l]*cbm::M2_IN_HA);
583 // O2 partial pressure in equilibrium with dissolved O2 of the surface water [bar] (as in MeTrX_ebullition)
584 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sb_.o2_sbl[l] / (M_2O_SCALE * get_henry_coefficient( *mc_temp_atm, henry_o2) * h_wl) * cbm::PA_IN_BAR);
585 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //o2 consumption
586 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //no
587 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //n2o
588 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //c_humus_0
589 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //c_humus_1
590 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //c_humus_2
591 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //no3_cons_denit
592 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //denit_factor_c
593 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //denit_factor_n
594 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //no3_prod_nit
595 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0.0); //no3_leaching
596
597 lerr_t rc_write = output_writer_.write_layer_daily( -static_cast< int >( sbl), output_data_);
598 if ( rc_write)
599 {
600 return LDNDC_ERR_FAIL;
601 }
602 }
603
604 for ( size_t l = 0; l < sl_.soil_layer_cnt(); ++l)
605 {
606 LDNDC_OUTPUT_SET_COLUMN_INDEX(0);
607 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( -sc_.depth_sl[l]);
608 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sc_.h_sl[l]);
609 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sc_.ph_sl[l]);
610 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( pore_connectivity_sl[l]);
611 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( D_eff_air_sl[l]);
612 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( D_eff_plant_sl[l]);
613 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( cumulative_freezing_degree_days_sl[l]);
614 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( wc_.wc_sl[l] * 100.0); // [%]
615 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( v_air_sl[l] / sc_.h_sl[l] * 100.0); // [%]
616 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sc_.poro_sl[l] * 100.0); // [%]
617 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sc_.fe2_sl[l]*cbm::M2_IN_HA);
618 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sc_.fe3_sl[l]*cbm::M2_IN_HA);
619 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( (co2_liq_sl[l]+co2_gas_sl[l])*cbm::M2_IN_HA);
620 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( (ch4_liq_sl[l]+ch4_gas_sl[l])*cbm::M2_IN_HA);
621 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( (accumulated_c_ch4_bubbling_sl[l]-
622 output_writer_.output_writer_layer_daily.accumulated_c_ch4_bubbling_sl[l])*cbm::M2_IN_HA);
623 output_writer_.output_writer_layer_daily.accumulated_c_ch4_bubbling_sl[l] = accumulated_c_ch4_bubbling_sl[l];
624 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( (day_ch4_production_acetate_sl[l]+day_ch4_production_hydrogen_sl[l])*cbm::M2_IN_HA);
625 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_ch4_oxidation_sl[l]*cbm::M2_IN_HA);
626 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_doc_prod_sl[l]*cbm::M2_IN_HA);
627 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_acetate_prod_sl[l]*cbm::M2_IN_HA);
628 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_decay_c_mic_sl[l]*cbm::M2_IN_HA);
629 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( (sc_.doc_sl[l])*cbm::M2_IN_HA);
630 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( (sc_.an_doc_sl[l])*cbm::M2_IN_HA);
631 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( (ae_acetate_sl[l]+an_acetate_sl[l])*cbm::M2_IN_HA);
632 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( (no3_ae_sl[l])*cbm::M2_IN_HA);
633 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( (no3_an_sl[l])*cbm::M2_IN_HA);
634 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( (nh4_ae_sl[l]+nh4_an_sl[l]+sc_.clay_nh4_sl[l])*cbm::M2_IN_HA);
635 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sc_.urea_sl[l]*cbm::M2_IN_HA);
636 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( (sc_.nh3_gas_sl[l]+sc_.nh3_liq_sl[l])*cbm::M2_IN_HA);
637 // O2 partial pressure of the soil air [bar] (as in MeTrX_anaerobic_volume)
638 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( o2_gas_sl[l] * RGAS_M_O2_BAR_PA * (mc_temp_sl[l] + cbm::D_IN_K) / v_air_sl[l]);
639 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( o2_consumption_sl[l]*cbm::M2_IN_HA);
640 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( (no_liq_sl[l]+no_gas_sl[l]+an_no_liq_sl[l]+an_no_gas_sl[l])*cbm::M2_IN_HA);
641 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( (n2o_liq_sl[l]+n2o_gas_sl[l]+an_n2o_liq_sl[l]+an_n2o_gas_sl[l])*cbm::M2_IN_HA);
642 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( c_humus_1_sl[l]*cbm::M2_IN_HA);
643 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( c_humus_2_sl[l]*cbm::M2_IN_HA);
644 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( c_humus_3_sl[l]*cbm::M2_IN_HA);
645 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( (accumulated_n_no3_no2_denitrification_sl[l]
646 -output_writer_.output_writer_layer_daily.accumulated_n_no3_no2_denitrification_sl[l]) * cbm::M2_IN_HA);
647 output_writer_.output_writer_layer_daily.accumulated_n_no3_no2_denitrification_sl[l] = accumulated_n_no3_no2_denitrification_sl[l];
648 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_denit_factor_c_sl[l]*FTS_TOT_);
649 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_denit_factor_n_sl[l]*FTS_TOT_);
650 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( day_nit_no2_no3_sl[l]*cbm::M2_IN_HA);
651 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( (sc_.accumulated_n_no3_leaching_sl[l]
652 -output_writer_.output_writer_layer_daily.accumulated_n_no3_leaching_sl[l]) * cbm::M2_IN_HA);
653 output_writer_.output_writer_layer_daily.accumulated_n_no3_leaching_sl[l] = sc_.accumulated_n_no3_leaching_sl[l];
654 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sc_.C_micro3_sl[l]*cbm::M2_IN_HA);
655 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( c_aged_sl[l]*cbm::M2_IN_HA);
656 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( c_biochar_sl[l]*cbm::M2_IN_HA);
657
658 lerr_t rc_write = output_writer_.write_layer_daily( l, output_data_);
659 if ( rc_write)
660 {
661 return LDNDC_ERR_FAIL;
662 }
663 }
664
665 return LDNDC_ERR_OK;
666}

References MeTrX_get_ph_wl().

Referenced by MeTrX_write_output().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_write_output_layer_yearly()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_write_output_layer_yearly ( )
private
Parameters
[in]None
[out]None
Returns
error code
671{
672 for ( size_t l = 0; l < sl_.soil_layer_cnt(); ++l)
673 {
674 LDNDC_OUTPUT_SET_COLUMN_INDEX(0);
675 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( -sc_.depth_sl[l]);
676 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( c_humus_1_sl[l]);
677 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( c_humus_2_sl[l]);
678 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( c_humus_3_sl[l]);
679 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sc_.C_aorg_sl[l]);
680 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sc_.C_micro1_sl[l]+sc_.C_micro2_sl[l]+sc_.C_micro3_sl[l]);
681
682 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( accumulated_n_no3_no2_denitrification_sl[l] - output_writer_.output_writer_layer_yearly.accumulated_n_no3_no2_denitrification_sl[l]);
683 output_writer_.output_writer_layer_yearly.accumulated_n_no3_no2_denitrification_sl[l] = accumulated_n_no3_no2_denitrification_sl[l];
684
685 lerr_t rc_write = output_writer_.write_layer_yearly( l, output_data_);
686 if ( rc_write)
687 {
688 return LDNDC_ERR_FAIL;
689 }
690 }
691
692 return LDNDC_ERR_OK;
693}

Referenced by MeTrX_write_output().

Here is the caller graph for this function:

◆ MeTrX_write_output_pools()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_write_output_pools ( )
private
Parameters
[in]None
[out]None
Returns
error code
698{
699 for ( size_t l = 0; l < sl_.soil_layer_cnt(); ++l)
700 {
701 LDNDC_OUTPUT_SET_COLUMN_INDEX(0);
702 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( -sc_.depth_sl[l]);
703
704 //pools that exist for each soil layer
705 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sc_.urea_sl[l]);
706 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sc_.N_lit1_sl[l] + sc_.N_lit2_sl[l] + sc_.N_lit3_sl[l] + sc_.n_wood_sl[l] + sc_.n_raw_lit_1_sl[l] + sc_.n_raw_lit_2_sl[l] + sc_.n_raw_lit_3_sl[l]);
707 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sc_.N_aorg_sl[l]);
708 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( n_humus_1_sl[l]);
709 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( n_humus_2_sl[l]);
710 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( n_humus_3_sl[l]);
711 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( n_micro_1_sl[l] + n_micro_2_sl[l] + n_micro_3_sl[l]);
712 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sc_.nh3_liq_sl[l] + sc_.nh3_gas_sl[l]);
713 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( nh4_ae_sl[l] + nh4_an_sl[l] + sc_.clay_nh4_sl[l]);
714 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( don_ae_sl[l] + don_an_sl[l]);
715 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( no3_ae_sl[l] + no3_an_sl[l]);
716 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sc_.no2_sl[l] + sc_.an_no2_sl[l]);
717 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( no_gas_sl[l] + an_no_gas_sl[l] + no_liq_sl[l] + an_no_liq_sl[l]);
718 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( n2o_gas_sl[l] + an_n2o_gas_sl[l] + n2o_liq_sl[l] + an_n2o_liq_sl[l]);
719
720 //surface pools
721 if( l == 0 )
722 {
723 double nplant(0.0);
724 for ( PlantIterator vt = this->m_veg->begin(); vt != this->m_veg->end(); ++vt)
725 {
726 nplant += (*vt)->total_nitrogen();
727 }
728
729 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sb_.nh4_sbl.sum() );
730 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sb_.nh3_sbl.sum() );
731 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sb_.n2o_sbl.sum() );
732 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sb_.no_sbl.sum() );
733 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sb_.urea_sbl.sum() );
734 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sb_.no3_sbl.sum() );
735 //METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sb_.don_sbl.sum() );
736 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( nplant );
737 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sc_.n_wood + sc_.n_stubble_lit1 + sc_.n_stubble_lit2 + sc_.n_stubble_lit3 +
738 sc_.n_raw_lit_1_above + sc_.n_raw_lit_2_above + sc_.n_raw_lit_3_above);
739 }
740 else
741 {
742 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0 );
743 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0 );
744 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0 );
745 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0 );
746 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0 );
747 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0 );
748 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0 );
749 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0 );
750 //METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0 );
751 //METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( 0 );
752 }
753
754 lerr_t rc_write = output_writer_.write_pools( l, output_data_);
755 if ( rc_write)
756 {
757 return LDNDC_ERR_FAIL;
758 }
759 }
760
761 return LDNDC_ERR_OK;
762}

Referenced by MeTrX_write_output().

Here is the caller graph for this function:

◆ MeTrX_write_output_subdaily()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_write_output_subdaily ( )
private
Parameters
[in]None
[out]None
Returns
error code
1013{
1014 size_t s( lclock()->subday()-1);
1015 LDNDC_OUTPUT_SET_COLUMN_INDEX(0);
1016 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sc_.C_micro1_sl.sum());
1017 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sc_.C_micro2_sl.sum());
1018 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sc_.C_micro3_sl.sum());
1019 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sc_.C_aorg_sl.sum());
1020 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( nh4_ae_sl.sum()+nh4_an_sl.sum()+sc_.clay_nh4_sl.sum());
1021 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( no3_ae_sl.sum());
1022 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( no3_an_sl.sum());
1023 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sc_.doc_sl.sum());
1024 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sc_.an_doc_sl.sum());
1025 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( ae_acetate_sl.sum());
1026 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( an_acetate_sl.sum());
1027
1028 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_ch4_bubbling[s]);
1029 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_ch4_plant[s]);
1030 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_ch4_soil[s]);
1031 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_ch4_water[s]);
1032 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_ch4_leach[s]);
1033 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_ch4_prod[s]);
1034 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_ch4_ox[s]);
1035
1036 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_acetate_prod[s]);
1037 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_doc_prod[s]);
1038
1039 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( accumulated_n_no2_no3_nitrification_sl.sum() - output_writer_.output_writer_subdaily.accumulated_n_no2_no3_nitrification);
1040 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( accumulated_n_no3_no2_denitrification_sl.sum() - output_writer_.output_writer_subdaily.accumulated_n_no3_no2_denitrification);
1041
1042 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_n2o_bubbling[s]);
1043 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_n2o_plant[s]);
1044 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_n2o_soil[s]);
1045 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_n2o_water[s]);
1046 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_no_bubbling[s]);
1047 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_no_plant[s]);
1048 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_no_soil[s]);
1049 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_no_water[s]);
1050 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_nh3_bubbling[s]);
1051 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_nh3_plant[s]);
1052 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_nh3_soil[s]);
1053 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_nh3_water[s]);
1054
1055 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_plant_o2_cons[s]);
1056 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_o2_plant[s]);
1057 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( subdaily_algae_o2_prod[s]);
1058
1059 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( MeTrX_get_ph_wl());
1060 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( sc_.ph_sl[0]);
1061 double anvf_mean( sc_.anvf_sl.sum() / sl_.soil_layer_cnt());
1062 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( anvf_mean);
1063
1064 lerr_t rc_write = output_writer_.write_subdaily( output_data_);
1065 if ( rc_write)
1066 {
1067 return LDNDC_ERR_FAIL;
1068 }
1069
1070 output_writer_.output_writer_subdaily.accumulated_n_no2_no3_nitrification = accumulated_n_no2_no3_nitrification_sl.sum();
1071 output_writer_.output_writer_subdaily.accumulated_n_no3_no2_denitrification = accumulated_n_no3_no2_denitrification_sl.sum();
1072
1073 return LDNDC_ERR_OK;
1074}

References MeTrX_get_ph_wl().

Referenced by MeTrX_write_output().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeTrX_write_output_yearly()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_write_output_yearly ( )
private
Parameters
[in]None
[out]None
Returns
error code
446{
447 double surface_litter( c_algae + c_dead_algae + sc_.c_stubble_lit1 + sc_.c_stubble_lit2 + sc_.c_stubble_lit3);
448 double soc20( 0.0);
449 double c_hum_1_20( 0.0);
450 double c_hum_2_20( 0.0);
451 double c_hum_3_20( 0.0);
452 double c_litter_20( 0.0);
453 double c_aorg_20( 0.0);
454 for( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
455 {
456 if ( cbm::flt_less_equal( sc_.depth_sl[sl], 0.2))
457 {
458 soc20 += sc_.C_aorg_sl[sl] + c_humus_1_sl[sl] + c_humus_2_sl[sl] + c_humus_3_sl[sl] + c_biochar_sl[sl]
459 + sc_.C_micro1_sl[sl] + sc_.C_micro2_sl[sl] + sc_.C_micro3_sl[sl]
460 + sc_.C_lit1_sl[sl] + sc_.C_lit2_sl[sl] + sc_.C_lit3_sl[sl];
461 c_hum_1_20 += c_humus_1_sl[sl];
462 c_hum_2_20 += c_humus_2_sl[sl];
463 c_hum_3_20 += c_humus_3_sl[sl];
464 c_litter_20 += sc_.C_lit1_sl[sl] + sc_.C_lit2_sl[sl] + sc_.C_lit3_sl[sl];
465 c_aorg_20 += sc_.C_aorg_sl[sl];
466 }
467 else
468 {
469 break;
470 }
471 }
472
473#define METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT(__val__) LDNDC_OUTPUT_SET_COLUMN_((__val__),=,output_data_,1)
474 LDNDC_OUTPUT_SET_COLUMN_INDEX(0);
475
476 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( surface_litter);
477 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( soc20);
478 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( c_hum_1_20);
479 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( c_hum_2_20);
480 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( c_hum_3_20);
481 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( c_litter_20);
482 METRX_OUTPUT_SET_COLUMN_AND_GOTO_NEXT( c_aorg_20);
483
484 return output_writer_.write_yearly( output_data_);
485}

Referenced by MeTrX_write_output().

Here is the caller graph for this function:

◆ MeTrX_write_rates()

lerr_t ldndc::SoilChemistryMeTrX::MeTrX_write_rates ( )
private
Parameters
[in]None
[out]None
Returns
error code
25{
26 sc_.accumulated_n2_emis = 0.0;
27 for( size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
28 {
29 sc_.no_sl[sl] = no_gas_sl[sl]+no_liq_sl[sl];
30 sc_.an_no_sl[sl] = an_no_gas_sl[sl]+an_no_liq_sl[sl];
31
32 sc_.n2o_sl[sl] = n2o_gas_sl[sl]+n2o_liq_sl[sl];
33 sc_.an_n2o_sl[sl] = an_n2o_gas_sl[sl]+an_n2o_liq_sl[sl];
34
35 sc_.C_hum_sl[sl] = c_humus_1_sl[sl] + c_humus_2_sl[sl] + c_humus_3_sl[sl] + c_aged_sl[sl] + c_biochar_sl[sl];
36 sc_.N_hum_sl[sl] = n_humus_1_sl[sl] + n_humus_2_sl[sl] + n_humus_3_sl[sl] + n_aged_sl[sl] + n_biochar_sl[sl];
37
38 // acetate is soil organic carbon outside the standard pools
39 sc_.C_other_sl[sl] = ae_acetate_sl[sl] + an_acetate_sl[sl] + acetate_ice_sl[sl];
40
41 sc_.N_micro_sl[sl] = n_micro_1_sl[sl] + n_micro_2_sl[sl] + n_micro_3_sl[sl];
42 sc_.som_sl[sl] = (sc_.C_lit1_sl[sl] + sc_.C_lit2_sl[sl] + sc_.C_lit3_sl[sl]
43 + sc_.c_raw_lit_1_sl[sl] + sc_.c_raw_lit_2_sl[sl] + sc_.c_raw_lit_3_sl[sl]
44 + sc_.C_micro1_sl[sl] + sc_.C_micro2_sl[sl] + sc_.C_micro3_sl[sl]
45 + sc_.C_hum_sl[sl] + sc_.C_aorg_sl[sl])
46 / cbm::CCORG;
47
48 sc_.o2_sl[sl] = o2_gas_sl[sl] * RGAS_M_O2_BAR_PA * (mc_temp_sl[sl] + cbm::D_IN_K) / v_air_sl[sl];
49
50 sc_.accumulated_no3_denitrify_sl[sl] = accumulated_n_no3_no2_denitrification_sl[sl];
51 sc_.accumulated_n2_emis += accumulated_n_no3_n2_denitrification_sl[sl]
52 + accumulated_n_no2_n2_denitrification_sl[sl]
53 + accumulated_n_no_n2_denitrification_sl[sl]
54 + accumulated_n_n2o_n2_denitrification_sl[sl];
55 }
56
57 size_t const ts_end( (timemode_ == TMODE_SUBDAILY) ? lclock()->subday() * INTERNAL_TIME_STEPS : INTERNAL_TIME_STEPS);
58 size_t const ts_start( ts_end - INTERNAL_TIME_STEPS);
59 for ( size_t ts = ts_start; ts < ts_end; ++ts)
60 {
61 sc_.accumulated_co2_emis += subdaily_co2_soil[ts] + subdaily_co2_plant[ts] + subdaily_co2_bubbling[ts] + subdaily_co2_water[ts];
62 sc_.accumulated_ch4_emis += subdaily_ch4_soil[ts] + subdaily_ch4_plant[ts] + subdaily_ch4_bubbling[ts] + subdaily_ch4_water[ts];
63 sc_.accumulated_n2o_emis += subdaily_n2o_soil[ts] + subdaily_n2o_plant[ts] + subdaily_n2o_bubbling[ts] + subdaily_n2o_water[ts];
64 sc_.accumulated_no_emis += subdaily_no_soil[ts] + subdaily_no_plant[ts] + subdaily_no_bubbling[ts] + subdaily_no_water[ts];
65 sc_.accumulated_nh3_emis += subdaily_nh3_soil[ts] + subdaily_nh3_plant[ts] + subdaily_nh3_bubbling[ts] + subdaily_nh3_water[ts];
66 sc_.accumulated_radon_emis += subdaily_radon_soil[ts] + subdaily_radon_plant[ts] + subdaily_radon_water[ts];
67
68 sc_.accumulated_ch4_leach += subdaily_ch4_leach[ts];
69 }
70
71 sc_.accumulated_co2_emis_auto += co2_auto_sl.sum();
72 sc_.accumulated_co2_emis_hetero += co2_hetero_sl.sum();
73
74 if (timemode_ == TMODE_SUBDAILY)
75 {
76 for ( PlantIterator vt = this->m_veg->begin(); vt != this->m_veg->end(); ++vt)
77 {
78 accumulated_n_to_living_plant_and_algae_from_extern_sl[0] += (*vt)->n2_fixation;
79 }
80 }
81 else
82 {
83 for ( PlantIterator vt = this->m_veg->begin(); vt != this->m_veg->end(); ++vt)
84 {
85 accumulated_n_to_living_plant_and_algae_from_extern_sl[0] += (*vt)->d_n2_fixation;
86 }
87 }
88
89 if ( timemode_ != TMODE_SUBDAILY || lclock()->is_position( TMODE_POST_DAILY))
90 {
91 /*************************/
92 /* Yearly rate variables */
93 /*************************/
94
95 sc_.accumulated_c_fix_algae += day_c_fix_algae;
96 sc_.accumulated_n_fix_algae += day_n_fix_algae;
97 }
98
100
101 return LDNDC_ERR_OK;
102}
lerr_t MeTrX_send_state()
Definition soilchemistry-metrx-communicate.cpp:347

References MeTrX_send_state().

Referenced by solve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ solve()

lerr_t ldndc::SoilChemistryMeTrX::solve ( )

Kicks off computation for one time step.

27{
28 if ( (lclock()->subday() == 1) || (timemode_ != TMODE_SUBDAILY))
29 {
30 subdaily_time_step_ = 0;
31 }
32
33 lerr_t rc = MeTrX_check_for_negative_value( "entry");
34 if ( rc) return LDNDC_ERR_FAIL;
35
37
38 rc = MeTrX_update();
39 if ( rc) return LDNDC_ERR_FAIL;
40
41 /* isotope checkpoints (SIMONE): one pointer test each if isotopes are off;
42 * entry after MeTrX_update, which takes over the state changed by other modules */
43 if ( iso_) { MeTrX_isotopes_checkpoint( ISO_G_ENTRY); }
44 /* phosphorus checkpoints: one pointer test each if phosphorus is off */
45 if ( p_) { MeTrX_phosphorus_checkpoint( P_CP_ENTRY); }
46
47 rc = MeTrX_spinup();
48 if ( rc) return LDNDC_ERR_FAIL;
49 if ( p_) { MeTrX_phosphorus_checkpoint( P_CP_SPINUP); }
50
52 {
53 rc = MeTrX_balance_check( 1);
54 if ( rc) return LDNDC_ERR_FAIL;
55 }
56
57 rc = MeTrX_physics();
58 if ( rc) return LDNDC_ERR_FAIL;
59
60 rc = MeTrX_fertilize();
61 if ( rc) return LDNDC_ERR_FAIL;
62
63 rc = MeTrX_irrigate();
64 if ( rc) return LDNDC_ERR_FAIL;
65
66 rc = MeTrX_liming();
67 if ( rc) return LDNDC_ERR_FAIL;
68
69 rc = MeTrX_manure();
70 if ( rc) return LDNDC_ERR_FAIL;
71
72 if ( iso_) { MeTrX_isotopes_checkpoint( ISO_G_MGMT); }
73 if ( p_) { MeTrX_phosphorus_checkpoint( P_CP_MGMT); }
74
75 rc = MeTrX_till();
76 if ( rc) return LDNDC_ERR_FAIL;
77
79
80 if ( iso_) { MeTrX_isotopes_checkpoint( ISO_G_LEACH); }
81
82 for ( int ts = 0; ts < INTERNAL_TIME_STEPS; ++ts)
83 {
85
88 MeTrX_groundwater_lateral_solutes();
91 {
93 }
94 else
95 {
97 }
100
101 if ( iso_) { MeTrX_isotopes_checkpoint( ISO_G_TRANSPORT); }
102
104
106
107 lerr_t rc_meta = MeTrX_metabolism();
108 if (rc_meta) { return rc_meta; }
109
110 lerr_t rc_pertub = MeTrX_pertubation();
111 if (rc_pertub) { return rc_pertub; }
112
113 if ( iso_) { MeTrX_isotopes_checkpoint( ISO_G_PERT); }
114
116 MeTrX_inhibitor_decay();
118
123
124 if ( iso_) { MeTrX_isotopes_checkpoint( ISO_G_BIO); }
125
127
128 if ( iso_) { MeTrX_isotopes_checkpoint( ISO_G_NIT); }
129
132
133 if ( iso_) { MeTrX_isotopes_checkpoint( ISO_G_DENIT); }
134
136
140
142
145
148
151
152 if ( iso_) { MeTrX_isotopes_checkpoint( ISO_G_END); }
153
154 subdaily_time_step_ += 1;
155 }
156
157 if ( p_) { MeTrX_phosphorus_checkpoint( P_CP_END); }
158
160 {
161 rc = MeTrX_balance_check( 2);
162 if ( rc) return LDNDC_ERR_FAIL;
163 }
164
167
168 /* isotope composition of the mobile pools for landscape kernels (EcHy3D) */
169 if ( iso_) { MeTrX_isotopes_send(); }
170
171 rc = MeTrX_check_for_negative_value( "exit");
172 if ( rc) return LDNDC_ERR_FAIL;
173
174 return LDNDC_ERR_OK;
175}
lerr_t MeTrX_radon_source_sink()
Definition soilchemistry-metrx-physics-chemistry.cpp:563
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
void MeTrX_pH_calculation()
Definition soilchemistry-metrx-physics-chemistry.cpp:768
lerr_t MeTrX_write_output()
Definition soilchemistry-metrx-output.cpp:22
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
lerr_t MeTrX_update()
Definition soilchemistry-metrx-communicate.cpp:67
lerr_t MeTrX_freeze_thaw()
Definition soilchemistry-metrx-physics-chemistry.cpp:502
void MeTrX_clay_nh4_equilibrium()
Definition soilchemistry-metrx-physics-chemistry.cpp:100
lerr_t MeTrX_write_rates()
Definition soilchemistry-metrx-integrate.cpp:24
lerr_t MeTrX_metabolism()
Definition soilchemistry-metrx-microbial-dynamics.cpp:261
void MeTrX_soil_organic_matter_turnover()
bool advection_equilibrium_
Definition soilchemistry-metrx.h:329
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
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
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
lerr_t MeTrX_fragmentation()
Definition soilchemistry-metrx-fragmentation.cpp:45
bool have_balance_check_
Definition soilchemistry-metrx.h:331
void MeTrX_urea_hydrolysis()
Definition soilchemistry-metrx-management.cpp:1198
void MeTrX_groundwater_access()
Definition soilchemistry-metrx-transport.cpp:847
@ P_CP_SPINUP
Definition soilchemistry-metrx-phosphorus.h:114
@ P_CP_END
Definition soilchemistry-metrx-phosphorus.h:116
@ P_CP_MGMT
Definition soilchemistry-metrx-phosphorus.h:115
@ P_CP_ENTRY
Definition soilchemistry-metrx-phosphorus.h:113

References advection_equilibrium_, have_balance_check_, MeTrX_advection(), MeTrX_advection_equilibrium(), MeTrX_algae_dynamics(), MeTrX_anaerobic_volume(), MeTrX_ch4_oxidation(), MeTrX_ch4_production(), MeTrX_check_for_negative_value(), MeTrX_chemodenitrification(), MeTrX_clay_nh4_equilibrium(), MeTrX_denitrification(), MeTrX_dissolution(), MeTrX_ebullition(), MeTrX_fermentation(), MeTrX_fertilize(), MeTrX_fragmentation(), MeTrX_freeze_thaw(), MeTrX_gas_diffusion(), MeTrX_groundwater_access(), MeTrX_iron_oxidation(), MeTrX_iron_reduction(), MeTrX_leaching(), MeTrX_liming(), MeTrX_liq_diffusion(), MeTrX_manure(), MeTrX_metabolism(), MeTrX_microbial_dynamics(), MeTrX_nh3_nh4_equilibrium(), MeTrX_nitrification(), MeTrX_nitrogen_fertilizer_release(), MeTrX_pertubation(), MeTrX_pH_calculation(), MeTrX_physics(), MeTrX_plant_respiration(), MeTrX_radon_source_sink(), MeTrX_reset(), MeTrX_soil_organic_matter_turnover(), MeTrX_spinup(), MeTrX_sulfate_reduction(), MeTrX_sulfide_oxidation(), MeTrX_till(), MeTrX_update(), MeTrX_urea_hydrolysis(), MeTrX_write_output(), MeTrX_write_rates(), ldndc::P_CP_END, ldndc::P_CP_ENTRY, ldndc::P_CP_MGMT, and ldndc::P_CP_SPINUP.

Here is the call graph for this function:

Member Data Documentation

◆ advection_equilibrium_

bool ldndc::SoilChemistryMeTrX::advection_equilibrium_
private

advection = "equilibrium"

Referenced by solve().

◆ ANVF_ATM

double const ldndc::SoilChemistryMeTrX::ANVF_ATM
private

strict anaerobic volume fraction at atmospheric oxygen partial pressure (option anvf="wfps")

◆ anvf_default_

bool ldndc::SoilChemistryMeTrX::anvf_default_
private

anvf = "default"

◆ anvf_wfps_

bool ldndc::SoilChemistryMeTrX::anvf_wfps_
private

anvf = "wfps"

◆ C_SATURATION

const double ldndc::SoilChemistryMeTrX::C_SATURATION = 82.0 * cbm::KG_IN_G
staticprivate

C-saturation level for mineral associated cabon [kg(C):kg(silt+clay)-1]

Referenced by MeTrX_peat_layer().

◆ ch4_depth_factor_

bool ldndc::SoilChemistryMeTrX::ch4_depth_factor_
private

ch4depthfactor = "yes"

◆ d_eff_millington_quirk_

bool ldndc::SoilChemistryMeTrX::d_eff_millington_quirk_
private

effectivediffusion = "millington_and_quirk_1961"

◆ d_eff_parameter_

bool ldndc::SoilChemistryMeTrX::d_eff_parameter_
private

effectivediffusion = "parameter"

Referenced by MeTrX_gas_liq_diffusion().

◆ FACT_PH_MIN

const double ldndc::SoilChemistryMeTrX::FACT_PH_MIN = 0.01
staticprivate

Minimum pH response factor, processes with smaller response are not calculated [-]

◆ ft_processes_

bool ldndc::SoilChemistryMeTrX::ft_processes_
private

freezethaw = "ft_processes"

Referenced by MeTrX_freeze_thaw(), and MeTrX_get_fact_t_denit().

◆ ft_yes_

bool ldndc::SoilChemistryMeTrX::ft_yes_
private

freezethaw = "yes"

Referenced by MeTrX_freeze_thaw().

◆ gas_liq_coupled_

bool ldndc::SoilChemistryMeTrX::gas_liq_coupled_
private

gasdiffusion = "coupled"

◆ gw_exchange_sl

double* ldndc::SoilChemistryMeTrX::gw_exchange_sl
private

lateral groundwater exchange of the time step, per layer (positive: inflow, negative: outflow) [m]

Referenced by MeTrX_update().

◆ have_balance_check_

bool ldndc::SoilChemistryMeTrX::have_balance_check_
private

C/N balance check each time step (configuration: balance_check)

Referenced by solve().

◆ organic_layer_sl_

std::vector< char > ldndc::SoilChemistryMeTrX::organic_layer_sl_
private

organic soil layers: peat layers and organic litter layers of forests (see MeTrX_organic_layer)

Referenced by MeTrX_organic_layer(), and MeTrX_peat_layer().

◆ peat_layer_sl_

std::vector< char > ldndc::SoilChemistryMeTrX::peat_layer_sl_
private

layers whose initial soil organic carbon exceeds the capacity of mineral surfaces (see MeTrX_peat_layer)

Referenced by MeTrX_peat_layer().

◆ PEAT_ORGANIC_VOLUME_1

const double ldndc::SoilChemistryMeTrX::PEAT_ORGANIC_VOLUME_1 = 0.2
staticprivate

organic volume share of the solids where the peat weight starts to rise from 0 and reaches 1

Referenced by MeTrX_peat_layer().

◆ peat_weight_sl_

std::vector< double > ldndc::SoilChemistryMeTrX::peat_weight_sl_
private

peat weight of soil layers for aged organic matter (see MeTrX_peat_weight)

Referenced by MeTrX_peat_layer(), and MeTrX_peat_weight().

◆ PH_MAX_CHEMODENIT

double const ldndc::SoilChemistryMeTrX::PH_MAX_CHEMODENIT
private

pH limits beyond which the pH response is below FACT_PH_MIN and processes are not calculated maximum pH of chemodenitrification

◆ RHO_ORGANIC_MATTER

const double ldndc::SoilChemistryMeTrX::RHO_ORGANIC_MATTER = 1.35
staticprivate

particle densities of organic and mineral matter [g cm-3] (peat weight, see MeTrX_peat_weight)

Referenced by MeTrX_peat_layer().

◆ spinup_aged_

bool ldndc::SoilChemistryMeTrX::spinup_aged_
private

spinup equilibrium of aged organic matter outside peat layers and the forest floor (option spinupaged)

◆ TNORM

const double ldndc::SoilChemistryMeTrX::TNORM = 293.2
staticprivate

Reference temperature [K]