Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mineralscloud/phdg

Thermo phase diagrams with ease.
https://github.com/mineralscloud/phdg

phase-diagram scientific-computations thermodynamics

Last synced: about 1 month ago
JSON representation

Thermo phase diagrams with ease.

Awesome Lists containing this project

README

        

.. raw:: html

PHDG



Thermo phase diagrams with ease.


Build by Chenxing with :heart:.


.. contents:: **Table of Contents**
.. section-numbering::

Introduction
============

Background
----------

The phase relation business has always been tedious. Even we only consider two elements, they could have already form many compounds and each have a bound of polymorphs. When we are dealing with a real world phase system like that in the earth, it could be nothing but even more annoying. This package hopes to resolve this phase relation problem for scientists. After you have calculated Gibbs free energy for all the phases, this program will consider the possible combinations at each temperature-pressure point at a given grid, and help you build the phase diagrams.

Based on the Gibbs free energy calculated with quasi-harmonic approximation, this package serves the following purposes:

1. Plot the given Gibbs energy pressure temperature field for all of the phases
2. Plot fields for all the possible combinations
3. Plot phase diagrams for a given system
4. Plot energy difference at a given temperature and pressure range

Concepts
--------

Here we introduces three basic abstractions for our program.

System
^^^^^^

System is the ensemble of everything. A system comprises of several substances. Some of them could form combinations.

Combination
^^^^^^^^^^^

Combination is a combination of one or more substances. You can understand it as one side of chemical reaction equation.

Substance
^^^^^^^^^

The substance could be understood as one polymorph for one given chemical formula, it is the basic unit of processing. Substance instance holds the gibbs free energy.

Example
^^^^^^^
.. |H2O| replace:: H\ :sub:`2`\ O
.. |H2| replace:: H\ :sub:`2`
.. |O2| replace:: O\ :sub:`2`

Let’s discuss these problem with the example of the buring of hydrogen in the air. Which is the following reaction equation:

.. raw :: html

2 H2 (g) + O2 (g) = 2 H2O (l)

In this reaction, *substances* are |H2| (g), |O2| (g) and |H2O| (l). However, if you would like to work on high temperature status, you would want to add in |H2O| (g), which is water vapour, then you should be tabulating the following four:

* |H2O| (g)
* |H2O| (l)
* |H2| (g)
* |O2| (g)

Then the *combinations* should be the following three:

* 2 |H2O| (g)
* 2 |H2O| (l)
* 2 |H2| (g) + |O2| (g)

And all these are the hydrogen-oxygen *system*.

Usage
=====

Dependencies
------------

This package is build for **Python 3** (>=3.6) with minimalism in mind. It depends only on

- **Numpy**: Math library.
- **Matplotlib**: Afterall, this is a package for ploting, right? :)
- **PyYAML**: Parses configuration file.

You would be able to install these dependencies with

.. code :: bash

$ pip3 install -r requirements.txt

CLI interface
-------------

Get the input file ready, and just run the ``src/app.py`` script with Python:

.. code :: bash

$ python3 src/app.py {PATH/TO/INPUT.yaml}

Input file
----------

Currently we only support YAML input file.

Example
^^^^^^^

This is an example input file as we have discussed for the hydrogen-oxygen system:

.. code :: yaml

system:
substances:
- name: H2O (l)
type: H2O
gibbs_dir: /path/to/gibbs/for/water
- name: H2O (g)
type: H2O
gibbs_dir: /path/to/gibbs/for/water/vapour
- name: H2 (g)
type: H2
gibbs_dir: /path/to/gibbs/for/hydrogen
- name: O2 (g)
type: O2
gibbs_dir: /path/to/gibbs/for/oxygen
manifests:
- [[2, H2O (g)]]
- [[2, H2O (l)]]
- [[2, H2 (g)], [1, O2(g)]]
plots:
- type: substances
output: /output/for/substance/plot.png
args:
p_range: [0.1, 0.2]
t_range: [0, 120]
- type: combinations
output: /output/for/combination/plot.png
args:
- type: gibbs_free_energy_difference
output: /output/for/gibbs/free/energy/difference.png
- type: phase_diagram
output: /output/for/the/system.png

Licence
=======

To be decided.