pychnosz 1.1.10__tar.gz
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-1.1.10/CITATION.cff +17 -0
- pychnosz-1.1.10/LICENSE.txt +19 -0
- pychnosz-1.1.10/MANIFEST.in +36 -0
- pychnosz-1.1.10/PKG-INFO +197 -0
- pychnosz-1.1.10/README.md +148 -0
- pychnosz-1.1.10/compile_fortran.py +200 -0
- pychnosz-1.1.10/html/pychnosz/biomolecules/index.html +1095 -0
- pychnosz-1.1.10/html/pychnosz/biomolecules/proteins.html +855 -0
- pychnosz-1.1.10/html/pychnosz/core/animation.html +674 -0
- pychnosz-1.1.10/html/pychnosz/core/balance.html +411 -0
- pychnosz-1.1.10/html/pychnosz/core/equilibrium.html +895 -0
- pychnosz-1.1.10/html/pychnosz/core/index.html +4206 -0
- pychnosz-1.1.10/html/pychnosz/core/speciation.html +1272 -0
- pychnosz-1.1.10/html/pychnosz/core/unicurve.html +951 -0
- pychnosz-1.1.10/html/pychnosz/data/add_obigt.html +467 -0
- pychnosz-1.1.10/html/pychnosz/data/index.html +2178 -0
- pychnosz-1.1.10/html/pychnosz/data/loader.html +1108 -0
- pychnosz-1.1.10/html/pychnosz/data/mod_obigt.html +431 -0
- pychnosz-1.1.10/html/pychnosz/data/obigt.html +1124 -0
- pychnosz-1.1.10/html/pychnosz/data/worm.html +397 -0
- pychnosz-1.1.10/html/pychnosz/fortran/h2o92_interface.html +1124 -0
- pychnosz-1.1.10/html/pychnosz/fortran/index.html +1135 -0
- pychnosz-1.1.10/html/pychnosz/geochemistry/index.html +2097 -0
- pychnosz-1.1.10/html/pychnosz/geochemistry/minerals.html +1106 -0
- pychnosz-1.1.10/html/pychnosz/geochemistry/redox.html +1057 -0
- pychnosz-1.1.10/html/pychnosz/index.html +12998 -0
- pychnosz-1.1.10/html/pychnosz/models/archer_wang.html +234 -0
- pychnosz-1.1.10/html/pychnosz/models/berman.html +400 -0
- pychnosz-1.1.10/html/pychnosz/models/dew.html +1357 -0
- pychnosz-1.1.10/html/pychnosz/models/hkf_helpers.html +362 -0
- pychnosz-1.1.10/html/pychnosz/models/iapws95.html +1661 -0
- pychnosz-1.1.10/html/pychnosz/models/index.html +2287 -0
- pychnosz-1.1.10/html/pychnosz/models/supcrt92_fortran.html +491 -0
- pychnosz-1.1.10/html/pychnosz/utils/expression.html +1424 -0
- pychnosz-1.1.10/html/pychnosz/utils/formula.html +901 -0
- pychnosz-1.1.10/html/pychnosz/utils/formula_ox.html +416 -0
- pychnosz-1.1.10/html/pychnosz/utils/index.html +971 -0
- pychnosz-1.1.10/html/pychnosz/utils/units.html +391 -0
- pychnosz-1.1.10/pychnosz/__init__.py +129 -0
- pychnosz-1.1.10/pychnosz/biomolecules/__init__.py +29 -0
- pychnosz-1.1.10/pychnosz/biomolecules/ionize_aa.py +197 -0
- pychnosz-1.1.10/pychnosz/biomolecules/proteins.py +595 -0
- pychnosz-1.1.10/pychnosz/core/__init__.py +46 -0
- pychnosz-1.1.10/pychnosz/core/affinity.py +1256 -0
- pychnosz-1.1.10/pychnosz/core/animation.py +593 -0
- pychnosz-1.1.10/pychnosz/core/balance.py +334 -0
- pychnosz-1.1.10/pychnosz/core/basis.py +716 -0
- pychnosz-1.1.10/pychnosz/core/diagram.py +3336 -0
- pychnosz-1.1.10/pychnosz/core/equilibrate.py +813 -0
- pychnosz-1.1.10/pychnosz/core/equilibrium.py +554 -0
- pychnosz-1.1.10/pychnosz/core/info.py +821 -0
- pychnosz-1.1.10/pychnosz/core/retrieve.py +364 -0
- pychnosz-1.1.10/pychnosz/core/speciation.py +580 -0
- pychnosz-1.1.10/pychnosz/core/species.py +599 -0
- pychnosz-1.1.10/pychnosz/core/subcrt.py +1696 -0
- pychnosz-1.1.10/pychnosz/core/thermo.py +593 -0
- pychnosz-1.1.10/pychnosz/core/unicurve.py +1226 -0
- pychnosz-1.1.10/pychnosz/data/__init__.py +11 -0
- pychnosz-1.1.10/pychnosz/data/add_obigt.py +327 -0
- pychnosz-1.1.10/pychnosz/data/extdata/Berman/BDat17_2017.csv +2 -0
- pychnosz-1.1.10/pychnosz/data/extdata/Berman/Ber88_1988.csv +68 -0
- pychnosz-1.1.10/pychnosz/data/extdata/Berman/Ber90_1990.csv +5 -0
- pychnosz-1.1.10/pychnosz/data/extdata/Berman/DS10_2010.csv +6 -0
- pychnosz-1.1.10/pychnosz/data/extdata/Berman/FDM+14_2014.csv +2 -0
- pychnosz-1.1.10/pychnosz/data/extdata/Berman/Got04_2004.csv +5 -0
- pychnosz-1.1.10/pychnosz/data/extdata/Berman/JUN92_1992.csv +3 -0
- pychnosz-1.1.10/pychnosz/data/extdata/Berman/SHD91_1991.csv +12 -0
- pychnosz-1.1.10/pychnosz/data/extdata/Berman/VGT92_1992.csv +2 -0
- pychnosz-1.1.10/pychnosz/data/extdata/Berman/VPT01_2001.csv +3 -0
- pychnosz-1.1.10/pychnosz/data/extdata/Berman/VPV05_2005.csv +2 -0
- pychnosz-1.1.10/pychnosz/data/extdata/Berman/ZS92_1992.csv +11 -0
- pychnosz-1.1.10/pychnosz/data/extdata/Berman/sympy.R +99 -0
- pychnosz-1.1.10/pychnosz/data/extdata/Berman/testing/BA96.bib +12 -0
- pychnosz-1.1.10/pychnosz/data/extdata/Berman/testing/BA96_Berman.csv +21 -0
- pychnosz-1.1.10/pychnosz/data/extdata/Berman/testing/BA96_OBIGT.csv +21 -0
- pychnosz-1.1.10/pychnosz/data/extdata/Berman/testing/BA96_refs.csv +6 -0
- pychnosz-1.1.10/pychnosz/data/extdata/OBIGT/AD.csv +25 -0
- pychnosz-1.1.10/pychnosz/data/extdata/OBIGT/Berman_cr.csv +93 -0
- pychnosz-1.1.10/pychnosz/data/extdata/OBIGT/DEW.csv +211 -0
- pychnosz-1.1.10/pychnosz/data/extdata/OBIGT/H2O_aq.csv +4 -0
- pychnosz-1.1.10/pychnosz/data/extdata/OBIGT/SLOP98.csv +411 -0
- pychnosz-1.1.10/pychnosz/data/extdata/OBIGT/SUPCRT92.csv +178 -0
- pychnosz-1.1.10/pychnosz/data/extdata/OBIGT/inorganic_aq.csv +729 -0
- pychnosz-1.1.10/pychnosz/data/extdata/OBIGT/inorganic_cr.csv +273 -0
- pychnosz-1.1.10/pychnosz/data/extdata/OBIGT/inorganic_gas.csv +20 -0
- pychnosz-1.1.10/pychnosz/data/extdata/OBIGT/organic_aq.csv +1104 -0
- pychnosz-1.1.10/pychnosz/data/extdata/OBIGT/organic_cr.csv +481 -0
- pychnosz-1.1.10/pychnosz/data/extdata/OBIGT/organic_gas.csv +268 -0
- pychnosz-1.1.10/pychnosz/data/extdata/OBIGT/organic_liq.csv +533 -0
- pychnosz-1.1.10/pychnosz/data/extdata/OBIGT/testing/GEMSFIT.csv +43 -0
- pychnosz-1.1.10/pychnosz/data/extdata/OBIGT/testing/IGEM.csv +17 -0
- pychnosz-1.1.10/pychnosz/data/extdata/OBIGT/testing/Sandia.csv +8 -0
- pychnosz-1.1.10/pychnosz/data/extdata/OBIGT/testing/SiO2.csv +4 -0
- pychnosz-1.1.10/pychnosz/data/extdata/misc/AD03_Fig1a.csv +69 -0
- pychnosz-1.1.10/pychnosz/data/extdata/misc/AD03_Fig1b.csv +43 -0
- pychnosz-1.1.10/pychnosz/data/extdata/misc/AD03_Fig1c.csv +89 -0
- pychnosz-1.1.10/pychnosz/data/extdata/misc/AD03_Fig1d.csv +30 -0
- pychnosz-1.1.10/pychnosz/data/extdata/misc/BZA10.csv +5 -0
- pychnosz-1.1.10/pychnosz/data/extdata/misc/HW97_Cp.csv +90 -0
- pychnosz-1.1.10/pychnosz/data/extdata/misc/HWM96_V.csv +229 -0
- pychnosz-1.1.10/pychnosz/data/extdata/misc/LA19_test.csv +7 -0
- pychnosz-1.1.10/pychnosz/data/extdata/misc/Mer75_Table4.csv +42 -0
- pychnosz-1.1.10/pychnosz/data/extdata/misc/OBIGT_check.csv +423 -0
- pychnosz-1.1.10/pychnosz/data/extdata/misc/PM90.csv +7 -0
- pychnosz-1.1.10/pychnosz/data/extdata/misc/RH95.csv +23 -0
- pychnosz-1.1.10/pychnosz/data/extdata/misc/RH98_Table15.csv +17 -0
- pychnosz-1.1.10/pychnosz/data/extdata/misc/SC10_Rainbow.csv +19 -0
- pychnosz-1.1.10/pychnosz/data/extdata/misc/SK95.csv +55 -0
- pychnosz-1.1.10/pychnosz/data/extdata/misc/SOJSH.csv +61 -0
- pychnosz-1.1.10/pychnosz/data/extdata/misc/SS98_Fig5a.csv +81 -0
- pychnosz-1.1.10/pychnosz/data/extdata/misc/SS98_Fig5b.csv +84 -0
- pychnosz-1.1.10/pychnosz/data/extdata/misc/TKSS14_Fig2.csv +25 -0
- pychnosz-1.1.10/pychnosz/data/extdata/misc/bluered.txt +1000 -0
- pychnosz-1.1.10/pychnosz/data/extdata/protein/Cas/Cas_aa.csv +177 -0
- pychnosz-1.1.10/pychnosz/data/extdata/protein/Cas/Cas_uniprot.csv +186 -0
- pychnosz-1.1.10/pychnosz/data/extdata/protein/Cas/download.R +34 -0
- pychnosz-1.1.10/pychnosz/data/extdata/protein/Cas/mkaa.R +34 -0
- pychnosz-1.1.10/pychnosz/data/extdata/protein/POLG.csv +12 -0
- pychnosz-1.1.10/pychnosz/data/extdata/protein/TBD+05.csv +393 -0
- pychnosz-1.1.10/pychnosz/data/extdata/protein/TBD+05_aa.csv +393 -0
- pychnosz-1.1.10/pychnosz/data/extdata/protein/rubisco.csv +28 -0
- pychnosz-1.1.10/pychnosz/data/extdata/protein/rubisco.fasta +239 -0
- pychnosz-1.1.10/pychnosz/data/extdata/protein/rubisco_aa.csv +28 -0
- pychnosz-1.1.10/pychnosz/data/extdata/src/H2O92D.f.orig +3457 -0
- pychnosz-1.1.10/pychnosz/data/extdata/src/README.txt +5 -0
- pychnosz-1.1.10/pychnosz/data/extdata/taxonomy/names.dmp +215 -0
- pychnosz-1.1.10/pychnosz/data/extdata/taxonomy/nodes.dmp +63 -0
- pychnosz-1.1.10/pychnosz/data/extdata/thermo/Bdot_acirc.csv +60 -0
- pychnosz-1.1.10/pychnosz/data/extdata/thermo/buffer.csv +40 -0
- pychnosz-1.1.10/pychnosz/data/extdata/thermo/element.csv +135 -0
- pychnosz-1.1.10/pychnosz/data/extdata/thermo/groups.csv +6 -0
- pychnosz-1.1.10/pychnosz/data/extdata/thermo/opt.csv +2 -0
- pychnosz-1.1.10/pychnosz/data/extdata/thermo/protein.csv +506 -0
- pychnosz-1.1.10/pychnosz/data/extdata/thermo/refs.csv +343 -0
- pychnosz-1.1.10/pychnosz/data/extdata/thermo/stoich.csv.xz +0 -0
- pychnosz-1.1.10/pychnosz/data/loader.py +431 -0
- pychnosz-1.1.10/pychnosz/data/mod_obigt.py +322 -0
- pychnosz-1.1.10/pychnosz/data/obigt.py +471 -0
- pychnosz-1.1.10/pychnosz/data/worm.py +228 -0
- pychnosz-1.1.10/pychnosz/fortran/__init__.py +16 -0
- pychnosz-1.1.10/pychnosz/fortran/h2o92_interface.py +527 -0
- pychnosz-1.1.10/pychnosz/geochemistry/__init__.py +21 -0
- pychnosz-1.1.10/pychnosz/geochemistry/minerals.py +514 -0
- pychnosz-1.1.10/pychnosz/geochemistry/redox.py +500 -0
- pychnosz-1.1.10/pychnosz/models/__init__.py +47 -0
- pychnosz-1.1.10/pychnosz/models/archer_wang.py +165 -0
- pychnosz-1.1.10/pychnosz/models/berman.py +309 -0
- pychnosz-1.1.10/pychnosz/models/cgl.py +381 -0
- pychnosz-1.1.10/pychnosz/models/dew.py +997 -0
- pychnosz-1.1.10/pychnosz/models/hkf.py +523 -0
- pychnosz-1.1.10/pychnosz/models/hkf_helpers.py +223 -0
- pychnosz-1.1.10/pychnosz/models/iapws95.py +1113 -0
- pychnosz-1.1.10/pychnosz/models/supcrt92_fortran.py +238 -0
- pychnosz-1.1.10/pychnosz/models/water.py +480 -0
- pychnosz-1.1.10/pychnosz/utils/__init__.py +27 -0
- pychnosz-1.1.10/pychnosz/utils/expression.py +1074 -0
- pychnosz-1.1.10/pychnosz/utils/formula.py +830 -0
- pychnosz-1.1.10/pychnosz/utils/formula_ox.py +227 -0
- pychnosz-1.1.10/pychnosz/utils/reset.py +33 -0
- pychnosz-1.1.10/pychnosz/utils/units.py +259 -0
- pychnosz-1.1.10/pychnosz.egg-info/PKG-INFO +197 -0
- pychnosz-1.1.10/pychnosz.egg-info/SOURCES.txt +167 -0
- pychnosz-1.1.10/pychnosz.egg-info/dependency_links.txt +1 -0
- pychnosz-1.1.10/pychnosz.egg-info/requires.txt +22 -0
- pychnosz-1.1.10/pychnosz.egg-info/top_level.txt +1 -0
- pychnosz-1.1.10/pyproject.toml +136 -0
- pychnosz-1.1.10/setup.cfg +4 -0
- pychnosz-1.1.10/setup.py +32 -0
- pychnosz-1.1.10/test_integration.py +139 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# YAML 1.2
|
|
2
|
+
---
|
|
3
|
+
authors:
|
|
4
|
+
-
|
|
5
|
+
affiliation: "Arizona State University, School of Earth and Space Exploration"
|
|
6
|
+
family-names: Boyer
|
|
7
|
+
given-names: Grayson
|
|
8
|
+
orcid: "https://orcid.org/0000-0002-7670-9273"
|
|
9
|
+
|
|
10
|
+
cff-version: "0.10.0"
|
|
11
|
+
license: MIT
|
|
12
|
+
message: "If you use this software, please cite it using these metadata."
|
|
13
|
+
repository-code: "https://github.com/worm-portal/pychnosz"
|
|
14
|
+
title: "pyCHNOSZ: Python conversion of the thermodynamic package CHNOSZ"
|
|
15
|
+
version: "0.10.0"
|
|
16
|
+
date-released: 2025-11-1
|
|
17
|
+
...
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2025 Grayson Boyer and GEOPIG Lab. The original CHNOSZ belongs to Jeff Dick.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Include important documentation files
|
|
2
|
+
include README.md
|
|
3
|
+
include LICENSE.txt
|
|
4
|
+
include CITATION.cff
|
|
5
|
+
include pyproject.toml
|
|
6
|
+
|
|
7
|
+
# Include compilation script (needed for building wheels)
|
|
8
|
+
include compile_fortran.py
|
|
9
|
+
|
|
10
|
+
# Include integration test script (needed for wheel testing)
|
|
11
|
+
include test_integration.py
|
|
12
|
+
|
|
13
|
+
# Include HTML documentation
|
|
14
|
+
recursive-include html *.html *.css *.js
|
|
15
|
+
|
|
16
|
+
# Include all thermodynamic database files
|
|
17
|
+
recursive-include pychnosz/data/extdata *.csv *.csv.gz *.csv.xz *.json
|
|
18
|
+
recursive-include pychnosz/data *.csv *.csv.gz *.json
|
|
19
|
+
|
|
20
|
+
# Include Fortran source files (will be compiled during wheel build)
|
|
21
|
+
recursive-include pychnosz/data/extdata/src *.f *.f90 *.for *.f.orig
|
|
22
|
+
|
|
23
|
+
# NOTE: Fortran binaries (*.so, *.dll, *.dylib) are NOT included in the source distribution
|
|
24
|
+
# They are compiled during the wheel build process via compile_fortran.py
|
|
25
|
+
|
|
26
|
+
# Exclude test files and development artifacts
|
|
27
|
+
prune test
|
|
28
|
+
global-exclude *.pyc
|
|
29
|
+
global-exclude *.pyo
|
|
30
|
+
global-exclude *.pyd
|
|
31
|
+
global-exclude __pycache__
|
|
32
|
+
global-exclude .pytest_cache
|
|
33
|
+
global-exclude .ipynb_checkpoints
|
|
34
|
+
global-exclude *~
|
|
35
|
+
global-exclude *.swp
|
|
36
|
+
global-exclude .DS_Store
|
pychnosz-1.1.10/PKG-INFO
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pychnosz
|
|
3
|
+
Version: 1.1.10
|
|
4
|
+
Summary: Python port of the package CHNOSZ
|
|
5
|
+
Author-email: Grayson Boyer <gmboyer@asu.edu>
|
|
6
|
+
Maintainer-email: Grayson Boyer <gmboyer@asu.edu>
|
|
7
|
+
License: MIT License
|
|
8
|
+
Project-URL: Homepage, https://worm-portal.asu.edu
|
|
9
|
+
Project-URL: Repository, https://github.com/worm-portal/pychnosz
|
|
10
|
+
Project-URL: Documentation, https://worm-portal.asu.edu/pyCHNOSZ-docs/index.html
|
|
11
|
+
Project-URL: Issues, https://github.com/worm-portal/pychnosz/issues
|
|
12
|
+
Keywords: thermodynamics,geochemistry,geobiochemistry,aqueous chemistry,equilibrium,phase diagrams
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Chemistry
|
|
25
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
26
|
+
Requires-Python: >=3.10
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
License-File: LICENSE.txt
|
|
29
|
+
Requires-Dist: numpy>=1.20.0
|
|
30
|
+
Requires-Dist: pandas>=1.3.0
|
|
31
|
+
Requires-Dist: scipy>=1.7.0
|
|
32
|
+
Requires-Dist: matplotlib>=3.3.0
|
|
33
|
+
Provides-Extra: dev
|
|
34
|
+
Requires-Dist: pytest>=6.0; extra == "dev"
|
|
35
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
36
|
+
Requires-Dist: black; extra == "dev"
|
|
37
|
+
Requires-Dist: flake8; extra == "dev"
|
|
38
|
+
Requires-Dist: mypy; extra == "dev"
|
|
39
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
40
|
+
Provides-Extra: docs
|
|
41
|
+
Requires-Dist: sphinx>=4.0; extra == "docs"
|
|
42
|
+
Requires-Dist: sphinx-rtd-theme; extra == "docs"
|
|
43
|
+
Requires-Dist: sphinx-autodoc-typehints; extra == "docs"
|
|
44
|
+
Requires-Dist: myst-parser; extra == "docs"
|
|
45
|
+
Provides-Extra: interactive
|
|
46
|
+
Requires-Dist: plotly>=5.0.0; extra == "interactive"
|
|
47
|
+
Requires-Dist: ipython>=7.0.0; extra == "interactive"
|
|
48
|
+
Dynamic: license-file
|
|
49
|
+
|
|
50
|
+
# pyCHNOSZ
|
|
51
|
+
|
|
52
|
+
[](https://doi.org/10.5281/zenodo.11406142)
|
|
53
|
+
|
|
54
|
+
Author: Dr. Grayson Boyer, GEOPIG Lab, Arizona State University
|
|
55
|
+
|
|
56
|
+
[CHNOSZ](https://www.chnosz.net/) is a package written by [Dr. Jeff Dick](https://chnosz.net/jeff/) for performing thermodynamic calculations in aqueous geochemistry and biogeochemistry. pyCHNOSZ is a Python conversion of CHNOSZ that allows these calculations to be carried out in Python 3 Jupyter notebooks.
|
|
57
|
+
|
|
58
|
+
## Features
|
|
59
|
+
|
|
60
|
+
The following CHNOSZ functions are supported in pyCHNOSZ:
|
|
61
|
+
|
|
62
|
+
- [info](https://chnosz.net/manual/info.html) - Search for chemical species by name or formula and retrieve their thermodynamic parameters.
|
|
63
|
+
- [add_OBIGT](https://chnosz.net/manual/add.OBIGT.html) - Add or overwrite species in the OBIGT thermodynamic database by supplying a comma separated value (csv) file with custom data.
|
|
64
|
+
- [mod_OBIGT](https://chnosz.net/manual/add.OBIGT.html) - Modify species in the OBIGT thermodynamic database. Optionally, supply a Pandas dataframe containing custom data.
|
|
65
|
+
- [reset](https://chnosz.net/manual/thermo.html) - reset data to default values.
|
|
66
|
+
- [subcrt](https://chnosz.net/manual/subcrt.html) - Calculate standard state partial molal thermodynamic properties of reactions at elevated temperatures and pressures.
|
|
67
|
+
- [basis](https://chnosz.net/manual/basis.html) - Define basis species of a chemical system.
|
|
68
|
+
- [species](https://chnosz.net/manual/species.html) - Define the species of interest in a system.
|
|
69
|
+
- [equilibrate](https://chnosz.net/manual/equilibrate.html) - Calculate equilibrium chemical activities of species from the affinities of formation of the species at unit activity.
|
|
70
|
+
- [affinity](https://chnosz.net/manual/affinity.html) - Calculate the chemical affinities of formation reactions of species.
|
|
71
|
+
- [diagram](https://chnosz.net/manual/diagram.html) - Plot equilibrium chemical activity (1-D speciation) or equal-activity (2-D predominance) diagrams as a function of chemical activities of basis species, temperature and/or pressure.
|
|
72
|
+
- And more. See the [documentation for pyCHNOSZ](https://worm-portal.asu.edu/pyCHNOSZ-docs/fun.html)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
## Requirements
|
|
76
|
+
|
|
77
|
+
This package must be installed into an environment with an [R](https://www.r-project.org/) installation. See [these instructions](https://docs.anaconda.com/anaconda/user-guide/tasks/using-r-language/) for installing R with Anaconda. Additionally, the CHNOSZ package for R must be installed (see instructions below).
|
|
78
|
+
|
|
79
|
+
## Installation
|
|
80
|
+
|
|
81
|
+
### Installing pyCHNOSZ
|
|
82
|
+
|
|
83
|
+
Install pyCHNOSZ using pip:
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
$ pip install pychnosz
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Usage
|
|
90
|
+
|
|
91
|
+
Import pyCHNOSZ in your python code with:
|
|
92
|
+
```python
|
|
93
|
+
import pychnosz
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
In the following examples, pyCHNOSZ functions are imported with:
|
|
97
|
+
```python
|
|
98
|
+
from pychnosz import info, add_OBIGT, mod_OBIGT, reset, subcrt
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Search for chemical species
|
|
102
|
+
|
|
103
|
+
The `info()` function can be used to look up chemical species by name or formula. If names or formulas are provided, database index integers are returned. A list of integers will look up chemical species by index and return a table of thermodynamic properties. See the `info()` function's [original documentation](https://chnosz.net/manual/info.html) to learn more about what this function can do. A few examples are shown below.
|
|
104
|
+
|
|
105
|
+
Look up the database index value of Fe+2:
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
info("Fe+2")
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Look up multiple chemical species:
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
info(["HCO3-", "CH4"])
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Define chemical states:
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
info(["HCO3-", "CH4"], state=["aq", "gas"])
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Search species by index values to look up their thermodynamic parameters.
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
info([13, 872])
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Nest `info` functions to look up thermodynamic properties directly from names or formulas:
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
info(info("Fe+2"))
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Add or replace thermodynamic data in the database
|
|
136
|
+
|
|
137
|
+
See the original R documentation for `add_OBIGT()` and `reset()` for basic useage. A few examples are given below.
|
|
138
|
+
|
|
139
|
+
Load the SUPCRT92 database.
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
a = add_OBIGT("SUPCRT92")
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
The variable `a` is assigned a list of integers corresponding to the indices of chemical species that are added or replaced in the OBIGT thermodynamic database used by pyCHNOSZ.
|
|
146
|
+
|
|
147
|
+
It is possible to add a custom table of thermodynamic parameters.
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
a = add_OBIGT("my_custom_entries.csv")
|
|
151
|
+
info(a) # confirm new entries have been added
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
The entries of `my_custom_entries.csv` would then be available for thermodynamic calculations with `subcrt()`, for example.
|
|
155
|
+
|
|
156
|
+
Reset thermodynamic database to its original configuration.
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
reset()
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Modify values in the thermodynamic database with `mod_OBIGT()`:
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
mod_OBIGT("HCO3-", G = -140283.7, Cp = -9)
|
|
166
|
+
info(info("HCO3-"))
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Calculate thermodynamic properties of reactions
|
|
170
|
+
|
|
171
|
+
See the [original documentation](https://chnosz.net/manual/subcrt.html) for `subcrt()`. Useage in pyCHNOSZ is the same, except python lists are used in place of R's vectors. The function produces a dictionary of results stored in pandas dataframes. An example is shown below for the reaction H<sub>2 (aq)</sub> + 0.5 O<sub>2 (gas)</sub> = H<sub>2</sub>O<sub>(liq)</sub> at 30 and 50 degrees C and 100 bars pressure:
|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
subcrt(species=["H2", "O2", "H2O"], coeff=[-1.0, -0.5, 1.0],
|
|
175
|
+
state=["aq", "gas", "liq"], T=[30, 50], P=100)
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Output is a python dictionary of dataframes:
|
|
179
|
+
```
|
|
180
|
+
subcrt: 3 species at 2 values of T (ºC) and P (bar) (wet) [energy units: cal]
|
|
181
|
+
|
|
182
|
+
{'reaction': coeff name formula state ispecies
|
|
183
|
+
62 -1.0 H2 H2 aq 62.0
|
|
184
|
+
2612 -0.5 oxygen O2 gas 2612.0
|
|
185
|
+
1 1.0 water H2O liq 1.0,
|
|
186
|
+
'out': T P rho logK G H S \
|
|
187
|
+
1 30.0 100 1.000017 43.855086 -60832.380282 -67420.887872 -21.89070
|
|
188
|
+
2 50.0 100 0.992305 40.834419 -60379.262657 -67882.530994 -23.36663
|
|
189
|
+
|
|
190
|
+
V Cp
|
|
191
|
+
1 -7.494052 -24.126268
|
|
192
|
+
2 -8.259704 -20.941879 }
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### More examples:
|
|
196
|
+
|
|
197
|
+
For more examples, check out the [pyCHNOSZ tutorial notebooks available from the WORM Library](https://github.com/worm-portal/WORM-Library/tree/master/2-Reaction-Properties).
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# pyCHNOSZ
|
|
2
|
+
|
|
3
|
+
[](https://doi.org/10.5281/zenodo.11406142)
|
|
4
|
+
|
|
5
|
+
Author: Dr. Grayson Boyer, GEOPIG Lab, Arizona State University
|
|
6
|
+
|
|
7
|
+
[CHNOSZ](https://www.chnosz.net/) is a package written by [Dr. Jeff Dick](https://chnosz.net/jeff/) for performing thermodynamic calculations in aqueous geochemistry and biogeochemistry. pyCHNOSZ is a Python conversion of CHNOSZ that allows these calculations to be carried out in Python 3 Jupyter notebooks.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
The following CHNOSZ functions are supported in pyCHNOSZ:
|
|
12
|
+
|
|
13
|
+
- [info](https://chnosz.net/manual/info.html) - Search for chemical species by name or formula and retrieve their thermodynamic parameters.
|
|
14
|
+
- [add_OBIGT](https://chnosz.net/manual/add.OBIGT.html) - Add or overwrite species in the OBIGT thermodynamic database by supplying a comma separated value (csv) file with custom data.
|
|
15
|
+
- [mod_OBIGT](https://chnosz.net/manual/add.OBIGT.html) - Modify species in the OBIGT thermodynamic database. Optionally, supply a Pandas dataframe containing custom data.
|
|
16
|
+
- [reset](https://chnosz.net/manual/thermo.html) - reset data to default values.
|
|
17
|
+
- [subcrt](https://chnosz.net/manual/subcrt.html) - Calculate standard state partial molal thermodynamic properties of reactions at elevated temperatures and pressures.
|
|
18
|
+
- [basis](https://chnosz.net/manual/basis.html) - Define basis species of a chemical system.
|
|
19
|
+
- [species](https://chnosz.net/manual/species.html) - Define the species of interest in a system.
|
|
20
|
+
- [equilibrate](https://chnosz.net/manual/equilibrate.html) - Calculate equilibrium chemical activities of species from the affinities of formation of the species at unit activity.
|
|
21
|
+
- [affinity](https://chnosz.net/manual/affinity.html) - Calculate the chemical affinities of formation reactions of species.
|
|
22
|
+
- [diagram](https://chnosz.net/manual/diagram.html) - Plot equilibrium chemical activity (1-D speciation) or equal-activity (2-D predominance) diagrams as a function of chemical activities of basis species, temperature and/or pressure.
|
|
23
|
+
- And more. See the [documentation for pyCHNOSZ](https://worm-portal.asu.edu/pyCHNOSZ-docs/fun.html)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## Requirements
|
|
27
|
+
|
|
28
|
+
This package must be installed into an environment with an [R](https://www.r-project.org/) installation. See [these instructions](https://docs.anaconda.com/anaconda/user-guide/tasks/using-r-language/) for installing R with Anaconda. Additionally, the CHNOSZ package for R must be installed (see instructions below).
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
### Installing pyCHNOSZ
|
|
33
|
+
|
|
34
|
+
Install pyCHNOSZ using pip:
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
$ pip install pychnosz
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
Import pyCHNOSZ in your python code with:
|
|
43
|
+
```python
|
|
44
|
+
import pychnosz
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
In the following examples, pyCHNOSZ functions are imported with:
|
|
48
|
+
```python
|
|
49
|
+
from pychnosz import info, add_OBIGT, mod_OBIGT, reset, subcrt
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Search for chemical species
|
|
53
|
+
|
|
54
|
+
The `info()` function can be used to look up chemical species by name or formula. If names or formulas are provided, database index integers are returned. A list of integers will look up chemical species by index and return a table of thermodynamic properties. See the `info()` function's [original documentation](https://chnosz.net/manual/info.html) to learn more about what this function can do. A few examples are shown below.
|
|
55
|
+
|
|
56
|
+
Look up the database index value of Fe+2:
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
info("Fe+2")
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Look up multiple chemical species:
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
info(["HCO3-", "CH4"])
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Define chemical states:
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
info(["HCO3-", "CH4"], state=["aq", "gas"])
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Search species by index values to look up their thermodynamic parameters.
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
info([13, 872])
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Nest `info` functions to look up thermodynamic properties directly from names or formulas:
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
info(info("Fe+2"))
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Add or replace thermodynamic data in the database
|
|
87
|
+
|
|
88
|
+
See the original R documentation for `add_OBIGT()` and `reset()` for basic useage. A few examples are given below.
|
|
89
|
+
|
|
90
|
+
Load the SUPCRT92 database.
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
a = add_OBIGT("SUPCRT92")
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
The variable `a` is assigned a list of integers corresponding to the indices of chemical species that are added or replaced in the OBIGT thermodynamic database used by pyCHNOSZ.
|
|
97
|
+
|
|
98
|
+
It is possible to add a custom table of thermodynamic parameters.
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
a = add_OBIGT("my_custom_entries.csv")
|
|
102
|
+
info(a) # confirm new entries have been added
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
The entries of `my_custom_entries.csv` would then be available for thermodynamic calculations with `subcrt()`, for example.
|
|
106
|
+
|
|
107
|
+
Reset thermodynamic database to its original configuration.
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
reset()
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Modify values in the thermodynamic database with `mod_OBIGT()`:
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
mod_OBIGT("HCO3-", G = -140283.7, Cp = -9)
|
|
117
|
+
info(info("HCO3-"))
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Calculate thermodynamic properties of reactions
|
|
121
|
+
|
|
122
|
+
See the [original documentation](https://chnosz.net/manual/subcrt.html) for `subcrt()`. Useage in pyCHNOSZ is the same, except python lists are used in place of R's vectors. The function produces a dictionary of results stored in pandas dataframes. An example is shown below for the reaction H<sub>2 (aq)</sub> + 0.5 O<sub>2 (gas)</sub> = H<sub>2</sub>O<sub>(liq)</sub> at 30 and 50 degrees C and 100 bars pressure:
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
subcrt(species=["H2", "O2", "H2O"], coeff=[-1.0, -0.5, 1.0],
|
|
126
|
+
state=["aq", "gas", "liq"], T=[30, 50], P=100)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Output is a python dictionary of dataframes:
|
|
130
|
+
```
|
|
131
|
+
subcrt: 3 species at 2 values of T (ºC) and P (bar) (wet) [energy units: cal]
|
|
132
|
+
|
|
133
|
+
{'reaction': coeff name formula state ispecies
|
|
134
|
+
62 -1.0 H2 H2 aq 62.0
|
|
135
|
+
2612 -0.5 oxygen O2 gas 2612.0
|
|
136
|
+
1 1.0 water H2O liq 1.0,
|
|
137
|
+
'out': T P rho logK G H S \
|
|
138
|
+
1 30.0 100 1.000017 43.855086 -60832.380282 -67420.887872 -21.89070
|
|
139
|
+
2 50.0 100 0.992305 40.834419 -60379.262657 -67882.530994 -23.36663
|
|
140
|
+
|
|
141
|
+
V Cp
|
|
142
|
+
1 -7.494052 -24.126268
|
|
143
|
+
2 -8.259704 -20.941879 }
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### More examples:
|
|
147
|
+
|
|
148
|
+
For more examples, check out the [pyCHNOSZ tutorial notebooks available from the WORM Library](https://github.com/worm-portal/WORM-Library/tree/master/2-Reaction-Properties).
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
"""
|
|
3
|
+
Compile Fortran source code to shared library for the current platform.
|
|
4
|
+
|
|
5
|
+
This script is called during the wheel build process to compile the H2O92
|
|
6
|
+
Fortran subroutine into a platform-specific shared library.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
import sys
|
|
11
|
+
import subprocess
|
|
12
|
+
import shutil
|
|
13
|
+
import platform
|
|
14
|
+
import tempfile
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def find_gfortran():
|
|
19
|
+
"""Find gfortran compiler on the system."""
|
|
20
|
+
# Check if explicit gfortran path is provided via environment variable
|
|
21
|
+
explicit_path = os.environ.get('GFORTRAN_PATH')
|
|
22
|
+
if explicit_path and os.path.isfile(explicit_path):
|
|
23
|
+
print(f"Using explicit gfortran path from GFORTRAN_PATH: {explicit_path}")
|
|
24
|
+
return explicit_path
|
|
25
|
+
|
|
26
|
+
# Try common gfortran locations
|
|
27
|
+
candidates = ['gfortran', 'gfortran-11', 'gfortran-12', 'gfortran-13', 'gfortran-14']
|
|
28
|
+
|
|
29
|
+
for compiler in candidates:
|
|
30
|
+
compiler_path = shutil.which(compiler)
|
|
31
|
+
if compiler_path:
|
|
32
|
+
return compiler_path
|
|
33
|
+
|
|
34
|
+
raise RuntimeError(
|
|
35
|
+
"gfortran compiler not found. Please install gfortran:\n"
|
|
36
|
+
" Ubuntu/Debian: sudo apt-get install gfortran\n"
|
|
37
|
+
" macOS: brew install gcc\n"
|
|
38
|
+
" Windows: Install MinGW-w64 with gfortran support"
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def compile_fortran():
|
|
43
|
+
"""Compile H2O92D.f.orig to a shared library."""
|
|
44
|
+
# Determine paths
|
|
45
|
+
script_dir = Path(__file__).parent
|
|
46
|
+
source_file = script_dir / "pychnosz" / "data" / "extdata" / "src" / "H2O92D.f.orig"
|
|
47
|
+
output_dir = script_dir / "pychnosz" / "fortran"
|
|
48
|
+
|
|
49
|
+
# Verify source file exists
|
|
50
|
+
if not source_file.exists():
|
|
51
|
+
raise FileNotFoundError(f"Fortran source not found: {source_file}")
|
|
52
|
+
|
|
53
|
+
# Create output directory if it doesn't exist
|
|
54
|
+
output_dir.mkdir(parents=True, exist_ok=True)
|
|
55
|
+
|
|
56
|
+
# Determine output library name based on platform
|
|
57
|
+
if sys.platform == "win32":
|
|
58
|
+
lib_name = "h2o92.dll"
|
|
59
|
+
elif sys.platform == "darwin":
|
|
60
|
+
lib_name = "h2o92.dylib"
|
|
61
|
+
else: # Linux and other Unix-like
|
|
62
|
+
lib_name = "h2o92.so"
|
|
63
|
+
|
|
64
|
+
output_file = output_dir / lib_name
|
|
65
|
+
|
|
66
|
+
# Find gfortran
|
|
67
|
+
gfortran = find_gfortran()
|
|
68
|
+
print(f"Using compiler: {gfortran}")
|
|
69
|
+
print(f"Compiling {source_file.name} -> {lib_name}")
|
|
70
|
+
|
|
71
|
+
# Detect macOS architecture for cross-compilation
|
|
72
|
+
macos_arch = None
|
|
73
|
+
if sys.platform == "darwin":
|
|
74
|
+
# Check environment variable set by cibuildwheel
|
|
75
|
+
archflags = os.environ.get('ARCHFLAGS', '')
|
|
76
|
+
print(f"ARCHFLAGS environment variable: '{archflags}'")
|
|
77
|
+
|
|
78
|
+
if 'x86_64' in archflags:
|
|
79
|
+
macos_arch = 'x86_64'
|
|
80
|
+
elif 'arm64' in archflags:
|
|
81
|
+
macos_arch = 'arm64'
|
|
82
|
+
else:
|
|
83
|
+
# Fallback to machine architecture
|
|
84
|
+
machine = platform.machine()
|
|
85
|
+
macos_arch = 'arm64' if machine == 'arm64' else 'x86_64'
|
|
86
|
+
print(f"macOS target architecture: {macos_arch}")
|
|
87
|
+
print(f"Current machine architecture: {platform.machine()}")
|
|
88
|
+
|
|
89
|
+
# gfortran doesn't recognize .f.orig extension, so copy to temp file with .f extension
|
|
90
|
+
with tempfile.NamedTemporaryFile(suffix='.f', delete=False) as tmp_f:
|
|
91
|
+
temp_source = Path(tmp_f.name)
|
|
92
|
+
|
|
93
|
+
try:
|
|
94
|
+
# Copy source to temp file with .f extension
|
|
95
|
+
shutil.copy2(source_file, temp_source)
|
|
96
|
+
print(f"Using temporary source file: {temp_source}")
|
|
97
|
+
|
|
98
|
+
# Compile command
|
|
99
|
+
# -shared: create a shared library
|
|
100
|
+
# -fPIC: position-independent code (required for shared libraries)
|
|
101
|
+
# -O2: optimization level 2
|
|
102
|
+
# -o: output file
|
|
103
|
+
cmd = [
|
|
104
|
+
gfortran,
|
|
105
|
+
"-shared",
|
|
106
|
+
"-fPIC",
|
|
107
|
+
"-O2",
|
|
108
|
+
str(temp_source),
|
|
109
|
+
"-o", str(output_file)
|
|
110
|
+
]
|
|
111
|
+
|
|
112
|
+
# Platform-specific flags
|
|
113
|
+
if sys.platform == "darwin":
|
|
114
|
+
# macOS requires -dynamiclib for shared libraries
|
|
115
|
+
cmd[1] = "-dynamiclib"
|
|
116
|
+
# Add architecture flag for cross-compilation
|
|
117
|
+
if macos_arch:
|
|
118
|
+
cmd.insert(2, f"-arch")
|
|
119
|
+
cmd.insert(3, macos_arch)
|
|
120
|
+
elif sys.platform == "win32":
|
|
121
|
+
# Windows: statically link all MinGW runtime libraries
|
|
122
|
+
# This ensures the DLL has no external dependencies
|
|
123
|
+
cmd.insert(2, "-static-libgfortran")
|
|
124
|
+
cmd.insert(3, "-static-libgcc")
|
|
125
|
+
cmd.insert(4, "-static")
|
|
126
|
+
cmd.insert(5, "-lquadmath")
|
|
127
|
+
|
|
128
|
+
print(f"Running: {' '.join(cmd)}")
|
|
129
|
+
|
|
130
|
+
try:
|
|
131
|
+
result = subprocess.run(
|
|
132
|
+
cmd,
|
|
133
|
+
check=True,
|
|
134
|
+
capture_output=True,
|
|
135
|
+
text=True
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
if result.stdout:
|
|
139
|
+
print(result.stdout)
|
|
140
|
+
|
|
141
|
+
if result.stderr:
|
|
142
|
+
print(result.stderr, file=sys.stderr)
|
|
143
|
+
|
|
144
|
+
print(f"[OK] Successfully compiled {lib_name}")
|
|
145
|
+
print(f" Output: {output_file}")
|
|
146
|
+
print(f" Size: {output_file.stat().st_size / 1024:.1f} KB")
|
|
147
|
+
|
|
148
|
+
# Verify architecture on macOS
|
|
149
|
+
if sys.platform == "darwin":
|
|
150
|
+
print(f"Verifying architecture of compiled library...")
|
|
151
|
+
try:
|
|
152
|
+
arch_check = subprocess.run(
|
|
153
|
+
["lipo", "-info", str(output_file)],
|
|
154
|
+
capture_output=True,
|
|
155
|
+
text=True
|
|
156
|
+
)
|
|
157
|
+
print(f" lipo output: {arch_check.stdout.strip()}")
|
|
158
|
+
except FileNotFoundError:
|
|
159
|
+
print(f" Warning: lipo not found, skipping architecture check")
|
|
160
|
+
|
|
161
|
+
return True
|
|
162
|
+
|
|
163
|
+
except subprocess.CalledProcessError as e:
|
|
164
|
+
print(f"[ERROR] Compilation failed!", file=sys.stderr)
|
|
165
|
+
print(f"Exit code: {e.returncode}", file=sys.stderr)
|
|
166
|
+
if e.stdout:
|
|
167
|
+
print(f"stdout: {e.stdout}", file=sys.stderr)
|
|
168
|
+
if e.stderr:
|
|
169
|
+
print(f"stderr: {e.stderr}", file=sys.stderr)
|
|
170
|
+
raise RuntimeError(f"Failed to compile Fortran library: {e}")
|
|
171
|
+
|
|
172
|
+
finally:
|
|
173
|
+
# Clean up temporary file
|
|
174
|
+
if temp_source.exists():
|
|
175
|
+
temp_source.unlink()
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def main():
|
|
179
|
+
"""Main entry point."""
|
|
180
|
+
print("=" * 60)
|
|
181
|
+
print("Compiling Fortran library for pychnosz")
|
|
182
|
+
print("=" * 60)
|
|
183
|
+
print(f"Platform: {sys.platform}")
|
|
184
|
+
print(f"Python: {sys.version.split()[0]}")
|
|
185
|
+
|
|
186
|
+
try:
|
|
187
|
+
compile_fortran()
|
|
188
|
+
print("=" * 60)
|
|
189
|
+
print("Compilation successful!")
|
|
190
|
+
print("=" * 60)
|
|
191
|
+
return 0
|
|
192
|
+
except Exception as e:
|
|
193
|
+
print("=" * 60, file=sys.stderr)
|
|
194
|
+
print(f"ERROR: {e}", file=sys.stderr)
|
|
195
|
+
print("=" * 60, file=sys.stderr)
|
|
196
|
+
return 1
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
if __name__ == "__main__":
|
|
200
|
+
sys.exit(main())
|