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. """)