tud_lbm.config.adapter_toml

TOML configuration file adapter.

Reads and writes .toml config files.

Requires Python ≥ 3.11 (tomllib in stdlib) or the tomli back-port on Python 3.10:

pip install tomli

Example usage:

from config.adapter_toml import TomlAdapter

adapter = TomlAdapter()
config = adapter.load("example_for_test/config_simple.toml")
adapter.save(config, "output/config.toml")

Attributes

tomli_w

Classes

TomlAdapter

Adapter that reads and writes TOML configuration files.

Module Contents

tud_lbm.config.adapter_toml.tomli_w = None[source]
class tud_lbm.config.adapter_toml.TomlAdapter[source]

Bases: tud_lbm.config.adapter_base.ConfigAdapter

Adapter that reads and writes TOML configuration files.

Supported top-level tables

[simulation_type]

Required. Contains the simulation type (type), grid shape, physics parameters, and runner/IO fields.

[multiphase]

Optional. Extra physics parameters when type = "multiphase".

[gravity_force] / [electric_force] / …

Optional. One top-level table per force model.

[boundary_conditions]

Optional. Boundary condition configuration (including nested wetting_params and hysteresis_params).

[output]

Optional. Output/saving overrides (results_dir, fields).

load_raw(path: str) dict[str, Any][source]

Parse path and return raw configuration dict.

Unlike load(), this returns the raw config dict without instantiating SimulationConfig. Useful for detecting array fields before expansion.

Parameters:

path – Filesystem path to a .toml file.

Returns:

Raw config dictionary (may contain array values for physics parameters, plus output overrides from [output]).

Raises:
load(path: str) tud_lbm.config.simulation_config.SimulationConfig[source]

Parse path and return a SimulationConfig.

Supports both scalar and array-valued parameters. For array parameters, use load_raw() followed by expand_config() to generate multiple configs.

Parameters:

path – Filesystem path to a .toml file.

Returns:

A validated SimulationConfig.

Raises:
save(config: tud_lbm.config.simulation_config.SimulationConfig, path: str) None[source]

Serialise config to a .toml file at path.

Delegates the field → section bucketing to build_sections() (shared by all adapters) and writes the result with tomli_w.

Parameters:
  • config – A validated SimulationConfig.

  • path – Destination file path.

Raises: