The BioCro C++ Library
light_from_solar.h
Go to the documentation of this file.
1#ifndef LIGHT_FROM_SOLAR_H
2#define LIGHT_FROM_SOLAR_H
3
4#include "../framework/module.h"
5#include "../framework/state_map.h"
6
7namespace standardBML
8{
9class light_from_solar : public direct_module
10{
11 public:
12 light_from_solar(state_map const& input_quantities, state_map* output_quantities)
13 : direct_module{},
14
15 // Get pointers to input quantities
16 solar_ip{get_ip(input_quantities, "solar")},
17 light_threshold_ip{get_ip(input_quantities, "light_threshold")},
18 light_exp_at_zero_ip{get_ip(input_quantities, "light_exp_at_zero")},
19
20 // Get pointers to output quantities
21 light_op{get_op(output_quantities, "light")}
22 {
23 }
24 static string_vector get_inputs();
25 static string_vector get_outputs();
26 static std::string get_name() { return "light_from_solar"; }
27
28 private:
29 // Pointers to input quantities
30 const double* solar_ip;
31 const double* light_threshold_ip;
32 const double* light_exp_at_zero_ip;
33
34 // Pointers to output quantities
35 double* light_op;
36
37 // Main operation
38 void do_operation() const;
39};
40
42{
43 return {
44 "solar", //
45 "light_threshold", //
46 "light_exp_at_zero" //
47 };
48}
49
51{
52 return {
53 "light" //
54 };
55}
56
57void light_from_solar::do_operation() const
58{
60 // Collect inputs and make calculations //
62
63 // Get the current level of solar radiation
64 double solar = *solar_ip;
65
66 // Get the light threshold
67 double light_threshold = *light_threshold_ip;
68
69 // Get the light exponent at zero
70 double light_exp_at_zero = *light_exp_at_zero_ip;
71
72 // Check whether the plant is illuminated
73 // Rather than simply using a step function (i.e., light = solar > 0),
74 // this logistic function smoothly turns on as the solar radiation
75 // increases
76 // Coefficients have been chosen so that light:
77 // (1) roughly equals exp(-light_exp_at_zero) for solar = 0
78 // (2) roughly equals 1 - exp(-light_exp_at_zero) for solar = light_threshold
79 // (3) equals 1/2 for solar = light_threshold/2
80 double light = 1.0 / (1.0 + exp(-2.0 * light_exp_at_zero * (solar - 0.5 * light_threshold) / light_threshold));
81
83 // Update the output quantity list //
85
86 update(light_op, light);
87}
88
89} // namespace standardBML
90#endif
static string_vector get_outputs()
static string_vector get_inputs()
static std::string get_name()
light_from_solar(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