Skip to content

Commit c1f393d

Browse files
authored
Miscellaneous clean-ups of several examples (#74)
1 parent 9041f2e commit c1f393d

File tree

8 files changed

+37
-17
lines changed

8 files changed

+37
-17
lines changed

examples/gaas-map/gaas-map.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""
1+
r"""
22
PCA/PCovR Visualization for the rattled GaAs training dataset
33
=============================================================
44
@@ -12,6 +12,10 @@
1212
description of the dataset, that is then visualized using
1313
``chemiscope``.
1414
15+
This example uses the dataset from
16+
`Imbalzano (2021) <http://doi.org/10.1103/PhysRevMaterials.5.063804>`_
17+
and the principal covariate regression scheme as implemented in
18+
`Helfrecht (2020) <http://doi.org/10.1088/2632-2153/aba9ef>`_.
1519
"""
1620

1721
import os

examples/pi-metad/pi-metad.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,14 @@
4949
# Metadynamics for the Zundel cation
5050
# ----------------------------------
5151
#
52-
# Metadynamics is a metnod to accelerate sampling of rare events - microscopic processes
52+
# Metadynamics is a method to accelerate sampling of rare events - microscopic processes
5353
# that are too infrequent to be observed over the time scale (ns-µs) accessible to
5454
# molecular dynamics simulations. You can read one of the many excellent reviews
5555
# on metadynamics (see e.g.
56-
# `Bussi and Branduardi (2015) <https://doi.org/10.1002/9781118889886.ch1>`_).
56+
# `Bussi and Branduardi (2015) <https://doi.org/10.1002/9781118889886.ch1>`_),
57+
# or follow a
58+
# `lecture from the PLUMED masterclass
59+
# <https://www.plumed-tutorials.org/lessons/21/004/data/NAVIGATION.html>`_.
5760
# In short, during a metadynamics simulation an adaptive biasing potential is
5861
# built as a superimposition of Gaussians centered over configurations that have
5962
# been previously visited by the trajectory. This discourages the system from remaining
@@ -233,6 +236,7 @@
233236
# If you run this in a notebook, you can go ahead and start loading
234237
# output files *before* i-PI has finished running by skipping this cell
235238

239+
# wait for simulations to finish
236240
if ipi_process is not None:
237241
ipi_process.wait()
238242
for process in driver_process:
@@ -495,8 +499,8 @@ def moving_average(arr, window_size):
495499
# is important to distinguish between the free-energy computed
496500
# as the logarithm of the probability of observing a given
497501
# configuration (that depends on the distribution of the
498-
# replicas) and the free-energy taken as a mean to estimate
499-
# and reaction rates :math:`k` in a transition-state theory
502+
# replicas) and the free-energy taken as a tool to estimate
503+
# reaction rates :math:`k` in a transition-state theory
500504
# fashion :math:`k\propto e^{-\Delta E^\ddagger/kT}`,
501505
# where the energy barrier :math:`\Delta E^\ddagger`
502506
# is better estimated from the distribution of the centroid.
@@ -519,7 +523,7 @@ def moving_average(arr, window_size):
519523
#
520524
# The other changes are purely cosmetic, and the calculation
521525
# can be launched very easily, using several drivers to parallelize
522-
# the calculation over the beads (although this kind of calculations
526+
# the energy evaluation over the beads (although this kind of calculations
523527
# is not limited by the evaluation of the forces).
524528

525529
# don't rerun if the outputs already exist
@@ -539,7 +543,7 @@ def moving_average(arr, window_size):
539543
# If you run this in a notebook, you can go ahead and start loading
540544
# output files _before_ i-PI has finished running by skipping this cell
541545

542-
# don't rerun if the outputs already exist
546+
# wait for simulations to finish
543547
if ipi_process is not None:
544548
ipi_process.wait()
545549
for process in driver_process:
1.55 KB
Binary file not shown.

examples/roy-gch/roy-gch.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
and uses the directional convex hull function from
1414
`scikit-matter <https://github.com/lab-cosmo/scikit-matter>`__
1515
to make the figure.
16+
17+
The GCH construction aims at determining structures, among a collection of
18+
candidate configurations, that are stable or have the potential of being stabilized
19+
by appropriate thermodynamic boundary conditions (pressure, doping, external fields,
20+
...). It does so by using microscopic descriptors to determine the diversity of
21+
structures, and assumes that configurations that are stable relative to other
22+
configurations with similar descriptors are those that could be made
23+
"locally" stable by suitable synthesis conditions.
1624
"""
1725

1826
import chemiscope
@@ -45,7 +53,11 @@
4553
# -------------------
4654
#
4755
# The Directional Convex Hull routines can be used to compute a
48-
# conventional density-energy hull
56+
# conventional density-energy hull (see
57+
# `Hautier (2014)
58+
# <http://doi.org/10.1007/128_2013_486>`_ for a pedagogic
59+
# introduction to the convex hull construction in the context
60+
# of atomistic simulations).
4961

5062
dch_builder = DirectionalConvexHull(low_dim_idx=[0])
5163
dch_builder.fit(density.reshape(-1, 1), energy)

noxfile.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
ROOT = os.path.realpath(os.path.dirname(__file__))
1313

1414
sys.path.insert(0, ROOT)
15-
from developer.get_examples import get_examples # noqa: E402
15+
from src.get_examples import get_examples # noqa: E402
1616

1717

1818
# global nox options
@@ -31,11 +31,11 @@
3131
# Files that need to be linted & formatted
3232
def get_lint_files():
3333
LINT_FILES = [
34-
"ipynb-to-gallery.py",
35-
"generate-gallery.py",
34+
"src/ipynb-to-gallery.py",
35+
"src/generate-gallery.py",
3636
"noxfile.py",
3737
"docs/src/conf.py",
38-
"developer/get_examples.py",
38+
"src/get_examples.py",
3939
]
4040
return LINT_FILES + get_example_files()
4141

@@ -159,7 +159,7 @@ def example(session, name=name):
159159
f"examples/{name}/data", "zip", f"examples/{name}/", "data/"
160160
)
161161

162-
session.run("python", "generate-gallery.py", f"examples/{name}")
162+
session.run("python", "src/generate-gallery.py", f"examples/{name}")
163163

164164
os.unlink(f"docs/src/examples/{name}/index.rst")
165165

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from chemiscope.sphinx import ChemiscopeScraper
88

99

10-
HERE = os.path.realpath(os.path.dirname(__file__))
10+
ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "../"))
1111

1212

1313
class AttrDict(dict):
@@ -24,7 +24,7 @@ class PseudoSphinxApp:
2424

2525
def __init__(self, example):
2626
gallery_dir = os.path.join(
27-
HERE, "docs", "src", "examples", os.path.basename(example)
27+
ROOT, "docs", "src", "examples", os.path.basename(example)
2828
)
2929
if os.path.exists(gallery_dir):
3030
shutil.rmtree(gallery_dir)
@@ -38,7 +38,7 @@ def __init__(self, example):
3838
self.config.default_role = ""
3939
self.config.sphinx_gallery_conf = {
4040
"filename_pattern": ".*",
41-
"examples_dirs": os.path.join(HERE, example),
41+
"examples_dirs": os.path.join(ROOT, example),
4242
"gallery_dirs": gallery_dir,
4343
"min_reported_time": 60,
4444
"copyfile_regex": r".*\.(sh|xyz|cp2k|yml|png|zip)",
@@ -48,7 +48,7 @@ def __init__(self, example):
4848
}
4949

5050
self.builder = AttrDict()
51-
self.builder.srcdir = os.path.join(HERE, "docs", "src")
51+
self.builder.srcdir = os.path.join(ROOT, "docs", "src")
5252
self.builder.outdir = ""
5353
self.builder.name = os.path.basename(example)
5454

0 commit comments

Comments
 (0)