Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -27,47 +27,51 @@ sunlight_hours = st.number_input("Enter the average sunlight hours per day:", mi
|
|
27 |
# Solar Panel Output
|
28 |
solar_panel_output = st.number_input("Enter the solar panel output (in watts, W):", min_value=0)
|
29 |
|
30 |
-
#
|
|
|
|
|
31 |
|
32 |
-
# Determine Annual Energy Consumption (in kWh)
|
33 |
-
annual_energy_consumption = monthly_usage * 12
|
34 |
|
35 |
-
# Calculate Daily Energy Requirement (in kWh)
|
36 |
-
daily_energy_requirement = annual_energy_consumption / 365
|
37 |
|
38 |
-
# Solar Panel Output in kWh (daily)
|
39 |
-
solar_panel_output_kwh = (solar_panel_output / 1000) * sunlight_hours # Convert from watts to kWh
|
40 |
|
41 |
-
# Calculate number of solar panels required to meet daily energy requirement
|
42 |
-
num_panels_required = daily_energy_requirement / solar_panel_output_kwh
|
43 |
|
44 |
-
# Cost Calculations
|
45 |
-
total_solar_cost = num_panels_required * solar_panel_cost
|
46 |
|
47 |
-
# Payback Period (years)
|
48 |
-
annual_savings = annual_energy_consumption * cost_per_kwh
|
49 |
-
payback_period = total_solar_cost / annual_savings
|
50 |
|
51 |
-
# Output Section: Display results
|
52 |
-
st.header("Results:")
|
53 |
|
54 |
-
# Display annual energy consumption
|
55 |
-
st.subheader(f"Annual Energy Consumption: {annual_energy_consumption:.2f} kWh")
|
56 |
|
57 |
-
# Display daily energy requirement
|
58 |
-
st.subheader(f"Daily Energy Requirement: {daily_energy_requirement:.2f} kWh")
|
59 |
|
60 |
-
# Display solar panel output
|
61 |
-
st.subheader(f"Solar Panel Output per day: {solar_panel_output_kwh:.2f} kWh")
|
62 |
|
63 |
-
# Display number of panels required
|
64 |
-
st.subheader(f"Number of Solar Panels Required: {num_panels_required:.2f} panels")
|
65 |
|
66 |
-
# Display total solar system cost
|
67 |
-
st.subheader(f"Total Solar Panel Installation Cost: {total_solar_cost:.2f} local currency")
|
68 |
|
69 |
-
# Display payback period
|
70 |
-
st.subheader(f"Payback Period: {payback_period:.2f} years")
|
|
|
|
|
71 |
|
72 |
# Show tips for improving the app or using it effectively
|
73 |
st.markdown("""
|
@@ -75,4 +79,3 @@ st.markdown("""
|
|
75 |
- You can adjust the efficiency, cost, and solar panel output to simulate different scenarios.
|
76 |
- The payback period assumes the energy savings are constant each year.
|
77 |
""")
|
78 |
-
|
|
|
27 |
# Solar Panel Output
|
28 |
solar_panel_output = st.number_input("Enter the solar panel output (in watts, W):", min_value=0)
|
29 |
|
30 |
+
# Avoid ZeroDivisionError by checking input values
|
31 |
+
if solar_panel_output > 0 and sunlight_hours > 0:
|
32 |
+
# Calculations
|
33 |
|
34 |
+
# Determine Annual Energy Consumption (in kWh)
|
35 |
+
annual_energy_consumption = monthly_usage * 12
|
36 |
|
37 |
+
# Calculate Daily Energy Requirement (in kWh)
|
38 |
+
daily_energy_requirement = annual_energy_consumption / 365
|
39 |
|
40 |
+
# Solar Panel Output in kWh (daily)
|
41 |
+
solar_panel_output_kwh = (solar_panel_output / 1000) * sunlight_hours # Convert from watts to kWh
|
42 |
|
43 |
+
# Calculate number of solar panels required to meet daily energy requirement
|
44 |
+
num_panels_required = daily_energy_requirement / solar_panel_output_kwh
|
45 |
|
46 |
+
# Cost Calculations
|
47 |
+
total_solar_cost = num_panels_required * solar_panel_cost
|
48 |
|
49 |
+
# Payback Period (years)
|
50 |
+
annual_savings = annual_energy_consumption * cost_per_kwh
|
51 |
+
payback_period = total_solar_cost / annual_savings
|
52 |
|
53 |
+
# Output Section: Display results
|
54 |
+
st.header("Results:")
|
55 |
|
56 |
+
# Display annual energy consumption
|
57 |
+
st.subheader(f"Annual Energy Consumption: {annual_energy_consumption:.2f} kWh")
|
58 |
|
59 |
+
# Display daily energy requirement
|
60 |
+
st.subheader(f"Daily Energy Requirement: {daily_energy_requirement:.2f} kWh")
|
61 |
|
62 |
+
# Display solar panel output
|
63 |
+
st.subheader(f"Solar Panel Output per day: {solar_panel_output_kwh:.2f} kWh")
|
64 |
|
65 |
+
# Display number of panels required
|
66 |
+
st.subheader(f"Number of Solar Panels Required: {num_panels_required:.2f} panels")
|
67 |
|
68 |
+
# Display total solar system cost
|
69 |
+
st.subheader(f"Total Solar Panel Installation Cost: {total_solar_cost:.2f} local currency")
|
70 |
|
71 |
+
# Display payback period
|
72 |
+
st.subheader(f"Payback Period: {payback_period:.2f} years")
|
73 |
+
else:
|
74 |
+
st.warning("Please ensure that both solar panel output and sunlight hours are greater than 0.")
|
75 |
|
76 |
# Show tips for improving the app or using it effectively
|
77 |
st.markdown("""
|
|
|
79 |
- You can adjust the efficiency, cost, and solar panel output to simulate different scenarios.
|
80 |
- The payback period assumes the energy savings are constant each year.
|
81 |
""")
|
|