Skip to content

flixOpt 1.0.1#122

Merged
baumbude merged 5 commits intomainfrom
next/patch
Jan 13, 2025
Merged

flixOpt 1.0.1#122
baumbude merged 5 commits intomainfrom
next/patch

Conversation

@FBumann
Copy link
Copy Markdown
Member

@FBumann FBumann commented Jan 11, 2025

flixOpt 1.0.1

This patch includes the following changes:

  • a config file for flixOpt, which the user can overwrite
  • default values being stored as empty dicts or empty lists instead of None whoever possible
  • default values in network visualization improved
  • typo in attribute of class CoolingTower fixed

Adding a CONFIG to flixOpt

To control central behaviour of flixOpt without hard coding it, we introduce a CONFIG.
a default config is provided and loaded when importing the package.
The values are validated on import.
CUrrently there are Configs for:

Logging

  • logging_level
  • logging_file
  • rich: use the rich logging (for terminal formatting)

modeling

  • BIG
  • EPSILON
  • BIG_BINARY_BOUND

If the user desires to change these values, he has to provide his own config_file.

import flixOpt as fx

import numpy as np

if __name__ == '__main__':
    fx.CONFIG.load_config('new_config.yaml')
    # --- Define Thermal Load Profile ---
    # Load profile (e.g., kW) for heating demand over time
    thermal_load_profile = np.array([30., 0., 20.])
    ...

This has to be done at the beginning of your script, to work as expected.
This is currently the only way to reliably change the config values!

To change the logging level without a config file, use the existing function:

fx.change_logging_level('DEBUG')

Default values changed: {} / [] instead of None

Instead of using None to represent the absence of certain values, empty Lists and Dictionaries are now used (when applicable).
This enables iterating over them easier.

LinearConverter

  • conversion_factors
  • segmented_conversion_factors

Flow

  • effects_per_flow_hour

InvestParameters

  • fix_effects
  • specific_effects
  • divest_effects

OnOffParameters

  • effects_per_switch_on
  • effects_per_running_hour

aggregation.py

AggregationParameters

  • time_series_for_high_peaks
  • time_series_for_low_peaks

Aggregation

  • weights
  • time_series_for_high_peaks
  • time_series_for_low_peaks

Other improvements:

Improved an Exception message in CalculationResults.to_dataframe(), regarding not found Elements

* Improved file handling in code

* Changing default values to make network plot more compact
* Using a config file in flixOpt for global settings

* Moving logging code into config.py

* Making load_config() availlable

* Using dataclasses to provide a robust Structure with validation for config.py

* Adding config.yaml to pyproject.yaml files

* Trying to improve the CONFIG handling

* Added to_dict()

* Added setup_logging() to load_config()

* Adding Config to SystemModel.infos()

* BUGFIX in test for new CONFIG
* Changed conversion_factors and segmented_conversion_factors to be [] or {} by default

* Changing type hint in Effect

* Changing type hint in Flow and making effects_per_flow_hour an empty {}

* Making defaults in effects in interface.py to {} instead of None

* Fixing if statement in conversion factors

* Changing None to empty lists and dicts in aggregation.py

* Changing logical checks for empty dicts and lists instead of None

* Improving error handling in CalculationResults.to_dataframe()
@FBumann FBumann requested review from PStange and baumbude January 11, 2025 13:19
@baumbude baumbude merged commit 405c245 into main Jan 13, 2025
@baumbude baumbude deleted the next/patch branch January 13, 2025 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants