Matlab Codes for Volcanology - Magma Density

By Tom D Pering

University of Sheffield, England

Download (M)

Licensed according to this deed.

Published on


A simple Matlab function for calculating the density of the magma.

It is based on the method of Bottinga & Weill (1970) - Densities of silicate systems calculated from partial molar volumes of oxide components. American Journal of Science 269, pp. 169-182

It requires the inputs:
H2O - water content
mTc - magma temperature in celsius

The outputs are:
density_gas = density of the magma with gas
density_no_gas = density of the magma with no gas
totalweight = total weight of all inputs - ideally this should be close to 100!

I have also used the Excel spreadsheet by John D. Winter (Available at: - which is called "Magma Density Spreadsheet" and the Excel spreadsheet by GabbroSoft (Available at: which is called "MAGMA-DENSITY" as guides when creating the Matlab code.

The Excel spreadsheets are probably more user friendly, however, I have found that when performing modelling tasks with large datasets it is easier to have everything running on one program. I also find it is useful to run this function in combination with work I do on movement of bubbles in magma (see other contributions).

If you have any questions please don't hesitate to contact me.

Cite this work

Researchers should cite this work as follows:

  • Tom D Pering (2013), "Matlab Codes for Volcanology - Magma Density,"

    BibTex | EndNote