Measuring Density with Gas Pycnometry

In my very first post, I mentioned several ways of measuring density. Since then, I’ve talked quite a bit about measuring the density of a tamped puck, but there are a few reasons I’d like to be able to measure the “true density”, i.e., the density of the beans themselves:

  • This is something we could use to characterize a new bag of beans before we’ve put anything into the grinder. Potentially, this could save time dialing in the shot.
  • True density is closely related to the microscopic properties of the bean. We could use this value to check some of the tamped puck density results, and also for new research.

The simplest method of measuring true density is by measuring the volume of water an object displaces, e.g., using a calibrated glass pycnometer. However, measuring density in this way would leave the beans wet—something I’d like to avoid. There are also complications if the beans absorb some of the water.

Another option is gas pycnometry. With gas pycnometry, we measure the volume of gas surrounding the object. We can use this information to derive the volume of the object itself.

How It Works

Gas pycnometers make use of a property of gasses which can be expressed as Boyle’s law:

    \[P \propto \frac{1}{V}\]

Put simply, Boyle’s law states that the when the volume of a gas increases, its pressure decreases in proportion.

Imagine we have a cylindrical chamber, filled with gas, with one wall formed by a movable piston. The pressure and volume of the gas are given by P_a and V_a respectively.

Now we draw back the piston to increase the volume of the chamber without adding more gas. The new pressure is P_b and the new volume is V_b = V_a + \Delta V.

Using Boyle’s law, we can calculate the original volume of gas as follows:

    \[V_a &= \frac{\Delta V}{P_a / P_b - 1}\]

Notice that we only need to know three things:

  • The change in the volume of the gas
  • The starting pressure
  • The ending pressure

This means we can calculate the volume of gas in an irregularly shaped chamber—e.g., one containing a solid sample—provided we can produce a known change in volume.

If we measure the volume of gas in this way, once with the chamber empty, and once with our sample in the chamber, we can take the difference to get the volume of the sample.


There are two main types of gas pycnometer:

  • A gas expansion pycnometer uses two chambers, with gas expanding from one chamber into the other.
  • A variable volume pycnometer uses a single chamber whose volume can be varied using a mechanical piston.

In this post, we’re going to look at a variable volume pycnometer built using a handful of easy to find parts:

Here’s what the assembled pycnometer looks like:

The construction of the pycnometer is pretty straightforward, but there are a couple of things that can be done to make it more accurate.

First, the plunger on the syringe is made of separate rubber and plastic pieces. If these are left as is, the rubber part will expand into the sample chamber like a balloon when we pull the plunger back. To prevent this, I sanded the mating surface of the two parts lightly, then used Gorilla epoxy to bond them.

Second, I’ve constructed spacers using angled cardboard pieces I had lying around. I cut these so that the plunger roughly lines up with the 10 ml lines on the syringe when the spacer is installed as shown in the photo above. This allows me to set the plunger to a precise position, and makes it a lot easier to read the pressure gauge.

One at a time, I installed each spacer in the syringe, measured the length of the gap the spacer fills, and subtracted the length of that gap when no spacer is installed. This gives me a displacement relative to the empty syringe:

    \[\begin{gathered}\text{Displacement} = \text{Length with spacer}\,- \\\text{Length without spacer}\end{gathered}\]

I then multiplied by the cross-sectional area of the syringe to get an accurate and repeatable volume measurement:

    \[\text{Volume} = \text{Area} \times \text{Displacement}\]

In the case of the syringes I’m using here, the cross-sectional area is actually 1000 mm2, so the displacement in mm is the same as the volume in ml.

Finally, I wrote this volume measurement on each spacer. This way, I don’t have to look anything up when I’m making volume measurements.

How to Measure

We start by measuring the mass of the coffee beans, 13.70 g, and the ambient air pressure, 89.9 kPa.

We can get the ambient air pressure using either a barometer or a nearby weather station. In either case, be aware that the figure we’re looking for is station pressure, not barometric pressure. There is an excellent article here which describes the difference between the two.

