clease
Advanced tools
| .. _basis_function_api: | ||
| Basis Functions | ||
| =============== | ||
| Each cluster is defined on a set of cluster functions, which is expanded on a set of single-site basis functions. | ||
| The basis function obeys the orthogonality condition | ||
| .. math:: \frac{1}{M} \sum _{s_i=-m}^m \Theta _n (s_i) \Theta_{n'}(s_i) = \delta _{nn'} | ||
| For more information, please see the `CLEASE paper <https://doi.org/10.1088/1361-648X/ab1bbc>`_. | ||
| CLEASE implements three different basis functions: | ||
| :class:`~clease.basis_function.Polynomial`, | ||
| :class:`~clease.basis_function.Trigonometric` and | ||
| :class:`~clease.basis_function.BinaryLinear`. | ||
| .. autoclass:: clease.basis_function.Polynomial | ||
| :members: | ||
| .. autoclass:: clease.basis_function.Trigonometric | ||
| :members: | ||
| .. autoclass:: clease.basis_function.BinaryLinear | ||
| :members: | ||
| All three basis functions inherit from the same base abstract base interface: | ||
| .. autoclass:: clease.basis_function.BasisFunction | ||
| :members: |
| Metadata-Version: 2.1 | ||
| Name: clease | ||
| Version: 1.0.0 | ||
| Version: 1.0.1 | ||
| Summary: CLuster Expansion in Atomistic Simulation Environment | ||
@@ -5,0 +5,0 @@ Home-page: https://gitlab.com/computationalmaterials/clease/ |
@@ -16,21 +16,21 @@ ase<3.23,>=3.20 | ||
| [all] | ||
| clease-gui | ||
| clang-format>=14.0.3 | ||
| pre-commit | ||
| ipython | ||
| pytest | ||
| pyclean>=2.0.0 | ||
| pytest-mock | ||
| pytest-benchmark[histogram]>=3.4.1 | ||
| pylint | ||
| pip | ||
| black>=22.1.0 | ||
| sphinx | ||
| pre-commit | ||
| cython | ||
| tox>=3.24.0 | ||
| pip | ||
| twine | ||
| mock | ||
| sphinx_rtd_theme | ||
| build | ||
| pytest-benchmark[histogram]>=3.4.1 | ||
| clang-format>=14.0.3 | ||
| pytest-cov | ||
| tox>=3.24.0 | ||
| cython | ||
| pytest | ||
| pytest-mock | ||
| mock | ||
| sphinx | ||
| clease-gui | ||
@@ -37,0 +37,0 @@ [dev] |
@@ -180,2 +180,3 @@ LICENSE.md | ||
| doc/source/releasenotes.rst | ||
| doc/source/api/basis_function.rst | ||
| doc/source/api/corr_func.rst | ||
@@ -182,0 +183,0 @@ doc/source/api/data_getters.rst |
@@ -1,1 +0,1 @@ | ||
| 1.0.0 | ||
| 1.0.1 |
@@ -53,2 +53,3 @@ """Module for setting up pseudospins and basis functions.""" | ||
| def basis_functions(self) -> List[Dict[str, float]]: | ||
| """Property access to :meth:`get_basis_functions`.""" | ||
| return self.get_basis_functions() | ||
@@ -62,3 +63,3 @@ | ||
| def get_basis_functions(self): | ||
| """Get basis function.""" | ||
| """Create basis functions which guarantees the orthonormality condition.""" | ||
@@ -157,3 +158,5 @@ # pylint: disable=no-self-use | ||
| class BinaryLinear(BasisFunction): | ||
| """Pseudospin and basis function from Zhang and Sluiter. | ||
| """Pseudospin and basis function from Zhang and Sluiter. The ``redunant_element`` | ||
| parameter can be used to select which element is not explicitly defined by the ECI values. | ||
| If it is not set, the element will be chosen as the first element in alphabetical order. | ||
@@ -160,0 +163,0 @@ Zhang, X. and Sluiter M. |
@@ -96,3 +96,4 @@ from itertools import product | ||
| assert len(sublattices) == len(ints) | ||
| return [FourVector(*vals, subl) for vals, subl in zip(ints, sublattices)] | ||
| # Iterating the array as a list is more efficient than iterating the numpy array. | ||
| return [FourVector(*vals, subl) for vals, subl in zip(ints.tolist(), sublattices)] | ||
@@ -99,0 +100,0 @@ def to_four_vector(self, cartesian: np.ndarray, sublattice: int = None) -> FourVector: |
| from typing import Union, Sequence, Callable, List | ||
| from tkinter import TclError | ||
| import numpy as np | ||
| from ase.db import connect | ||
@@ -120,2 +121,3 @@ from ase.gui.gui import GUI | ||
| ax_obj = self.annotated_axes[event_index] | ||
| ax = ax_obj.ax | ||
| lines = ax_obj.lines | ||
@@ -125,3 +127,24 @@ line = lines[self.active_line_index] | ||
| self.active_annot = self.all_annotations[event_index] | ||
| self.active_annot.xy = (x[ind["ind"][0]], y[ind["ind"][0]]) | ||
| xy = x[ind["ind"][0]], y[ind["ind"][0]] | ||
| self.active_annot.xy = xy | ||
| # Adjust the xytext coordinates away from the figure edges. | ||
| # Calculate a vector towards the center of the plot | ||
| xlim = ax.get_xlim() | ||
| ylim = ax.get_ylim() | ||
| center = np.array([sum(xlim), sum(ylim)]) / 2 | ||
| delta = center - xy | ||
| # Set the values depending on the sign of the difference vector. | ||
| # vector has constant length, of direction towards the center of the plot. | ||
| # (i.e. away from the edges) | ||
| # Values chosen by eye, but are scale-independent. | ||
| sgn = np.sign(delta) | ||
| xnew = 20 if sgn[0] >= 0 else -100 | ||
| ynew = 20 if sgn[1] >= 0 else -80 | ||
| self.active_annot.set_x(xnew) | ||
| self.active_annot.set_y(ynew) | ||
| anot = ax_obj.annotations[self.active_line_index] | ||
@@ -147,2 +170,3 @@ text = anot[ind["ind"][0]] | ||
| self.active_annot.set_visible(True) | ||
| self.fig.canvas.draw_idle() | ||
@@ -149,0 +173,0 @@ else: |
@@ -164,3 +164,3 @@ """Monte Carlo method for ase.""" | ||
| def run(self, steps: int = 100) -> None: | ||
| def run(self, steps: int = 100, call_observers: bool = True) -> None: | ||
| """Run Monte Carlo simulation. | ||
@@ -172,6 +172,10 @@ | ||
| Number of steps in the MC simulation | ||
| call_observers: bool | ||
| Should the observers be called during this run? Can be turned off for running burn-ins. | ||
| The energy averagers will still be updated, even if this flag is disabled. | ||
| Defaults to True. | ||
| """ | ||
| # Construct the iterator, make the preparations for starting the run | ||
| mc_iter = self.irun(steps) | ||
| mc_iter = self.irun(steps, call_observers=call_observers) | ||
@@ -195,3 +199,3 @@ start = time.perf_counter() | ||
| def irun(self, steps: int) -> Iterator[MCStep]: | ||
| def irun(self, steps: int, call_observers: bool = True) -> Iterator[MCStep]: | ||
| """Run Monte Carlo simulation as an iterator. | ||
@@ -213,2 +217,6 @@ Can be used to inspect the MC after each step, for example, | ||
| Number of steps in the MC simulation | ||
| call_observers: bool | ||
| Should the observers be called during this run? Can be turned off for running burn-ins. | ||
| The energy averagers will still be updated, even if this flag is disabled. | ||
| Defaults to True. | ||
| """ | ||
@@ -224,9 +232,9 @@ logger.info("Starting MC run with %d steps.", steps) | ||
| # Now we create the iterator | ||
| return self._irun(steps) | ||
| return self._irun(steps, call_observers=call_observers) | ||
| def _irun(self, steps: int) -> Iterator[MCStep]: | ||
| def _irun(self, steps: int, call_observers: bool = True) -> Iterator[MCStep]: | ||
| """Create the MC iterator""" | ||
| # Offset range by 1, so that we start with current step = 1 | ||
| for _ in range(steps): | ||
| step = self._mc_step() | ||
| step = self._mc_step(call_observers=call_observers) | ||
@@ -368,3 +376,3 @@ en = step.energy | ||
| def _mc_step(self) -> MCStep: | ||
| def _mc_step(self, call_observers: bool = True) -> MCStep: | ||
| """Make one Monte Carlo step by swithing two atoms.""" | ||
@@ -382,4 +390,5 @@ self.current_step += 1 | ||
| step = MCStep(self.current_step, self.current_energy, move_accepted, system_changes) | ||
| # Execute all observers | ||
| self.execute_observers(step) | ||
| if call_observers: | ||
| # Execute all observers | ||
| self.execute_observers(step) | ||
@@ -386,0 +395,0 @@ return step |
@@ -140,6 +140,6 @@ from typing import Sequence, Dict | ||
| def run(self, steps: int = 10, chem_pot: Dict[str, float] = None): | ||
| def run(self, steps: int = 10, call_observers: bool = True, chem_pot: Dict[str, float] = None): | ||
| """ | ||
| Run Monte Carlo simulation. | ||
| See :py:meth:`cemc.mcmc.Montecarlo.runMC` | ||
| See :py:meth:`~clease.montecarlo.montecarlo.Montecarlo.run` | ||
@@ -163,3 +163,3 @@ Parameters: | ||
| super().run(steps=steps) | ||
| super().run(steps=steps, call_observers=call_observers) | ||
@@ -166,0 +166,0 @@ def singlet2composition(self, avg_singlets: Dict[str, float]): |
@@ -30,4 +30,4 @@ from typing import List, Tuple | ||
| Y = evaluate.get_energy_predict() | ||
| xlabel = plot_args.get("xlabel", "E_DFT (eV/atom)") | ||
| ylabel = plot_args.get("ylabel", "E_CE (eV/atom)") | ||
| xlabel = plot_args.get("xlabel", r"E$_{DFT}$ (eV/atom)") | ||
| ylabel = plot_args.get("ylabel", r"E$_{CE}$ (eV/atom)") | ||
| title = plot_args.get("title", f"Fit using {len(evaluate.e_dft)} data points.") | ||
@@ -152,3 +152,7 @@ | ||
| def plot_eci(evaluate: Evaluate, plot_args: dict = None) -> Figure: | ||
| def plot_eci( | ||
| evaluate: Evaluate, | ||
| plot_args: dict = None, | ||
| ignore_sizes=(), | ||
| ) -> Figure: | ||
| """ | ||
@@ -167,2 +171,6 @@ Figure object of ECI value according to cluster diameter | ||
| - "sizes": list of int to include n-body cluster in plot | ||
| :param ignore_sizes: list of ints | ||
| Sizes listed in this list will not be plotted. | ||
| E.g. ``ignore_sizes=[0]`` will exclude the 0-body cluster. | ||
| Default is to not ignore any clusters. | ||
@@ -175,3 +183,3 @@ :return: Figure instance of plot | ||
| eci_by_size = evaluate.get_eci_by_size() | ||
| xlabel = plot_args.get("xlabel", "Cluster diameter ($n^{th}$ nearest neighbor)") | ||
| xlabel = plot_args.get("xlabel", r"Cluster diameter ($n^{th}$ nearest neighbor)") | ||
| ylabel = plot_args.get("ylabel", "ECI (eV/atom)") | ||
@@ -193,2 +201,4 @@ title = plot_args.get("title", "Plot ECI") | ||
| for size in sizes: | ||
| if ignore_sizes and size in ignore_sizes: | ||
| continue | ||
| data = eci_by_size[size] | ||
@@ -195,0 +205,0 @@ # Add 1, as NN starts from 1 and not 0 |
@@ -104,4 +104,2 @@ """Definition of ClusterExpansionSettings Class. | ||
| ) -> None: | ||
| # pylint: disable=too-many-arguments | ||
| self._include_background_atoms = include_background_atoms | ||
@@ -140,3 +138,3 @@ self._cluster_mng = None | ||
| self.max_cluster_dia = np.array(max_cluster_dia) | ||
| self.max_cluster_dia = max_cluster_dia | ||
@@ -171,2 +169,16 @@ self.basis_func_type = basis_func_type | ||
| @property | ||
| def max_cluster_dia(self) -> np.ndarray: | ||
| """The maximum cluster diameter, expressed in a NumPy | ||
| array starting from 2-body clusters at index 0. | ||
| Diameters are given in units of Ångstrom. | ||
| """ | ||
| return self._max_cluster_dia | ||
| @max_cluster_dia.setter | ||
| def max_cluster_dia(self, value) -> None: | ||
| # Ensure it's NumPy array, and make a copy. | ||
| self._max_cluster_dia = np.array(value, dtype=float) | ||
| self.clear_cache() | ||
| @property | ||
| def db_name(self) -> str: | ||
@@ -173,0 +185,0 @@ """Name of the underlaying data base.""" |
@@ -7,2 +7,3 @@ API Documentation | ||
| ./api/newstruct | ||
| ./api/basis_function | ||
| ./api/corr_func | ||
@@ -9,0 +10,0 @@ ./api/evaluate |
| Fitting Schemes | ||
| ================ | ||
| .. _fitting_api: | ||
@@ -16,2 +17,5 @@ .. autoclass:: clease.regression.LinearRegression | ||
| .. autoclass:: clease.regression.physical_ridge.PhysicalRidge | ||
| :members: | ||
| .. autoclass:: clease.regression.bayesian_compressive_sensing.BayesianCompressiveSensing | ||
@@ -18,0 +22,0 @@ :members: |
@@ -0,1 +1,3 @@ | ||
| .. _mc_constraints: | ||
| Monte Carlo Constraints | ||
@@ -2,0 +4,0 @@ ======================== |
@@ -0,1 +1,3 @@ | ||
| .. _mc_observers: | ||
| Monte Carlo Observers | ||
@@ -2,0 +4,0 @@ ====================== |
@@ -0,1 +1,3 @@ | ||
| .. _mc_api: | ||
| ============ | ||
@@ -8,5 +10,4 @@ Monte Carlo | ||
| The Monte Carlo class | ||
| ===================== | ||
| Canonical MC | ||
| ============= | ||
| The canonical Monte Carlo class has the following API: | ||
@@ -17,5 +18,15 @@ | ||
| Semi-grand canonical MC | ||
| ======================== | ||
| The semi-grand canonical (SGC) Monte Carlo class: | ||
| Additionally, the montecarlo class inherits from the | ||
| :class:`~clease.montecarlo.base.BaseMC` class, | ||
| .. autoclass:: clease.montecarlo.sgc_montecarlo.SGCMonteCarlo | ||
| :members: | ||
| Related Objects | ||
| =============== | ||
| All MC classes inherit from the | ||
| :class:`~clease.montecarlo.base.BaseMC` interface, | ||
| which adds the following methods: | ||
@@ -32,6 +43,2 @@ | ||
| Related Objects | ||
| --------------- | ||
| Below are some related objects, which may be useful in your Monte Carlo endeavours. | ||
@@ -38,0 +45,0 @@ |
@@ -0,1 +1,3 @@ | ||
| .. _structgen_api: | ||
| Structure Generation | ||
@@ -2,0 +4,0 @@ ===================== |
@@ -0,1 +1,3 @@ | ||
| .. _plot_post_process: | ||
| Post Process Plotting | ||
@@ -2,0 +4,0 @@ ===================== |
+45
-37
@@ -11,15 +11,55 @@ .. CLEASE documentation master file, created by | ||
| Cluster expansion (CE) is a widely used method for studying thermondynamic | ||
| properties of disordered materials. CLEASE offers: | ||
| properties of disordered materials. CLEASE is a cluster expansion code which strives | ||
| to be highly flexible and customizable, which also offering a wide range of useful tools, | ||
| such as: | ||
| * Tools to construct a CE model | ||
| * Semi-automatic generation of training set | ||
| * Semi-automatic :ref:`structure generation <structgen_api>` for constructing training data, | ||
| such as random, ground-state and probe structures. | ||
| * Database to store calculation results | ||
| * Database for storing calculation results. | ||
| * Various fitting methods to evaluate the CE model. | ||
| * Multiple basis functions for the CE model to choose from: | ||
| :class:`~clease.basis_function.Polynomial`, | ||
| :class:`~clease.basis_function.Trigonometric` or | ||
| :class:`~clease.basis_function.BinaryLinear`. | ||
| * Many methods for parameterization :ref:`fitting <fitting_api>` and | ||
| evaluating the CE model, such as :class:`~clease.regression.regression.Lasso` | ||
| :class:`~clease.regression.regression.Tikhonov`, :class:`~clease.regression.physical_ridge.PhysicalRidge` | ||
| and :class:`~clease.regression.ga_fit.GAFit`. | ||
| * Tools for :ref:`easily visualizing <plot_post_process>` the accuracy | ||
| of your CE model, and interact with the plots e.g. when made in a Jupyter | ||
| notebook. | ||
| * Various flavors of Monte Carlo samplers where one can explore a large | ||
| configurational space in a relatively large simulastion cell. | ||
| configurational space in a large simulation cell | ||
| * Canonical and semi-grand canonical :ref:`Monte Carlo schemes <mc_api>`. | ||
| * Flexible customization options for restricting the model during MC runs. | ||
| CLEASE provides a :ref:`number of constraints <mc_constraints>`, | ||
| but it is also easy to :ref:`implement custom constraints <implementing your own constraints>`. | ||
| * Use one our :ref:`pre-made observers <mc_observers>` to collect thermondynamic | ||
| data about your system during an MC run, or | ||
| :ref:`write your own <implementing your own observer>`. | ||
| and much more. A tutorial of how to use CLEASE can be found in our :ref:`AuCu example <ce_aucu_tutorial>`. | ||
| GUI | ||
| --- | ||
| .. _clease-gui: | ||
| Most of the standard CE routines can be performed using the graphical user | ||
| interface (GUI). The `CLEASE GUI <https://clease-gui.readthedocs.io>`_ | ||
| is an app based on the jupyter notebook. | ||
| Please remember to `report any issues <https://gitlab.com/computationalmaterials/clease-gui/-/issues>`_ | ||
| to the developers. | ||
| Installation | ||
@@ -50,15 +90,2 @@ ------------ | ||
| GUI | ||
| --- | ||
| Most of the standard CE routines can be performed using the graphical user | ||
| interface (GUI). The `CLEASE GUI <https://clease-gui.readthedocs.io>`_ | ||
| is an app based on the jupyter notebook. | ||
| .. note:: | ||
| The GUI is still under early development, so please don't forget to | ||
| `report any issues <https://gitlab.com/computationalmaterials/clease-gui/-/issues>`_ | ||
| if you use the GUI. | ||
| Using CLEASE | ||
@@ -77,5 +104,2 @@ ------------- | ||
| The use of CLEASE is best learned through tutorials: | ||
| .. toctree:: | ||
@@ -95,17 +119,1 @@ :maxdepth: 1 | ||
| acknowledgements | ||
| .. Indices and tables | ||
| .. ================== | ||
| .. * :ref:`genindex` | ||
| .. * :ref:`modindex` | ||
| .. * :ref:`search` | ||
| .. The use of CLEASE is best learned through tutorials: | ||
| .. .. toctree:: | ||
| .. :maxdepth: 2 | ||
| .. A simple tutorial explaining how to set up a database and perform a set of | ||
| .. calculations for Cu-Au alloy can be found here: :ref:`ce_aucu_tutorial` |
@@ -119,2 +119,4 @@ Monte Carlo Sampling | ||
| ------------------------------ | ||
| .. _implementing your own observer: | ||
| You can implement your own observer and monitor whatever quantity | ||
@@ -188,2 +190,4 @@ you might be interested in. To to so you can create your own class that | ||
| ================================== | ||
| .. _implementing your own constraints: | ||
| If you want to have custom constraints on MC moves, CLEASE | ||
@@ -190,0 +194,0 @@ lets you implement your own. The idea is to create a class |
@@ -7,2 +7,10 @@ .. _releasenotes: | ||
| 1.0.1 | ||
| ====== | ||
| * Added the ``ignore_sizes`` keyword to :py:func:`~clease.plot_post_process.plot_eci` | ||
| * Changing the maximum cluster diameter will now clear any cached clusters, and | ||
| requires a new build. | ||
| * Calling observers in canonical MC can now be disabled with the ``call_observers`` keyword | ||
| for performing burn-in, without executing observers. | ||
| 1.0.0 | ||
@@ -9,0 +17,0 @@ ====== |
+1
-1
| Metadata-Version: 2.1 | ||
| Name: clease | ||
| Version: 1.0.0 | ||
| Version: 1.0.1 | ||
| Summary: CLuster Expansion in Atomistic Simulation Environment | ||
@@ -5,0 +5,0 @@ Home-page: https://gitlab.com/computationalmaterials/clease/ |
Sorry, the diff of this file is too big to display
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
1593197
0.35%198
0.51%16679
0.31%