This repository presents the math and code required to construct the thermodynamic phase diagram for a ternary alloy system containing two or three phases.
A ternary phase diagram, for example.
A Makefile is provided to build both the documentation and a shared library required to efficiently crunch the numbers. The derivation is written in LaTeX, while the implementation is in Python.
- To use the Makefile, you will need make.
- To build the derivation, you will need a LaTeX distribution.
- To build the shared library, you will need a scientific Python distribution
(e.g., Anaconda,
Canopy,
Python(x,y)) and
SymPy, which is available from
GitHub or
PyPI (
pip install sympy
).
With these dependencies met, you can regenerate the example phase diagram with
$ make
This triggers a three-stage process:
- Evaluate free-energies.py to write three paraboloid
free energies (one per phase) to C expressions:
$ python free-energies.py
- Compile the C expressions to a shared library:
$ gcc -Wall -fPIC -shared paraboloids.c -o paraboloids.so
- Execute phase-diagram.py to draw the pretty picture:
$ python phase-diagram.py
To rebuild the documentation, simply
$ make docs
To make this code your own, edit free-energies.py and refine
(or redefine) the three pure-phase free energy expressions: GA
, GB
, and
GC
. Perhaps start with increasing curvatures, or change skew
to change the
amount of "squish" along the
$ make
If things aren't making sense, it might make sense to visualize your free energy landscape. The utility file ternary-landscape.py will convert your free energy landscape to a grayscale contour plot. Run
$ python ternary-landscape.py