Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -24,58 +24,62 @@ panel_output_watts = st.number_input("Enter the solar panel output (in watts, W)
|
|
24 |
# Average Sunlight Hours per Day
|
25 |
sunlight_hours = st.number_input("Enter the average sunlight hours per day:", min_value=0.0)
|
26 |
|
27 |
-
# Calculate Inverter Capacity based on Peak Demand
|
28 |
-
if peak_demand > 0:
|
29 |
-
inverter_capacity = peak_demand * 1.2 # Inverter capacity should be around 1.2 times the peak demand for efficiency
|
30 |
-
st.write(f"Recommended Inverter Capacity: {inverter_capacity:.2f} kW (1.2 times peak demand)")
|
31 |
-
|
32 |
# Inverter Cost (user input)
|
33 |
inverter_cost = st.number_input(f"Enter the cost of the inverter (in {currency}):", min_value=0.0)
|
34 |
|
35 |
# Cost per Solar Panel
|
36 |
panel_cost = st.number_input(f"Enter the cost per solar panel (in {currency}):", min_value=0.0)
|
37 |
|
38 |
-
#
|
39 |
-
if
|
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 |
-
else:
|
78 |
-
|
79 |
|
80 |
# Show tips for improving the app or using it effectively
|
81 |
st.markdown("""
|
|
|
24 |
# Average Sunlight Hours per Day
|
25 |
sunlight_hours = st.number_input("Enter the average sunlight hours per day:", min_value=0.0)
|
26 |
|
|
|
|
|
|
|
|
|
|
|
27 |
# Inverter Cost (user input)
|
28 |
inverter_cost = st.number_input(f"Enter the cost of the inverter (in {currency}):", min_value=0.0)
|
29 |
|
30 |
# Cost per Solar Panel
|
31 |
panel_cost = st.number_input(f"Enter the cost per solar panel (in {currency}):", min_value=0.0)
|
32 |
|
33 |
+
# Calculate Inverter Capacity based on Peak Demand (will be done once peak demand is entered)
|
34 |
+
if peak_demand > 0:
|
35 |
+
inverter_capacity = peak_demand * 1.2 # Inverter capacity should be around 1.2 times the peak demand for efficiency
|
36 |
+
st.write(f"Recommended Inverter Capacity: {inverter_capacity:.2f} kW (1.2 times peak demand)")
|
37 |
+
|
38 |
+
# Button to trigger the calculations
|
39 |
+
calculate_button = st.button("Calculate Solar Energy System")
|
40 |
+
|
41 |
+
if calculate_button:
|
42 |
+
# Perform calculations when the button is clicked
|
43 |
+
if panel_output_watts > 0 and sunlight_hours > 0:
|
44 |
+
# Determine Annual Energy Consumption (in kWh)
|
45 |
+
annual_energy_consumption = monthly_usage * 12
|
46 |
|
47 |
+
# Calculate Daily Energy Requirement (in kWh)
|
48 |
+
daily_energy_requirement = annual_energy_consumption / 365
|
49 |
|
50 |
+
# Solar Panel Output in kWh per day (considering the sunlight hours)
|
51 |
+
solar_panel_output_kwh = (panel_output_watts / 1000) * sunlight_hours # Convert watts to kWh
|
52 |
|
53 |
+
# Calculate the number of panels required
|
54 |
+
num_panels_required = daily_energy_requirement / solar_panel_output_kwh
|
55 |
|
56 |
+
# Cost Calculations
|
57 |
+
total_solar_cost = num_panels_required * panel_cost
|
58 |
+
total_inverter_cost = inverter_cost
|
59 |
|
60 |
+
# Total Solar System Installation Cost
|
61 |
+
total_installation_cost = total_solar_cost + total_inverter_cost
|
62 |
|
63 |
+
# Payback Period Calculation
|
64 |
+
cost_per_kwh = st.number_input(f"Enter the cost per kWh of electricity (in {currency}):", min_value=0.0)
|
65 |
+
annual_savings = annual_energy_consumption * cost_per_kwh
|
66 |
+
payback_period = total_installation_cost / annual_savings if annual_savings > 0 else float('inf')
|
67 |
|
68 |
+
# Display Results
|
69 |
+
st.header("Results:")
|
70 |
|
71 |
+
st.subheader(f"Annual Energy Consumption: {annual_energy_consumption:.2f} kWh")
|
72 |
+
st.subheader(f"Daily Energy Requirement: {daily_energy_requirement:.2f} kWh")
|
73 |
+
st.subheader(f"Solar Panel Output per day: {solar_panel_output_kwh:.2f} kWh")
|
74 |
+
st.subheader(f"Number of Panels Required: {num_panels_required:.2f} panels")
|
75 |
+
st.subheader(f"Inverter Capacity Required: {inverter_capacity:.2f} kW")
|
76 |
+
st.subheader(f"Total Solar Panel Cost: {total_solar_cost:.2f} {currency}")
|
77 |
+
st.subheader(f"Total Inverter Cost: {total_inverter_cost:.2f} {currency}")
|
78 |
+
st.subheader(f"Total Installation Cost: {total_installation_cost:.2f} {currency}")
|
79 |
+
st.subheader(f"Payback Period: {payback_period:.2f} years")
|
80 |
|
81 |
+
else:
|
82 |
+
st.warning("Please ensure that both solar panel output and sunlight hours are greater than 0.")
|
83 |
|
84 |
# Show tips for improving the app or using it effectively
|
85 |
st.markdown("""
|