calcBgVol {biogas}R Documentation

Calculate Cumulative Biogas Production from Volumetric Data

Description

calcBgVol (for calculation of biogas production from volumetric) measurements) calculates cumulative biogas, methane production and production rates from individual volume and composition measurements for any number of bottles.

Usage

calcBgVol(
  # Main arguments
  dat, comp = NULL, temp = NULL,
  pres = NULL, interval = TRUE, 
  data.struct = 'longcombo',
  # Column names
  id.name = 'id', time.name = 'time', vol.name = 'vol',
  comp.name = NULL,
  # Additional arguments
  headspace = NULL, vol.hs.name = 'vol.hs',
  # Calculation method and other settings
  cmethod = 'removed', imethod = 'linear', extrap = FALSE, 
  addt0 = TRUE, showt0 = TRUE,
  dry = FALSE, 
  empty.name = NULL,
  # Warnings and messages
  std.message = !quiet,
  check = TRUE,
  # Units and standard conditions
  temp.std = getOption('temp.std', as.numeric(NA)),
  pres.std = getOption('pres.std', as.numeric(NA)),
  unit.temp = getOption('unit.temp', 'C'),
  unit.pres = getOption('unit.pres', 'atm'),
  quiet = FALSE
  ) 

Arguments

dat

a data frame with bottle identification code; time of measurement (as numeric, or POSIX); and measured biogas volume. See Details section for details on units. Additional columns can be present–these will be returned in the output data frame. See data.struct argument for details on how data frames are structured.

comp

(optional) a data frame with the columns bottle 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 (unless cmethod = "total") or a single numeric value. If omitted, cumulative biogas volume will still be calculated and returned (but no methane data will be returned). The names of these columns are specified with id.name, time.name, and comp.name. Default is NULL.

temp

the temperature at which biogas volume was measured. A length-one numeric vector. Degrees Celcius by default (see unit.temp argument). Default is NULL, which suppresses correction for temperature and pressure.

pres

the absolute pressure at which biogas volume was measured. A length-one numeric vector or a character vector giving the name of the column in dat with the pressure measurements. Atmospheres by default (see unit.pres argument). Default is NULL, which suppresses correction for temperature and pressure.

interval

do biogas volume measurements represent production only from the time interval between observations (default)? interval = FALSE means measured gas volume is cumulative. Default is TRUE.

data.struct

the structure of input data. The default of 'longcombo' means separate objects for volume and composition (if available). The dat data frame must have bottle identification code and time columns with names specified with id.name and time.name, volume data in a single column with the name specified by vol.name, and biogas composition in a single column with the name specified by comp.name For the data.struct = 'long' option, two separate data frames are needed, one for volume and one for composition (if available). Each data frame must have bottle identification code and time columns with names specified with id.name and time.name. The dat data frame must have volume data in a single column with the name specified by vol.name. The comp data frame must have biogas composition in a single column with the name specified by comp.name. For the data.struct = 'wide' option, two separate data frames are needed as in 'long', but there are no bottle identification code columns. Instead, in dat, volume data are in a separate column for each bottle, and column names are bottle identification codes. Here, vol.name should be the name of the first column with volume data. All following columns are assumed to also have volume data. And in comp, biogas composition data are also in a separate column for each bottle, also with bottle identification codes for column names. Here, comp.name should be the name of the first column with biogas composition data, as for dat.

id.name

name of the bottle identification code column in dat. Must 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".

vol.name

name of column containing the primary response variable (as-measured volume) in dat data frame. Default is vol.

comp.name

name of column containing biogas mole fraction of methane in comp data frame. Default is "xCH4". Must be normalised so xCH4 + xCO2 = 1.0 unless cmethod = "total".

headspace

(optional) a data frame or length-one numeric vector with bottle headspace volume(s). If a data frame is used, it should at least contain a "id" (bottle identification code) column (see "id.name") and headspace volume column (see vol.hs.name argument). Required if cmethod = "total". Default is NULL.

vol.hs.name

name of column containing headspace volume data in optional headspace data frame. Default is "vol.hs".

cmethod

method for calculating cumulative methane production. Use "removed" to base production on xCH4 and gas volumes removed (default). Use "total" to base it on the sum of methane removed and methane remaining in the bottle headspace. For "removed", xCH4 should be calculated based on methane and CO2 only (xCH4 + xCO2 = 1.0). For "total", xCH4 should be calculated including all biogas components (CH4, CO2, N2, H2S, etc.) except water. Length one character vector.

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 interpolation.

extrap

should comp.name be extrapolated? Length one logical vector. This is passed as the extrap argument to interp. Default is FALSE.

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 bottle in order to calculate production rates for the first observation. This addition is only made when time.name is numeric (or integer). Length-one logical vector. Default is TRUE. To return these additional rows in the output, see showt0.

showt0

should “time zero” rows be returned in the output? Can be convenient for plotting cumulative volumes. 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 addt0). Default value depends on dat time.name column content. If time.name column is numeric and contains 0 then the default value is TRUE and otherwise FALSE.