Next, I measure the volume of gas in the empty syringe. To do this, I install the plunger and push it all the way in. Then I connect the syringe to the pressure gauge. Finally, I install the 10 ml cardboard spacer, which in my case is labelled as 10.24 ml. The pressure gauge reads -17.1 inHg (-57.9 kPa).

The pressure gauge measures relative to the ambient pressure, but what we really want is absolute pressure. This is easy enough to calculate:

    \[P_{\text{absolute}} = P_{\text{ambient}} + P_{\text{gauge}}\]

If you’re wondering why I have a cloth under the pressure gauge, it’s there to give a little padding under the gauge, and also to prevent it from slipping when I’m pulling the pycnometer apart. Early on, I had an incident while disassembling the pycnometer, and the gauge went skittering off the edge of the counter. These are fairly sensitive instruments, and when I picked it up the “zero” had moved. It is possible to pry the gauge open and re-zero it, but as they say an ounce of prevention is worth a pound of cure.

Now we measure the volume of gas with the sample in place. I disassemble the pycnometer, pour in the beans, give a little shake to settle them, then push the plunger in so it touches the top of the sample. Ideally, you want as little “dead space” in the sample chamber as possible, so, if you can, it’s best to adjust your sample size so the plunger is close to the sample when one of the spacers is installed.

The plunger sits just below the 40 ml line, so we’ll use the spacer labeled as 40.03 ml as a starting point. I install the spacer, squeeze the plunger to hold it in place, and connect the pressure gauge.

The pressure gauge is most accurate in the middle third of its range, so for the next step we want to choose another spacer which drops the pressure to around -15 inHg. In my case, the cardboard spacer labeled as 79.28 ml gets me to -15.6 inHg (-52.8 kPa), which is pretty good.

The table below summarizes the data we’ve collected:

Mass13.70 g
P_089.9 kPa
V_{1,\text{empty}}0 ml
V_{2,\text{empty}}10.24 ml
P_{2,\text{empty}}P_0 – 57.9 kPa = 32.0 kPa
V_{1,\text{sample}}40.03 ml
V_{2,\text{sample}}79.28 ml
P_{2,\text{sample}}P_0 – 52.8 kPa = 37.1 kPa

From this, we first calculate the volume of gas in the empty syringe as follows:

    \[\begin{aligned}V_{\text{empty}} &= \frac{V_{2,\text{empty}} -  V_{1,\text{empty}}}{P_0 / P_{2,\text{empty}} - 1} \\&= \frac{(10.24\,\text{ml}) - (0\,\text{ml})}{(89.9\,\text{kPa}) / (32.0\,\text{kPa}) - 1} \\&= 5.66\,\text{ml}\end{aligned}\]

V_{\text{empty}} represents the amount of “dead space” in the syringe, fittings, and pressure gauge. If you don’t change the configuration of the pycnometer, you should be able to use the same value for future measurements.

Now let’s calculate the volume of gas with the sample in place:

    \[\begin{aligned}V_{\text{sample}} &= \frac{V_{2,\text{sample}} -  V_{1,\text{sample}}}{P_0 / P_{2,\text{sample}} - 1} \\&= \frac{(79.28\,\text{ml}) - (40.03\,\text{ml})}{(89.9\,\text{kPa}) / (37.1\,\text{kPa}) - 1} \\&= 27.58\,\text{ml}\end{aligned}\]

We calculate the volume of the beans by taking the volume of the empty sample chamber the beans sit in, then subtracting the volume of gas in that chamber. There’s a little trick here… We know the volume of the empty syringe with the plunger pushed all the way in, but not when it’s pulled out to the starting position when the beans are in place. To make this adjustment, we add V_{1,\text{sample}} to V_{\text{empty}}.

