name mode size
package 040000
tutorial 040000
.gitattributes 100644 70B
.gitignore 100644 530B
LICENSE 100644 35.12kB
README.md 100644 21.87kB
README.pdf 100644 187.3kB
README.md

alphaMELTS for MATLAB/Python 1.2: Latest news…

As of May 31st, 2024, releases and source code are available at the alphaMELTS repository on GitHub. Release v2.3.0 there brings the suite of alphaMELTS software -- formerly alphaMELTS 2 (v2.2.1) and alphaMELTS for MATLAB/Python (v1.2.2) -- into one open-source repository. The same versioning is now applied to all interfaces, as the majority of edits are to the C library of MELTS functions that is common to all the software interfaces.

The binaries have been repackaged so that users need only download files for the platforms (MacOS, Windows, Linux) and alphaMELTS interface that they intend to use. This arrangement is transitional, while workflows are being developed to package the software for PyPI, Homebrew, CRAN, MATLAB File Exchange etc. The Caltech-hosted GitList repository and the GitLab-hosted private repository are being preserved as a placeholder for previous users of alphaMELTS for MATLAB/Python, but no new members will be added to the alphaMELTS group.

As of November 19th, 2020 a major update was uploaded. Most changes are 'under the hood' and set up the code for rapid implementation of new features. So this version 1.0 has a very similar functionality to the previous version, which was the last 'beta' version (and was the alphaMELTS for Python included in the final VM alphaMELTS Lubuntu 18.04 virtual machine).

The main changes required for existing scripts in moving from 'beta' to 1.0 is that the units of temperature are now Celsius (previously K), and of density are now g/cc (previously kg/m^3). This is for consistency with other MELTS software, in particular standalone alphaMELTS 2.

The Python version has been brought up to date with the MATLAB one, except for a few minor edits that are work in progress (e.g. making sure all routines can accept either Python lists or NumPy arrays). The 'tutorial' is included for testing, but other examples have been moved out of the repository. They will be provided with workshop files instead, and eventually as part of DACITE - the Database of AlphaMELTS CIT (=Caltech) Examples.

As of December 21st, 2021 a new option to calculate viscosity from Giordano et al. (2008) has been added. The main change required for existing scripts is that liquid viscosity is now a property of the liquid(s), so calls to 'getListProperty' or 'getNodeProperty' will need to be updated accordingly (see Note). As the online Supplemental Calculator was shut down recently, the calculation of activities for phases with ordering, speciation or structural transitions has been simplified: the 'activity' property is now relative to the Berman/MELTS standard state in the same way as other MELTS software. Activities relative to a particular ordering state and/or structure are still included as 'activity0'; these are intended for comparison with other thermodynamic models/software (see the test_activities workshop example for more details).

[Note that the system ("bulk") viscosity somewhat accounts for crystalinity but, unlike the easyMelts melts.out values, it does not yet include previously fractionated crystals.]

To get notifications when alphaMELTS for MATLAB/Python is updated

Select 'Settings' in the dropdown for your GitLab profile (top righthand corner of browser window). Click 'Notifications' in the lefthand panel and then choose 'Watch' for the MELTS_Matlab repository. Most changes will be incremental and described in the commit messages; major updates will be noted above.

Note that GitLab started capping the number of members in a group like the alphaMELTS group so email notifications stopped working. Past members of the alphaMELTS will be removed and added to the invidual repositories so they can still access alphaMELTS2 and MELTSMatlab history and be redirected to the newly combined alphaMELTS repository._

To get help with alphaMELTS for MATLAB/Python and other MELTS software

Visit the alphaMELTS 2 page for links to example files, documentation on the forum, contact details for software support etc.

Also, the drop-in Zoom "office hours" at last year's Thermodynamic Modeling of Magmatic Processes with alphaMELTS 2 workshop worked really well. We kept them going and opened them up to anyone in the alphaMELTS GitLab group who wanted help with alphaMELTS 2, alphaMELTS for MALTAB/Python or easyMelts. They were paused when the Zoom license was reverted but could be set up within the 40 min limit if there is interest (email psmith@gps.caltech.edu).

To download the alphaMELTS for MATLAB/Python files

On GitLab, you can either clone this repository or click the cloud symbol (next to the 'Web IDE button') to download a zip of all the files. For access on the MAGMA Source GitList server during alphaMELTS 2 workshops, click the zip or tar button. Alternatively, download individual .m or .py files by clicking on the file name (you might need to select the 'Raw' option, and you should not download the lib files this way).

