Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
187 commits
Select commit Hold shift + click to select a range
843f996
Scenarios: Prepare DataModel (#213)
FBumann Mar 31, 2025
8c4a45b
Feature/scenarios Transform data and update type hints (#215)
FBumann Apr 1, 2025
9905790
Feature/scenarios effects (#216)
FBumann Apr 2, 2025
24af8c6
ruff check and format
FBumann Apr 2, 2025
3792523
Fix coords in constraints and variables
FBumann Apr 2, 2025
dcc86f4
Feature/scenarios results (#220)
FBumann Apr 5, 2025
bd1d2b6
ruff check and format
FBumann Apr 5, 2025
28a46dc
Feature/scenarios dims order (#219)
FBumann Apr 5, 2025
479c1eb
Bugfix main results
FBumann Apr 9, 2025
a611672
Remove code duplicate
FBumann Apr 9, 2025
9a8724e
Feature/scenarios invest (#227)
FBumann Apr 9, 2025
39f9e4b
Feature/scenarios weights (#228)
FBumann Apr 9, 2025
75cb399
Feature/scenarios tests pandas (#229)
FBumann Apr 9, 2025
26bc447
ruff check
FBumann Apr 9, 2025
0241d1d
Merge branch 'main' into scenarios/main
FBumann Apr 11, 2025
6eeea72
Bugfix plausibility in Storage
FBumann Apr 11, 2025
ecf64d2
Bugfix check in Storage Model
FBumann Apr 11, 2025
091ab71
Improve example
FBumann Apr 11, 2025
0a7e336
ruff check
FBumann Apr 11, 2025
da60aa2
Merge branch 'main' into scenarios/main
FBumann Apr 11, 2025
8b5d2fc
Simplifying the investment with scenarios, by a simpler approach
FBumann Apr 14, 2025
f28db64
Simplifying the investment with scenarios
FBumann Apr 14, 2025
8696430
Bugfix in scenario selection
FBumann Apr 14, 2025
2d3f0ad
ruff check
FBumann Apr 14, 2025
c730b87
Scenarios/io (#244)
FBumann Apr 15, 2025
50bb559
Scenarios/testing (#246)
FBumann Apr 15, 2025
9ea8fba
ruff check
FBumann Apr 15, 2025
7f4fddb
Bugfix in _create_bounds_for_scenarios()
FBumann Apr 15, 2025
e2192da
exclude super long test
FBumann Apr 16, 2025
4ad86d5
exclude super long test - fix
FBumann Apr 16, 2025
967174c
Bugfix plot_node_balance_pie()
FBumann Apr 17, 2025
d24b5e7
Scenarios/fixes (#252)
FBumann Apr 22, 2025
a3c7d47
Scenarios/filter (#253)
FBumann Apr 22, 2025
0977c1f
Scenarios/drop suffix (#251)
FBumann Apr 22, 2025
5cf6e0e
Scenarios/bar plot (#254)
FBumann Apr 22, 2025
4cfa27f
Bugfix plotting
FBumann Apr 22, 2025
16fd74c
Fix example_calculation_types.py
FBumann Apr 22, 2025
67d1716
Scenarios/fixes (#255)
FBumann Apr 24, 2025
b968027
Scenarios/effects (#256)
FBumann Apr 25, 2025
9f2f38b
Scenarios/datasets results (#257)
FBumann Apr 28, 2025
dbfb1b5
ruff check
FBumann Apr 28, 2025
6738d34
ruff check
FBumann Apr 28, 2025
c64d12e
Scenarios/deprecation (#258)
FBumann Apr 28, 2025
0499497
Bugfix in plausibility_check: Index 0
FBumann Apr 28, 2025
ee00577
Set bargap to 0 in stacked bars
FBumann Apr 29, 2025
a11ed92
Ensure the size is always properly indexed in results.
FBumann Apr 29, 2025
2400244
ruff check
FBumann Apr 29, 2025
0f9b30a
BUGFIX in extract data, that causes coords in linopy to be incorrect …
FBumann May 5, 2025
26e89a9
Improve yaml formatting for model documentation (#259)
FBumann May 5, 2025
c0cbaae
Make the size/capacity a TimeSeries (#260)
FBumann May 5, 2025
67ebfbb
Scenarios/plot network (#262)
FBumann May 13, 2025
9edd1fa
Update deploy-docs.yaml:
FBumann May 13, 2025
d3c0c48
Bugfix DataConverter and add tests (#263)
FBumann May 13, 2025
e6e680c
Fix doc deployment to not publish on non stable releases
FBumann May 13, 2025
3d89b74
Remove unused code
FBumann May 15, 2025
cc772a4
Remove legend placing for better auto placing in plotly
FBumann May 16, 2025
d92349e
Fix plotly dependency
FBumann May 16, 2025
5c2900a
Improve validation when adding new effects
FBumann May 19, 2025
8e2e949
Merge branch 'main' into scenarios/main
FBumann Jun 14, 2025
8d3bbe9
Moved release notes to CHANGELOG.md
FBumann Jun 14, 2025
be6572d
Try to add to_dataset to Elements
FBumann Jun 23, 2025
f63db8b
Remove TimeSeries
FBumann Jun 23, 2025
167fb2c
Remove TimeSeries
FBumann Jun 23, 2025
fc76adf
Rename conversion method to pattern: to_...
FBumann Jun 23, 2025
cc7b155
Move methods to FlowSystem
FBumann Jun 23, 2025
ec6e792
Drop nan values across time dimension if present
FBumann Jun 23, 2025
b42aad2
Allow lists of values to create DataArray
FBumann Jun 24, 2025
b55af45
Update resolving of FlowSystem
FBumann Jun 24, 2025
d5ace96
Simplify TimeSeriesData
FBumann Jun 24, 2025
4187f30
Move TImeSeriesData to Structure and simplyfy to inherrit from xarray…
FBumann Jun 24, 2025
617600f
Adjust IO
FBumann Jun 24, 2025
e80bba0
Move TimeSeriesData back to core.py and fix Conversion
FBumann Jun 24, 2025
387cac6
Adjust IO to account for attrs of DataArrays in a Dataset
FBumann Jun 24, 2025
27734cf
Rename transforming and connection methods in FlowSystem
FBumann Jun 24, 2025
4915b81
Compacted IO methods
FBumann Jun 24, 2025
fc5549a
Remove infos()
FBumann Jun 24, 2025
299ff43
remove from_dict() and to_dict()
FBumann Jun 24, 2025
abc22b1
Update __str__ of Interface
FBumann Jun 24, 2025
9b4c44c
Improve str and repr
FBumann Jun 24, 2025
0ab7ea6
Improve str and repr
FBumann Jun 24, 2025
1dcbbb0
Add docstring
FBumann Jun 24, 2025
9aec990
Unify IO stuff in Interface class
FBumann Jun 24, 2025
e370311
Improve test tu utilize __eq__ method
FBumann Jun 24, 2025
793e820
Make Interface class more robust and improve exceptions
FBumann Jun 24, 2025
b87d979
Add option to copy Interfaces (And the FlowSystem)
FBumann Jun 24, 2025
8ec265e
Make a copy of a FLowSytsem that gets reused in a second Calculation
FBumann Jun 25, 2025
a46fe64
Remove test_timeseries.py
FBumann Jun 25, 2025
201d066
Reorganizing Datatypes
FBumann Jun 25, 2025
10d2925
Remove TImeSeries and TimeSeriesCollection entirely
FBumann Jun 25, 2025
cf9d17f
Remove old method
FBumann Jun 25, 2025
bd52e05
Add option to get structure with stats of dataarrays
FBumann Jun 25, 2025
aa36689
Change __str__ method
FBumann Jun 25, 2025
63b1c92
Remove old methods
FBumann Jun 25, 2025
29062fa
remove old imports
FBumann Jun 25, 2025
18c43e4
Add isel, sel and resample methods to FlowSystem
FBumann Jun 26, 2025
1f9ef07
Remove need for timeseries with extra timestep
FBumann Jun 26, 2025
5d88fde
Simplify IO of FLowSystem
FBumann Jun 26, 2025
1e94de3
Remove parameter timesteps from IO
FBumann Jun 26, 2025
e5828ad
Improve Exceptions and Docstrings
FBumann Jun 26, 2025
870efee
Improve isel sel and resample methods
FBumann Jun 26, 2025
e97ec5f
Change test
FBumann Jun 26, 2025
f15113e
Bugfix
FBumann Jun 26, 2025
284072e
Improve
FBumann Jun 26, 2025
ebbb5dd
Improve
FBumann Jun 26, 2025
a501e05
Add test for Storage Bounds
FBumann Jun 26, 2025
1825089
Add test for Storage Bounds
FBumann Jun 26, 2025
126b07f
CHANGELOG.md
FBumann Jun 26, 2025
94d841d
ruff check
FBumann Jun 26, 2025
c19edc8
Improve types
FBumann Jun 26, 2025
36cf47d
CHANGELOG.md
FBumann Jun 26, 2025
8f1261d
Bugfix in Storage
FBumann Jun 26, 2025
89d69f0
Revert changes in example_calculation_types.py
FBumann Jun 26, 2025
76f51a8
Revert changes in simple_example.py
FBumann Jun 26, 2025
0ff4d29
Add convenient access to Elements in FlowSystem
FBumann Jun 26, 2025
84c850b
Get Aggregated Calculation Working
FBumann Jun 27, 2025
8b9dabb
Segmented running with wrong results
FBumann Jun 27, 2025
7e72ab5
Use new persistent FLowSystem to create Calculations upfront
FBumann Jun 27, 2025
17632f3
Improve SegmentedCalcualtion
FBumann Jun 27, 2025
3c355c9
Improve SegmentedCalcualtion
FBumann Jun 27, 2025
f473ce5
Fix SegmentedResults IO
FBumann Jun 27, 2025
7869a72
ruff check
FBumann Jun 27, 2025
bb29ef2
Update example
FBumann Jun 27, 2025
8d96a49
Updated logger essages to use .label_full instead of .label
FBumann Jun 27, 2025
8240da1
Re-add parameters. Use deprecation warning instead
FBumann Jun 27, 2025
8ac2664
Update changelog
FBumann Jun 27, 2025
43a64ea
Improve warning message
FBumann Jun 27, 2025
7b67f8d
Merge branch 'unify-timesteps' into scenarios-no-ts/main
FBumann Jun 27, 2025
b3fe443
Merge
FBumann Jun 27, 2025
483ba12
Merge
FBumann Jun 28, 2025
dee1de4
Fit scenario weights to model coords when transforming
FBumann Jun 28, 2025
4ec3914
Merge
FBumann Jun 28, 2025
2554d8a
Removing logic between minimum, maximum and fixed size from InvestPar…
FBumann Jun 28, 2025
d062727
Remove selected_timesteps
FBumann Jun 28, 2025
6dc23f5
Improve TypeHints
FBumann Jun 28, 2025
e6100d6
New property on InvestParameters for min/max/fixed size
FBumann Jun 28, 2025
46f2035
Move logic for InvestParameters in Transmission to from Model to Inte…
FBumann Jun 28, 2025
6baeb8e
Make transformation of data more hierarchical (Flows after Components)
FBumann Jun 28, 2025
aeaaa83
Add scenario validation
FBumann Jun 28, 2025
15fd124
Change Transmission to have a "balanced" attribute. Change Tests acco…
FBumann Jun 28, 2025
d0b231d
Improve index validations
FBumann Jun 28, 2025
4ebe6a5
rename method in tests
FBumann Jun 29, 2025
6b56dac
Update DataConverter
FBumann Jun 29, 2025
a7ec994
Add DataFrame Support back
FBumann Jun 29, 2025
2a75ed3
Add copy() to DataConverter
FBumann Jun 29, 2025
dae9f01
Update fit_to_model_coords to take a list of coords
FBumann Jun 29, 2025
ba195ff
Make the DataConverter more universal by accepting a list of coords/dims
FBumann Jun 29, 2025
605f034
Update DataConverter for n-d arrays
FBumann Jun 29, 2025
6560006
Update DataConverter for n-d arrays
FBumann Jun 29, 2025
78132ef
Add extra tests for 3-dims
FBumann Jun 29, 2025
a53c116
Add FLowSystemDimension Type
FBumann Jun 30, 2025
2cb551b
Revert some logic about the fit_to_model coords
FBumann Jun 30, 2025
d7be766
Adjust FLowSystem IO for scenarios
FBumann Jun 30, 2025
e60dd07
BUGFIX: Raise Exception instead of logging
FBumann Jun 30, 2025
bd2f1b8
Change usage of TimeSeriesData
FBumann Jun 30, 2025
a7da9d2
Adjust logic to handle non scalars
FBumann Jun 30, 2025
b8f0e22
Adjust logic to _resolve_dataarray_reference into separate method
FBumann Jun 30, 2025
7123b6b
Update IO of FlowSystem
FBumann Jun 30, 2025
fa5475d
Improve get_coords()
FBumann Jul 2, 2025
80cb161
Adjust FlowSystem init for correct IO
FBumann Jul 2, 2025
81ad3ba
Add scenario to sel and isel methods, and dont normalize scenario wei…
FBumann Jul 2, 2025
691a45e
Improve scenario_weights_handling
FBumann Jul 2, 2025
3931ac5
Add warning for not scaled weights
FBumann Jul 2, 2025
75a45e1
Update test_scenarios.py
FBumann Jul 2, 2025
2882147
Improve util method
FBumann Jul 2, 2025
50491ff
Add objective to solution dataset.
FBumann Jul 2, 2025
4f3a798
Update handling of scenario_weights update tests
FBumann Jul 2, 2025
314aef9
Ruff check. Fix type hints
FBumann Jul 2, 2025
0302947
Fix type hints and improve None handling
FBumann Jul 3, 2025
40c437a
Fix coords in AggregatedCalculation
FBumann Jul 3, 2025
8d2d208
Improve Error Messages of DataConversion
FBumann Jul 3, 2025
9c0c95f
Allow multi dim data conversion and broadcasting by length
FBumann Jul 3, 2025
d568ad6
Improve DataConverter to handle multi-dim arrays
FBumann Jul 3, 2025
ffc196a
Rename methods and remove unused code
FBumann Jul 5, 2025
6142f44
Improve DataConverter by better splitting handling per datatype. Seri…
FBumann Jul 5, 2025
cec7367
Add test for error handling
FBumann Jul 5, 2025
eba1ec4
Update scenario example
FBumann Jul 5, 2025
5f97bf3
Fix Handling of TimeSeriesData
FBumann Jul 7, 2025
9351083
Improve DataConverter
FBumann Jul 7, 2025
99e6b19
Fix resampling of the FlowSystem
FBumann Jul 15, 2025
4981a9c
Improve Warning Message
FBumann Jul 15, 2025
516f45b
Add example that leverages resampling
FBumann Jul 15, 2025
ef0acfc
Add example that leverages resampling adn fixing of Investments
FBumann Jul 16, 2025
706c1ec
Add flag to Calculation if its modeled
FBumann Jul 16, 2025
a4cdb43
Make flag for connected_and_transformed FLowSystem public
FBumann Jul 16, 2025
148a852
Make Calcualtion Methods return themselfes to make them chainable
FBumann Jul 16, 2025
61755f9
Improve example
FBumann Jul 16, 2025
66f6a86
Improve Unreleased CHANGELOG.md
FBumann Jul 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
78 changes: 77 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,83 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [Unreleased - New Model dimensions]

## What's New

### Scenarios
Scenarios are a new feature of flixopt. They can be used to model uncertainties in the flow system, such as:
* Different demand profiles
* Different price forecasts
* Different weather conditions
They might also be used to model an evolving system with multiple investment periods. Each **scenario** might be a new year, a new month, or a new day, with a different set of investment decisions to take.

The weighted sum of the total objective effect of each scenario is used as the objective of the optimization.

#### Investments and scenarios
Scenarios allow for more flexibility in investment decisions.
You can decide to allow different investment decisions for each scenario, or to allow a single investment decision for a subset of all scenarios, while not allowing for an invest in others.
This enables the following use cases:
* Find the best investment decision for each scenario individually
* Find the best overall investment decision for possible scenarios (robust decision-making)
* Find the best overall investment decision for a subset of all scenarios

The last one might be useful if you want to model a system with multiple investment periods, where one investment decision is made for more than one scenario.
This might occur when scenarios represent years or months, while an investment decision influences the system for multiple years or months.


### Other new features
* Balanced storage - Storage charging and discharging sizes can now be forced to be equal in when optimizing their size.
* Feature 2 - Description


## [Unreleased - Data Management and IO]

### Changed
* **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
* **BREAKING**: Calculation.do_modeling() now returns the Calculation object instead of its linopy.Model
* FlowSystems can not be shared across multiple Calculations anymore. A copy of the FlowSystem is created instead, making every Calculation independent
* Type system overhaul - added clear separation between temporal and non-temporal data throughout codebase for better clarity
* FlowSystem data management simplified - removed `time_series_collection` pattern in favor of direct timestep properties
* Enhanced FlowSystem interface with improved `__repr__()` and `__str__()` methods

### Added
* Complete serialization infrastructure through `Interface` base class
* IO for all Interfaces and the FlowSystem with round-trip serialization support
* Automatic DataArray extraction and restoration
* NetCDF export/import capabilities for all Interface objects and FlowSystem
* JSON export for documentation purposes
* Recursive handling of nested Interface objects
* FlowSystem data manipulation methods
* `sel()` and `isel()` methods for temporal data selection
* `resample()` method for temporal resampling
* `copy()` method to create a copy of a FlowSystem, including all underlying Elements and their data
* `__eq__()` method for FlowSystem comparison
* Storage component enhancements
* `relative_minimum_final_charge_state` parameter for final state control
* `relative_maximum_final_charge_state` parameter for final state control
* Core data handling improvements
* `get_dataarray_stats()` function for statistical summaries
* Enhanced `DataConverter` class with better TimeSeriesData support
* Internal: Enhanced data handling methods
* `fit_to_model_coords()` method for data alignment
* `fit_effects_to_model_coords()` method for effect data processing
* `connect_and_transform()` method replacing several operations

### Fixed
* Enhanced NetCDF I/O with proper attribute preservation for DataArrays
* Improved error handling and validation in serialization processes
* Better type consistency across all framework components

### Know Issues
* Plotly >= 6 may raise errors if "nbformat" is not installed. We pinned plotly to <6, but this may be fixed in the future.
* 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.

### Deprecated
* 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.
* 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.
* 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.
* 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.

## [2.1.2] - 2025-06-14

Expand Down
115 changes: 115 additions & 0 deletions docs/user-guide/Mathematical Notation/Investment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Investments

## Current state
$$
\beta_{\text{invest}} \cdot \text{max}(\epsilon, \text V^{\text L}) \leq V \leq \beta_{\text{invest}} \cdot \text V^{\text U}
$$
With:
- $V$ = size
- $V^{\text L}$ = minimum size
- $V^{\text U}$ = maximum size
- $\epsilon$ = epsilon, a small number (such as $1e^{-5}$)
- $\beta_{invest} \in {0,1}$ = wether the size is invested or not

_Please edit the use cases as needed_
## Quickfix 1: Optimize the single best size overall
### Single variable
This is already possible and should be, as this is a needed use case
An additional factor to when the size is actually available might me practical (Which indicates the (fixed) time of investment)
## Math
$$
V(p) = V * a(p)
$$
with:
- $V$ = size
- $a(p)$ = factor for availlability per period

Factor $a(p)$ is simply multiplied with relative minimum or maximum(t). This is already possible by doing this yourself.
Effectively, the relative minimum or maximum are altered before using the same constraiints as before.
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.
**Therefore this might not be the best choice. See (#Variable per Scenario)

## Variable per Scenario
- **size** and **invest** as a variable per period $V(s)$ and $\beta_{invest}(s)$
- with scenario $s \in S$

### Usecase 1: Optimize the size for each Scenario independently
Restrictions are seperatly for each scenario
No changes needed. This could be the default behaviour.

### Usecase 2: Optimize ONE size for ALL scenarios
The size is the same globally, but not a scalar, but a variable per scenario $V(s)$
#### 2a: The same size in all scenarios
$$
V(s) = V(s') \quad \forall s,s' \in S
$$

With:
- $V(s)$ and $V(s')$ = size
- $S$ = set of scenarios

#### 2b: The same size, but can be 0 prior to the first increment
- Find the Optimal time of investment.
- Force an investment in a certain scenario (parameter optional as a list/array ob booleans)
- Combine optional and minimum/maximum size to force an investment inside a range if scenarios

$$
\beta_{\text{invest}}(s) \leq \beta_{\text{invest}}(s+1) \quad \forall s \in \{1,2,\ldots,S-1\}
$$

$$
V(s') - V(s) \leq M \cdot (2 - \beta_{\text{invest}}(s) - \beta_{\text{invest}}(s')) \quad \forall s, s' \in S
$$
$$
V(s') - V(s) \geq M \cdot (2 - \beta_{\text{invest}}(s) - \beta_{\text{invest}}(s')) \quad \forall s, s' \in S
$$

This could be the default behaviour. (which would be consistent with other variables)


### Switch

$$
\begin{aligned}
& \text{SWITCH}_s \in \{0,1\} \quad \forall s \in \{1,2,\ldots,S\} \\
& \sum_{s=1}^{S} \text{SWITCH}_s = 1 \\
& \beta_{\text{invest}}(s) = \sum_{s'=1}^{s} \text{SWITCH}_{s'} \quad \forall s \in \{1,2,\ldots,S\} \\
\end{aligned}
$$

$$
\begin{aligned}
& V(s) \leq V_{\text{actual}} \quad \forall s \in \{1,2,\ldots,S\} \\
& V(s) \geq V_{\text{actual}} - M \cdot (1 - \beta_{\text{invest}}(s)) \quad \forall s \in \{1,2,\ldots,S\}
\end{aligned}
$$




### Usecase 3: Find the best scenario to increment the size (Timing of the investment)
The size can only increment once (based on a starting point). This allows to optimize the timing of an investment.
#### Math
Treat $\beta_{invest}$ like an ON/OFF variable, and introduce a SwitchOn, that can only be active once.

*Thoughts:*
- Treating $\beta_{invest}$ like an ON/OFF variable suggest using the already presentconstraints linked to On/OffModel
- The timing could be constraint to be first in scenario x, or last in scenario y
- Restrict the number of consecutive scenarios
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)


### Others

#### Usecase 4: Only increase/decrease the size
Start from a certain size. For each scenario, the size can increase, but never decrease. (Or the other way around).
This would mean that a size expansion is possible,

#### Usecase 5: Restrict the increment in size per scenario
Restrict how much the size can increase/decrease for in scenario, based on the prior scenario.





Many more are possible
3 changes: 2 additions & 1 deletion examples/01_Simple/simple_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
discharging=fx.Flow('Q_th_unload', bus='Fernwärme', size=1000),
capacity_in_flow_hours=fx.InvestParameters(fix_effects=20, fixed_size=30, optional=False),
initial_charge_state=0, # Initial storage state: empty
relative_maximum_charge_state=1 / 100 * np.array([80, 70, 80, 80, 80, 80, 80, 80, 80, 80]),
relative_maximum_charge_state=1 / 100 * np.array([80, 70, 80, 80, 80, 80, 80, 80, 80]),
relative_maximum_final_charge_state=0.8,
eta_charge=0.9,
eta_discharge=1, # Efficiency factors for charging/discharging
relative_loss_per_hour=0.08, # 8% loss per hour. Absolute loss depends on current charge state
Expand Down
22 changes: 11 additions & 11 deletions examples/03_Calculation_types/example_calculation_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@

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

flow_system = fx.FlowSystem(timesteps)
flow_system.add_elements(
Expand Down Expand Up @@ -164,12 +164,12 @@
if full:
calculation = fx.FullCalculation('Full', flow_system)
calculation.do_modeling()
calculation.solve(fx.solvers.HighsSolver(0, 60))
calculation.solve(fx.solvers.HighsSolver(0.01/100, 60))
calculations.append(calculation)

if segmented:
calculation = fx.SegmentedCalculation('Segmented', flow_system, segment_length, overlap_length)
calculation.do_modeling_and_solve(fx.solvers.HighsSolver(0, 60))
calculation.do_modeling_and_solve(fx.solvers.HighsSolver(0.01/100, 60))
calculations.append(calculation)

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

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

fx.plotting.with_plotly(
get_solutions(calculations, 'BHKW2(Q_th)|flow_rate').to_dataframe(),
mode='line',
style='line',
title='BHKW2(Q_th) Flow Rate Comparison',
ylabel='Flow rate',
).write_html('results/BHKW2 Thermal Power.html')

fx.plotting.with_plotly(
get_solutions(calculations, 'costs(operation)|total_per_timestep').to_dataframe(),
mode='line',
style='line',
title='Operation Cost Comparison',
ylabel='Costs [€]',
).write_html('results/Operation Costs.html')

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

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