Config

Overview

Config stores the model configuration used to initialize model structure, input paths, and selected element sets.

Use Cases

  • Load model settings from YAML files.

  • Pass validated configuration objects into Model.from_config.

Examples

The code below shows an example of a full config.yaml file. This file is used to configure ZEN-creator and is required for it to run.

name: ''
source_path: null
output_folder: null
elements:
  insert:
    energy_system: ''
    set_sectors: []
    set_conversion_technologies: []
    set_storage_technologies: []
    set_transport_technologies: []
    set_retrofitting_technologies: []
    set_carriers: []
  exclude:
    energy_system: ''
    set_sectors: []
    set_conversion_technologies: []
    set_storage_technologies: []
    set_transport_technologies: []
    set_retrofitting_technologies: []
    set_carriers: []
system:
  set_nodes: []
  set_transport_technologies_loss_exponential: null
  use_existing_capacities: null
  allow_investment: null
  double_capex_transport: null
  unaggregated_time_steps_per_year: null
  conduct_time_series_aggregation: null
  aggregated_time_steps_per_year: null
  reference_year: null
  total_hours_per_year: null
  optimized_years: null
  interval_between_years: null
  use_rolling_horizon: null
  years_in_rolling_horizon: null
  years_in_decision_horizon: null
  conduct_scenario_analysis: null
  run_default_scenario: null
  clean_sub_scenarios: null
  storage_periodicity: null
  multiyear_periodicity: null
  exclude_parameters_from_TSA: null
  knowledge_depreciation_rate: null
  storage_charge_discharge_binary: null
energy_system:
  units:
    base_units: []
    definitions: {}
  parameters_interpolation_off:
    parameter_name: []
data:
  datasets:
    setting: true
  dataset_collections:
    setting: true

Summary

zen_creator.Config.__init__

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

Constructors

Config.__init__(**data: Any) None

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.

Member Reference

class zen_creator.Config(*, name: str = '', source_path: str | None = None, output_folder: str | None = None, elements: ~zen_creator.utils.default_config.ElementConfig = <factory>, system: ~zen_creator.utils.default_config.SystemConfig = <factory>, energy_system: ~zen_creator.utils.default_config.EnergySystemConfig = <factory>, data: ~zen_creator.utils.default_config.DataConfig = <factory>)

Bases: Subscriptable

Default configuration for ZEN-creator.

data: DataConfig
elements: ElementConfig
energy_system: EnergySystemConfig
classmethod load_from_existing_model(existing_model_path: str | Path) Config

Load a configuration from an existing model.

Parameters:

path (str | Path) – Path to the existing model.

Returns:

The loaded configuration object.

Return type:

Config

Raises:

TypeError – If path is not a string or Path.

classmethod load_from_yaml(path: str | Path) Config

Load a configuration from a YAML file.

Parameters:

path (str | Path) – Path to the YAML configuration file.

Returns:

The loaded configuration object.

Return type:

Config

Raises:
  • TypeError – If path is not a string or Path.

  • FileNotFoundError – If the configuration file does not exist.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'validate_assignment': True}

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

name: str
output_folder: str | None
source_path: str | None
system: SystemConfig
validate_config() None

Validate the configurations loaded from the config.

Raises:

ValueError – If one of the required config inputs does not exist. The required inputs are name, source_path, system.set_nodes, system.reference_year, system.optimized_years, and system.interval_between_years.