Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,10 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
import numpy as np
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
# App Title
|
| 6 |
st.markdown(
|
| 7 |
"<h1 style='text-align: center; color: #4CAF50;'>SolarEase: Hybrid Solar System Planner</h1>",
|
| 8 |
unsafe_allow_html=True,
|
|
@@ -65,21 +67,6 @@ if st.session_state.appliances:
|
|
| 65 |
appliances_df = pd.DataFrame(st.session_state.appliances)
|
| 66 |
st.table(appliances_df)
|
| 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:
|
| 81 |
-
st.error("Invalid row number.")
|
| 82 |
-
|
| 83 |
# If Appliances List is Not Empty, Perform Calculations
|
| 84 |
if st.session_state.appliances:
|
| 85 |
# Calculations
|
|
@@ -94,25 +81,25 @@ if st.session_state.appliances:
|
|
| 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 |
-
#
|
| 98 |
-
#
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
|
| 103 |
-
#
|
| 104 |
-
|
| 105 |
-
|
|
|
|
| 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):** {
|
| 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 |
|
|
@@ -120,15 +107,15 @@ if st.session_state.appliances:
|
|
| 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 |
-
"
|
| 125 |
-
"Consider lithium-ion batteries for
|
| 126 |
-
"
|
| 127 |
-
"
|
| 128 |
-
"
|
| 129 |
-
"
|
| 130 |
-
"
|
| 131 |
-
"Consult a professional installer to ensure safety and compliance.",
|
| 132 |
]
|
| 133 |
for suggestion in suggestions:
|
| 134 |
st.write(f"- {suggestion}")
|
|
@@ -143,3 +130,4 @@ st.markdown(
|
|
| 143 |
|
| 144 |
|
| 145 |
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
import numpy as np
|
| 4 |
+
from sympy import symbols, solve
|
| 5 |
+
import pvlib
|
| 6 |
|
| 7 |
+
# App Title
|
| 8 |
st.markdown(
|
| 9 |
"<h1 style='text-align: center; color: #4CAF50;'>SolarEase: Hybrid Solar System Planner</h1>",
|
| 10 |
unsafe_allow_html=True,
|
|
|
|
| 67 |
appliances_df = pd.DataFrame(st.session_state.appliances)
|
| 68 |
st.table(appliances_df)
|
| 69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
# If Appliances List is Not Empty, Perform Calculations
|
| 71 |
if st.session_state.appliances:
|
| 72 |
# Calculations
|
|
|
|
| 81 |
sunlight_hours = st.slider("Average Sunlight Hours", min_value=4, max_value=10, value=6)
|
| 82 |
battery_backup_hours = st.slider("Battery Backup Time (Hours)", min_value=1, max_value=24, value=4)
|
| 83 |
|
| 84 |
+
# Accurate Solar Panel and Battery Calculations
|
| 85 |
+
solar_panel_capacity_w = 550 # 550W solar panel
|
| 86 |
+
energy_per_day_kwh = total_energy_kwh
|
| 87 |
+
daily_solar_output_kwh = solar_panel_capacity_w * sunlight_hours / 1000 # in kWh
|
| 88 |
+
number_of_solar_panels = int(np.ceil(energy_per_day_kwh / daily_solar_output_kwh))
|
| 89 |
|
| 90 |
+
# Battery Calculation
|
| 91 |
+
system_voltage = 48 # Assuming a 48V system for efficiency
|
| 92 |
+
total_battery_capacity_ah = (energy_per_day_kwh * 1000) / system_voltage # in Ah
|
| 93 |
+
number_of_batteries = int(np.ceil((total_battery_capacity_ah * battery_backup_hours) / 200)) # Assuming 200Ah batteries
|
| 94 |
|
| 95 |
+
# Inverter Size
|
| 96 |
inverter_size_kw = total_load_watts / 1000 # Convert to kW
|
| 97 |
|
| 98 |
# Display Results
|
| 99 |
st.markdown("<hr>", unsafe_allow_html=True)
|
| 100 |
st.markdown("<h2 style='color: #FF5722;'>System Recommendations</h2>", unsafe_allow_html=True)
|
| 101 |
st.write(f"**Total Load:** {total_load_watts:.2f} Watts")
|
| 102 |
+
st.write(f"**Number of Solar Panels (550W each):** {number_of_solar_panels}")
|
|
|
|
| 103 |
st.write(f"**Number of Batteries (200Ah each):** {number_of_batteries}")
|
| 104 |
st.write(f"**Inverter Size Required:** {inverter_size_kw:.2f} kW")
|
| 105 |
|
|
|
|
| 107 |
st.markdown("<h3 style='color: #3F51B5;'>Design Suggestions:</h3>", unsafe_allow_html=True)
|
| 108 |
suggestions = [
|
| 109 |
"Use monocrystalline panels for better efficiency.",
|
| 110 |
+
"Install a charge controller to prevent overcharging the batteries.",
|
| 111 |
"Ensure the inverter size is 20-30% higher than the total load.",
|
| 112 |
+
"Use MPPT (Maximum Power Point Tracking) technology for optimal solar output.",
|
| 113 |
+
"Consider lithium-ion batteries for better energy density and lifespan.",
|
| 114 |
+
"Install panels at an optimal tilt angle based on your location.",
|
| 115 |
+
"Clean solar panels regularly to maintain performance.",
|
| 116 |
+
"Invest in a hybrid inverter to switch between solar, grid, and battery power.",
|
| 117 |
+
"Consult a certified solar installer for professional system design.",
|
| 118 |
+
"Ensure proper wiring and safety measures for long-term reliability.",
|
|
|
|
| 119 |
]
|
| 120 |
for suggestion in suggestions:
|
| 121 |
st.write(f"- {suggestion}")
|
|
|
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
+
|