Learn R Programming

biogas (version 1.0.1)

cumBg: Calculate Cumulative Biogas Production

Description

cumBg (for cumulative biogas) calculates cumulative biogas, methane production and production rates from individual volume and composition measurements for any number of reactors.

Usage

cumBg(dat, dat.type="vol", comp="NULL", temp="NULL", pres = 1, id.name="id", 
      time.name="time",dat.name=dat.type, comp.name="xCH4", headspace=NULL, 
      vol.hs.name="vol.hs", temp.std = NULL, pres.std = NULL, unit.pres = "atm", 
      unit.temp = "C", cmethod = "removed", imethod = "linear", extrap = FALSE, 
      addt0= TRUE, showt0 = if(any(dat[,time.name]==0)) TRUE else FALSE)

Arguments

dat
a data frame with the columns reactor identification code; time of measurement (as numeric, or POSIX); and measured biogas volume or total reactor mass, in g (see dat.type argument). The names of these columns c
dat.type
the type of data contained in dat. Value can be "vol" if the data is measured biogas volume or "mass" if the reactor masses are used. Default is "vol".
comp
(optional) a data frame with the columns reactor identification code; time of measurement, (as numeric, or POSIX); and methane concentration within dry biogas as a mole fraction, considering only methane and carbon dioxide (unles
temp
the temperature at which biogas volume was measured (when dat.type="vol"), or of biogas as it exited the reactor (when dat.type="mass"). A length-one numeric vector. Degrees Celcius by default (see unit.temp
pres
the pressure at which biogas volume was measured (when dat.type="vol"), or of biogas as it exited the reactor (when dat.type="mass"). A length-one numeric vector. Presure is set to 1 atmosphere (atm) by default (see
id.name
name of the reactor identification code column in dat. Should be the same in all data frames used in the function. Default is "id".
time.name
name of column containing time data in dat and comp data frames. Default is "time".
dat.name
name of column containing the data in dat data frame. Default is dat.type value. See dat.type argument.
comp.name
name of column containing gas composition data in comp data frame. Default is "xCH4".
headspace
an optional data frame or numeric vector with reactor headspace volumes. If a data frame is used, it should at least contain a "id" (reactor identification code) column (see "id.name") and headspace volume column (see
vol.hs.name
name of column containing headspace volume data in optional headspace dataframe. Default is "vol.hs".
temp.std
standard temperature for presentation of biogas and methane results. Default value is 0 degrees C. See stdVol. Length one numeric vector.
pres.std
standard pressure for presentation of biogas and methane results. Default value is 1.0 atm. See stdVol. Length one numeric vector.
unit.pres
pressure units for pres and pres.std arguments. Options are "atm", "Pa", "kPa", "hPa", and "bar". Default is "atm".
unit.temp
temperature units for temp and temp.std arguments. Options are "C" (degrees Celcius), "F" (degrees Fahrenheit), and "K" (Kelvin). Default is "C". See
cmethod
the method for calculating cumulative methane production. Use "removed" to base production on xCH4 and gas volumes removed. Use "total" to base it on the sum of methane removed and methane remaining in the
imethod
method used for interpolation of xCH4. This is passed as the method argument to interp. Length one character vector. Default is linear for linear interpolatio
extrap
should comp.name be extrapolated? Set to TRUE if extrapolation wanted. Length one logical vector. This is passed as the extrap argument to interp.
addt0
is the earliest time in dat data frame ``time zero'' (start time)? If not, this argument adds a row with time.name=0 for each reactor in order to calculate production rates for the first observation. This addition is o
showt0
should ``time zero'' rows be returned in the output? Only applies if time.name is numeric (or integer). These rows may have been present in the original data (dat) or added by the function (see

Value

  • cumBg returns a data frame with all the columns originally present in dat, plus these others:
  • vBgNormalized volume of biogas production for individual event.
  • xCH4Interpolated mole fraction of methane in biogas.
  • vCH4Normalized volume of methane production for individual event. Only if comp is provided.
  • cvBgNormalized cumulative volume of biogas production.
  • cvCH4Normalized cumulative volume of methane production. Only if comp is provided.
  • rvBgProduction rate of biogas.
  • rvCH4Production rate of methane. Only if comp is provided.

concept

biogas

Details

Using volume or mass data from dat and, optionally, gas composition from comp, this function will calculate normalized biogas and methane production (if comp is provided) for each observation, interpolating comp.name (from comp argument) to each time.name in dat if needed, and summing these for cumulative values. Use of volumetric measurements is the default case. Alternatively, if reactor mass is included in dat, a gravimetric approach (Hafner et al. in review) can be applied by setting dat.type to "mass". In this case, to determine total cumulative biogas production for batch reactors, an initial mass should be included for each reactor. All volumes (input and output) have the same units, e.g., mL, L, SCF. To surpress volume correction to a 'standard' temperature and pressure, leave temp as NULL (the default).

References

Hafner, S.D., Rennuit, C., Triolo, J.M., Richards, B.K. In review. A gravimetric method for measuring biogas production. Biomass and Bioenergy. Richards, B.K., Cummings, R.J., White, T.E., Jewell, W.J. 1991. Methods for kinetic analysis of methane fermentation in high solids biomass digesters. Biomass and Bioenergy 1: 65-73.

See Also

summBg, interp, stdVol

Examples

Run this code
data("vol")
data("comp")
head(vol)
head(comp)
# Example using extrapolation
cumBg(vol,temp=20,comp=comp,time.name="days",extrap=TRUE)
# Compare to extrap=FALSE (default)
cumBg(vol,temp=20,comp=comp,time.name="days")
# Time 0 was assumed to be at days=0 (default addt0 argument), can show this row
cumBg(vol,temp=20,comp=comp,time.name="days",extrap=TRUE,showt0=TRUE)
# Leave out composition data
cumBg(vol,temp=20,time.name="days",extrap=TRUE)

# Example with different column names
data(vol2)
data(comp2)
head(vol2)
head(comp2)
cumBg(vol2,temp=20,comp=comp2,id.name="bottle",time.name="days",dat.name="meas.vol",
      comp.name="CH4.conc",extrap=TRUE)

# Mass example
data("mass")
mass
cumBg(mass,dat.type="mass",temp=38,comp=comp,time.name="days")
cumBg(mass,dat.type="mass",temp=38,comp=comp,time.name="days",showt0=FALSE)

Run the code above in your browser using DataLab