uclchem.makerates.config ======================== .. py:module:: uclchem.makerates.config .. autoapi-nested-parse:: 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 ~~~~~~~ .. autoapisummary:: uclchem.makerates.config.MakeratesConfig Attributes ~~~~~~~~~~ .. autoapisummary:: uclchem.makerates.config.ReactionFileTypes uclchem.makerates.config.logger .. py:class:: MakeratesConfig(/, **data: Any) Bases: :py:obj:`pydantic.BaseModel` Configuration 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. .. rubric:: 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. .. py:method:: auto_enable_rates_storage() -> MakeratesConfig Automatically enable rates storage if needed for exothermicity. :returns: validated MakeratesConfig. :rtype: MakeratesConfig .. py:method:: check_three_phase_deprecation() -> MakeratesConfig Raise error if ``three_phase`` is explicitly set to False. :returns: validated MakeratesConfig. :rtype: MakeratesConfig :raises ValueError: If ``three_phase`` is False. .. py:method:: from_yaml(yaml_path: str | pathlib.Path) -> MakeratesConfig :classmethod: 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. :param yaml_path: Path to the YAML configuration file :type yaml_path: str | Path :returns: Validated MakeratesConfig instance :rtype: MakeratesConfig :raises FileNotFoundError: If config file doesn't exist .. py:method:: generate_template(output_path: str | pathlib.Path = 'user_settings_template.yaml') :classmethod: Generate a template configuration file with all parameters documented. :param output_path: Where to write the template file. Default = "user_settings_template.yaml" :type output_path: str | Path .. py:method:: get_all_reaction_files() -> list[pathlib.Path] Get all reaction files (database + custom) as resolved paths. :returns: **files** -- List of absolute paths to all reaction files :rtype: list[Path] .. py:method:: get_all_reaction_types() -> list[ReactionFileTypes] Get all reaction types (database + custom) in correct order. :returns: **types** -- list of reaction type strings :rtype: list[ReactionFileTypes] .. py:method:: log_configuration() -> None Log the current configuration for debugging. .. py:method:: normalize_coolants_file(v: str | pathlib.Path | None) -> pathlib.Path | None :classmethod: Normalize a single coolant file path to a Path object. :param v: string to normalize :type v: str | Path | None :returns: Path instance, or None if v is None :rtype: Path | None :raises TypeError: If coolants_file is not a string or Path instance. .. py:method:: normalize_to_list(v: str | pathlib.Path | list | None) -> list[str | pathlib.Path] | None :classmethod: Convert single values to lists for consistent handling. :param v: variable to make consistent. :type v: str | Path | list | None :returns: list of strings or paths, or None if v is None :rtype: list[str | Path] | None .. py:method:: normalize_type_to_list(v: str | list[str] | None) -> list[str] | None :classmethod: Convert single type strings to lists for consistent handling. :param v: variable to convert to list :type v: str | list[str] | None :returns: **v** -- list of string, or None if original v is None :rtype: list[str] | None .. py:method:: print_help() :classmethod: Print detailed help about all configuration parameters. .. py:method:: resolve_path(path: str | pathlib.Path) -> pathlib.Path Resolve a path relative to the configuration file directory. :param path: Path to resolve (can be absolute or relative) :type path: str | Path :returns: Resolved absolute Path :rtype: Path .. py:method:: validate_coolants(v: list[dict[str, str]] | None) -> list[dict[str, str | float]] | None :classmethod: Validate inline coolants format. :param v: variable to make consistent :type v: list[dict[str, str]] | None :returns: **validated** -- list of validated coolant dictionaries :rtype: list[dict[str, str | float]] | None :raises TypeError: If v is not a list of dictionaries. :raises KeyError: If entries in v do not contain keys 'file' and 'name' :raises ValueError: If entries in v with keys 'file' are not bare file names. .. py:method:: validate_coolants_mutual_exclusion() -> MakeratesConfig Ensure coolants and coolants_file are mutually exclusive. :returns: validated MakeratesConfig. :rtype: MakeratesConfig :raises ValueError: If both `coolants` and `coolants_file` are specified. .. py:method:: validate_reaction_files_and_types() -> MakeratesConfig Ensure reaction files and types are consistent. :returns: validated MakeratesConfig. :rtype: MakeratesConfig :raises ValueError: If the length of reaction files and reaction file types is not the same :raises ValueError: If `custom_reaction_type` is not specified but `custom_reaction_file` is. .. py:attribute:: add_crp_photo_to_grain :type: bool :value: None .. py:attribute:: coolant_data_dir :type: pathlib.Path | None :value: None .. py:attribute:: coolants :type: list[dict] | None :value: None .. py:attribute:: coolants_file :type: pathlib.Path | None :value: None .. py:attribute:: custom_reaction_file :type: pathlib.Path | list[pathlib.Path] | None :value: None .. py:attribute:: custom_reaction_type :type: ReactionFileTypes | list[ReactionFileTypes] | None :value: None .. py:attribute:: database_reaction_exothermicity :type: list[pathlib.Path] | None :value: None .. py:attribute:: database_reaction_file :type: pathlib.Path | list[pathlib.Path] :value: None .. py:attribute:: database_reaction_type :type: ReactionFileTypes | list[ReactionFileTypes] :value: None .. py:attribute:: derive_reaction_exothermicity :type: bool | str | list[str] :value: None .. py:attribute:: enable_rates_storage :type: bool :value: None .. py:attribute:: gas_phase_extrapolation :type: bool :value: None .. py:attribute:: grain_assisted_recombination_file :type: pathlib.Path | None :value: None .. py:attribute:: model_config Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict]. .. py:attribute:: output_directory :type: pathlib.Path | None :value: None .. py:attribute:: species_file :type: pathlib.Path :value: None .. py:attribute:: three_phase :type: bool :value: None .. py:data:: ReactionFileTypes .. py:data:: logger