Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,59 +1,58 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
st.title("SolarEase:
|
| 6 |
-
st.
|
| 7 |
-
|
| 8 |
""")
|
| 9 |
|
| 10 |
-
#
|
| 11 |
st.sidebar.header("Add Appliance Details")
|
| 12 |
appliance_name = st.sidebar.text_input("Appliance Name", "LED Bulb")
|
| 13 |
-
wattage = st.sidebar.number_input("Wattage (Watts)", min_value=1, value=10
|
| 14 |
-
quantity = st.sidebar.number_input("Quantity", min_value=1, value=1
|
| 15 |
-
usage_hours = st.sidebar.number_input("Daily Usage Hours", min_value=1, value=1
|
| 16 |
-
|
| 17 |
|
| 18 |
-
#
|
| 19 |
if "appliances" not in st.session_state:
|
| 20 |
-
st.session_state
|
| 21 |
|
| 22 |
-
if
|
| 23 |
-
st.session_state
|
| 24 |
"Appliance": appliance_name,
|
| 25 |
"Wattage": wattage,
|
| 26 |
"Quantity": quantity,
|
| 27 |
-
"Usage Hours": usage_hours
|
| 28 |
})
|
| 29 |
|
| 30 |
# Display appliance table
|
| 31 |
-
if st.session_state
|
| 32 |
st.subheader("Appliance Details")
|
| 33 |
-
|
| 34 |
-
st.table(
|
| 35 |
|
| 36 |
-
#
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
| 39 |
|
|
|
|
|
|
|
| 40 |
sunlight_hours = st.slider("Average Sunlight Hours", min_value=4, max_value=10, value=6)
|
| 41 |
panel_efficiency = st.slider("Solar Panel Efficiency (%)", min_value=15, max_value=25, value=20) / 100
|
| 42 |
-
battery_voltage = 12 # Default battery voltage
|
| 43 |
-
battery_efficiency = 0.85 # Default battery efficiency
|
| 44 |
|
| 45 |
# Calculations
|
| 46 |
-
total_panel_wattage =
|
| 47 |
-
battery_capacity =
|
| 48 |
-
peak_load = appliance_df["Wattage"].sum()
|
| 49 |
|
| 50 |
-
# Display
|
| 51 |
-
st.
|
| 52 |
-
st.write(f"**Total Daily Energy Consumption:** {total_energy:.2f} kWh")
|
| 53 |
st.write(f"**Required Solar Panel Capacity:** {total_panel_wattage:.2f} W")
|
| 54 |
st.write(f"**Battery Capacity Needed:** {battery_capacity:.2f} Ah")
|
| 55 |
-
st.write(f"**Recommended Inverter Size:** {peak_load:.2f} W")
|
| 56 |
|
| 57 |
-
# Footer
|
| 58 |
st.markdown("---")
|
| 59 |
-
st.markdown("**
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
|
| 4 |
+
# App Title
|
| 5 |
+
st.title("SolarEase: Solar System Planner")
|
| 6 |
+
st.write("""
|
| 7 |
+
This app calculates the total energy requirements and suggests a solar panel, battery, and inverter configuration.
|
| 8 |
""")
|
| 9 |
|
| 10 |
+
# Input Section
|
| 11 |
st.sidebar.header("Add Appliance Details")
|
| 12 |
appliance_name = st.sidebar.text_input("Appliance Name", "LED Bulb")
|
| 13 |
+
wattage = st.sidebar.number_input("Wattage (Watts)", min_value=1, value=10)
|
| 14 |
+
quantity = st.sidebar.number_input("Quantity", min_value=1, value=1)
|
| 15 |
+
usage_hours = st.sidebar.number_input("Daily Usage Hours", min_value=1, value=1)
|
| 16 |
+
add_button = st.sidebar.button("Add Appliance")
|
| 17 |
|
| 18 |
+
# Session state for storing appliances
|
| 19 |
if "appliances" not in st.session_state:
|
| 20 |
+
st.session_state.appliances = []
|
| 21 |
|
| 22 |
+
if add_button:
|
| 23 |
+
st.session_state.appliances.append({
|
| 24 |
"Appliance": appliance_name,
|
| 25 |
"Wattage": wattage,
|
| 26 |
"Quantity": quantity,
|
| 27 |
+
"Usage Hours": usage_hours
|
| 28 |
})
|
| 29 |
|
| 30 |
# Display appliance table
|
| 31 |
+
if st.session_state.appliances:
|
| 32 |
st.subheader("Appliance Details")
|
| 33 |
+
appliances_df = pd.DataFrame(st.session_state.appliances)
|
| 34 |
+
st.table(appliances_df)
|
| 35 |
|
| 36 |
+
# Calculate Total Energy Consumption
|
| 37 |
+
appliances_df["Daily Energy (Wh)"] = (
|
| 38 |
+
appliances_df["Wattage"] * appliances_df["Quantity"] * appliances_df["Usage Hours"]
|
| 39 |
+
)
|
| 40 |
+
total_energy_kwh = appliances_df["Daily Energy (Wh)"].sum() / 1000 # Convert to kWh
|
| 41 |
|
| 42 |
+
# Input for Solar System Configuration
|
| 43 |
+
st.subheader("Solar System Configuration")
|
| 44 |
sunlight_hours = st.slider("Average Sunlight Hours", min_value=4, max_value=10, value=6)
|
| 45 |
panel_efficiency = st.slider("Solar Panel Efficiency (%)", min_value=15, max_value=25, value=20) / 100
|
|
|
|
|
|
|
| 46 |
|
| 47 |
# Calculations
|
| 48 |
+
total_panel_wattage = total_energy_kwh / (sunlight_hours * panel_efficiency)
|
| 49 |
+
battery_capacity = total_energy_kwh / 12 # Assume 12V system
|
|
|
|
| 50 |
|
| 51 |
+
# Display Results
|
| 52 |
+
st.write(f"**Total Energy Consumption:** {total_energy_kwh:.2f} kWh")
|
|
|
|
| 53 |
st.write(f"**Required Solar Panel Capacity:** {total_panel_wattage:.2f} W")
|
| 54 |
st.write(f"**Battery Capacity Needed:** {battery_capacity:.2f} Ah")
|
|
|
|
| 55 |
|
|
|
|
| 56 |
st.markdown("---")
|
| 57 |
+
st.markdown("**Developed by Engr. Muhammad Arsalan**")
|
| 58 |
+
|