Upload 3 files
Browse files- README.md +4 -4
- app.py +126 -0
- requirements.txt +8 -0
README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
| 1 |
---
|
| 2 |
-
title: Energy
|
| 3 |
emoji: π
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: streamlit
|
| 7 |
sdk_version: 1.41.1
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
-
short_description:
|
| 11 |
---
|
| 12 |
|
| 13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Load Energy
|
| 3 |
emoji: π
|
| 4 |
+
colorFrom: gray
|
| 5 |
+
colorTo: green
|
| 6 |
sdk: streamlit
|
| 7 |
sdk_version: 1.41.1
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
+
short_description: Optimize energy distribution in a microgrid.
|
| 11 |
---
|
| 12 |
|
| 13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import numpy as np
|
| 4 |
+
import plotly.graph_objects as go
|
| 5 |
+
|
| 6 |
+
# App Configuration
|
| 7 |
+
st.set_page_config(page_title="Energy Optimization AI", layout="wide", page_icon="π")
|
| 8 |
+
|
| 9 |
+
# App Title
|
| 10 |
+
st.title("πβ‘ Energy Optimization AI β‘π¬οΈ")
|
| 11 |
+
st.write("""
|
| 12 |
+
Optimize your energy distribution across renewable sources in real-time
|
| 13 |
+
to maximize efficiency, reduce costs, and promote sustainability.
|
| 14 |
+
""")
|
| 15 |
+
|
| 16 |
+
# Overview Section
|
| 17 |
+
st.header("Project Overview")
|
| 18 |
+
st.write("""
|
| 19 |
+
This application leverages **AI-based decision-making** to analyze your energy usage across solar and wind energy sources. It provides recommendations for optimizing cost-effectiveness and efficiency while maintaining sustainability goals. Use this tool to make informed energy distribution decisions for homes, industries, or renewable energy setups.
|
| 20 |
+
""")
|
| 21 |
+
|
| 22 |
+
# Input Section
|
| 23 |
+
st.header("Input Energy Details")
|
| 24 |
+
col1, col2 = st.columns(2)
|
| 25 |
+
|
| 26 |
+
# User Inputs
|
| 27 |
+
with col1:
|
| 28 |
+
st.subheader("Solar Energy")
|
| 29 |
+
solar_usage = st.slider("Solar Energy Usage (kWh):", 0.0, 1000.0, 200.0, step=10.0)
|
| 30 |
+
solar_cost = st.slider("Solar Cost per kWh:", 0.0, 10.0, 2.5, step=0.1)
|
| 31 |
+
|
| 32 |
+
with col2:
|
| 33 |
+
st.subheader("Wind Energy")
|
| 34 |
+
wind_usage = st.slider("Wind Energy Usage (kWh):", 0.0, 1000.0, 300.0, step=10.0)
|
| 35 |
+
wind_cost = st.slider("Wind Cost per kWh:", 0.0, 10.0, 1.8, step=0.1)
|
| 36 |
+
|
| 37 |
+
# Optimization Logic
|
| 38 |
+
if st.button("π Optimize"):
|
| 39 |
+
total_usage = solar_usage + wind_usage
|
| 40 |
+
|
| 41 |
+
if total_usage == 0:
|
| 42 |
+
st.error("β οΈ Please enter energy usage for at least one source.")
|
| 43 |
+
else:
|
| 44 |
+
total_cost = (solar_usage * solar_cost) + (wind_usage * wind_cost)
|
| 45 |
+
solar_share = (solar_usage / total_usage) * 100 if solar_usage > 0 else 0
|
| 46 |
+
wind_share = (wind_usage / total_usage) * 100 if wind_usage > 0 else 0
|
| 47 |
+
|
| 48 |
+
cost_effective_source = (
|
| 49 |
+
"solar" if solar_cost < wind_cost
|
| 50 |
+
else "wind" if wind_cost < solar_cost
|
| 51 |
+
else "both sources equally"
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
suggestion = (
|
| 55 |
+
f"Balance usage between solar and wind energy, prioritizing {cost_effective_source} for lower costs."
|
| 56 |
+
)
|
| 57 |
+
|
| 58 |
+
# Display Results
|
| 59 |
+
st.subheader("Optimization Results")
|
| 60 |
+
col3, col4 = st.columns(2)
|
| 61 |
+
with col3:
|
| 62 |
+
st.metric("Total Energy Usage", f"{total_usage:.2f} kWh")
|
| 63 |
+
st.metric("Solar Share", f"{solar_share:.2f}%")
|
| 64 |
+
with col4:
|
| 65 |
+
st.metric("Total Cost", f"{total_cost:.2f} currency")
|
| 66 |
+
st.metric("Wind Share", f"{wind_share:.2f}%")
|
| 67 |
+
|
| 68 |
+
st.success(suggestion)
|
| 69 |
+
|
| 70 |
+
# Charts
|
| 71 |
+
st.subheader("Visualization")
|
| 72 |
+
chart_data = pd.DataFrame(
|
| 73 |
+
{
|
| 74 |
+
"Energy Source": ["Solar", "Wind"],
|
| 75 |
+
"Usage (kWh)": [solar_usage, wind_usage],
|
| 76 |
+
"Cost (Currency)": [solar_usage * solar_cost, wind_usage * wind_cost],
|
| 77 |
+
}
|
| 78 |
+
)
|
| 79 |
+
|
| 80 |
+
# Improved Visualization with Plotly
|
| 81 |
+
fig = go.Figure()
|
| 82 |
+
|
| 83 |
+
# Add Usage Bar
|
| 84 |
+
fig.add_trace(go.Bar(
|
| 85 |
+
x=chart_data["Energy Source"],
|
| 86 |
+
y=chart_data["Usage (kWh)"],
|
| 87 |
+
name="Usage (kWh)",
|
| 88 |
+
marker_color='blue'
|
| 89 |
+
))
|
| 90 |
+
|
| 91 |
+
# Add Cost Bar
|
| 92 |
+
fig.add_trace(go.Bar(
|
| 93 |
+
x=chart_data["Energy Source"],
|
| 94 |
+
y=chart_data["Cost (Currency)"],
|
| 95 |
+
name="Cost (Currency)",
|
| 96 |
+
marker_color='green'
|
| 97 |
+
))
|
| 98 |
+
|
| 99 |
+
fig.update_layout(
|
| 100 |
+
barmode='group',
|
| 101 |
+
title="Energy Usage and Cost Comparison",
|
| 102 |
+
xaxis_title="Energy Source",
|
| 103 |
+
yaxis_title="Value",
|
| 104 |
+
legend_title="Metrics",
|
| 105 |
+
)
|
| 106 |
+
st.plotly_chart(fig, use_container_width=True)
|
| 107 |
+
|
| 108 |
+
# Explanation
|
| 109 |
+
st.subheader("Detailed Explanation")
|
| 110 |
+
st.write(
|
| 111 |
+
f"Based on your inputs, **{cost_effective_source} energy** is more cost-effective. "
|
| 112 |
+
f"This analysis helps balance your energy sources to minimize costs and maximize efficiency."
|
| 113 |
+
)
|
| 114 |
+
|
| 115 |
+
# Sidebar
|
| 116 |
+
st.sidebar.header("About")
|
| 117 |
+
st.sidebar.info("""
|
| 118 |
+
This tool helps optimize renewable energy usage for cost savings, sustainability,
|
| 119 |
+
and better energy distribution management.
|
| 120 |
+
""")
|
| 121 |
+
st.sidebar.header("How It Works")
|
| 122 |
+
st.sidebar.write("""
|
| 123 |
+
1. **Input Energy Details**: Specify the usage and cost for solar and wind energy.
|
| 124 |
+
2. **Optimization**: The tool calculates the total energy usage, cost, and shares of each source.
|
| 125 |
+
3. **Visual Analysis**: Get insights into cost-effective strategies with detailed charts and recommendations.
|
| 126 |
+
""")
|
requirements.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
transformers
|
| 3 |
+
torch
|
| 4 |
+
pandas
|
| 5 |
+
numpy
|
| 6 |
+
scipy
|
| 7 |
+
matplotlib
|
| 8 |
+
plotly
|