[Note that as of February 1st, 2020, both alphaMELTS 2 and alphaMELTS for MATLAB/Python on GitLab have moved. If you cloned the repository before then you will need to change the configuration to point to 'alphaMELTS/MELTSMatlab' instead of 'magmasource/MELTSMatlab'.]

System requirements for alphaMELTS for MATLAB

alphaMELTS for MATLAB is currently developed using R2021b but older and newer versions should work also. It is helpful to have alphaMELTS 2 (and easyMelts) installed for the same version i.e. Mac, Linux, or native Windows.

  • alphaMELTS for MATLAB has been tested on Ubuntu 18.04 and 20.04, and macOS Ventura (Intel) and Monterey (M1 chip). On other MacOS versions your mileage may vary.
  • alphaMELTS for MATLAB has been tested on Windows 10 and 11. Other Windows versions are not supported.

alphaMELTS for MATLAB requires a C compiler (or at least the C runtime libraries) be installed. There are plenty of free options available (see below). alphaMELTS for MATLAB also uses the GNU Science Library (GSL). For Windows, this and other .dll prerequsites are provided. For Mac the file is most easily installed via Homebrew: install Homebrew as directed on the homepage (or see below for M1/M2 chip Macs) and then type brew install gsl at the Terminal command line. On Linux it can be installed via the package manager (e.g. apt install gsl-bin on Ubuntu). It can also be downloaded directly but this has not been tested with alphaMELTS for MATLAB.

Note that MATLAB on M1/M2 chip Macs currently runs through Rosetta 2, which means you will need to install the Intel version of Homebrew. At the time of writing (July 2023) this procedure appears to be working:

arch -x86_64 zsh
cd /usr/local
sudo mkdir Homebrew
curl -L https://github.com/Homebrew/brew/tarball/master | sudo tar xz --strip 1 -C Homebrew
sudo chown -R *yourusername*:wheel Homebrew
sudo ln -sf Homebrew/opt opt

Enter your normal user password if asked. Also, if you get a message that you need to change the ownership of the Homebrew directory at any point then just run the command it suggests. Finally type /usr/local/Homebrew/bin/brew install gsl

System requirements for alphaMELTS for Python

alphaMELTS for Python requires a Python 3 environment and your choice of Python IDE. Pyzo is a Python 3 IDE with a similar feel to MATLAB, that we sometimes use for demos at alphaMELTS 2 workshops (note that you might need to subsitute 'pyqt' with 'pyqt5' in the Quickstart instructions). There are other options, e.g. Anaconda python comes with Spyder and Jupyter, and RStudio can be used as an IDE for Python and R simultaneously. On Windows 10 or 11 you can run the Linux version of alphaMELTS for Python if you have the Windows Subsystem for Linux (WSL) enabled, or you can run the native Windows version. It is helpful to have alphaMELTS 2 (and easyMelts) installed for the same version i.e. Mac, Linux or native Windows.

alphaMELTS for Python has been tested on various systems including (not a complete list):

  • On Mac with the Homebrew installation of python3, and Pyzo and VS Code as IDE / Debugger.
  • With the WSL installations of python3 (Ubuntu 18.04, Ubuntu 20.04), and VS Code as IDE / Debugger (previous versions were also tested with a combination of Pyzo and X410 as IDE).
  • With native Anaconda and PyCharm installations on Windows 10, which work well with Visual Studio. It has also been tested with the Microsoft Store version of Python, together with Pyzo.
  • On Ubuntu 18.04 with system and Anaconda installations of python3, and Pyzo and VS Code respectively as IDE / Debugger.

alphaMELTS for Python requires a C compiler (or at least the C runtime libraries) be installed. There are plenty of free options available (see below) alphaMELTS for Python also uses the GNU Science Library (GSL). For Windows, this and other .dll prerequsites are provided. For Mac the file is most easily installed via Homebrew: install Homebrew as directed on the homepage (or see the previous section for M1/M2 chip Macs running the Intel version Anaconda) and then type brew install gsl at the Terminal command line. On Linux it can be installed via the package manager (e.g. apt install gsl-bin on Ubuntu). It can also be downloaded directly but this has not been tested with alphaMELTS for Python.

Finally, alphaMELTS for Python requires some Python modules that are installed by default in Anaconda, but not in some of the lighter weight Python installations. You can get the necessary packages by following Pyzo's Quickstart instructions (note that you might need to subsitute 'pyqt' with 'pyqt5'). Or you can install pip3 at the command line (e.g. sudo apt install python3-pip on Ubuntu) and then use that to install the required modules (e.g. pip3 install numpy pandas).