Thus, we can calculate the volume of the beans as follows:

    \[\begin{aligned}\text{Volume} &= V_{\text{empty}} + V_{1,\text{sample}} - V_{\text{sample}} \\&= (5.66\,\text{ml}) + (40.03\,\text{ml}) - (27.58\,\text{ml}) \\&= 18.11\,\text{ml}\end{aligned}\]

Finally, we calculate the true density of the beans:

    \[\begin{aligned}\text{Density} &= \text{Mass} / \text{Volume} \\&= (13.70\,\text{g}) / (18.11\,\text{ml}) \\&= 0.7565\,\text{g}/\text{ml}\end{aligned}\]

This result is consistent with results reported in the literature. For example, Rodrigues et al. report particle densities of 550-755 kg/m3 (0.550-0.755 g/ml) for light to medium roast coffee.


How accurate are these results? It would be difficult to confirm the accuracy using coffee beans, so instead we use 3/8″ steel shot. The great thing about steel shot is that we can measure its volume using at least two other methods to compare with the result we just got:

  • We can measure how much water the steel shot displaces.
  • We can measure the diameter of the steel shot, then calculate its volume.

Using these methods I was able to determine the following volumes for a single ball:

  • Water displacement: 460.0 ± 3.5 mm3
  • Based on diameter: 454.2 ± 4.3 mm3

To measure the volume using our gas pycnometer, we follow the same procedure we used above, but using steel shot in place of the coffee beans.

To check how consistent this is, I repeated the experiment five times each with 9, 19, 30, 40, and 51 balls in the syringe. These samples occupied about 10, 20, 30, 40, and 50 ml of volume respectively. The results are summarized in the following plot:

The error bars show the average and expected standard deviation for a volume calculation using a single pair of measurements, given 0.01 ml accuracy in volume and 0.1 inHg accuracy in pressure.

Interestingly, by far the greatest contribution to this error comes from pressure. In the plot above, we can see that the volume measurements are discrete. This corresponds with steps of 0.1 inHg in the pressure measurement. So if we wanted to improve the accuracy of this apparatus, likely the best thing would be to replace the pressure gauge with something that has better accuracy—or, even better, an absolute pressure gauge.

As we might expect, accuracy gets better as the sample size increases. To my eye, there are diminishing returns past about 40 ml sample volume. With a 40 ml sample and a single pair of measurements, we get about 2.6% expected standard deviation in the volume measurement.

One potential source of systematic error is an offset in either the ambient or gauge pressure measurement. Looking at the figure above, an error of 0.1 inHg (about 0.3 kPa) in either of these measurements could bump us up/down one discrete “step” in the volume measurement. We could calibrate for this by adding a fixed correction to our pressure measurements so that the measured volume using 3/8″ steel shot agrees with the measurements using either water displacement or diameter of the balls.

Update: For those who are looking to dig a little deeper, I’ve uploaded additional error analysis to GitHub and Binder.


There is a lot of exploration to be done using gas pycnometry. A recent comment on this blog linked Borja Roman Corrochano’s thesis, “Advancing the Engineering Understanding of Coffee Extraction”. In this thesis, Corrochano mentions at least two measurements we can make with gas pycnometry:

  • We can measure the true density of either ground or unground coffee. This density excludes pores and fissures which are connected to the external volume of gas, but includes internal pores.
  • If we grind the coffee very finely, we can measure the solid density of the coffee. This is the density of the solid material that makes up the coffee bean, excluding all pores.

I think this technique will also be helpful for anyone roasting their own coffee, as it will provide an accurate measurement of density both for green coffee beans and for the roasted product.

Of course, if you use this technique, I’d love to hear what you do with it.


  1. I do find measuring density saves time dialing in the shot. More than that it indicates starting ratio, dose, temp, even grind setting. Have you had a look at

    1. Actually, your website was one of the things that inspired me to design a homemade gas pycnometer. I wanted a way to improve on the accuracy of bulk density measurement in a graduated cylinder, but without destroying the beans, and gas pycnometry seemed like the best option.

Leave a comment

Your email address will not be published. Required fields are marked *