You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Simplify Data Handling by not reusing the same FLowSystem object in multiple Calculations (use a copy) #272
Simplify Data Handling by not reusing the same FLowSystem object in multiple Calculations (use a copy)
Problem Description
When a single FlowSystem instance is used across multiple Calculation objects, it can lead to data contamination, model overwriting, and state confusion that can cause unexpected results and difficult-to-debug issues.
Currently, this is cared for inside flixopt, but is quite painful to maintain, test and keep robust.
Issues Identified
1. Data Contamination
Modifications in one calculation affect all others sharing the same FlowSystem
Parameter changes are not isolated between calculations
2. Shared Elements
Elements (FLow, Bus, Effect, ...) are shared across Calculations, as the full FlowSystem is.
2. Model Overwriting
do_modeling() calls overwrite the Models of the Elements
Previous calculation models are lost
Only the last calculation's model is retained
3. State Confusion
transform_data() can only be called once successfully
Subsequent calls on shared FlowSystem produce warnings
Transformation state is shared across all calculations
Expected Behavior
Each Calculation should have an independent FlowSystem (including independent Elements and Interfaces) to ensure:
✅ Isolated modifications between calculations
✅ Preserved models for each calculation
✅ Independent transformation state
✅ Predictable and debuggable behavior
Proposed Solution
Automatic Copying of FlowSystem
Automatically create a copy when FlowSystem is reused:
Activity
FBumann commentedon Oct 8, 2025
Closed somewhere in #348