hamzaherry commited on
Commit
f82f589
·
verified ·
1 Parent(s): 85711fe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -13
app.py CHANGED
@@ -6,6 +6,9 @@ st.title("Complete Solar Energy Calculator")
6
  # Input Section: User inputs for energy usage, costs, etc.
7
  st.header("Enter 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
 
@@ -18,15 +21,20 @@ solar_panel_efficiency = st.number_input("Enter the efficiency of your solar pan
18
  # Panel Output in Watts (W)
19
  panel_output_watts = st.number_input("Enter the solar panel output (in watts, W):", min_value=0)
20
 
21
- # Inverter Cost (per inverter)
22
- inverter_cost = st.number_input("Enter the cost of the inverter (in your local currency):", min_value=0.0)
23
-
24
- # Cost per Solar Panel
25
- panel_cost = st.number_input("Enter the cost per solar panel (in your local currency):", min_value=0.0)
26
-
27
  # Average Sunlight Hours per Day
28
  sunlight_hours = st.number_input("Enter the average sunlight hours per day:", min_value=0.0)
29
 
 
 
 
 
 
 
 
 
 
 
 
30
  # Calculations Section
31
  if panel_output_watts > 0 and sunlight_hours > 0:
32
  # Determine Annual Energy Consumption (in kWh)
@@ -41,9 +49,6 @@ if panel_output_watts > 0 and sunlight_hours > 0:
41
  # Calculate the number of panels required
42
  num_panels_required = daily_energy_requirement / solar_panel_output_kwh
43
 
44
- # Inverter Capacity (based on peak demand)
45
- inverter_capacity = peak_demand * 1.2 # Inverter capacity should be around 1.2 times the peak demand for efficiency
46
-
47
  # Cost Calculations
48
  total_solar_cost = num_panels_required * panel_cost
49
  total_inverter_cost = inverter_cost
@@ -52,7 +57,8 @@ if panel_output_watts > 0 and sunlight_hours > 0:
52
  total_installation_cost = total_solar_cost + total_inverter_cost
53
 
54
  # Payback Period Calculation
55
- annual_savings = annual_energy_consumption * (cost_per_kwh := st.number_input("Enter the cost per kWh of electricity:", min_value=0.0))
 
56
  payback_period = total_installation_cost / annual_savings if annual_savings > 0 else float('inf')
57
 
58
  # Display Results
@@ -63,9 +69,9 @@ if panel_output_watts > 0 and sunlight_hours > 0:
63
  st.subheader(f"Solar Panel Output per day: {solar_panel_output_kwh:.2f} kWh")
64
  st.subheader(f"Number of Panels Required: {num_panels_required:.2f} panels")
65
  st.subheader(f"Inverter Capacity Required: {inverter_capacity:.2f} kW")
66
- st.subheader(f"Total Solar Panel Cost: {total_solar_cost:.2f} local currency")
67
- st.subheader(f"Total Inverter Cost: {total_inverter_cost:.2f} local currency")
68
- st.subheader(f"Total Installation Cost: {total_installation_cost:.2f} local currency")
69
  st.subheader(f"Payback Period: {payback_period:.2f} years")
70
 
71
  else:
 
6
  # Input Section: User inputs for energy usage, costs, etc.
7
  st.header("Enter your energy usage and system parameters:")
8
 
9
+ # Currency selection
10
+ currency = st.selectbox("Select your currency:", ["USD", "EUR", "INR", "GBP", "AUD", "CAD", "JPY", "Other"])
11
+
12
  # Average Monthly Usage in kWh
13
  monthly_usage = st.number_input("Enter your average monthly energy usage (kWh):", min_value=0.0)
14
 
 
21
  # Panel Output in Watts (W)
22
  panel_output_watts = st.number_input("Enter the solar panel output (in watts, W):", min_value=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
+ # 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
  # Calculations Section
39
  if panel_output_watts > 0 and sunlight_hours > 0:
40
  # Determine Annual Energy Consumption (in kWh)
 
49
  # Calculate the number of panels required
50
  num_panels_required = daily_energy_requirement / solar_panel_output_kwh
51
 
 
 
 
52
  # Cost Calculations
53
  total_solar_cost = num_panels_required * panel_cost
54
  total_inverter_cost = inverter_cost
 
57
  total_installation_cost = total_solar_cost + total_inverter_cost
58
 
59
  # Payback Period Calculation
60
+ cost_per_kwh = st.number_input(f"Enter the cost per kWh of electricity (in {currency}):", min_value=0.0)
61
+ annual_savings = annual_energy_consumption * cost_per_kwh
62
  payback_period = total_installation_cost / annual_savings if annual_savings > 0 else float('inf')
63
 
64
  # Display Results
 
69
  st.subheader(f"Solar Panel Output per day: {solar_panel_output_kwh:.2f} kWh")
70
  st.subheader(f"Number of Panels Required: {num_panels_required:.2f} panels")
71
  st.subheader(f"Inverter Capacity Required: {inverter_capacity:.2f} kW")
72
+ st.subheader(f"Total Solar Panel Cost: {total_solar_cost:.2f} {currency}")
73
+ st.subheader(f"Total Inverter Cost: {total_inverter_cost:.2f} {currency}")
74
+ st.subheader(f"Total Installation Cost: {total_installation_cost:.2f} {currency}")
75
  st.subheader(f"Payback Period: {payback_period:.2f} years")
76
 
77
  else: