The BioCro C++ Library
lightME.cpp
Go to the documentation of this file.
1#include "lightME.h"
2#include "../framework/constants.h" // for atmospheric_pressure_at_sea_level
3
4using physical_constants::atmospheric_pressure_at_sea_level;
5
57 double cosine_zenith_angle, // dimensionless
58 double atmospheric_pressure, // Pa
59 double atmospheric_transmittance, // dimensionless
60 double atmospheric_scattering // dimensionless
61)
62{
63 // Dimensionless quantity used in later calculations.
64 double const pressure_ratio =
65 atmospheric_pressure / atmospheric_pressure_at_sea_level;
66
67 // Equation 11.1 from Campbell & Norman, solving for
68 // direct_transmittance = S_p / S_p0 (dimensionless).
69 // If the sun is near the horizon, take the limit as cosine_zenith_angle
70 // approaches 0 (which is 0).
71 double const direct_transmittance =
72 cosine_zenith_angle <= 0 ? 0
73 : pow(atmospheric_transmittance,
74 (pressure_ratio / cosine_zenith_angle));
75
76 // Equation 11.13 from Campbell & Norman, solving for
77 // diffuse_transmittance = S_p / S_p0 (dimensionless).
78 // If the sun is near the horizon, take the limit as cosine_zenith_angle
79 // approaches 0 (which is 0).
80 double const diffuse_transmittance =
81 cosine_zenith_angle <= 0 ? 0
82 : atmospheric_scattering *
83 (1 - direct_transmittance) *
84 cosine_zenith_angle;
85
86 // The fraction of direct irradiance just above the canopy is the ratio of
87 // the direct transmittance to the total transmittance (dimensionless).
88 // If the sun is near the horizon, take the limit as cosine_zenith_angle
89 // approaches 0 (which is 0).
90 double const direct_fraction =
91 cosine_zenith_angle <= 0 ? 0
92 : direct_transmittance /
93 (direct_transmittance + diffuse_transmittance);
94
95 // The remaining irradiance is diffuse (dimensionless).
96 double const diffuse_fraction = 1.0 - direct_fraction;
97
98 return Light_model{
99 /* .direct_transmittance = */ direct_transmittance, // dimensionless
100 /* .diffuse_transmittance = */ diffuse_transmittance, // dimensionless
101 /* .direct_fraction = */ direct_fraction, // dimensionless
102 /* .diffuse_fraction = */ diffuse_fraction // dimensionless
103 };
104}
Light_model lightME(double cosine_zenith_angle, double atmospheric_pressure, double atmospheric_transmittance, double atmospheric_scattering)
Calculates the "light macro environment"; in other words, the amount of sunlight scattered out of the...
Definition: lightME.cpp:56