Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,7 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from translate import Translator
|
| 3 |
-
from pvlib import location, pvsystem
|
| 4 |
import pandas as pd
|
| 5 |
import numpy as np
|
|
|
|
| 6 |
|
| 7 |
# Translator setup
|
| 8 |
def translate_text(text, lang_code):
|
|
@@ -29,76 +28,57 @@ lang_code = languages[selected_language]
|
|
| 29 |
# App title
|
| 30 |
st.title(translate_text("Solar System Designer", lang_code))
|
| 31 |
|
| 32 |
-
#
|
| 33 |
-
solar_panel_capacity = 550 # Fixed for simplicity
|
| 34 |
-
|
| 35 |
-
# Battery options
|
| 36 |
battery_types = {"Lithium-Ion": 0.95, "Lead-Acid": 0.8}
|
| 37 |
battery_choice = st.selectbox(translate_text("Select Battery Type", lang_code), options=battery_types.keys())
|
| 38 |
battery_efficiency = battery_types[battery_choice]
|
| 39 |
|
| 40 |
-
#
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
"LED TV": 80,
|
| 45 |
-
"Computers": 150,
|
| 46 |
-
"Refrigerator": 200,
|
| 47 |
-
"Washing Machine": 500,
|
| 48 |
-
"Water Pump": 750,
|
| 49 |
-
"Iron": 1000,
|
| 50 |
-
"Microwave Oven": 1200,
|
| 51 |
-
"Water Dispenser": 150,
|
| 52 |
-
"Geyser": 2000,
|
| 53 |
-
"Heater": 2000,
|
| 54 |
-
"Dishwasher": 1800,
|
| 55 |
-
"Inverter AC": 1500,
|
| 56 |
-
"Others": 0 # Custom power input
|
| 57 |
-
}
|
| 58 |
|
| 59 |
-
# Appliance
|
| 60 |
-
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
hours = st.number_input(translate_text(f"Usage Hours for {appliance}:", lang_code), min_value=0, max_value=24, value=1)
|
| 67 |
-
if hours > 0:
|
| 68 |
-
selected_appliances.append({"name": appliance, "power": power, "hours": hours})
|
| 69 |
|
| 70 |
-
|
| 71 |
-
st.write(translate_text("Selected Appliances:", lang_code))
|
| 72 |
-
st.table(selected_appliances)
|
| 73 |
-
|
| 74 |
-
# Calculate recommendations
|
| 75 |
if st.button(translate_text("Calculate Recommendations", lang_code)):
|
| 76 |
-
|
| 77 |
-
|
| 78 |
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
st.write(translate_text(f"Inverter Required: {inverter_capacity:.2f} kW", lang_code))
|
| 82 |
|
| 83 |
-
#
|
|
|
|
| 84 |
sunlight_hours = 5 # Average peak sunlight hours
|
| 85 |
-
panels_required = np.ceil(
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
st.write(translate_text(f"
|
| 91 |
|
| 92 |
# Suggestions
|
| 93 |
st.subheader(translate_text("System Design Suggestions", lang_code))
|
| 94 |
suggestions = [
|
| 95 |
"Ensure panels are installed at the optimal tilt angle.",
|
| 96 |
-
"Consider a hybrid system for
|
| 97 |
-
"Use
|
| 98 |
-
"Plan for system expansion
|
| 99 |
-
"
|
| 100 |
-
"Choose reliable and locally available components.",
|
| 101 |
-
"Use an energy monitoring system to track usage.",
|
| 102 |
"Consult a certified solar installer for best practices."
|
| 103 |
]
|
| 104 |
for suggestion in suggestions:
|
|
@@ -113,3 +93,4 @@ if st.button(translate_text("Calculate Recommendations", lang_code)):
|
|
| 113 |
|
| 114 |
|
| 115 |
|
|
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
import numpy as np
|
| 4 |
+
from translate import Translator
|
| 5 |
|
| 6 |
# Translator setup
|
| 7 |
def translate_text(text, lang_code):
|
|
|
|
| 28 |
# App title
|
| 29 |
st.title(translate_text("Solar System Designer", lang_code))
|
| 30 |
|
| 31 |
+
# Battery efficiency
|
|
|
|
|
|
|
|
|
|
| 32 |
battery_types = {"Lithium-Ion": 0.95, "Lead-Acid": 0.8}
|
| 33 |
battery_choice = st.selectbox(translate_text("Select Battery Type", lang_code), options=battery_types.keys())
|
| 34 |
battery_efficiency = battery_types[battery_choice]
|
| 35 |
|
| 36 |
+
# Table for appliance selection
|
| 37 |
+
st.subheader(translate_text("Appliances Input", lang_code))
|
| 38 |
+
appliance_data = pd.DataFrame(columns=["Appliance", "Wattage (W)", "Hours per Day", "Quantity"])
|
| 39 |
+
default_appliances = ["LED Bulb", "Fan", "Refrigerator", "Microwave Oven", "Water Pump", "Iron", "Inverter AC", "Others"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
+
# Appliance input table
|
| 42 |
+
for appliance in default_appliances:
|
| 43 |
+
wattage = st.number_input(translate_text(f"{appliance} - Wattage:", lang_code), min_value=0, step=1, key=f"{appliance}_wattage")
|
| 44 |
+
hours = st.number_input(translate_text(f"{appliance} - Hours per Day:", lang_code), min_value=0, step=1, key=f"{appliance}_hours")
|
| 45 |
+
quantity = st.number_input(translate_text(f"{appliance} - Quantity:", lang_code), min_value=0, step=1, key=f"{appliance}_quantity")
|
| 46 |
+
if wattage > 0 and hours > 0 and quantity > 0:
|
| 47 |
+
appliance_data = pd.concat([appliance_data, pd.DataFrame([[appliance, wattage, hours, quantity]], columns=appliance_data.columns)], ignore_index=True)
|
| 48 |
|
| 49 |
+
if not appliance_data.empty:
|
| 50 |
+
st.write(translate_text("Selected Appliances", lang_code))
|
| 51 |
+
st.dataframe(appliance_data)
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
+
# System recommendations
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
if st.button(translate_text("Calculate Recommendations", lang_code)):
|
| 55 |
+
total_energy_consumption = sum(appliance_data["Wattage (W)"] * appliance_data["Hours per Day"] * appliance_data["Quantity"]) / 1000 # in kWh
|
| 56 |
+
total_load = sum(appliance_data["Wattage (W)"] * appliance_data["Quantity"]) # in Watts
|
| 57 |
|
| 58 |
+
st.write(translate_text(f"Total Load: {total_load} Watts", lang_code))
|
| 59 |
+
st.write(translate_text(f"Total Energy Consumption: {total_energy_consumption:.2f} kWh/day", lang_code))
|
|
|
|
| 60 |
|
| 61 |
+
# Calculate solar panel and battery requirements
|
| 62 |
+
solar_panel_capacity = 550 # Fixed capacity of a solar panel
|
| 63 |
sunlight_hours = 5 # Average peak sunlight hours
|
| 64 |
+
panels_required = np.ceil(total_energy_consumption / (solar_panel_capacity / 1000 * sunlight_hours))
|
| 65 |
+
|
| 66 |
+
battery_capacity_kWh = total_energy_consumption / battery_efficiency # Battery capacity in kWh
|
| 67 |
+
battery_capacity_ah = battery_capacity_kWh * 1000 / 48 # Assuming a 48V system
|
| 68 |
+
batteries_required = np.ceil(battery_capacity_ah / 200) # Assuming 200 Ah per battery
|
| 69 |
|
| 70 |
+
st.subheader(translate_text("System Recommendations", lang_code))
|
| 71 |
+
st.write(translate_text(f"Solar Panels Required: {int(panels_required)} (550W each)", lang_code))
|
| 72 |
+
st.write(translate_text(f"Batteries Required: {int(batteries_required)} (200 Ah, 48V system)", lang_code))
|
| 73 |
|
| 74 |
# Suggestions
|
| 75 |
st.subheader(translate_text("System Design Suggestions", lang_code))
|
| 76 |
suggestions = [
|
| 77 |
"Ensure panels are installed at the optimal tilt angle.",
|
| 78 |
+
"Consider a hybrid system for grid integration.",
|
| 79 |
+
"Use MPPT charge controllers for efficiency.",
|
| 80 |
+
"Plan for future system expansion.",
|
| 81 |
+
"Choose high-quality and reliable components.",
|
|
|
|
|
|
|
| 82 |
"Consult a certified solar installer for best practices."
|
| 83 |
]
|
| 84 |
for suggestion in suggestions:
|
|
|
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
+
|