egg_water | R Documentation |
Function for computing the exchange of gaseous and liquid water between an egg and soil under environmental conditions that vary with time, using interpolation functions to estimate environmental conditions at particular time intervals. Michael Kearney developed this R function based on Tracy, C. R., Packard, G. C., and Packard, M. J. (1978). Water relations of chelonian eggs. Physiological Zoology 51, 378–387. Parameter examples come from this paper.
ode(y = c(m_init, psi_e_init), times = t, func = egg_water, parms = indata)
t |
time intervals (s) at which output is required |
m_init |
= 5.8 / 1000, mass of freshly laid egg (kg) |
psi_e_init |
= -707, water potential of freshly laid egg (J/kg) |
shape |
= 0.6, ratio of minor axes major axis of ellipsoid (-) |
f_air |
= 0.5, fraction of egg surface exposed to air |
K_e |
= 1.12 * 60 * 24 / 1e6 / (3600 * 24 * 10), hydraulic conductance of egg (kg m-2 s-1 (J/kg)-1), converted from original μg cm-2 min-1 bar-1 |
spec_hyd |
= 0.5, water potential-specific hydration (m3 m-3 (J/kg)-1) |
pct_wet |
= 0.24, percent of surface area acting as a free-water surface for evaporation (%) |
P_e |
= -0.5052209, soil air entry potential (J/kg), derived from soil texture data via the function 'pedotransfer' and used to get soil hydraulic conductivity |
b |
= 1.41005, Campbell's b parameter (-), derived from soil texture data via the function 'pedotransfer' and used to get soil hydraulic conductivity |
K_sat |
= 0.003733307, soil saturated hydraulic conductivity (kg m-1 s-1 (J/kg)-1) derived from soil texture data via the function 'pedotransfer' and used to get soil hydraulic conductivity |
elev |
= 0, elevation (m), needed for properties of air |
vel |
= 0.001, wind speed (m/s) |
Tsoilf |
soil temperature function with time, generated by 'approxfun' (°C) |
Tbf |
body temperature function with time, generated by 'approxfun'(°C) |
RHsoilf |
relative humidity function with time, generated by 'approxfun' (fractional) |
PSIsoilf |
soil water potential with time, generated by 'approxfun' (J/kg) |
m Egg mass (kg)
psi_e Egg water potential (J/kg)
library(NicheMapR)
# egg functional traits
m_init <- 5.8 / 1000 # kg, mass of freshly laid egg
psi_e_init <- -707 # J/kg, water potential of freshly laid egg
shape <- 0.6 # -, ratio of minor axes major axis of ellipsoid (-)
f_air <- 0.5 # -, fraction of egg surface exposed to air
K_e <- 1.12 * 60 * 24 / 1e6 / (3600 * 24 * 10) # kg m-2 s-1 (J/kg)-1, hydraulic conductance of egg
spec_hyd <- 0.0304 / 100 # m3 m-3 (J/kg)-1, water potential-specific hydration, empirically determined from linear model
pct_wet <- 0.25 # %, percent of surface area acting as a free-water surface for evaporation
# get soil properties based on texture
pct_sand <- 99 # %
pct_silt <- 0 # %
pct_clay <- 100 - pct_sand # %
bulkdens <- 1.3 # Mg/m3
soilpro <- matrix(data = c(0, bulkdens, pct_clay, pct_silt, pct_sand), nrow = 1, ncol = 5)
colnames(soilpro) <- c('depth', 'blkdens', 'clay', 'silt', 'sand')
#Now get hydraulic properties for this soil using Cosby et al. 1984 pedotransfer functions.
soil.hydro <- pedotransfer(soilpro = as.data.frame(soilpro), DEP = 0, model = 2)
P_e <- soil.hydro$PE # J/kg
b <- soil.hydro$BB # -
K_sat <- soil.hydro$KS # kg s/m3
t <- seq(0, 24 * 3600 * 150, 24 * 3600) # seconds
elev <- 0 # m, need elevation for air properties
vel <- 0.001 # m/s, wind speed
T_soil <- 29 # deg C, soil temperature
T_egg <- T_soil + 0.15 # deg C, egg temperature
RH_soil <- 0.99 # fractional, relative humidity
PSI_soil <- -100 # J/kg, soil water potential
# use approxfun to create interpolations for the required environmental variables
Tsoilf <- approxfun(t, rep(T_soil, length(t)), rule = 2) # deg C, soil temperature
Tbf <- approxfun(t, rep(T_egg, length(t)), rule = 2) # deg C, body temperature in soil
RHsoilf <- approxfun(t, rep(RH_soil, length(t)), rule = 2) # fractional, relative humidity
PSIsoilf <- approxfun(t, rep(PSI_soil, length(t)), rule = 2) # J/kg, soil water potential
# input parameters
indata <- list(shape = shape, K_e = K_e, spec_hyd = spec_hyd, f_air = f_air, pct_wet = pct_wet, elev = elev, vel = vel, K_sat = K_sat, P_e = P_e, b = b)
# solve
egg_ode <- as.data.frame(deSolve::ode(y = c(m_init, psi_e_init), times = t, func = egg_water, parms = indata))
colnames(egg_ode) = c("time", "m", "psi_e")
# plot results
par(mfrow = c(2, 1))
with(egg_ode, plot(t / (24 * 3600), m * 1000, type = 'l', ylab = 'egg mass, g', xlab = 'time, days', col = 'black'))
with(egg_ode, plot(t / (24 * 3600), psi_e, type = 'l', ylab = 'egg water potential, J / kg', xlab = 'time, days', col = 'black', ylim = c(psi_e_init, PSI_soil)))
abline(h = PSI_soil, lty = 2, col = 'blue')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.