Coffee CO2

Quick Start

How much CO2 is in your coffee after roasting, and how long does it take for you to lose CO2 from your coffee. We have some excellent published data that allows us to show in broad terms what to expect. This is a beta version for comment.

Credits

Based on a paper from a team at Zurich University of Applied Sciences led by Chahan Yeretzian, Time-Resolved Gravimetric Method To Assess Degassing of Roasted Coffee, J. Agric. Food Chem. 2018, 66, 5293−5300.

Coffee CO2

Roast Level
Roast Speed
 t in Days
 Ground
"use strict"
window.onload = function () {
    //restoreDefaultValues(); //Un-comment this if you want to start with defaults

    Main();
};

//Main() is hard wired as THE place to start calculating when inputs change
//It does no calculations itself, it merely sets them up, sends off variables, gets results and, if necessary, plots them.
function Main() {
    //Save settings every time you calculate, so they're always ready on a reload
    saveSettings();

    //Send all the inputs as a structured object
    //If you need to convert to, say, SI units, do it here!
    const inputs = {
        Roast: document.getElementById("Roast").value,
        Speed: document.getElementById("Speed").value,
       Ground: document.getElementById("Ground").checked,
        Days: document.getElementById("Days").checked
   };

    const result = CalcIt(inputs);
     if (result.plots) {
        for (let i = 0; i < result.plots.length; i++) {
            plotIt(result.plots[i], result.canvas[i]);
        }
    }
}
const data={"LightFast":[310,0.96,3.67],"LightMedium":[377,1,3.44],"LightSlow":[326,1,3.57],"MediumFast":[190,0.92,7.34],"MediumMedium":[232,0.99,6.53],"MediumSlow":[270,0.98,5.71],"DarkFast":[153,0.85,12.67],"DarkMedium":[190,0.93,11.16],"DarkSlow":[242,0.96,10.16]}
//Here's the app calculation
function CalcIt({ Roast, Speed, Ground,Days}) {
    let plotCO2 = [], lambda, k
    const theType=Roast+Speed
    const vals=data[theType]
    const Mfact=Ground?0.5:1
    const lfact=Ground?10:1
    let tmax=Ground?200:400
    if (Days) tmax=Ground?240:480
    const tfact=Days?24:1
    for (let i=0;i<=tmax;i++){
            plotCO2.push({x:i/tfact,y:0.1*vals[2]*Mfact*Math.exp(-Math.pow(i/(vals[0]/lfact),vals[1]))})
        }

    if (Ground){

    } else {
     }

    let plotData = [plotCO2]
    const hideLegend=true
    const lineLabels = ["CO2"]
    const myColors = ["green"]
    const borderWidth = [2]
    const xlabel=Days? "t&d":"t&hr"
    //Now set up all the graphing data detail by detail.
    const prmap = {
        plotData: plotData, //An array of 1 or more datasets
        lineLabels: lineLabels, //An array of labels for each dataset
        colors: myColors, //An array of colors for each dataset
        hideLegend: hideLegend,
        borderWidth: borderWidth,
        xLabel: xlabel, //Label for the x axis, with an & to separate the units
        yLabel: 'CO2 w/w&%', //Label for the y axis, with an & to separate the units
        y2Label: null, //Label for the y2 axis, null if not needed
        yAxisL1R2: [], //Array to say which axis each dataset goes on. Blank=Left=1
        logX: false, //Is the x-axis in log form?
        xTicks: undefined, //We can define a tick function if we're being fancy
        logY: false, //Is the y-axis in log form?
        yTicks: undefined, //We can define a tick function if we're being fancy
        legendPosition: 'top', //Where we want the legend - top, bottom, left, right
        xMinMax: [,], //Set min and max, e.g. [-10,100], leave one or both blank for auto
        yMinMax: [,], //Set min and max, e.g. [-10,100], leave one or both blank for auto
        y2MinMax: [,], //Set min and max, e.g. [-10,100], leave one or both blank for auto
        xSigFigs: 'F0', //These are the sig figs for the Tooltip readout. A wide choice!
        ySigFigs: 'F2', //F for Fixed, P for Precision, E for exponential
    };

    //Now we return everything - text boxes, plot and the name of the canvas, which is 'canvas' for a single plot
    return {
        plots: [prmap],
        canvas: ['canvas'],
    };
}
            

Losing CO2

This paper measures CO2 loss gravimetrically, giving great precision. Other methods analyse the CO2 remaining in the bean, for example by releasing the CO2 into a closed box containing a near-IR CO2 detector. Details of results will depend on many factors. Here we take advantage of their data from 3 different roast extents (Light, Medium, Dark) done at 3 different speeds (Fast, Medium, Slow). You can use your knowledge of your own roasts to judge which combination to use.

The loss of CO2 follows a Weibull curve. Starting with an initial concentration C0 the concentration at time t depends on an exponential time constant λ, modified by the "shape parameter" k which for coffee is less than 1, indicating a faster early release, slowing down with time. The paper gives 9 sets of parameters and the app plots data based on your chosen set:

`C_t=C_0exp^(-(t/λ)^k)`

We don't have the constants for the ground coffee so the plots are based on a 50% reduction in initial amount (lost during grinding and before start of measurement) and a 10 fold decrease in λ, meaning a much faster loss.