The maths behind a perfect cup of coffee

The process behind your favourite hot drink involves growing the beans, harvesting, drying, roasting, grinding, brewing - and maths

Brewing the perfect cup of coffee has long been considered an art, depending on experience and skills honed by baristas and amateur enthusiasts alike over generations. However, each of the processes though which coffee is realised - such as growing the beans, harvesting, drying, roasting, grinding and brewing - are fundamentally science-driven applications. Even the most mature processes can benefit from a scientific approach, grounded in the language of mathematics.

The coffee market in Ireland is booming, reflecting a wider trend in the rest of the world. This growth indicates that coffee is starting to challenge the tea market, the traditional favourite and most popular hot beverage in Ireland. Recent reports by Bord Bia reveal that 75 percent of Irish consumers say they drink coffee and seven in ten drink more than one cup per day.

Consumers are also becoming more discerning and are prepared to pay more for a higher quality product. Driven by the consumption habits of millennials, speciality coffees are in and the instant coffee market is declining.

With an enormous global market and an increasingly discerning consumer, coffee companies and baristas alike are increasingly turning to science to gain an edge. Chemists, engineers and applied mathematicians find themselves challenged with uncovering the mysteries of the roasting and grinding processes, discovering the perfect water composition with which to brew coffee, reducing its environmental impact and ultimately consistently brewing better coffee for everyone.

If you are lucky enough to be reading this while enjoying the perfect cup of coffee, you may not consider just how many things had to go right for this to be a reality! The realisation of that cup of coffee depended on a myriad of factors: the coffee origin, the roasting level of the beans, the grinding and brewing techniques and even the chemistry of the water used. Taste is a complicated and subjective matter that science is still trying to come to terms with. My perfect coffee will likely be different to yours.

One of the major challenges is to brew that same delicious cup of coffee every time. If a barista produces a cup of coffee capable of winning the world barista championships, they would like to be able to do this consistently. Unfortunately, the combination of coffee beans, grinding and brewing which make a world beating coffee one day, may lead to less than exciting coffee the next day – despite apparently changing nothing.

Similarly, companies manufacturing coffee brewing apparatus want their equipment to consistently deliver high quality coffee to the end user. Mathematical modelling, combined with a set of targeted experiments, offers a powerful technique to simulate and understand why coffee brewing is challenging and find ways to make it more consistent.

In recent years, a group of researchers in the MACSI industrial applied mathematics group in the University of Limerick have been working with international academic and industrial partners to investigate what happens during the coffee brewing process. The ultimate goal is to create a mathematical set of equations to predict the quality of brewed coffee, based on the properties of the coffee grounds (e.g. grain size and shape, origin, roasting level etc.), the water used (water chemistry) and the brewing settings (method, time, coffee bed size and shape).

This will allow coffee manufacturers provide us with machines which brew that excellent cup every time. Once confirmed by experiments, such a model allows different equipment designs to be evaluated using computer simulations, without carrying out expensive testing. This is an example of a technique called digital twinning, where a computer model of a process is constructed. Espresso type coffee extraction has been successfully mathematically derived and further work on the more challenging case of pour-over or drip filter coffee is underway.

Coffee is composed of hundreds of different chemicals depending on its origin and roasting methods. About 30 pecent roast and ground coffee consists of material soluble during brewing. These chemicals extract at different rates, contributing different flavours to the brew. The initial brew can be strong, acidic and sour. As brewing progresses, sweet and caramel tones become dominant, before finally moving to bitter flavours.

Good coffee is all about a balance of flavours. Stopping extraction too soon means a sour and underdeveloped coffee, while extracting too long leaves a bitter cup of coffee. The Speciality Coffee Association recommends extracting between 18 to 22 percent of the mass of the coffee grains (the extraction yield) to achieve the best balance of flavours.

The time taken to do this depends critically on the size of the ground coffee. The finer coffee is ground, the more surface area is available for coffee to extract and the slower the water will flow over the grains. If your coffee is too bitter, you should either reduce the brewing time or grind coarser to extract less bitter compounds. For underdeveloped coffee flavours, do the opposite. This might be seen as basic logic, but by writing down equations which describe these effects, we can effectively demonstrate how different grind sizes influence the extraction yield.

Better understanding of coffee brewing can also have a positive impact on the environment. By understanding how water flows through a coffee bed we can ensure the coffee grains are extracted evenly. This means more flavoursome coffee can be extracted, before the taste is ruined by bitter tastes from over-extracted parts of the bed. Ultimately, this means less coffee grains are needed for each cup, saving money and waste!

As a consumer, you can have a more direct influence by refusing to use single use coffee cups. Besides being bad for the environment, the plastic in these cups has been shown to have a negative impact on coffee flavour! Ceramic is best, having no impact on flavour, so take your time to enjoy your coffee, or, if you are really run off your feet, invest in a portable cup.

We are always interested in new collaborators in the coffee industry to provide insight, expert guidance and experimental data to further develop our work. The development of mathematical models of coffee brewing means that coffee manufacturers can utilise this knowledge in designing and building the optimum coffee brewing apparatus. For more sophisticated equipment, this means better controlled systems to regulate that perfect extraction in every cup.

Through power mathematics, we can analyse what makes that amazing cup of coffee you are always looking for, rather than through the traditional trial and error approach. The work here endeavours to consistently provide you with your favourite aromatic flavours, whilst giving you that extra boost you need to get you through your day.

Dr Kevin Moroney is a postdoctoral researcher in the MACSI group and the SSPC research centre in UL. Dr Ken O’Connell is a postdoctoral researcher in the DPTC research centre in UL.

This article first appeared on RTE's Brainstorm website