AdsorPy 1.0.2__tar.gz → 1.1.2__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.1.2}/.github/workflows/docs-ci.yml +1 -1
- {adsorpy-1.0.2 → adsorpy-1.1.2}/.github/workflows/publish_to_PyPI.yml +2 -2
- {adsorpy-1.0.2 → adsorpy-1.1.2}/.github/workflows/tests-ci.yml +1 -1
- adsorpy-1.1.2/CHANGELOG.md +68 -0
- {adsorpy-1.0.2 → adsorpy-1.1.2}/PKG-INFO +2 -2
- {adsorpy-1.0.2 → adsorpy-1.1.2}/pyproject.toml +3 -4
- {adsorpy-1.0.2 → adsorpy-1.1.2}/requirements.txt +2 -2
- {adsorpy-1.0.2 → adsorpy-1.1.2}/requirements_dev.txt +2 -2
- {adsorpy-1.0.2 → adsorpy-1.1.2}/src/adsorpy/randomsequentialadsorption.py +32 -29
- {adsorpy-1.0.2 → adsorpy-1.1.2}/src/adsorpy/rsa_calculator.py +15 -11
- {adsorpy-1.0.2 → adsorpy-1.1.2}/src/adsorpy/run_simulation.py +48 -25
- {adsorpy-1.0.2 → adsorpy-1.1.2}/tests/rsa_test.py +3 -12
- {adsorpy-1.0.2 → adsorpy-1.1.2}/tests/run_simulation_test.py +78 -21
- adsorpy-1.0.2/CHANGELOG.md +0 -34
- {adsorpy-1.0.2 → adsorpy-1.1.2}/LICENSE.md +0 -0
- {adsorpy-1.0.2 → adsorpy-1.1.2}/README.md +0 -0
- {adsorpy-1.0.2 → adsorpy-1.1.2}/docs/Makefile +0 -0
- {adsorpy-1.0.2 → adsorpy-1.1.2}/docs/make.bat +0 -0
- {adsorpy-1.0.2 → adsorpy-1.1.2}/docs/source/adsorpy.molecule_lib.rst +0 -0
- {adsorpy-1.0.2 → adsorpy-1.1.2}/docs/source/adsorpy.randomsequentialadsorption.rst +0 -0
- {adsorpy-1.0.2 → adsorpy-1.1.2}/docs/source/adsorpy.rsa_calculator.rst +0 -0
- {adsorpy-1.0.2 → adsorpy-1.1.2}/docs/source/adsorpy.rsa_config.rst +0 -0
- {adsorpy-1.0.2 → adsorpy-1.1.2}/docs/source/adsorpy.rst +0 -0
- {adsorpy-1.0.2 → adsorpy-1.1.2}/docs/source/adsorpy.run_simulation.rst +0 -0
- {adsorpy-1.0.2 → adsorpy-1.1.2}/docs/source/conf.py +0 -0
- {adsorpy-1.0.2 → adsorpy-1.1.2}/docs/source/index.rst +0 -0
- {adsorpy-1.0.2 → adsorpy-1.1.2}/docs/source/modules.rst +0 -0
- {adsorpy-1.0.2 → adsorpy-1.1.2}/images/AdsorPy_Covered_Surface.png +0 -0
- {adsorpy-1.0.2 → adsorpy-1.1.2}/py.typed +0 -0
- {adsorpy-1.0.2 → adsorpy-1.1.2}/src/__init__.py +0 -0
- {adsorpy-1.0.2 → adsorpy-1.1.2}/src/__main__.py +0 -0
- {adsorpy-1.0.2 → adsorpy-1.1.2}/src/adsorpy/VdW_Radii.csv +0 -0
- {adsorpy-1.0.2 → adsorpy-1.1.2}/src/adsorpy/__init__.py +0 -0
- {adsorpy-1.0.2 → adsorpy-1.1.2}/src/adsorpy/config.json +0 -0
- {adsorpy-1.0.2 → adsorpy-1.1.2}/src/adsorpy/molecule_colour.json +0 -0
- {adsorpy-1.0.2 → adsorpy-1.1.2}/src/adsorpy/molecule_lib.py +0 -0
- {adsorpy-1.0.2 → adsorpy-1.1.2}/src/adsorpy/rsa_config.py +0 -0
- {adsorpy-1.0.2 → adsorpy-1.1.2}/tests/__init__.py +0 -0
- {adsorpy-1.0.2 → adsorpy-1.1.2}/tests/test_data/config_test_hard.json +0 -0
- {adsorpy-1.0.2 → adsorpy-1.1.2}/tests/test_data/config_test_periodic.json +0 -0
- {adsorpy-1.0.2 → adsorpy-1.1.2}/tests/test_data/config_test_soft.json +0 -0
- {adsorpy-1.0.2 → adsorpy-1.1.2}/tox.ini +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
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.1.2 - 2026-04-27
|
|
13
|
+
### Added
|
|
14
|
+
### Changed
|
|
15
|
+
### Fixed
|
|
16
|
+
- Turn relative imports into absolute imports to make the package pip-installable.
|
|
17
|
+
- Fix the type hints that broke as a result of this.
|
|
18
|
+
### Removed
|
|
19
|
+
|
|
20
|
+
## 1.1.1 - 2026-04-27
|
|
21
|
+
### Added
|
|
22
|
+
### Changed
|
|
23
|
+
- Update dependency versions.
|
|
24
|
+
### Fixed
|
|
25
|
+
- Fix ``pyproject.toml``: ``"AdsorPy" = ["py.typed"]`` (from ``rsa-mc``, the old internal project name.)
|
|
26
|
+
### Removed
|
|
27
|
+
|
|
28
|
+
## 1.1.0 - 2026-04-24
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
- Add the ``Simulator`` class as 6th return value of ``run_simulation()``.
|
|
32
|
+
- Add overlap and gap size subtests to the dosing scheme tests of ``run_simulation_test``.
|
|
33
|
+
### Changed
|
|
34
|
+
- Update CI action/deploy-pages to v5. Update CI action/upload-artifact to v7.
|
|
35
|
+
- Move overlap and gap size test for alt simulation to subtests.
|
|
36
|
+
### Fixed
|
|
37
|
+
### Removed
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## 1.0.2 - 2026-04-23
|
|
41
|
+
|
|
42
|
+
### Added
|
|
43
|
+
|
|
44
|
+
### Changed
|
|
45
|
+
- Update CI actions to move from ``node.js`` 20 to 24.
|
|
46
|
+
|
|
47
|
+
### Fixed
|
|
48
|
+
|
|
49
|
+
### Removed
|
|
50
|
+
- Remove unnecessary type casts.
|
|
51
|
+
|
|
52
|
+
## 1.0.1 - 2026-04-23
|
|
53
|
+
|
|
54
|
+
### Added
|
|
55
|
+
- Implement subtests for the test_run_alt (a test for the RSA simulator on an alternative seed).
|
|
56
|
+
- Add a determinism test to show identical outcome for identical seeds.
|
|
57
|
+
- In ``tool.ruff.lint``: use ``future-annotations = true``, this correctly checks ``__future__`` annotation.
|
|
58
|
+
### Changed
|
|
59
|
+
- Update version dependencies.
|
|
60
|
+
- Strengthen seed comparison test.
|
|
61
|
+
- Vectorise (remove a for-loop) from overlap test.
|
|
62
|
+
|
|
63
|
+
### Fixed
|
|
64
|
+
|
|
65
|
+
### Removed
|
|
66
|
+
|
|
67
|
+
## 1.0.0 - 2025-11-29
|
|
68
|
+
- Full release
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: AdsorPy
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1.2
|
|
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
|
|
@@ -29,7 +29,7 @@ Requires-Dist: pytest; extra == 'testing'
|
|
|
29
29
|
Requires-Dist: pytest-cov; extra == 'testing'
|
|
30
30
|
Requires-Dist: ruff; extra == 'testing'
|
|
31
31
|
Requires-Dist: scipy==1.15.3; (python_version <= '3.10') and extra == 'testing'
|
|
32
|
-
Requires-Dist: scipy
|
|
32
|
+
Requires-Dist: scipy>=1.16.3; (python_version > '3.10') and extra == 'testing'
|
|
33
33
|
Description-Content-Type: text/markdown
|
|
34
34
|
|
|
35
35
|
# AdsorPy
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "AdsorPy"
|
|
7
|
-
version = "1.
|
|
7
|
+
version = "1.1.2"
|
|
8
8
|
description = "Random sequential adsorption (RSA) simulation, 2D lattice-based."
|
|
9
9
|
authors = [{ name = "J.F.W. Maas", email = "j.f.w.maas@tue.nl" }]
|
|
10
10
|
readme = "README.md"
|
|
@@ -45,12 +45,12 @@ testing = [
|
|
|
45
45
|
"mypy",
|
|
46
46
|
"ruff",
|
|
47
47
|
"scipy==1.15.3; python_version <= '3.10'",
|
|
48
|
-
"scipy
|
|
48
|
+
"scipy>=1.16.3; python_version > '3.10'",
|
|
49
49
|
]
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
[tool.hatch.package_data]
|
|
53
|
-
"
|
|
53
|
+
"AdsorPy" = ["py.typed"]
|
|
54
54
|
|
|
55
55
|
[tool.pytest.ini_options]
|
|
56
56
|
testpaths = ["tests"]
|
|
@@ -93,7 +93,6 @@ exclude_also = [
|
|
|
93
93
|
mypy_path = ["src", "optional"]
|
|
94
94
|
ignore_missing_imports = true
|
|
95
95
|
strict = true
|
|
96
|
-
#no_implicit_reexport = true
|
|
97
96
|
disallow_any_explicit = true
|
|
98
97
|
#disallow_any_decorated = true # Throws an error because geo.Polygon in a tuple is turned into Any for the @staticmethod.
|
|
99
98
|
#warn_unreachable = true # Set this to true when pushing to main?
|
|
@@ -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
|
|
|
@@ -17,17 +17,18 @@ else:
|
|
|
17
17
|
import time # For timing of the script.
|
|
18
18
|
from itertools import count # A simple counter, iterates with next(...).
|
|
19
19
|
from pathlib import Path # For path handling in Python.
|
|
20
|
-
from typing import Literal, ParamSpec, TypeVar, cast # For type hinting.
|
|
20
|
+
from typing import TYPE_CHECKING, Literal, ParamSpec, TypeVar, cast # For type hinting.
|
|
21
21
|
|
|
22
|
-
import molecule_lib as mol # Homebrew lib of molecules and molecule footprint generation.
|
|
23
22
|
import numpy as np # For vectorised computations (performed in C).
|
|
24
23
|
from numpy.random import PCG64DXSM, Generator # New random generator.
|
|
25
24
|
from numpy.typing import NDArray
|
|
26
|
-
from randomsequentialadsorption import MoleculeGroup, Simulator, Surface
|
|
27
|
-
from rsa_config import RsaConfig # Config of the simulation.
|
|
28
25
|
from shapely import Polygon # Shapely creates and manipulates polygons.
|
|
29
26
|
from shapely.prepared import PreparedGeometry
|
|
30
27
|
|
|
28
|
+
import src.adsorpy.molecule_lib as mol # Homebrew lib of molecules and molecule footprint generation.
|
|
29
|
+
from src.adsorpy.randomsequentialadsorption import MoleculeGroup, Simulator, Surface
|
|
30
|
+
from src.adsorpy.rsa_config import RsaConfig # Config of the simulation.
|
|
31
|
+
|
|
31
32
|
P = ParamSpec("P") # Helps with static type checkers.
|
|
32
33
|
T1 = TypeVar("T1")
|
|
33
34
|
T2 = TypeVar("T2", bound=np.generic | Polygon) # type: ignore[explicit-any]
|
|
@@ -59,7 +60,7 @@ def run_simulation( # noqa: PLR0913
|
|
|
59
60
|
lattice_a: float | None = None,
|
|
60
61
|
boundary_condition: str | None = None,
|
|
61
62
|
simulation_type: str = "sequential",
|
|
62
|
-
dosing_distribution: list[float] | None = None,
|
|
63
|
+
dosing_distribution: list[float] | DistArray | None = None,
|
|
63
64
|
include_rejected_flux: bool = False,
|
|
64
65
|
calculate_gap_size: bool = False,
|
|
65
66
|
print_output_flag: bool = False,
|
|
@@ -70,8 +71,8 @@ def run_simulation( # noqa: PLR0913
|
|
|
70
71
|
site_y_coords: DistArray | None = None,
|
|
71
72
|
bounding_x_coord: float | None = None,
|
|
72
73
|
bounding_y_coord: float | None = None,
|
|
73
|
-
sticking_probability: float | list[float] = 1.,
|
|
74
|
-
) -> tuple[list[int], DistArray, int, IdxArray, IdxArray]:
|
|
74
|
+
sticking_probability: float | list[float] | DistArray = 1.,
|
|
75
|
+
) -> tuple[list[int], DistArray, int, IdxArray, IdxArray, Simulator]:
|
|
75
76
|
"""Run the RSA simulation.
|
|
76
77
|
|
|
77
78
|
If no molecule is provided, defaults to a circular molecule of radius 0.55 Angstrom.
|
|
@@ -106,11 +107,17 @@ def run_simulation( # noqa: PLR0913
|
|
|
106
107
|
2. The RNG seed.
|
|
107
108
|
3. The fluxes/doses as a list of counts per stepcount of adsorption event.
|
|
108
109
|
4. The available surface function (ASF).
|
|
110
|
+
5. The Simulator class.
|
|
109
111
|
:raises TypeError: If the sticking probability is an invalid type.
|
|
110
112
|
"""
|
|
111
113
|
rsa_config = RsaConfig(str(Path(__file__).parent / "config.json")) if rsa_config is None else rsa_config
|
|
112
114
|
|
|
113
|
-
|
|
115
|
+
mol_lst: GeoArray
|
|
116
|
+
rot_syms: IdxArray
|
|
117
|
+
refl_syms: BoolArray
|
|
118
|
+
rot_cnts: IdxArray
|
|
119
|
+
|
|
120
|
+
mol_lst, rot_syms, refl_syms, rot_cnts = _initialise_run_parameters(
|
|
114
121
|
molecules_list,
|
|
115
122
|
rotation_symmetries,
|
|
116
123
|
reflection_symmetries,
|
|
@@ -118,11 +125,19 @@ def run_simulation( # noqa: PLR0913
|
|
|
118
125
|
simulation_type,
|
|
119
126
|
)
|
|
120
127
|
|
|
128
|
+
# molecules_list, rotation_symmetries, reflection_symmetries, rotation_counts = _initialise_run_parameters(
|
|
129
|
+
# molecules_list,
|
|
130
|
+
# rotation_symmetries,
|
|
131
|
+
# reflection_symmetries,
|
|
132
|
+
# rotation_counts,
|
|
133
|
+
# simulation_type,
|
|
134
|
+
# )
|
|
135
|
+
|
|
121
136
|
custom_grid_flg: bool = _error_checker(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
137
|
+
mol_lst,
|
|
138
|
+
rot_syms,
|
|
139
|
+
refl_syms,
|
|
140
|
+
rot_cnts,
|
|
126
141
|
simulation_type,
|
|
127
142
|
dosing_distribution,
|
|
128
143
|
boundary_condition,
|
|
@@ -132,6 +147,8 @@ def run_simulation( # noqa: PLR0913
|
|
|
132
147
|
bounding_y_coord,
|
|
133
148
|
)
|
|
134
149
|
|
|
150
|
+
|
|
151
|
+
|
|
135
152
|
# The seed is defined as the datetime in microseconds. The seed is stored so simulations can be verified.
|
|
136
153
|
how_late = datetime.now(UTC) if version_info >= (3, 11) else datetime.utcnow()
|
|
137
154
|
seed = int(how_late.strftime("%Y%m%d%H%M%S%f")) if seed is None else seed
|
|
@@ -145,7 +162,6 @@ def run_simulation( # noqa: PLR0913
|
|
|
145
162
|
|
|
146
163
|
temp_results_folder = results_folder
|
|
147
164
|
attempt_count: int = 0
|
|
148
|
-
# while os.path.isdir(temp_results_folder):
|
|
149
165
|
while temp_results_folder.is_dir():
|
|
150
166
|
temp_results_folder = results_folder.parent / (results_folder.name + f"_{attempt_count}")
|
|
151
167
|
# Add a counter to the end of the folder name.
|
|
@@ -155,29 +171,35 @@ def run_simulation( # noqa: PLR0913
|
|
|
155
171
|
|
|
156
172
|
surf = Surface(rsa_config, lattice_type=lattice_type, lattice_a=lattice_a, site_count=site_count)
|
|
157
173
|
if custom_grid_flg:
|
|
174
|
+
if TYPE_CHECKING:
|
|
175
|
+
if site_x_coords is None or site_y_coords is None or bounding_x_coord is None or bounding_y_coord is None:
|
|
176
|
+
errmsg = "Site_x_coords, site_y_coords, bounding_x_coord, bounding_y_coord must be provided."
|
|
177
|
+
raise TypeError(errmsg)
|
|
178
|
+
|
|
158
179
|
surf.generate_custom_surface(site_x_coords, site_y_coords, bounding_x_coord, bounding_y_coord)
|
|
159
180
|
else:
|
|
160
181
|
surf.generate_grid(rng)
|
|
161
182
|
|
|
162
183
|
molecules = [] # Initially, there are none.
|
|
163
|
-
rot_syms = rotation_symmetries # Rotation symmetry
|
|
164
|
-
mirror_syms = reflection_symmetries # Mirror symmetry
|
|
165
|
-
rot_cnts = rotation_counts
|
|
166
184
|
mgc: count[int] = count()
|
|
185
|
+
stick_prob: DistArray = np.array([1.])
|
|
167
186
|
if isinstance(sticking_probability, float):
|
|
168
|
-
|
|
169
|
-
elif
|
|
187
|
+
stick_prob = np.array([sticking_probability] * len(mol_lst))
|
|
188
|
+
elif isinstance(sticking_probability, list):
|
|
189
|
+
stick_prob = np.array(sticking_probability)
|
|
190
|
+
elif not isinstance(sticking_probability, np.ndarray) and sticking_probability is not None:
|
|
170
191
|
errmsg = "sticking_probability must be a float, list, or np.ndarray"
|
|
171
192
|
raise TypeError(errmsg)
|
|
172
193
|
|
|
194
|
+
|
|
173
195
|
pp: Polygon
|
|
174
|
-
for idx, (pp, stick) in enumerate(zip(
|
|
196
|
+
for idx, (pp, stick) in enumerate(zip(mol_lst, stick_prob, strict=True)):
|
|
175
197
|
molecules.append(
|
|
176
198
|
MoleculeGroup(
|
|
177
199
|
rsa_config,
|
|
178
200
|
pp,
|
|
179
201
|
rot_syms[idx],
|
|
180
|
-
|
|
202
|
+
refl_syms[idx],
|
|
181
203
|
surf.all_site_count,
|
|
182
204
|
mgc,
|
|
183
205
|
rot_cnts[idx],
|
|
@@ -223,7 +245,7 @@ def run_simulation( # noqa: PLR0913
|
|
|
223
245
|
timestr,
|
|
224
246
|
)
|
|
225
247
|
|
|
226
|
-
return [mgr.molecule_counter for mgr in sim.molgroups], gaps, seed, all_flux, phi
|
|
248
|
+
return [mgr.molecule_counter for mgr in sim.molgroups], gaps, seed, all_flux, phi, sim
|
|
227
249
|
|
|
228
250
|
|
|
229
251
|
def _run_sequential(
|
|
@@ -244,7 +266,7 @@ def _run_codosing(
|
|
|
244
266
|
molecules: list[MoleculeGroup],
|
|
245
267
|
time_count: count[int],
|
|
246
268
|
timestep_limit: int,
|
|
247
|
-
dosing_distribution: list[float] | None = None,
|
|
269
|
+
dosing_distribution: list[float] | DistArray | None = None,
|
|
248
270
|
) -> None:
|
|
249
271
|
for moldx, molgr in enumerate(sim.molgroups):
|
|
250
272
|
while molgr.vacancy_count and next(time_count) < timestep_limit:
|
|
@@ -312,11 +334,12 @@ def _run_flux_fixedrotation(
|
|
|
312
334
|
"""
|
|
313
335
|
mol_flux: list[int] = []
|
|
314
336
|
all_phis: list[int] = []
|
|
337
|
+
mol_array: GeoArray = np.array(molecules)
|
|
315
338
|
for step in range(timestep_limit):
|
|
316
339
|
if not np.any([molgroup.vacancy_count for molgroup in molecules]):
|
|
317
340
|
break # If nothing is available, terminate.
|
|
318
341
|
|
|
319
|
-
randmol: MoleculeGroup = sim.rng.choice(
|
|
342
|
+
randmol: MoleculeGroup = sim.rng.choice(mol_array, p=distribution) # mypy complains without np.array.
|
|
320
343
|
if not randmol.vacancy_count:
|
|
321
344
|
continue
|
|
322
345
|
flag, *_, phi = sim.attempt_place_molecule(surf, randmol)
|
|
@@ -391,7 +414,7 @@ def _error_checker(
|
|
|
391
414
|
reflection_symmetries: BoolArray,
|
|
392
415
|
rotation_counts: IdxArray,
|
|
393
416
|
simulation_type: str,
|
|
394
|
-
dosing_distribution: list[float] | None = None,
|
|
417
|
+
dosing_distribution: list[float] | DistArray | None = None,
|
|
395
418
|
boundary_condition: str | None = None,
|
|
396
419
|
site_x_coords: DistArray | None = None,
|
|
397
420
|
site_y_coords: DistArray | None = None,
|
|
@@ -497,7 +520,7 @@ def _select_and_run(
|
|
|
497
520
|
include_rejected_flux: bool,
|
|
498
521
|
time_count: count[int],
|
|
499
522
|
timestep_limit: int,
|
|
500
|
-
dosing_distribution: list[float] | None = None,
|
|
523
|
+
dosing_distribution: list[float] | DistArray | None = None,
|
|
501
524
|
) -> tuple[IdxArray, IdxArray]:
|
|
502
525
|
"""Select and run. A collection of the simulations. Putting them in one function helps streamline adjusting them.
|
|
503
526
|
|
|
@@ -196,7 +196,6 @@ class TestWithParameters:
|
|
|
196
196
|
polygons = simulator.sim.mol_data.stored_data["polygon"][existing]
|
|
197
197
|
|
|
198
198
|
ii: Polygon
|
|
199
|
-
jj: Polygon
|
|
200
199
|
overlap = False
|
|
201
200
|
for idx, ii in enumerate(polygons): # TODO: Add STRtree to speed up?
|
|
202
201
|
prepared_multipolygon = prep(unary_union(polygons[idx + 1:]))
|
|
@@ -208,7 +207,7 @@ class TestWithParameters:
|
|
|
208
207
|
|
|
209
208
|
def test_no_large_gaps(self, simulator, configname, molgr_count, surf_type):
|
|
210
209
|
"""Tests whether there are sites with gaps larger than the molecule's circumradius.
|
|
211
|
-
|
|
210
|
+
If gaps are larger, a molecule should be able to fit, and the simulation terminated before saturation.
|
|
212
211
|
"""
|
|
213
212
|
gaps = simulator.sim.analyse_gap_size(simulator.sim.surf)
|
|
214
213
|
circumradius = simulator.sim.molgroups[0].max_radius
|
|
@@ -228,7 +227,7 @@ class TestWithParameters:
|
|
|
228
227
|
for alt_test in [self.test_load_config, self.test_create_surface, self.test_create_molecules,
|
|
229
228
|
self.test_boundaryparameters_creation, self.test_generate_simulation,
|
|
230
229
|
self.test_place_fist_molecule, self.test_buffer_trimming, self.test_random_placement,
|
|
231
|
-
self.test_try_placement, self.test_run_simulation]:
|
|
230
|
+
self.test_try_placement, self.test_run_simulation, self.test_no_overlap, self.test_no_large_gaps]:
|
|
232
231
|
with subtests.test(f"{alt_test.__name__}"):
|
|
233
232
|
alt_test(alt_simulator, *arguments)
|
|
234
233
|
|
|
@@ -246,20 +245,12 @@ class TestWithParameters:
|
|
|
246
245
|
|
|
247
246
|
assert not np.array_equal(existing_sim_mols, existing_altsim_mols)
|
|
248
247
|
|
|
249
|
-
def test_alt_nooverlap(self, alt_simulator, configname, molgr_count, surf_type):
|
|
250
|
-
"""Is there no overlap for the alternative simulation as well?"""
|
|
251
|
-
self.test_no_overlap(alt_simulator, configname, molgr_count, surf_type)
|
|
252
|
-
|
|
253
|
-
def test_alt_gaps(self, alt_simulator, configname, molgr_count, surf_type):
|
|
254
|
-
"""Test whether the gap size analysis succeeds for the alternative simulation as well."""
|
|
255
|
-
self.test_no_large_gaps(alt_simulator, configname, molgr_count, surf_type)
|
|
256
|
-
|
|
257
248
|
|
|
258
249
|
def test_surfacetype_invalid_input():
|
|
259
250
|
"""Is an error raised when the lattice type is incorrect?"""
|
|
260
251
|
with pytest.raises(ValueError):
|
|
261
252
|
rsarun.Surface(
|
|
262
|
-
|
|
253
|
+
RsaConfig(
|
|
263
254
|
join(dirname(__file__), "test_data", "config_test_soft.json")
|
|
264
255
|
),
|
|
265
256
|
"Dogbonium",
|
|
@@ -3,9 +3,13 @@ from datetime import datetime, timedelta
|
|
|
3
3
|
import numpy as np
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
from hypothesis import given, strategies as st, settings
|
|
6
|
-
from shapely import Polygon
|
|
6
|
+
from shapely import Polygon, unary_union
|
|
7
7
|
from shapely.ops import orient
|
|
8
|
-
from
|
|
8
|
+
from shapely.prepared import prep
|
|
9
|
+
from src.adsorpy.run_simulation import run_simulation, RsaConfig, _select_and_run, Simulator
|
|
10
|
+
from typing import Literal
|
|
11
|
+
|
|
12
|
+
SEED = 123654789
|
|
9
13
|
|
|
10
14
|
|
|
11
15
|
@pytest.fixture
|
|
@@ -21,22 +25,64 @@ def default_polygon():
|
|
|
21
25
|
return Polygon([(-5, -5), (5, -5), (5, 5), (-5, 5)])
|
|
22
26
|
|
|
23
27
|
|
|
24
|
-
def
|
|
25
|
-
"""
|
|
28
|
+
def overlap_tester(simulator: Simulator) -> Literal[0]:
|
|
29
|
+
"""Tests whether none of the molecules overlap. Solely for periodic boundary conditions."""
|
|
30
|
+
polygons: np.ndarray[Polygon]
|
|
31
|
+
existing = simulator.mol_data.stored_mirr_data["exists"]
|
|
32
|
+
polygons = simulator.mol_data.stored_mirr_data["polygon"][existing]
|
|
33
|
+
|
|
34
|
+
ii: Polygon
|
|
35
|
+
overlap = False
|
|
36
|
+
for idx, ii in enumerate(polygons):
|
|
37
|
+
prepared_multipolygon = prep(unary_union(polygons[idx + 1:]))
|
|
38
|
+
overlap = prepared_multipolygon.intersects(ii) # If there is any overlap, this test fails.
|
|
39
|
+
if overlap:
|
|
40
|
+
break
|
|
41
|
+
|
|
42
|
+
assert not overlap
|
|
43
|
+
|
|
44
|
+
return 0
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def gapsize_tester(simulator: Simulator) -> Literal[0]:
|
|
48
|
+
"""Tests whether there are sites with gaps larger than the largest molecule's circumradius.
|
|
49
|
+
If gaps are larger, a molecule should be able to fit, and the simulation terminated before saturation.
|
|
50
|
+
"""
|
|
51
|
+
gaps = simulator.analyse_gap_size(simulator.surf)
|
|
52
|
+
circumradius = max(molgr.max_radius for molgr in simulator.molgroups)
|
|
53
|
+
assert np.all(gaps <= circumradius)
|
|
54
|
+
|
|
55
|
+
return 0
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def simulation_end_tester(simulator: Simulator, subtests) -> Literal[0]:
|
|
59
|
+
test_functions = (overlap_tester, gapsize_tester)
|
|
60
|
+
for t_func in test_functions:
|
|
61
|
+
with subtests.test(f"{t_func.__name__}"):
|
|
62
|
+
t_func(simulator)
|
|
63
|
+
|
|
64
|
+
return 0
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def test_run_simulation_default_params(rsa_config, default_polygon, subtests):
|
|
68
|
+
"""Test the simulation with default parameter return types."""
|
|
26
69
|
results = run_simulation(rsa_config)
|
|
27
70
|
assert isinstance(results, tuple)
|
|
28
|
-
assert len(results) ==
|
|
71
|
+
assert len(results) == 6
|
|
29
72
|
assert isinstance(results[0], list)
|
|
30
73
|
assert isinstance(results[1], np.ndarray)
|
|
31
74
|
assert isinstance(results[2], int)
|
|
32
75
|
assert isinstance(results[3], np.ndarray)
|
|
33
76
|
assert isinstance(results[4], np.ndarray)
|
|
77
|
+
assert isinstance(results[5], Simulator)
|
|
78
|
+
simulation_end_tester(results[5], subtests)
|
|
34
79
|
|
|
35
80
|
|
|
36
|
-
def test_run_simulation_with_molecule(rsa_config, default_polygon):
|
|
81
|
+
def test_run_simulation_with_molecule(rsa_config, default_polygon, subtests):
|
|
37
82
|
"""Test the simulation with a provided molecule."""
|
|
38
|
-
results = run_simulation(rsa_config, molecules_list=default_polygon)
|
|
83
|
+
results = run_simulation(rsa_config, seed=SEED, molecules_list=default_polygon)
|
|
39
84
|
assert len(results[0]) == 1
|
|
85
|
+
simulation_end_tester(results[5], subtests)
|
|
40
86
|
|
|
41
87
|
|
|
42
88
|
def test_run_simulation_invalid_simulation_type(rsa_config, default_polygon):
|
|
@@ -74,37 +120,47 @@ def test_run_simulation_codosing_mismatch_distribution(rsa_config, default_polyg
|
|
|
74
120
|
)
|
|
75
121
|
|
|
76
122
|
|
|
77
|
-
def test_run_simulation_sequential(rsa_config, default_polygon):
|
|
123
|
+
def test_run_simulation_sequential(rsa_config, default_polygon, subtests):
|
|
78
124
|
"""Test the sequential simulation."""
|
|
79
|
-
results = run_simulation(rsa_config, molecules_list=[default_polygon], simulation_type="sequential")
|
|
125
|
+
results = run_simulation(rsa_config, seed=SEED, molecules_list=[default_polygon], simulation_type="sequential")
|
|
80
126
|
assert len(results[0]) == 1
|
|
127
|
+
simulation_end_tester(results[5], subtests)
|
|
81
128
|
|
|
82
129
|
|
|
83
|
-
def test_run_simulation_codosing(rsa_config, default_polygon):
|
|
130
|
+
def test_run_simulation_codosing(rsa_config, default_polygon, subtests):
|
|
84
131
|
"""Test the codosing simulation."""
|
|
85
132
|
results = run_simulation(
|
|
86
133
|
rsa_config,
|
|
134
|
+
seed=SEED,
|
|
87
135
|
molecules_list=[default_polygon, default_polygon],
|
|
88
136
|
simulation_type="codosing",
|
|
89
137
|
dosing_distribution=[0.5, 0.5]
|
|
90
138
|
)
|
|
91
139
|
assert len(results[0]) == 2
|
|
140
|
+
simulation_end_tester(results[5], subtests)
|
|
92
141
|
|
|
93
142
|
|
|
94
|
-
def test_run_simulation_cascade(rsa_config, default_polygon):
|
|
143
|
+
def test_run_simulation_cascade(rsa_config, default_polygon, subtests):
|
|
95
144
|
"""Test the cascade simulation."""
|
|
96
|
-
results = run_simulation(rsa_config, molecules_list=[default_polygon], simulation_type="cascade")
|
|
145
|
+
results = run_simulation(rsa_config, seed=SEED, molecules_list=[default_polygon], simulation_type="cascade")
|
|
97
146
|
assert len(results[0]) == 1
|
|
147
|
+
simulation_end_tester(results[5], subtests)
|
|
98
148
|
|
|
99
149
|
|
|
100
150
|
def test_run_simulation_boundary_conditions(rsa_config, default_polygon):
|
|
101
151
|
"""Test different boundary conditions."""
|
|
102
152
|
for boundary in ["soft", "hard", "periodic"]:
|
|
103
|
-
results = run_simulation(rsa_config, molecules_list=[default_polygon], boundary_condition=boundary)
|
|
153
|
+
results = run_simulation(rsa_config, seed=SEED, molecules_list=[default_polygon], boundary_condition=boundary)
|
|
104
154
|
assert len(results[0]) == 1
|
|
105
155
|
|
|
156
|
+
def test_run_simulation_sticking_probability(rsa_config, default_polygon, subtests):
|
|
157
|
+
"""Test different sticking probability types."""
|
|
158
|
+
for stck in (0.5, [0.5], np.array([0.5])):
|
|
159
|
+
with subtests.test(f"Sticking type {type(stck)}"):
|
|
160
|
+
results = run_simulation(rsa_config, seed=SEED, molecules_list=[default_polygon], sticking_probability=stck)
|
|
161
|
+
assert len(results[0]) == 1
|
|
106
162
|
|
|
107
|
-
def test_run_simulation_randomness(rsa_config, default_polygon, monkeypatch):
|
|
163
|
+
def test_run_simulation_randomness(rsa_config, default_polygon, monkeypatch, subtests):
|
|
108
164
|
"""Test the randomness based on datetime seed."""
|
|
109
165
|
fixed_datetime = datetime(2023, 1, 1, 0, 0, 0, 1)
|
|
110
166
|
monkeypatch.setattr("run_simulation.datetime", fixed_datetime)
|
|
@@ -128,11 +184,11 @@ def test_run_simulation_determinism(rsa_config, default_polygon, monkeypatch, su
|
|
|
128
184
|
"molecules_list": [default_polygon],
|
|
129
185
|
"seed": 42,
|
|
130
186
|
}
|
|
131
|
-
results_1 = run_simulation(rsa_config, **kwargs)
|
|
132
|
-
results_2 = run_simulation(rsa_config, **kwargs)
|
|
187
|
+
results_1 = run_simulation(rsa_config, **kwargs)[:-1]
|
|
188
|
+
results_2 = run_simulation(rsa_config, **kwargs)[:-1]
|
|
133
189
|
comparison_test_names = ("Mol count", "Gap size", "Seed", "Flux/dose", "ASF")
|
|
134
190
|
for comparison_test_name, output_1, output_2 in zip(comparison_test_names, results_1, results_2, strict=True):
|
|
135
|
-
with subtests.test(comparison_test_name):
|
|
191
|
+
with subtests.test(f"{comparison_test_name} equivalence"):
|
|
136
192
|
assert np.array_equal(output_1, output_2) # Everything should be identical.
|
|
137
193
|
|
|
138
194
|
|
|
@@ -192,7 +248,7 @@ def test_run_simulation_property_test(site_count, lattice_a, boundary_condition,
|
|
|
192
248
|
boundary_condition=boundary_condition,
|
|
193
249
|
seed=seed
|
|
194
250
|
)
|
|
195
|
-
molecule_counters, gap_sizes, seed_out,
|
|
251
|
+
molecule_counters, gap_sizes, seed_out, *_ = results
|
|
196
252
|
|
|
197
253
|
assert len(molecule_counters) == len(molecules_list)
|
|
198
254
|
assert all(count >= 0 for count in molecule_counters)
|
|
@@ -238,15 +294,16 @@ class TestCustomGrid:
|
|
|
238
294
|
"""Does the custom grid generate correctly without errors?
|
|
239
295
|
"""
|
|
240
296
|
rsa_config = RsaConfig(str(Path(__file__).parent / "test_data" / "config_test_periodic.json"))
|
|
241
|
-
run_simulation(rsa_config=rsa_config, site_x_coords=0.9 * np.repeat(np.arange(10), 10),
|
|
242
|
-
|
|
297
|
+
*_, sim = run_simulation(rsa_config=rsa_config, seed=SEED, site_x_coords=0.9 * np.repeat(np.arange(10), 10),
|
|
298
|
+
site_y_coords=0.9 * np.tile(np.arange(10), 10), bounding_x_coord=10,
|
|
299
|
+
bounding_y_coord=10)
|
|
243
300
|
|
|
244
301
|
|
|
245
302
|
def test_sequential_fluxreject():
|
|
246
303
|
"""Does the code handle flux-based simulation correctly?
|
|
247
304
|
"""
|
|
248
305
|
rsa_config = RsaConfig(str(Path(__file__).parent / "test_data" / "config_test_periodic.json"))
|
|
249
|
-
|
|
306
|
+
flux = run_simulation(rsa_config=rsa_config, seed=SEED, simulation_type="sequential", include_rejected_flux=True)[3]
|
|
250
307
|
assert flux is not None # The flux return value has to exist.
|
|
251
308
|
assert isinstance(flux, np.ndarray) # It should be a numpy array.
|
|
252
309
|
assert flux.size # The numpy array should not be empty.
|
adsorpy-1.0.2/CHANGELOG.md
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
All important changes to this project 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
|
-
## 1.0.2 - 2026-04-23
|
|
7
|
-
|
|
8
|
-
### Added
|
|
9
|
-
|
|
10
|
-
### Changed
|
|
11
|
-
- Update CI actions to move from node.js 20 to 24.
|
|
12
|
-
|
|
13
|
-
### Fixed
|
|
14
|
-
|
|
15
|
-
### Removed
|
|
16
|
-
- Remove unnecessary type casts.
|
|
17
|
-
|
|
18
|
-
## 1.0.1 - 2026-04-23
|
|
19
|
-
|
|
20
|
-
### Added
|
|
21
|
-
- Implement subtests for the test_run_alt (a test for the RSA simulator on an alternative seed).
|
|
22
|
-
- Add a determinism test to show identical outcome for identical seeds.
|
|
23
|
-
- In tool.ruff.lint: use future-annotations = true, this correctly checks \_\_future\_\_ annotation.
|
|
24
|
-
### Changed
|
|
25
|
-
- Update version dependencies.
|
|
26
|
-
- Strengthen seed comparison test.
|
|
27
|
-
- Vectorise (remove a for-loop) from overlap test.
|
|
28
|
-
|
|
29
|
-
### Fixed
|
|
30
|
-
|
|
31
|
-
### Removed
|
|
32
|
-
|
|
33
|
-
## 1.0.0 - 2025-11-29
|
|
34
|
-
- Full release
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|