Defines functions getSchmidt

Documented in getSchmidt

#'@title Returns Schmidt number for a specific gas at a given temperature
#'Schmidt number is temperature dependant, and is the ratio of the kinematic viscosity of water 
#'to a diffusion coefficient. Coefficients are included for He, O2, CO2, CH4, SF6, N2O, Ar, and N2.\cr
#'getSchmidt(temperature, gas)
#'@param temperature Numeric vector of water temperatures in deg. Celsius
#'@param gas String for gas code. Valid inputs include: He, O2, CO2, CH4, SF6, N2O, Ar, and N2
#'@return Schmidt number (unitless)
#'@note Temperature range is only valid from 4-35 deg Celsius
#'@keywords methods math
#'Raymond, Peter A., Christopher J. Zappa, David Butman, Thomas L. Bott, Jody Potter, Patrick Mulholland, 
#'Andrew E. Laursen, William H. McDowell, and Denis Newbold. \emph{Scaling the gas transfer velocity and hydraulic 
#'geometry in streams and small rivers}. Limnology & Oceanography: Fluids & Environments 2 (2012): 41-53.
#'Jordan S. Read
#'getSchmidt(temperature=12, gas="O2")
getSchmidt	<-	function(temperature, gas){
	range.t	<-	c(4,35) # supported temperature range
	Schmidt	<-	data.frame(
	obsT <- is.finite(temperature) # logical for observed (not NA or NaN [or Inf or -Inf]) -RDB
	if (!is.character(gas)){stop(paste('gas must be a character. was given as',gas))}
	if (length(gas)>1){stop("only one gas can be specified for this version")}
	if (!any(names(Schmidt)==gas)){stop(paste(gas,'not found in list of coded gasses'))}
	if (any(temperature[obsT] < range.t[1] | temperature[obsT] > range.t[2])){ # This logical threw an error if any temperature were NA (or NaN, etc.) -RDB
		warning("temperature out of range")
	A	<-	unlist(Schmidt[gas])[1]
	B	<-	unlist(Schmidt[gas])[2]
	C	<-	unlist(Schmidt[gas])[3]
	D	<-	unlist(Schmidt[gas])[4]

	Sc = as.numeric(A+B*temperature+C*temperature^2+D*temperature^3)


Try the LakeMetabolizer package in your browser

Any scripts or data that you put into this service are public.

LakeMetabolizer documentation built on Nov. 16, 2022, 1:09 a.m.