AdsorPy 1.0.2__tar.gz → 1.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {adsorpy-1.0.2 → adsorpy-1.0.3}/.github/workflows/docs-ci.yml +1 -1
- {adsorpy-1.0.2 → adsorpy-1.0.3}/.github/workflows/publish_to_PyPI.yml +2 -2
- {adsorpy-1.0.2 → adsorpy-1.0.3}/.github/workflows/tests-ci.yml +1 -1
- adsorpy-1.0.3/CHANGELOG.md +57 -0
- {adsorpy-1.0.2 → adsorpy-1.0.3}/PKG-INFO +16 -3
- {adsorpy-1.0.2 → adsorpy-1.0.3}/pyproject.toml +40 -6
- {adsorpy-1.0.2 → adsorpy-1.0.3}/requirements.txt +2 -2
- {adsorpy-1.0.2 → adsorpy-1.0.3}/requirements_dev.txt +2 -2
- adsorpy-1.0.3/src/adsorpy/__init__.py +17 -0
- {adsorpy-1.0.2 → adsorpy-1.0.3}/src/adsorpy/molecule_lib.py +49 -50
- {adsorpy-1.0.2 → adsorpy-1.0.3}/src/adsorpy/randomsequentialadsorption.py +32 -29
- {adsorpy-1.0.2 → adsorpy-1.0.3}/src/adsorpy/rsa_calculator.py +15 -11
- {adsorpy-1.0.2 → adsorpy-1.0.3}/src/adsorpy/rsa_config.py +1 -2
- {adsorpy-1.0.2 → adsorpy-1.0.3}/src/adsorpy/run_simulation.py +122 -101
- {adsorpy-1.0.2 → adsorpy-1.0.3}/tests/rsa_test.py +4 -13
- {adsorpy-1.0.2 → adsorpy-1.0.3}/tests/run_simulation_test.py +60 -18
- adsorpy-1.0.2/CHANGELOG.md +0 -34
- adsorpy-1.0.2/tests/__init__.py +0 -0
- {adsorpy-1.0.2 → adsorpy-1.0.3}/LICENSE.md +0 -0
- {adsorpy-1.0.2 → adsorpy-1.0.3}/README.md +0 -0
- {adsorpy-1.0.2 → adsorpy-1.0.3}/docs/Makefile +0 -0
- {adsorpy-1.0.2 → adsorpy-1.0.3}/docs/make.bat +0 -0
- {adsorpy-1.0.2 → adsorpy-1.0.3}/docs/source/adsorpy.molecule_lib.rst +0 -0
- {adsorpy-1.0.2 → adsorpy-1.0.3}/docs/source/adsorpy.randomsequentialadsorption.rst +0 -0
- {adsorpy-1.0.2 → adsorpy-1.0.3}/docs/source/adsorpy.rsa_calculator.rst +0 -0
- {adsorpy-1.0.2 → adsorpy-1.0.3}/docs/source/adsorpy.rsa_config.rst +0 -0
- {adsorpy-1.0.2 → adsorpy-1.0.3}/docs/source/adsorpy.rst +0 -0
- {adsorpy-1.0.2 → adsorpy-1.0.3}/docs/source/adsorpy.run_simulation.rst +0 -0
- {adsorpy-1.0.2 → adsorpy-1.0.3}/docs/source/conf.py +0 -0
- {adsorpy-1.0.2 → adsorpy-1.0.3}/docs/source/index.rst +0 -0
- {adsorpy-1.0.2 → adsorpy-1.0.3}/docs/source/modules.rst +0 -0
- {adsorpy-1.0.2 → adsorpy-1.0.3}/images/AdsorPy_Covered_Surface.png +0 -0
- {adsorpy-1.0.2 → adsorpy-1.0.3}/py.typed +0 -0
- {adsorpy-1.0.2 → adsorpy-1.0.3}/src/__init__.py +0 -0
- {adsorpy-1.0.2 → adsorpy-1.0.3}/src/__main__.py +0 -0
- {adsorpy-1.0.2 → adsorpy-1.0.3}/src/adsorpy/VdW_Radii.csv +0 -0
- {adsorpy-1.0.2 → adsorpy-1.0.3}/src/adsorpy/config.json +0 -0
- {adsorpy-1.0.2 → adsorpy-1.0.3}/src/adsorpy/molecule_colour.json +0 -0
- {adsorpy-1.0.2/src/adsorpy → adsorpy-1.0.3/tests}/__init__.py +0 -0
- {adsorpy-1.0.2 → adsorpy-1.0.3}/tests/test_data/config_test_hard.json +0 -0
- {adsorpy-1.0.2 → adsorpy-1.0.3}/tests/test_data/config_test_periodic.json +0 -0
- {adsorpy-1.0.2 → adsorpy-1.0.3}/tests/test_data/config_test_soft.json +0 -0
- {adsorpy-1.0.2 → adsorpy-1.0.3}/tox.ini +0 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
All important changes to ``AdsorPy`` will be documented in this file.
|
|
3
|
+
|
|
4
|
+
This format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
5
|
+
|
|
6
|
+
## [unreleased]
|
|
7
|
+
### Added
|
|
8
|
+
### Changed
|
|
9
|
+
### Fixed
|
|
10
|
+
### Removed
|
|
11
|
+
|
|
12
|
+
## 1.0.3 - 2026-04-28
|
|
13
|
+
### Added
|
|
14
|
+
- Add the ``Simulator`` class as 6th return value of ``run_simulation()``.
|
|
15
|
+
- Add overlap and gap size subtests to the dosing scheme tests of ``run_simulation_test``.
|
|
16
|
+
- Add ``__version__``, ``__name__``, ``__author__``, and ``__author_email__`` to ``__init__.py``.
|
|
17
|
+
### Changed
|
|
18
|
+
- Update CI action/deploy-pages to v5. Update CI action/upload-artifact to v7.
|
|
19
|
+
- Move overlap and gap size test for alt simulation to subtests.
|
|
20
|
+
- Update dependency versions.
|
|
21
|
+
### Fixed
|
|
22
|
+
- Fix ``pyproject.toml``: ``"AdsorPy" = ["py.typed"]`` (from ``rsa-mc``, the old internal project name.)
|
|
23
|
+
- Turn relative imports into absolute imports to make the package pip-installable.
|
|
24
|
+
- Fix the type hints that broke as a result of this.
|
|
25
|
+
- Update ``pyproject.toml`` to have the appropriate keywords and classifiers. The project does not show up on the PyPI index but can be installed from it.
|
|
26
|
+
### Removed
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## 1.0.2 - 2026-04-23
|
|
30
|
+
|
|
31
|
+
### Added
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
- Update CI actions to move from ``node.js`` 20 to 24.
|
|
35
|
+
|
|
36
|
+
### Fixed
|
|
37
|
+
|
|
38
|
+
### Removed
|
|
39
|
+
- Remove unnecessary type casts.
|
|
40
|
+
|
|
41
|
+
## 1.0.1 - 2026-04-23
|
|
42
|
+
|
|
43
|
+
### Added
|
|
44
|
+
- Implement subtests for the test_run_alt (a test for the RSA simulator on an alternative seed).
|
|
45
|
+
- Add a determinism test to show identical outcome for identical seeds.
|
|
46
|
+
- In ``tool.ruff.lint``: use ``future-annotations = true``, this correctly checks ``__future__`` annotation.
|
|
47
|
+
### Changed
|
|
48
|
+
- Update version dependencies.
|
|
49
|
+
- Strengthen seed comparison test.
|
|
50
|
+
- Vectorise (remove a for-loop) from overlap test.
|
|
51
|
+
|
|
52
|
+
### Fixed
|
|
53
|
+
|
|
54
|
+
### Removed
|
|
55
|
+
|
|
56
|
+
## 1.0.0 - 2025-11-29
|
|
57
|
+
- Full release
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
|
-
Name:
|
|
3
|
-
Version: 1.0.
|
|
2
|
+
Name: adsorpy
|
|
3
|
+
Version: 1.0.3
|
|
4
4
|
Summary: Random sequential adsorption (RSA) simulation, 2D lattice-based.
|
|
5
5
|
Project-URL: Repository, https://github.com/JoostFWMaas/AdsorPy
|
|
6
6
|
Project-URL: Documentation, https://joostfwmaas.github.io/AdsorPy
|
|
@@ -8,14 +8,27 @@ Project-URL: Changelog, https://github.com/JoostFWMaas/AdsorPy/blob/main/CHANGEL
|
|
|
8
8
|
Author-email: "J.F.W. Maas" <j.f.w.maas@tue.nl>
|
|
9
9
|
License-Expression: MIT
|
|
10
10
|
License-File: LICENSE.md
|
|
11
|
+
Keywords: Monte Carlo,RSA,adsorption,computational chemistry,computational physics,coverage,gap size distribution,jamming,lattice model,molecular adsorption,packing,random sequential adsorption,statistical mechanics,stochastic simulation,surface science
|
|
11
12
|
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Natural Language :: English
|
|
12
17
|
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python
|
|
13
19
|
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
14
21
|
Classifier: Programming Language :: Python :: 3.10
|
|
15
22
|
Classifier: Programming Language :: Python :: 3.11
|
|
16
23
|
Classifier: Programming Language :: Python :: 3.12
|
|
17
24
|
Classifier: Programming Language :: Python :: 3.13
|
|
18
25
|
Classifier: Programming Language :: Python :: 3.14
|
|
26
|
+
Classifier: Topic :: Scientific/Engineering
|
|
27
|
+
Classifier: Topic :: Scientific/Engineering :: Chemistry
|
|
28
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
29
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
30
|
+
Classifier: Topic :: Software Development
|
|
31
|
+
Classifier: Typing :: Typed
|
|
19
32
|
Requires-Python: >=3.10
|
|
20
33
|
Requires-Dist: matplotlib
|
|
21
34
|
Requires-Dist: numba
|
|
@@ -29,7 +42,7 @@ Requires-Dist: pytest; extra == 'testing'
|
|
|
29
42
|
Requires-Dist: pytest-cov; extra == 'testing'
|
|
30
43
|
Requires-Dist: ruff; extra == 'testing'
|
|
31
44
|
Requires-Dist: scipy==1.15.3; (python_version <= '3.10') and extra == 'testing'
|
|
32
|
-
Requires-Dist: scipy
|
|
45
|
+
Requires-Dist: scipy>=1.16.3; (python_version > '3.10') and extra == 'testing'
|
|
33
46
|
Description-Content-Type: text/markdown
|
|
34
47
|
|
|
35
48
|
# AdsorPy
|
|
@@ -3,8 +3,9 @@ requires = ["hatchling"]
|
|
|
3
3
|
build-backend = "hatchling.build"
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
|
-
name = "
|
|
7
|
-
|
|
6
|
+
name = "adsorpy"
|
|
7
|
+
#dynamic = ["version"] # The Python guide says that this will use the Git tag to fill it in.
|
|
8
|
+
version = "1.0.3" # The Python guide says that this will use the Git tag to fill it in.
|
|
8
9
|
description = "Random sequential adsorption (RSA) simulation, 2D lattice-based."
|
|
9
10
|
authors = [{ name = "J.F.W. Maas", email = "j.f.w.maas@tue.nl" }]
|
|
10
11
|
readme = "README.md"
|
|
@@ -12,17 +13,51 @@ requires-python = ">=3.10"
|
|
|
12
13
|
license = "MIT"
|
|
13
14
|
license-files = ["LICEN[CS]E.md"]
|
|
14
15
|
classifiers = [
|
|
16
|
+
# Project maturity:
|
|
15
17
|
"Development Status :: 5 - Production/Stable",
|
|
16
|
-
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Typing :: Typed",
|
|
20
|
+
"Natural Language :: English",
|
|
21
|
+
|
|
22
|
+
# Intended users of project:
|
|
23
|
+
"Intended Audience :: Developers",
|
|
24
|
+
"Intended Audience :: Science/Research",
|
|
25
|
+
"Topic :: Software Development",
|
|
26
|
+
"Topic :: Scientific/Engineering",
|
|
27
|
+
"Topic :: Scientific/Engineering :: Chemistry",
|
|
28
|
+
"Topic :: Scientific/Engineering :: Mathematics",
|
|
29
|
+
"Topic :: Scientific/Engineering :: Physics",
|
|
30
|
+
|
|
31
|
+
# Supported Python versions:
|
|
32
|
+
"Programming Language :: Python",
|
|
17
33
|
"Programming Language :: Python :: 3",
|
|
34
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
18
35
|
"Programming Language :: Python :: 3.10",
|
|
19
36
|
"Programming Language :: Python :: 3.11",
|
|
20
37
|
"Programming Language :: Python :: 3.12",
|
|
21
38
|
"Programming Language :: Python :: 3.13",
|
|
22
39
|
"Programming Language :: Python :: 3.14",
|
|
23
40
|
|
|
41
|
+
# This does not run on mobile because of Shapely.
|
|
24
42
|
"Operating System :: OS Independent",
|
|
25
43
|
]
|
|
44
|
+
keywords = [
|
|
45
|
+
"RSA",
|
|
46
|
+
"random sequential adsorption",
|
|
47
|
+
"adsorption",
|
|
48
|
+
"surface science",
|
|
49
|
+
"Monte Carlo",
|
|
50
|
+
"lattice model",
|
|
51
|
+
"statistical mechanics",
|
|
52
|
+
"packing",
|
|
53
|
+
"jamming",
|
|
54
|
+
"molecular adsorption",
|
|
55
|
+
"coverage",
|
|
56
|
+
"computational chemistry",
|
|
57
|
+
"computational physics",
|
|
58
|
+
"stochastic simulation",
|
|
59
|
+
"gap size distribution"
|
|
60
|
+
]
|
|
26
61
|
dependencies = [
|
|
27
62
|
"numpy",
|
|
28
63
|
"numba",
|
|
@@ -45,12 +80,12 @@ testing = [
|
|
|
45
80
|
"mypy",
|
|
46
81
|
"ruff",
|
|
47
82
|
"scipy==1.15.3; python_version <= '3.10'",
|
|
48
|
-
"scipy
|
|
83
|
+
"scipy>=1.16.3; python_version > '3.10'",
|
|
49
84
|
]
|
|
50
85
|
|
|
51
86
|
|
|
52
87
|
[tool.hatch.package_data]
|
|
53
|
-
"
|
|
88
|
+
"AdsorPy" = ["py.typed"]
|
|
54
89
|
|
|
55
90
|
[tool.pytest.ini_options]
|
|
56
91
|
testpaths = ["tests"]
|
|
@@ -93,7 +128,6 @@ exclude_also = [
|
|
|
93
128
|
mypy_path = ["src", "optional"]
|
|
94
129
|
ignore_missing_imports = true
|
|
95
130
|
strict = true
|
|
96
|
-
#no_implicit_reexport = true
|
|
97
131
|
disallow_any_explicit = true
|
|
98
132
|
#disallow_any_decorated = true # Throws an error because geo.Polygon in a tuple is turned into Any for the @staticmethod.
|
|
99
133
|
#warn_unreachable = true # Set this to true when pushing to main?
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from importlib.metadata import PackageNotFoundError, metadata
|
|
3
|
+
|
|
4
|
+
try: # This only works when running as a package.
|
|
5
|
+
meta = metadata(__package__ or __name__)
|
|
6
|
+
except PackageNotFoundError: # For development, this will trigger instead.
|
|
7
|
+
meta = metadata("adsorpy")
|
|
8
|
+
|
|
9
|
+
__name__ = meta["Name"]
|
|
10
|
+
__version__ = meta["Version"]
|
|
11
|
+
|
|
12
|
+
author_and_email = meta["Author-email"]
|
|
13
|
+
name = re.search(r'"([^"]*)"', author_and_email)
|
|
14
|
+
email = re.search(r'<([^"]*)>', author_and_email)
|
|
15
|
+
|
|
16
|
+
__author__ = name[1] if name is not None else name
|
|
17
|
+
__author_email__ = email[1] if email is not None else email
|
|
@@ -58,7 +58,6 @@ GeoArray = np.ndarray[tuple[int], np.dtype[Polygon]]
|
|
|
58
58
|
FloatArray = NDArray[np.float64]
|
|
59
59
|
RotMatrix = np.ndarray[tuple[Literal[3], Literal[3]], np.dtype[np.float64]]
|
|
60
60
|
|
|
61
|
-
|
|
62
61
|
# Van der Waals radii of atoms. Source: https://doi.org/10.1039/C3DT50599E
|
|
63
62
|
current_dir_file = Path(__file__).parent / "VdW_Radii.csv"
|
|
64
63
|
RADII: dict[str, float] = dict(
|
|
@@ -72,9 +71,9 @@ RADII: dict[str, float] = dict(
|
|
|
72
71
|
|
|
73
72
|
|
|
74
73
|
def discorectangle(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
params: list[float],
|
|
75
|
+
offx: float = 0.0,
|
|
76
|
+
offy: float = 0.0,
|
|
78
77
|
) -> Polygon:
|
|
79
78
|
"""Create a discorectangle using the union of two circles and a rectangle.
|
|
80
79
|
|
|
@@ -107,10 +106,10 @@ def discorectangle(
|
|
|
107
106
|
|
|
108
107
|
|
|
109
108
|
def circulium(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
109
|
+
radius: float,
|
|
110
|
+
x_offset: float = 0.0,
|
|
111
|
+
y_offset: float = 0.0,
|
|
112
|
+
quad_segs: int = 8,
|
|
114
113
|
) -> Polygon:
|
|
115
114
|
"""Create a simple circular polygon.
|
|
116
115
|
|
|
@@ -144,9 +143,9 @@ def dogbonium(scale: float = 1) -> Polygon:
|
|
|
144
143
|
|
|
145
144
|
|
|
146
145
|
def polygonium(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
146
|
+
verts: int = 3,
|
|
147
|
+
scale: float = 1.0,
|
|
148
|
+
roundedness: float = 0.0,
|
|
150
149
|
) -> Polygon:
|
|
151
150
|
"""Create a simple regular polygon with optional rounding.
|
|
152
151
|
|
|
@@ -174,16 +173,16 @@ def polygonium(
|
|
|
174
173
|
|
|
175
174
|
|
|
176
175
|
def xyz_reader(
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
176
|
+
file_name: str | Path,
|
|
177
|
+
ignore_atoms: str | list[str] | None = None,
|
|
178
|
+
x_offset: float = 0.0,
|
|
179
|
+
y_offset: float = 0.0,
|
|
180
|
+
roll: float = 0.0,
|
|
181
|
+
pitch: float = 0.0,
|
|
182
|
+
yaw: float = 0.0,
|
|
183
|
+
z_trim: float | None = None,
|
|
184
|
+
# *args: P.args,
|
|
185
|
+
# **kwargs: P.kwargs,
|
|
187
186
|
) -> Polygon:
|
|
188
187
|
"""Read files in the xyz format of VASP.
|
|
189
188
|
|
|
@@ -238,15 +237,15 @@ def xyz_reader(
|
|
|
238
237
|
|
|
239
238
|
|
|
240
239
|
def first_time_loader( # noqa: PLR0915
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
240
|
+
file_name: str | Path,
|
|
241
|
+
ignore_atoms: str | list[str] | None = None,
|
|
242
|
+
x_offset: float | None = None,
|
|
243
|
+
y_offset: float | None = None,
|
|
244
|
+
roll: float | None = None,
|
|
245
|
+
pitch: float | None = None,
|
|
246
|
+
yaw: float | None = None,
|
|
247
|
+
z_trim: float | None = None,
|
|
248
|
+
reference_lattice_spacing: float = 4.74,
|
|
250
249
|
) -> InDict:
|
|
251
250
|
"""Script to run when you first load the molecule. Shows the molecule in xy, zy, and xz perspective, and vdwaals.
|
|
252
251
|
|
|
@@ -463,23 +462,23 @@ def first_time_loader( # noqa: PLR0915
|
|
|
463
462
|
|
|
464
463
|
|
|
465
464
|
def _update( # noqa: PLR0913
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
465
|
+
val: float,
|
|
466
|
+
ang_x: Slider,
|
|
467
|
+
ang_y: Slider,
|
|
468
|
+
ang_z: Slider,
|
|
469
|
+
translate_x: Slider,
|
|
470
|
+
translate_y: Slider,
|
|
471
|
+
box_x: TextBox,
|
|
472
|
+
box_y: TextBox,
|
|
473
|
+
box_z: TextBox,
|
|
474
|
+
box_xoff: TextBox,
|
|
475
|
+
box_yoff: TextBox,
|
|
476
|
+
atompos: FloatArray,
|
|
477
|
+
axs: list[axes.Axes],
|
|
478
|
+
fig: figure.Figure,
|
|
479
|
+
atomcolours: NDArray[np.str_],
|
|
480
|
+
atomkeys: NDArray[np.str_],
|
|
481
|
+
reference_lattice_spacing: float,
|
|
483
482
|
) -> None:
|
|
484
483
|
roll = ang_z.val
|
|
485
484
|
pitch = ang_y.val
|
|
@@ -604,9 +603,9 @@ def _update( # noqa: PLR0913
|
|
|
604
603
|
|
|
605
604
|
|
|
606
605
|
def _initialise_reader(
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
606
|
+
file_name: str | Path,
|
|
607
|
+
ignore_atoms: str | list[str] | None = None,
|
|
608
|
+
z_trim: float | None = None,
|
|
610
609
|
) -> tuple[np.ndarray[tuple[int], np.dtype[np.str_]], np.ndarray[tuple[int, Literal[3]], np.dtype[np.float64]]]:
|
|
611
610
|
"""Initialise the xyz_reader and first_time_loader.
|
|
612
611
|
|
|
@@ -12,21 +12,23 @@ from pathlib import Path
|
|
|
12
12
|
from typing import TYPE_CHECKING, Final, Literal, ParamSpec, cast
|
|
13
13
|
|
|
14
14
|
import numpy as np # For vectorised computations (performed in C).
|
|
15
|
-
import rsa_calculator as calc # Library for calculation functions. Used to be static methods.
|
|
16
15
|
import shapely.affinity as aff
|
|
17
16
|
from matplotlib import pyplot as plt # Plotting.
|
|
18
17
|
from matplotlib.collections import PatchCollection, PolyCollection # To make pointers.
|
|
19
18
|
from matplotlib.patches import CirclePolygon, Rectangle
|
|
20
19
|
from numpy.typing import NDArray
|
|
21
|
-
from rsa_config import RsaConfig # noqa: TC002 # Config of the simulation.
|
|
22
20
|
from rtree.index import Index, Property # RTree, helps lookups!
|
|
23
21
|
from shapely import MultiPoint, Point, Polygon, STRtree, box, contains_xy, prepare
|
|
24
22
|
from shapely.prepared import PreparedGeometry # For vectorised inclusion checks.
|
|
25
23
|
|
|
24
|
+
import src.adsorpy.rsa_calculator as calc # Library for calculation functions. Used to be static methods.
|
|
25
|
+
|
|
26
26
|
if TYPE_CHECKING:
|
|
27
27
|
from matplotlib.axes import Axes
|
|
28
28
|
from matplotlib.figure import Figure
|
|
29
29
|
|
|
30
|
+
from src.adsorpy.rsa_config import RsaConfig # Config of the simulation.
|
|
31
|
+
|
|
30
32
|
plt.rcParams.update(
|
|
31
33
|
{
|
|
32
34
|
"font.size": 20,
|
|
@@ -170,7 +172,7 @@ class BoundaryParameters:
|
|
|
170
172
|
"A counter for the molecules + mirror molecules."
|
|
171
173
|
self.mirrors: IdxArray = np.empty(0, dtype=np.int_)
|
|
172
174
|
"Mirror indices."
|
|
173
|
-
self.biggest_radius:
|
|
175
|
+
self.biggest_radius: float = dbl_max_radius
|
|
174
176
|
"The biggest radius between the two largest molecules in the simulation."
|
|
175
177
|
self.tree: STRtree = STRtree([Point()]) # TODO: Figure out whether faster.
|
|
176
178
|
"STRtree, currently unused."
|
|
@@ -332,14 +334,14 @@ class MoleculeGroup:
|
|
|
332
334
|
|
|
333
335
|
self.config: Final[Config] = Config(
|
|
334
336
|
rsa_config=rsa_config,
|
|
335
|
-
sites=rsa_config.get_value("sites", required=False),
|
|
336
|
-
xsize=rsa_config.get_value("xsize", required=False),
|
|
337
|
-
ysize=rsa_config.get_value("ysize", required=False),
|
|
338
|
-
zsize=rsa_config.get_value("zsize", required=False),
|
|
339
|
-
max_molecule_count=rsa_config.get_value("max_molecule_count"),
|
|
340
|
-
lattice_a=rsa_config.get_value("lattice_a"),
|
|
341
|
-
boundary_type=rsa_config.get_value("boundary_type"),
|
|
342
|
-
sticking_probability=rsa_config.get_value("sticking_probability"),
|
|
337
|
+
sites=rsa_config.get_value("sites", required=False), # type: ignore[arg-type]
|
|
338
|
+
xsize=rsa_config.get_value("xsize", required=False), # type: ignore[arg-type]
|
|
339
|
+
ysize=rsa_config.get_value("ysize", required=False), # type: ignore[arg-type]
|
|
340
|
+
zsize=rsa_config.get_value("zsize", required=False), # type: ignore[arg-type]
|
|
341
|
+
max_molecule_count=rsa_config.get_value("max_molecule_count"), # type: ignore[arg-type]
|
|
342
|
+
lattice_a=rsa_config.get_value("lattice_a"), # type: ignore[arg-type]
|
|
343
|
+
boundary_type=rsa_config.get_value("boundary_type"), # type: ignore[arg-type]
|
|
344
|
+
sticking_probability=rsa_config.get_value("sticking_probability"), # type: ignore[arg-type]
|
|
343
345
|
)
|
|
344
346
|
"Config values."
|
|
345
347
|
|
|
@@ -558,14 +560,14 @@ class Simulator:
|
|
|
558
560
|
"""
|
|
559
561
|
self.config: Final[Config] = Config(
|
|
560
562
|
rsa_config=rsa_config,
|
|
561
|
-
sites=rsa_config.get_value("sites", required=False),
|
|
562
|
-
xsize=rsa_config.get_value("xsize", required=False),
|
|
563
|
-
ysize=rsa_config.get_value("ysize", required=False),
|
|
564
|
-
zsize=rsa_config.get_value("zsize", required=False),
|
|
565
|
-
max_molecule_count=rsa_config.get_value("max_molecule_count"),
|
|
566
|
-
lattice_a=rsa_config.get_value("lattice_a"),
|
|
567
|
-
boundary_type=rsa_config.get_value("boundary_type") if boundary_type is None else boundary_type,
|
|
568
|
-
sticking_probability=rsa_config.get_value("sticking_probability"),
|
|
563
|
+
sites=rsa_config.get_value("sites", required=False), # type: ignore[arg-type]
|
|
564
|
+
xsize=rsa_config.get_value("xsize", required=False), # type: ignore[arg-type]
|
|
565
|
+
ysize=rsa_config.get_value("ysize", required=False), # type: ignore[arg-type]
|
|
566
|
+
zsize=rsa_config.get_value("zsize", required=False), # type: ignore[arg-type]
|
|
567
|
+
max_molecule_count=rsa_config.get_value("max_molecule_count"), # type: ignore[arg-type]
|
|
568
|
+
lattice_a=rsa_config.get_value("lattice_a"), # type: ignore[arg-type]
|
|
569
|
+
boundary_type=rsa_config.get_value("boundary_type") if boundary_type is None else boundary_type, # type: ignore[arg-type]
|
|
570
|
+
sticking_probability=rsa_config.get_value("sticking_probability"), # type: ignore[arg-type]
|
|
569
571
|
)
|
|
570
572
|
"Config values."
|
|
571
573
|
|
|
@@ -1025,7 +1027,7 @@ class Simulator:
|
|
|
1025
1027
|
self,
|
|
1026
1028
|
surf: Surface,
|
|
1027
1029
|
*molgrs: MoleculeGroup,
|
|
1028
|
-
weights: FloatArray | None = None,
|
|
1030
|
+
weights: FloatArray | list[float] | None = None,
|
|
1029
1031
|
) -> tuple[bool, int, int, int, int, list[int]]:
|
|
1030
1032
|
"""Pick from a list of molecule groups and places a random one.
|
|
1031
1033
|
|
|
@@ -1035,6 +1037,7 @@ class Simulator:
|
|
|
1035
1037
|
|
|
1036
1038
|
:return: The output of Simulator.attempt_place_molecule().
|
|
1037
1039
|
"""
|
|
1040
|
+
weights = np.array(weights) if weights is not None else None
|
|
1038
1041
|
distribution = None if weights is None or len(weights) != len(molgrs) else weights / np.sum(weights)
|
|
1039
1042
|
return self.attempt_place_molecule(
|
|
1040
1043
|
surf,
|
|
@@ -1078,7 +1081,7 @@ class Simulator:
|
|
|
1078
1081
|
|
|
1079
1082
|
# Removes all gaps of 0. distance (in a molecule). Basically removes all inaccessible/occupied sites.
|
|
1080
1083
|
if not keepzero:
|
|
1081
|
-
distance_to_grid =
|
|
1084
|
+
distance_to_grid = distance_to_grid[np.nonzero(distance_to_grid)]
|
|
1082
1085
|
|
|
1083
1086
|
return distance_to_grid
|
|
1084
1087
|
|
|
@@ -1127,14 +1130,14 @@ class Surface:
|
|
|
1127
1130
|
"""
|
|
1128
1131
|
self.config: Final[Config] = Config(
|
|
1129
1132
|
rsa_config=rsa_config,
|
|
1130
|
-
sites=rsa_config.get_value("sites", required=False),
|
|
1131
|
-
xsize=rsa_config.get_value("xsize", required=False),
|
|
1132
|
-
ysize=rsa_config.get_value("ysize", required=False),
|
|
1133
|
-
zsize=rsa_config.get_value("zsize", required=False),
|
|
1134
|
-
max_molecule_count=rsa_config.get_value("max_molecule_count"),
|
|
1135
|
-
lattice_a=rsa_config.get_value("lattice_a"),
|
|
1136
|
-
boundary_type=rsa_config.get_value("boundary_type") if boundary_type is None else boundary_type,
|
|
1137
|
-
sticking_probability=rsa_config.get_value("sticking_probability"),
|
|
1133
|
+
sites=rsa_config.get_value("sites", required=False), # type: ignore[arg-type]
|
|
1134
|
+
xsize=rsa_config.get_value("xsize", required=False), # type: ignore[arg-type]
|
|
1135
|
+
ysize=rsa_config.get_value("ysize", required=False), # type: ignore[arg-type]
|
|
1136
|
+
zsize=rsa_config.get_value("zsize", required=False), # type: ignore[arg-type]
|
|
1137
|
+
max_molecule_count=rsa_config.get_value("max_molecule_count"), # type: ignore[arg-type]
|
|
1138
|
+
lattice_a=rsa_config.get_value("lattice_a"), # type: ignore[arg-type]
|
|
1139
|
+
boundary_type=rsa_config.get_value("boundary_type") if boundary_type is None else boundary_type, # type: ignore[arg-type]
|
|
1140
|
+
sticking_probability=rsa_config.get_value("sticking_probability"), # type: ignore[arg-type]
|
|
1138
1141
|
)
|
|
1139
1142
|
"Config values."
|
|
1140
1143
|
|
|
@@ -4,7 +4,7 @@ There is no real reason for the user to need to use any of this, but the functio
|
|
|
4
4
|
"""
|
|
5
5
|
from __future__ import annotations
|
|
6
6
|
|
|
7
|
-
from typing import TYPE_CHECKING, Literal, ParamSpec, cast
|
|
7
|
+
from typing import TYPE_CHECKING, Literal, ParamSpec, TypeVar, cast
|
|
8
8
|
|
|
9
9
|
import numpy as np # For vectorised computations (performed in C).
|
|
10
10
|
import shapely.affinity as aff # Install shapely via https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely
|
|
@@ -27,12 +27,14 @@ IdxArray = np.ndarray[tuple[int], np.dtype[np.int_]] # Flat index aray of integ
|
|
|
27
27
|
BoolArray = np.ndarray[tuple[int], np.dtype[np.bool_]] # Flat Boolean array.
|
|
28
28
|
CoordPair = np.ndarray[tuple[Literal[2], Literal[1]], np.dtype[np.float64]] # 2x1 array of coordinates
|
|
29
29
|
CoordsArray = np.ndarray[tuple[Literal[2], int], np.dtype[np.float64]] # 2xN array of coords.
|
|
30
|
-
|
|
30
|
+
CoordsArray3D = np.ndarray[tuple[Literal[3], int], np.dtype[np.float64]] # 2 or 3 x N array of coords.
|
|
31
31
|
Bools2D = np.ndarray[tuple[int, int], np.dtype[np.bool_]]
|
|
32
32
|
GeoArray = np.ndarray[tuple[int], np.dtype[Polygon]]
|
|
33
33
|
FloatArray = NDArray[np.float64]
|
|
34
34
|
DistArray = np.ndarray[tuple[int], np.dtype[np.float64]]
|
|
35
35
|
|
|
36
|
+
T = TypeVar("T", CoordsArray, CoordsArray3D)
|
|
37
|
+
|
|
36
38
|
|
|
37
39
|
@njit("float64[:, :](float64[:, :], float64[:, :])", parallel=True, cache=True) # type: ignore[untyped-decorator]
|
|
38
40
|
def squared_cdist(coords1: CoordsArray, coords2: CoordsArray) -> np.ndarray[tuple[int, int], np.dtype[np.float64]]:
|
|
@@ -182,7 +184,7 @@ def check_shape_overlap(
|
|
|
182
184
|
neighbour_index: IdxArray,
|
|
183
185
|
simul: Simulator,
|
|
184
186
|
pmg: MoleculeGroup,
|
|
185
|
-
try_angle_first: int | None = None,
|
|
187
|
+
try_angle_first: int | np.int_ | None = None,
|
|
186
188
|
) -> tuple[bool, CandidateMolecule]:
|
|
187
189
|
"""Check whether there the new molecule overlaps with existing molecules.
|
|
188
190
|
|
|
@@ -302,11 +304,11 @@ def make_rectangular_filter(
|
|
|
302
304
|
|
|
303
305
|
|
|
304
306
|
def create_periodic_images(
|
|
305
|
-
coordinates:
|
|
307
|
+
coordinates: T,
|
|
306
308
|
x_max: float,
|
|
307
309
|
y_max: float,
|
|
308
310
|
z_max: float | None = None,
|
|
309
|
-
) ->
|
|
311
|
+
) -> T:
|
|
310
312
|
"""Create a padding of coordinates.
|
|
311
313
|
|
|
312
314
|
Repeats the images above, below, and on the diagonals (9 tiles).
|
|
@@ -318,10 +320,12 @@ def create_periodic_images(
|
|
|
318
320
|
|
|
319
321
|
:returns: 2 by 9*N coordinate array if 2D, otherwise 3 by 27*N array.
|
|
320
322
|
"""
|
|
321
|
-
extended_coordinates:
|
|
323
|
+
extended_coordinates: T = coordinates.copy()
|
|
322
324
|
# This creates an array of the form [[x_max, 0], [0, y_max]].
|
|
323
|
-
temp_offset: np.ndarray[tuple[Literal[2
|
|
324
|
-
|
|
325
|
+
temp_offset: np.ndarray[tuple[Literal[2], Literal[2]], np.dtype[np.float64]] | np.ndarray[
|
|
326
|
+
tuple[Literal[3], Literal[3]], np.dtype[np.float64]] = cast(
|
|
327
|
+
"""np.ndarray[tuple[Literal[2], Literal[2]], np.dtype[np.float64]] |
|
|
328
|
+
np.ndarray[tuple[Literal[3], Literal[3]], np.dtype[np.float64]]""",
|
|
325
329
|
np.diag([x_max, y_max]).reshape((2, 2)) if z_max is None else np.diag([x_max, y_max, z_max]),
|
|
326
330
|
)
|
|
327
331
|
offset: np.ndarray[tuple[Literal[2, 3], Literal[2, 3], Literal[1]], np.dtype[np.float64]] = temp_offset[
|
|
@@ -330,10 +334,10 @@ def create_periodic_images(
|
|
|
330
334
|
ii: NDArray[np.float64]
|
|
331
335
|
for ii in offset: # The first pass creates padding in x dir, the second pads in y.
|
|
332
336
|
sliced_offset = ii
|
|
333
|
-
extended_coordinates1:
|
|
334
|
-
extended_coordinates2:
|
|
337
|
+
extended_coordinates1: T = extended_coordinates + sliced_offset
|
|
338
|
+
extended_coordinates2: T = extended_coordinates - sliced_offset
|
|
335
339
|
extended_coordinates = cast(
|
|
336
|
-
"
|
|
340
|
+
"T",
|
|
337
341
|
np.hstack((extended_coordinates, extended_coordinates1, extended_coordinates2), dtype=np.float64),
|
|
338
342
|
)
|
|
339
343
|
|
|
@@ -13,7 +13,6 @@ from typing import ParamSpec, TypeAlias
|
|
|
13
13
|
|
|
14
14
|
P = ParamSpec("P")
|
|
15
15
|
T: TypeAlias = float | str | int | list[float]
|
|
16
|
-
# T = TypeVar("T", bound=float | str | list[float])
|
|
17
16
|
|
|
18
17
|
|
|
19
18
|
class RsaConfig:
|
|
@@ -72,7 +71,7 @@ class RsaConfig:
|
|
|
72
71
|
return result
|
|
73
72
|
|
|
74
73
|
def __return_key_value(
|
|
75
|
-
|
|
74
|
+
self, config_value: dict[str, T] | T, keys: list[str],
|
|
76
75
|
) -> T | dict[str, T] | RsaConfig | None:
|
|
77
76
|
if not len(keys):
|
|
78
77
|
if isinstance(config_value, dict):
|