This page was generated from docs/Installation/InstallationScript.ipynb. Interactive online version: Binder badge.

Python Notebook Download

Installation of alphaMELTS for Python

Please download this notebook (use the links above to find the source file) and run the following installation script as a notebook.

Step 0 - Only use if you’ve previously installed alphaMELTS for Python via PetThermoTools. Alternatively go straight to Step 1.

To update alphaMELTS for Python installation run the update function below.

Please join and keep an eye on the alphaMELTS Discord Server where we will post information about updates to the alphaMELTS for Python source code and which versions have been tested with PetThermoTools. Following updates we will indicate if later versions of PetThermoTools require users to update their alphaMELTS for Python installation. using the function below.

[ ]:
# import petthermotools as ptt
# ptt.update_alphaMELTS_path(version="2.3.1")

# from meltsdynamic import MELTSdynamic
# meltstest = MELTSdynamic(1)
# meltstest.version

Step 1 - Install Python

This may seem obvious, but the first step is to obtain Python3 (tested on v3.9 through 3.13). If you haven’t used python before, we recommend installing it through anaconda.

anaconda3 “https://www.anaconda.com/products/individual”.

Step 2 - Pip install PetThermoTools and it’s dependencies

[1]:
#### If you already have ptt installed upgrade the installation instead ####

%pip install petthermotools
# %pip install --upgrade petthermotools

Step 3 - Installing alphaMELTS for Python.

Read carefully, instructions might vary based on operating system

If using MacOS with native M1 (or later) chip

Before proceeding please you need to install GSL with Homebrew.

  • Open the terminal

  • Copy and past the install command from https://brew.sh into the terminal

  • Follow the installation instructions as they appear

  • Once it has finished type “brew install gsl”

If any issues arise with this step - or if you have any issues with any of the steps below - please contact me at gleesonm@berkeley.edu

Once GSL has been installed (or if you’re using a Windows OS) you can continue onto the script below.

This code will download the latest compatible version of alphaMELTS for Python and – if you have administrative privaledges on your computer – add these files to the Python path. If you don’t have administrative privaledges the code will print instructions of how to add the files to your Python path at the start of every new notebook.

[1]:
### First import petthermotools and check the version. As of December 19th 2025 this should be v0.3.2 or later
import petthermotools as ptt
ptt.__version__
alphaMELTS for Python files successfully located.
If you are planning on using the Green et al. (2025) or Weller et al. (2024) thermodynamic models through MAGEMin for crystallization, melting, or phase diagram calculations
you will need to run `ptt.activate_petthermotools_env()` at the start of each notebook, prior to any calculations, every time you restart the kernel.
This step establishes the python-julia connection and sets up the julia workers. Expect it to take about 20-40s on most machines.
[1]:
'1.3.1'
[3]:
### Use the ptt.install_alphaMELTS() function to download the alphaMELTS for Python files and add them to your Python path
ptt.install_alphaMELTS(version = "2.3.1")

### If you want to download the alphaMELTS files to a certain folder on your machine you can instead use this function below
# ptt.install_alphaMELTS(file_location="/Users/gleesonm/Library/CloudStorage/GoogleDrive-matthew.gleeson.geo@gmail.com/My Drive/!!!Berkeley/2024/MELTS/")
Please note this does not remove the previously downloaded alphaMELTS files. That has to be done manually.
 This function simply removes the Python path to those files so that you can install/update to a new version of alphaMELTS for Python.
Checking /Users/gleesonm/anaconda3/lib/python3.11/site-packages for .pth files
Found .pth file: sphinxcontrib_jsmath-1.0.1-py3.9-nspkg.pth
Found .pth file: ruamel.yaml-0.17.21-py3.11-nspkg.pth
Found .pth file: easy-install.pth
Found .pth file: my_MELTS_path.pth
Found .pth file: aeosa.pth
Found .pth file: distutils-precedence.pth
Found .pth file: protobuf-3.20.3-py3.11-nspkg.pth
Removed /Users/gleesonm/anaconda3/lib/python3.11/site-packages/my_MELTS_path.pth
Downloading alphaMELTS from: https://github.com/magmasource/alphaMELTS/releases/download/v2.3.1/alphamelts-py-2.3.1-macos-arm64.zip...
Extracting to: /Users/gleesonm/Library/CloudStorage/GoogleDrive-matthew.gleeson.geo@gmail.com/My Drive/!!!Berkeley/2024/MELTS/alphamelts_py-2.3.1...
Path permanently added via: /Users/gleesonm/anaconda3/lib/python3.11/site-packages/my_MELTS_path.pth

To check that the download and extract proceeded without issue run the code below.

This should print a message with current alphaMELTS verions (2.3.1) if there are no issues.

[2]:
from meltsdynamic import MELTSdynamic
meltstest = MELTSdynamic(1)
meltstest.version

alphaMELTS for Python version 2.3.1beta (Aug  3 2024 10:01:38)
Setting calculation mode to rhyolite-MELTS 1.0.2

[2]:
'2.3.1beta (Aug  3 2024 10:01:38)'

Step 4 - Test installation

I recommend restarting the Python Kernel and then running the two cells below.

This will run a simple fractional crystallization calculation if everything is installed correctly.

If you’re on MacOS it will print all the outputs from the MELTS calculations (this can be a lot). Scroll to the bottom and you should see a table of liquid compositions if the calcualtions run correctly.

