Skip to content

Commit

Permalink
Few tweaks to roy example and re-trigger RTD build (#27)
Browse files Browse the repository at this point in the history
* Few tweaks to roy example and re-trigger RTD build
* Modified environment to pick chemiscope from gh
  • Loading branch information
ceriottm authored Oct 20, 2023
1 parent 598dd30 commit 51b048c
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 49 deletions.
5 changes: 2 additions & 3 deletions examples/roy_gch/environement.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
name: lode_linear
name: roy_gch
dependencies:
- python=3.11
- pip
- pip:
- ase
- chemiscope
- chemiscope @ git+https://github.com/lab-cosmo/chemiscope
- skmatter
- metatensor
- equisolve @ git+https://github.com/lab-cosmo/equisolve.git@63c9c54046507b27f115efb1d9b9fa8a1573c4da
- rascaline @ git+https://github.com/Luthaf/rascaline@581d0ca4dece424b4594c8c3cac40a7381e13ae5
126 changes: 80 additions & 46 deletions examples/roy_gch/roy_gch.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
conventional density-energy convex hull with a Generalized Convex Hull
(GCH) analysis (see `Anelli et al., Phys. Rev. Materials
(2018) <https://doi.org/10.1103/PhysRevMaterials.2.103804>`__).
It uses features computed with `rascaline <https://github.com/lab-cosmo/rascaline>`
It uses features computed with `rascaline <https://github.com/lab-cosmo/rascaline>`__
and uses the directional convex hull function from
`scikit-matter <https://github.com/lab-cosmo/scikit-matter>`
`scikit-matter <https://github.com/lab-cosmo/scikit-matter>`__
to make the figure.
"""

import chemiscope
import matplotlib.tri
import numpy as np
Expand Down Expand Up @@ -92,27 +93,33 @@
# requires having the ``chemiscope`` package installed.
#

if chemiscope.jupyter._is_running_in_notebook():
chemiscope.show(
structures,
dict(
energy=energy,
density=density,
hull_energy=dch_dist,
structure_type=structype,
),
settings={
"map": {
"x": {"property": "density"},
"y": {"property": "energy"},
"color": {"property": "hull_energy"},
"symbol": "structure_type",
"size": {"factor": 35},
},
"structure": [{"unitCell": True, "supercell": {"0": 2, "1": 2, "2": 2}}],
cs = chemiscope.show(
structures,
dict(
energy=energy,
density=density,
hull_energy=dch_dist,
structure_type=structype,
),
settings={
"map": {
"x": {"property": "density"},
"y": {"property": "energy"},
"color": {"property": "hull_energy"},
"symbol": "structure_type",
"size": {"factor": 35},
},
)
"structure": [{"unitCell": True, "supercell": {"0": 2, "1": 2, "2": 2}}],
},
)


if chemiscope.jupyter._is_running_in_notebook():
from IPython.display import display

display(cs)
else:
cs.save("roy_ch.json.gz")

# %%
# Generalized Convex Hull
Expand Down Expand Up @@ -229,30 +236,57 @@
structure_properties.update({"per_atom_energy": energy, "hull_energy": dch_dist})

# shows chemiscope if not run in terminal
if chemiscope.jupyter._is_running_in_notebook():
chemiscope.show(
frames=structures,
properties=structure_properties,
settings={
"map": {
"x": {"property": "pca_1"},
"y": {"property": "pca_2"},
"z": {"property": "energy"},
"symbol": "type",
"color": {"property": "hull_energy"},
"size": {
"factor": 35,
"mode": "linear",
"property": "",
"reverse": True,
},

cs = chemiscope.show(
frames=structures,
properties=structure_properties,
meta={
"name": "GCH for ROY polymorphs",
"description": """
Demonstration of the Generalized Convex Hull construction for
polymorphs of the ROY molecule. Molecules that are closest to
the hull built on PCA-based structural descriptors and having the
internal energy predicted by electronic-structure calculations as
the z axis are the most thermodynamically stable. Indeed most of the
known polymorphs of ROY are on (or very close) to this hull.
""",
"authors": ["Michele Ceriotti <[email protected]>"],
"references": [
'A. Anelli, E. A. Engel, C. J. Pickard, and M. Ceriotti, \
"Generalized convex hull construction for materials discovery," \
Physical Review Materials 2(10), 103804 (2018).',
'G. J. O. Beran, I. J. Sugden, C. Greenwell, D. H. Bowskill, \
C. C. Pantelides, and C. S. Adjiman, "How many more polymorphs of \
ROY remain undiscovered," Chem. Sci. 13(5), 1288–1297 (2022).',
],
},
settings={
"map": {
"x": {"property": "pca_1"},
"y": {"property": "pca_2"},
"z": {"property": "energy"},
"symbol": "type",
"color": {"property": "hull_energy"},
"size": {
"factor": 35,
"mode": "linear",
"property": "",
"reverse": True,
},
"structure": [
{
"bonds": True,
"unitCell": True,
"keepOrientation": True,
}
],
},
)
"structure": [
{
"bonds": True,
"unitCell": True,
"keepOrientation": True,
}
],
},
)

if chemiscope.jupyter._is_running_in_notebook():
from IPython.display import display

display(cs)
else:
cs.save("roy_gch.json.gz")

0 comments on commit 51b048c

Please sign in to comment.