Skip to content

Releases: flixOpt/flixopt

v1.0.1

14 Jan 09:22

Choose a tag to compare

flixOpt 1.0.1

In Short

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

v1.0.0

17 Dec 17:46
9f8ea0e

Choose a tag to compare

flixOpt v1.0.0

Months of work come to an end, resulting in a big new release of flixOpt

This rework targets the following issues of the flixOpt package:

Following PEP 8 for naming conventions

This lead to renaming pretty much all classes, functions and attributes. We are confident, that every renaming was done carefully and made the package easier to understand and more concise.
Highlights are:

  • nominal_val was renamed to size
  • val was renamed to flow_rate
  • onHours to consecutive_on_hours
  • ...

Simplifying the user interface

flixOpt is now meant to be imported as import flixOpt as fx. All relevant classes and functions will be available from there.

fx.Flow()
fx.Effect
fx.FullCalculation
fx.FlowSystem
fx.LinearConverter()
fx.Sink()

More is available through sub-modules:

fx.linear_converters.Boiler()
fx.linear_converters.CHP()
fx.solvers.HighsSolver()

explore by typing fx.and look for hints by your IDE

Changing the Hierarchy of classes

In conjunction with renaming, the package was restructured thoroughly.
Following highlights are to be named here:

  • splitting different calculation types into several classes (FullCaluclation, AggregatedCalcultion, Segmented Calculation)
  • Splitting the initiation of an Element (Flow, Bus, Effect, ...) form its mathematical modeling (FlowModel, BusModel, EffectModel). This greatly streamlines the interaction of Elements and Models, making the modeling much easier to understand. Further, this makes the implementation of new Features is way easier
  • Grouping parameters into classes and removing **kwargs from all elements: New classes InvestmentParameters and OnOffParameters are introduced, to centralize the documentation of them. This makes optional kwargs obsolete

Decoupling of math_modeling.py

The core of flixOpt, handling Variables, Constraints and the translation to pyomo (or other modeling languages) was greatly improved. It was completely decoupled from the rest of the package, making it actually usable for other purposes. Further, The Interfaces to solvers where moved into individual classes, accessible through solvers.py

Saving results to .json

Prior to this rework, the results of a Calculation were saved as a .yaml file for metadata and a .pickle file for the actual results. The .pickle format brings several issues through its nature of deserializing python objects, leading to security issues and issues with opening the file without having the unmodified python source code for the classes. To resolve these issues, the results of a flixOpt Calculation are now saved as .json instead of .pickle
Further, the .yaml file and .json file are now clearly structured and constructed in an easy to understand matter. This emnables for easy adoptions and changes in the future, and paths the way for simpler automated evaluation of results.
The .yaml file now holds all input parameters of the constructed FlowSystem, improving later evaluation possibilities.
The structure of both files is greatly improved and streamlined, improving automated evaluations and human readability.

Evaluation of results

As the results are now saved as a json file, the results can be analyzed anywhere and anytime. But flixOpt provides a .results.py module, which simplifies the process, providing several functions and classed for analyzing results and creating nice plots. These plots can be used as a baseline, or further modified by the user.
The plotting.py module, which the .results.yp relies on, can be used for that. But the user can modify the plots in any way he likes

This rework further brings new functionality

Logging

  • Proper Logging with pretty formatting is introduced, as well as saving the log to file
  • fx.setup_logging() for customizing the setup

Visualizing the FlowSystem as a Network

  • using pyvis, the created FlowSystem can now be visualized as an interactive html and shown in the browser. This enables for quick debugging and documentation.

Changing attributes of Elements (Flow, Component, ...) after initiation

  • The attributes of Elements are not transformed into other datatypes before FLowSystem is modeled. This enables the user to change attributes of Elements after creation without issues.

Testing

  • No Changes except name changes were made in tests. All Tests passing
  • examples were added to the test routine, to make sure they don't throw errors

Other changes

  • flixOpt now uses the modern pyproject.toml instead of setup.py
  • Output of HiGHS-Solver is printed to console (unfortunately only after the solve, and not in real time)

Bug fixes

  • The were basically no Bigs in the mathematical modeling itself. The reworks main purpose was to simplify the modeling process, to enable new features to be introduced, as well as to improve user experience.

Known issues

  • Solver output is not inserted into the flixOpt logger, and only printed to console.
  • Solver interfaces only accept a few parameters
  • Although type-hinted, no checks are performed to make sure the right datatypes are passed to Elements of flixOpt. We strongly recommend to make sure to not pass pd.DataFrames or pd.Series objects, but instead convert them to numpy.array() by calling
series = pd.Series([1, 2, 3, 4])
array = series.to_numpy()  # Output: [1 2 3 4]
# Or for DataFrames
df = pd.DataFrame({'A': [1, 2, 3, 4]})
array = df['A'].to_numpy()  # Output: [1 2 3 4]

Removed Functionality

Some of the functionality of flixOpt were removed. Many of them will be readied in the future, but with a different implementation:

  • Medium: Buses and Flows don't accept a Medium anymore. This was used for validation. We plan on reintroducing this with added functionality to the evaluation of results.
  • plotting: The potting in general was made much simpler. Currently, we sacrificed some plots for this simpler interface (pie charts, sorted charts ('Jahresdauerlinie)).

Contributors

Felix Bumann

Reviewers

Peter Stange
Felix Panitz

v0.2.0 - Initial Release of flixOpt

02 Jul 14:49

Choose a tag to compare

Initial Release of flixOpt

After being in development, this marks the first official release of flixOpt.
flixOpt and all its dependencies (including a solver) are now easily installable via pip (see README.md)
This release is a crucial part in preparation of a major new release with breaking changes, like new class names, module names and more.

API Changes

  • HiGHS-Solver API established - Open Source and faster than other open source solvers - https://highs.dev/#docs
  • Tutorial as Python Notebook added
  • Time-stamp labeling in .csv export of results enabled

New features

  • Limits per Time step for effects introduced
  • New Concept "exists" introduced.
    • This Attribute allows for multi-period investments.
    • Sets The upper limit for TS_Variables to 0 when Component or Flow does not exist.
    • The existence of flows is limited by the existence of the Component it is assigned to.
    • Vice versa, it's possible that a Flow does not yet exist while its component does (for ex. multiple grid connections).
    • The concept is introduced but, some aspects are not yet perfectly implemented.
  • str() and repr() methods added for major classes, which enables the printing of a system configuration for documentation and debugging purposes
  • Type Hints are added, improving readability and ease of use
  • New Module flixCompsExperimental.py with a experimental and early state implementation of a CHP-Plant with variable rate between heat and power

Bug fixes

  • Fixed onHoursSum_max & min in Flows
  • Fixed Segmented Modeling
  • Fixed max_rel in combination with no Investment in class Storage

Other changes

  • Proper tests are introduced for better and safer future developments

Known issues

  • onHoursSum_max & min are not yet working in Components (raises Error). Use Flow instead.
  • exists is still in early state:
    • on single flows does not work with segmentsOfFlows. use exists in Component
    • does not affect all properties that might be expected:
      • cFlow: on_valuesBeforeBegin, valuesBeforeBegin are still before the begin of the model, not at the time step before existence
      • cStorage: chargeState0_inFlowHours, charge_state_end_min, charge_state_end_max and fracLossPerHour are not affected by "exists". Only the available capacity is limited to 0

Contributors

Felix Bumann
Felix Panitz
Peter Stange