Spaces:
Sleeping
Sleeping
File size: 4,130 Bytes
949d1e6 c3713aa c83f986 949d1e6 46c310e c83f986 46c310e f82f589 4ba0351 f82f589 46c310e c83f986 46c310e c83f986 46c310e f82f589 f677adf 46c310e f677adf 949d1e6 f677adf 46c310e f677adf 46c310e f677adf c83f986 f677adf 46c310e f677adf 46c310e f677adf 46c310e f677adf c83f986 f677adf 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 81 82 83 84 85 86 87 88 89 90 |
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:")
# Currency selection
currency = st.selectbox("Select your currency:", ["USD", "EUR", "INR", "GBP", "AUD", "CAD", "JPY", "PKR", "Other"])
# 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)
# Average Sunlight Hours per Day
sunlight_hours = st.number_input("Enter the average sunlight hours per day:", min_value=0.0)
# Inverter Cost (user input)
inverter_cost = st.number_input(f"Enter the cost of the inverter (in {currency}):", min_value=0.0)
# Cost per Solar Panel
panel_cost = st.number_input(f"Enter the cost per solar panel (in {currency}):", min_value=0.0)
# Calculate Inverter Capacity based on Peak Demand (will be done once peak demand is entered)
if peak_demand > 0:
inverter_capacity = peak_demand * 1.2 # Inverter capacity should be around 1.2 times the peak demand for efficiency
st.write(f"Recommended Inverter Capacity: {inverter_capacity:.2f} kW (1.2 times peak demand)")
# Button to trigger the calculations
calculate_button = st.button("Calculate Solar Energy System")
if calculate_button:
# Perform calculations when the button is clicked
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
# 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
cost_per_kwh = st.number_input(f"Enter the cost per kWh of electricity (in {currency}):", min_value=0.0)
annual_savings = annual_energy_consumption * cost_per_kwh
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} {currency}")
st.subheader(f"Total Inverter Cost: {total_inverter_cost:.2f} {currency}")
st.subheader(f"Total Installation Cost: {total_installation_cost:.2f} {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.
""")
|