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