adsorpy.rsa_config module

Schema and validator for the RSA simulation configuration.

adsorpy.rsa_config.JsonValue: TypeAlias = 'JsonLeaf | list[JsonLeaf] | dict[str, JsonLeaf]'

Values stored in the JSON. Potentially recursive.

adsorpy.rsa_config.RawJsonDict

Dictionary containing the JSON values.

alias of dict[str, JsonLeaf | list[JsonLeaf] | dict[str, JsonLeaf]]

adsorpy.rsa_config.JsonLeaf: TypeAlias = float | str | int | list[float] | bool | None

Primitive values stored in the JSON.

class adsorpy.rsa_config.LoggingConfig(*, enabled)[source]

Bases: BaseModel

Whether logging is enabled or not.

Parameters:

enabled (bool) – If true: enable logging.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

enabled: bool
classmethod strip_comments(data)[source]

Strip keys containing ‘_comment’ from the incoming data dictionary.

Parameters:

data (dict[str, float | str | int | list[float] | bool | None | list[float | str | int | list[float] | bool | None] | dict[str, float | str | int | list[float] | bool | None]]) – Raw dictionary.

Return type:

dict[str, float | str | int | list[float] | bool | None | list[float | str | int | list[float] | bool | None] | dict[str, float | str | int | list[float] | bool | None]]

Returns:

Dictionary with ‘_comment’ removed.

_abc_impl = <_abc._abc_data object>
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class adsorpy.rsa_config.WrappedValue[T: float | str | int | list[float] | bool | None](*, value)[source]

Bases: BaseModel, Generic[T]

Generic wrapper for fields containing a nested ‘value’ key.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:

value (T)

value: T
classmethod strip_comments(data)[source]

Strip keys containing ‘_comment’ from the incoming data dictionary.

Return type:

dict[str, float | str | int | list[float] | bool | None | list[float | str | int | list[float] | bool | None] | dict[str, float | str | int | list[float] | bool | None]]

Parameters:

data (dict[str, float | str | int | list[float] | bool | None | list[float | str | int | list[float] | bool | None] | dict[str, float | str | int | list[float] | bool | None]])

_abc_impl = <_abc._abc_data object>
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class adsorpy.rsa_config.RsaConfig(config_path=None, *, logging, sites, xsize, ysize, zsize, max_molecule_count, lattice_a, boundary_type, sticking_probability)[source]

Bases: BaseModel

Full RSA Configuration model mirroring the JSON schema exactly.

Variables:
  • logging (LoggingConfig) – Whether to enable logging.

  • sites (WrappedValue[Union[Annotated[int, Gt], NoneType]]) – The surface site count.

  • xsize (WrappedValue[Union[Annotated[float, Ge], NoneType]]) – The surface size in the x direction.

  • ysize (WrappedValue[Union[Annotated[float, Ge], NoneType]]) – The surface size in the y direction.

  • zsize (WrappedValue[Union[Annotated[float, Ge], NoneType]]) – The surface size in the z direction.

  • max_molecule_count (WrappedValue[Annotated[int, Ge]]) – The maximum number of molecules allowed in the simulation.

  • lattice_a (WrappedValue[Annotated[float, Ge]]) – The lattice spacing.

  • boundary_type (WrappedValue[Literal['soft', 'hard', 'periodic']]) – The boundary type.

  • sticking_probability (WrappedValue[Annotated[float, Ge]]) – The sticking probability.

Parameters:

Initialise the configuration.

Supports drop-in instantiation via a positional file path string/Path object, or keyword arguments for testing/override setups.

Parameters:
logging: LoggingConfig
sites: WrappedValue[Annotated[int, Gt] | NoneType]
xsize: WrappedValue[Annotated[float, Ge] | NoneType]
ysize: WrappedValue[Annotated[float, Ge] | NoneType]
zsize: WrappedValue[Annotated[float, Ge] | NoneType]
max_molecule_count: WrappedValue[Annotated[int, Ge]]
lattice_a: WrappedValue[Annotated[float, Ge]]
boundary_type: WrappedValue[Literal['soft', 'hard', 'periodic']]
_abc_impl = <_abc._abc_data object>
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

sticking_probability: WrappedValue[Annotated[float, Ge]]
__init__(config_path=None, **kwargs)[source]

Initialise the configuration.

Supports drop-in instantiation via a positional file path string/Path object, or keyword arguments for testing/override setups.

Parameters:
  • config_path (str | Path | None) – The path to the configuration file.

  • kwargs (object) – Additional keyword arguments.

Return type:

None

validate_dimensions()[source]

Enforce mutual exclusivity between grid ‘sites’ and spatial ‘sizes’.

Return type:

Self

Returns:

The class itself.