Skip to content

Instantly share code, notes, and snippets.

@dwinston
Created March 22, 2016 23:28
Show Gist options
  • Save dwinston/1dc91a069f275993a0b3 to your computer and use it in GitHub Desktop.
Save dwinston/1dc91a069f275993a0b3 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from pymatgen.matproj.rest import MPRester\n",
"from pymatgen import Composition\n",
"from pymatgen.phasediagram.pdmaker import CompoundPhaseDiagram, PhaseDiagramError"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"mpr = MPRester()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"el1, el2 = 'Ca', 'Mg'\n",
"\n",
"all_entries = mpr.get_entries_in_chemsys([el1, el2, 'O', 'C'])"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"for entry in all_entries:\n",
" if entry.name == \"CO2\":\n",
" entry.correction = 1.412 # 0.353*4, as the entry is C4O8\n",
"\n",
"try:\n",
" pd = CompoundPhaseDiagram(all_entries, [Composition(c) for c in [el1, el2, \"O2\"]],\n",
" normalize_terminal_compositions=False)\n",
"except PhaseDiagramError:\n",
" print 'Error with Phase Diagram'"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"Xf-Xg-Xh phase diagram\n",
"6 stable phases: \n",
"CaO, Mg, Ca, CaMg2, O2, MgO"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pd"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.10"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment