-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
82fae79
commit 4866a1e
Showing
185 changed files
with
41,791 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
|
||
|
||
**/.DS_Store | ||
|
||
# Byte-compiled / optimized / DLL files | ||
**/__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
**/*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
develop-eggs/ | ||
dist/ | ||
build/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
# sdist/ | ||
var/ | ||
# wheels/ | ||
wheelhouse/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
cover/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
.pybuilder/ | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
# For a library or package, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# .python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# poetry | ||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. | ||
# This is especially recommended for binary packages to ensure reproducibility, and is more | ||
# commonly ignored for libraries. | ||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control | ||
#poetry.lock | ||
|
||
# pdm | ||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. | ||
#pdm.lock | ||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it | ||
# in version control. | ||
# https://pdm.fming.dev/#use-with-ide | ||
.pdm.toml | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# pytype static type analyzer | ||
.pytype/ | ||
|
||
# Cython debug symbols | ||
cython_debug/ | ||
|
||
# PyCharm | ||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can | ||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore | ||
# and can be added to the global gitignore or merged into this file. For a more nuclear | ||
# option (not recommended) you can uncomment the following to ignore the entire idea folder. | ||
#.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Equilipy | ||
Equilipy is an open-source python package that offers multicomponent multiphase equilibrium calculations based on the CALPHAD (CALculation of PHAse Diagram) approach. With a set of Gibbs energy description (Thermochemical database) and input conditions (Composition, temperature, pressure), equilibrium phase configureation, amount, composition, and thermochemical properties can be obtained. Equilipy uses the Gibbs energy descriptions furnished by THERMOCHIMICA with the modified Gibbs energy minimization algorithm initially proposed by de Capitani, C. and Brown, T.H. (1987). | ||
|
||
## Dependencies | ||
|Dependency | Version | Required | Libraries | | ||
|---------- | ------- |-------- |------- | | ||
|Fortran | - | Yes | - | ||
|Python | 3.9+ | Yes | numpy, wheel, meson, ninja | ||
|
||
## Before installation | ||
Because Equilipy uses Fortran subroutines a Fortran compiler needs to be available in the local envirionment. To install GNU Fortran, following command may be used for Ubuntu and Debian, | ||
``` | ||
sudo apt-get install gfortran | ||
``` | ||
for MacOS, | ||
``` | ||
brew install gcc | ||
``` | ||
for Windows, check out [MinGW-w64](https://www.mingw-w64.org/downloads/#mingw-builds). | ||
|
||
Equilipy also requires Python version 3.9 and above. The Fortran backend needs to be compiled through the f2py module in `numpy` which requires `meson` and `ninja`. The `wheel` library is used for packaging. These can both be installed through pip: | ||
``` | ||
pip install numpy wheel meson ninja | ||
``` | ||
|
||
## Installation | ||
Here is the procedure to install Equilipy: | ||
1. Clone the repository | ||
``` | ||
git clone https://github.com/ORNL/Equilipy.git | ||
``` | ||
2. Create wheels | ||
``` | ||
python setup.py bdist_wheel --dist-dir=./wheelhouse | ||
``` | ||
Note that on macOS it may be necessary to explicitly use GNU `gcc` instead of the Apple clang `gcc`. For example, with a brew installation, export `CC` before calling `setup.py`: | ||
``` | ||
export CC=/usr/local/Cellar/gcc/*/bin/gcc-* | ||
``` | ||
3. Install from .whl file | ||
``` | ||
pip install wheelhouse/equilipy-*.whl | ||
``` | ||
|
||
## Features and example | ||
The following features are currently available. | ||
- Single condition equilibrium calculations | ||
- Batch equilibrium calculations | ||
- Scheil-Gulliver solidification | ||
- Phase selection | ||
|
||
For details, check out the example directory. | ||
Running the first example is as simple as: | ||
``` | ||
cd example/ | ||
python Example01_SingleEquilib.py | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
|
||
import numpy as np | ||
from tqdm import tqdm | ||
import equilipy.equilifort as fort | ||
from .InternalFunctions import _dict2np | ||
from .InputCondition import input_condition | ||
from .Minimize import minimize | ||
from .PostProcess import Result | ||
from .PhaseSelection import phase_selection | ||
from .ListPhases import list_phases | ||
from .Errors import * | ||
from .ReadDict import read_dict | ||
import equilipy.variables as var | ||
|
||
|
||
def equilib_batch(Database:str,Unit:list,NTP:dict,ListOfPhases:list=None): | ||
''' | ||
Calculate phase equlibria for multiple NTP conditions. | ||
---------------------------------------------------------------------------------------------------------------- | ||
Input | ||
----- | ||
Database : A string of 'Directory/databasename.dat' | ||
Unit : A list of units for temperature, pressure, mass e.g.['K','atm','moles']. | ||
Temperature units, 'K'/'C'/'F'/'R'. | ||
Pressure units, 'atm'/'psi'/'bar'/'Pa'/'kPa'. | ||
Mass units, 'mass fraction'/'kilograms'/'grams'/'pounds'/'mole fraction'/'atom fraction'/'atoms'/'moles'. | ||
NTP : Dictionary of T, P, element1, element2 ... | ||
Output | ||
------ | ||
Result: Equilipy result object that includes system properties and phase properties. | ||
System properties | ||
Result.N : Dictionary {element: Amount,...} | ||
Result.T : Temperature | ||
Result.P : Pressure | ||
Result.G : System Gibbs energy (total) | ||
Result.H : System enthalpy (total) | ||
Result.S : System entropy (total) | ||
Result.Cp : System heat capacity (total) | ||
Phase properties | ||
Result.StablePhases: Dictionary {'ID':[phase_id1,..],'Name':[phase_name1,...],'Amount':[phase_amount1,...]'} | ||
Result.Phases : Dictionary {phase_name: phase_object,...} | ||
''' | ||
# Read Database saved in a dictionary | ||
read_dict(Database) | ||
|
||
# Get info from NTP dictionary | ||
NTPheader,NTPvals=_dict2np(NTP) | ||
L,_=NTPvals.shape | ||
res = Result() | ||
|
||
|
||
try: | ||
# If this is successfull, systems are defined previously | ||
if ListOfPhases!=None: phase_selection(ListOfPhases) | ||
else: KeyError('Error: add a list of phases') | ||
except AttributeError: | ||
list_phases(Database,NTPheader[2:]) | ||
|
||
for i in tqdm(range(L),colour='#8060ff',ascii="░▒▓",bar_format="{l_bar}{bar:50}{r_bar}"): | ||
|
||
# Revise input condition when some of the elements are zero | ||
condition=NTPvals[i,:] | ||
comp=np.array(NTPvals[i,2:]) | ||
|
||
if 0 in comp: | ||
elements=np.array(NTPheader[2:]) | ||
elements=list(elements[comp!=0]) | ||
condition=list(comp[comp!=0]) | ||
condition=np.array(list(NTPvals[i,:2])+condition) | ||
|
||
list_phases(Database,elements) | ||
if ListOfPhases!=None: | ||
phase_selection(ListOfPhases) | ||
|
||
else: | ||
list_phases(Database,NTPheader[2:]) | ||
if ListOfPhases!=None: phase_selection(ListOfPhases) | ||
|
||
var.dConditionSys=condition | ||
input_condition(Unit,condition) | ||
try: | ||
minimize() | ||
res.append_output() | ||
|
||
except EquilibError: | ||
res.append_error() | ||
|
||
fort.resetthermo() | ||
fort.resetthermoparser() | ||
|
||
|
||
return res | ||
|
||
|
Oops, something went wrong.