Skip to content

Add library of solidus/liquidus parameterizations selectable via melting_dir parameter#658

Open
planetmariana wants to merge 14 commits intomainfrom
melting_curves_library
Open

Add library of solidus/liquidus parameterizations selectable via melting_dir parameter#658
planetmariana wants to merge 14 commits intomainfrom
melting_curves_library

Conversation

@planetmariana
Copy link
Member

@planetmariana planetmariana commented Mar 22, 2026

Description

This pull request introduces a script to generate and manage a collection of solidus and liquidus parameterizations from the literature. The goal is to allow users to easily select different melting curves through the melting_dir parameter in the PROTEUS .toml file.

The new script (solidus_func.py) computes melting curves in both P–T and P–S space and stores them as lookup tables in:

$FWL_DATA/interior_lookup_tables/Melting_curves/

Each parametrization is saved in its own folder and can be selected at runtime without additional computation. For each parametrization, the workflow is as follows:

  • The solidus and liquidus curves are first constructed in P–T space

  • Any non-physical regions where the curves cross (i.e. solidus ≥ liquidus) are automatically detected and truncated to retain only the valid interval

  • The curves are then converted into P–S space by inverting the EOS relation, while respecting the valid thermodynamic bounds of the EOS tables (in this case the ones previously used by SPIDER - Bower et. al 2018-)

  • This ensures that all generated melting curves are physically consistent and compatible with the EOS used in PROTEUS.

This feature enables straightforward comparison between different melting models and facilitates testing their impact on interior evolution.

Closes #656

The full set of melting curves are shown here in P-T and P-S:
melting_curves_grid_PT_PS

To check that all the intermediate steps were correct, I tested the final output in P-S space with the original tables from SPIDER:
test

Validation of changes

  • The implementation was tested by running:
python src/proteus/utils/solidus_func.py --all

to generate all melting curve parametrizations.

  • Verifying that all expected output files (solidus_P-T.dat, liquidus_P-T.dat, solidus_P-S.dat, liquidus_P-S.dat) are correctly created in the FWL_DATA directory

  • Running PROTEUS simulations with different melting_dir values (e.g. wolf_bower_2018, katz_2003, lin_2024) and confirming that:

The correct melting curves are loaded

  • No runtime computation of melting curves is performed

  • Simulations take this specific file in SPIDER.

Test configuration with Python 3.12.

Checklist

  • [X ] I have followed the contributing guidelines
  • [ X] My code follows the style guidelines of this project
  • [X ] I have performed a self-review of my code
  • [ X] My changes generate no new warnings or errors
  • [X ] I have checked that the tests still pass on my computer
  • [X ] I have updated the docs, as appropriate
  • [ X] I have added tests for these changes, as appropriate
  • I have checked that all dependencies have been updated, as required

Relevant people

Tag people who should know about this PR here

Copilot AI review requested due to automatic review settings March 22, 2026 18:18
@planetmariana planetmariana requested a review from a team as a code owner March 22, 2026 18:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds infrastructure to support multiple solidus/liquidus parameterizations selectable via interior.melting_dir, primarily by introducing a generator that exports P–T and P–S lookup tables into $FWL_DATA/interior_lookup_tables/Melting_curves/<model>/.

Changes:

  • Added src/proteus/utils/solidus_func.py to generate/export melting curves (P–T and P–S) for multiple literature models.
  • Updated download_melting_curves() to recognize a canonical flat file layout (including P–S tables) and skip downloads when present.
  • Updated config/docs/examples to reference and explain the new melting-curve workflow.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/proteus/utils/solidus_func.py New CLI/script to generate model libraries and export P–T/P–S lookup tables into FWL_DATA.
src/proteus/utils/data.py Enhances melting-curve acquisition logic: checks for local canonical files, falls back to remote mapping, maintains legacy P–T filename compatibility.
input/ensembles/example.grid.toml Changes example ensemble defaults (SLURM enabled and higher job/time limits).
input/all_options.toml Updates example/default config values, including interior.melting_dir.
docs/How-to/usage.md Adds a “Melting Curves” section describing available parameterizations and how to generate tables.
Comments suppressed due to low confidence (1)

input/all_options.toml:314

  • melting_dir is set here to andrault_2011, but proteus get interiordata defaults to using input/all_options.toml and download_melting_curves() only knows how to download a small set of melting curves from the remote DATA_SOURCE_MAP (currently Monteux±600 and Wolf_Bower+2018). On a clean install this will raise “No data source mapping found …” unless the user has already generated local tables. Consider keeping the default as a remotely downloadable curve (e.g. Monteux-600) or adding a corresponding data-source mapping / automated generation step so the default CLI path works out of the box.
    melting_dir     = "Monteux-600" # Melting curve set used by all interior modules (Zalmoxis, Aragog, SPIDER)

