Removed config - added distinction for thermal/intermittent units#23
Open
AlessandroPampado99 wants to merge 4 commits intomainfrom
Open
Removed config - added distinction for thermal/intermittent units#23AlessandroPampado99 wants to merge 4 commits intomainfrom
AlessandroPampado99 wants to merge 4 commits intomainfrom
Conversation
davide-f
reviewed
Feb 27, 2026
Comment on lines
+83
to
176
| Parameters | ||
| ---------- | ||
| unitblocks : dict | ||
| Dictionary that holds the parameters for each unit block, organized by network components. | ||
|
|
||
| IntermittentUnitBlock_parameters : dict | ||
| Parameters for an IntermittentUnitBlock, like solar and wind turbines. | ||
| The values set to a float number are absent in Pypsa, while lambda functions are used to get data from | ||
| Pypa DataFrames | ||
|
|
||
| ThermalUnitBlock_parameters : dict | ||
| Parameters for a ThermalUnitBlock | ||
| merge_links : bool | str | Sequence[str], default True | ||
| Controls whether store-related charge/discharge link pairs are merged into a single | ||
| "merged link" representation (useful to match PyPSA-Eur modelling conventions). | ||
|
|
||
| Supported values: | ||
| - False: disable merging entirely. | ||
| - True: enable merging for built-in safe presets (TES, battery, H2 reversed). | ||
| - str / list[str]: enable merging for a subset of presets and/or custom tags. | ||
| If custom tags are provided (i.e., values not in {"tes","battery","h2"}), | ||
| a `merge_selector` MUST be provided. | ||
|
|
||
| merge_selector : callable, optional | ||
| Optional power-user hook to authorize additional merges beyond the built-in presets. | ||
|
|
||
| Signature: | ||
| merge_selector(n, store_name, srow, charge_row, discharge_row) -> bool | ||
|
|
||
| Notes: | ||
| - If `merge_links` contains custom entries, this selector is required. | ||
| - Any exception raised inside the selector will cause the corresponding store | ||
| merge to be skipped. | ||
|
|
||
| capacity_expansion_ucblock : bool, default True | ||
| Selects the internal block structure / modelling mode: | ||
| - True -> build UCBlock-style representation. | ||
| - False -> build InvestmentBlock-style representation. | ||
|
|
||
| This flag is used to choose default SMS++ templates when `configfile="auto"`. | ||
|
|
||
| enable_thermal_units : bool, default False | ||
| Controls whether "thermal" generator units are allowed in the transformation. | ||
|
|
||
| Behaviour: | ||
| - False: all non-slack generators are treated as intermittent (i.e., no thermals). | ||
| - True : both intermittent and thermal generators are allowed. | ||
|
|
||
| When enabled, the intermittent/thermal split is determined by `intermittent_carriers` | ||
| (user override) or by the library default set (typically `renewable_carriers` from constants). | ||
|
|
||
| intermittent_carriers : str | Sequence[str], optional | ||
| Defines which generator carriers should be treated as intermittent when | ||
| `enable_thermal_units=True`. | ||
|
|
||
| Behaviour: | ||
| - None: use the library default intermittent set (typically `renewable_carriers`). | ||
| - str / list[str]: explicit override (case-insensitive). | ||
|
|
||
| Notes: | ||
| - This parameter is ignored when `enable_thermal_units=False` (since everything | ||
| is treated as intermittent anyway, except slack/load-shedding carriers). | ||
|
|
||
| workdir : str | Path, default "output" | ||
| Output directory for SMS++ artifacts. The directory is created if it does not exist. | ||
|
|
||
| name : str, default "test_case" | ||
| Case name used to render file templates (e.g., "temp_{name}.nc"). | ||
|
|
||
| overwrite : bool, default True | ||
| If True, existing artifacts at the resolved paths are removed before optimization. | ||
|
|
||
| fp_temp : str | Path, default "temp_{name}.nc" | ||
| Temporary network file path template passed to `SMSNetwork.optimize(fp_temp=...)`. | ||
| If relative, it is interpreted relative to `workdir`. | ||
| Supports formatting with `{name}`. | ||
|
|
||
| fp_log : str | Path | None, default "log_{name}.txt" | ||
| Log file path template passed to `SMSNetwork.optimize(fp_log=...)`. | ||
| If None, logging to file is disabled. Supports `{name}`. | ||
|
|
||
| fp_solution : str | Path | None, default "solution_{name}.nc" | ||
| Solution file path template passed to `SMSNetwork.optimize(fp_solution=...)`. | ||
| If None, solution writing may be disabled depending on solver behaviour. Supports `{name}`. | ||
|
|
||
| configfile : str | Path | pysmspp.SMSConfig | None, default "auto" | ||
| SMS++ configuration input passed to `SMSNetwork.optimize(configfile=...)`. | ||
|
|
||
| Supported values: | ||
| - "auto" or None: use built-in default template based on `capacity_expansion_ucblock`. | ||
| - str/Path: interpreted as a template path used to build `pysmspp.SMSConfig(template=...)`. | ||
| - pysmspp.SMSConfig: used directly. | ||
|
|
||
| pysmspp_options : Mapping[str, Any], optional | ||
| Additional keyword arguments forwarded to `SMSNetwork.optimize(...)`. | ||
|
|
||
| Typical keys include (all optional; pySMSpp provides defaults): | ||
| - smspp_solver : str | SMSPPSolverTool | ||
| - inner_block_name : str | ||
| - logging : bool | ||
| - tracking_period : float | ||
|
|
||
| Any other keys are forwarded as solver-constructor kwargs (power-user usage). | ||
| """ |
Member
There was a problem hiding this comment.
These entries shall be moved into the init they are the arguments of the init
Member
There was a problem hiding this comment.
The introduction of this class shall provide info on the class and how to use it.
It can be another PR
Comment on lines
+192
to
+197
| fp_temp: Union[str, Path] = "temp_{name}.nc", | ||
| fp_log: Optional[Union[str, Path]] = "log_{name}.txt", | ||
| fp_solution: Optional[Union[str, Path]] = "solution_{name}.nc", | ||
|
|
||
| Methods: | ||
| ---------- | ||
| init : Start the workflow of the class | ||
|
|
||
| """ | ||
|
|
||
| # Class with conversion dicts for PyPSA-SMS++ | ||
| config_conv = TransformationConfig() | ||
| # Work on a private copy so we can safely mutate dicts | ||
| self.config = deepcopy(config_conv) | ||
|
|
||
| # Config file | ||
| self.cfg = load_any_config( | ||
| config, | ||
| defaults=default_transformation_cfg(), | ||
| as_attrdict=True, | ||
| ) | ||
| # --- SMS++ --- | ||
| configfile: Optional[Union[str, Path, "pysmspp.SMSConfig"]] = "auto", |
Member
There was a problem hiding this comment.
these are pysmspp_options. Is there a reason to place them separately?
| "Bus": "buses" | ||
| } | ||
|
|
||
| self.max_hours_stores = 1 |
Member
There was a problem hiding this comment.
? this should be documented. why 1?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@davide-f FYI. This PR is removing the use of the YAML config file passing parameters to pypsa2smspp directly. It distinguishes unit commitment cases directly, as well as distinction between capacity expansion with ucblock (base case) or investment