calcBgGD: Calculate Biogas Production from Gas Density Data (GD-BMP)

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/calcBgGD.R

Description

calcBgGD (for calculate biogas from GD (gas density) measurements) calculates cumulative biogas, methane production and production rates from mass loss and volume measurements for any number of bottles.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
calcBgGD(
  # Main arguments
  dat, 
  temp.vol,
  temp.grav,
  pres.vol,
  pres.grav,
  # Column names
  id.name, 
  time.name, 
  vol.name,
  m.pre.name = NULL,
  m.post.name,
  comp.name = 'xCH4',       
  # Settings
  vented.mass = FALSE,
  averaging = 'final',  
  temp.init = NULL,       
  pres.init = NULL,      
  headspace = NULL,     
  vol.hs.name = NULL,  
  headcomp = 'N2',    
  # Calculation method and other settings
  vmethod = 'vol',   
  comp.lim = c(0, 1), 
  comp.sub = NA,     
  imethod = 'linear',
  extrap = FALSE,
  addt0 = TRUE,
  showt0 = TRUE,
  dry = FALSE,
  # Warnings and messages
  std.message = TRUE,
  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')
  ) 

Arguments

dat

a data frame with bottle identification code, time of measurement (as numeric, or POSIX), bottle mass, 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.

temp.vol

temperature at which biogas volume was measured.

temp.grav

temperature of bottle headspace at time of biogas venting, prior to gravimetric measurement.

pres.vol

pressure at which biogas volume was measured.

pres.grav

pressure of bottle headspace at time of biogas venting, prior to gravimetric measurement.

id.name

name of the bottle identification code column in dat. Must be the same in all data frames used in the function.

time.name

name of column containing time data (cumulative time) in dat.

vol.name

name of the measured biogas volume column in dat.

m.pre.name

name of column containing pre-venting bottle mass in dat data frame. Optional, required for vented.mass = TRUE and to calculate leakage.

m.post.name

name of column containing post-venting bottle mass in dat data frame. See details.

comp.name

name of column with biogas composition to be added to output data frame.

vented.mass

Set to TRUE to use vented mass loss (GD_v method) instead of total mass loss (GD_t method) in calculations. See details.

averaging

type of averaging used for calculating biogas composition. Default is final. See details.

temp.init

optional initial headspace temperature. Used to correct results for initial headspace. See details.

pres.init

optional initial headspace pressure. Used to correct results for initial headspace. See details.

headspace

optional data frame or length-one numeric vector with reactor headspace volume(s). 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 argument). Required if cmethod = "total". Default is NULL.

vol.hs.name

optional name of column containing headspace volume data in optional headspace data frame.

headcomp

optional initial headspace composition used to correct results for initial headspace. Default of "N2" is only logical value.

vmethod

method used for calculating biogas volume. Default of 'vol' is based on measured biogas volume in vol.name column. Alternative is 'grav' for gravimetric method, which should be used with vented.mass = TRUE.

comp.lim

acceptable limits on calculated methane mole fraction. Any values outside of this range are set to comp.sub. Default of c(0, 1). Length two vector.

comp.sub

Value substituted in for calculated methane mole fraction when calculated value is outside of comp.lim range. Length one vector. Default value of NA should generally never be changed.

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 reactor 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 standardized to dry conditions. The default (FALSE) means biogas is assumed to be saturated with water vapor.

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" for degrees Celcius. Argument is passed to stdVol.

unit.pres

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

Details

Using volume and mass loss data from dat, this function will calculate standardized biogas and methane production for each observation using the gas density (GD) method. See reference below for details on the method.

Standard values and units for temperature and pressure can be globally set using the function options. See stdVol.

Value

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

vBg

Standardized volume of biogas production for individual event.

xCH4

Calculated mole fraction of methane in biogas.

vCH4

Standardized volume of methane production for individual event.

cvBg

Standardized cumulative volume of biogas production.

cvCH4

Standardized cumulative volume of methane production.

rvBg

Production rate of biogas.

rvCH4

Production rate of methane.

Units are based on units in input data.

Author(s)

Sasha D. Hafner, Camilla Justesen, Jacob Mortensen

References

Justesen, C.G., Astals, S., Mortensen, J.R., Thorsen, R., Koch, K., Weinrich, S., Triolo, J.M., Hafner, S.D. 2019. Development and validation of a low-cost gas density method for measuring biochemical potential (BMP) Water (MDPI) 11(12): 2431.

See Also

calcBgMan, calcBgVol, summBg, interp, stdVol, options

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
 

data("UQGDBiogas")
data("UQGDSetup")

head(UQGDBiogas)
head(UQGDSetup)

cbg <- calcBgGD(UQGDBiogas,
                temp.vol = 20, pres.vol = 1013.25,
                temp.grav = 30, pres.grav = 1500,
                id.name = 'id', vol.name = 'vol',
                m.pre.name = 'mass.init', m.post.name = 'mass.final',
                time.name = 'time.d', unit.pres = 'mbar')


BMP <- summBg(cbg, UQGDSetup, id.name = "id",
              time.name = 'time.d', descrip.name = 'descrip',
              inoc.name = "Inoculum", inoc.m.name = "m.inoc", norm.name = "m.sub.vs",
              when = 'end')

BMP

biogas documentation built on Jan. 8, 2020, 5:08 p.m.