Skip to content

Commit 7467d2b

Browse files
authored
V3.0.0/main (#284)
* Bugfix plot_node_balance_pie() * Scenarios/fixes (#252) * BUGFIX missing conversion to TimeSeries * BUGFIX missing conversion to TimeSeries * Bugfix node_balance with flow_hours: Negate correctly * Scenarios/filter (#253) * Add containts and startswith to filter_solution * Scenarios/drop suffix (#251) Drop suffixes in plots and add the option to drop suffixes to sanitize_dataset() * Scenarios/bar plot (#254) * Add stacked bar style to plotting methods * Rename mode to style (line, bar, area, ...) * Bugfix plotting * Fix example_calculation_types.py * Scenarios/fixes (#255) * Fix indexing issue with only one scenario * Bugfix Cooling Tower * Add option for balanced Storage Flows (equalize size of charging and discharging) * Add option for balanced Storage Flows * Change error to warning (non-fixed size with piecewise conversion AND fixed_flow_rate with OnOff) * Bugfix in DataConverter * BUGFIX: Typo (total_max/total_min in Effect) * Bugfix in node_balance() (negating did not work when using flow_hours mode * Scenarios/effects (#256) * Add methods to track effect shares of components and Flows * Add option to include flows when retrieving effects * Add properties and methods to store effect results in a dataset * Reorder methods * Rename and improve docs * Bugfix test class name * Fix the Network algorithm to calculate the sum of parallel paths, and be independent on nr of nodes and complexity of the network * Add tests for the newtork chaining and the results of effect shares * Add methods to check for circular references * Add test to check for circular references * Update cycle checker to return the found cycles * Add checks in results to confirm effects are computed correctly * BUGFIX: Remove +1 from prior testing * Add option for grouped bars to plotting.with_plotly() and make lines of stacked bar plots invisible * Reconstruct FlowSystem in CalculationResults on demand. DEPRECATION in CalculationResults * ruff check * Bugfix: save flow_system data, not the flow_system * Update tests * Scenarios/datasets results (#257) * Use dataarray instead of dataset * Change effects dataset to dataarray and use nan when no share was found * Add method for flow_rates dataset * Add methods to get flow_rates and flow_hours as datasets * Rename the dataarrays to the flow * Preserve index order * Improve filter_edges_dataset() * Simplify _create_flow_rates_dataarray() * Add dataset for sizes of Flows * Extend results structure to contain flows AND start/end infos * Add FlowResults Object * BUGFIX:Typo in _ElementResults.constraints * Add flows to results of Nodes * Simplify dataarray creation and improve FlowResults * Add nice docstrings * Improve filtering of flow results * Improve filtering of flow results. Add attribute of component * Add big dataarray with all variables but indexed * Revert "Add big dataarray with all variables but indexed" This reverts commit 08cd8a1. * Improve filtering method for coords filter and add error handling for restoring the flow system * Remove unnecessary methods in results .from_json() * Ensure consistent coord ordering in Effects dataarray * Rename get_effects_per_component() * Make effects_per_component() a dataset instead of a dataarray * Improve backwards compatability * ruff check * ruff check * Scenarios/deprecation (#258) * Deprecate .active_timesteps * Improve logger warning * Starting release notes * Bugfix in plausibility_check: Index 0 * Set bargap to 0 in stacked bars * Ensure the size is always properly indexed in results. * ruff check * BUGFIX in extract data, that causes coords in linopy to be incorrect (scalar xarray.DataArrays) * Improve yaml formatting for model documentation (#259) * Make the size/capacity a TimeSeries (#260) * Scenarios/plot network (#262) * Catch bug in plot_network with 2D arrays * Add plot_network() to test_io.py * Update deploy-docs.yaml: Run on Release publishing instead of creation and only run for stable releases (vx.y.z) * Bugfix DataConverter and add tests (#263) * Fix doc deployment to not publish on non stable releases * Remove unused code * Remove legend placing for better auto placing in plotly * Fix plotly dependency * Improve validation when adding new effects * Moved release notes to CHANGELOG.md * Try to add to_dataset to Elements * Remove TimeSeries * Remove TimeSeries * Rename conversion method to pattern: to_... * Move methods to FlowSystem * Drop nan values across time dimension if present * Allow lists of values to create DataArray * Update resolving of FlowSystem * Simplify TimeSeriesData * Move TImeSeriesData to Structure and simplyfy to inherrit from xarray.DataArray * Adjust IO * Move TimeSeriesData back to core.py and fix Conversion * Adjust IO to account for attrs of DataArrays in a Dataset * Rename transforming and connection methods in FlowSystem * Compacted IO methods * Remove infos() * remove from_dict() and to_dict() * Update __str__ of Interface * Improve str and repr * Improve str and repr * Add docstring * Unify IO stuff in Interface class * Improve test tu utilize __eq__ method * Make Interface class more robust and improve exceptions * Add option to copy Interfaces (And the FlowSystem) * Make a copy of a FLowSytsem that gets reused in a second Calculation * Remove test_timeseries.py * Reorganizing Datatypes * Remove TImeSeries and TimeSeriesCollection entirely * Remove old method * Add option to get structure with stats of dataarrays * Change __str__ method * Remove old methods * remove old imports * Add isel, sel and resample methods to FlowSystem * Remove need for timeseries with extra timestep * Simplify IO of FLowSystem * Remove parameter timesteps from IO * Improve Exceptions and Docstrings * Improve isel sel and resample methods * Change test * Bugfix * Improve * Improve * Add test for Storage Bounds * Add test for Storage Bounds * CHANGELOG.md * ruff check * Improve types * CHANGELOG.md * Bugfix in Storage * Revert changes in example_calculation_types.py * Revert changes in simple_example.py * Add convenient access to Elements in FlowSystem * Get Aggregated Calculation Working * Segmented running with wrong results * Use new persistent FLowSystem to create Calculations upfront * Improve SegmentedCalcualtion * Improve SegmentedCalcualtion * Fix SegmentedResults IO * ruff check * Update example * Updated logger essages to use .label_full instead of .label * Re-add parameters. Use deprecation warning instead * Update changelog * Improve warning message * Merge * Merge * Fit scenario weights to model coords when transforming * Merge * Removing logic between minimum, maximum and fixed size from InvestParameters * Remove selected_timesteps * Improve TypeHints * New property on InvestParameters for min/max/fixed size * Move logic for InvestParameters in Transmission to from Model to Interface * Make transformation of data more hierarchical (Flows after Components) * Add scenario validation * Change Transmission to have a "balanced" attribute. Change Tests accordingly * Improve index validations * rename method in tests * Update DataConverter * Add DataFrame Support back * Add copy() to DataConverter * Update fit_to_model_coords to take a list of coords * Make the DataConverter more universal by accepting a list of coords/dims * Update DataConverter for n-d arrays * Update DataConverter for n-d arrays * Add extra tests for 3-dims * Add FLowSystemDimension Type * Revert some logic about the fit_to_model coords * Adjust FLowSystem IO for scenarios * BUGFIX: Raise Exception instead of logging * Change usage of TimeSeriesData * Adjust logic to handle non scalars * Adjust logic to _resolve_dataarray_reference into separate method * Update IO of FlowSystem * Improve get_coords() * Adjust FlowSystem init for correct IO * Add scenario to sel and isel methods, and dont normalize scenario weights * Improve scenario_weights_handling * Add warning for not scaled weights * Update test_scenarios.py * Improve util method * Add objective to solution dataset. * Update handling of scenario_weights update tests * Ruff check. Fix type hints * Fix type hints and improve None handling * Fix coords in AggregatedCalculation * Improve Error Messages of DataConversion * Allow multi dim data conversion and broadcasting by length * Improve DataConverter to handle multi-dim arrays * Rename methods and remove unused code * Improve DataConverter by better splitting handling per datatype. Series only matches index (for one dim). Numpy matches shape * Add test for error handling * Update scenario example * Fix Handling of TimeSeriesData * Improve DataConverter * Fix resampling of the FlowSystem * Improve Warning Message * Add example that leverages resampling * Add example that leverages resampling adn fixing of Investments * Add flag to Calculation if its modeled * Make flag for connected_and_transformed FLowSystem public * Make Calcualtion Methods return themselfes to make them chainable * Improve example * Improve Unreleased CHANGELOG.md * Add year coord to FlowSystem * Improve dimension handling * Change plotting to use an indexer instead * Change plotting to use an indexer instead * Use tuples to set dimensions in Models * Bugfix in validation logic and test * Improve Errors * Improve weights handling and rescaling if None * Fix typehint * Update Broadcasting in Storage Bounds and improve type hints * Make .get_model_coords() return an actual xr.Coordinates Object * Improve get_coords() * Rename SystemModel to FlowSystemModel * First steps * Improve Feature Patterns * Improve acess to variables via short names * Improve * Add naming options to big_m_binary_bounds() * Fix and improve FLowModeling with Investment * Improve * Tyring to improve the Methods for bounding variables in different scenarios * Improve BoundingPatterns * Improve BoundingPatterns * Improve BoundingPatterns * Fix duration Modeling * Fix On + Size * Fix InvestmentModel * Fix Models * Update constraint names in test * Fix OnOffModel for multiple Flows * Update constraint names in tests * Simplify * Improve handling of vars/cons and models * Revising the basic structure of a class Model * Revising the basic structure of a class Model * Simplify and focus more on own Model class * Update tests * Improve state computation in ModelingUtilities * Improve handling of previous flowrates * Imropove repr and submodel acess * Update access pattern in tests * Fix PiecewiseEffects and StorageModel * Fix StorageModel and Remove PreventSimultaniousUseModel * Fix Aggregation and SegmentedCalculation * Update tests * Loosen precision in tests * Update test_on_hours_computation.py and some types * Rename class Model to Submodel * rename sub_model to submodel everywhere * rename self.model to self.submodel everywhere * Rename .model with .submodel if its only a submodel * Rename .sub_models with .submodels * Improve repr * Improve repr * Include def do_modeling() into __init__() of models * Make properties private * Improve Inheritance of Models * V3.0.0/plotting (#285) * Use indexer to reliably plot solutions with and wihtout scenarios/years * ruff check * Improve typehints * Update CHANGELOG.md * Bugfix from renaming to .submodel * Bugfix from renaming to .submodel * Improve indexer in results plotting * rename register_submodel() to .add_submodels() adn add SUbmodels collection class * Add nice repr to FlowSystemModel and Submodel * Bugfix .variables and .constraints * Add type checks to modeling.py * Improve assertion in tests * Improve docstrings and register ElementModels directly in FlowSystemModel * Improve __repr__() * ruff check * Use new method to compare sets in tests * ruff check * Update Contribute.md, some dependencies and add pre-commit * Pre commit hook * Run Pre-Commit Hook for the first time * Fix link in README.md * Update Effect name in tests to be 'costs' instead of 'Costs' Everywhere Simplify testing by creating a Element Library * Improve some of the modeling and coord handling * Add tests with years and scenarios * Update tests to run with multiple coords * Fix Effects dataset computation in case of empty effects * Update Test for multiple dims Fix Dim order in scaled_bounds_with_state Bugfix logic in .use_switch_on * Fix test with multiple dims * Fix test with multiple dims * New test * New test for previous flow_rates * V3.0.0/main fit to model coords improve (#295) * Change fit_to_model_coords to work with a Collection of dims * Improve fit_to_model_coords * Improve CHANGELOG.md
1 parent e07dca8 commit 7467d2b

45 files changed

Lines changed: 44850 additions & 5287 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/deploy-docs.yaml

Whitespace-only changes.

CHANGELOG.md

Lines changed: 103 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,109 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [Unreleased]
8+
## [Unreleased - New Model dimensions]
9+
10+
### Changed
11+
* **BREAKING**: `relative_minimum_charge_state` and `relative_maximum_charge_state` don't have an extra timestep anymore. The final charge state can now be constrained by parameters `relative_minimum_final_charge_state` and `relative_maximum_final_charge_state` instead
12+
* **BREAKING**: Calculation.do_modeling() now returns the Calculation object instead of its linopy.Model
13+
* **BREAKING**: Renamed class `SystemModel` to `FlowSystemModel`
14+
* **BREAKING**: Renamed class `Model` to `Submodel`
15+
* **BREAKING**: Renamed `mode` parameter in plotting methods to `style`
16+
* FlowSystems can not be shared across multiple Calculations anymore. A copy of the FlowSystem is created instead, making every Calculation independent
17+
* Each Subcalculation in `SegmentedCalculation` now has its own distinct `FlowSystem` object
18+
* Type system overhaul - added clear separation between temporal and non-temporal data throughout codebase for better clarity
19+
* Enhanced FlowSystem interface with improved `__repr__()` and `__str__()` methods
20+
* Improved Model Structure - Views and organisation is now divided into:
21+
* Model: The main Model (linopy.Model) that is used to create and store the variables and constraints for the flow_system.
22+
* Submodel: The base class for all submodels. Each is a subset of the Model, for simpler acess and clearer code.
23+
*
24+
25+
#### Internal:
26+
* **BREAKING**: Calculation.do_modeling() now returns the Calculation object instead of its linopy.Model
27+
* **BREAKING**: Renamed class `SystemModel` to `FlowSystemModel`
28+
* **BREAKING**: Renamed class `Model` to `Submodel`
29+
* FlowSystem data management simplified - removed `time_series_collection` pattern in favor of direct timestep properties
30+
* Change modeling hierarchy to allow for more flexibility in future development. This leads to minimal changes in the access and creation of Submodels and their variables.
31+
* Added new module `.modeling`that contains Modelling primitives and utilities
32+
33+
34+
### Added
35+
* FlowSystem Restoring: The used FlowSystem will now get restired from the results (lazily). ALll Parameters can be safely acessed anytime after the solve.
36+
* FLowResults added as a new class to store the results of Flows. They can now be accessed directly.
37+
* Added precomputed DataArrays for `size`s, `flow_rate`s and `flow_hour`s.
38+
* Added `effects_per_component()`-Dataset to Results that stores the direct (and indirect) effects of each component. This greatly improves the evaluation of the impact of individual Components, even with many and complex effects.
39+
* Improved filter methods for Results
40+
41+
#### Scenarios
42+
Scenarios are a new feature of flixopt. They can be used to model uncertainties in the flow system, such as:
43+
* Different demand profiles
44+
* Different price forecasts
45+
* Different weather conditions
46+
47+
Common use cases are:
48+
* Find the best overall investment decision for possible scenarios (robust decision-making)
49+
* Find the best dispatch for the most important assets under uncertain price and weather conditions
50+
51+
The weighted sum of the total objective effect of each scenario is used as the objective of the optimization.
52+
53+
#### Years (Investment periods)
54+
A flixopt model might be modeled with a "year" dimension.
55+
This enables to model transformation pathways over multiple years.
56+
57+
%%%%% TODO: New Interfaces to model sizes changing over time, annuity, etc.
58+
59+
#### Improved Data handling: IO, resampling and more through xarray
60+
* Complete serialization infrastructure through `Interface` base class
61+
* IO for all Interfaces and the FlowSystem with round-trip serialization support
62+
* Automatic DataArray extraction and restoration
63+
* NetCDF export/import capabilities for all Interface objects and FlowSystem
64+
* JSON export for documentation purposes
65+
* Recursive handling of nested Interface objects
66+
* FlowSystem data manipulation methods
67+
* `sel()` and `isel()` methods for temporal data selection
68+
* `resample()` method for temporal resampling
69+
* `copy()` method to create a copy of a FlowSystem, including all underlying Elements and their data
70+
* `__eq__()` method for FlowSystem comparison
71+
* Storage component enhancements
72+
* `relative_minimum_final_charge_state` parameter for final state control
73+
* `relative_maximum_final_charge_state` parameter for final state control
74+
* Core data handling improvements
75+
* `get_dataarray_stats()` function for statistical summaries
76+
* Enhanced `DataConverter` class with better TimeSeriesData support
77+
* Internal: Enhanced data handling methods
78+
* `fit_to_model_coords()` method for data alignment
79+
* `fit_effects_to_model_coords()` method for effect data processing
80+
* `connect_and_transform()` method replacing several operations
81+
82+
#### Internal: Improved Model organisation and access
83+
* Clearer separation between the main Model and "Submodels"
84+
* Improved access to the Submodels and their variables, constraints and submodels
85+
* Added __repr__() for Submodels to easily inspect its content
86+
87+
88+
#### Other new features
89+
* Balanced storage - Storage charging and discharging sizes can now be forced to be equal in when optimizing their size.
90+
91+
#### Examples:
92+
* Added Example for 2-stage Investment decisions leveraging the resampling of a FlowSystem
93+
94+
95+
### Fixed
96+
* Enhanced NetCDF I/O with proper attribute preservation for DataArrays
97+
* Improved error handling and validation in serialization processes
98+
* Better type consistency across all framework components
99+
100+
101+
### Know Issues
102+
* Plotly >= 6 may raise errors if "nbformat" is not installed. We pinned plotly to <6, but this may be fixed in the future.
103+
* IO for single Interfaces/Elemenets to Datasets might not work properly if the Interface/Element is not part of a fully transformed and connected FlowSystem. This arrises from Numeric Data not being stored as xr.DataArray by the user. To avoid this, always use the `to_dataset()` on Elements inside a FlowSystem thats connected and transformed.
104+
105+
106+
### Deprecated
107+
* The `agg_group` and `agg_weight` parameters of `TimeSeriesData` are deprecated and will be removed in a future version. Use `aggregation_group` and `aggregation_weight` instead.
108+
* The `active_timesteps` parameter of `Calculation` is deprecated and will be removed in a future version. Use the new `sel(time=...)` method on the FlowSystem instead.
109+
* The assignment of Bus Objects to Flow.bus is deprecated and will be removed in a future version. Use the label of the Bus instead.
110+
* The usage of Effects objects in Dicts to assign shares to Effects is deprecated and will be removed in a future version. Use the label of the Effect instead.
9111

10112

11113
## [2.1.6] - 2025-09-02

docs/images/flixopt-icon.svg

Lines changed: 1 addition & 1 deletion
Loading
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Investments
2+
3+
## Current state
4+
$$
5+
\beta_{\text{invest}} \cdot \text{max}(\epsilon, \text V^{\text L}) \leq V \leq \beta_{\text{invest}} \cdot \text V^{\text U}
6+
$$
7+
With:
8+
- $V$ = size
9+
- $V^{\text L}$ = minimum size
10+
- $V^{\text U}$ = maximum size
11+
- $\epsilon$ = epsilon, a small number (such as $1e^{-5}$)
12+
- $\beta_{invest} \in {0,1}$ = wether the size is invested or not
13+
14+
_Please edit the use cases as needed_
15+
## Quickfix 1: Optimize the single best size overall
16+
### Single variable
17+
This is already possible and should be, as this is a needed use case
18+
An additional factor to when the size is actually available might me practical (Which indicates the (fixed) time of investment)
19+
## Math
20+
$$
21+
V(p) = V * a(p)
22+
$$
23+
with:
24+
- $V$ = size
25+
- $a(p)$ = factor for availlability per period
26+
27+
Factor $a(p)$ is simply multiplied with relative minimum or maximum(t). This is already possible by doing this yourself.
28+
Effectively, the relative minimum or maximum are altered before using the same constraiints as before.
29+
THis might lead to some issues regariding minimum_load factor, or others, as the size is not 0 in a scenario where the component cant produce.
30+
**Therefore this might not be the best choice. See (#Variable per Scenario)
31+
32+
## Variable per Scenario
33+
- **size** and **invest** as a variable per period $V(s)$ and $\beta_{invest}(s)$
34+
- with scenario $s \in S$
35+
36+
### Usecase 1: Optimize the size for each Scenario independently
37+
Restrictions are seperatly for each scenario
38+
No changes needed. This could be the default behaviour.
39+
40+
### Usecase 2: Optimize ONE size for ALL scenarios
41+
The size is the same globally, but not a scalar, but a variable per scenario $V(s)$
42+
#### 2a: The same size in all scenarios
43+
$$
44+
V(s) = V(s') \quad \forall s,s' \in S
45+
$$
46+
47+
With:
48+
- $V(s)$ and $V(s')$ = size
49+
- $S$ = set of scenarios
50+
51+
#### 2b: The same size, but can be 0 prior to the first increment
52+
- Find the Optimal time of investment.
53+
- Force an investment in a certain scenario (parameter optional as a list/array ob booleans)
54+
- Combine optional and minimum/maximum size to force an investment inside a range if scenarios
55+
56+
$$
57+
\beta_{\text{invest}}(s) \leq \beta_{\text{invest}}(s+1) \quad \forall s \in \{1,2,\ldots,S-1\}
58+
$$
59+
60+
$$
61+
V(s') - V(s) \leq M \cdot (2 - \beta_{\text{invest}}(s) - \beta_{\text{invest}}(s')) \quad \forall s, s' \in S
62+
$$
63+
$$
64+
V(s') - V(s) \geq M \cdot (2 - \beta_{\text{invest}}(s) - \beta_{\text{invest}}(s')) \quad \forall s, s' \in S
65+
$$
66+
67+
This could be the default behaviour. (which would be consistent with other variables)
68+
69+
70+
### Switch
71+
72+
$$
73+
\begin{aligned}
74+
& \text{SWITCH}_s \in \{0,1\} \quad \forall s \in \{1,2,\ldots,S\} \\
75+
& \sum_{s=1}^{S} \text{SWITCH}_s = 1 \\
76+
& \beta_{\text{invest}}(s) = \sum_{s'=1}^{s} \text{SWITCH}_{s'} \quad \forall s \in \{1,2,\ldots,S\} \\
77+
\end{aligned}
78+
$$
79+
80+
$$
81+
\begin{aligned}
82+
& V(s) \leq V_{\text{actual}} \quad \forall s \in \{1,2,\ldots,S\} \\
83+
& V(s) \geq V_{\text{actual}} - M \cdot (1 - \beta_{\text{invest}}(s)) \quad \forall s \in \{1,2,\ldots,S\}
84+
\end{aligned}
85+
$$
86+
87+
88+
89+
90+
### Usecase 3: Find the best scenario to increment the size (Timing of the investment)
91+
The size can only increment once (based on a starting point). This allows to optimize the timing of an investment.
92+
#### Math
93+
Treat $\beta_{invest}$ like an ON/OFF variable, and introduce a SwitchOn, that can only be active once.
94+
95+
*Thoughts:*
96+
- Treating $\beta_{invest}$ like an ON/OFF variable suggest using the already presentconstraints linked to On/OffModel
97+
- The timing could be constraint to be first in scenario x, or last in scenario y
98+
- Restrict the number of consecutive scenarios
99+
THis might needs the OnOffModel to be more generic (HOURS). Further, the span between scenarios needs to be weighted (like dt_in_hours), or the scenarios need to be measureable (integers)
100+
101+
102+
### Others
103+
104+
#### Usecase 4: Only increase/decrease the size
105+
Start from a certain size. For each scenario, the size can increase, but never decrease. (Or the other way around).
106+
This would mean that a size expansion is possible,
107+
108+
#### Usecase 5: Restrict the increment in size per scenario
109+
Restrict how much the size can increase/decrease for in scenario, based on the prior scenario.
110+
111+
112+
113+
114+
115+
Many more are possible

examples/01_Simple/simple_example.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@
6767
discharging=fx.Flow('Q_th_unload', bus='Fernwärme', size=1000),
6868
capacity_in_flow_hours=fx.InvestParameters(fix_effects=20, fixed_size=30, optional=False),
6969
initial_charge_state=0, # Initial storage state: empty
70-
relative_maximum_charge_state=1 / 100 * np.array([80, 70, 80, 80, 80, 80, 80, 80, 80, 80]),
70+
relative_maximum_charge_state=1 / 100 * np.array([80, 70, 80, 80, 80, 80, 80, 80, 80]),
71+
relative_maximum_final_charge_state=0.8,
7172
eta_charge=0.9,
7273
eta_discharge=1, # Efficiency factors for charging/discharging
7374
relative_loss_per_hour=0.08, # 8% loss per hour. Absolute loss depends on current charge state

examples/03_Calculation_types/example_calculation_types.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848

4949
# TimeSeriesData objects
5050
TS_heat_demand = fx.TimeSeriesData(heat_demand)
51-
TS_electricity_demand = fx.TimeSeriesData(electricity_demand, agg_weight=0.7)
52-
TS_electricity_price_sell = fx.TimeSeriesData(-(electricity_demand - 0.5), agg_group='p_el')
53-
TS_electricity_price_buy = fx.TimeSeriesData(electricity_price + 0.5, agg_group='p_el')
51+
TS_electricity_demand = fx.TimeSeriesData(electricity_demand, aggregation_weight=0.7)
52+
TS_electricity_price_sell = fx.TimeSeriesData(-(electricity_demand - 0.5), aggregation_group='p_el')
53+
TS_electricity_price_buy = fx.TimeSeriesData(electricity_price + 0.5, aggregation_group='p_el')
5454

5555
flow_system = fx.FlowSystem(timesteps)
5656
flow_system.add_elements(
@@ -164,12 +164,12 @@
164164
if full:
165165
calculation = fx.FullCalculation('Full', flow_system)
166166
calculation.do_modeling()
167-
calculation.solve(fx.solvers.HighsSolver(0, 60))
167+
calculation.solve(fx.solvers.HighsSolver(0.01 / 100, 60))
168168
calculations.append(calculation)
169169

170170
if segmented:
171171
calculation = fx.SegmentedCalculation('Segmented', flow_system, segment_length, overlap_length)
172-
calculation.do_modeling_and_solve(fx.solvers.HighsSolver(0, 60))
172+
calculation.do_modeling_and_solve(fx.solvers.HighsSolver(0.01 / 100, 60))
173173
calculations.append(calculation)
174174

175175
if aggregated:
@@ -178,7 +178,7 @@
178178
aggregation_parameters.time_series_for_low_peaks = [TS_electricity_demand, TS_heat_demand]
179179
calculation = fx.AggregatedCalculation('Aggregated', flow_system, aggregation_parameters)
180180
calculation.do_modeling()
181-
calculation.solve(fx.solvers.HighsSolver(0, 60))
181+
calculation.solve(fx.solvers.HighsSolver(0.01 / 100, 60))
182182
calculations.append(calculation)
183183

184184
# Get solutions for plotting for different calculations
@@ -194,34 +194,35 @@ def get_solutions(calcs: List, variable: str) -> xr.Dataset:
194194
# --- Plotting for comparison ---
195195
fx.plotting.with_plotly(
196196
get_solutions(calculations, 'Speicher|charge_state').to_dataframe(),
197-
mode='line',
197+
style='line',
198198
title='Charge State Comparison',
199199
ylabel='Charge state',
200200
).write_html('results/Charge State.html')
201201

202202
fx.plotting.with_plotly(
203203
get_solutions(calculations, 'BHKW2(Q_th)|flow_rate').to_dataframe(),
204-
mode='line',
204+
style='line',
205205
title='BHKW2(Q_th) Flow Rate Comparison',
206206
ylabel='Flow rate',
207207
).write_html('results/BHKW2 Thermal Power.html')
208208

209209
fx.plotting.with_plotly(
210210
get_solutions(calculations, 'costs(operation)|total_per_timestep').to_dataframe(),
211-
mode='line',
211+
style='line',
212212
title='Operation Cost Comparison',
213213
ylabel='Costs [€]',
214214
).write_html('results/Operation Costs.html')
215215

216216
fx.plotting.with_plotly(
217217
pd.DataFrame(get_solutions(calculations, 'costs(operation)|total_per_timestep').to_dataframe().sum()).T,
218-
mode='bar',
218+
style='stacked_bar',
219219
title='Total Cost Comparison',
220220
ylabel='Costs [€]',
221221
).update_layout(barmode='group').write_html('results/Total Costs.html')
222222

223223
fx.plotting.with_plotly(
224-
pd.DataFrame([calc.durations for calc in calculations], index=[calc.name for calc in calculations]), 'bar'
224+
pd.DataFrame([calc.durations for calc in calculations], index=[calc.name for calc in calculations]),
225+
'stacked_bar',
225226
).update_layout(title='Duration Comparison', xaxis_title='Calculation type', yaxis_title='Time (s)').write_html(
226227
'results/Speed Comparison.html'
227228
)

0 commit comments

Comments
 (0)