arsalan16 commited on
Commit
8d4019f
·
verified ·
1 Parent(s): 45e5a0e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -20
app.py CHANGED
@@ -1,13 +1,14 @@
1
  import streamlit as st
2
  import pandas as pd
 
3
 
4
  # App Title with Styling
5
  st.markdown(
6
- "<h1 style='text-align: center; color: #4CAF50;'>SolarEase: Solar System Planner</h1>",
7
  unsafe_allow_html=True,
8
  )
9
  st.write(
10
- "This app helps you calculate the total load and suggests a solar panel, inverter, and battery configuration for your home or office."
11
  )
12
 
13
  # Sidebar for Appliance Input
@@ -66,11 +67,14 @@ if st.session_state.appliances:
66
 
67
  # Remove Appliance Option
68
  remove_index = st.number_input(
69
- "Enter the row number to remove an appliance (starting from 1):", min_value=0, max_value=len(appliances_df)-1, step=1
 
 
 
70
  )
71
  remove_button = st.button("Remove Appliance")
72
  if remove_button:
73
- if 1 <= remove_index < len(st.session_state.appliances):
74
  del st.session_state.appliances[remove_index]
75
  st.success("Appliance removed successfully!")
76
  else:
@@ -88,37 +92,46 @@ if st.session_state.appliances:
88
  # Solar System Inputs
89
  st.subheader("Solar System Configuration")
90
  sunlight_hours = st.slider("Average Sunlight Hours", min_value=4, max_value=10, value=6)
91
- panel_efficiency = st.slider("Solar Panel Efficiency (%)", min_value=15, max_value=25, value=20) / 100
92
  battery_backup_hours = st.slider("Battery Backup Time (Hours)", min_value=1, max_value=24, value=4)
93
 
94
- # Solar Panel Calculation
95
- total_panel_wattage = total_energy_kwh / (sunlight_hours * panel_efficiency)
96
- number_of_panels = int(total_panel_wattage / 550) # Assuming 550W panels
 
 
97
 
98
- # Battery Calculation
99
- battery_capacity_ah = (total_energy_kwh * battery_backup_hours * 1000) / 12 # Assuming 12V batteries
100
- number_of_batteries = int(battery_capacity_ah / 200) # Assuming 200Ah batteries
101
 
102
- # Inverter Calculation
103
  inverter_size_kw = total_load_watts / 1000 # Convert to kW
104
 
105
  # Display Results
106
  st.markdown("<hr>", unsafe_allow_html=True)
107
  st.markdown("<h2 style='color: #FF5722;'>System Recommendations</h2>", unsafe_allow_html=True)
108
  st.write(f"**Total Load:** {total_load_watts:.2f} Watts")
109
- st.write(f"**Required Solar Panel Capacity:** {total_panel_wattage:.2f} W")
110
  st.write(f"**Number of Solar Panels (550W each):** {number_of_panels}")
111
  st.write(f"**Battery Capacity Needed:** {battery_capacity_ah:.2f} Ah")
112
  st.write(f"**Number of Batteries (200Ah each):** {number_of_batteries}")
113
  st.write(f"**Inverter Size Required:** {inverter_size_kw:.2f} kW")
114
 
115
- # Additional Suggestions
116
- st.markdown("<h3 style='color: #3F51B5;'>Suggestions:</h3>", unsafe_allow_html=True)
117
- st.write(
118
- "- Choose high-efficiency solar panels for better performance.\n"
119
- "- Ensure your inverter has at least 20% extra capacity to handle peak loads.\n"
120
- "- Use lithium-ion batteries for longer life and better efficiency."
121
- )
 
 
 
 
 
 
 
 
 
122
 
123
  # Footer
124
  st.markdown("<hr>", unsafe_allow_html=True)
