Spaces:
Build error
Build error
| import streamlit as st | |
| import pandas as pd | |
| # Title and App Description | |
| st.title("SolarEase: Smart Solar System Designer") | |
| st.markdown(""" | |
| Plan your solar system with ease! Input details for your appliances, and this app will recommend the necessary solar panels, batteries, and inverter capacity. | |
| """) | |
| # Sidebar for appliance input | |
| st.sidebar.header("Add Appliance Details") | |
| appliance_name = st.sidebar.text_input("Appliance Name", "LED Bulb") | |
| wattage = st.sidebar.number_input("Wattage (Watts)", min_value=1, value=10, step=1) | |
| quantity = st.sidebar.number_input("Quantity", min_value=1, value=1, step=1) | |
| usage_hours = st.sidebar.number_input("Daily Usage Hours", min_value=1, value=1, step=1) | |
| add_appliance = st.sidebar.button("Add Appliance") | |
| # Store appliance data | |
| if "appliances" not in st.session_state: | |
| st.session_state["appliances"] = [] | |
| if add_appliance: | |
| st.session_state["appliances"].append({ | |
| "Appliance": appliance_name, | |
| "Wattage": wattage, | |
| "Quantity": quantity, | |
| "Usage Hours": usage_hours, | |
| }) | |
| # Display appliance table | |
| if st.session_state["appliances"]: | |
| st.subheader("Appliance Details") | |
| appliance_df = pd.DataFrame(st.session_state["appliances"]) | |
| st.table(appliance_df) | |
| # Perform backend calculations | |
| appliance_df["Daily Energy (Wh)"] = appliance_df["Wattage"] * appliance_df["Quantity"] * appliance_df["Usage Hours"] | |
| total_energy = appliance_df["Daily Energy (Wh)"].sum() / 1000 # Convert Wh to kWh | |
| sunlight_hours = st.slider("Average Sunlight Hours", min_value=4, max_value=10, value=6) | |
| panel_efficiency = st.slider("Solar Panel Efficiency (%)", min_value=15, max_value=25, value=20) / 100 | |
| battery_voltage = 12 # Default battery voltage | |
| battery_efficiency = 0.85 # Default battery efficiency | |
| # Calculations | |
| total_panel_wattage = total_energy / (sunlight_hours * panel_efficiency) | |
| battery_capacity = total_energy / (battery_voltage * battery_efficiency) | |
| peak_load = appliance_df["Wattage"].sum() | |
| # Display results | |
| st.subheader("Solar System Recommendations") | |
| st.write(f"**Total Daily Energy Consumption:** {total_energy:.2f} kWh") | |
| st.write(f"**Required Solar Panel Capacity:** {total_panel_wattage:.2f} W") | |
| st.write(f"**Battery Capacity Needed:** {battery_capacity:.2f} Ah") | |
| st.write(f"**Recommended Inverter Size:** {peak_load:.2f} W") | |
| # Footer | |
| st.markdown("---") | |
| st.markdown("**Designed by Engr. Muhammad Arsalan**") | |