Repository navigation
Extract specific energy flows from results #275
Copy link
Copy link
Closed
Description
Activity
@PRse4 The Example doesnt run, as you reference a local
.csv-file. Can you include it here or mimic the included data?Alternatively, here is a altered example with the solution
import flixopt as fx import pandas as pd import numpy as np import pathlib from typing import Dict, List, Union import plotly.graph_objects as go if __name__ == '__main__': timesteps = pd.date_range('2024-01-01', periods=100, freq='15min') flow_system = fx.FlowSystem(timesteps) # Create FlowSystem electricity_generation_pv = np.sin(np.linspace(0, 2*np.pi, len(timesteps))) # --- Define Energy Buses --- # Represent node balances (inputs=outputs) for the different energy carriers (electricity, heat, gas) in the system flow_system.add_elements(fx.Bus('AC')) # --- Define Effects --- # Specify effects related to costs, CO2 emissions, and primary energy consumption costs = fx.Effect('costs', '€', 'Kosten', is_standard=True, is_objective=True) # --- Define Components --- battery = fx.Storage( 'battery', charging=fx.Flow('E_Batt_in', bus='AC', size=2500), discharging=fx.Flow('E_Batt_out', bus='AC', size=2500), capacity_in_flow_hours=5000, ) pv_system = fx.Source( 'PV', source=fx.Flow( 'E_el_PV_generation', bus='AC', size=1, fixed_relative_profile=electricity_generation_pv) ) flow_system.add_elements(costs, battery, pv_system) # --- Solve Flowsystem --- calculation = fx.FullCalculation(name='Full', flow_system=flow_system) calculation.do_modeling() calculation.solve(fx.solvers.HighsSolver(mip_gap=0.01, time_limit_seconds=1200)) # Get solution of batter variables all_variable_solutions_of_battery = calculation.results.components['battery'].solution charging_flow_rate = calculation.results.solution['battery(E_Batt_in)|flow_rate'] discharging_flow_rate = calculation.results.solution['battery(E_Batt_in)|flow_rate'] charge_state = calculation.results.solution['battery|charge_state'] # Convert to table df = all_variable_solutions_of_battery.to_pandas()
thanks
- locked and limited conversation to collaborators
on Jul 1, 2025
Metadata
Metadata
Assignees
Labels
No labels
How can I extract flows/flow rates from results of specific components?