Spaces:
Running
Running
working status quo vs real
Browse files
src/pages/potential_analysis.py
CHANGED
|
@@ -3057,6 +3057,61 @@ else:
|
|
| 3057 |
except Exception as hpi_error:
|
| 3058 |
st.warning(f"⚠️ Heat pump integration could not be performed with the selected streams: {str(hpi_error)}")
|
| 3059 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3060 |
# Notes section
|
| 3061 |
st.markdown("---")
|
| 3062 |
st.markdown("##### Notes")
|
|
|
|
| 3057 |
except Exception as hpi_error:
|
| 3058 |
st.warning(f"⚠️ Heat pump integration could not be performed with the selected streams: {str(hpi_error)}")
|
| 3059 |
|
| 3060 |
+
# =====================================================
|
| 3061 |
+
# STATUS QUO VS PINCH ANALYSIS COMPARISON
|
| 3062 |
+
# =====================================================
|
| 3063 |
+
st.markdown("---")
|
| 3064 |
+
st.markdown("## Status Quo vs Pinch Analysis Comparison")
|
| 3065 |
+
|
| 3066 |
+
# Check if we have current energy demands
|
| 3067 |
+
current_demands = st.session_state.get('current_energy_demands', [])
|
| 3068 |
+
has_demands = any(d['heat_demand'] > 0 or d['cooling_demand'] > 0 for d in current_demands)
|
| 3069 |
+
|
| 3070 |
+
if not has_demands:
|
| 3071 |
+
st.info("💡 Current energy demands are required to calculate the difference to status quo. Please configure energy demand sets in the 'Current energy demand set' section above.")
|
| 3072 |
+
else:
|
| 3073 |
+
# Calculate total current demands
|
| 3074 |
+
total_current_heat = sum(d['heat_demand'] for d in current_demands)
|
| 3075 |
+
total_current_cooling = sum(d['cooling_demand'] for d in current_demands)
|
| 3076 |
+
|
| 3077 |
+
# Check if pinch analysis was run (look for the results in the session or check if we have the data)
|
| 3078 |
+
pinch_results_available = False
|
| 3079 |
+
pinch_heat_min = 0
|
| 3080 |
+
pinch_cooling_min = 0
|
| 3081 |
+
|
| 3082 |
+
# Try to get pinch results from the analysis above
|
| 3083 |
+
try:
|
| 3084 |
+
if 'results' in locals() and results:
|
| 3085 |
+
pinch_heat_min = results['hot_utility']
|
| 3086 |
+
pinch_cooling_min = results['cold_utility']
|
| 3087 |
+
pinch_results_available = True
|
| 3088 |
+
except:
|
| 3089 |
+
pinch_results_available = False
|
| 3090 |
+
|
| 3091 |
+
if pinch_results_available:
|
| 3092 |
+
# Calculate improvements (positive = savings, negative = additional need)
|
| 3093 |
+
heat_improvement = total_current_heat - pinch_heat_min
|
| 3094 |
+
cooling_improvement = total_current_cooling - pinch_cooling_min
|
| 3095 |
+
|
| 3096 |
+
# Create comparison table
|
| 3097 |
+
import pandas as pd
|
| 3098 |
+
|
| 3099 |
+
comparison_data = {
|
| 3100 |
+
'Energy Type': ['Heating Demand', 'Cooling Demand'],
|
| 3101 |
+
'Current Status Quo (kW)': [f"{total_current_heat:.1f}", f"{total_current_cooling:.1f}"],
|
| 3102 |
+
'Pinch Reduction (kW)': [f"-{pinch_heat_min:.1f}", f"-{pinch_cooling_min:.1f}"],
|
| 3103 |
+
'Savings (kW)': [f"-{heat_improvement:.1f}", f"-{cooling_improvement:.1f}"],
|
| 3104 |
+
'Percentage': [
|
| 3105 |
+
f"-{abs(heat_improvement) / total_current_heat * 100:.1f}%" if total_current_heat > 0 else "N/A",
|
| 3106 |
+
f"-{abs(cooling_improvement) / total_current_cooling * 100:.1f}%" if total_current_cooling > 0 else "N/A"
|
| 3107 |
+
]
|
| 3108 |
+
}
|
| 3109 |
+
|
| 3110 |
+
comparison_df = pd.DataFrame(comparison_data)
|
| 3111 |
+
st.table(comparison_df)
|
| 3112 |
+
else:
|
| 3113 |
+
st.warning("⚠️ Pinch analysis results not available. Please ensure you have selected at least 2 streams with complete data to run the analysis.")
|
| 3114 |
+
|
| 3115 |
# Notes section
|
| 3116 |
st.markdown("---")
|
| 3117 |
st.markdown("##### Notes")
|