Installing and updating alphaMELTS for MATLAB/Python

On Mac, if you have Xcode installed, and it is up to date, this will work. If you do not have Xcode you do not need to install it, and you probably don't want to as it is huge(~10 GB)! Instead install just the Command Line Tools, which are < 1 GB; you will get some warnings when you run alphaMELTS for MATLAB, but they are harmless and can be suppressed. To install see Install Xcode Command Line Tools and then see Mex on macOS without Xcode to tell MATLAB that you agreed to the Xcode license; finally, the next time you open MATLAB, type mex -setup C (you need only do these steps once).

On Windows, MATLAB will offer to install MinGW as a MATLAB add-in if it can't find a compiler; you will need to log in with your Mathworks account. Or go here to install the add-in directly. Alternatively, or as well, you can use Visual Studio 2015, 2017 or 2019. Visual Studio has a Community Edition that is free for academia. There is also standalone MinGW-w64, which is available for free here, though testing of this in alphaMELTS for MATLAB has been limited. Note that if you do use mingw-w64-install.exe, you should usually choose Structured Exception Handling (SEH), rather than Setjump Longjump (SJLJ); see the 'Note about error handling' section below for more details.

On Windows, even if you have not installed a C compiler, it is likely that alphaMELTS for Python will still run because many applications (including most software by Microsoft and Adobe) install copies of the Microsoft Visual C++ Redistributable libraries. If not, and if you do not want to install the full Visual Studio Community Edition, you can get the relevant libraries here; scroll down to "Other Tools and Frameworks" at the bottom of the page. You can also try the standalone MinGW-w64, which is available for free here, though this has not been tested for the Python version of alphaMELTS. See the comment about Structured Exception Handling (SEH) versus Setjump Longjump (SJLJ) above, and the 'Note about error handling' section below.

The WSL installation of Ubuntu doesn't include a compiler by default but if you install pip3 (sudo apt install python3-pip) then gcc will be installed as one of the dependencies (or you can just install it with sudo apt install gcc).

Using alphaMELTS for MATLAB

On Linux or Mac, you need to open MATLAB from the command line so that messages from the MELTS library are directed to the terminal command line. On Linux, you can probably just type matlab &. On Mac you can type something like /Applications/MATLAB_R2021b.app/bin/matlab & (substitute the MATLAB release that you have, if appropriate) or you can set up an alias so that you don't need to type the whole line each time.

You need to make sure the 'MELTS_Matlab/package' folder (or whatever the folder is called on your system) is in the MATLAB path. There are various ways to do this, including right clicking on the folder and selecting 'Add to Path'. Alterntively, type addpath('PATH_TO_THE_MELTS_MATLAB_PACKAGE_FOLDER') substituting the correct path.

On Windows, just open MATLAB in the normal way; a console for MELTS library messages has been added as part of the MELTS for MATLAB package. On native Windows (and possibly for some other setups) the system PATH or 'Path' variable may also need to include 'MELTSMatlab/package', as that is where it will search for the C dynamic library of MELTS functions. Setting the Path in the same way as when installing alphaMELTS 2 (subsituting 'PATHTOTHEMELTSMATLABPACKAGE_FOLDER' for '~/bin', '~/Documents/bin' or a custom folder) in probably the safest way to do this. Please contact me (psmith@gps.caltech.edu) for help if you are not sure how to so this.

Documentation strings within the MELTS…m files have been populated for MELTSdynamic and MELTSengine but not other files (yet). You can see brief information on the structure of the MELTS for MATLAB classes by typing something like help MELTSdynamic (with or without the '.m') or help MELTSengine and then clicking the 'Reference page for …' links.

Using alphaMELTS for Python

For now, until MELTS for Python is properly packaged (e.g. so that it can be installed via pip or conda), you will need to set the PYTHONPATH environment variables to include the path to 'MELTSMatlab/package', or whatever the folder is called on your system. There are various ways to do that, including the same methods used to set the Path when installing alphaMELTS 2 (subsituting 'PYTHONPATH' for 'PATH', and 'PATHTOTHEMELTSMATLABPACKAGEFOLDER' for '~/bin', '~/Documents/bin' or a custom folder). In Pyzo you can set the PYTHONPATH under Shell->Edit shell confgurations… Alternatively, simply copy any .py script you wish to run into the 'MELTSMatlab/package' folder and run it there.