@@ -129,3 +142,4 @@ st.markdown(
129
 
130
 
131
 
 
 
1
  import streamlit as st
2
  import pandas as pd
3
+ import numpy as np
4
 
5
  # App Title with Styling
6
  st.markdown(
7
+ "<h1 style='text-align: center; color: #4CAF50;'>SolarEase: Hybrid Solar System Planner</h1>",
8
  unsafe_allow_html=True,
9
  )
10
  st.write(
11
+ "This app helps you calculate the total load and provides recommendations for a hybrid solar system, including solar panels, inverter size, and battery configuration."
12
  )
13
 
14
  # Sidebar for Appliance Input
 
67
 
68
  # Remove Appliance Option
69
  remove_index = st.number_input(
70
+ "Enter the row number to remove an appliance (starting from 0):",
71
+ min_value=0,
72
+ max_value=len(appliances_df) - 1,
73
+ step=1,
74
  )
75
  remove_button = st.button("Remove Appliance")
76
  if remove_button:
77
+ if 0 <= remove_index < len(st.session_state.appliances):
78
  del st.session_state.appliances[remove_index]
79
  st.success("Appliance removed successfully!")
80
  else:
 
92
  # Solar System Inputs
93
  st.subheader("Solar System Configuration")
94
  sunlight_hours = st.slider("Average Sunlight Hours", min_value=4, max_value=10, value=6)
 
95
  battery_backup_hours = st.slider("Battery Backup Time (Hours)", min_value=1, max_value=24, value=4)
96
 
97
+ # Hybrid Solar System Calculations
98
+ # Solar Panels
99
+ energy_per_day = total_energy_kwh
100
+ panel_output_per_day = 550 * sunlight_hours / 1000 # 550W panels in kWh
101
+ number_of_panels = int(np.ceil(energy_per_day / panel_output_per_day))
102
 
103
+ # Batteries
104
+ battery_capacity_ah = (energy_per_day * battery_backup_hours * 1000) / 12 # Assuming 12V batteries
105
+ number_of_batteries = int(np.ceil(battery_capacity_ah / 200)) # Assuming 200Ah batteries
106
 
107
+ # Inverter
108
  inverter_size_kw = total_load_watts / 1000 # Convert to kW
109
 
110
  # Display Results
111
  st.markdown("<hr>", unsafe_allow_html=True)
112
  st.markdown("<h2 style='color: #FF5722;'>System Recommendations</h2>", unsafe_allow_html=True)
113
  st.write(f"**Total Load:** {total_load_watts:.2f} Watts")
 
114
  st.write(f"**Number of Solar Panels (550W each):** {number_of_panels}")
115
  st.write(f"**Battery Capacity Needed:** {battery_capacity_ah:.2f} Ah")
116
  st.write(f"**Number of Batteries (200Ah each):** {number_of_batteries}")
117
  st.write(f"**Inverter Size Required:** {inverter_size_kw:.2f} kW")
118
 
119
+ # Suggestions for Solar System Design
120
+ st.markdown("<h3 style='color: #3F51B5;'>Design Suggestions:</h3>", unsafe_allow_html=True)
121
+ suggestions = [
122
+ "Use monocrystalline panels for better efficiency.",
123
+ "Ensure the inverter size is 20-30% higher than the total load.",
124
+ "Install a charge controller to protect batteries from overcharging.",
125
+ "Consider lithium-ion batteries for higher energy density and lifespan.",
126
+ "Place solar panels in a south-facing direction for maximum sunlight exposure.",
127
+ "Use MPPT (Maximum Power Point Tracking) technology for better solar output.",
128
+ "Regularly clean the panels to maintain efficiency.",
129
+ "Calculate the load of heavy appliances like ACs separately for better sizing.",
130
+ "Invest in a hybrid inverter to handle both solar and grid power.",
131
+ "Consult a professional installer to ensure safety and compliance.",
132
+ ]
133
+ for suggestion in suggestions:
134
+ st.write(f"- {suggestion}")
135
 
136
  # Footer
137
  st.markdown("<hr>", unsafe_allow_html=True)
 
142
 
143
 
144
 
145
+