@codecov
Copy link

codecov bot commented Mar 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.33%. Comparing base (e637066) to head (a0e7d02).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #658      +/-   ##
==========================================
+ Coverage   69.12%   69.33%   +0.20%     
==========================================
  Files          98       98              
  Lines       10123    10130       +7     
  Branches     1401     1402       +1     
==========================================
+ Hits         6998     7024      +26     
+ Misses       2791     2786       -5     
+ Partials      334      320      -14     
Flag Coverage Δ
unit-tests 56.33% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@timlichtenberg
Copy link
Member

@planetmariana please address the bot reviewers, reply to them and click "resolve" once you are happy with this and then please ping us/me again once you think this should be reviewed by us.

@planetmariana
Copy link
Member Author

planetmariana commented Mar 24, 2026

@timlichtenberg @maraattia @nichollsh this is ready for review !

@planetmariana planetmariana requested a review from nichollsh March 24, 2026 16:40
Copy link
Member

@nichollsh nichollsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, @planetmariana! It is going to be extremely useful to have all of these melting curves available. I am already curious to see the different types of solidification mode that will arise from switching between them.

I ran your script following the documentation instructions and it worked as described. I then modified all_options.toml to use the generated Fei+21 curve with SPIDER, which also ran fine.

A few minor code-related comments below to implement, before this is ready to be approved and merged.

Before running PROTEUS, generate the lookup tables:

```console
python src/proteus/utils/solidus_func.py --all
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executable script should be located in tools/ not in src/.

core_heatcap = 880.0 # Core specific heat capacity [J K-1 kg-1]

module = "zalmoxis" # self | zalmoxis
module = "self" # self | zalmoxis
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change this?

Comment on lines +1190 to +1202
def main():
args = parse_args()

shortcut_model = resolve_requested_model(args)
explicit_model = args.model

if args.all:
if explicit_model is not None or shortcut_model is not None:
raise SystemExit(
'Error: please use either --all or a single model selection, not both.'
)
try:
export_all_models(out_root=args.out_root, n=args.n, spider_dir=args.spider_dir)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executable scripts should not be located inside the PROTEUS src/ folder. They should only be in the tools/ folder.

It would be best to keep most of the functions inside this file (so that they are accessible to the rest of PROTEUS) but move all of the 'executable' parts (e.g. main()) into a separate script in tools/.

Putting executables in src/ does not follow the existing code structure.

if len(selected_models) == 0:
raise SystemExit(
'Error: no model selected. Use --all or choose one model with '
'--model or a shortcut like --katz2003.'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

List the available models, here, or point the user to the documentation which lists them.

Comment on lines +534 to +545
nP = 2020
nS_solid = 125
nS_liquid = 95
skip_header = 5

SCALE_P_EOS = 1e9
SCALE_T_EOS = 1.0
SCALE_S_SOLID_EOS = 4.82426684604467e6
SCALE_S_LIQUID_EOS = 4.805046659407042e6

SCALE_P_OUT = 1_000_000_000.0
SCALE_S_OUT = 4_824_266.84604467
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Global variables are generally bad practice. Can you move these into the relevant functions where possible? Ideally, can you make them optional function arguments?

Comment on lines +573 to +578
def get_default_spider_dir() -> Path:
"""
Return the default SPIDER directory relative to this module.
"""
script_dir = Path(__file__).resolve().parent
return (script_dir / '../../../SPIDER').resolve()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe there's already functionality for this in utils.py.

Comment on lines +464 to +467
andrault_2011_cut = truncate_to_physical_interval(andrault_2011)
monteux_2016_cut = truncate_to_physical_interval(monteux_2016)
wolf_bower_2018_cut = truncate_to_physical_interval(wolf_bower_2018)
katz_2003_cut = truncate_to_physical_interval(katz_2003)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These do not need to be global variables. Can you put them inside the relevant functions?

Comment on lines +923 to +924
print(f' Saved to : {out_dir.resolve()}')
print()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use log.info rather than print if possible. This applies throughout the file.

Comment on lines +310 to +319
- andrault_2011
- monteux_2016
- wolf_bower_2018
- katz_2003
- fei_2021
- belonoshko_2005
- fiquet_2010
- hirschmann_2000
- stixrude_2014
- lin_2024
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this documentation. It would be worthwhile moving the large comment at the start of solidus_func.py into the documentation where people can more easily see it. This includes the literature references.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add library of solidus parameterizations selectable via melting_dir parameter

4 participants