pychnosz 1.1.1__cp311-cp311-macosx_10_13_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pychnosz/.dylibs/libgcc_s.1.1.dylib +0 -0
- pychnosz/.dylibs/libgfortran.5.dylib +0 -0
- pychnosz/.dylibs/libquadmath.0.dylib +0 -0
- pychnosz/__init__.py +129 -0
- pychnosz/biomolecules/__init__.py +29 -0
- pychnosz/biomolecules/ionize_aa.py +197 -0
- pychnosz/biomolecules/proteins.py +595 -0
- pychnosz/core/__init__.py +46 -0
- pychnosz/core/affinity.py +1256 -0
- pychnosz/core/animation.py +593 -0
- pychnosz/core/balance.py +334 -0
- pychnosz/core/basis.py +716 -0
- pychnosz/core/diagram.py +3336 -0
- pychnosz/core/equilibrate.py +813 -0
- pychnosz/core/equilibrium.py +554 -0
- pychnosz/core/info.py +821 -0
- pychnosz/core/retrieve.py +364 -0
- pychnosz/core/speciation.py +580 -0
- pychnosz/core/species.py +599 -0
- pychnosz/core/subcrt.py +1700 -0
- pychnosz/core/thermo.py +593 -0
- pychnosz/core/unicurve.py +1226 -0
- pychnosz/data/__init__.py +11 -0
- pychnosz/data/add_obigt.py +327 -0
- pychnosz/data/extdata/Berman/BDat17_2017.csv +2 -0
- pychnosz/data/extdata/Berman/Ber88_1988.csv +68 -0
- pychnosz/data/extdata/Berman/Ber90_1990.csv +5 -0
- pychnosz/data/extdata/Berman/DS10_2010.csv +6 -0
- pychnosz/data/extdata/Berman/FDM+14_2014.csv +2 -0
- pychnosz/data/extdata/Berman/Got04_2004.csv +5 -0
- pychnosz/data/extdata/Berman/JUN92_1992.csv +3 -0
- pychnosz/data/extdata/Berman/SHD91_1991.csv +12 -0
- pychnosz/data/extdata/Berman/VGT92_1992.csv +2 -0
- pychnosz/data/extdata/Berman/VPT01_2001.csv +3 -0
- pychnosz/data/extdata/Berman/VPV05_2005.csv +2 -0
- pychnosz/data/extdata/Berman/ZS92_1992.csv +11 -0
- pychnosz/data/extdata/Berman/sympy.R +99 -0
- pychnosz/data/extdata/Berman/testing/BA96.bib +12 -0
- pychnosz/data/extdata/Berman/testing/BA96_Berman.csv +21 -0
- pychnosz/data/extdata/Berman/testing/BA96_OBIGT.csv +21 -0
- pychnosz/data/extdata/Berman/testing/BA96_refs.csv +6 -0
- pychnosz/data/extdata/OBIGT/AD.csv +25 -0
- pychnosz/data/extdata/OBIGT/Berman_cr.csv +93 -0
- pychnosz/data/extdata/OBIGT/DEW.csv +211 -0
- pychnosz/data/extdata/OBIGT/H2O_aq.csv +4 -0
- pychnosz/data/extdata/OBIGT/SLOP98.csv +411 -0
- pychnosz/data/extdata/OBIGT/SUPCRT92.csv +178 -0
- pychnosz/data/extdata/OBIGT/inorganic_aq.csv +729 -0
- pychnosz/data/extdata/OBIGT/inorganic_cr.csv +273 -0
- pychnosz/data/extdata/OBIGT/inorganic_gas.csv +20 -0
- pychnosz/data/extdata/OBIGT/organic_aq.csv +1104 -0
- pychnosz/data/extdata/OBIGT/organic_cr.csv +481 -0
- pychnosz/data/extdata/OBIGT/organic_gas.csv +268 -0
- pychnosz/data/extdata/OBIGT/organic_liq.csv +533 -0
- pychnosz/data/extdata/OBIGT/testing/GEMSFIT.csv +43 -0
- pychnosz/data/extdata/OBIGT/testing/IGEM.csv +17 -0
- pychnosz/data/extdata/OBIGT/testing/Sandia.csv +8 -0
- pychnosz/data/extdata/OBIGT/testing/SiO2.csv +4 -0
- pychnosz/data/extdata/misc/AD03_Fig1a.csv +69 -0
- pychnosz/data/extdata/misc/AD03_Fig1b.csv +43 -0
- pychnosz/data/extdata/misc/AD03_Fig1c.csv +89 -0
- pychnosz/data/extdata/misc/AD03_Fig1d.csv +30 -0
- pychnosz/data/extdata/misc/BZA10.csv +5 -0
- pychnosz/data/extdata/misc/HW97_Cp.csv +90 -0
- pychnosz/data/extdata/misc/HWM96_V.csv +229 -0
- pychnosz/data/extdata/misc/LA19_test.csv +7 -0
- pychnosz/data/extdata/misc/Mer75_Table4.csv +42 -0
- pychnosz/data/extdata/misc/OBIGT_check.csv +423 -0
- pychnosz/data/extdata/misc/PM90.csv +7 -0
- pychnosz/data/extdata/misc/RH95.csv +23 -0
- pychnosz/data/extdata/misc/RH98_Table15.csv +17 -0
- pychnosz/data/extdata/misc/SC10_Rainbow.csv +19 -0
- pychnosz/data/extdata/misc/SK95.csv +55 -0
- pychnosz/data/extdata/misc/SOJSH.csv +61 -0
- pychnosz/data/extdata/misc/SS98_Fig5a.csv +81 -0
- pychnosz/data/extdata/misc/SS98_Fig5b.csv +84 -0
- pychnosz/data/extdata/misc/TKSS14_Fig2.csv +25 -0
- pychnosz/data/extdata/misc/bluered.txt +1000 -0
- pychnosz/data/extdata/protein/Cas/Cas_aa.csv +177 -0
- pychnosz/data/extdata/protein/Cas/Cas_uniprot.csv +186 -0
- pychnosz/data/extdata/protein/Cas/download.R +34 -0
- pychnosz/data/extdata/protein/Cas/mkaa.R +34 -0
- pychnosz/data/extdata/protein/POLG.csv +12 -0
- pychnosz/data/extdata/protein/TBD+05.csv +393 -0
- pychnosz/data/extdata/protein/TBD+05_aa.csv +393 -0
- pychnosz/data/extdata/protein/rubisco.csv +28 -0
- pychnosz/data/extdata/protein/rubisco.fasta +239 -0
- pychnosz/data/extdata/protein/rubisco_aa.csv +28 -0
- pychnosz/data/extdata/src/H2O92D.f.orig +3457 -0
- pychnosz/data/extdata/src/README.txt +5 -0
- pychnosz/data/extdata/taxonomy/names.dmp +215 -0
- pychnosz/data/extdata/taxonomy/nodes.dmp +63 -0
- pychnosz/data/extdata/thermo/Bdot_acirc.csv +60 -0
- pychnosz/data/extdata/thermo/buffer.csv +40 -0
- pychnosz/data/extdata/thermo/element.csv +135 -0
- pychnosz/data/extdata/thermo/groups.csv +6 -0
- pychnosz/data/extdata/thermo/opt.csv +2 -0
- pychnosz/data/extdata/thermo/protein.csv +506 -0
- pychnosz/data/extdata/thermo/refs.csv +343 -0
- pychnosz/data/extdata/thermo/stoich.csv.xz +0 -0
- pychnosz/data/loader.py +431 -0
- pychnosz/data/mod_obigt.py +322 -0
- pychnosz/data/obigt.py +471 -0
- pychnosz/data/worm.py +228 -0
- pychnosz/fortran/__init__.py +16 -0
- pychnosz/fortran/h2o92.dylib +0 -0
- pychnosz/fortran/h2o92_interface.py +527 -0
- pychnosz/geochemistry/__init__.py +21 -0
- pychnosz/geochemistry/minerals.py +514 -0
- pychnosz/geochemistry/redox.py +500 -0
- pychnosz/models/__init__.py +47 -0
- pychnosz/models/archer_wang.py +165 -0
- pychnosz/models/berman.py +309 -0
- pychnosz/models/cgl.py +381 -0
- pychnosz/models/dew.py +997 -0
- pychnosz/models/hkf.py +523 -0
- pychnosz/models/hkf_helpers.py +222 -0
- pychnosz/models/iapws95.py +1113 -0
- pychnosz/models/supcrt92_fortran.py +238 -0
- pychnosz/models/water.py +480 -0
- pychnosz/utils/__init__.py +27 -0
- pychnosz/utils/expression.py +1074 -0
- pychnosz/utils/formula.py +830 -0
- pychnosz/utils/formula_ox.py +227 -0
- pychnosz/utils/reset.py +33 -0
- pychnosz/utils/units.py +259 -0
- pychnosz-1.1.1.dist-info/METADATA +197 -0
- pychnosz-1.1.1.dist-info/RECORD +131 -0
- pychnosz-1.1.1.dist-info/WHEEL +5 -0
- pychnosz-1.1.1.dist-info/licenses/LICENSE.txt +19 -0
- pychnosz-1.1.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Data management and access for CHNOSZ thermodynamic database."""
|
|
2
|
+
|
|
3
|
+
from .loader import DataLoader, get_default_loader
|
|
4
|
+
from .obigt import OBIGTDatabase, get_default_obigt
|
|
5
|
+
|
|
6
|
+
__all__ = [
|
|
7
|
+
'DataLoader',
|
|
8
|
+
'get_default_loader',
|
|
9
|
+
'OBIGTDatabase',
|
|
10
|
+
'get_default_obigt'
|
|
11
|
+
]
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Implementation of add_OBIGT() function for Python CHNOSZ.
|
|
3
|
+
|
|
4
|
+
This function loads external OBIGT database files and replaces or adds
|
|
5
|
+
entries to the currently loaded thermodynamic database, mimicking the
|
|
6
|
+
behavior of R CHNOSZ add.OBIGT() function.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import pandas as pd
|
|
10
|
+
import numpy as np
|
|
11
|
+
import os
|
|
12
|
+
from typing import Union, List, Optional
|
|
13
|
+
import warnings
|
|
14
|
+
|
|
15
|
+
from ..core.thermo import thermo
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def add_OBIGT(file: Union[str, pd.DataFrame], force: bool = True, messages: bool = True) -> List[int]:
|
|
19
|
+
"""
|
|
20
|
+
Add or replace entries in the thermodynamic database from external files or DataFrames.
|
|
21
|
+
|
|
22
|
+
This function replicates the behavior of R CHNOSZ add.OBIGT() by loading
|
|
23
|
+
CSV files from inst/extdata/OBIGT/ or accepting pandas DataFrames directly,
|
|
24
|
+
and replacing entries with matching names.
|
|
25
|
+
|
|
26
|
+
Parameters
|
|
27
|
+
----------
|
|
28
|
+
file : str or pd.DataFrame
|
|
29
|
+
Either:
|
|
30
|
+
- Name of the database file to load (e.g., "SUPCRT92")
|
|
31
|
+
The function will look for file.csv in inst/extdata/OBIGT/
|
|
32
|
+
- Full path to a CSV file
|
|
33
|
+
- A pandas DataFrame containing OBIGT data
|
|
34
|
+
force : bool, default True
|
|
35
|
+
If True, proceed even if some species are not found
|
|
36
|
+
messages : bool, default True
|
|
37
|
+
If True, print informational messages about additions/replacements
|
|
38
|
+
If False, suppress all output (equivalent to R's suppressMessages())
|
|
39
|
+
|
|
40
|
+
Returns
|
|
41
|
+
-------
|
|
42
|
+
list of int
|
|
43
|
+
List of species indices (1-based) that were added or replaced
|
|
44
|
+
|
|
45
|
+
Examples
|
|
46
|
+
--------
|
|
47
|
+
>>> import pychnosz
|
|
48
|
+
>>> import pandas as pd
|
|
49
|
+
>>>
|
|
50
|
+
>>> # Example 1: Load from file name
|
|
51
|
+
>>> pychnosz.reset()
|
|
52
|
+
>>> indices = pychnosz.add_OBIGT("SUPCRT92")
|
|
53
|
+
>>>
|
|
54
|
+
>>> # Example 2: Load from DataFrame
|
|
55
|
+
>>> thermo_df = pd.read_csv("thermodata.csv")
|
|
56
|
+
>>> indices = pychnosz.add_OBIGT(thermo_df)
|
|
57
|
+
>>>
|
|
58
|
+
>>> # Example 3: Suppress messages
|
|
59
|
+
>>> indices = pychnosz.add_OBIGT(thermo_df, messages=False)
|
|
60
|
+
|
|
61
|
+
Notes
|
|
62
|
+
-----
|
|
63
|
+
This function modifies the thermo() object in place, replacing entries
|
|
64
|
+
with matching names and adding new entries for species not in the database.
|
|
65
|
+
The behavior exactly matches R CHNOSZ add.OBIGT().
|
|
66
|
+
"""
|
|
67
|
+
|
|
68
|
+
# Get the thermo system
|
|
69
|
+
thermo_sys = thermo()
|
|
70
|
+
|
|
71
|
+
# Ensure the thermodynamic system is initialized
|
|
72
|
+
if not thermo_sys.is_initialized() or thermo_sys.obigt is None:
|
|
73
|
+
thermo_sys.reset()
|
|
74
|
+
|
|
75
|
+
# Handle DataFrame input
|
|
76
|
+
if isinstance(file, pd.DataFrame):
|
|
77
|
+
new_data = file.copy()
|
|
78
|
+
file_path = "<DataFrame>"
|
|
79
|
+
file_basename = None
|
|
80
|
+
else:
|
|
81
|
+
# Handle string file path
|
|
82
|
+
# If file is not an existing path, look for it in OBIGT directories
|
|
83
|
+
if not os.path.exists(file):
|
|
84
|
+
if not file.endswith('.csv'):
|
|
85
|
+
file_to_find = file + '.csv'
|
|
86
|
+
else:
|
|
87
|
+
file_to_find = file
|
|
88
|
+
|
|
89
|
+
# Look for the file in the OBIGT data directory
|
|
90
|
+
# Use package-relative path
|
|
91
|
+
base_paths = [
|
|
92
|
+
os.path.join(os.path.dirname(__file__), 'extdata', 'OBIGT'),
|
|
93
|
+
]
|
|
94
|
+
|
|
95
|
+
file_path = None
|
|
96
|
+
for base_path in base_paths:
|
|
97
|
+
potential_path = os.path.join(base_path, file_to_find)
|
|
98
|
+
if os.path.exists(potential_path):
|
|
99
|
+
file_path = potential_path
|
|
100
|
+
break
|
|
101
|
+
|
|
102
|
+
if file_path is None:
|
|
103
|
+
raise FileNotFoundError(f"Could not find OBIGT file: {file}")
|
|
104
|
+
else:
|
|
105
|
+
# Use the file path as provided
|
|
106
|
+
file_path = file
|
|
107
|
+
|
|
108
|
+
# Extract the basename for source_file column
|
|
109
|
+
file_basename = os.path.basename(file_path)
|
|
110
|
+
|
|
111
|
+
# Read the CSV file
|
|
112
|
+
try:
|
|
113
|
+
new_data = pd.read_csv(file_path)
|
|
114
|
+
except Exception as e:
|
|
115
|
+
raise ValueError(f"Error reading {file_path}: {e}")
|
|
116
|
+
|
|
117
|
+
if new_data.empty:
|
|
118
|
+
raise ValueError(f"No data found in {file_path if isinstance(file, str) else 'DataFrame'}")
|
|
119
|
+
|
|
120
|
+
# Validate columns before processing
|
|
121
|
+
# Get the current OBIGT database to determine required columns
|
|
122
|
+
to1 = thermo_sys.obigt
|
|
123
|
+
|
|
124
|
+
# Define core required columns that all species must have
|
|
125
|
+
# These are the fundamental columns needed for thermodynamic calculations
|
|
126
|
+
# Model-specific columns (logK*, T*, P*, etc.) are optional
|
|
127
|
+
core_required_columns = [
|
|
128
|
+
'name', 'abbrv', 'formula', 'state', 'ref1', 'ref2', 'date', 'E_units',
|
|
129
|
+
'G', 'H', 'S', 'Cp', 'V',
|
|
130
|
+
'a1.a', 'a2.b', 'a3.c', 'a4.d', 'c1.e', 'c2.f', 'omega.lambda', 'z.T'
|
|
131
|
+
]
|
|
132
|
+
|
|
133
|
+
# The 'model' column is optional and will be auto-generated if missing
|
|
134
|
+
# Filter to only include columns that exist in current OBIGT (for compatibility)
|
|
135
|
+
required_columns = [col for col in core_required_columns if col in to1.columns]
|
|
136
|
+
|
|
137
|
+
# Check for missing required columns
|
|
138
|
+
missing_columns = [col for col in required_columns if col not in new_data.columns]
|
|
139
|
+
|
|
140
|
+
if missing_columns:
|
|
141
|
+
raise ValueError(
|
|
142
|
+
f"Missing required columns in input data: {', '.join(missing_columns)}. "
|
|
143
|
+
f"Please ensure the CSV file contains all necessary OBIGT database columns."
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
# Special handling for 'model' column
|
|
147
|
+
if 'model' not in new_data.columns:
|
|
148
|
+
# Create model column with proper values
|
|
149
|
+
new_data = new_data.copy() # Make a copy to avoid SettingWithCopyWarning
|
|
150
|
+
|
|
151
|
+
# Assign model based on state:
|
|
152
|
+
# - aqueous species (state == 'aq') get 'HKF'
|
|
153
|
+
# - non-aqueous species get 'CGL'
|
|
154
|
+
new_data['model'] = new_data['state'].apply(lambda x: 'HKF' if x == 'aq' else 'CGL')
|
|
155
|
+
|
|
156
|
+
# Issue a warning to inform the user
|
|
157
|
+
warnings.warn(
|
|
158
|
+
"The 'model' column was not found in the input data. "
|
|
159
|
+
"Auto-generating 'model' column: 'HKF' for aqueous species (state='aq'), "
|
|
160
|
+
"'CGL' for all other species.",
|
|
161
|
+
UserWarning
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
# Get energy units from the file (all unique values)
|
|
165
|
+
# Match R's behavior: unique values joined with " and "
|
|
166
|
+
if 'E_units' in new_data.columns:
|
|
167
|
+
unique_units = new_data['E_units'].dropna().unique().tolist()
|
|
168
|
+
# Filter out non-energy unit values like "CGL" (which is a model, not energy unit)
|
|
169
|
+
# Valid energy units are typically "cal" and "J"
|
|
170
|
+
energy_unit_names = [str(u) for u in unique_units if str(u) in ['cal', 'J']]
|
|
171
|
+
# Join in the order they appear in the file (matching R's paste(unique(...), collapse = " and "))
|
|
172
|
+
energy_units_str = ' and '.join(energy_unit_names) if energy_unit_names else 'cal'
|
|
173
|
+
else:
|
|
174
|
+
energy_units_str = 'cal'
|
|
175
|
+
|
|
176
|
+
# Create identifier strings for matching (name + state)
|
|
177
|
+
id1 = to1['name'].astype(str) + ' ' + to1['state'].astype(str)
|
|
178
|
+
id2 = new_data['name'].astype(str) + ' ' + new_data['state'].astype(str)
|
|
179
|
+
|
|
180
|
+
# Track the indices we've modified/added
|
|
181
|
+
inew = []
|
|
182
|
+
|
|
183
|
+
# Check which entries in new_data exist in current database
|
|
184
|
+
# does_exist is a boolean array indicating which id2 entries are in id1
|
|
185
|
+
does_exist = id2.isin(id1.values)
|
|
186
|
+
|
|
187
|
+
# Get the indices in to1 where matches exist (matching R's match(id2, id1))
|
|
188
|
+
# This gives us the positions in to1 for each id2 element
|
|
189
|
+
ispecies_exist = []
|
|
190
|
+
for i, id_val in enumerate(id2):
|
|
191
|
+
if does_exist.iloc[i]:
|
|
192
|
+
# Find the index in to1 where this matches
|
|
193
|
+
match_idx = id1[id1 == id_val].index[0]
|
|
194
|
+
ispecies_exist.append(match_idx)
|
|
195
|
+
else:
|
|
196
|
+
ispecies_exist.append(None)
|
|
197
|
+
|
|
198
|
+
nexist = sum(does_exist)
|
|
199
|
+
|
|
200
|
+
# Check if new_data has columns that to1 doesn't have, and add them
|
|
201
|
+
# Use object dtype for new columns to match pandas default behavior and avoid FutureWarning
|
|
202
|
+
for col in new_data.columns:
|
|
203
|
+
if col not in to1.columns:
|
|
204
|
+
# Determine dtype from new_data
|
|
205
|
+
dtype = new_data[col].dtype
|
|
206
|
+
# Use object dtype for string columns to avoid dtype incompatibility
|
|
207
|
+
if dtype == object or pd.api.types.is_string_dtype(dtype):
|
|
208
|
+
to1[col] = pd.Series(dtype=object)
|
|
209
|
+
else:
|
|
210
|
+
to1[col] = np.nan
|
|
211
|
+
|
|
212
|
+
if force:
|
|
213
|
+
# Replace existing entries
|
|
214
|
+
if nexist > 0:
|
|
215
|
+
# Update rows in to1 for species that exist
|
|
216
|
+
for i, idx in enumerate(ispecies_exist):
|
|
217
|
+
if idx is not None:
|
|
218
|
+
# Replace the row in to1 with data from new_data
|
|
219
|
+
for col in new_data.columns:
|
|
220
|
+
# col should now be in to1 since we added missing columns above
|
|
221
|
+
to1.loc[idx, col] = new_data.iloc[i][col]
|
|
222
|
+
# Set source_file for replaced entries
|
|
223
|
+
if file_basename is not None:
|
|
224
|
+
to1.loc[idx, 'source_file'] = file_basename
|
|
225
|
+
|
|
226
|
+
# Add these indices to inew
|
|
227
|
+
inew.extend([idx for idx in ispecies_exist if idx is not None])
|
|
228
|
+
|
|
229
|
+
# Remove existing entries from new_data (to2 <- to2[!does.exist, ])
|
|
230
|
+
to2 = new_data[~does_exist].copy()
|
|
231
|
+
else:
|
|
232
|
+
to2 = new_data.copy()
|
|
233
|
+
else:
|
|
234
|
+
# Ignore any new entries that already exist
|
|
235
|
+
to2 = new_data[~does_exist].copy()
|
|
236
|
+
nexist = 0
|
|
237
|
+
|
|
238
|
+
# Add new entries
|
|
239
|
+
if len(to2) > 0:
|
|
240
|
+
# Store the starting index for new additions
|
|
241
|
+
len_id1 = len(id1)
|
|
242
|
+
|
|
243
|
+
# Ensure new entries have all required columns
|
|
244
|
+
# Make a proper copy to avoid SettingWithCopyWarning
|
|
245
|
+
to2 = to2.copy()
|
|
246
|
+
for col in to1.columns:
|
|
247
|
+
if col not in to2.columns:
|
|
248
|
+
to2[col] = np.nan
|
|
249
|
+
|
|
250
|
+
# Set source_file for new entries
|
|
251
|
+
if file_basename is not None:
|
|
252
|
+
to2['source_file'] = file_basename
|
|
253
|
+
|
|
254
|
+
# Reorder columns to match current OBIGT
|
|
255
|
+
to2 = to2.reindex(columns=to1.columns)
|
|
256
|
+
|
|
257
|
+
# Add to the database
|
|
258
|
+
# Use concat with explicit future behavior to avoid FutureWarning
|
|
259
|
+
to1 = pd.concat([to1, to2], ignore_index=True, sort=False)
|
|
260
|
+
|
|
261
|
+
# Add new indices: (length(id1)+1):nrow(to1)
|
|
262
|
+
new_indices = list(range(len_id1 + 1, len(to1) + 1))
|
|
263
|
+
inew.extend(new_indices)
|
|
264
|
+
|
|
265
|
+
# Reset rownames to 1:nrow (matching R's rownames(thermo$OBIGT) <- 1:nrow(thermo$OBIGT))
|
|
266
|
+
to1.index = range(1, len(to1) + 1)
|
|
267
|
+
|
|
268
|
+
# Update the thermo system with modified database
|
|
269
|
+
thermo_sys.obigt = to1
|
|
270
|
+
|
|
271
|
+
# Update formula_ox if the column exists in the database
|
|
272
|
+
if 'formula_ox' in to1.columns:
|
|
273
|
+
# Create a DataFrame with name and formula_ox columns
|
|
274
|
+
# Keep the same index as the obigt DataFrame (1-based)
|
|
275
|
+
formula_ox_df = pd.DataFrame({
|
|
276
|
+
'name': to1['name'],
|
|
277
|
+
'formula_ox': to1['formula_ox']
|
|
278
|
+
})
|
|
279
|
+
# Preserve the 1-based index
|
|
280
|
+
formula_ox_df.index = to1.index
|
|
281
|
+
thermo_sys.formula_ox = formula_ox_df
|
|
282
|
+
else:
|
|
283
|
+
# If formula_ox column doesn't exist, set to None
|
|
284
|
+
thermo_sys.formula_ox = None
|
|
285
|
+
|
|
286
|
+
# Print summary (matching R CHNOSZ output)
|
|
287
|
+
if messages:
|
|
288
|
+
print(f"add_OBIGT: read {len(new_data)} rows; made {nexist} replacements, {len(to2) if len(to2) > 0 else 0} additions [energy units: {energy_units_str}]")
|
|
289
|
+
|
|
290
|
+
return inew
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
def list_OBIGT_files() -> List[str]:
|
|
294
|
+
"""
|
|
295
|
+
List available OBIGT database files.
|
|
296
|
+
|
|
297
|
+
Returns
|
|
298
|
+
-------
|
|
299
|
+
list of str
|
|
300
|
+
List of available .csv files in the OBIGT directory
|
|
301
|
+
"""
|
|
302
|
+
|
|
303
|
+
# Use package-relative path
|
|
304
|
+
base_paths = [
|
|
305
|
+
os.path.join(os.path.dirname(__file__), 'extdata', 'OBIGT'),
|
|
306
|
+
]
|
|
307
|
+
|
|
308
|
+
files = []
|
|
309
|
+
for base_path in base_paths:
|
|
310
|
+
if os.path.exists(base_path):
|
|
311
|
+
csv_files = [f[:-4] for f in os.listdir(base_path) if f.endswith('.csv')]
|
|
312
|
+
files.extend(csv_files)
|
|
313
|
+
break
|
|
314
|
+
|
|
315
|
+
return sorted(list(set(files))) # Remove duplicates and sort
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
def reset_OBIGT() -> None:
|
|
319
|
+
"""
|
|
320
|
+
Reset OBIGT database to default state.
|
|
321
|
+
|
|
322
|
+
This function reloads the default thermodynamic database,
|
|
323
|
+
removing any modifications made by add_OBIGT().
|
|
324
|
+
"""
|
|
325
|
+
from ..utils.reset import reset
|
|
326
|
+
reset()
|
|
327
|
+
print("OBIGT database reset to default state")
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
name,GfPrTr,HfPrTr,SPrTr,VPrTr,k0,k1,k2,k3,k4,k5,k6,v1,v2,v3,v4,Tlambda,Tref,dTdP,l1,l2,DtH,Tmax,Tmin,d0,d1,d2,d3,d4,Vad
|
|
2
|
+
akermanite,-3663786,-3860441,212,9.252,387.06,-2938.8,0,-40790000,0,0,0,2.5011,0.00067224,-0.0785,0,358,298,0,0,0,452,,,,,,,,
|
|
3
|
+
albite,-3711715,-3935100,207.443,10.043,393.64,-2415.5,-7892800,1070640000,0,0,0,2.6307,0.00032407,-0.1945,0.0004861,,,,,,,,,,,,,,
|
|
4
|
+
"albite,high",-3703293,-3921618,224.412,10.083,393.64,-2415.5,-7892800,1070640000,0,0,0,2.6307,0.00032407,-0.1945,0.0004861,,,,,,,,,,,,,,
|
|
5
|
+
"albite,low",-3711715,-3935100,207.443,10.043,393.64,-2415.5,-7892800,1070640000,0,0,0,2.6307,0.00032407,-0.1945,0.0004861,,,,,,,,,,,,,,
|
|
6
|
+
almandine,-4941728,-5265502,339.927,11.511,573.96,-1483.1,-29292000,5022080000,0,0,0,1.8613,0.00074539,-0.0558,3.21E-05,,,,,,,,,,,,,,
|
|
7
|
+
andalusite,-2441806,-2589972,91.434,5.147,236.48,-1102.9,-7526800,936440000,0,0,0,2.3443,7.189E-05,-0.077,0.0001923,,,,,,,,,,,,,,
|
|
8
|
+
anorthite,-4003221,-4228730,200.186,10.075,439.37,-3734.1,0,-317020000,0,0,0,1.0918,0.00041985,-0.1272,0.0003176,,,,,,,,,,,,,,
|
|
9
|
+
anthophyllite,-11342582,-12069032,535.195,26.56,1219.31,-5766.5,-34766100,4400900000,0,0,0,2.706,0.00031325,-0.1259,0,,,,,,,,,,,,,,
|
|
10
|
+
antigorite,-66076529,-71364156,3602.996,174.246,7394.51,0,-548363000,87284120000,0,0,0,2.4965,0.00039444,-0.1978,0.0004944,,,,,,,,,,,,,,
|
|
11
|
+
brucite,-834868,-925937,63.064,2.468,136.84,-537.1,-4361900,552690000,0,0,0,3.2854,0.0001094,-0.2023,0.0006726,,,,,,,,,,,,,,
|
|
12
|
+
Ca-Al-pyroxene,-3122310,-3298767,140.751,6.356,310.7,-1671.6,-7455300,948780000,0,0,0,2.225,0.00052863,-0.087,0.0002171,,,,,,,,,,,,,,
|
|
13
|
+
calcite,-1128295,-1206819,91.725,3.69,178.19,-1657.7,-482700,166600000,0,0,0,0.8907,0.00227402,-0.14,0,,,,,,,,,,,,,,
|
|
14
|
+
chrysotile,-4035373,-4363356,220.134,10.72,610.02,-5581.2,-1857300,195470000,0,0,0,2.7151,0.00067351,-0.181,0.0004524,,,,,,,,,,,,,,
|
|
15
|
+
clinochlore,-8250546,-8909590,435.154,21.147,1214.28,-11217.1,0,-1256250000,0,0,0,2.6452,0,-0.1819,0,,,,,,,,,,,,,,
|
|
16
|
+
coesite,-852585,-907604,39.424,2.064,94.907,-767.3,-527900,26270000,0,0,0,0.7396,0.00043605,-0.1037,0.0003,,,,,,,,,,,,,,
|
|
17
|
+
cordierite,-8651517,-9158727,417.97,23.311,954.39,-7962.3,-2317300,-370210000,0,0,0,0.3003,0.00018017,-0.1158,0,,,,,,,,,,,,,,
|
|
18
|
+
corundum,-1582199,-1675700,50.82,2.558,155.02,-828.4,-3861400,409080000,0,0,0,2.1342,0.0004718,-0.0385,3.75E-05,,,,,,,,,,,,,,
|
|
19
|
+
"cristobalite,alpha",-853918,-907753,43.394,2.587,83.51,-374.7,-2455400,280070000,0,0,0,2.0824,0,-0.2515,0,535,298,0.048,-0.14216,0.00044142,0,,,,,,,,
|
|
20
|
+
"cristobalite,beta",-853327,-906377,46.029,2.73,83.51,-374.7,-2455400,280070000,0,0,0,0.3189,0,-0.11,0.0005535,,,,,,,,,,,,,,
|
|
21
|
+
diaspore,-920806,-999378,35.308,1.776,143.24,-1540.4,-323100,64630000,0,0,0,2.9718,0,-0.0599,0,,,,,,,,,,,,,,
|
|
22
|
+
diopside,-3026202,-3200583,142.5,6.62,305.41,-1604.9,-7166000,921840000,0,0,0,2.7795,0.00083082,-0.0872,0.0001707,,,,,,,,,,,,,,
|
|
23
|
+
dolomite,-2162354,-2325248,154.89,6.432,328.48,-2554.4,-4688500,790380000,0,0,0,1.423,0.00363778,-0.107,0,,,,,,,1423,298,-9.42,0,385000,0.01732,5.02E-06,0
|
|
24
|
+
"enstatite,clino",-1458601,-1545926,66.325,3.131,139.96,-497,-4400200,535710000,0,0,0,2.1915,0.0007492,-0.075,4.48E-05,,,,,,,,,,,,,,
|
|
25
|
+
enstatite,-1458181,-1545552,66.17,3.133,166.58,-1200.6,-2270600,279150000,0,0,0,2.4656,0.0007467,-0.0749,4.47E-05,,,,,,,,,,,,,,
|
|
26
|
+
"enstatite,proto",-1456965,-1543959,67.438,3.242,166.58,-1200.6,-2270600,279150000,0,0,0,1.6832,0.0011665,-0.075,4.48E-05,,,,,,,,,,,,,,
|
|
27
|
+
fayalite,-1380154,-1479360,150.93,4.63,248.93,-1923.9,0,-139100000,0,0,0,2.6546,0.00079482,-0.073,0,,,,,,,,,,,,,,
|
|
28
|
+
ferrosilite,-1117472,-1194375,95.882,3.296,169.06,-1193,-2097100,292530000,0,0,0,3.1808,0.0007585,-0.099,0,,,,,,,,,,,,,,
|
|
29
|
+
forsterite,-2055023,-2174420,94.01,4.366,238.64,-2001.3,0,-116240000,0,0,0,2.9464,0.00088633,-0.0791,0.0001351,,,,,,,,,,,,,,
|
|
30
|
+
gehlenite,-3785954,-3988158,198.6,9.033,373.09,-2276.8,-4778500,477910000,0,0,0,2.4926,5.664E-05,-0.0996,0.0002488,,,,,,,1600,698,-221.74,0,17291000,0.3695,-0.0001469,0
|
|
31
|
+
grossular,-6270974,-6632859,255.15,12.538,573.43,-2039.4,-18887200,2319310000,0,0,0,1.8994,0.00079756,-0.0654,0.0001635,,,,,,,,,,,,,,
|
|
32
|
+
hematite,-743681,-825627,87.437,3.027,146.86,0,-5576800,525630000,0,0,0,3.831,1.65E-05,-0.0479,3.04E-05,955,298,0,-0.07403,0.00027921,1287,,,,,,,,
|
|
33
|
+
ilmenite,-1155320,-1231947,108.628,3.17,150,-441.6,-3323700,348150000,0,0,0,2.7248,0.00029968,-0.0584,0.000123,,,,,,,,,,,,,,
|
|
34
|
+
jadeite,-2846482,-3025118,133.574,6.034,311.29,-2005.1,-5350300,662570000,0,0,0,2.3118,0.00025785,-0.086,0.0002149,,,,,,,,,,,,,,
|
|
35
|
+
kaolinite,-3799770,-4120327,203.7,9.952,523.23,-4426.7,-2244300,92310000,0,0,0,3.2,0,-0.12,0,,,,,,,,,,,,,,
|
|
36
|
+
kyanite,-2443370,-2594220,82.43,4.412,262.68,-2001.4,-1999700,-63180000,0,0,0,2.3973,0,-0.0646,0,,,,,,,,,,,,,,
|
|
37
|
+
lawsonite,-4509709,-4865666,229.176,10.144,728.67,-8248.1,0,850560000,0,0,0,2.6283,0,-0.0769,0.0001922,,,,,,,,,,,,,,
|
|
38
|
+
lime,-603350,-635090,37.75,1.676,58.79,-133.9,-1147100,102980000,0,0,0,3.461,0.00067406,-0.1022,0.0002565,,,,,,,,,,,,,,
|
|
39
|
+
magnesite,-1029875,-1113636,65.21,2.803,162.3,-1109.3,-4882600,874660000,0,0,0,1.8436,0.00415968,-0.089,0.0002212,,,,,,,,,,,,,,
|
|
40
|
+
magnetite,-1014235,-1117403,146.114,4.452,207.93,0,-7243300,664360000,0,0,0,3.0291,0.0013847,-0.0582,0.0001751,848,298,0,-0.19502,0.00061037,1565,,,,,,,,
|
|
41
|
+
margarite,-5852244,-6236603,265.084,12.958,699.8,-5587.1,-6807700,734320000,0,0,0,2.1019,0.00124556,-0.1155,0.0002886,,,,,,,,,,,,,,
|
|
42
|
+
meionite,-13105915,-13849723,730,34.036,1511.35,-13243.3,0,-751610000,0,0,0,0.934,0,-0.111,0,,,,,,,,,,,,,,
|
|
43
|
+
merwinite,-4309707,-4537497,251.777,9.847,453.62,-3250,0,-344230000,0,0,0,2.9376,0.00087235,-0.0551,0.0001381,,,,,,,,,,,,,,
|
|
44
|
+
monticellite,-2132222,-2250027,108.3,5.148,226.34,-1542.7,-1179700,-23290000,0,0,0,2.7863,0.00076339,-0.0904,0.0002,,,,,,,,,,,,,,
|
|
45
|
+
muscovite,-5596723,-5976740,293.157,14.087,651.49,-3873.2,-18523200,2742470000,0,0,0,3.3527,0,-0.1717,0.0004295,,,,,,,,,,,,,,
|
|
46
|
+
paragonite,-5563572,-5944208,277.699,13.216,577.57,-1472.8,-32214400,5050080000,0,0,0,3.9424,0.00059701,-0.1973,0.0004933,,,,,,,,,,,,,,
|
|
47
|
+
periclase,-569209,-601500,26.951,1.125,61.11,-296.2,-621200,5840000,0,0,0,3.7477,3.556E-05,-0.0622,0.0001511,,,,,,,,,,,,,,
|
|
48
|
+
phlogopite,-5827224,-6207342,334.158,14.977,610.38,-2083.8,-21533000,2841040000,0,0,0,3.4447,0,-0.1697,0,,,,,,,,,,,,,,
|
|
49
|
+
K-feldspar,-3745415,-3970791,214.145,10.869,381.37,-1941,-12037300,1836430000,0,0,0,1.5145,0.0005485,-0.1805,0.0005112,,,,,,,1436,298,282.98,-4830,3621000,-0.15733,3.477E-05,410630
|
|
50
|
+
"K-feldspar,high",-3738804,-3959704,229.157,10.896,381.37,-1941,-12037300,1836430000,0,0,0,1.5145,0.0005485,-0.1805,0.0005112,,,,,,,,,,,,,,
|
|
51
|
+
"K-feldspar,low",-3745415,-3970791,214.145,10.869,381.37,-1941,-12037300,1836430000,0,0,0,1.5145,0.0005485,-0.1805,0.0005112,,,,,,,,,,,,,,
|
|
52
|
+
prehnite,-5820154,-6198606,288.634,14.016,716.05,-6404.6,-2182500,268500000,0,0,0,0.1468,0.01128353,-0.1427,0,,,,,,,,,,,,,,
|
|
53
|
+
pyrope,-5936009,-6286548,266.359,11.316,640.72,-4542.1,-4701900,0,0,0,0,2.2519,0.00037044,-0.0576,4.42E-05,,,,,,,,,,,,,,
|
|
54
|
+
pyrophyllite,-5266865,-5640781,239.4,12.76,665.93,-5897.4,-4979900,661810000,0,0,0,1.2637,0.00381661,-0.1354,0,,,,,,,,,,,,,,
|
|
55
|
+
quartz,-856288,-910700,41.46,2.269,80.01,-240.3,-3546700,491570000,0,0,0,2.3895,0,-0.2434,0.0010137,848,373,0.0237,-0.09187,0.00024607,0,,,,,,,,
|
|
56
|
+
"quartz,beta",-855033,-908627,44.207,2.37,80.01,-240.3,-3546700,491570000,0,0,0,0,0,-0.1238,0.0007087,,,,,,,,,,,,,,
|
|
57
|
+
rutile,-889497,-944750,50.46,1.882,77.84,0,-3367800,402940000,0,0,0,2.5716,0.00015409,-0.0454,5.84E-05,,,,,,,,,,,,,,
|
|
58
|
+
sillimanite,-2439265,-2586091,95.93,4.983,256.73,-1887.2,-2977400,250960000,0,0,0,1.3431,0,-0.0753,0,,,,,,,,,,,,,,
|
|
59
|
+
sphene,-2455134,-2596652,129.29,5.565,234.62,-1040.3,-5118300,591460000,0,0,0,2.52,0,-0.059,0,,,,,,,,,,,,,,
|
|
60
|
+
spinel,-2176537,-2300313,84.535,3.977,235.9,-1766.6,-1710400,40620000,0,0,0,2.1691,0.00050528,-0.0489,0,,,,,,,,,,,,,,
|
|
61
|
+
talc,-5517657,-5897387,261.24,13.61,664.11,-5187.2,-2147200,-327370000,0,0,0,2.9447,0,-0.1699,0.0005665,,,,,,,,,,,,,,
|
|
62
|
+
tremolite,-11578548,-12305578,551.15,27.268,1229.36,-6401.9,-32089900,4208810000,0,0,0,2.4374,0.00098338,-0.1392,0.0003481,,,,,,,,,,,,,,
|
|
63
|
+
"tridymite,low",-854026,-907750,43.77,2.675,75.37,0,-5958100,958250000,0,0,0,1.9339,0,-0.2508,0,383,298,0,0.4267,-0.00144575,130,,,,,,,,
|
|
64
|
+
"tridymite,high",-853844,-907045,45.524,2.737,75.37,0,-5958100,958250000,0,0,0,0.4829,0,-0.074,0.0003735,,,,,,,,,,,,,,
|
|
65
|
+
wollastonite,-1546123,-1631500,81.81,3.983,149.07,-690.3,-3659300,484350000,0,0,0,2.818,0,-0.1245,0.0003113,,,,,,,,,,,,,,
|
|
66
|
+
pseudowollastonite,-1543085,-1627427,85.279,4.016,141.16,-417.2,-5857600,940740000,0,0,0,2.818,0,-0.1245,0.0003113,,,,,,,,,,,,,,
|
|
67
|
+
zoisite,-6494148,-6889488,297.576,13.588,749.17,-6509.3,-2380500,124860000,0,0,0,3.467,0,-0.0515,0.0001288,,,,,,,,,,,,,,
|
|
68
|
+
clinozoisite,-6496497,-6894968,287.076,13.673,749.17,-6509.3,-2380500,124860000,0,0,0,3.467,0,-0.0515,0.0001288,,,,,,,,,,,,,,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
name,GfPrTr,HfPrTr,SPrTr,VPrTr,k0,k1,k2,k3,k4,k5,k6,v1,v2,v3,v4,Tlambda,Tref,dTdP,l1,l2,DtH,Tmax,Tmin,d0,d1,d2,d3,d4,Vad
|
|
2
|
+
almandine,-4943492,-5267216,340.007,11.511,573.96,-1483.1,-29292000,5022080000,0,0,0,1.8613,0.00074539,-0.0558,3.21E-05,,,,,,,,,,,,,,
|
|
3
|
+
annite,-4793115,-5142800,420,15.408,727.21,-4775.04,-13831900,2119060000,0,0,0,3.4447,0,-0.1697,0,,,,,,,,,,,,,,
|
|
4
|
+
ilmenite,-1155794,-1232448,108.628,3.17,150,-441.6,-3323700,348150000,0,0,0,2.7248,0.00029968,-0.0584,0.000123,,,,,,,,,,,,,,
|
|
5
|
+
phlogopite,-5830350,-6210391,334.346,14.977,610.38,-2083.8,-21533000,2841040000,0,0,0,3.4447,0,-0.1697,0,,,,,,,,,,,,,,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
name,GfPrTr,HfPrTr,SPrTr,VPrTr,k0,k1,k2,k3,k4,k5,k6,v1,v2,v3,v4,Tlambda,Tref,dTdP,l1,l2,DtH,Tmax,Tmin,d0,d1,d2,d3,d4,Vad
|
|
2
|
+
hedenbergite,-2674300,-2837802.5,173.59,6.785,353.31148,-3106.646,2047911.742,-563018581,0,0,0,2.796487,0,-0.17457,0.00151,,,,,,,,,,,,,,
|
|
3
|
+
andradite,-5419000,-5761985.8,316.4,13.167,569.7558,-1441.44,-22441040.802,3146543781,0,0,0,2.072525,0.000561,-0.06539136,0.0001635,,,,,,,,,,,,,,
|
|
4
|
+
ferro-actinolite,-9839000,-10518042.6,685.1,28.26,1321.15758,-8966.454,-21705844.286,3236159154,0,0,0,2.84,0,-0.15,0,,,,,,,,,,,,,,
|
|
5
|
+
grunerite,-8964807,-9623000,725,27.8,1347.83,-9356.91,-20228480,3039190000,0,0,0,2.84,0,-0.15,0,,,,,,,,,,,,,,
|
|
6
|
+
ilvaite,-3440000,-3695605.5,291.5,10.016,682.79138,-8787.112,30183568.71,-5666432624,0,0,0,1.801543,0.001152,-0.06838,2.4E-05,,,,,,,,,,,,,,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
name,GfPrTr,HfPrTr,SPrTr,VPrTr,k0,k1,k2,k3,k4,k5,k6,v1,v2,v3,v4,Tlambda,Tref,dTdP,l1,l2,DtH,Tmax,Tmin,d0,d1,d2,d3,d4,Vad
|
|
2
|
+
zoisite,NA,-6891340,297.38,13.572,733.034,-5979.52,-5079660,552314000,0,0,0,3.713,0,-0.0735,0,,,,,,,,,,,,,,
|
|
3
|
+
orthoepidote,NA,-6449500,340.8,13.852,728.954,-5565.32,-5937360,610589000,0,0,0,3.713,0,-0.0735,0,,,,,,,,,,,,,,
|
|
4
|
+
clinozoisite,NA,-6892040,294.88,13.64,733.034,-5979.52,-5079660,552314000,0,0,0,2.95,0,-0.0649,0,,,,,,,,,,,,,,
|
|
5
|
+
epidote,NA,-6462600,332.8,13.901,728.954,-5565.32,-5937360,610589000,0,0,0,2.95,0,-0.0581,0,,,,,,,,,,,,,,
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
name,GfPrTr,HfPrTr,SPrTr,VPrTr,k0,k1,k2,k3,k4,k5,k6,v1,v2,v3,v4,Tlambda,Tref,dTdP,l1,l2,DtH,Tmax,Tmin,d0,d1,d2,d3,d4,Vad
|
|
2
|
+
glaucophane,-11225858,-11960500,535,26.05,1717.5,-19272,7050000,0,0,0,0,2.2,0.00088,-0.116,0.00029,,,,,,,,,,,,,,
|
|
3
|
+
pumpellyite,-13448936,-14402300,584,29.55,1576,-10603.8,-28304200,3838351000,0,0,0,3.467,0,-0.051516,0.0001288,,,,,,,,,,,,,,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
name,GfPrTr,HfPrTr,SPrTr,VPrTr,k0,k1,k2,k3,k4,k5,k6,v1,v2,v3,v4,Tlambda,Tref,dTdP,l1,l2,DtH,Tmax,Tmin,d0,d1,d2,d3,d4,Vad
|
|
2
|
+
muscovite,-5603417,-5983434,293.157,14.087,651.49,-3873.2,-18523200,2742470000,0,0,0,3.3527,0,-0.1717,0.0004295,,,,,,,,,,,,,,
|
|
3
|
+
phlogopite,-5837044,-6217085,334.346,14.977,610.38,-2083.8,-21533000,2841040000,0,0,0,3.4447,0,-0.1697,0,,,,,,,,,,,,,,
|
|
4
|
+
K-feldspar,-3752109,-3977485,214.145,10.869,381.37,-1941,-12037300,1836430000,0,0,0,1.5145,0.0005485,-0.1805,0.0005112,,,,,,,1436,298,282.98,-4830,3621000,-0.15733,3.477E-05,410630
|
|
5
|
+
"K-feldspar,high",-3745498,-3966398,229.157,10.896,381.37,-1941,-12037300,1836430000,0,0,0,1.5145,0.0005485,-0.1805,0.0005112,,,,,,,,,,,,,,
|
|
6
|
+
"K-feldspar,low",-3752109,-3977485,214.145,10.869,381.37,-1941,-12037300,1836430000,0,0,0,1.5145,0.0005485,-0.1805,0.0005112,,,,,,,,,,,,,,
|
|
7
|
+
paragonite,-5570375,-5951011,277.699,13.216,577.57,-1472.8,-32214400,5050080000,0,0,0,3.9424,0.00059701,-0.1973,0.0004933,,,,,,,,,,,,,,
|
|
8
|
+
albite,-3718518,-3941903,207.443,10.043,393.64,-2415.5,-7892800,1070640000,0,0,0,2.6307,0.00032407,-0.1945,0.0004861,,,,,,,,,,,,,,
|
|
9
|
+
"albite,high",-3710096,-3928421,224.412,10.083,393.64,-2415.5,-7892800,1070640000,0,0,0,2.6307,0.00032407,-0.1945,0.0004861,,,,,,,,,,,,,,
|
|
10
|
+
"albite,low",-3718518,-3941903,207.443,10.043,393.64,-2415.5,-7892800,1070640000,0,0,0,2.6307,0.00032407,-0.1945,0.0004861,,,,,,,,,,,,,,
|
|
11
|
+
jadeite,-2853285,-3031921,133.574,6.034,311.29,-2005.1,-5350300,662570000,0,0,0,2.3118,0.00025785,-0.086,0.0002149,,,,,,,,,,,,,,
|
|
12
|
+
annite,-4799809,-5149494,420,15.408,727.21,-4775.04,-13831900,2119060000,0,0,0,3.4447,0,-0.1697,0,,,,,,,,,,,,,,
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
name,GfPrTr,HfPrTr,SPrTr,VPrTr,k0,k1,k2,k3,k4,k5,k6,v1,v2,v3,v4,Tlambda,Tref,dTdP,l1,l2,DtH,Tmax,Tmin,d0,d1,d2,d3,d4,Vad
|
|
2
|
+
daphnite,NA,-7120845,559.4,21.588,1229.23,-10256.5,-12276900,2121510000,0,0,0,2.6451,0,-0.182,0,,,,,,,,,,,,,,
|
|
3
|
+
Mg-amesite,NA,-9035900,403.2,20.52,1144.45,-8327.2,-20058040,2820786000,0,0,0,2.6451,0,-0.182,0,,,,,,,,,,,,,,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
name,GfPrTr,HfPrTr,SPrTr,VPrTr,k0,k1,k2,k3,k4,k5,k6,v1,v2,v3,v4,Tlambda,Tref,dTdP,l1,l2,DtH,Tmax,Tmin,d0,d1,d2,d3,d4,Vad
|
|
2
|
+
fluormuscovite,-5772803,-6111401,299.03,14.087,680.36024,-6515.743,0,110583120,0,0,0,3.35273302,0,-0.17169021,0.00042947,NA,NA,NA,NA,NA,NA,NA,NA,,,,,,
|
|
3
|
+
fluorphlogopite,-6063382,-6403168,336.394,14.637,653.70816,-5175.19,0,-324594720,0,0,0,3.44473262,0,-0.16969784,0,NA,NA,NA,NA,NA,NA,NA,NA,,,,,,
|
|
4
|
+
fluorannite,-4983910,-5293254,422.291,15.075,742.82736,-6817.41,0,418441840,0,0,0,3.44473262,0,-0.16969784,0,NA,NA,NA,NA,NA,NA,NA,NA,,,,,,
|
|
5
|
+
fluortremolite,-11782144,-12457969,570.279,27.045,1272.64728,-9493.496,0,-10517739.2,0,0,0,2.43738877,0.00098338,-0.13917727,0.00034809,NA,NA,NA,NA,NA,NA,NA,NA,,,,,,
|
|
6
|
+
fluorapatite,-6443050,-6823447,387.857,15.753,668.77056,-4534.201,0,-746341920,0,0,0,0,0,0,0,NA,NA,NA,NA,NA,NA,NA,NA,,,,,,
|
|
7
|
+
hydroxyapatite,-6297702,-6694689,398.735,15.822,758.81024,-6480.598,0,-447939040,0,0,0,0,0,0,0,NA,NA,NA,NA,NA,NA,NA,NA,,,,,,
|
|
8
|
+
chlorapatite,-6217424,-6597260,399.907,16.403,663.87528,-4435.877,0,-690234480,0,0,0,0,0,0,0,NA,NA,NA,NA,NA,NA,NA,NA,,,,,,
|
|
9
|
+
fluortalc,-5717018,-6056244,264.052,13.33,602.74704,-4766.831,0,-292588712,0,0,0,2.94468112,0,-0.16988979,0.0005665,NA,NA,NA,NA,NA,NA,NA,NA,,,,,,
|
|
10
|
+
chlorphlogopite,-5600840,-5939422,360.703,16.59,573.45904,-2063.549,-16465713.6,2105765360,0,0,0,3.44473262,0,-0.16969784,0,NA,NA,NA,NA,NA,NA,NA,NA,,,,,,
|
|
11
|
+
chlorannite,-4582036,-4890196,449.529,17.247,690.44368,-4760.137,-8725313.6,1376828880,0,0,0,3.44473262,0,-0.16969784,0,NA,NA,NA,NA,NA,NA,NA,NA,,,,,,
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# integrate Berman's equations using sympy 20170930
|
|
2
|
+
# add k4, k5, k6 20180328
|
|
3
|
+
library(rSymPy)
|
|
4
|
+
|
|
5
|
+
# create SymPy variables called T and P
|
|
6
|
+
sympy("var('T')")
|
|
7
|
+
sympy("var('P')")
|
|
8
|
+
|
|
9
|
+
sympy("k0 = Symbol('k0', real=True)")
|
|
10
|
+
sympy("k1 = Symbol('k1', real=True)")
|
|
11
|
+
sympy("k2 = Symbol('k2', real=True)")
|
|
12
|
+
sympy("k3 = Symbol('k3', real=True)")
|
|
13
|
+
sympy("k4 = Symbol('k4', real=True)")
|
|
14
|
+
sympy("k5 = Symbol('k5', real=True)")
|
|
15
|
+
sympy("k6 = Symbol('k6', real=True)")
|
|
16
|
+
sympy("v1 = Symbol('v1', real=True)")
|
|
17
|
+
sympy("v2 = Symbol('v2', real=True)")
|
|
18
|
+
sympy("v3 = Symbol('v3', real=True)")
|
|
19
|
+
sympy("v4 = Symbol('v4', real=True)")
|
|
20
|
+
sympy("Tr = Symbol('Tr', real=True)")
|
|
21
|
+
sympy("Pr = Symbol('Pr', real=True)")
|
|
22
|
+
sympy("VPrTr = Symbol('VPrTr', real=True)")
|
|
23
|
+
sympy("HPrTr = Symbol('HPrTr', real=True)")
|
|
24
|
+
sympy("SPrTr = Symbol('SPrTr', real=True)")
|
|
25
|
+
|
|
26
|
+
# Cp and its integrals
|
|
27
|
+
Cp <- "k0 + k1*T**-0.5 + k2*T**-2 + k3*T**-3 + k4*T**-1 + k5*T + k6*T**2"
|
|
28
|
+
intCp <- sympy(paste("integrate(", Cp,", (T, Tr, T))"))
|
|
29
|
+
message("intCp = ", intCp)
|
|
30
|
+
|
|
31
|
+
Cp_T <- "k0*T**-1 + k1*T**-1.5 + k2*T**-3 + k3*T**-4 + k4*T**-2 + k5 + k6*T"
|
|
32
|
+
intCp_T <- sympy(paste("integrate(", Cp_T,", (T, Tr, T))"))
|
|
33
|
+
message("intCp_T = ", intCp_T)
|
|
34
|
+
|
|
35
|
+
# V and its integrals
|
|
36
|
+
# as written in Berman, 1988
|
|
37
|
+
#V <- "VPrTr * (1 + v1*(P - Pr) + v2*(P - Pr)**2 + v3*(T- Tr) + v4*(T - Tr)**2)"
|
|
38
|
+
# simplified version with Pr==1 (Anderson and Crerar, 1993, p. 175)
|
|
39
|
+
V <- "VPrTr * (1 + v1*(P - 1) + v2*(P - 1)**2 + v3*(T - Tr) + v4*(T - Tr)**2)"
|
|
40
|
+
intV <- sympy(paste("integrate(", V,", (P, 1, P))"))
|
|
41
|
+
# check that intV is equal to the expression in Berman, 1988 and Anderson, 2005 eq. 5.36
|
|
42
|
+
#refintV <- "VPrTr * ( (v1/2 - v2) * (P**2 - Pr**2) + v2/3 * (P**3 - Pr**3) + (1 - v1 + v2 + v3*(T-Tr) + v4*(T-Tr)**2) * (P - Pr) )"
|
|
43
|
+
# simplified version with Pr==1
|
|
44
|
+
refintV <- "VPrTr * ( (v1 / 2 - v2) * (P**2 - 1) + v2 / 3 * (P**3 - 1) + (1 - v1 + v2 + v3*(T-Tr) + v4*(T-Tr)**2) * (P - 1) )"
|
|
45
|
+
# this doesn't collect and cancel terms, so we have to expand the expressions
|
|
46
|
+
#sympy(paste(intV, "- (", refintV, ")"))
|
|
47
|
+
expintV <- sympy(paste("expand (", intV, ")"))
|
|
48
|
+
exprefintV <- sympy(paste("expand (", refintV, ")"))
|
|
49
|
+
# the difference is zero!
|
|
50
|
+
diffintV <- sympy(paste(expintV, "- (", exprefintV, ")"))
|
|
51
|
+
message("diffintV = ", diffintV, " (should be 0)")
|
|
52
|
+
|
|
53
|
+
# another way to check that the expressions are equal
|
|
54
|
+
# a function to separate the terms of an expression
|
|
55
|
+
septerms <- function(x) {
|
|
56
|
+
x <- paste("+", x)
|
|
57
|
+
x <- gsub("+ ", "+", x, fixed=TRUE)
|
|
58
|
+
x <- gsub("- ", "-", x, fixed=TRUE)
|
|
59
|
+
strsplit(x, " ")[[1]]
|
|
60
|
+
}
|
|
61
|
+
intVterms <- septerms(expintV)
|
|
62
|
+
refintVterms <- septerms(exprefintV)
|
|
63
|
+
equalintVterms <- setequal(intVterms, refintVterms)
|
|
64
|
+
message("equalintVterms is ", equalintVterms, " (should be TRUE)")
|
|
65
|
+
|
|
66
|
+
# continuing with V integrals for S and H
|
|
67
|
+
dVdT <- sympy(paste("diff(", V, ", T, 1)"))
|
|
68
|
+
# again, integrate using Pr==1
|
|
69
|
+
intdVdT <- sympy(paste("integrate(", dVdT,", (P, 1, P))")) # for S
|
|
70
|
+
message("intdVdT = ", intdVdT)
|
|
71
|
+
|
|
72
|
+
minusintdVdT <- sympy(paste("- (", intdVdT, ")")) # apply minus sign!
|
|
73
|
+
V_TdVdT <- sympy(paste(V, " - T * (", dVdT, ")"))
|
|
74
|
+
intV_TdVdT <- sympy(paste("integrate(", V_TdVdT,", (P, 1, P))")) # for H
|
|
75
|
+
message("intV_TdVdT = ", intV_TdVdT)
|
|
76
|
+
|
|
77
|
+
# check that intV_TdVdT - T * minusintdVdT is equal to intV (for G)
|
|
78
|
+
intV2 <- sympy(paste(intV_TdVdT, "- T * (", minusintdVdT, ")") )
|
|
79
|
+
expintV2 <- sympy(paste("expand (", intV2, ")"))
|
|
80
|
+
## maybe we need to expand the terms first...
|
|
81
|
+
#expintV_TdVdT <- sympy(paste("expand (", intV_TdVdT, ")"))
|
|
82
|
+
#TintdVdT <- sympy(paste("T * (", intdVdT, ")") )
|
|
83
|
+
#expTintdVdT <- sympy(paste("expand (", TintdVdT, ")"))
|
|
84
|
+
#expintV3 <- sympy(paste(expintV_TdVdT, "- (", expTintdVdT, ")"))
|
|
85
|
+
# this is zero!
|
|
86
|
+
diffexpintV <- sympy(paste(expintV2, "- (", expintV, ")"))
|
|
87
|
+
message("diffexpintV = ", diffexpintV, " (should be 0)")
|
|
88
|
+
|
|
89
|
+
# H, S and G
|
|
90
|
+
#HCp <- sympy(paste("HPrTr +", intCp, "+", intV_TdVdT))
|
|
91
|
+
#SCp <- sympy(paste("SPrTr +", intCp_T, "- (", intdVdT, ")"))
|
|
92
|
+
#GCp <- sympy(paste(HCp, "- T * (", SCp, ")"))
|
|
93
|
+
#G <- sympy(paste(GCp, "+", intV))
|
|
94
|
+
|
|
95
|
+
# References
|
|
96
|
+
# Anderson, G. M. (2005) \emph{Thermodynamics of Natural Systems}, 2nd ed., Cambridge University Press, 648 p. \url{http://www.worldcat.org/oclc/474880901}
|
|
97
|
+
# Anderson, G. M. and Crerar, D. A. (1993) \emph{Thermodynamics in Geochemistry: The Equilibrium Model}, Oxford University Press. \url{http://www.worldcat.org/oclc/803272549}
|
|
98
|
+
# Berman, R. G. (1988) Internally-consistent thermodynamic data for minerals in the system Na{\s2}O-K{\s2}O-CaO-MgO-FeO-Fe{\s2}O{\s3}-Al{\s2}O{\s3}-SiO{\s2}-TiO{\s2}-H{\s2}O-CO{\s2}. \emph{J. Petrol.} \bold{29}, 445-522. \url{https://doi.org/10.1093/petrology/29.2.445}
|
|
99
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
@Article{BA96,
|
|
2
|
+
author = {Berman, R. G. and Aranovich, L. {\relax Ya}.},
|
|
3
|
+
journal = {Contributions to Mineralogy and Petrology},
|
|
4
|
+
title = {{O}ptimized standard state and solution properties of minerals. {I}. {M}odel calibration for olivine, orthopyroxene, cordierite, garnet, and ilmenite in the system {F}e{O}-{M}g{O}-{C}a{O}-{A}l$_2${O}$_3$-{T}i{O}$_2$-{S}i{O}$2$},
|
|
5
|
+
year = {1996},
|
|
6
|
+
volume = {126},
|
|
7
|
+
number = {1},
|
|
8
|
+
pages = {25--37},
|
|
9
|
+
day = {01},
|
|
10
|
+
doi = {10.1007/s004100050233},
|
|
11
|
+
issn = {1432-0967},
|
|
12
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name,GfPrTr,HfPrTr,SPrTr,VPrTr,k0,k1,k2,k3,k4,k5,k6,v1,v2,v3,v4,Tlambda,Tref,dTdP,l1,l2,DtH,Tmax,Tmin,d0,d1,d2,d3,d4,Vad
|
|
2
|
+
almandine,,-5265440,341.51,11.529,621.43,-3287.9,-15081000,2211870000,0,0,0,1.8599,0.00074711,-0.057,4.34E-05,,,,,,,,,,,,,,
|
|
3
|
+
anthophyllite,,-12074470,537.4,26.33,1233.79,-7134,-22163800,2333940000,0,0,0,2.8105,0.00062894,-0.1139,0,,,,,,,,,,,,,,
|
|
4
|
+
cordierite,,-9161480,416.23,23.311,954.39,-7962.3,-2317300,-370210000,0,0,0,0.3003,0.00018017,-0.1158,0,,,,,,,,,,,,,,
|
|
5
|
+
Fe-cordierite,,-8430550,482.18,23.706,983.48,-8403.7,-1870300,-85680000,0,0,0,0.4265,0,-0.17,0,,,,,,,,,,,,,,
|
|
6
|
+
fayalite,,-1477170,151.73,4.639,252,-2013.7,0,-62190000,0,0,0,2.621,0.00084233,-0.0822,0.0001944,,,,,,,,,,,,,,
|
|
7
|
+
ferrosilite,,-1192910,96.47,3.295,174.2,-1393,-454400,-37710000,0,0,0,3.1406,0.000804,-0.0911,3.03E-05,,,,,,,,,,,,,,
|
|
8
|
+
forsterite,,-2174420,94.18,4.36,233.18,-1801.6,0,-267940000,0,0,0,2.9464,0.00088633,-0.0791,0.0001351,,,,,,,,,,,,,,
|
|
9
|
+
geikelite,,-1570520,74.41,3.077,146.2,-416,-3999800,402330000,0,0,0,2.3314,0.00088328,-0.0529,0,,,,,,,,,,,,,,
|
|
10
|
+
hematite,,-826740,87.36,3.027,146.86,0,-5576800,525630000,0,0,0,3.831,1.65E-05,-0.0479,3.04E-05,955,298,0,-0.07403,0.00027921,1287,,,,,,,,
|
|
11
|
+
hercynite,,-1945360,123.13,4.08,251.77,-2044.4,-1348300,131500000,0,0,0,1.5819,0.00096276,-0.051,0,,,,,,,,,,,,,,
|
|
12
|
+
ilmenite,,-1233320,108.5,3.17,150,-441.6,-3323700,348150000,0,0,0,2.3314,0.00088328,-0.0529,0,,,,,,,,,,,,,,
|
|
13
|
+
iron-a,,0,27.45,0.709,51.87,-379.4,-2543000,506800000,0,0,0,4.5071,0.00014104,-0.0602,0,1042,298,-0.00057,-0.22208,0.00034823,1000,,,,,,,,
|
|
14
|
+
iron-g,,7720,35.64,0.691,66.24,-1237.1,6373300,-1060400000,0,0,0,4.7153,0.00014451,-0.0467,-0.0001445,,,,,,,,,,,,,,
|
|
15
|
+
magnetite,,-1116960,146.04,4.452,207.93,0,-7243300,664360000,0,0,0,3.0291,0.0013847,-0.0582,0.0001751,848,298,0,-0.19502,0.00061037,1565,,,,,,,,
|
|
16
|
+
enstatite,,-1546040,66.18,3.133,166.58,-1200.6,-2270600,279150000,0,0,0,2.4656,0.0007467,-0.0749,4.47E-05,,,,,,,,,,,,,,
|
|
17
|
+
orthocorundum,,-1634950,33.93,3.123,119.38,774.8,-6509100,422880000,0,0,0,2.4656,0.0007467,-0.0749,4.47E-05,,,,,,,,,,,,,,
|
|
18
|
+
pyrope,,-6284740,268.8,11.311,590.9,-2827,-13320800,1260330000,0,0,0,2.2519,0.00037044,-0.0576,4.42E-05,,,,,,,,,,,,,,
|
|
19
|
+
rutile,,-944750,50.88,1.883,77.84,0,-3367800,402940000,0,0,0,2.5716,0.00015409,-0.0454,5.85E-05,,,,,,,,,,,,,,
|
|
20
|
+
spinel,,-2302160,80.37,3.978,244.67,-2004,0,0,0,0,0,2.1691,0.00050528,-0.0489,0,,,,,,,,,,,,,,
|
|
21
|
+
talc,,-5898960,261.21,13.61,664.11,-5187.2,-2147200,-327370000,0,0,0,2.5616,0,-0.1847,0.0005878,,,,,,,,,,,,,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name,abbrv,formula,state,ref1,ref2,date,model,E_units,G,H,S,Cp,V,a1.a,a2.b,a3.c,a4.d,c1.e,c2.f,omega.lambda,z.T
|
|
2
|
+
almandine,Alm,Si3Fe3Al2O12,cr,BA96.1,NA,03.Oct.17,Berman,J,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA
|
|
3
|
+
anthophyllite,Ath,Mg7Si8O24H2,cr,BA96.1,NA,01.Oct.17,Berman,J,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA
|
|
4
|
+
cordierite,Cd,Mg2Al4Si5O18,cr,Ber88,BA96.2,01.Oct.17,Berman,J,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA
|
|
5
|
+
enstatite,En,MgSiO3,cr,Ber88,BA96.2,01.Oct.17,Berman,J,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA
|
|
6
|
+
fayalite,Fa,Fe2SiO4,cr,BA96.1,NA,01.Oct.17,Berman,J,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA
|
|
7
|
+
ferrosilite,Fsl,SiFeO3,cr,BA96.1,NA,01.Oct.17,Berman,J,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA
|
|
8
|
+
forsterite,Fo,Mg2SiO4,cr,Ber88,BA96.3,01.Oct.17,Berman,J,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA
|
|
9
|
+
hematite,Hm,Fe2O3,cr,Ber88,BA96.2,01.Oct.17,Berman,J,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA
|
|
10
|
+
ilmenite,Ilm,FeTiO3,cr,Ber88,BA96.4,03.Oct.17,Berman,J,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA
|
|
11
|
+
magnetite,Mt,Fe3O4,cr,Ber88,BA96.2,01.Oct.17,Berman,J,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA
|
|
12
|
+
pyrope,Py,Mg3Al2Si3O12,cr,Ber88,BA96.3,01.Oct.17,Berman,J,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA
|
|
13
|
+
rutile,Rt,TiO2,cr,Ber88,BA96.2,01.Oct.17,Berman,J,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA
|
|
14
|
+
spinel,Sp,MgAl2O4,cr,Ber88,BA96.3,01.Oct.17,Berman,J,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA
|
|
15
|
+
talc,Tc,Mg3Si4O12H2,cr,Ber88,BA96.4,01.Oct.17,Berman,J,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA
|
|
16
|
+
Fe-cordierite,fCd,Fe2Al4Si5O18,cr,BA96,NA,12.Dec.17,Berman,J,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA
|
|
17
|
+
geikelite,Gk,MgTiO3,cr,BA96,NA,12.Dec.17,Berman,J,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA
|
|
18
|
+
hercynite,Hc,FeAl2O4,cr,BA96,NA,12.Dec.17,Berman,J,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA
|
|
19
|
+
iron-a,aFe,Fe,cr,BA96,NA,12.Dec.17,Berman,J,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA
|
|
20
|
+
iron-g,gFe,Fe,cr,BA96,NA,12.Dec.17,Berman,J,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA
|
|
21
|
+
orthocorundum,Ok,Al2O3,cr,BA96,NA,12.Dec.17,Berman,J,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA
|