[3]:
import petthermotools as ptt
[4]:
# This will run a simple crystallization calculation to test the installation process has worked correctly.
ptt.test_alphaMELTS()
multi_path_v2: timeout not specified, using the platform default of 60s per path (pass timeout=<seconds> to override).
multi_path_v2: 1/1 completed, 0/1 returned partial results after a crash, 0/1 returned partial results after timing out, 0/1 returned no results (no retry by default -- see max_retries).
     SiO2_Liq  TiO2_Liq  Al2O3_Liq  Cr2O3_Liq  Fe2O3_Liq    FeO_Liq  \
0   49.936390  1.965528  15.724226        0.0   1.866184   7.649596
1   49.917719  2.070720  15.696104        0.0   1.913297   7.974035
2   49.875120  2.191811  15.600944        0.0   1.978358   8.340462
3   49.804993  2.319179  15.496539        0.0   2.053363   8.709604
4   49.705458  2.454359  15.380534        0.0   2.138784   9.082435
5   49.575191  2.598292  15.251151        0.0   2.234887   9.459322
6   49.414006  2.750883  15.107974        0.0   2.341459   9.840027
7   49.218853  2.918519  14.925211        0.0   2.463338  10.231667
8   49.003423  3.087995  14.731907        0.0   2.592317  10.625945
9   48.772807  3.253887  14.540837        0.0   2.725728  11.020045
10  48.529493  3.414638  14.352146        0.0   2.863827  11.414536
11  48.276833  3.568215  14.166139        0.0   3.006767  11.809544
12  48.019350  3.711981  13.983369        0.0   3.154543  12.204591
13  47.763169  3.842511  13.804762        0.0   3.306885  12.598330
14  47.516631  3.955363  13.631811        0.0   3.463105  12.988146
15  47.291118  4.044774  13.466835        0.0   3.621857  13.369559
16  47.177670  4.038589  13.331313        0.0   3.778605  13.723018
17  47.465858  3.692653  13.305218        0.0   3.917618  13.971090
18  50.416474  3.048036  14.145492        0.0   2.841336  12.108336
19  51.597083  2.721598  14.390320        0.0   2.511251  11.470444
20  52.473929  2.474228  14.553328        0.0   2.287814  10.992375
21  53.191691  2.273808  14.679514        0.0   2.114391  10.584729
22  53.799355  2.104746  14.783924        0.0   1.973461  10.223507

     FeOt_Liq  MnO_Liq   MgO_Liq    CaO_Liq  Na2O_Liq   K2O_Liq  P2O5_Liq  \
0    9.328776      0.0  7.882068  11.713351  3.033099  0.029932       0.0
1    9.695607      0.0  7.748125  11.289241  3.146006  0.031711       0.0
2   10.120576      0.0  7.628832  10.863477  3.258663  0.033702       0.0
3   10.557206      0.0  7.500259  10.469009  3.365915  0.035768       0.0
4   11.006899      0.0  7.361374  10.107620  3.468021  0.037918       0.0
5   11.470259      0.0  7.212664   9.780205  3.564925  0.040157       0.0
6   11.946856      0.0  7.056638   9.485764  3.656168  0.042472       0.0
7   12.448162      0.0  6.863686   9.255523  3.749048  0.044988       0.0
8   12.958495      0.0  6.668675   9.049851  3.836715  0.047541       0.0
9   13.472638      0.0  6.485683   8.851058  3.916401  0.050058       0.0
10  13.991388      0.0  6.313090   8.657816  3.989005  0.052535       0.0
11  14.515013      0.0  6.149170   8.468692  4.055602  0.054966       0.0
12  15.043027      0.0  5.992016   8.282104  4.117526  0.057350       0.0
13  15.573842      0.0  5.839445   8.096275  4.176480  0.059684       0.0
14  16.104225      0.0  5.688876   7.909168  4.234699  0.061975       0.0
15  16.628482      0.0  5.537190   7.718427  4.295170  0.064233       0.0
16  17.122982      0.0  5.360172   7.496690  4.388054  0.066801       0.0
17  17.496137      0.0  5.086821   7.153702  4.622449  0.070885       0.0
18  14.664951      0.0  4.398260   6.869792  5.238279  0.084072       0.0
19  13.730051      0.0  4.068810   6.613830  5.573408  0.091874       0.0
20  13.050935      0.0  3.813676   6.384994  5.850360  0.098700       0.0
21  12.487244      0.0  3.601214   6.177687  6.092053  0.104967       0.0
22  11.999215      0.0  3.418487   5.987137  6.308346  0.110817       0.0

     H2O_Liq  CO2_Liq  Fe3Fet_Liq
0   0.199626      0.0    0.180000
1   0.213041      0.0    0.177562
2   0.228631      0.0    0.175891
3   0.245372      0.0    0.175009
4   0.263498      0.0    0.174842
5   0.283206      0.0    0.175317
6   0.304609      0.0    0.176350
7   0.329167      0.0    0.178058
8   0.355631      0.0    0.180002
9   0.383495      0.0    0.182042
10  0.412915      0.0    0.184174
11  0.444072      0.0    0.186391
12  0.477172      0.0    0.188688
13  0.512459      0.0    0.191058
14  0.550227      0.0    0.193494
15  0.590837      0.0    0.195984
16  0.639088      0.0    0.198561
17  0.713705      0.0    0.201476
18  0.849924      0.0    0.174335
19  0.961382      0.0    0.164574
20  1.070596      0.0    0.157733
21  1.179946      0.0    0.152357
22  1.290221      0.0    0.147985
[ ]: