News:

alphaMELTS 2.3 standalone & for MATLAB/Python is now open source and available on GitHub (https://github.com/magmasource/alphaMELTS).
alphaMELTS 1.9 is available at the legacy download and information site.
For news of all MELTS software see the MELTS Facebook page.

Main Menu

Recent posts

#11
alphaMELTS for MATLAB/Python / Re: Help Needed Translating EN...
Last post by liushanke - October 23, 2024, 01:11:24 AM
Yes,thanks for your response.
#12
alphaMELTS for MATLAB/Python / Re: Help Needed Translating EN...
Last post by Paula - October 17, 2024, 09:46:23 AM
It should be ok now.

Paula
#13
alphaMELTS for MATLAB/Python / Re: Help Needed Translating EN...
Last post by liushanke - October 17, 2024, 05:22:34 AM
Hi Paul,

Thank you for your kind response—it has been very helpful. However, I was unable to access the link: "https://magmasource.caltech.edu/gitlist/Workshops.git/tree/main/workshop_files/matlab_python_rc12/".

I realize that fully understanding the different ways to run alphaMELTS is still a long journey ahead.

Thank you again for your help!

Sincerely,
Shanke
#14
alphaMELTS for MATLAB/Python / Re: Help Needed Translating EN...
Last post by Paula - October 16, 2024, 09:28:00 AM
Hi Shanke,

If you want to run the ENKI examples you need to install Thermoengine locally or run it in Docker. If you are on Windows then Docker is your only option. There's more information here: https://gitlab.com/ENKI-portal/ThermoEngine and you should be able to get help on the ENKI Slack channel (enki-portal.slack.com). It's the free version of Slack so you can't see old posts, unfortunately, but queries usually get answered by community members quickly.

However, this will not help with running alphaMELTS for Python. The underlying thermodynamic models are the same but it's a different implementation (forked from Mark Ghiorso's xMELTS code) and a different interface, although both use Python. There are alphaMELTS examples from past workshops, including fractionation crystallization and degassing. For example, see here: https://magmasource.caltech.edu/gitlist/Workshops.git/tree/main/workshop_files/matlab_python_rc12/

There isn't an isobaric equilibrium (batch) crystallization example but you can make one by replacing
ptpath.engine.setSystemProperties(["Log fO2 Path: -1FMQ", "Mode: Fractionate Solids"])with
ptpath.engine.setSystemProperties(["Log fO2 Path: -1FMQ"])
Or have a look at PetThermoTools, which builds on alphaMELTS for Python, and includes documentation and examples for common calculations like modeling liquid lines of descent. See https://github.com/gleesonm1/PetThermoTools

Best wishes,
Paula
#15
alphaMELTS for MATLAB/Python / Help Needed Translating ENKI M...
Last post by liushanke - October 14, 2024, 12:31:54 AM
Hello everyone,

I am currently learning to use alphaMELTS by following the examples provided on the ENKI website. Two specific examples demonstrate modeling systematic variation for the same initial conditions:

Fractionation example: 1. https://enki-portal.gitlab.io/ThermoEngine/MELTS-v1.0.2-fractionation.html
Equilibrium example: 2. https://enki-portal.gitlab.io/ThermoEngine/MELTS-v1.0.2-equilibrium.html

To deepen my understanding, I tried translating these examples into Python scripts. However, I encountered issues running the Python code. Below is one of my attempts:
~~~~~~~~
from thermoengine import equilibrate
import matplotlib.pyplot as plt
import numpy as np

# Initialize MELTS v1.0.2 instance
melts = equilibrate.MELTSmodel()

# Set initial bulk composition (wt% or grams)
feasible = melts.set_bulk_composition({
    'SiO2': 77.5, 'TiO2': 0.08, 'Al2O3': 12.5, 'Fe2O3': 0.207,
    'Cr2O3': 0.0, 'FeO': 0.473, 'MnO': 0.0, 'MgO': 0.03,
    'NiO': 0.0, 'CoO': 0.0, 'CaO': 0.43, 'Na2O': 3.98,
    'K2O': 4.88, 'P2O5': 0.0, 'H2O': 5.5
})

# Optional: Suppress unwanted phases
melts.set_phase_inclusion_status({'Nepheline': False, 'OrthoOxide': False})

# Compute equilibrium at specific T (°C) and P (MPa)
output = melts.equilibrate_tp(760.0, 175.0, initialize=True)
(status, t, p, xmlout) = output
print(status, t, p)

# Display summary output
melts.output_summary(xmlout)

# List thermodynamic properties for the system
props = melts.get_list_of_properties()
for prop in props:
    print(f"{prop:<20s} {melts.get_property_of_phase(xmlout, 'System', prop):13.6e} {melts.get_units_of_property(prop):<10s}")

# List chemical affinities and undersaturated phase compositions
affinity_dict = melts.get_dictionary_of_affinities(xmlout, sort=True)
for phase in affinity_dict:
    affinity, formulae = affinity_dict[phase]
    print(f"{phase:<20s} {affinity:10.2f} {formulae:<60s}")

# Set up for sequential calculations and plotting
number_of_steps = 20
t_increment = -1.0
p_increment = 0.0

plotPhases = ['Liquid', 'Sanidine', 'Plagioclase', 'Quartz', 'Water']
plotColors = ['ro', 'bo', 'go', 'co', 'mo']

# Initialize data arrays for plotting
n = len(plotPhases)
xPlot = np.zeros(number_of_steps + 1)
yPlot = np.zeros((n, number_of_steps + 1))

xPlot
  • = t
for i in range(n):
    yPlot
  • = melts.get_property_of_phase(xmlout, plotPhases)

# Create a plot for the phase data
plt.ion()
fig, ax = plt.subplots()
ax.set_xlim([min(t, t + t_increment * number_of_steps), max(t, t + t_increment * number_of_steps)])
ax.set_ylim([0.0, 100.0])

graphs = [ax.plot(xPlot, yPlot, plotColors)
  • for i in range(n)]
ax.legend(graphs, plotPhases, loc='upper left')

# Perform sequential calculations and update the plot
for i in range(1, number_of_steps + 1):
    output = melts.equilibrate_tp(t + i * t_increment, p + i * p_increment)
    status, t, p, xmlout = output
    print(f"{status:<30s} {t:8.2f} {p:8.2f}")

    xPlot = t
    for j in range(n):
        yPlot[j] = melts.get_property_of_phase(xmlout, plotPhases[j])

    for j, graph in enumerate(graphs):
        graph.set_xdata(xPlot)
        graph.set_ydata(yPlot[j])

    fig.canvas.draw()

# Show the plot (important for standard Python scripts)
plt.show()
~~~~~~~~~~~

I know these examples are designed to run on the ENKI server. However, I encountered difficulties translating them into a Python script, particularly because I couldn't find the thermoengine  module referenced in the original examples. This has been a blocking issue, preventing me from running the code successfully on my local machine.

Could someone kindly help me verify the code or guide me in correctly setting it up and running it in Python, so I can run it smoothly, just like the example from this web link (https://github.com/magmasource/alphaMELTS/blob/main/examples/py/tutorial.py), using the "alphamelts-py-2.3.1-win64" package on my personal computer?

I would greatly appreciate any advice or insights.

Thank you in advance for your help!

Best regards,
Shanke


#16
Windows / Re: Ways to Resolve Locale War...
Last post by Paula - October 07, 2024, 09:54:40 AM
Thank you so much! The install.command script does something similar, but the .bat files it writes do not have the LANG and LC_ALL lines. I'll add your fix to install.command in alphaMELTS 1.9 and also implement something similar in alphaMELTS 2. See https://github.com/magmasource/alphaMELTS

The new alphaMELTS command line interface, currently v2.3.1, is much easier to use than 1.9. It has tab completion and a more flexible menu. That means we really do not need to support double-clicking on Mac anymore, which in turn means the installation can be simplified for all platforms. I was planning to do that sometime soon, but will now incorporate your locale workaround at the same time.

Thanks again,
Paula
#17
Windows / Ways to Resolve Locale Warning...
Last post by liushanke - October 06, 2024, 06:32:23 AM
I've recently started learning how to use alphaMelts, and I found it quite complex, especially for beginners. I experimented with different ways to run the script and encountered issues when using Perl, particularly with the "en_US.UTF-8" locale settings. Below, I provide a guide to help others who might face the same problem.

If a similar method has already been shared, I kindly ask the forum administrators to remove this post. Thank you!

If you try to run `run_alphamelts.command` using Perl when the locale is not set to "en_US.UTF-8" (e.g., it defaults to "Chinese (Simplified)_China.936," which is unsupported by the Perl interpreter), you will encounter warnings related to locale settings. This happens because Perl expects to use the "en_US.UTF-8" locale. To resolve this issue, there are two common solutions:

Option 1: Create a Batch Script

You can create a batch script that sets the locale and then runs your Perl command. Follow these steps:

1. Open **Notepad** or any text editor and paste the following code:

    @echo off
    set LANG=C
    set LC_ALL=C
    perl C:\your\local\file\folder\run_alphamelts.command (Replace `C:\your\local\file\folder\` with the path to the folder where the `run_alphamelts.command` script is located.)

2. Save this file with a `.bat` extension, for example, `run_alphamelts.bat`.

3. Double-click the `.bat` file to run the script. This batch script sets the locale variables to "C" and then executes your Perl script.

Option 2: Set Environment Variables Permanently

You can also set the `LANG` and `LC_ALL` environment variables permanently in the system settings:

1. Press `Windows + R`, type `sysdm.cpl`, and press Enter to open "System Properties".
2. Go to the "Advanced tab" and click on "Environment Variables".
3. In the "System variables" section, click "New" to create a new environment variable:
    - Variable name: `LANG`
    - Variable value: `C`
4. Click "New" again to create another environment variable:
    - Variable name: `LC_ALL`
    - Variable value: `C`
5. Click "OK" to close all windows and apply the changes.
6. Restart your computer for the changes to take effect.
#18
Thank you, Paula.
Writing out a .melts file and running it in the alphaMELTS 2 may be a quick way to obtain the solid composition.
I will try it.
#19
All the information is there but spread across multiple files and I don't think there's a quick way to create the solid composition for open system runs. What I would do is write out a .melts file just after you have set up the assimilation run in easyMelts. Add an "Output: both" line and run it in the standalone alphaMELTS 2 app. That way you'll get the alphaMELTS-style output as well as the melts.out / .tbl files.
#20
Hi, Paula,
Sorry to bother you again.
I have recently conducted some carbonate assimilation calculations by using easyMELTS.
However, there is no solid composition in these output files, only liquid and mineral compositions.
So I was wondering how to make easyMELTS give the solid composition automatically, just like the alphaMELTS2.
Thank you.