-
Notifications
You must be signed in to change notification settings - Fork 875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add formal_chempots
option to ChemicalPotentialDiagram
to plot the formal chemical potentials rather than the DFT energies
#2916
Conversation
…e formal chemical potentials rather than the DFT energies
…to all applicable tests in `test_chempot_diagram.py`
Thanks @kavanase for the clear explanation and screenshots. Very helpful! |
No problem @janosh, thanks for the speedy merge! |
…e formal chemical potentials rather than the DFT energies (materialsproject#2916) * Add `formal_chempots` option to `ChemicalPotentialDiagram` to plot the formal chemical potentials rather than the DFT energies * Add tests for `formal_chempots` option in `ChemicalPotentialDiagram` to all applicable tests in `test_chempot_diagram.py` * remove useless dict.copy() in _renormalize_entry(), fix some doc strings and typos * replace assertArrayAlmostEqual() with pytest.approx() in test_chempot_diagram.py * use dot access for plot attributes --------- Co-authored-by: Janosh Riebesell <[email protected]>
Just wanted to second, this was a great change. Thanks @kavanase! |
No problem @mkhorton! 😃 |
@kavanase The |
Ok cool! Thanks very much for the info @janosh! 🙌 |
Just pinging @tschaume and @yang-ruoxi to make sure we bump pymatgen for the next web deployment to publish this fix. |
@janosh had a browse through, looks great! 😃 The elemental forms now arise when |
Looks good to me as well. Thanks for making this change @kavanase. I should have fixed this a long time ago ;) |
Thanks for confirming the fix @kavanase @mattmcdermott. |
The
ChemicalPotentialDiagram
object for which the (very useful! 🙌)pymatgen.analysis.chempot_diagram
module is written, plots the chemical potential diagram using the absolute DFT energies, rather than the actual (formal) chemical potentials (aka. reference potentials) of the elements, which are the meaningful values that can be compared to experiment.This is essentially the difference between absolute DFT energies (which on their own are essentially meaningless and differ substantially between different functional choices, input parameter/grid settings, vdW corrections, DFT codes etc) and formation energies (i.e. energies relative to the elemental energies) which are meaningful, and far more robust with respect to input parameter choice.
Moreover, the axis labels for these plots in the output of
ChemicalPotentialDiagram.get_plot()
(which is also used on the Materials Project website for the chemical potential diagram plots) are given asμ_X - μ_X^0
, which means it should refer to the formal chemical potentials, but in fact it's the absolute DFT energies that are shown (i.e. μ_X(DFT)).This PR adds an optional parameter
formal_chempots = True
toChemicalPotentialDiagram
which renormalises the entry energies and plots the formal chemical potentials.Example changes:
The chemical potential diagram of the Y-Ti-O-S phase space on the Materials Project (using the old code):
You can see the energies of the elemental reference states are not zero as they should be (i.e. not corresponding to their
μ_X - μ_X^0
axis labels). – Might need to click into the image to see this clearly.With the updated code we get the expected/desired behaviour:
Further examples can be generated using the test data in
test_chempot_diagram.py
.I've added docstrings for these additions and also added a full set of tests to
test_chempot_diagram.py
for this option.