This repository stores mass balance algorithms for petrology in general, with MCMC for propagating errors on phases and bulk compositions, including:
- Non-negative least square algorithm
- Matrix decomposition algorithm of Li et al. (2020).
- Algorithm of Albarede and Provost (1977) (future update)
Please contact me at yishen.zhang@kuleuven.be or drop issue
, PR
for bug reporting, new feature requirement or contribution.
-
Check the documentation page here
-
Download or clone the github files, compile python environment from Anaconda for Win, Anaconda for Mac, or Miniforge.
-
No pip or conda installation is planned, you can install by calling the
setup.py
file in the unzipped downloaded file (directory name supposedly as MassBalanceCal-main). Run the line below in any terminal like app (terminal in Mac, or Anaconda prompt in Win):pip install .
or quicker install from the github repo url:
pip install "git+https://github.com/eazzzon/MassBalanceCal.git"
-
If you don't want to install the module, you can still either run the scripts/notebook file within the example directory, or relative import the module as:
sys.path.append(filepath of massbalance folder in your system)
-
To do the calculation, simply run the scripts or notebook file from IDEs (VS code, Spyder, Jupyterlab/Jupyter notebook). See PREPARATION first for data preparation.
-
Highly recommend to look through the tutorial notebook file (in the Tutorial directory), which gives general information of the code. Python scripts (example directory) are also avaiable covering examples for different cases.
-
Uninstallation as:
pip uninstall massbalance
numpy, pandas, scipy
- Load your phase compositions in the input excel files, use sheets store different phases, free to change sheet names and orders BUT NOT
bulk
andrun_index
sheets (they should always stay as the last two),bulk
sheet should give the bulk composition(s),run_index
should give the entire experimental run numbers ± expts conditions, sample numbers or rock ids for natural samples, which are then used for indexing and matching during calculation. - If you only have one bulk composition, you can use
input_comp_oneBulk.xlsx
, orinput_comp.xlsx
but overwrite the bulk sheet. - If you change the element in the header, you should also change the definition of element list in the script for consistency.
- If you didn't install the module, DO NOT change the structure of the directory.
You may cite the code as:
-- Zhang Y, Namur O, Charlier B, 2023. Experimental study of high-Ti and low-Ti basalts: liquid lines of descent and silicate liquid immiscibility in large igneous provinces. Contrib. Mineral. Petrol. 178(1):1-24. https://doi.org/10.1007/s00410-022-01990-x
Also need to cite the papers for these excellent algorithms:
For non-negative algorithm:
-- Lawson C., Hanson R.J., (1987) Solving Least Squares Problems, SIAM
For matrix decomposition:
-- Li, X., Zhang, C., Almeev, R.R. and Holtz, F., 2020. GeoBalance: An Excel VBA program for mass balance calculation in geosciences. Geochemistry, 80(2), p.125629
-- Ghiorso, M.S., 1983. LSEQIEQ: A FORTRAN IV subroutine package for the analysis of multiple linear regression problems with possibly deficient pseudorank and linear equality and inequality constraints. Computers & Geosciences, 9(3), pp.391-416.