Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,78 @@
|
|
1 |
import streamlit as st
|
2 |
|
3 |
# Title of the app
|
4 |
-
st.title(
|
5 |
|
6 |
-
# Input
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
# Calculations
|
12 |
-
|
|
|
|
|
|
|
|
|
13 |
daily_energy_requirement = annual_energy_consumption / 365
|
14 |
-
solar_panel_output = daily_energy_requirement / solar_panel_efficiency
|
15 |
|
16 |
-
#
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
-
# Cost calculations and payback period can be added here based on the specific formula you have in mind
|
|
|
1 |
import streamlit as st
|
2 |
|
3 |
# Title of the app
|
4 |
+
st.title("Solar Energy Calculator")
|
5 |
|
6 |
+
# Input Section: User inputs for energy usage, costs, etc.
|
7 |
+
st.header("Input your energy usage and system parameters:")
|
8 |
+
|
9 |
+
# Average Monthly Usage in kWh
|
10 |
+
monthly_usage = st.number_input("Enter your average monthly energy usage (kWh):", min_value=0.0)
|
11 |
+
|
12 |
+
# Peak Demand
|
13 |
+
peak_demand = st.number_input("Enter your peak demand (kW):", min_value=0.0)
|
14 |
+
|
15 |
+
# Solar Panel Efficiency
|
16 |
+
solar_panel_efficiency = st.number_input("Enter the efficiency of your solar panels (0 to 100):", min_value=0.0, max_value=100.0)
|
17 |
+
|
18 |
+
# Cost of electricity per kWh (user input or fixed)
|
19 |
+
cost_per_kwh = st.number_input("Enter the cost per kWh (in your local currency):", min_value=0.0)
|
20 |
+
|
21 |
+
# Solar panel cost (in local currency per panel or total cost)
|
22 |
+
solar_panel_cost = st.number_input("Enter the cost of installing solar panels (in your local currency):", min_value=0.0)
|
23 |
+
|
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 |
+
# Solar Panel Output
|
28 |
+
solar_panel_output = st.number_input("Enter the solar panel output (in watts, W):", min_value=0)
|
29 |
|
30 |
# Calculations
|
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("""
|
74 |
+
- Make sure to input accurate data to get the most reliable results.
|
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 |
|
|