-
Notifications
You must be signed in to change notification settings - Fork 9
Add Multi-Period-modeling and stochastic modeling to flixopt #348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 15 commits
7467d2b
09949ea
334f183
579b894
c76fb29
cc3dbd4
b326abc
3b68281
af4a297
edfe995
2f2d083
acae94e
f1bd392
1c2b75a
c03e888
ec9d380
7c9f719
3c8f713
0eeb094
95f3666
fab3a01
a66ae3a
8ee16e4
10f455b
bc0a262
50f6cc0
5318503
28b78d5
a6c6432
d305b29
216ce17
c7f071b
515329f
af57316
9977ea5
5491664
b477686
6dc494e
5c50c1b
ec11000
834f44a
7ac41c2
f736ee6
d1557c6
0da3cdb
377eff1
84d4bba
c16c2b2
7c31a21
968d7fe
7f1d783
ac1c0bc
088cd3f
6dc3a83
3bc90f4
7624191
e7d2e9d
8cb3866
c8c1417
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,9 +45,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') | ||
|
|
||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| flow_system = fx.FlowSystem(timesteps) | ||
| flow_system.add_elements( | ||
|
|
@@ -136,7 +136,10 @@ | |
| a_strom_tarif = fx.Source( | ||
| 'Stromtarif', | ||
| source=fx.Flow( | ||
| 'P_el', bus='Strom', size=1000, effects_per_flow_hour={costs.label: TS_electricity_price_buy, CO2: 0.3} | ||
| 'P_el', | ||
| bus='Strom', | ||
| size=1000, | ||
| effects_per_flow_hour={costs.label: TS_electricity_price_buy, CO2.label: 0.3}, | ||
| ), | ||
| ) | ||
|
|
||
|
|
@@ -161,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: | ||
|
|
@@ -175,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 | ||
|
|
@@ -191,34 +194,35 @@ 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') | ||
|
|
||
|
Comment on lines
203
to
210
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Create results/ directory before writing HTML write_html will fail if the folder doesn’t exist. # --- Plotting for comparison ---
+ pathlib.Path('results').mkdir(parents=True, exist_ok=True)
fx.plotting.with_plotly(
get_solutions(calculations, 'Speicher|charge_state').to_dataframe(),
style='line',
title='Charge State Comparison',
ylabel='Charge state',
).write_html('results/Charge State.html')
🤖 Prompt for AI Agents |
||
| 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') | ||
|
Comment on lines
+226
to
230
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clarify plotting intent: stacked vs. grouped bars. The code uses If grouped bars are desired, consider using 🤖 Prompt for AI Agents |
||
|
|
||
| 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' | ||
| ) | ||
Uh oh!
There was an error while loading. Please reload this page.