Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,51 +1,22 @@
|
|
1 |
import streamlit as st
|
2 |
|
3 |
-
#
|
4 |
-
|
5 |
-
# Constants
|
6 |
-
SUN_HOURS = 5 # Average daily sun hours (adjustable)
|
7 |
-
LOSS_FACTOR = 0.85 # 15% loss due to shading, weather, etc.
|
8 |
-
|
9 |
-
# Annual and daily energy calculations
|
10 |
-
annual_energy = monthly_usage * 12
|
11 |
-
daily_energy = annual_energy / 365
|
12 |
-
|
13 |
-
# Panel output adjustment based on direction and inclination
|
14 |
-
if roof_direction in ["south", "southeast", "southwest"]:
|
15 |
-
direction_factor = 1.0
|
16 |
-
else:
|
17 |
-
direction_factor = 0.8 # Example: less optimal directions
|
18 |
-
|
19 |
-
inclination_factor = max(0.9 - abs(inclination_angle - 30) * 0.01, 0.5) # Ideal angle ~30 degrees
|
20 |
-
|
21 |
-
panel_output_per_day = SUN_HOURS * (panel_efficiency / 100) * LOSS_FACTOR * direction_factor * inclination_factor
|
22 |
-
|
23 |
-
# Total panels required
|
24 |
-
num_panels = (daily_energy * peak_factor) / panel_output_per_day
|
25 |
-
|
26 |
-
return annual_energy, daily_energy, panel_output_per_day, num_panels
|
27 |
|
28 |
-
#
|
29 |
-
st.
|
30 |
-
st.
|
|
|
31 |
|
32 |
-
#
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
panel_efficiency = st.sidebar.slider("Solar Panel Efficiency (%)", min_value=10, max_value=25, value=20)
|
37 |
-
peak_factor = st.sidebar.slider("Peak Usage Factor (e.g., summer demand multiplier)", min_value=1.0, max_value=2.0, value=1.2)
|
38 |
|
39 |
-
#
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
st.subheader("Results")
|
47 |
-
st.write(f"**Annual Energy Consumption:** {annual_energy:.2f} kWh")
|
48 |
-
st.write(f"**Daily Energy Requirement:** {daily_energy:.2f} kWh")
|
49 |
-
st.write(f"**Solar Panel Output (per panel/day):** {panel_output_per_day:.2f} kWh")
|
50 |
-
st.write(f"**Number of Panels Required:** {num_panels:.0f}")
|
51 |
-
st.write("Note: These estimates account for real-world losses and adjustments for roof orientation and angle.")
|
|
|
1 |
import streamlit as st
|
2 |
|
3 |
+
# Title of the app
|
4 |
+
st.title('Solar Panel Calculator')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
+
# Input fields for user to enter data
|
7 |
+
avg_monthly_usage = st.number_input('Average Monthly Usage (kWh)', min_value=0.0, step=1.0)
|
8 |
+
peak_demand = st.number_input('Peak Demand (kW)', min_value=0.0, step=0.1)
|
9 |
+
solar_panel_efficiency = st.number_input('Solar Panel Efficiency (%)', min_value=0.0, max_value=100.0, step=1.0)
|
10 |
|
11 |
+
# Calculations
|
12 |
+
annual_energy_consumption = avg_monthly_usage * 12
|
13 |
+
daily_energy_requirement = annual_energy_consumption / 365
|
14 |
+
solar_panel_output = daily_energy_requirement / solar_panel_efficiency
|
|
|
|
|
15 |
|
16 |
+
# Display results
|
17 |
+
st.write('### Calculated Results:')
|
18 |
+
st.write(f'- Annual Energy Consumption: {annual_energy_consumption} kWh')
|
19 |
+
st.write(f'- Daily Energy Requirement: {daily_energy_requirement} kWh')
|
20 |
+
st.write(f'- Solar Panel Output: {solar_panel_output} kWh')
|
21 |
+
|
22 |
+
# Cost calculations and payback period can be added here based on the specific formula you have in mind
|
|
|
|
|
|
|
|
|
|
|
|