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 |
comp |
(optional) a data frame with the columns bottle identification code; time of measurement, (as |
temp |
the temperature at which biogas volume was measured.
A length-one numeric vector.
Degrees Celcius by default (see |
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 |
interval |
do biogas volume measurements represent production only from the time interval between observations (default)?
|
data.struct |
the structure of input data. The default of 'longcombo' means separate objects for volume and composition (if available).
The |
id.name |
name of the bottle identification code column in |
time.name |
name of column containing time data in |
vol.name |
name of column containing the primary response variable (as-measured volume) in |
comp.name |
name of column containing biogas mole fraction of methane in |
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 |
vol.hs.name |
name of column containing headspace volume data in optional |
cmethod |
method for calculating cumulative methane production.
Use |
imethod |
method used for interpolation of |
extrap |
should |
addt0 |
is the earliest time in |
showt0 |
should “time zero” rows be returned in the output?
Can be convenient for plotting cumulative volumes.
Only applies if |
dry |
set to |
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, |
std.message |
should a message with the standard conditions be displayed?
Default is |
check |
should input data be checked for unreasonable values (with warnings)?
Currently only composition values are checked.
Default is |
temp.std |
standard temperature for presentation of biogas and methane results.
Length one numeric vector.
Default value is 0 degrees C (set in |
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 |
unit.temp |
temperature units for |
unit.pres |
pressure units for |
quiet |
use to suppress messages. Default is |
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 |
vhsCH4 |
Standardised volume of methane present in bottle headspace. Only if |
cvBg |
Standardised cumulative volume of biogas production. |
cvCH4 |
Standardised cumulative volume of methane production. Only if |
rvBg |
Production rate of biogas. |
rvCH4 |
Production rate of methane. Only if |
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)