On native Windows (and possibly for some other setups) the system PATH or 'Path' variable also needs to include 'MELTSMatlab/package', as that is where it will search for the C dynamic library of MELTS functions. Setting the Path in the same way as when installing alphaMELTS 2 (subsituting 'PATHTOTHEMELTSMATLABPACKAGE_FOLDER' for '~/bin', '~/Documents/bin' or a custom folder) in probably the safest way to do this. Please contact me (psmith@gps.caltech.edu) for help if you are not sure how to so this.

Docstrings have been added for the meltsdynamic.py and meltsengine.py files but not other files (yet). You can see brief information on the methods in the MELTS for Python classes by typing something like help(MELTSdynamic) or help(MELTSengine). For information about class properties (e.g. units for thermodynamic quantities) you will need to examine the .py scripts.

Building the alphaMELTS library (optional)

The source for alphaMELTS 2 will be posted on the ENKI Portal once the trace elements have been fully implemented etc. (in the meantime, it is available on request, per the conditions of the GPLv3). You can build the MELTS version of the library that underlies alphaMELTS for MATLAB/Python from the xMELTS code repository on the ENKI Portal, if you have git and make installed. Currently, this is a more or less fully functioning version of (alpha)MELTS for MATLAB/Python - this will not be the case going forward, as more alphaMELTS-specific features are hooked up.

Note that in MELTS for MATLAB/Python, there is only one feldspar phase ('feldspar') rather than the two phases that alphaMELTS 2 has ('plagioclase' and 'alkali-feldspar'). You will need to adjust the tutorial.m / tutorial.py script accordingly.

You will need to contact Mark Ghiorso to be added to the xMELTS code repository. After cloning, checkout the alphaMELTS branch of the repository, git checkout alphaMELTS, and update with git pull, if needed. Follow the instructions in the xMELTS README to configure the Makefile etc. Finally, build the 'libMELTSdynamic' library with the following command: make realclean Melts-dynamicPrivate "BATCH=-DBATCH_VERSION -DRHYOLITE_ADJUSTMENTS" DYNAMIC=true (you may get an error message if you do not have Fortran installed, but you can safely ignore it). Rename the 'libMELTSdynamic' file, which will have a .dylib, .so or .dll suffix, to 'libalphamelts', with the same suffix. Finally, move the .dylib, .so or .dll library into the 'MELTS_Matlab/package' directory.

For Windows, you will need to use the Windows Subsystem for Linux (WSL) to build libalphamelts. If you are installing MinGW-w64 via apt in the WSL then use the Makefile.WSL makefile. For the standalone MinGW-w64 use the Makefile.Windows makefile. You will probably need to edit the makefile; please contact me (psmith@gps.caltech.edu) for help.

Once the alphaMELTS 2 code is available the build process will be similar, except that there is just one makefile that detects whether you are on Linux, Mac or Windows. You will checkout the appropriate branch of the code, probably 'master' or 'develop', and update with git pull. The build command will usually be: make realclean alphamelts DYNAMIC=true RELEASE=true. If you want to force it to use gcc on Linux, instead of clang, then add USEGCC=true to the list of flags; if you are using the MinGW compiler on the WSL then add WINDOWS=true to the list of flags, else it will build the Linux version.

Note about error handling etc.

Ideally, when an error is encountered or when the user wishes to switch between MELTS models, the MELTS library is reloaded to reinitialize all variables and then calculations can continue. This has been verified to work with MATLAB versions R2018a onwards for Linux, Mac and Windows. For Python, library reloading works on Windows but not on Linux or Mac (by design, as some system library dependencies cannot be reloaded). Instead, on Mac and Linux, any error will be caught, and an attempt to continue calculations will be made, if appropriate.

On Windows, the default error handling, Structured Exception Handling (SEH), is not very portable across compilers. The most common MELTS library errors (usually a negative mole fraction) will be caught and handled, but others may not be. If your calculations are pushing the boundaries of what MELTS is capable of, and you are getting unhandled errors (e.g. MATLAB says it needs to close) then switching to a compiler using Setjump Longjump (SJLJ) will help. SJLJ is used for the Linux and Mac versions, and there is an alternative version of the Windows MELTS library that uses SJLJ available on request. Install the standalone MinGW-w64, which is available for free here; once you start mingw-w64-install.exe, choose Setjump Longjump (SJLJ), instead of Structured Exception Handling (SEH). Please contact me (psmith@gps.caltech.edu) for the library and instructions to get it working in MATLAB. The Python version is untested, as yet, but you are welcome to try it out.