MineralsCloud / phdg

Thermo phase diagrams with ease.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PHDG

Thermo phase diagrams with ease.
Build by Chenxing with ❤️.

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

Here we introduces three basic abstractions for our program.

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

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

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.

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

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.

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

$ pip3 install -r requirements.txt

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

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

Currently we only support YAML input file.

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

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

To be decided.

About

Thermo phase diagrams with ease.


Languages

Language:Python 100.0%