uclchem.makerates.config#
Pydantic-based configuration system for UCLCHEM Makerates.
This module provides validated configuration handling with clear defaults, type checking, and automatic documentation generation.
Module Contents#
Classes#
Configuration for UCLCHEM Makerates chemical network generation. |
Attributes#
- class uclchem.makerates.config.MakeratesConfig(/, **data: Any)[source]#
Bases:
pydantic.BaseModelConfiguration for UCLCHEM Makerates chemical network generation.
This class validates all configuration parameters and provides sensible defaults where appropriate. All file paths are resolved relative to the configuration file location.
Examples
>>> from uclchem.utils import UCLCHEM_ROOT_DIR >>> config = MakeratesConfig.from_yaml(UCLCHEM_ROOT_DIR/ "../../Makerates/user_settings.yaml") >>> print(config.species_file) data/default/default_species.csv
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.
- auto_enable_rates_storage() MakeratesConfig[source]#
Automatically enable rates storage if needed for exothermicity.
- Returns:
validated MakeratesConfig.
- Return type:
- check_three_phase_deprecation() MakeratesConfig[source]#
Raise error if
three_phaseis explicitly set to False.- Returns:
validated MakeratesConfig.
- Return type:
- Raises:
ValueError – If
three_phaseis False.
- classmethod from_yaml(yaml_path: str | pathlib.Path) MakeratesConfig[source]#
Load and validate configuration from a YAML file.
All relative paths in the config file are resolved relative to the directory containing the YAML file.
- Parameters:
yaml_path (str | Path) – Path to the YAML configuration file
- Returns:
Validated MakeratesConfig instance
- Return type:
- Raises:
FileNotFoundError – If config file doesn’t exist
- classmethod generate_template(output_path: str | pathlib.Path = 'user_settings_template.yaml')[source]#
Generate a template configuration file with all parameters documented.
- Parameters:
output_path (str | Path) – Where to write the template file. Default = “user_settings_template.yaml”
- get_all_reaction_files() list[pathlib.Path][source]#
Get all reaction files (database + custom) as resolved paths.
- Returns:
files – List of absolute paths to all reaction files
- Return type:
list[Path]
- get_all_reaction_types() list[ReactionFileTypes][source]#
Get all reaction types (database + custom) in correct order.
- Returns:
types – list of reaction type strings
- Return type:
- classmethod normalize_coolants_file(v: str | pathlib.Path | None) pathlib.Path | None[source]#
Normalize a single coolant file path to a Path object.
- classmethod normalize_to_list(v: str | pathlib.Path | list | None) list[str | pathlib.Path] | None[source]#
Convert single values to lists for consistent handling.
- classmethod normalize_type_to_list(v: str | list[str] | None) list[str] | None[source]#
Convert single type strings to lists for consistent handling.
- resolve_path(path: str | pathlib.Path) pathlib.Path[source]#
Resolve a path relative to the configuration file directory.
- Parameters:
path (str | Path) – Path to resolve (can be absolute or relative)
- Returns:
Resolved absolute Path
- Return type:
Path
- classmethod validate_coolants(v: list[dict[str, str]] | None) list[dict[str, str | float]] | None[source]#
Validate inline coolants format.
- Parameters:
v (list[dict[str, str]] | None) – variable to make consistent
- Returns:
validated – list of validated coolant dictionaries
- Return type:
- Raises:
TypeError – If v is not a list of dictionaries.
KeyError – If entries in v do not contain keys ‘file’ and ‘name’
ValueError – If entries in v with keys ‘file’ are not bare file names.
- validate_coolants_mutual_exclusion() MakeratesConfig[source]#
Ensure coolants and coolants_file are mutually exclusive.
- Returns:
validated MakeratesConfig.
- Return type:
- Raises:
ValueError – If both coolants and coolants_file are specified.
- validate_reaction_files_and_types() MakeratesConfig[source]#
Ensure reaction files and types are consistent.
- Returns:
validated MakeratesConfig.
- Return type:
- Raises:
ValueError – If the length of reaction files and reaction file types is not the same
ValueError – If custom_reaction_type is not specified but custom_reaction_file is.
- coolant_data_dir: pathlib.Path | None = None[source]#
- coolants_file: pathlib.Path | None = None[source]#
- custom_reaction_file: pathlib.Path | list[pathlib.Path] | None = None[source]#
- custom_reaction_type: ReactionFileTypes | list[ReactionFileTypes] | None = None[source]#
- database_reaction_exothermicity: list[pathlib.Path] | None = None[source]#
- database_reaction_file: pathlib.Path | list[pathlib.Path] = None[source]#
- database_reaction_type: ReactionFileTypes | list[ReactionFileTypes] = None[source]#
- grain_assisted_recombination_file: pathlib.Path | None = None[source]#
- model_config[source]#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- output_directory: pathlib.Path | None = None[source]#
- species_file: pathlib.Path = None[source]#