Spaces:
Sleeping
Sleeping
File size: 3,239 Bytes
949d1e6 c3713aa 46c310e 949d1e6 46c310e 949d1e6 301aab4 46c310e 301aab4 46c310e 301aab4 949d1e6 301aab4 46c310e 301aab4 46c310e 301aab4 46c310e 301aab4 46c310e 301aab4 46c310e 301aab4 46c310e 301aab4 46c310e 301aab4 46c310e 301aab4 46c310e 301aab4 46c310e 301aab4 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 81 82 |
import streamlit as st
# Title of the app
st.title("Solar Energy Calculator")
# Input Section: User inputs for energy usage, costs, etc.
st.header("Input 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
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)
# Cost of electricity per kWh (user input or fixed)
cost_per_kwh = st.number_input("Enter the cost per kWh (in your local currency):", min_value=0.0)
# Solar panel cost (in local currency per panel or total cost)
solar_panel_cost = st.number_input("Enter the cost of installing solar panels (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)
# Solar Panel Output
solar_panel_output = st.number_input("Enter the solar panel output (in watts, W):", min_value=0)
# Avoid ZeroDivisionError by checking input values
if solar_panel_output > 0 and sunlight_hours > 0:
# Calculations
# 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 (daily)
solar_panel_output_kwh = (solar_panel_output / 1000) * sunlight_hours # Convert from watts to kWh
# Calculate number of solar panels required to meet daily energy requirement
num_panels_required = daily_energy_requirement / solar_panel_output_kwh
# Cost Calculations
total_solar_cost = num_panels_required * solar_panel_cost
# Payback Period (years)
annual_savings = annual_energy_consumption * cost_per_kwh
payback_period = total_solar_cost / annual_savings
# Output Section: Display results
st.header("Results:")
# Display annual energy consumption
st.subheader(f"Annual Energy Consumption: {annual_energy_consumption:.2f} kWh")
# Display daily energy requirement
st.subheader(f"Daily Energy Requirement: {daily_energy_requirement:.2f} kWh")
# Display solar panel output
st.subheader(f"Solar Panel Output per day: {solar_panel_output_kwh:.2f} kWh")
# Display number of panels required
st.subheader(f"Number of Solar Panels Required: {num_panels_required:.2f} panels")
# Display total solar system cost
st.subheader(f"Total Solar Panel Installation Cost: {total_solar_cost:.2f} local currency")
# Display payback period
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.
- You can adjust the efficiency, cost, and solar panel output to simulate different scenarios.
- The payback period assumes the energy savings are constant each year.
""")
|