calcBgMan {biogas} | R Documentation |
Calculate Cumulative Biogas Production from Pressure Data
Description
calcBgMan
(for cumulative biogas manometric) calculates cumulative biogas, methane production and production rates from individual pressure and composition measurements for any number of reactors.
Usage
calcBgMan(
# Main arguments
dat, comp = NULL, temp, interval = TRUE,
data.struct = 'longcombo',
# Column names
id.name = 'id', time.name = 'time',
pres.name = 'pres', comp.name = NULL,
# Additional arguments
pres.resid = NULL, temp.init = NULL, pres.init = NULL,
rh.resid = NULL,
rh.resid.init = 1, headspace = NULL,
vol.hs.name = 'vol.hs',
absolute = TRUE, pres.amb = NULL,
# Calculation method and other settings
cmethod = 'removed', imethod = 'linear', extrap = FALSE,
addt0 = TRUE, showt0 = TRUE,
# 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 reactor identification code; time of measurement (as |
comp |
(optional) a data frame with the columns reactor identification code; time of measurement, (as |
temp |
the temperature at which headspace pressure was measured.
A length-one numeric vector or length-one character vector referring to a column in |
interval |
do biogas pressure measurements represent production only from the time interval between observations (default)?
|
data.struct |
the structure of input data. The default of 'longcombo' means headspace pressure and composition in a single column.
The |
id.name |
name of the reactor identification code column in |
time.name |
name of column containing time data in |
pres.name |
name of column containing the primary response variable (pressure) in |
comp.name |
name of column containing biogas mole fraction of methane in |
pres.resid |
headspace pressure after venting.
Either a single numeric value, assumed to be the same for all observations, or the name of a column in |
temp.init |
initial headspace temperature in |
pres.init |
headspace pressure at the begining of the experiment.
Can be absolute (default) or gauge depending on the value of |
rh.resid |
relative humidity of the gas in the headspace after venting. If NULL (default), it is calculated for each interval as the ratio of post- to pre-venting pressure (equivalent to assuming relative water vapor concentration (mixing ratio) is the same before and after venting. If entered, typically should be 1.0. Length one numeric vector. |
rh.resid.init |
relative humidity of the gas in the headspace at the begining of the experiment. Typically should be 1.0 (the default). Length one numeric vector. |
headspace |
(optional) a data frame or length-one numeric vector with reactor 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 |
absolute |
is the headspace pressure measured ( |
pres.amb |
absolute ambient pressure needed to calculate absolute pressure from gauge pressure measurements.
In atmospheres by default (see |
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 |
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 pressure 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.
Inputs units are specified with unit.pres
, and output volumes are the same as headspace volume, e.g., mL or L.
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 (calcBgMan_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 reactor 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.
Hansen, T.L., Schmidt, J.E., Angelidaki, I., Marca, E., Jansen, J. la C., Mosbak, H. and Christensen, T.H. 2004. Method for determination of methane potentials of solid organic waste. Waste Management 24, 393-400
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
,
calcBgVol
,
calcBgGD
,
summBg
,
interp
,
stdVol
,
options
Examples
# Example with longcombo structured input data frame
data("sludgeTwoBiogas")
data("sludgeTwoSetup")
head(sludgeTwoBiogas)
head(sludgeTwoSetup)
# Calculate cumulative production and rates
# Pressure is gauge (not absolute) so absolute argument needed
# Data structure is default of longcombo
cbg <- calcBgMan(sludgeTwoBiogas, temp = 30,
id.name = "id", time.name = "time.d",
pres.name = "pres", comp.name = "xCH4n",
temp.init = 30, pres.resid = 0, pres.init = 0,
headspace = sludgeTwoSetup, vol.hs.name = "vol.hs",
pres.amb = 1013, absolute = FALSE,
unit.pres = "mbar")
head(cbg)
# Plot results
## Not run:
# Not run just because it is a bit slow
library(ggplot2)
ggplot(cbg, aes(time.d, cvCH4, colour = factor(id))) +
geom_point() +
geom_line(aes(group = id)) +
labs(x = "Time (d)", y = "Cumulative methane production (mL)", colour = "Bottle id") +
theme_bw()
## End(Not run)
# This sludgeTwoBiogas dataset has original xCH4 as well as normalized values
# So "method 2" can also be used by changing comp.name and cmethod arguments
cbg2 <- calcBgMan(sludgeTwoBiogas, temp = 30,
id.name = "id", time.name = "time.d",
pres.name = "pres", comp.name = "xCH4",
temp.init = 30, pres.resid = 0, pres.init = 0,
headspace = sludgeTwoSetup, vol.hs.name = "vol.hs",
pres.amb = 1013, cmethod = 'total', absolute = FALSE,
unit.pres = "mbar")
head(cbg2)
# Compare
quantile(cbg2$vCH4 - cbg$vCH4)
# Median difference of 0.2 mL
# Example with long structured input data frame
data("strawPressure")
data("strawComp")
data("strawSetup")
# Need to specify data structure with \code{data.struct} argument
# Using default values for time.name, pres.name
cbg <- calcBgMan(strawPressure, comp = strawComp, temp = 31,
data.struct = "long",
id.name = "bottle", comp.name = "xCH4",
temp.init = 21.55, pres.resid = "pres.resid", pres.init = 0,
headspace = strawSetup, vol.hs.name = "headspace",
pres.amb = 101.3, absolute = FALSE,
unit.pres = "kPa")
# Because of missing composition measurements at last time for some bottles
# CH4 volume will be missing
# Can estimate xCH4 here by extrapolation using argument of same name
cbg2 <- calcBgMan(strawPressure, comp = strawComp, temp = 31,
data.struct = "long",
id.name = "bottle", comp.name = "xCH4",
temp.init = 21.55, pres.resid = "pres.resid", pres.init = 0,
headspace = strawSetup, vol.hs.name = "headspace",
pres.amb = 101.3, absolute = FALSE,
extrap = TRUE, unit.pres = "kPa")
# For example with wide structured input data frame calcBgVol() help file