Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
|
| 4 |
+
# Title and Description
|
| 5 |
+
st.title("SolarEase: Smart Solar System Designer")
|
| 6 |
+
st.markdown("Plan your solar system with ease! Input your appliances and get precise recommendations for solar panels, batteries, and inverters.")
|
| 7 |
+
|
| 8 |
+
# Sidebar for User Inputs
|
| 9 |
+
st.sidebar.title("Add Appliance Details")
|
| 10 |
+
appliance_name = st.sidebar.text_input("Appliance Name", "LED Bulb")
|
| 11 |
+
wattage = st.sidebar.number_input("Power (Watts)", min_value=1, value=10)
|
| 12 |
+
quantity = st.sidebar.number_input("Quantity", min_value=1, value=1)
|
| 13 |
+
usage_hours = st.sidebar.number_input("Daily Usage Hours", min_value=1, value=1)
|
| 14 |
+
add_appliance = st.sidebar.button("Add Appliance")
|
| 15 |
+
|
| 16 |
+
# Store Appliance Data
|
| 17 |
+
if "appliances" not in st.session_state:
|
| 18 |
+
st.session_state["appliances"] = []
|
| 19 |
+
|
| 20 |
+
if add_appliance:
|
| 21 |
+
st.session_state["appliances"].append({
|
| 22 |
+
"Appliance": appliance_name,
|
| 23 |
+
"Wattage": wattage,
|
| 24 |
+
"Quantity": quantity,
|
| 25 |
+
"Usage Hours": usage_hours,
|
| 26 |
+
})
|
| 27 |
+
|
| 28 |
+
# Display Appliance Table
|
| 29 |
+
if st.session_state["appliances"]:
|
| 30 |
+
st.subheader("Appliance Details")
|
| 31 |
+
df = pd.DataFrame(st.session_state["appliances"])
|
| 32 |
+
st.table(df)
|
| 33 |
+
|
| 34 |
+
# Backend Calculations
|
| 35 |
+
df["Daily Energy (Wh)"] = df["Wattage"] * df["Quantity"] * df["Usage Hours"]
|
| 36 |
+
total_energy = df["Daily Energy (Wh)"].sum() / 1000 # Convert to kWh
|
| 37 |
+
sunlight_hours = st.slider("Average Sunlight Hours", min_value=4, max_value=10, value=6)
|
| 38 |
+
panel_efficiency = st.slider("Solar Panel Efficiency (%)", min_value=10, max_value=25, value=20) / 100
|
| 39 |
+
battery_voltage = 12 # Typical battery voltage
|
| 40 |
+
battery_efficiency = 0.85 # 85% efficiency
|
| 41 |
+
|
| 42 |
+
# Solar Panel Calculations
|
| 43 |
+
total_panel_wattage = total_energy / (sunlight_hours * panel_efficiency)
|
| 44 |
+
total_battery_capacity = total_energy / (battery_voltage * battery_efficiency)
|
| 45 |
+
peak_load = df["Wattage"].sum()
|
| 46 |
+
|
| 47 |
+
# Display Results
|
| 48 |
+
st.subheader("Results")
|
| 49 |
+
st.write(f"**Total Daily Energy Consumption:** {total_energy:.2f} kWh")
|
| 50 |
+
st.write(f"**Required Solar Panel Capacity:** {total_panel_wattage:.2f} W")
|
| 51 |
+
st.write(f"**Battery Capacity Needed:** {total_battery_capacity:.2f} Ah")
|
| 52 |
+
st.write(f"**Recommended Inverter Size:** {peak_load:.2f} W")
|
| 53 |
+
|
| 54 |
+
# Optional Cost Estimation (commented for simplicity)
|
| 55 |
+
# cost_estimation = total_panel_wattage * 0.5 # Example cost formula
|
| 56 |
+
# st.write(f"**Estimated Cost:** ${cost_estimation:.2f}")
|
| 57 |
+
|
| 58 |
+
# Footer
|
| 59 |
+
st.markdown("---")
|
| 60 |
+
st.markdown("**Designed by Engr. Muhammad Arsalan**")
|