The BioCro C++ Library
AuxBioCro.cpp File Reference
#include <string>
#include <stdexcept>
#include <algorithm>
#include <cmath>
#include <vector>
#include "c4photo.h"
#include "BioCro.h"
#include "boundary_layer_conductance.h"
#include "sunML.h"
#include "water_and_air_properties.h"
#include "../framework/constants.h"
+ Include dependency graph for AuxBioCro.cpp:

Go to the source code of this file.

Functions

double poisson_density (int x, double lambda)
 
void WINDprof (double WindSpeed, double LAI, vector< double > &wind_speed_profile)
 Wind profile function. More...
 
void RHprof (double RH, int nlayers, double *relative_humidity_profile)
 Calculates a relative humidity profile throughout a multilayer canopy. More...
 
void LNprof (double LeafN, double LAI, double kpLN, vector< double > &leafN_profile)
 
double SoilEvapo (double LAI, double k, double air_temperature, double ppfd, double soil_water_content, double fieldc, double wiltp, double winds, double RelH, double rsec, double soil_clod_size, double soil_reflectance, double soil_transmission, double specific_heat_of_air, double par_energy_content)
 
double compute_wsPhoto (int wsFun, double fieldc, double wiltp, double phi1, double awc)
 
ws_str watstr (double precipit, double evapo, double cws, double soildepth, double fieldc, double wiltp, double soil_saturation_capacity, double sand, double Ks, double air_entry, double b)
 
soilML_str soilML (double precipit, double transp, double *cws, double soildepth, double *depths, double soil_field_capacity, double soil_wilting_point, double soil_saturation_capacity, double soil_air_entry, double soil_saturated_conductivity, double soil_b_coefficient, double soil_sand_content, double phi1, double phi2, int wsFun, int layers, double rootDB, double LAI, double k, double AirTemp, double IRad, double winds, double RelH, int hydrDist, double rfl, double rsec, double rsdf, double soil_clod_size, double soil_reflectance, double soil_transmission, double specific_heat_of_air, double par_energy_content)
 
seqRD_str seqRootDepth (double to, int lengthOut)
 
rd_str rootDist (int n_layers, double rootDepth, double *depths, double rfl)
 

Function Documentation

◆ compute_wsPhoto()

double compute_wsPhoto ( int  wsFun,
double  fieldc,
double  wiltp,
double  phi1,
double  awc 
)

Definition at line 298 of file AuxBioCro.cpp.

◆ LNprof()

void LNprof ( double  LeafN,
double  LAI,
double  kpLN,
vector< double > &  leafN_profile 
)

Definition at line 184 of file AuxBioCro.cpp.

Referenced by c3CanAC(), CanAC(), and multilayer_canopy_properties::run().

+ Here is the caller graph for this function:

◆ poisson_density()

double poisson_density ( int  x,
double  lambda 
)

Definition at line 38 of file AuxBioCro.cpp.

Referenced by rootDist().

+ Here is the caller graph for this function:

◆ RHprof()

void RHprof ( double  RH,
int  nlayers,
double *  relative_humidity_profile 
)

Calculates a relative humidity profile throughout a multilayer canopy.

Parameters
[in]RHrelative humidity just above the canopy (0 <= RH <= 1)
[in]nlayersnumber of layers in the canopy (1 <= nlayers <= MAXLAY)
[out]relative_humidity_profilearray of relative humidity values expressed as fractions between 0 and 1, where the value at index i represents relative humidity at the bottom of canopy layer i and i = 0 corresponds to the top canopy layer.

One can derive an expression for the relative humidity (h) throughout a plant canopy by making the following assumptions:

  • h at the top of the canopy is the same as the ambient value (h = h0)
  • h at the bottom of the canopy is one hundred percent (h = 1)
  • h follows an exponential profile throughout the canopy

To enforce the exponential profile, we can write

h(x) = A * exp(B * x) [Equation (1)]

where x is a normalized expression of depth within the canopy (x = 0 at the canopy top and x = 1 at the bottom) and the values of A and B are yet to be determined.

To enforce the h value at the canopy top, we require h0 = h(0) = A; in other words, A = h0. To enforce the h value at the canopy bottom, we require 1 = h(1) = h0 * exp(B); in other words, B = -ln(h0). Putting it all together, we see that under these assumptions, h throughout the canopy is given by

h(x) = h0 * exp(-ln(h0) * x) [Equation (2)]

If we additionally assume that h0 is close to 1, we can simplify B = -ln(h0) by taking just the linear part of the Taylor series for -ln(h0) centered at h0 = 1, which is B = -(h0 - 1). With this modification, we have

h(x) = h0 * exp((1 - h0) * x) [Equation (3)]

