From 51b048c91d42e50511da51ef0fec8583a813c53e Mon Sep 17 00:00:00 2001 From: Michele Ceriotti Date: Fri, 20 Oct 2023 14:04:23 -0700 Subject: [PATCH] Few tweaks to roy example and re-trigger RTD build (#27) * Few tweaks to roy example and re-trigger RTD build * Modified environment to pick chemiscope from gh --- examples/roy_gch/environement.yml | 5 +- examples/roy_gch/roy_gch.py | 126 +++++++++++++++++++----------- 2 files changed, 82 insertions(+), 49 deletions(-) diff --git a/examples/roy_gch/environement.yml b/examples/roy_gch/environement.yml index 29ea918b..4e0f54ed 100644 --- a/examples/roy_gch/environement.yml +++ b/examples/roy_gch/environement.yml @@ -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 diff --git a/examples/roy_gch/roy_gch.py b/examples/roy_gch/roy_gch.py index d4c4eeb2..5b59ae97 100644 --- a/examples/roy_gch/roy_gch.py +++ b/examples/roy_gch/roy_gch.py @@ -8,11 +8,12 @@ conventional density-energy convex hull with a Generalized Convex Hull (GCH) analysis (see `Anelli et al., Phys. Rev. Materials (2018) `__). -It uses features computed with `rascaline ` +It uses features computed with `rascaline `__ and uses the directional convex hull function from -`scikit-matter ` +`scikit-matter `__ to make the figure. """ + import chemiscope import matplotlib.tri import numpy as np @@ -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 @@ -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 "], + "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")