Skip to content

Commit b41168f

Browse files
committed
add perplex-burnman-aspect workflow
1 parent 1ea2fb7 commit b41168f

11 files changed

+495
-306
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
*.tmp
88
*.pyc
99
/contrib/perplex/perplex-installer
10-
/contrib/perplex/iron_olivine_lo_res
10+
/contrib/perplex/iron_olivine_lo_res
11+
/contrib/perplex/ASPECT_1D_isentrope_properties.txt

contrib/perplex/Readme.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Perple_X P-T Table Generation
22

3-
This repository contains scripts and resources to download, install, and use **Perple_X** to generate and read a low-resolution thermodynamic table for an iron-olivine system. It can be used as a template to
4-
create and read your own tables.
3+
This repository contains scripts and resources to download, install, and use **Perple_X** to generate and read a low-resolution thermodynamic table for an iron-olivine system. It also contains a script to
4+
create a smoothed 1D adiabatic profile for use in ASPECT (https://github.com/geodynamics/aspect/).
5+
6+
These scripts can be used as a template to create, read and process your own tables.
57

68
## Contents
79

@@ -12,10 +14,18 @@ create and read your own tables.
1214
A Python script to generate a low-resolution thermodynamic table using Perple_X. This script calls Perple_X programs and configures the run for a simplified system.
1315

1416
- **read_lo_res_table.py**
15-
A Python script to read and parse the generated low-resolution table (e.g., from `table.txt`) for further analysis or plotting.
17+
A Python script to read and parse the generated low-resolution table for further
18+
analysis and plotting.
19+
20+
- **generate_aspect_compatible_1D_adiabat_table.py**
21+
A Python script to generate a smoothed table of properties along a 1D isentrope using
22+
a generated table.
1623

1724
- **perplex_utils.py**
18-
A python file containing useful Perple_X-related functions.
25+
A python file containing useful Perple_X-related functions. The start of the file defines
26+
some database dictionaries for the Holland and Powell (2018),
27+
and Stixrude and Lithgow-Bertelloni (2021, 2024) datasets which can be passed to the other
28+
functions or used as a basis for your own dictionaries.
1929

2030
## Getting Started
2131

@@ -41,9 +51,18 @@ create and read your own tables.
4151
python read_lo_res_table.py
4252
```
4353

44-
This script parses the output table for further use (e.g., plotting or machine learning workflows).
54+
This script parses the output table for further use (e.g., evaluating properties or plotting).
55+
56+
4. **Create ASPECT compatible Table:**
57+
58+
```bash
59+
python generate_aspect_compatible_1D_adiabat_table.py
60+
```
61+
62+
This script creates an ASPECT-compatible table.
4563

4664
## Notes
4765

48-
- The resolution and thermodynamic scope in this example are intentionally simplified.
66+
- The resolution and thermodynamic scope in this example are intentionally simplified. You will
67+
need to change the scripts if you want to increase the resolution.
4968
- Make sure to review Perple_X license and citation guidelines when using in published work.

contrib/perplex/create_lo_res_table.py

Lines changed: 59 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -9,68 +9,71 @@
99
from perplex_utils import run_vertex, run_pssect
1010
from perplex_utils import create_perplex_table
1111

12-
project_name = "iron_olivine_lo_res"
13-
database = databases["stx24"]
14-
composition = burnman.Composition(
15-
{"MgO": 1.8, "FeO": 0.2, "SiO2": 1.0, "Fe": 0.1}, "molar"
16-
)
17-
pressure_range = [1.0e5, 10.0e9]
18-
temperature_range = [200.0, 3000.0]
19-
n_pressures = 11
20-
n_temperatures = 11
21-
outfile = "iron_olivine_lo_res_table.dat"
12+
if __name__ == "__main__":
13+
project_name = "iron_olivine_lo_res"
14+
database = databases["stx24"]
15+
composition = burnman.Composition(
16+
{"MgO": 1.8, "FeO": 0.2, "SiO2": 1.0, "Fe": 0.1}, "molar"
17+
)
18+
pressure_range = [1.0e5, 10.0e9]
19+
temperature_range = [200.0, 3000.0]
20+
n_pressures = 11
21+
n_temperatures = 11
22+
outfile = "iron_olivine_lo_res_table.dat"
2223

23-
perplex_dir = os.path.join(os.getcwd(), "perplex-installer/Perple_X")
24-
perplex_bindir = os.path.join(os.getcwd(), "perplex-installer/Perple_X/bin")
24+
perplex_dir = os.path.join(os.getcwd(), "perplex-installer/Perple_X")
25+
perplex_bindir = os.path.join(os.getcwd(), "perplex-installer/Perple_X/bin")
2526

26-
try:
27-
shutil.rmtree(project_name)
28-
print(f"Deleted old project directory ({project_name}).")
29-
except FileNotFoundError:
30-
pass
27+
try:
28+
shutil.rmtree(project_name)
29+
print(f"Deleted old project directory ({project_name}).")
30+
except FileNotFoundError:
31+
pass
3132

32-
os.mkdir(project_name)
33-
os.chdir(project_name)
34-
print(f"Now working in newly created directory ({os.getcwd().split("/")[-1]}).")
33+
os.mkdir(project_name)
34+
os.chdir(project_name)
35+
print(f"Now working in newly created directory ({project_name}).")
3536

36-
print("Creating local copies of requested thermodynamic data files...")
37-
endmember_file = os.path.join(perplex_dir, "datafiles", database["data_file"])
38-
solution_file = os.path.join(perplex_dir, "datafiles", database["solution_model_file"])
39-
shutil.copyfile(endmember_file, os.path.join(os.getcwd(), database["data_file"]))
40-
shutil.copyfile(
41-
solution_file, os.path.join(os.getcwd(), database["solution_model_file"])
42-
)
43-
perplex_option_file = "burnman_perplex_options.dat"
37+
print("Creating local copies of requested thermodynamic data files...")
38+
endmember_file = os.path.join(perplex_dir, "datafiles", database["data_file"])
39+
solution_file = os.path.join(
40+
perplex_dir, "datafiles", database["solution_model_file"]
41+
)
42+
shutil.copyfile(endmember_file, os.path.join(os.getcwd(), database["data_file"]))
43+
shutil.copyfile(
44+
solution_file, os.path.join(os.getcwd(), database["solution_model_file"])
45+
)
46+
perplex_option_file = "burnman_perplex_options.dat"
4447

45-
with open(perplex_option_file, "w") as f:
46-
f.write("sample_on_grid F")
48+
with open(perplex_option_file, "w") as f:
49+
f.write("sample_on_grid F")
4750

48-
print("Making build file...")
49-
make_build_file(
50-
perplex_bindir,
51-
project_name,
52-
database,
53-
perplex_option_file,
54-
composition,
55-
pressure_range,
56-
temperature_range,
57-
verbose=False,
58-
)
51+
print("Making build file...")
52+
make_build_file(
53+
perplex_bindir,
54+
project_name,
55+
database,
56+
perplex_option_file,
57+
composition,
58+
pressure_range,
59+
temperature_range,
60+
verbose=False,
61+
)
5962

60-
print("Running vertex...")
61-
run_vertex(perplex_bindir, project_name, verbose=False)
63+
print("Running vertex...")
64+
run_vertex(perplex_bindir, project_name, verbose=False)
6265

63-
print("Running pssect...")
64-
run_pssect(perplex_bindir, project_name, convert_to_pdf=False, verbose=False)
66+
print("Running pssect...")
67+
run_pssect(perplex_bindir, project_name, convert_to_pdf=False, verbose=False)
6568

66-
print("Creating BurnMan-readable table...")
67-
create_perplex_table(
68-
perplex_bindir,
69-
project_name,
70-
outfile,
71-
n_pressures,
72-
n_temperatures,
73-
pressure_range,
74-
temperature_range,
75-
)
76-
print("Processing complete.")
69+
print("Creating BurnMan-readable table...")
70+
create_perplex_table(
71+
perplex_bindir,
72+
project_name,
73+
outfile,
74+
n_pressures,
75+
n_temperatures,
76+
pressure_range,
77+
temperature_range,
78+
)
79+
print("Processing complete.")

contrib/perplex/download_and_install_perplex.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#!/bin/bash
22

33
if [ -d perplex-installer ]; then
4-
rm -rf perplex-installer
4+
cd perplex-installer
5+
git pull --recurse-submodules origin main
6+
cd ..
7+
else
8+
git clone --recurse-submodules https://github.com/bobmyhill/perplex-installer.git
9+
cd perplex-installer
10+
./install_perplex.sh
11+
cd ..
512
fi
6-
git clone --recursive [email protected]:bobmyhill/perplex-installer.git
7-
cd perplex-installer
8-
./install_perplex.sh
9-
cd ..

0 commit comments

Comments
 (0)