From 4f1e4bc1e21457d1f5dee4473d0aacf2eb9aa24a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Oct 2023 19:08:04 +0000 Subject: [PATCH 01/36] Bump scikit-learn from 1.3.1 to 1.3.2 Bumps [scikit-learn](https://github.com/scikit-learn/scikit-learn) from 1.3.1 to 1.3.2. - [Release notes](https://github.com/scikit-learn/scikit-learn/releases) - [Commits](https://github.com/scikit-learn/scikit-learn/compare/1.3.1...1.3.2) --- updated-dependencies: - dependency-name: scikit-learn dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- binder/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binder/requirements.txt b/binder/requirements.txt index f21e96d7..0a65968c 100644 --- a/binder/requirements.txt +++ b/binder/requirements.txt @@ -2,6 +2,6 @@ nbgitpuller numpy>=1.20.1 monty==2023.9.25 pymatgen==2023.8.10 -scikit-learn==1.3.1 +scikit-learn==1.3.2 h5py==3.10.0 crystal_toolkit From 9629b54cbb2c43d9b5c8e5e2b2d2d61698c5d066 Mon Sep 17 00:00:00 2001 From: lbluque Date: Sat, 28 Oct 2023 00:13:48 +0000 Subject: [PATCH 02/36] auto-update pre-commit hooks --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 329ced00..e86532e7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ repos: args: ['--maxkb=600'] - repo: https://github.com/psf/black - rev: 23.9.1 + rev: 23.10.1 hooks: - id: black From 657f4c922a0d5fdfd9cccbe8b39769ccc81e7387 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 6 Nov 2023 17:51:13 +0000 Subject: [PATCH 03/36] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 23.9.1 → 23.10.1](https://github.com/psf/black/compare/23.9.1...23.10.1) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 329ced00..e86532e7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ repos: args: ['--maxkb=600'] - repo: https://github.com/psf/black - rev: 23.9.1 + rev: 23.10.1 hooks: - id: black From 850001404f08c85155a0490e5980ceb0754c364d Mon Sep 17 00:00:00 2001 From: lbluque Date: Tue, 14 Nov 2023 00:14:47 +0000 Subject: [PATCH 04/36] auto-update pre-commit hooks --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e86532e7..9a62bd3f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ repos: args: ['--maxkb=600'] - repo: https://github.com/psf/black - rev: 23.10.1 + rev: 23.11.0 hooks: - id: black From 45a8fda9e85a66baf5db5ffc4a3da623622e9e84 Mon Sep 17 00:00:00 2001 From: Ronald Kam Date: Fri, 1 Dec 2023 11:51:08 -0800 Subject: [PATCH 05/36] Update sampling efficiency Normalize by number of samples saved, not total number of MC iterations --- smol/moca/sampler/container.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/smol/moca/sampler/container.py b/smol/moca/sampler/container.py index 1603f5cb..054c8155 100644 --- a/smol/moca/sampler/container.py +++ b/smol/moca/sampler/container.py @@ -134,9 +134,12 @@ def traced_values(self): return self._trace.names def sampling_efficiency(self, discard=0, flat=True): - """Return the sampling efficiency for chains.""" + """Return the sampling efficiency for chains. If the sampling is thinned + by > 1, this value becomes only an estimate for the true sampling efficiency, + as we do not know the efficiency of the discarded samples.""" + total_accepted = self._trace.accepted[discard:].sum(axis=0) - efficiency = total_accepted / (self._total_steps - discard) + efficiency = total_accepted / (self._nsamples - discard) if flat: efficiency = efficiency.mean() return efficiency From 55c0316a0342bc1c9356ea36bab1a9d850978191 Mon Sep 17 00:00:00 2001 From: Ronald Kam Date: Fri, 1 Dec 2023 11:55:46 -0800 Subject: [PATCH 06/36] Fix docstring --- smol/moca/sampler/container.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/smol/moca/sampler/container.py b/smol/moca/sampler/container.py index 054c8155..7d940fe1 100644 --- a/smol/moca/sampler/container.py +++ b/smol/moca/sampler/container.py @@ -134,9 +134,12 @@ def traced_values(self): return self._trace.names def sampling_efficiency(self, discard=0, flat=True): - """Return the sampling efficiency for chains. If the sampling is thinned - by > 1, this value becomes only an estimate for the true sampling efficiency, - as we do not know the efficiency of the discarded samples.""" + """Return the sampling efficiency for chains. + + If the sampling is thinned by > 1, this value becomes only an estimate for the + true sampling efficiency, as we do not know the efficiency of the discarded + samples. + """ total_accepted = self._trace.accepted[discard:].sum(axis=0) efficiency = total_accepted / (self._nsamples - discard) From 2bf521bd6209f6fc72ea098d265421a025ebed2d Mon Sep 17 00:00:00 2001 From: Ronald Kam Date: Fri, 1 Dec 2023 11:58:40 -0800 Subject: [PATCH 07/36] Fix docstring again --- smol/moca/sampler/container.py | 1 - 1 file changed, 1 deletion(-) diff --git a/smol/moca/sampler/container.py b/smol/moca/sampler/container.py index 7d940fe1..2cf9b5b8 100644 --- a/smol/moca/sampler/container.py +++ b/smol/moca/sampler/container.py @@ -140,7 +140,6 @@ def sampling_efficiency(self, discard=0, flat=True): true sampling efficiency, as we do not know the efficiency of the discarded samples. """ - total_accepted = self._trace.accepted[discard:].sum(axis=0) efficiency = total_accepted / (self._nsamples - discard) if flat: From ae85393ab279e9ab5a3f7d51c956299b89374c81 Mon Sep 17 00:00:00 2001 From: Ronald Kam Date: Fri, 1 Dec 2023 13:05:51 -0800 Subject: [PATCH 08/36] Add function to check for MC convergence A relatively rudimentary check for convergence, perhaps not the most rigorous. The criteria for convergence are: 1) The last value of the property should be close to the mean of the property, +/- the spread of the property. 2) The cumulative mean of the property in the last M samples should be close to the mean of the property, +/- the spread of the property. --- smol/moca/analysis/convergence.py | 96 +++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 smol/moca/analysis/convergence.py diff --git a/smol/moca/analysis/convergence.py b/smol/moca/analysis/convergence.py new file mode 100644 index 00000000..ea814eb2 --- /dev/null +++ b/smol/moca/analysis/convergence.py @@ -0,0 +1,96 @@ +"""Tools to characterize MC convergence.""" + +__author__ = "Ronald Kam" + +from warnings import warn + +import numpy as np + + +def check_property_converged(property_array, min_std=1e-4, last_m=None, verbose=False): + """Check if a property is converged in MC run. + + A relatively rudimentary check for convergence, perhaps not the most rigorous. + The criteria for convergence are: + 1) The last value of the property should be close to the mean of the property, +/- + the spread of the property. + + 2) The cumulative mean of the property in the last M samples should be close to + the mean of the property, +/- the spread of the property. + + Args: + property_array (ndarray): + array of numerical values of a property (energy, composition, etc) + min_std (float): + minimum standard deviation of the property required to perform this + convergence test. If std dev is too small, then we can assume that there + were few acceptances and that the simulation is converged. + last_m (int): + Number of last M samples to determine the convergence of cumulative property + mean. If None, take the last 10% of samples. + + Returns: + converged (bool): + True if converged, False if not + + """ + property_array = np.array(property_array) + std_prop = np.std(property_array) + if std_prop < min_std: + # Check will never pass if the property std dev is too small, which means there + # were very few acceptances. Assume in this case that we are already close to + # the equilibrium value and that MC is converged. This is common for MC runs at + # low temperature. + + if verbose: + print( + "The std dev of the property is very small, so it can be assumed that" + "MC is converged." + ) + return True + + mean_prop = np.average(property_array) + n_samples = len(property_array) + + if last_m is None: + last_m = int(n_samples / 10) + + elif last_m > n_samples: + warn( + f"The specified number of last M samples ({last_m}) is greater than the " + f"number of samples ({n_samples})! Changing to the default value of last " + f"10% of samples ({int(n_samples / 10)})" + ) + last_m = int(n_samples / 10) + + # Check criteria 1 + converged_last_val = 0 + if ( + property_array[-1] < mean_prop + std_prop + and property_array[-1] > mean_prop - std_prop + ): + converged_last_val = True + + else: + if verbose: + print("The property last value is not close to the mean.") + + # Check criteria 2 + converged_cum_mean = 0 + prop_cum_mean = np.divide( + np.cumsum(property_array), np.arange(1, len(n_samples) + 1) + ) + if all(prop_cum_mean[last_m:] < mean_prop + std_prop) and all( + prop_cum_mean[last_m:] > mean_prop - std_prop + ): + converged_cum_mean = True + + else: + if verbose: + print("The cumulative property mean does not converge to the global mean.") + + if converged_last_val and converged_cum_mean: + return True + + else: + return False From 292aa267c615a5f0bc887a1a60c51bf88fd03c96 Mon Sep 17 00:00:00 2001 From: Ronald Kam Date: Fri, 1 Dec 2023 16:50:59 -0800 Subject: [PATCH 09/36] Add function to determine number of samples to discard Identify a range of discard values, and determine the smallest value to converge MC simulation --- smol/moca/analysis/convergence.py | 53 +++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/smol/moca/analysis/convergence.py b/smol/moca/analysis/convergence.py index ea814eb2..69c67b30 100644 --- a/smol/moca/analysis/convergence.py +++ b/smol/moca/analysis/convergence.py @@ -94,3 +94,56 @@ def check_property_converged(property_array, min_std=1e-4, last_m=None, verbose= else: return False + + +def determine_discard_number( + property_array, init_discard=None, increment=10, verbose=False +): + """Determine the minimum number of samples to discard for MC equilibration. + + Identify a range of number of samples to discard. Determine the smallest value that + yields a converged property. + + Args: + property_array (ndarray): + array of numerical values of a property (energy, composition, etc) + init_discard (int): + initial guess for number of samples to discard. If None, take the first 10% + as the initial guess + increment (int): + determines the increment of discard values to search for. Will search for + discard values in increments of (n_samples - init_discard)/increment + + Returns: + discard_n (int): + number of samples to discard + + """ + property_array = np.array(property_array) + n_samples = len(property_array) + + if init_discard is None: + init_discard = int(n_samples / 10) + elif init_discard > n_samples: + warn( + f"Number to discard ({init_discard}) is greater than num samples " + f"({n_samples})! Will set the discard value to be 10% of the number of" + f"samples ({int(n_samples/10)})" + ) + init_discard = int(n_samples / 10) + + discard_val_increment = (n_samples - init_discard) / increment + for discard_n in np.arange( + init_discard, n_samples - increment, discard_val_increment + ): + discard_n = int(discard_n) + if check_property_converged(property_array[discard_n:]): + return discard_n + + if verbose: + print( + "Could not find a discard value that leads to MC convergence. Will return" + " the initial guess." + ) + + return init_discard From bb575348608f704b9f0954922b9b876306248302 Mon Sep 17 00:00:00 2001 From: Ronald Kam Date: Fri, 1 Dec 2023 16:53:39 -0800 Subject: [PATCH 10/36] Fix print statement and small bug Had a mistake in calculating the cumulative property average --- smol/moca/analysis/convergence.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/smol/moca/analysis/convergence.py b/smol/moca/analysis/convergence.py index 69c67b30..de476770 100644 --- a/smol/moca/analysis/convergence.py +++ b/smol/moca/analysis/convergence.py @@ -73,13 +73,11 @@ def check_property_converged(property_array, min_std=1e-4, last_m=None, verbose= else: if verbose: - print("The property last value is not close to the mean.") + print("The last value of the property is not close to the mean.") # Check criteria 2 converged_cum_mean = 0 - prop_cum_mean = np.divide( - np.cumsum(property_array), np.arange(1, len(n_samples) + 1) - ) + prop_cum_mean = np.divide(np.cumsum(property_array), np.arange(1, n_samples + 1)) if all(prop_cum_mean[last_m:] < mean_prop + std_prop) and all( prop_cum_mean[last_m:] > mean_prop - std_prop ): From de8b5045c810a12d9549600ceaee77f376682dac Mon Sep 17 00:00:00 2001 From: Ronald Kam Date: Fri, 1 Dec 2023 17:31:25 -0800 Subject: [PATCH 11/36] Return 0 discard value instead of original guess --- smol/moca/analysis/convergence.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/smol/moca/analysis/convergence.py b/smol/moca/analysis/convergence.py index de476770..f0f84ee5 100644 --- a/smol/moca/analysis/convergence.py +++ b/smol/moca/analysis/convergence.py @@ -78,8 +78,8 @@ def check_property_converged(property_array, min_std=1e-4, last_m=None, verbose= # Check criteria 2 converged_cum_mean = 0 prop_cum_mean = np.divide(np.cumsum(property_array), np.arange(1, n_samples + 1)) - if all(prop_cum_mean[last_m:] < mean_prop + std_prop) and all( - prop_cum_mean[last_m:] > mean_prop - std_prop + if all(prop_cum_mean[-last_m:] < mean_prop + std_prop) and all( + prop_cum_mean[-last_m:] > mean_prop - std_prop ): converged_cum_mean = True @@ -140,8 +140,8 @@ def determine_discard_number( if verbose: print( - "Could not find a discard value that leads to MC convergence. Will return" - " the initial guess." + "Could not find a discard value that leads to MC convergence. Will return " + "0." ) - return init_discard + return 0 From d9c9bb0d8e8a88a993d7812c4ddbe9f37b9077e9 Mon Sep 17 00:00:00 2001 From: Ronald Kam Date: Fri, 1 Dec 2023 17:33:23 -0800 Subject: [PATCH 12/36] Add tests for convergence tools --- tests/test_moca/test_convergence.py | 40 +++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/test_moca/test_convergence.py diff --git a/tests/test_moca/test_convergence.py b/tests/test_moca/test_convergence.py new file mode 100644 index 00000000..4410d7cf --- /dev/null +++ b/tests/test_moca/test_convergence.py @@ -0,0 +1,40 @@ +import numpy as np +import pytest + +from smol.moca.analysis.convergence import ( + check_property_converged, + determine_discard_number, +) + + +@pytest.fixture() +def prop_array_1(): # array with an outlier at the end + array1 = [1, 2] * 100 + array1.append(10) + return np.array(array1) + + +@pytest.fixture() +def prop_array_2(rng): + # linearly decreasing array with some noise, then hold constant with noise + array2 = [] + for i in np.arange(1, -0.001, -0.05): + array2.append(i) + random_samples = rng.normal(loc=i, scale=0.01, size=10) + array2.extend(random_samples) + + more_random_samples = rng.normal(loc=0, scale=0.01, size=10000) + array2.extend(more_random_samples) + return np.array(array2) + + +def test_check_property_converged(prop_array_1, prop_array_2): + assert not check_property_converged(prop_array_1) + assert not check_property_converged(prop_array_2[:220]) + assert check_property_converged(prop_array_2[1000:]) + + +def test_determine_discard_number(prop_array_1, prop_array_2): + assert not determine_discard_number(prop_array_1) + assert not determine_discard_number(prop_array_2[:220]) + assert determine_discard_number(prop_array_2[1000:]) > 0 From 211febcf9b475332bf44cd87cbf9e2a3822cff91 Mon Sep 17 00:00:00 2001 From: Ronald Kam Date: Fri, 1 Dec 2023 18:09:46 -0800 Subject: [PATCH 13/36] Fix the test --- tests/test_moca/test_convergence.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_moca/test_convergence.py b/tests/test_moca/test_convergence.py index 4410d7cf..615fed6a 100644 --- a/tests/test_moca/test_convergence.py +++ b/tests/test_moca/test_convergence.py @@ -25,16 +25,17 @@ def prop_array_2(rng): more_random_samples = rng.normal(loc=0, scale=0.01, size=10000) array2.extend(more_random_samples) + array2.append(0.005) return np.array(array2) def test_check_property_converged(prop_array_1, prop_array_2): assert not check_property_converged(prop_array_1) - assert not check_property_converged(prop_array_2[:220]) + assert not check_property_converged(prop_array_2[:200]) assert check_property_converged(prop_array_2[1000:]) def test_determine_discard_number(prop_array_1, prop_array_2): assert not determine_discard_number(prop_array_1) - assert not determine_discard_number(prop_array_2[:220]) + assert not determine_discard_number(prop_array_2[:200]) assert determine_discard_number(prop_array_2[1000:]) > 0 From ac113a7121e4270166460adf619457e6965640e6 Mon Sep 17 00:00:00 2001 From: Ronald Kam Date: Fri, 1 Dec 2023 18:10:19 -0800 Subject: [PATCH 14/36] Allow user to define a convergence tolerance --- smol/moca/analysis/convergence.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/smol/moca/analysis/convergence.py b/smol/moca/analysis/convergence.py index f0f84ee5..e3ff51a3 100644 --- a/smol/moca/analysis/convergence.py +++ b/smol/moca/analysis/convergence.py @@ -7,20 +7,25 @@ import numpy as np -def check_property_converged(property_array, min_std=1e-4, last_m=None, verbose=False): +def check_property_converged( + property_array, conv_tol=None, min_std=1e-4, last_m=None, verbose=False +): """Check if a property is converged in MC run. A relatively rudimentary check for convergence, perhaps not the most rigorous. The criteria for convergence are: 1) The last value of the property should be close to the mean of the property, +/- - the spread of the property. + some tolerance. 2) The cumulative mean of the property in the last M samples should be close to - the mean of the property, +/- the spread of the property. + the mean of the property, +/- some tolerance. Args: property_array (ndarray): array of numerical values of a property (energy, composition, etc) + conv_tol (float): + value to determine the convergence tolerance. If None, the std. dev. of the + property will be used min_std (float): minimum standard deviation of the property required to perform this convergence test. If std dev is too small, then we can assume that there @@ -49,6 +54,9 @@ def check_property_converged(property_array, min_std=1e-4, last_m=None, verbose= ) return True + if conv_tol is None: + conv_tol = std_prop + mean_prop = np.average(property_array) n_samples = len(property_array) @@ -66,8 +74,8 @@ def check_property_converged(property_array, min_std=1e-4, last_m=None, verbose= # Check criteria 1 converged_last_val = 0 if ( - property_array[-1] < mean_prop + std_prop - and property_array[-1] > mean_prop - std_prop + property_array[-1] < mean_prop + conv_tol + and property_array[-1] > mean_prop - conv_tol ): converged_last_val = True @@ -78,8 +86,8 @@ def check_property_converged(property_array, min_std=1e-4, last_m=None, verbose= # Check criteria 2 converged_cum_mean = 0 prop_cum_mean = np.divide(np.cumsum(property_array), np.arange(1, n_samples + 1)) - if all(prop_cum_mean[-last_m:] < mean_prop + std_prop) and all( - prop_cum_mean[-last_m:] > mean_prop - std_prop + if all(prop_cum_mean[-last_m:] < mean_prop + conv_tol) and all( + prop_cum_mean[-last_m:] > mean_prop - conv_tol ): converged_cum_mean = True From a5c4a405d898f9dcb8def49385a3ea67bf0e5151 Mon Sep 17 00:00:00 2001 From: Ronald Kam Date: Fri, 1 Dec 2023 21:17:01 -0800 Subject: [PATCH 15/36] Fix the values of discard to check --- smol/moca/analysis/convergence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smol/moca/analysis/convergence.py b/smol/moca/analysis/convergence.py index e3ff51a3..5e86eb17 100644 --- a/smol/moca/analysis/convergence.py +++ b/smol/moca/analysis/convergence.py @@ -140,7 +140,7 @@ def determine_discard_number( discard_val_increment = (n_samples - init_discard) / increment for discard_n in np.arange( - init_discard, n_samples - increment, discard_val_increment + init_discard, n_samples - discard_val_increment, discard_val_increment ): discard_n = int(discard_n) if check_property_converged(property_array[discard_n:]): From f0d5e91454b84900d614c40624fcc5f2ca2ec29d Mon Sep 17 00:00:00 2001 From: Ronald Kam Date: Sun, 10 Dec 2023 17:52:25 -0800 Subject: [PATCH 16/36] Pin latest version of h5py as dependency --- pyproject.toml | 6 +++--- requirements-optional.txt | 1 - requirements.txt | 1 + 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 51e340db..d3ebb801 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,8 @@ classifiers = [ dependencies = [ "numpy >=1.24", "pymatgen >=2023.08.10", - "monty >=v2022.9.8" + "monty >=v2022.9.8", + "h5py >=3.10.0" ] authors = [ {name = "Luis Barroso-Luque", email = "lbluque@berkeley.edu"}, @@ -34,7 +35,6 @@ maintainers = [ [project.optional-dependencies] optional = [ "scikit-learn >=1.1.2", - "h5py >=3.6.0", "polytope", "cvxpy", "cvxopt", @@ -54,7 +54,7 @@ test = [ "pytest >=7.2.0", "pytest-cov >=4.0.0", "scikit-learn >=1.1.2", - "h5py >=3.6.0", + "h5py >=3.10.0", "coverage", "polytope", "cvxpy", diff --git a/requirements-optional.txt b/requirements-optional.txt index 9a1219cb..b637b2d7 100644 --- a/requirements-optional.txt +++ b/requirements-optional.txt @@ -1,4 +1,3 @@ -h5py==3.10.0 scikit-learn>=1.1.2 polytope cvxpy diff --git a/requirements.txt b/requirements.txt index cfab7549..8df40e0b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ numpy==1.24.4 monty==2023.9.25 pymatgen==2023.9.10 +h5py==3.10.0 From dd40f8a36a40bee936edbc653a072151239b7d72 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Dec 2023 19:10:33 +0000 Subject: [PATCH 17/36] Bump actions/setup-python from 4 to 5 Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/docs.yml | 2 +- .github/workflows/lint.yml | 2 +- .github/workflows/test.yml | 2 +- .github/workflows/update-precommit.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 30124028..6b0be9cf 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -12,7 +12,7 @@ jobs: - name: Install pandoc run: sudo apt-get install pandoc - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: 3.11 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4465113f..d70fa257 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -20,7 +20,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3.11 - name: Install dependencies diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 881af1ea..3ba567b6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,7 +26,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python_version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python_version }} diff --git a/.github/workflows/update-precommit.yaml b/.github/workflows/update-precommit.yaml index b4bdaf79..04b262c8 100644 --- a/.github/workflows/update-precommit.yaml +++ b/.github/workflows/update-precommit.yaml @@ -12,7 +12,7 @@ jobs: - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3.11 From ec1c16e231b895ef1505bebbf331590420bc5c8d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Dec 2023 19:14:17 +0000 Subject: [PATCH 18/36] Bump actions/upload-artifact from 3 to 4 Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3 to 4. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ab4b3b8c..39dcc8e7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,7 +35,7 @@ jobs: - name: Build wheels uses: pypa/cibuildwheel@v2.16.2 - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: path: wheelhouse/*.whl @@ -94,7 +94,7 @@ jobs: - name: Build wheels uses: pypa/cibuildwheel@v2.16.2 - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: path: wheelhouse/*.whl @@ -110,6 +110,6 @@ jobs: - name: Build sdist run: pipx run build --sdist - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: path: dist/*.tar.gz From 978bb80e7a40ec4656a84f69e82c72dbb1538259 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Dec 2023 19:14:20 +0000 Subject: [PATCH 19/36] Bump actions/download-artifact from 3 to 4 Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 3 to 4. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8701683e..be1699f0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -42,7 +42,7 @@ jobs: if: github.event.inputs.release-pypi == 'true' steps: - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: artifact path: dist From 9e1cb3a9257b037cbc923f363aa0bc4867846da1 Mon Sep 17 00:00:00 2001 From: Ronald Kam Date: Mon, 18 Dec 2023 14:35:09 -0800 Subject: [PATCH 20/36] Clean up container.py Change h5py import statement and remove @requires decorators --- smol/moca/sampler/container.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/smol/moca/sampler/container.py b/smol/moca/sampler/container.py index 2cf9b5b8..d66e70a5 100644 --- a/smol/moca/sampler/container.py +++ b/smol/moca/sampler/container.py @@ -12,8 +12,8 @@ import warnings from collections import defaultdict +import h5py import numpy as np -from monty.dev import requires from monty.json import MontyDecoder, MontyEncoder, MSONable, jsanitize from smol.moca import Ensemble @@ -21,11 +21,6 @@ from smol.moca.sublattice import Sublattice from smol.moca.trace import Trace -try: - import h5py -except ImportError: - h5py = None - class SampleContainer(MSONable): """A SampleContainer class stores Monte Carlo simulation samples. @@ -437,7 +432,6 @@ def flush_to_backend(self, backend): self._total_steps = 0 self._nsamples = 0 - @requires(h5py is not None, "'h5py' not found. Please install it.") def get_backend(self, file_path, alloc_nsamples=0, swmr_mode=False): """Get a backend file object. @@ -630,7 +624,6 @@ def to_hdf5(self, file_path): backend.close() @classmethod - @requires(h5py is not None, "'h5py' not found. Please install it.") def from_hdf5(cls, file_path, swmr_mode=True, ensemble=None): """Instantiate a SampleContainer from an hdf5 file. From 0c907e7d0320babc2b56941c346867f772295a8c Mon Sep 17 00:00:00 2001 From: Ronald Kam Date: Mon, 18 Dec 2023 16:05:49 -0800 Subject: [PATCH 21/36] Add convergence verification to jupyter examples --- .../running-canonical-mc-checkpoint.ipynb | 354 ++++++++++++++++++ ...ning-charge-balanced-gcmc-checkpoint.ipynb | 285 ++++++++++++++ docs/src/notebooks/running-canonical-mc.ipynb | 74 ++-- .../running-charge-balanced-gcmc.ipynb | 65 +++- 4 files changed, 747 insertions(+), 31 deletions(-) create mode 100644 docs/src/notebooks/.ipynb_checkpoints/running-canonical-mc-checkpoint.ipynb create mode 100644 docs/src/notebooks/.ipynb_checkpoints/running-charge-balanced-gcmc-checkpoint.ipynb diff --git a/docs/src/notebooks/.ipynb_checkpoints/running-canonical-mc-checkpoint.ipynb b/docs/src/notebooks/.ipynb_checkpoints/running-canonical-mc-checkpoint.ipynb new file mode 100644 index 00000000..8b80bb50 --- /dev/null +++ b/docs/src/notebooks/.ipynb_checkpoints/running-canonical-mc-checkpoint.ipynb @@ -0,0 +1,354 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Running Canonical Monte Carlo Sampling" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import numpy as np\n", + "import json\n", + "from pymatgen.core.structure import Structure\n", + "from smol.io import load_work" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 0) Load the previous LNO CE with electrostatics" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "work = load_work('data/basic_ce_ewald.mson')\n", + "expansion = work['ClusterExpansion']" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 1) Create a canonical ensemble\n", + "The `Ensemble` class can be used to run MC in a fixed composition ensemble.\n", + "The ensemble classes will determine the **active** sublattices by grouping all sites that have the same possible partial occupancies.\n", + "\n", + "To run for fixed chemical potential see the notebook on semigrand ensemble MC." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The supercell size for the processor is 16 prims.\n", + "The ensemble has a total of 64 sites.\n", + "The active sublattices are:\n", + "Sublattice(site_space=Li+0.5 vacA0+0.5, sites=array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]), active_sites=array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]), encoding=array([0, 1]))\n", + "Sublattice(site_space=Ni3+0.5 Ni4+0.5 , sites=array([16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]), active_sites=array([16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]), encoding=array([0, 1]))\n", + "Sublattice(site_space=O2-1 , sites=array([32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,\n", + " 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]), active_sites=array([], dtype=float64), encoding=array([0]))\n" + ] + } + ], + "source": [ + "from smol.moca import Ensemble\n", + "\n", + "# Create the ensemble\n", + "# This specifies the size of the MC simulation domain.\n", + "sc_matrix = np.array([\n", + " [6, 1, 1],\n", + " [1, 2, 1],\n", + " [1, 1, 2]\n", + "])\n", + "\n", + "# this convenience method will take care of creating the appropriate\n", + "# processor for the given cluster expansion.\n", + "ensemble = Ensemble.from_cluster_expansion(expansion, sc_matrix)\n", + "\n", + "# In a real scenario you may want a much larger processor.size\n", + "# An MC step is O(1) with the processor.size, meaning it runs at\n", + "# the same speed regardless of the size. However, larger sizes\n", + "# will need many more steps to reach equilibrium in an MC simulation.\n", + "print(f'The supercell size for the processor is {ensemble.processor.size} prims.')\n", + "print(f'The ensemble has a total of {ensemble.num_sites} sites.')\n", + "print(f'The active sublattices are:')\n", + "for sublattice in ensemble.sublattices:\n", + " print(sublattice)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 3) Create an MC sampler\n", + "A `Sampler` will take care of running MC sampling runs for a given ensemble. The sampler allows many different options for MC sampling most importantly setting the MCMC algorithm and the type of MC steps taken. However the defaults are usually enough for almost all use cases." + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Sampling information: Metadata(cls_name='SampleContainer', kernels=[Metadata(seed=305970771585639230070722133755157608508, step=Metadata(sublattices=[(Species Li+, Vacancy vacA0+), (Species Ni3+, Species Ni4+), (Species O2-,)], sublattice_probabilities=array([0.5, 0.5]), cls_name='Swap'), cls_name='Metropolis')])\n" + ] + } + ], + "source": [ + "from smol.moca import Sampler\n", + "\n", + "# This will take care of setting the defaults\n", + "# for the supplied canonical ensemble\n", + "sampler = Sampler.from_ensemble(ensemble, temperature=1500)\n", + "print(f\"Sampling information: {sampler.samples.metadata}\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 3) Create an initial structure and get occupancies\n", + "You will need to create an initial test structure to obtain an initial occupancy to start an MC run. There are many ways to do this, you could simply rescale a training structure and use that. But since the composition is fixed in a canonical ensemble you need to make sure you input the right composition. It can also be helpful to run a simulated anneal step to get a good initial structure rather than starting with a low energy one.\n", + "\n", + "Here we will use the underlying processor to generate a random occupancy at the composition of the disordered structure used in the original cluster expansion" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The disordered structure has composition: Li+8 Ni3+8 Ni4+8 O2-32\n", + "The initial occupancy has composition: Li+8 Ni3+8 Ni4+8 O2-32\n" + ] + } + ], + "source": [ + "from smol.capp.generate import generate_random_ordered_occupancy\n", + "\n", + "compositions = [sublattice.composition for sublattice in ensemble.sublattices]\n", + "init_occu = generate_random_ordered_occupancy(ensemble.processor, composition=compositions)\n", + "\n", + "print(f\"The disordered structure has composition: {ensemble.processor.structure.composition}\")\n", + "print(f\"The initial occupancy has composition: {ensemble.processor.structure_from_occupancy(init_occu).composition}\")" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The encoded occupancy is:\n", + "[1 1 1 0 1 1 1 0 0 0 0 1 0 0 0 1 0 1 1 0 1 0 0 0 1 0 0 1 0 1 1 1 0 0 0 0 0\n", + " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]\n", + "The initial occupancy is:\n", + " [Vacancy vacA0+, Vacancy vacA0+, Vacancy vacA0+, Species Li+, Vacancy vacA0+, Vacancy vacA0+, Vacancy vacA0+, Species Li+, Species Li+, Species Li+, Species Li+, Vacancy vacA0+, Species Li+, Species Li+, Species Li+, Vacancy vacA0+, Species Ni3+, Species Ni4+, Species Ni4+, Species Ni3+, Species Ni4+, Species Ni3+, Species Ni3+, Species Ni3+, Species Ni4+, Species Ni3+, Species Ni3+, Species Ni4+, Species Ni3+, Species Ni4+, Species Ni4+, Species Ni4+, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-]\n" + ] + } + ], + "source": [ + "# The occupancy strings created by the processor\n", + "# are by default \"encoded\" by the indices of the species\n", + "# for each given site. You can always see the actual\n", + "# species in the occupancy string by decoding it.\n", + "print(f'The encoded occupancy is:\\n{init_occu}')\n", + "print(f'The initial occupancy is:\\n {ensemble.processor.decode_occupancy(init_occu)}')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 4) Run MC iterations\n", + "MC iterations are by default run by swapping sites from all active sublattices, but fine grained simulations can also be ran by only flipping on some of the active sublattices or even freezen specific sites in active sublattices. MC samples are saved in a `SampleContainer` created or given to the `Sampler` when created." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Sampling 1 chain(s) from a cell with 64 sites...: 100%|██████████| 1000000/1000000 [08:03<00:00, 2070.18it/s]\n" + ] + } + ], + "source": [ + "# run 1M iterations\n", + "# since this is the first run, the initial occupancy must be supplied\n", + "sampler.run(\n", + " 1000000,\n", + " initial_occupancies=init_occu,\n", + " thin_by=100, # thin_by will save every 100th sample only\n", + " progress=True\n", + ") # progress will show progress bar" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Fraction of successful steps (efficiency) 0.003902\n", + "The last step energy is -551.9159632697251 eV\n", + "The minimum energy in trajectory is -552.6314360816468 eV\n" + ] + } + ], + "source": [ + "# Samples are saved in a sample container\n", + "samples = sampler.samples\n", + "\n", + "print(f'Fraction of successful steps (efficiency) {sampler.efficiency()}')\n", + "print(f'The last step energy is {samples.get_energies()[-1]} eV')\n", + "print(f'The minimum energy in trajectory is {samples.get_minimum_energy()} eV')\n", + "\n", + "# You can get the minimum energy structure and current structure\n", + "# by using the ensemble processor\n", + "curr_s = ensemble.processor.structure_from_occupancy(samples.get_occupancies()[-1])\n", + "min_s = ensemble.processor.structure_from_occupancy(samples.get_minimum_energy_occupancy())" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 4.1) Continuing or resetting the MC trajectory\n", + "You can always continue running more iterations from where the trajectory left off by calling `run` again.\n", + "You can also reset to the initial state. (we will skip this step for now so we can show results from the run above." + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [], + "source": [ + "# You can continue the MC trajectory simmply by calling run again\n", + "# it is recommended to use the same thin_by used before\n", + "#sampler.run(10000, thin_by=100) # this will append new data\n", + "\n", + "# If you want to start from scratch\n", + "#sampler.clear_samples() # this will delete data, and reset the ensemble to its initial state\n", + "# Now you can start a fresh run\n", + "#sampler.run(1000000,\n", + "# initial_occupancies=init_occu,\n", + "# thin_by=100, # thin_by will save every 100th sample only\n", + "# progress=True) # progress will show progress bar" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 5) Look at trajectory samples and averages\n", + "We can look at the sampled energies, the average and variance directly from the class properties.\n", + "\n", + "For further analysis samples are stored as a list of dictionaries for each sampled step in the `CanonicalEnsemble.data` attribute.\n", + "In the `CanonicalEnsemble` class only the energy and occupancy string of each sample are saved." + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "A total of 10000 samples taken.\n", + "A total of 9000 samples used for production.\n", + "The average energy is -551.7811770626871 eV\n", + "The energy variance is 0.04697867310315079 eV^2\n" + ] + } + ], + "source": [ + "# you can discard burn-in samples from analysis\n", + "# ie here we set 1000 samples as burn-in\n", + "discard = 1000 # this is in terms of samples so it would be discard*thin_by steps\n", + "print(f'A total of {len(samples)} samples taken.')\n", + "print(f'A total of {len(samples.get_energies(discard=discard))} samples used for production.')\n", + "print(f'The average energy is {samples.mean_energy(discard=discard)} eV')\n", + "print(f'The energy variance is {samples.energy_variance(discard=discard)} eV^2')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Save your work\n", + "The `Sampler` class does and can not be saved since it does not really have any computed values. However the `SampleContainter` where the MC samples are recorded can be saved.\n", + "You can use the same `save_work` convenience function to save your work.\n", + "\n", + "You can also save the `SampleContainer` as an hdf5 file. You will need `h5py` installed." + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "matx_dev", + "language": "python", + "name": "matx_dev" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.11" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/docs/src/notebooks/.ipynb_checkpoints/running-charge-balanced-gcmc-checkpoint.ipynb b/docs/src/notebooks/.ipynb_checkpoints/running-charge-balanced-gcmc-checkpoint.ipynb new file mode 100644 index 00000000..5888005b --- /dev/null +++ b/docs/src/notebooks/.ipynb_checkpoints/running-charge-balanced-gcmc-checkpoint.ipynb @@ -0,0 +1,285 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "181b4c0a", + "metadata": {}, + "source": [ + "# Running Semigrand Canonical Monte Carlo Sampling with charge-balance" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "8429d4ea", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import numpy as np\n", + "import json\n", + "from pymatgen.core.structure import Structure\n", + "from smol.io import load_work" + ] + }, + { + "cell_type": "markdown", + "id": "d7140bb7", + "metadata": {}, + "source": [ + "### 0) Load the previous LNO CE with electrostatics" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "c53f71e2", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "work = load_work('./data/basic_ce_ewald.mson')\n", + "expansion = work['ClusterExpansion']" + ] + }, + { + "cell_type": "markdown", + "id": "f0a68fb9", + "metadata": {}, + "source": [ + "### 1) Create a semigrand ensemble\n", + "The `Ensemble` class can also be used to run semigrand canonical MC by fixing relative chemical potentials.\n", + "\n", + "In SGC chemical potential differences are set as boundary conditions. Any one of the active species can be used as reference." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "2f89e47b", + "metadata": {}, + "outputs": [], + "source": [ + "from smol.moca import Ensemble\n", + "\n", + "# Create the ensemble\n", + "# This specifies the size of the MC simulation domain.\n", + "sc_matrix = np.array([\n", + " [6, 1, 1],\n", + " [1, 2, 1],\n", + " [1, 1, 2]\n", + "])\n", + "\n", + "# relative chemical potentials are provided as a dict\n", + "chemical_potentials = {'Li+': 0, 'Vacancy': 0, 'Ni3+': 0, 'Ni4+': 0}\n", + "\n", + "# this convenience method will take care of creating the appropriate\n", + "# processor for the given cluster expansion.\n", + "ensemble = Ensemble.from_cluster_expansion(\n", + " expansion, sc_matrix, chemical_potentials=chemical_potentials\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "eb907aa2", + "metadata": {}, + "source": [ + "### 2) Create an MC sampler\n", + "A `Sampler` will take care of running MC sampling runs for a given ensemble.\n", + "For a charge-balanced simulation, one can choose either a step type using:\n", + "1) the table-exchange method (TE, for historical reason, written as TableFlip in the code)\n", + "2) the square-charge bias method (SCB). \n", + "\n", + "For TE, one needs to specify the step type as \"table-flip\".\n", + "Additional arguments to control the step type can be specified directly as keyword arguments when creating the sampler. To see what arguments are available refer to the documentation of the `TableFlip` class." + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "f218c16a", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Sampling information: {'kernel': 'Metropolis', 'step': 'table-flip', 'chemical_potentials': {Species Li+: 0, Vacancy vacA0+: 0, Species Ni3+: 0, Species Ni4+: 0}, 'seeds': [97098921871036988304502408163907614831]}\n", + "Table exchanges in reaction formulas: ['1 Li+(0) + 1 Ni3+(1) -> 1 vacA0+(0) + 1 Ni4+(1)']\n" + ] + } + ], + "source": [ + "from smol.moca import Sampler\n", + "\n", + "# For the usage of other keywords, see documentation of the TableFlip class.\n", + "sampler_table = Sampler.from_ensemble(ensemble, temperature=500, step_type=\"table-flip\", optimize_basis=True)\n", + "\n", + "print(f\"Sampling information: {sampler_table.samples.metadata}\")\n", + "print(f\"Table exchanges in reaction formulas: {sampler_table.mckernels[0].mcusher._comp_space.flip_reactions}\")" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "2ddd22ee", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Li+8 Ni3+8 Ni4+8 O2-32\n", + "The encoded occupancy is:\n", + "[0 1 1 0 0 0 1 0 0 1 0 1 1 1 1 0 0 0 1 1 1 1 0 1 0 0 1 0 0 0 1 1 0 0 0 0 0\n", + " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]\n", + "The initial occupancy is:\n", + " [Species Li+, Vacancy vacA0+, Vacancy vacA0+, Species Li+, Species Li+, Species Li+, Vacancy vacA0+, Species Li+, Species Li+, Vacancy vacA0+, Species Li+, Vacancy vacA0+, Vacancy vacA0+, Vacancy vacA0+, Vacancy vacA0+, Species Li+, Species Ni3+, Species Ni3+, Species Ni4+, Species Ni4+, Species Ni4+, Species Ni4+, Species Ni3+, Species Ni4+, Species Ni3+, Species Ni3+, Species Ni4+, Species Ni3+, Species Ni3+, Species Ni3+, Species Ni4+, Species Ni4+, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-]\n" + ] + } + ], + "source": [ + "from pymatgen.transformations.standard_transformations import OrderDisorderedStructureTransformation\n", + "\n", + "# Here we will just use the order disordered transformation from\n", + "# pymatgen to get an ordered version of a prim supercell.\n", + "# The structure will have the same composition set in the prim.\n", + "transformation = OrderDisorderedStructureTransformation()\n", + "\n", + "supercell = expansion.cluster_subspace.structure.copy()\n", + "supercell.make_supercell(sc_matrix)\n", + "\n", + "# this can take a bit of time....\n", + "test_struct = transformation.apply_transformation(supercell)\n", + "print(test_struct.composition)\n", + "\n", + "# Obtain the initial occupancy string from the\n", + "# test structure created above.\n", + "init_occu = ensemble.processor.occupancy_from_structure(test_struct)\n", + "\n", + "# The occupancy strings created by the processor\n", + "# are by default \"encoded\" by the indices of the species\n", + "# for each given site. You can always see the actual\n", + "# species in the occupancy string by decoding it.\n", + "print(f'The encoded occupancy is:\\n{init_occu}')\n", + "print(f'The initial occupancy is:\\n {ensemble.processor.decode_occupancy(init_occu)}')" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "f8e40a78", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Sampling 1 chain(s) from a cell with 64 sites...: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 50000/50000 [00:24<00:00, 2055.76it/s]\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Average energy of charge balanced samples (eV): -599.4992302891402\n", + "Average composition of charge balanced samples: {Species Li+: 0.25, Vacancy vacA0+: 0.0, Species Ni3+: 0.25, Species Ni4+: 0.0, Species O2-: 0.5}\n" + ] + } + ], + "source": [ + "# Run a short simulation.\n", + "sampler_table.run(50000, init_occu, thin_by=10, progress=True)\n", + "energy_avg = sampler_table.samples.mean_energy(discard=sampler_table.samples.num_samples // 4)\n", + "comp_avg = sampler_table.samples.mean_composition(discard=sampler_table.samples.num_samples // 4)\n", + "print(f\"Average energy of charge balanced samples (eV): {energy_avg}\")\n", + "print(f\"Average composition of charge balanced samples: {comp_avg}\")" + ] + }, + { + "cell_type": "markdown", + "id": "119b9226", + "metadata": {}, + "source": [ + "For SCB, one can specify a square charge bias in sampler (if other constraints are to be enforced, refer to SquareHyperplaneBias):" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "1c2b206a", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Sampling information: {'kernel': 'Metropolis', 'step': 'flip', 'chemical_potentials': {Species Li+: 0, Vacancy vacA0+: 0, Species Ni3+: 0, Species Ni4+: 0}, 'seeds': [159094150126610822048360871456393092894]}\n" + ] + } + ], + "source": [ + "sampler_bias = Sampler.from_ensemble(ensemble, temperature=500,\n", + " step_type=\"flip\",\n", + " bias_type=\"square-charge\", bias_kwargs={\"penalty\": 1.0})\n", + "\n", + "print(f\"Sampling information: {sampler_bias.samples.metadata}\")" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "bf2f067b", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Sampling 1 chain(s) from a cell with 64 sites...: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100000/100000 [00:11<00:00, 8584.75it/s]\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Average energy of charge balanced samples (eV): -599.4992302891402\n" + ] + } + ], + "source": [ + "# SCB needs to filter out charge unbalanced configurations!\n", + "sampler_bias.run(100000, init_occu, thin_by=10, progress=True)\n", + "\n", + "bias = sampler_bias.samples.get_trace_value(\"bias\", discard=sampler_bias.samples.num_samples // 4)\n", + "energies = sampler_bias.samples.get_energies(discard=sampler_bias.samples.num_samples // 4)\n", + "energy_avg = np.average(energies[np.isclose(bias, 0)])\n", + "print(f\"Average energy of charge balanced samples (eV): {energy_avg}\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.11" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/docs/src/notebooks/running-canonical-mc.ipynb b/docs/src/notebooks/running-canonical-mc.ipynb index 8b80bb50..b5d3f1e5 100644 --- a/docs/src/notebooks/running-canonical-mc.ipynb +++ b/docs/src/notebooks/running-canonical-mc.ipynb @@ -115,7 +115,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Sampling information: Metadata(cls_name='SampleContainer', kernels=[Metadata(seed=305970771585639230070722133755157608508, step=Metadata(sublattices=[(Species Li+, Vacancy vacA0+), (Species Ni3+, Species Ni4+), (Species O2-,)], sublattice_probabilities=array([0.5, 0.5]), cls_name='Swap'), cls_name='Metropolis')])\n" + "Sampling information: Metadata(cls_name='SampleContainer', kernels=[Metadata(seed=20591352976779962497111620739889289287, step=Metadata(sublattices=[(Species Li+, Vacancy vacA0+), (Species Ni3+, Species Ni4+), (Species O2-,)], sublattice_probabilities=array([0.5, 0.5]), cls_name='Swap'), cls_name='Metropolis')])\n" ] } ], @@ -176,10 +176,10 @@ "output_type": "stream", "text": [ "The encoded occupancy is:\n", - "[1 1 1 0 1 1 1 0 0 0 0 1 0 0 0 1 0 1 1 0 1 0 0 0 1 0 0 1 0 1 1 1 0 0 0 0 0\n", + "[1 0 0 1 0 0 0 0 1 0 1 0 1 1 1 1 0 1 0 1 0 0 1 1 0 1 1 0 0 1 1 0 0 0 0 0 0\n", " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]\n", "The initial occupancy is:\n", - " [Vacancy vacA0+, Vacancy vacA0+, Vacancy vacA0+, Species Li+, Vacancy vacA0+, Vacancy vacA0+, Vacancy vacA0+, Species Li+, Species Li+, Species Li+, Species Li+, Vacancy vacA0+, Species Li+, Species Li+, Species Li+, Vacancy vacA0+, Species Ni3+, Species Ni4+, Species Ni4+, Species Ni3+, Species Ni4+, Species Ni3+, Species Ni3+, Species Ni3+, Species Ni4+, Species Ni3+, Species Ni3+, Species Ni4+, Species Ni3+, Species Ni4+, Species Ni4+, Species Ni4+, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-]\n" + " [Vacancy vacA0+, Species Li+, Species Li+, Vacancy vacA0+, Species Li+, Species Li+, Species Li+, Species Li+, Vacancy vacA0+, Species Li+, Vacancy vacA0+, Species Li+, Vacancy vacA0+, Vacancy vacA0+, Vacancy vacA0+, Vacancy vacA0+, Species Ni3+, Species Ni4+, Species Ni3+, Species Ni4+, Species Ni3+, Species Ni3+, Species Ni4+, Species Ni4+, Species Ni3+, Species Ni4+, Species Ni4+, Species Ni3+, Species Ni3+, Species Ni4+, Species Ni4+, Species Ni3+, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-]\n" ] } ], @@ -202,14 +202,14 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "Sampling 1 chain(s) from a cell with 64 sites...: 100%|██████████| 1000000/1000000 [08:03<00:00, 2070.18it/s]\n" + "Sampling 1 chain(s) from a cell with 64 sites: 100%|█| 1000000/1000000 [01:45<00:00, 9437.58i\n" ] } ], @@ -226,16 +226,16 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Fraction of successful steps (efficiency) 0.003902\n", - "The last step energy is -551.9159632697251 eV\n", - "The minimum energy in trajectory is -552.6314360816468 eV\n" + "Fraction of successful steps (efficiency) 0.3849\n", + "The last step energy is -551.6679436062601 eV\n", + "The minimum energy in trajectory is -552.6314360816037 eV\n" ] } ], @@ -264,7 +264,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -285,7 +285,38 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### 5) Look at trajectory samples and averages\n", + "### 5) Check convergence of MC sampling\n", + "Find the minimum number of samples required to discard for equilibration while converging the energy" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Is the energy converged after discarding the first 100 samples? True\n" + ] + } + ], + "source": [ + "from smol.moca.analysis.convergence import check_property_converged, determine_discard_number\n", + "\n", + "energies = samples.get_energies()\n", + "# 100 as an initial guess for amount to discard\n", + "opt_discard = determine_discard_number(property_array=energies, init_discard=100, verbose=True)\n", + "converged = check_property_converged(energies[opt_discard:])\n", + "print(f'Is the energy converged after discarding the first {opt_discard} samples?', converged)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 6) Look at trajectory samples and averages\n", "We can look at the sampled energies, the average and variance directly from the class properties.\n", "\n", "For further analysis samples are stored as a list of dictionaries for each sampled step in the `CanonicalEnsemble.data` attribute.\n", @@ -302,20 +333,21 @@ "output_type": "stream", "text": [ "A total of 10000 samples taken.\n", - "A total of 9000 samples used for production.\n", - "The average energy is -551.7811770626871 eV\n", - "The energy variance is 0.04697867310315079 eV^2\n" + "A total of 9900 samples used for production.\n", + "The average energy is -551.7841691590747 eV\n", + "The energy variance is 0.04799366234166897 eV^2\n", + "The sampling efficiency (acceptance rate) is approximately 0.38505050505050503\n" ] } ], "source": [ - "# you can discard burn-in samples from analysis\n", - "# ie here we set 1000 samples as burn-in\n", - "discard = 1000 # this is in terms of samples so it would be discard*thin_by steps\n", + "# Set 100 samples for burn-in, as determined in 5)\n", + "discard = 100 # this is in terms of samples so it would be discard*thin_by steps\n", "print(f'A total of {len(samples)} samples taken.')\n", "print(f'A total of {len(samples.get_energies(discard=discard))} samples used for production.')\n", "print(f'The average energy is {samples.mean_energy(discard=discard)} eV')\n", - "print(f'The energy variance is {samples.energy_variance(discard=discard)} eV^2')" + "print(f'The energy variance is {samples.energy_variance(discard=discard)} eV^2')\n", + "print(f'The sampling efficiency (acceptance rate) is approximately {samples.sampling_efficiency(discard=discard)}')" ] }, { @@ -332,9 +364,9 @@ ], "metadata": { "kernelspec": { - "display_name": "matx_dev", + "display_name": "Python 3 (ipykernel)", "language": "python", - "name": "matx_dev" + "name": "python3" }, "language_info": { "codemirror_mode": { @@ -346,7 +378,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.9.7" } }, "nbformat": 4, diff --git a/docs/src/notebooks/running-charge-balanced-gcmc.ipynb b/docs/src/notebooks/running-charge-balanced-gcmc.ipynb index 5888005b..c20c8f3d 100644 --- a/docs/src/notebooks/running-charge-balanced-gcmc.ipynb +++ b/docs/src/notebooks/running-charge-balanced-gcmc.ipynb @@ -107,7 +107,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Sampling information: {'kernel': 'Metropolis', 'step': 'table-flip', 'chemical_potentials': {Species Li+: 0, Vacancy vacA0+: 0, Species Ni3+: 0, Species Ni4+: 0}, 'seeds': [97098921871036988304502408163907614831]}\n", + "Sampling information: Metadata(chemical_potentials={Species Li+: 0, Vacancy vacA0+: 0, Species Ni3+: 0, Species Ni4+: 0}, cls_name='SampleContainer', kernels=[Metadata(seed=39476637764722681107161738538781464779, step=Metadata(sublattices=[(Species Li+, Vacancy vacA0+), (Species Ni3+, Species Ni4+), (Species O2-,)], sublattice_probabilities=array([0.5, 0.5]), cls_name='TableFlip', flip_table=[[-1, 1, -1, 1, 0]], flip_weights=[1.0, 1.0], other_constraints=None, charge_balanced=True, optimize_basis=True, table_ergodic=False, swap_weight=0.1), cls_name='Metropolis')])\n", "Table exchanges in reaction formulas: ['1 Li+(0) + 1 Ni3+(1) -> 1 vacA0+(0) + 1 Ni4+(1)']\n" ] } @@ -134,10 +134,10 @@ "text": [ "Li+8 Ni3+8 Ni4+8 O2-32\n", "The encoded occupancy is:\n", - "[0 1 1 0 0 0 1 0 0 1 0 1 1 1 1 0 0 0 1 1 1 1 0 1 0 0 1 0 0 0 1 1 0 0 0 0 0\n", + "[0 1 1 0 0 0 1 0 0 1 0 1 1 1 1 0 0 1 1 1 1 0 0 1 0 0 0 0 1 0 1 1 0 0 0 0 0\n", " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]\n", "The initial occupancy is:\n", - " [Species Li+, Vacancy vacA0+, Vacancy vacA0+, Species Li+, Species Li+, Species Li+, Vacancy vacA0+, Species Li+, Species Li+, Vacancy vacA0+, Species Li+, Vacancy vacA0+, Vacancy vacA0+, Vacancy vacA0+, Vacancy vacA0+, Species Li+, Species Ni3+, Species Ni3+, Species Ni4+, Species Ni4+, Species Ni4+, Species Ni4+, Species Ni3+, Species Ni4+, Species Ni3+, Species Ni3+, Species Ni4+, Species Ni3+, Species Ni3+, Species Ni3+, Species Ni4+, Species Ni4+, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-]\n" + " [Species Li+, Vacancy vacA0+, Vacancy vacA0+, Species Li+, Species Li+, Species Li+, Vacancy vacA0+, Species Li+, Species Li+, Vacancy vacA0+, Species Li+, Vacancy vacA0+, Vacancy vacA0+, Vacancy vacA0+, Vacancy vacA0+, Species Li+, Species Ni3+, Species Ni4+, Species Ni4+, Species Ni4+, Species Ni4+, Species Ni3+, Species Ni3+, Species Ni4+, Species Ni3+, Species Ni3+, Species Ni3+, Species Ni3+, Species Ni4+, Species Ni3+, Species Ni4+, Species Ni4+, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-, Species O2-]\n" ] } ], @@ -147,7 +147,7 @@ "# Here we will just use the order disordered transformation from\n", "# pymatgen to get an ordered version of a prim supercell.\n", "# The structure will have the same composition set in the prim.\n", - "transformation = OrderDisorderedStructureTransformation()\n", + "transformation = OrderDisorderedStructureTransformation(algo=2)\n", "\n", "supercell = expansion.cluster_subspace.structure.copy()\n", "supercell.make_supercell(sc_matrix)\n", @@ -178,7 +178,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "Sampling 1 chain(s) from a cell with 64 sites...: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 50000/50000 [00:24<00:00, 2055.76it/s]\n" + "Sampling 1 chain(s) from a cell with 64 sites: 100%|█| 50000/50000 [00:28<00:00, 1752.52it/s]\n" ] }, { @@ -199,6 +199,43 @@ "print(f\"Average composition of charge balanced samples: {comp_avg}\")" ] }, + { + "cell_type": "markdown", + "id": "62a9210e-500a-414d-8524-b20471d01761", + "metadata": {}, + "source": [ + "Check convergence of Li composition" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "35119147-b969-4e6e-b9f6-30375df13369", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The initial Li composition is 0.875 Li per O2, and the final value is 1.0\n", + "Is the composition converged after discarding the first 500 samples? True\n", + "The average and std dev of Li composition is 1.0 and 0.0 Li per O2\n" + ] + } + ], + "source": [ + "from smol.moca.analysis.convergence import check_property_converged, determine_discard_number\n", + "from pymatgen.core import Species\n", + "\n", + "init_discard = int(sampler_table.samples.num_samples / 10) # Initial guess for number of samples to discard: 10% of samples\n", + "li_comps = sampler_table.samples.get_compositions()[Species('Li+')]*4 # Li compositions per O2\n", + "print(f'The initial Li composition is {li_comps[0]} Li per O2, and the final value is {li_comps[-1]}')\n", + "disc = determine_discard_number(property_array=li_comps, init_discard=init_discard, verbose=True)\n", + "converged = check_property_converged(li_comps[disc:])\n", + "print(f'Is the composition converged after discarding the first {disc} samples?', converged)\n", + "print(f'The average and std dev of Li composition is {np.average(li_comps[disc:])} and {np.std(li_comps[disc:])} Li per O2')" + ] + }, { "cell_type": "markdown", "id": "119b9226", @@ -209,7 +246,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "id": "1c2b206a", "metadata": {}, "outputs": [ @@ -217,7 +254,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Sampling information: {'kernel': 'Metropolis', 'step': 'flip', 'chemical_potentials': {Species Li+: 0, Vacancy vacA0+: 0, Species Ni3+: 0, Species Ni4+: 0}, 'seeds': [159094150126610822048360871456393092894]}\n" + "Sampling information: Metadata(chemical_potentials={Species Li+: 0, Vacancy vacA0+: 0, Species Ni3+: 0, Species Ni4+: 0}, cls_name='SampleContainer', kernels=[Metadata(seed=47719333132304718576589376853864751432, step=Metadata(sublattices=[(Species Li+, Vacancy vacA0+), (Species Ni3+, Species Ni4+), (Species O2-,)], sublattice_probabilities=array([0.5, 0.5]), cls_name='Flip'), cls_name='Metropolis', bias=Metadata(type='SquareChargeBias', sublattices=[{'Li+': 0.5}, {'Ni3+': 0.5, 'Ni4+': 0.5}, {'O2-': 1.0}], cls_name=None, penalty=1.0))])\n" ] } ], @@ -231,7 +268,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "id": "bf2f067b", "metadata": {}, "outputs": [ @@ -239,7 +276,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "Sampling 1 chain(s) from a cell with 64 sites...: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100000/100000 [00:11<00:00, 8584.75it/s]\n" + "Sampling 1 chain(s) from a cell with 64 sites: 100%|█| 100000/100000 [00:13<00:00, 7599.14it/\n" ] }, { @@ -259,6 +296,14 @@ "energy_avg = np.average(energies[np.isclose(bias, 0)])\n", "print(f\"Average energy of charge balanced samples (eV): {energy_avg}\")" ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "60944637-2ca5-41c3-b497-07ba530f7e7f", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -277,7 +322,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.9.7" } }, "nbformat": 4, From 3a4fba6d0aba1fdec15271384046502b7e3733df Mon Sep 17 00:00:00 2001 From: lbluque Date: Thu, 28 Dec 2023 00:15:07 +0000 Subject: [PATCH 22/36] auto-update pre-commit hooks --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9a62bd3f..2ee339da 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ repos: args: ['--maxkb=600'] - repo: https://github.com/psf/black - rev: 23.11.0 + rev: 23.12.1 hooks: - id: black @@ -30,7 +30,7 @@ repos: exclude: README.md - repo: https://github.com/pycqa/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort name: isort (python) From 6ac2556ea314c40651ff3836f92d3702d8209f17 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 1 Jan 2024 17:45:52 +0000 Subject: [PATCH 23/36] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 23.11.0 → 23.12.1](https://github.com/psf/black/compare/23.11.0...23.12.1) - [github.com/pycqa/isort: 5.12.0 → 5.13.2](https://github.com/pycqa/isort/compare/5.12.0...5.13.2) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9a62bd3f..2ee339da 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ repos: args: ['--maxkb=600'] - repo: https://github.com/psf/black - rev: 23.11.0 + rev: 23.12.1 hooks: - id: black @@ -30,7 +30,7 @@ repos: exclude: README.md - repo: https://github.com/pycqa/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort name: isort (python) From 82563e75e759c037b409fe569c4c6cc919dd92bb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jan 2024 19:45:44 +0000 Subject: [PATCH 24/36] Bump actions/cache from 3 to 4 Bumps [actions/cache](https://github.com/actions/cache) from 3 to 4. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3ba567b6..4b2899e3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,7 +36,7 @@ jobs: sudo apt-get update && sudo apt install -y ./SCIPOptSuite-${{ env.scip-version }}-Linux-ubuntu.deb - name: Cache pip - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} From 13b04f24c190a798bb119b2f6a3e1696f61ad661 Mon Sep 17 00:00:00 2001 From: lbluque Date: Sun, 28 Jan 2024 00:16:24 +0000 Subject: [PATCH 25/36] auto-update pre-commit hooks --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2ee339da..a9816f36 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ repos: args: ['--maxkb=600'] - repo: https://github.com/psf/black - rev: 23.12.1 + rev: 24.1.0 hooks: - id: black From c0b9e6cc0b25f223a6f7bddf5ec33bd74c0edac7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 28 Jan 2024 00:16:52 +0000 Subject: [PATCH 26/36] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- setup.py | 1 + smol/capp/generate/groundstate/upper_bound/constraints.py | 1 + smol/capp/generate/groundstate/upper_bound/objectives.py | 1 + smol/capp/generate/groundstate/upper_bound/solver.py | 1 + smol/capp/generate/groundstate/upper_bound/terms.py | 1 + smol/capp/generate/groundstate/upper_bound/variables.py | 1 + smol/cofe/extern/__init__.py | 1 - smol/cofe/space/basis.py | 7 ++++--- smol/cofe/space/cluster.py | 8 +++++--- smol/cofe/space/clusterspace.py | 1 + smol/cofe/space/constants.py | 1 - smol/moca/composition/constraints.py | 1 + smol/moca/kernel/base.py | 6 +++--- smol/utils/cluster/numthreads.py | 1 - smol/utils/exceptions.py | 1 - tests/test_capp/test_solver/conftest.py | 1 + tests/test_capp/test_solver/test_constraints.py | 1 + tests/test_capp/test_solver/test_objectives.py | 1 + tests/test_capp/test_solver/test_solver.py | 1 + tests/test_capp/test_solver/test_utils.py | 1 + tests/test_capp/test_solver/test_variables.py | 1 + tests/test_cofe/test_basis.py | 4 ++-- tests/test_moca/test_constraint_utils.py | 1 + tests/test_moca/test_occu_utils.py | 1 + tests/test_utils/test_math_utils.py | 1 + 25 files changed, 31 insertions(+), 15 deletions(-) diff --git a/setup.py b/setup.py index d5135a9d..33ba4e9b 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ """smol -- Statistical Mechanics On Lattices""" + import os import platform import shutil diff --git a/smol/capp/generate/groundstate/upper_bound/constraints.py b/smol/capp/generate/groundstate/upper_bound/constraints.py index cf37d231..f5aa7170 100644 --- a/smol/capp/generate/groundstate/upper_bound/constraints.py +++ b/smol/capp/generate/groundstate/upper_bound/constraints.py @@ -1,4 +1,5 @@ """Get constraints on variables from a processor.""" + from numbers import Number from typing import List, Tuple, Union diff --git a/smol/capp/generate/groundstate/upper_bound/objectives.py b/smol/capp/generate/groundstate/upper_bound/objectives.py index 7d3e4d53..5a59801b 100644 --- a/smol/capp/generate/groundstate/upper_bound/objectives.py +++ b/smol/capp/generate/groundstate/upper_bound/objectives.py @@ -1,4 +1,5 @@ """Generate energy terms from processor to be converted into cvxpy.""" + from copy import deepcopy from itertools import product from typing import List, Tuple, Union diff --git a/smol/capp/generate/groundstate/upper_bound/solver.py b/smol/capp/generate/groundstate/upper_bound/solver.py index 81a19f88..a1666b49 100644 --- a/smol/capp/generate/groundstate/upper_bound/solver.py +++ b/smol/capp/generate/groundstate/upper_bound/solver.py @@ -1,4 +1,5 @@ """Solver class for the ground state problem of cluster expansion.""" + from typing import List, NamedTuple, Union from warnings import warn diff --git a/smol/capp/generate/groundstate/upper_bound/terms.py b/smol/capp/generate/groundstate/upper_bound/terms.py index 1a94eefc..bf1b2b1a 100644 --- a/smol/capp/generate/groundstate/upper_bound/terms.py +++ b/smol/capp/generate/groundstate/upper_bound/terms.py @@ -1,4 +1,5 @@ """Handles boolean product terms in expression.""" + from typing import List, Tuple import cvxpy as cp diff --git a/smol/capp/generate/groundstate/upper_bound/variables.py b/smol/capp/generate/groundstate/upper_bound/variables.py index 3c781794..0be3061c 100644 --- a/smol/capp/generate/groundstate/upper_bound/variables.py +++ b/smol/capp/generate/groundstate/upper_bound/variables.py @@ -1,4 +1,5 @@ """Get variables from processor.""" + from typing import List, Tuple import cvxpy as cp diff --git a/smol/cofe/extern/__init__.py b/smol/cofe/extern/__init__.py index 83710eb4..d539800d 100644 --- a/smol/cofe/extern/__init__.py +++ b/smol/cofe/extern/__init__.py @@ -7,7 +7,6 @@ be the only term ever needed, but alas abstraction? """ - from .ewald import EwaldTerm __all__ = ["EwaldTerm"] diff --git a/smol/cofe/space/basis.py b/smol/cofe/space/basis.py index 6d65b475..da6b836c 100644 --- a/smol/cofe/space/basis.py +++ b/smol/cofe/space/basis.py @@ -5,6 +5,7 @@ which is defined by the allowed species at the site and their measures, i.e. the concentration of the species in the random structure. """ + # pylint: disable=invalid-name, too-few-public-methods import warnings @@ -323,9 +324,9 @@ def rotate(self, angle, index1=0, index2=1): ) self._f_array[1:] = self._f_array[1:] @ rotation_mat.T # make really small numbers zero - self._f_array[ - abs(self._f_array) < EPS_MULT * np.finfo(np.float64).eps - ] = 0.0 + self._f_array[abs(self._f_array) < EPS_MULT * np.finfo(np.float64).eps] = ( + 0.0 + ) self._rot_array = rotation_mat @ self._rot_array diff --git a/smol/cofe/space/cluster.py b/smol/cofe/space/cluster.py index 41dfcefa..2b6c740f 100644 --- a/smol/cofe/space/cluster.py +++ b/smol/cofe/space/cluster.py @@ -285,9 +285,11 @@ def from_dict(cls, d): for symbols, site in zip(d["vacancy_symbols"], sites): site.species = Composition( { - spec - if spec.symbol not in symbols - else Vacancy(spec.symbol, spec.oxidation_state, spec.spin): val + ( + spec + if spec.symbol not in symbols + else Vacancy(spec.symbol, spec.oxidation_state, spec.spin) + ): val for spec, val in site.species.items() if spec.symbol not in symbols } diff --git a/smol/cofe/space/clusterspace.py b/smol/cofe/space/clusterspace.py index af7301f5..52bffb7c 100644 --- a/smol/cofe/space/clusterspace.py +++ b/smol/cofe/space/clusterspace.py @@ -6,6 +6,7 @@ The PottsSubspace class is an (experimental) class that is similar, but diverges from the CE mathematic formalism. """ + # pylint: disable=too-many-lines diff --git a/smol/cofe/space/constants.py b/smol/cofe/space/constants.py index 3ade8342..cb1ea2a4 100644 --- a/smol/cofe/space/constants.py +++ b/smol/cofe/space/constants.py @@ -1,6 +1,5 @@ """Definitions of global constants used in cofe.space module.""" - # site tolerance is the absolute tolerance passed to the pymatgen coord utils # to determine mappings and subsets. The default in pymatgen is 1E-8. # If you want to tighten or loosen this tolerance, do it at runtime in your diff --git a/smol/moca/composition/constraints.py b/smol/moca/composition/constraints.py index f970b403..9a3e9eb8 100644 --- a/smol/moca/composition/constraints.py +++ b/smol/moca/composition/constraints.py @@ -1,4 +1,5 @@ """Utility manager that converts input of composition constraints to equations.""" + import itertools import re from numbers import Number diff --git a/smol/moca/kernel/base.py b/smol/moca/kernel/base.py index 81bda925..d3defdc9 100644 --- a/smol/moca/kernel/base.py +++ b/smol/moca/kernel/base.py @@ -705,9 +705,9 @@ def set_aux_state(self, occupancy, *args, **kwargs): new_features.append(kernel.ensemble.compute_feature_vector(occupancy)) self._features = np.vstack(new_features) else: # if only one assume it is continuing from a run... - self._features[ - self._current_kernel_index, : - ] = self.current_kernel.ensemble.compute_feature_vector(occupancy) + self._features[self._current_kernel_index, :] = ( + self.current_kernel.ensemble.compute_feature_vector(occupancy) + ) self.current_kernel.set_aux_state(occupancy, *args, **kwargs) def compute_initial_trace(self, occupancy): diff --git a/smol/utils/cluster/numthreads.py b/smol/utils/cluster/numthreads.py index 776f3e16..b74b30d0 100644 --- a/smol/utils/cluster/numthreads.py +++ b/smol/utils/cluster/numthreads.py @@ -1,6 +1,5 @@ """Simple mixin class that has an attributed/method that runs in parallel.""" - import os import warnings diff --git a/smol/utils/exceptions.py b/smol/utils/exceptions.py index 02c4245b..7e1d6be1 100644 --- a/smol/utils/exceptions.py +++ b/smol/utils/exceptions.py @@ -1,6 +1,5 @@ """Definitions of specific exceptions raised elsewhere.""" - SYMMETRY_ERROR_MESSAGE = ( "Error in calculating symmetry operations." "Try using a more symmetrically refined input" diff --git a/tests/test_capp/test_solver/conftest.py b/tests/test_capp/test_solver/conftest.py index 36f6164b..e1ff643a 100644 --- a/tests/test_capp/test_solver/conftest.py +++ b/tests/test_capp/test_solver/conftest.py @@ -1,4 +1,5 @@ """Exotic cases where sub-lattices contains split and manually fixed sites.""" + from itertools import product import numpy as np diff --git a/tests/test_capp/test_solver/test_constraints.py b/tests/test_capp/test_solver/test_constraints.py index 803632f1..96f4469a 100644 --- a/tests/test_capp/test_solver/test_constraints.py +++ b/tests/test_capp/test_solver/test_constraints.py @@ -1,4 +1,5 @@ """Test constraints to the upper-bound problem.""" + import itertools import pytest diff --git a/tests/test_capp/test_solver/test_objectives.py b/tests/test_capp/test_solver/test_objectives.py index 195587d8..20162126 100644 --- a/tests/test_capp/test_solver/test_objectives.py +++ b/tests/test_capp/test_solver/test_objectives.py @@ -1,4 +1,5 @@ """Test objective functions generation.""" + import numpy as np import numpy.testing as npt diff --git a/tests/test_capp/test_solver/test_solver.py b/tests/test_capp/test_solver/test_solver.py index a3c797be..8f0e76e1 100644 --- a/tests/test_capp/test_solver/test_solver.py +++ b/tests/test_capp/test_solver/test_solver.py @@ -1,4 +1,5 @@ """Test groundstate class construction and usage.""" + from itertools import permutations, product import numpy as np diff --git a/tests/test_capp/test_solver/test_utils.py b/tests/test_capp/test_solver/test_utils.py index c1d96711..9f61b442 100644 --- a/tests/test_capp/test_solver/test_utils.py +++ b/tests/test_capp/test_solver/test_utils.py @@ -1,4 +1,5 @@ """Test utility functions for upper-bound.""" + from itertools import product import cvxpy as cp diff --git a/tests/test_capp/test_solver/test_variables.py b/tests/test_capp/test_solver/test_variables.py index 0abad535..a87abae8 100644 --- a/tests/test_capp/test_solver/test_variables.py +++ b/tests/test_capp/test_solver/test_variables.py @@ -1,4 +1,5 @@ """Test boolean variables' generation for upper-bound groundstate.""" + import numpy as np import numpy.testing as npt import pytest diff --git a/tests/test_cofe/test_basis.py b/tests/test_cofe/test_basis.py index 98b046f8..8e6e38d5 100644 --- a/tests/test_cofe/test_basis.py +++ b/tests/test_cofe/test_basis.py @@ -176,8 +176,8 @@ def test_sinusoid_basis(site_space): m = len(site_space) for n in range(1, len(site_space)): a = -(-n // 2) - f = ( - lambda s: -np.sin(2 * np.pi * a * s / m) + f = lambda s: ( + -np.sin(2 * np.pi * a * s / m) if n % 2 == 0 else -np.cos(2 * np.pi * a * s / m) ) diff --git a/tests/test_moca/test_constraint_utils.py b/tests/test_moca/test_constraint_utils.py index a91683ea..145b1d6d 100644 --- a/tests/test_moca/test_constraint_utils.py +++ b/tests/test_moca/test_constraint_utils.py @@ -1,4 +1,5 @@ """Test utilities for managing composition constraints.""" + import numpy.testing as npt import pytest from pymatgen.core import DummySpecies, Element, Species diff --git a/tests/test_moca/test_occu_utils.py b/tests/test_moca/test_occu_utils.py index d9b03228..2850c4b8 100644 --- a/tests/test_moca/test_occu_utils.py +++ b/tests/test_moca/test_occu_utils.py @@ -1,4 +1,5 @@ """Test smol.moca.utils.occu_utils.""" + import itertools import numpy as np diff --git a/tests/test_utils/test_math_utils.py b/tests/test_utils/test_math_utils.py index ba66eecc..3297dadc 100644 --- a/tests/test_utils/test_math_utils.py +++ b/tests/test_utils/test_math_utils.py @@ -1,4 +1,5 @@ """Test smol.moca.utils.math_utils.""" + from collections import Counter from fractions import Fraction From b699e49b74925b85a9c0284847d00b2f06333c74 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 30 Jan 2024 19:47:46 +0000 Subject: [PATCH 27/36] Bump pypa/cibuildwheel from 2.16.2 to 2.16.4 Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 2.16.2 to 2.16.4. - [Release notes](https://github.com/pypa/cibuildwheel/releases) - [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md) - [Commits](https://github.com/pypa/cibuildwheel/compare/v2.16.2...v2.16.4) --- updated-dependencies: - dependency-name: pypa/cibuildwheel dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 39dcc8e7..6ca609f0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,7 +33,7 @@ jobs: fetch-depth: 0 - name: Build wheels - uses: pypa/cibuildwheel@v2.16.2 + uses: pypa/cibuildwheel@v2.16.4 - uses: actions/upload-artifact@v4 with: @@ -92,7 +92,7 @@ jobs: echo "LDFLAGS="$LDFLAGS -Wl,-S -Wl,-rpath,$PREFIX/lib -L$PREFIX/lib -lomp"" >> "$GITHUB_ENV" - name: Build wheels - uses: pypa/cibuildwheel@v2.16.2 + uses: pypa/cibuildwheel@v2.16.4 - uses: actions/upload-artifact@v4 with: From 2bc13233909772b43ea46431d4f4be14881b5e4a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 17:50:30 +0000 Subject: [PATCH 28/36] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 24.1.0 → 24.1.1](https://github.com/psf/black/compare/24.1.0...24.1.1) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a9816f36..fe9e85c8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ repos: args: ['--maxkb=600'] - repo: https://github.com/psf/black - rev: 24.1.0 + rev: 24.1.1 hooks: - id: black From 00fe594696ae0317ccd04b3d16675da1000feb2e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 19:50:07 +0000 Subject: [PATCH 29/36] Bump pypa/cibuildwheel from 2.16.4 to 2.16.5 Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 2.16.4 to 2.16.5. - [Release notes](https://github.com/pypa/cibuildwheel/releases) - [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md) - [Commits](https://github.com/pypa/cibuildwheel/compare/v2.16.4...v2.16.5) --- updated-dependencies: - dependency-name: pypa/cibuildwheel dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6ca609f0..a99c0c4d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,7 +33,7 @@ jobs: fetch-depth: 0 - name: Build wheels - uses: pypa/cibuildwheel@v2.16.4 + uses: pypa/cibuildwheel@v2.16.5 - uses: actions/upload-artifact@v4 with: @@ -92,7 +92,7 @@ jobs: echo "LDFLAGS="$LDFLAGS -Wl,-S -Wl,-rpath,$PREFIX/lib -L$PREFIX/lib -lomp"" >> "$GITHUB_ENV" - name: Build wheels - uses: pypa/cibuildwheel@v2.16.4 + uses: pypa/cibuildwheel@v2.16.5 - uses: actions/upload-artifact@v4 with: From a4f6096c572c6e85fa604b885a2f674a828b80f0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 19:50:10 +0000 Subject: [PATCH 30/36] Bump peter-evans/create-pull-request from 5.0.2 to 6.0.0 Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 5.0.2 to 6.0.0. - [Release notes](https://github.com/peter-evans/create-pull-request/releases) - [Commits](https://github.com/peter-evans/create-pull-request/compare/v5.0.2...v6.0.0) --- updated-dependencies: - dependency-name: peter-evans/create-pull-request dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/update-precommit.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-precommit.yaml b/.github/workflows/update-precommit.yaml index 04b262c8..dfc4650c 100644 --- a/.github/workflows/update-precommit.yaml +++ b/.github/workflows/update-precommit.yaml @@ -23,7 +23,7 @@ jobs: run: pre-commit autoupdate - name: Create Pull Request - uses: peter-evans/create-pull-request@v5.0.2 + uses: peter-evans/create-pull-request@v6.0.0 with: token: ${{ secrets.GITHUB_TOKEN }} branch: update/pre-commit-autoupdate From 965c8fb46082cce45c61148e97bb24dbacf27ac9 Mon Sep 17 00:00:00 2001 From: lbluque Date: Wed, 14 Feb 2024 00:14:51 +0000 Subject: [PATCH 31/36] auto-update pre-commit hooks --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a9816f36..5adfdd06 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ repos: args: ['--maxkb=600'] - repo: https://github.com/psf/black - rev: 24.1.0 + rev: 24.2.0 hooks: - id: black From 831514e8bbb417717078ca54b7367085f4a8c02f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 19:55:57 +0000 Subject: [PATCH 32/36] Bump peter-evans/create-pull-request from 6.0.0 to 6.0.1 Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 6.0.0 to 6.0.1. - [Release notes](https://github.com/peter-evans/create-pull-request/releases) - [Commits](https://github.com/peter-evans/create-pull-request/compare/v6.0.0...v6.0.1) --- updated-dependencies: - dependency-name: peter-evans/create-pull-request dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/update-precommit.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-precommit.yaml b/.github/workflows/update-precommit.yaml index dfc4650c..3da0a747 100644 --- a/.github/workflows/update-precommit.yaml +++ b/.github/workflows/update-precommit.yaml @@ -23,7 +23,7 @@ jobs: run: pre-commit autoupdate - name: Create Pull Request - uses: peter-evans/create-pull-request@v6.0.0 + uses: peter-evans/create-pull-request@v6.0.1 with: token: ${{ secrets.GITHUB_TOKEN }} branch: update/pre-commit-autoupdate From a7cdd90a1a9949a0c54577904118ed9dbfa46fd3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 19:17:30 +0000 Subject: [PATCH 33/36] Bump peter-evans/create-pull-request from 6.0.1 to 6.0.2 Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 6.0.1 to 6.0.2. - [Release notes](https://github.com/peter-evans/create-pull-request/releases) - [Commits](https://github.com/peter-evans/create-pull-request/compare/v6.0.1...v6.0.2) --- updated-dependencies: - dependency-name: peter-evans/create-pull-request dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/update-precommit.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-precommit.yaml b/.github/workflows/update-precommit.yaml index 3da0a747..bd138b24 100644 --- a/.github/workflows/update-precommit.yaml +++ b/.github/workflows/update-precommit.yaml @@ -23,7 +23,7 @@ jobs: run: pre-commit autoupdate - name: Create Pull Request - uses: peter-evans/create-pull-request@v6.0.1 + uses: peter-evans/create-pull-request@v6.0.2 with: token: ${{ secrets.GITHUB_TOKEN }} branch: update/pre-commit-autoupdate From 0ca30c8029fcad169ed42c8576a657101c3e0c4b Mon Sep 17 00:00:00 2001 From: lbluque <9788715+lbluque@users.noreply.github.com> Date: Thu, 28 Mar 2024 00:15:19 +0000 Subject: [PATCH 34/36] auto-update pre-commit hooks --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5adfdd06..8c518bdb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ repos: args: ['--maxkb=600'] - repo: https://github.com/psf/black - rev: 24.2.0 + rev: 24.3.0 hooks: - id: black @@ -38,13 +38,13 @@ repos: - --profile=black - repo: https://github.com/asottile/pyupgrade - rev: v3.15.0 + rev: v3.15.2 hooks: - id: pyupgrade args: [--py38-plus] - repo: https://github.com/PyCQA/autoflake - rev: v2.2.1 + rev: v2.3.1 hooks: - id: autoflake args: From f6b75009654cc2ceb0483a1be45aa74f48975ed9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Apr 2024 01:12:16 +0000 Subject: [PATCH 35/36] Bump pypa/cibuildwheel from 2.16.5 to 2.17.0 Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 2.16.5 to 2.17.0. - [Release notes](https://github.com/pypa/cibuildwheel/releases) - [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md) - [Commits](https://github.com/pypa/cibuildwheel/compare/v2.16.5...v2.17.0) --- updated-dependencies: - dependency-name: pypa/cibuildwheel dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a99c0c4d..85c8eb14 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,7 +33,7 @@ jobs: fetch-depth: 0 - name: Build wheels - uses: pypa/cibuildwheel@v2.16.5 + uses: pypa/cibuildwheel@v2.17.0 - uses: actions/upload-artifact@v4 with: @@ -92,7 +92,7 @@ jobs: echo "LDFLAGS="$LDFLAGS -Wl,-S -Wl,-rpath,$PREFIX/lib -L$PREFIX/lib -lomp"" >> "$GITHUB_ENV" - name: Build wheels - uses: pypa/cibuildwheel@v2.16.5 + uses: pypa/cibuildwheel@v2.17.0 - uses: actions/upload-artifact@v4 with: From 00d493d7e59b4fb2a146bc5ece7d7788e283b83b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 19:34:09 +0000 Subject: [PATCH 36/36] Bump h5py from 3.10.0 to 3.11.0 Bumps [h5py](https://github.com/h5py/h5py) from 3.10.0 to 3.11.0. - [Release notes](https://github.com/h5py/h5py/releases) - [Changelog](https://github.com/h5py/h5py/blob/master/docs/release_guide.rst) - [Commits](https://github.com/h5py/h5py/compare/3.10.0...3.11.0) --- updated-dependencies: - dependency-name: h5py dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- binder/requirements.txt | 2 +- requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/binder/requirements.txt b/binder/requirements.txt index 0a65968c..1359d92d 100644 --- a/binder/requirements.txt +++ b/binder/requirements.txt @@ -3,5 +3,5 @@ numpy>=1.20.1 monty==2023.9.25 pymatgen==2023.8.10 scikit-learn==1.3.2 -h5py==3.10.0 +h5py==3.11.0 crystal_toolkit diff --git a/requirements.txt b/requirements.txt index 8df40e0b..d907ff7b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ numpy==1.24.4 monty==2023.9.25 pymatgen==2023.9.10 -h5py==3.10.0 +h5py==3.11.0