The BioCro C++ Library
thermal_time_trilinear.h
Go to the documentation of this file.
1#ifndef THERMAL_TIME_TRILINEAR_H
2#define THERMAL_TIME_TRILINEAR_H
3
4#include "../framework/module.h"
5#include "../framework/state_map.h"
6
7namespace standardBML
8{
86class thermal_time_trilinear : public differential_module
87{
88 public:
90 state_map const& input_quantities,
91 state_map* output_quantities)
92 : differential_module{},
93
94 // Get references to input quantities
95 fractional_doy{get_input(input_quantities, "fractional_doy")},
96 sowing_fractional_doy{get_input(input_quantities, "sowing_fractional_doy")},
97 temp{get_input(input_quantities, "temp")},
98 tbase{get_input(input_quantities, "tbase")},
99 topt_lower{get_input(input_quantities, "topt_lower")},
100 topt_upper{get_input(input_quantities, "topt_upper")},
101 tmax{get_input(input_quantities, "tmax")},
102
103 // Get pointers to output quantities
104 TTc_op{get_op(output_quantities, "TTc")}
105 {
106 }
107 static string_vector get_inputs();
108 static string_vector get_outputs();
109 static std::string get_name() { return "thermal_time_trilinear"; }
110
111 private:
112 // References to input quantities
113 double const& fractional_doy;
114 double const& sowing_fractional_doy;
115 double const& temp;
116 double const& tbase;
117 double const& topt_lower;
118 double const& topt_upper;
119 double const& tmax;
120
121 // Pointers to output quantities
122 double* TTc_op;
123
124 // Main operation
125 void do_operation() const;
126};
127
129{
130 return {
131 "fractional_doy", // days
132 "sowing_fractional_doy", // days
133 "temp", // degrees C
134 "tbase", // degrees C
135 "topt_lower", // degrees C
136 "topt_upper", // degrees C
137 "tmax" // degrees C
138 };
139}
140
142{
143 return {
144 "TTc" // degrees C * day / hr
145 };
146}
147
148void thermal_time_trilinear::do_operation() const
149{
150 // Find the rate of change on a daily basis
151 double const rate_per_day =
152 fractional_doy < sowing_fractional_doy ? 0.0
153 : temp <= tbase ? 0.0
154 : temp <= topt_lower ? temp - tbase
155 : temp <= topt_upper ? topt_lower - tbase
156 : temp <= tmax ? (tmax - temp) * (topt_lower - tbase) / (tmax - topt_upper)
157 : 0.0; // degrees C
158
159 // Convert to an hourly rate
160 double const rate_per_hour = rate_per_day / 24.0; // degrees C * day / hr
161
162 // Update the output quantity list
163 update(TTc_op, rate_per_hour);
164}
165
166} // namespace standardBML
167#endif
Calculates the rate of thermal time accumulation using a trilinear model.
thermal_time_trilinear(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