When h0 = 1, Equations (2) and (3) are in perfect agreement, reducing to h(x) = 1. However, as h0 deviates further from h0 = 1, the linearization for B becomes less accurate and the two versions diverge, especially deeper in the canopy. For example, when h0 = 0.7, Equation (2) becomes h(x) = 0.7 * exp(0.357 * x) while Equation (3) becomes h(x) = 0.7 * exp(0.300 * x). Both versions agree at the top of the canopy where x = 0 and h(x) = 1, but are different at the bottom: 1.00 vs. 0.94. For lower h0 values, the difference at the canopy bottom becomes even more pronounced, significantly violating one of the original assumptions. However, there isn't a strong scientific justification for assuming humidity is 1 at the bottom of every canopy, so the error due to the approximation for B is deemed to be acceptable.


In BioCro, we divide the canopy into equally sized layers; i.e., the interval 0 <= x <= 1 is divided into n segments of length 1 / n by n + 1 boundaries occurring at x = 0, x = 1 / n, x = 2 / n, ..., x = 1. Here we wish to find the h value at the bottom of each layer, so we use Equation (3) with x = 1 / n, x = 2 / n, ..., x = 1.

In the code below, the RH input argument corresponds to h0, the exponential growth constant kh corresponds to B, and nlayers corresponds to n.


Note 1: the explanation for this code was "reverse engineered" by EBL from some crytpic documentation found in earlier versions of this function and from Stephen Humphries's thesis, which is not available online:

Humphries, S. "Will mechanistically rich models provide us with new insights into the response of plant production to climate change?: development and experiments with WIMOVAC: (Windows Intuitive Model of Vegetation response to Atmosphere & Climate Change)" (University of Essex, 2002).


Note 2: Equation (2) can be rewritten by noting that h0 = exp(ln(h0)). With this replacement, the equation becomes

h(x) = exp(ln(h0) - ln(h0) * x) = exp(-B * (1 - x))

The equation takes this form in Humphries's thesis.

Definition at line 166 of file AuxBioCro.cpp.

References MAXLAY.

◆ rootDist()

rd_str rootDist ( int  n_layers,
double  rootDepth,
double *  depths,
double  rfl 
)

Definition at line 647 of file AuxBioCro.cpp.

References poisson_density(), rootDist(), and rd_str::rootDist.

Referenced by rootDist(), and soilML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ seqRootDepth()

seqRD_str seqRootDepth ( double  to,
int  lengthOut 
)

Definition at line 636 of file AuxBioCro.cpp.

References seqRD_str::rootDepths.

◆ SoilEvapo()

double SoilEvapo ( double  LAI,
double  k,
double  air_temperature,
double  ppfd,
double  soil_water_content,
double  fieldc,
double  wiltp,
double  winds,
double  RelH,
double  rsec,
double  soil_clod_size,
double  soil_reflectance,
double  soil_transmission,
double  specific_heat_of_air,
double  par_energy_content 
)

Definition at line 202 of file AuxBioCro.cpp.

References saturation_vapor_pressure(), TempToDdryA(), TempToLHV(), TempToSFS(), and thick_layer_absorption().

Referenced by soilML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ soilML()

soilML_str soilML ( double  precipit,
double  transp,
double *  cws,
double  soildepth,
double *  depths,
double  soil_field_capacity,
double  soil_wilting_point,
double  soil_saturation_capacity,
double  soil_air_entry,
double  soil_saturated_conductivity,
double  soil_b_coefficient,
double  soil_sand_content,
double  phi1,
double  phi2,
int  wsFun,
int  layers,
double  rootDB,
double  LAI,
double  k,
double  AirTemp,
double  IRad,
double  winds,
double  RelH,
int  hydrDist,
double  rfl,
double  rsec,
double  rsdf,
double  soil_clod_size,
double  soil_reflectance,
double  soil_transmission,
double  specific_heat_of_air,
double  par_energy_content 
)

◆ watstr()

ws_str watstr ( double  precipit,
double  evapo,
double  cws,
double  soildepth,
double  fieldc,
double  wiltp,
double  soil_saturation_capacity,
double  sand,
double  Ks,
double  air_entry,
double  b 
)

Definition at line 352 of file AuxBioCro.cpp.

References ws_str::awc, ws_str::Nleach, ws_str::psim, and ws_str::runoff.

◆ WINDprof()

void WINDprof ( double  WindSpeed,
double  LAI,
vector< double > &  wind_speed_profile 
)

Wind profile function.

Preconditions: WindSpeed is non-negative. LAI is non-negative wind_speed_profile is a vector of size at most MAXLAY.

Definition at line 66 of file AuxBioCro.cpp.

Referenced by c3CanAC(), CanAC(), and multilayer_canopy_properties::run().

+ Here is the caller graph for this function: