Volcano Blog by Tom Pering
  • Blog
  • About Me
  • Publications
  • Slug Calculator

Matlab Codes for Volcanology

The following codes for Matlab are those which I have developed during the course of my PhD so far, please feel free to use them. If you do please acknowledge me! I will upload more as and when I produce them and have time to upload! They will also be available on vhub. Any questions please contact me!

1) Atmospheric Pressure

Here is a very simple Matlab function for calculating atmospheric pressure. The only value which needs inputting is the number of metres above sea level (asl) that you want to determine the atmospheric pressure for. I often use this (and link it in) with other code for looking at strombolian activity.
atmpressure.m
File Size: 0 kb
File Type: m
Download File

2) Slug/Bubble Molar Mass and Density

When modelling bubble rise and/or slug based strombolian activity it is often essential to know the slug molar mass and density for use with further calculations. To run this function the mass in kg of CO2, SO2 and H2O of the bubble/slug are needed (generally the most voluminous gases in magmas). The gas_properties file is also needed to run the function - it contains the properties of common volcanic gases.
slug.m
File Size: 0 kb
File Type: m
Download File

gas_properties.mat
File Size: 0 kb
File Type: mat
Download File

3) Stokes Rise of Bubbles - Single Point

A function to calculate the rise speed of a bubble given a specific radius. 
stokes.m
File Size: 0 kb
File Type: m
Download File

4) Stokes Rise of Bubbles - Dynamic

This function calculates the dynamic change in rise speed and radius of a bubble (amongst others) from a set depth (length in the code). Also included is the time taken for the bubble to travel each metre iteration (slug_tt) and the total time it takes to travel from the set depth (slug_ttC). Again the gas properties file is needed to run this function.
stokesf.m
File Size: 1 kb
File Type: m
Download File

gas_properties.mat
File Size: 0 kb
File Type: mat
Download File

5) Magma Density and Viscosity Calculations

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:
SiO2
TiO2
Al2O3
FeO
MgO
CaO
Na2O
K2O
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: http://www.whitman.edu/geology/winter/ - which is called "Magma Density Spreadsheet" and the Excel spreadsheet by GabbroSoft (Available at: http://www.gabbrosoft.org/spreadsheets.html) 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).

density.m
File Size: 3 kb
File Type: m
Download File

A simple Matlab function for calculating the viscosity of magma. It is based on the method of Shaw (1972). Viscosities of magmatic silicate liquids: an empirical method of prediction. American Journal of Science 272, pp. 870-893

It requires the inputs:
SiO2
TiO2
Al2O3
Fe2O3
MnO
MgO
CaO
Na2O
K2O
P2O5
H2O - water content
mTc - magma temperature in celsius

The outputs are:
viscosity_gas = viscosity of the magma with the water content

viscosity_no_gas = viscosity of the magma with no gas

totalweight = total weight of all the inputs

During creation I also used the excel spreadsheet by John D. Winter as a guide (Available at: http://www.whitman.edu/geology/winter/) - which is called "Magma Viscosity spreadsheet". As per my magma density code, the excel spreadsheet is probably more user friendly, however, it is useful to have this file in Matlab. It is also useful to use in combination with modelling work.

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

viscosity.m
File Size: 2 kb
File Type: m
Download File

An informative blog for anyone interested about all things volcano related!
  • Blog
  • About Me
  • Publications
  • Slug Calculator