The BioCro C++ Library
partitioning_coefficient_logistic.h
Go to the documentation of this file.
1#ifndef PARTITIONING_COEFFICIENT_LOGISTIC_H
2#define PARTITIONING_COEFFICIENT_LOGISTIC_H
3
4#include "../framework/module.h"
5#include "../framework/state_map.h"
6#include <cmath> // for exp
7
8namespace standardBML
9{
10double strength_term(double const alpha, double const beta, double const DVI);
11
66class partitioning_coefficient_logistic : public direct_module
67{
68 public:
70 state_map const& input_quantities,
71 state_map* output_quantities)
72 : direct_module{},
73
74 // Get references to input quantities
75 alphaLeaf{get_input(input_quantities, "alphaLeaf")},
76 alphaRhizome{get_input(input_quantities, "alphaRhizome")},
77 alphaRoot{get_input(input_quantities, "alphaRoot")},
78 alphaShell{get_input(input_quantities, "alphaShell")},
79 alphaStem{get_input(input_quantities, "alphaStem")},
80 betaLeaf{get_input(input_quantities, "betaLeaf")},
81 betaRhizome{get_input(input_quantities, "betaRhizome")},
82 betaRoot{get_input(input_quantities, "betaRoot")},
83 betaShell{get_input(input_quantities, "betaShell")},
84 betaStem{get_input(input_quantities, "betaStem")},
85 DVI{get_input(input_quantities, "DVI")},
86 kRhizome_emr{get_input(input_quantities, "kRhizome_emr")},
87 kRhizome_emr_DVI{get_input(input_quantities, "kRhizome_emr_DVI")},
88
89 // Get pointers to output quantities
90 kGrain_op{get_op(output_quantities, "kGrain")},
91 kLeaf_op{get_op(output_quantities, "kLeaf")},
92 kRhizome_op{get_op(output_quantities, "kRhizome")},
93 kRoot_op{get_op(output_quantities, "kRoot")},
94 kShell_op{get_op(output_quantities, "kShell")},
95 kStem_op{get_op(output_quantities, "kStem")}
96 {
97 }
98 static string_vector get_inputs();
99 static string_vector get_outputs();
100 static std::string get_name() { return "partitioning_coefficient_logistic"; }
101
102 private:
103 // Pointers to input quantities
104 const double& alphaLeaf;
105 const double& alphaRhizome;
106 const double& alphaRoot;
107 const double& alphaShell;
108 const double& alphaStem;
109 const double& betaLeaf;
110 const double& betaRhizome;
111 const double& betaRoot;
112 const double& betaShell;
113 const double& betaStem;
114 const double& DVI;
115 const double& kRhizome_emr;
116 const double& kRhizome_emr_DVI;
117
118 // Pointers to output quantities
119 double* kGrain_op;
120 double* kLeaf_op;
121 double* kRhizome_op;
122 double* kRoot_op;
123 double* kShell_op;
124 double* kStem_op;
125
126 // Implement the pure virtual function do_operation():
127 void do_operation() const override final;
128};
129
131{
132 return {
133 "alphaLeaf", // dimensionless
134 "alphaRhizome", // dimensionless
135 "alphaRoot", // dimensionless
136 "alphaShell", // dimensionless
137 "alphaStem", // dimensionless
138 "betaLeaf", // dimensionless
139 "betaRhizome", // dimensionless
140 "betaRoot", // dimensionless
141 "betaShell", // dimensionless
142 "betaStem", // dimensionless
143 "DVI", // dimensionless
144 "kRhizome_emr", // dimensionless
145 "kRhizome_emr_DVI" // dimensionless
146 };
147}
148
150{
151 return {
152 "kGrain", // dimensionless
153 "kLeaf", // dimesnionless
154 "kRhizome", // dimensionless
155 "kRoot", // dimensionless
156 "kShell", // dimensionless
157 "kStem" // dimensionless
158 };
159}
160
161void partitioning_coefficient_logistic::do_operation() const
162{
163 // Check for error conditions; kRhizome_emr should be zero or negative,
164 // since it applies when the rhizome is acting as a carbon source.
165 if (kRhizome_emr > 0.0) {
166 throw std::range_error("Thrown in partitioning_coefficient_logistic: kRhizome_emr is positive.");
167 }
168
169 // Determine partitioning coefficients using multinomial logistic equations
170 // from Osborne et al., 2015 JULES-crop https://doi.org/10.5194/gmd-8-1139-2015
171
172 // Calculate the sink strength of each tissue (relative to grain)
173 double const leaf_strength{strength_term(alphaLeaf, betaLeaf, DVI)};
174 double const root_strength{strength_term(alphaRoot, betaRoot, DVI)};
175 double const shell_strength{strength_term(alphaShell, betaShell, DVI)};
176 double const stem_strength{strength_term(alphaStem, betaStem, DVI)};
177 double constexpr grain_strength{1};
178
179 // The rhizome is treated different from the other tissues. When the plant
180 // is in its emergence stage (DVI < 0), the rhizome acts like a carbon
181 // source. In this case, its demand for carbon is zero. Otherwise, it
182 // follows the same rules as the other tissues.
183 double const rhizome_strength{DVI < kRhizome_emr_DVI
184 ? 0
185 : strength_term(alphaRhizome, betaRhizome, DVI)};
186
187 // Calculate the total sink strength
188 double const total_strength =
189 leaf_strength + rhizome_strength + root_strength + shell_strength +
190 stem_strength + grain_strength;
191
192 // The k values are the fraction of total demand from each tissue
193 double const kGrain{grain_strength / total_strength}; // dimensionless
194 double const kLeaf{leaf_strength / total_strength}; // dimensionless
195 double const kRoot{root_strength / total_strength}; // dimensionless
196 double const kShell{shell_strength / total_strength}; // dimensionless
197 double const kStem{stem_strength / total_strength}; // dimensionless
198
199 // The rhizome is treated different from the other tissues. When DVI < 0,
200 // its k value is given by kRhizome_emr. Otherwise, it follows the same
201 // rules as the other tissues.
202 double const kRhizome{DVI < kRhizome_emr_DVI
203 ? kRhizome_emr
204 : rhizome_strength / total_strength}; // dimensionless
205
206 // Update the output quantities
207 update(kGrain_op, kGrain); // dimensionless
208 update(kLeaf_op, kLeaf); // dimensionless
209 update(kRhizome_op, kRhizome); // dimensionless
210 update(kRoot_op, kRoot); // dimensionless
211 update(kShell_op, kShell); // dimensionless
212 update(kStem_op, kStem); // dimensionless
213}
214
215double strength_term(double const alpha, double const beta, double const DVI)
216{
217 return exp(alpha + beta * DVI); // dimensionless
218}
219
220} // namespace standardBML
221#endif
Calculates carbon partitioning coefficients based on logistic-based functions and development index u...
partitioning_coefficient_logistic(state_map const &input_quantities, state_map *output_quantities)
This is the standard BioCro module library; it includes the essential modules used in typical BioCro ...
Definition: aba_decay.h:8
double strength_term(double const alpha, double const beta, double const DVI)