The BioCro C++ Library
partitioning_growth.h
Go to the documentation of this file.
1#ifndef PARTITIONING_GROWTH_H
2#define PARTITIONING_GROWTH_H
3
4#include "../framework/module.h"
5#include "../framework/state_map.h"
6
7namespace standardBML
8{
62class partitioning_growth : public differential_module
63{
64 public:
66 state_map const& input_quantities,
67 state_map* output_quantities)
68 : differential_module{},
69
70 // Get references to input quantities
71 kGrain{get_input(input_quantities, "kGrain")},
72 kLeaf{get_input(input_quantities, "kLeaf")},
73 kRhizome{get_input(input_quantities, "kRhizome")},
74 kRoot{get_input(input_quantities, "kRoot")},
75 kShell{get_input(input_quantities, "kShell")},
76 kStem{get_input(input_quantities, "kStem")},
77 Leaf{get_input(input_quantities, "Leaf")},
78 net_assimilation_rate_grain{get_input(input_quantities, "net_assimilation_rate_grain")},
79 net_assimilation_rate_leaf{get_input(input_quantities, "net_assimilation_rate_leaf")},
80 net_assimilation_rate_rhizome{get_input(input_quantities, "net_assimilation_rate_rhizome")},
81 net_assimilation_rate_root{get_input(input_quantities, "net_assimilation_rate_root")},
82 net_assimilation_rate_shell{get_input(input_quantities, "net_assimilation_rate_shell")},
83 net_assimilation_rate_stem{get_input(input_quantities, "net_assimilation_rate_stem")},
84 retrans{get_input(input_quantities, "retrans")},
85 retrans_rhizome{get_input(input_quantities, "retrans_rhizome")},
86 Rhizome{get_input(input_quantities, "Rhizome")},
87 Root{get_input(input_quantities, "Root")},
88 Stem{get_input(input_quantities, "Stem")},
89
90 // Get pointers to output quantities
91 Grain_op{get_op(output_quantities, "Grain")},
92 Leaf_op{get_op(output_quantities, "Leaf")},
93 Rhizome_op{get_op(output_quantities, "Rhizome")},
94 Root_op{get_op(output_quantities, "Root")},
95 Shell_op{get_op(output_quantities, "Shell")},
96 Stem_op{get_op(output_quantities, "Stem")}
97 {
98 }
99 static string_vector get_inputs();
100 static string_vector get_outputs();
101 static std::string get_name() { return "partitioning_growth"; }
102
103 private:
104 // References to input quantities
105 const double& kGrain;
106 const double& kLeaf;
107 const double& kRhizome;
108 const double& kRoot;
109 const double& kShell;
110 const double& kStem;
111 const double& Leaf;
112 const double& net_assimilation_rate_grain;
113 const double& net_assimilation_rate_leaf;
114 const double& net_assimilation_rate_rhizome;
115 const double& net_assimilation_rate_root;
116 const double& net_assimilation_rate_shell;
117 const double& net_assimilation_rate_stem;
118 const double& retrans;
119 const double& retrans_rhizome;
120 const double& Rhizome;
121 const double& Root;
122 const double& Stem;
123
124 // Pointers to output quantities
125 double* Grain_op;
126 double* Leaf_op;
127 double* Rhizome_op;
128 double* Root_op;
129 double* Shell_op;
130 double* Stem_op;
131
132 // Implement the pure virtual function do_operation():
133 void do_operation() const override final;
134};
135
137{
138 return {
139 "kGrain", // dimensionless
140 "kLeaf", // dimensionless
141 "kRhizome", // dimensionless
142 "kRoot", // dimensionless
143 "kShell", // dimensionless
144 "kStem", // dimensionless
145 "Leaf", // Mg / ha
146 "net_assimilation_rate_grain", // Mg / ha / hour
147 "net_assimilation_rate_leaf", // Mg / ha / hour
148 "net_assimilation_rate_rhizome", // Mg / ha / hour
149 "net_assimilation_rate_root", // Mg / ha / hour
150 "net_assimilation_rate_shell", // Mg / ha / hour
151 "net_assimilation_rate_stem", // Mg / ha / hour
152 "retrans", // dimensionless
153 "retrans_rhizome", // dimensionless
154 "Rhizome", // Mg / ha
155 "Root", // Mg / ha
156 "Stem" // Mg / ha
157 };
158}
159
161{
162 return {
163 "Grain", // Mg / ha / hour
164 "Leaf", // Mg / ha / hour
165 "Rhizome", // Mg / ha / hour
166 "Root", // Mg / ha / hour
167 "Shell", // Mg / ha / hour
168 "Stem" // Mg / ha / hour
169 };
170}
171
172void partitioning_growth::do_operation() const
173{
174 // Initialize variables
175 double dGrain{0.0};
176 double dLeaf{0.0};
177 double dRhizome{0.0};
178 double dRoot{0.0};
179 double dShell{0.0};
180 double dStem{0.0};
181
182 // Determine whether Leaf is growing or decaying
183 if (kLeaf > 0.0) {
184 dLeaf += net_assimilation_rate_leaf;
185 } else {
186 dLeaf += Leaf * kLeaf;
187 dRhizome += kRhizome * (-dLeaf) * retrans;
188 dStem += kStem * (-dLeaf) * retrans;
189 dRoot += kRoot * (-dLeaf) * retrans;
190 dGrain += kGrain * (-dLeaf) * retrans;
191 dShell += kShell * (-dLeaf) * retrans;
192 }
193
194 // Determine whether Stem is growing or decaying
195 if (kStem >= 0.0) {
196 dStem += net_assimilation_rate_stem;
197 } else {
198 dStem += Stem * kStem;
199 dRhizome += kRhizome * (-dStem) * retrans;
200 dLeaf += kLeaf * (-dStem) * retrans;
201 dRoot += kRoot * (-dStem) * retrans;
202 dGrain += kGrain * (-dStem) * retrans;
203 dShell += kShell * (-dStem) * retrans;
204 }
205
206 // Determine whether Root is growing or decaying
207 if (kRoot > 0.0) {
208 dRoot += net_assimilation_rate_root;
209 } else {
210 dRoot += Root * kRoot;
211 dRhizome += kRhizome * (-dRoot) * retrans;
212 dStem += kStem * (-dRoot) * retrans;
213 dLeaf += kLeaf * (-dRoot) * retrans;
214 dGrain += kGrain * (-dRoot) * retrans;
215 dShell += kShell * (-dRoot) * retrans;
216 }
217
218 // Determine whether Rhizome is growing or decaying
219 if (kRhizome > 0.0) {
220 dRhizome += net_assimilation_rate_rhizome;
221 } else {
222 dRhizome += Rhizome * kRhizome;
223 if (dRhizome + Rhizome < 0) {
224 // Try to prevent Rhizome mass from becoming negative
225 dRhizome = -0.9 * Rhizome;
226 }
227 dRoot += kRoot * (-dRhizome) * retrans_rhizome;
228 dStem += kStem * (-dRhizome) * retrans_rhizome;
229 dLeaf += kLeaf * (-dRhizome) * retrans_rhizome;
230 dGrain += kGrain * (-dRhizome) * retrans_rhizome;
231 dShell += kShell * (-dRhizome) * retrans_rhizome;
232 }
233
234 // Determine whether Grain is growing
235 if (kGrain > 0.0) {
236 dGrain += net_assimilation_rate_grain;
237 }
238
239 if (kShell > 0.0) {
240 dShell += net_assimilation_rate_shell;
241 }
242
243 // Update the output quantity list
244 update(Grain_op, dGrain);
245 update(Leaf_op, dLeaf);
246 update(Rhizome_op, dRhizome);
247 update(Root_op, dRoot);
248 update(Shell_op, dShell);
249 update(Stem_op, dStem);
250}
251
252} // namespace standardBML
253#endif
This module determines the growth rate for several plant organs from the net rate of carbon assimilat...
partitioning_growth(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