dry

set to TRUE if volume data are standardised to dry conditions (e.g., AMPTS II data). The default (FALSE) means biogas is assumed to be saturated with water vapor.

empty.name

column containing a binary (logical, or integer or numeric (1 or 0)) variable indicating when accumulated biogas was emptied. Use for mix of cumulative/interval data. If used, interval is ignored.

std.message

should a message with the standard conditions be displayed? Default is TRUE.

check

should input data be checked for unreasonable values (with warnings)? Currently only composition values are checked. Default is TRUE. Values are changed if outside 0, 1 (divided by 100).

temp.std

standard temperature for presentation of biogas and methane results. Length one numeric vector. Default value is 0 degrees C (set in stdVol). Argument is passed to stdVol.

pres.std

standard pressure for presentation of biogas and methane results. Length one numeric vector. Default value is 1.0 atm (101325 Pa) (set in stdVol). Argument is passed to stdVol.

unit.temp

temperature units for temp and temp.std arguments. Default is "C". Argument is passed to stdVol.

unit.pres

pressure units for pres and pres.std arguments. Default is "atm". Argument is passed to stdVol.

quiet

use to suppress messages. Default is FALSE.

Details

Using volume data from dat and gas composition from comp, this function will calculate standardised 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. All volumes (input and output) have the same units, e.g., mL, L, SCF.

Biogas composition (comp.name column in comp) is specified as the mole fraction of methane in dry biogas, normalised so mole fractions of methane and carbon dioxide sum to unity (Richards et al. 1991). Alternatively, if cmethod is set to "total", biogas composition is the mole fraction of methane in dry biogas (include all the other gases except water).

Standard values and units for temperature and pressure can be globally set using the function options. See stdVol. To surpress volume correction to a “standard” temperature and pressure, leave temp as NULL (the default).

If check = TRUE, the input values of mole fraction of methane in biogas are checked, and a warning is returned if the are outside 0, 1.

See associated vignette (calcBgVol_function.Rnw) for more information.

Value

a data frame with all the columns originally present in dat, plus these others:

vBg

Standardised volume of biogas production for individual event.

xCH4

Interpolated mole fraction of methane in biogas.

vCH4

Standardised volume of methane production for individual event. Only if comp is provided.

vhsCH4

Standardised volume of methane present in bottle headspace. Only if method = "total" is used.

cvBg

Standardised cumulative volume of biogas production.

cvCH4

Standardised cumulative volume of methane production. Only if comp is provided.

rvBg

Production rate of biogas.

rvCH4

Production rate of methane. Only if comp is provided.

Author(s)

Sasha D. Hafner and Nanna Lojborg

References

Hafner, S.D., Rennuit, C., Triolo, J.M., Richards, B.K. 2015. Validation of a simple gravimetric method for measuring biogas production in laboratory experiments. Biomass and Bioenergy 83, 297-301.

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

cumBg, calcBgMan, calcBgGD, summBg, interp, stdVol, options

Examples

 
# Example with long structured input data frame

data("s3lcombo")
s3lcombo

# Calculate cumulative production and rates from s3lcombo
# With default data structure comp argument is not needed
# Necessary to extrapolate because first observations are missing xCH4
cbg <- calcBgVol(s3lcombo, 
                 temp = 25, pres = 1,
                 id.name = 'id', time.name = 'time.d', 
                 vol.name = 'vol.ml', comp.name = 'xCH4', 
                 extrap = TRUE)
head(cbg)

# Plot results
## Not run: 
  # Not run just because it is a bit slow
  ggplot(cbg, aes(time.d, cvCH4, colour = id)) + 
         geom_point() + geom_line(aes(group = id)) +
         labs(x = "Time (d)", y = "Cumulative methane production  (mL)", colour = "Bottle ID")  + 
         theme_bw() 

  plot(ggplot)

## End(Not run)


# Wide data structure, from AMPTS II in this case
data("feedVol")
head(feedVol)

# By default biogas is assumed to be saturated with water vapor
# Composition is set to a single value. 
# Data are cumulative
args(calcBgVol)
cbg <- calcBgVol(feedVol, comp = 1, temp = 0, pres = 1,
                 interval = FALSE, data.struct = 'wide',
                 id.name = "id", time.name = 'time.d', vol.name = '1', 
                 dry = TRUE)

head(cbg)


# Calculate cumulative production and rates from vol and comp
# Biogas volume and composition can be in separate data frames
data("vol")
data("comp")

head(vol)
head(comp)

# extrap = TRUE is needed to get CH4 results here because first xCH4 values are missing
cbg <- calcBgVol(vol, comp = comp, temp = 20, pres = 1, 
                 data.struct = "long",
                 id.name = "id", time.name = "days", comp.name = "xCH4", 
                 vol.name = "vol", extrap = TRUE)

head(cbg)



[Package biogas version 1.23.2 Index]