Spaces:
Sleeping
Sleeping
File size: 3,549 Bytes
949d1e6 c3713aa c83f986 949d1e6 46c310e c83f986 46c310e c83f986 46c310e c83f986 46c310e c83f986 46c310e c83f986 301aab4 46c310e 301aab4 949d1e6 c83f986 46c310e c83f986 301aab4 46c310e c83f986 301aab4 c83f986 46c310e c83f986 46c310e c83f986 301aab4 46c310e 301aab4 c83f986 301aab4 c83f986 301aab4 46c310e c83f986 46c310e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
import streamlit as st
# Title of the app
st.title("Complete Solar Energy Calculator")
# Input Section: User inputs for energy usage, costs, etc.
st.header("Enter your energy usage and system parameters:")
# Average Monthly Usage in kWh
monthly_usage = st.number_input("Enter your average monthly energy usage (kWh):", min_value=0.0)
# Peak Demand in kW
peak_demand = st.number_input("Enter your peak demand (kW):", min_value=0.0)
# Solar Panel Efficiency
solar_panel_efficiency = st.number_input("Enter the efficiency of your solar panels (0 to 100):", min_value=0.0, max_value=100.0)
# Panel Output in Watts (W)
panel_output_watts = st.number_input("Enter the solar panel output (in watts, W):", min_value=0)
# Inverter Cost (per inverter)
inverter_cost = st.number_input("Enter the cost of the inverter (in your local currency):", min_value=0.0)
# Cost per Solar Panel
panel_cost = st.number_input("Enter the cost per solar panel (in your local currency):", min_value=0.0)
# Average Sunlight Hours per Day
sunlight_hours = st.number_input("Enter the average sunlight hours per day:", min_value=0.0)
# Calculations Section
if panel_output_watts > 0 and sunlight_hours > 0:
# Determine Annual Energy Consumption (in kWh)
annual_energy_consumption = monthly_usage * 12
# Calculate Daily Energy Requirement (in kWh)
daily_energy_requirement = annual_energy_consumption / 365
# Solar Panel Output in kWh per day (considering the sunlight hours)
solar_panel_output_kwh = (panel_output_watts / 1000) * sunlight_hours # Convert watts to kWh
# Calculate the number of panels required
num_panels_required = daily_energy_requirement / solar_panel_output_kwh
# Inverter Capacity (based on peak demand)
inverter_capacity = peak_demand * 1.2 # Inverter capacity should be around 1.2 times the peak demand for efficiency
# Cost Calculations
total_solar_cost = num_panels_required * panel_cost
total_inverter_cost = inverter_cost
# Total Solar System Installation Cost
total_installation_cost = total_solar_cost + total_inverter_cost
# Payback Period Calculation
annual_savings = annual_energy_consumption * (cost_per_kwh := st.number_input("Enter the cost per kWh of electricity:", min_value=0.0))
payback_period = total_installation_cost / annual_savings if annual_savings > 0 else float('inf')
# Display Results
st.header("Results:")
st.subheader(f"Annual Energy Consumption: {annual_energy_consumption:.2f} kWh")
st.subheader(f"Daily Energy Requirement: {daily_energy_requirement:.2f} kWh")
st.subheader(f"Solar Panel Output per day: {solar_panel_output_kwh:.2f} kWh")
st.subheader(f"Number of Panels Required: {num_panels_required:.2f} panels")
st.subheader(f"Inverter Capacity Required: {inverter_capacity:.2f} kW")
st.subheader(f"Total Solar Panel Cost: {total_solar_cost:.2f} local currency")
st.subheader(f"Total Inverter Cost: {total_inverter_cost:.2f} local currency")
st.subheader(f"Total Installation Cost: {total_installation_cost:.2f} local currency")
st.subheader(f"Payback Period: {payback_period:.2f} years")
else:
st.warning("Please ensure that both solar panel output and sunlight hours are greater than 0.")
# Show tips for improving the app or using it effectively
st.markdown("""
- Make sure to input accurate data to get the most reliable results.
- The inverter capacity is calculated based on your peak demand.
- Payback period assumes that energy savings will remain constant each year.
""")
|