Introduction to geochemical calculations using MATLAB

Don Baker, McGill University
Author Profile


This activity is designed to teach the students how to find and use MATLAB functions to solve equations and to write simple programs to calculate chemical equilibria.

Learning Goals

The goals of this activity are to introduce the students to the following functions in MATLAB: help, roots and some of the various MATLAB functions that perform numerical integration. Learn how to write a loop for an iterative calculation and use a conditional statement to exit a loop when a solution is found (using Newton's Method). They will practice writing matrices in MATLAB and solving coupled systems of linear equations using the MATLAB backslash operator. Additionally, the students will review their knowledge of calculations of ΔH, ΔS, and ΔG for simple chemical reactions.They will also learn some geologically important reactions and the names and formulas of some end-member mineral formulas.

Context for Use

This activity is designed to be performed in the 1st laboratory session in the 1st week of a 1st semester of a 1st year course for B.Sc. students in the geosciences. It is designed for students with no knowledge of geosciences, but who have had a college (university)-level course in general chemistry and courses in differential and integral calculus.

The students are assumed to have no knowledge of, or experience in, MATLAB except for the approximately 1.5 h introduction given at the start of the laboratory period. However, the weekend before school starts the students are recommended to download and install MATLAB and to use the MATLAB On-Ramp.

Description and Teaching Materials

The students are given a ~1 h introductory lecture on MATLAB and then split into groups of 4 to 7 students. Each group solves its own exercise (with the help of the teaching staff if necessary) and then presents their results at the end of the laboratory session to the entire class.
Introduction_Geochemical_CalculationsV3.pdf (Acrobat (PDF) 44kB Oct21 19)

Teaching Notes and Tips

This exercise is straightforward and can be easily modified by the instructor. In addition to introducing students in their 1st days at college (university) it is also designed as a "rust-remover" to get them to think about their previous courses in chemistry and mathematics. The usual challenge with this exercise is that the "Help" in MATLAB can be confusing to neophytes so instructors need to be on hand to help "translate" and provide examples.


The goal of this assignment is to learn. If you make a mistake we will help you redo the assignment until you understand the results and obtain the correct answers.

The assessment of student learning is accomplished by the students' successful completion of subsequent homework problems and exams that use MATLAB. As the goal of the course is to teach geochemical principles, MATLAB is used only as a tool to make calculations easier and is not specifically taught in depth.