Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import pandas as pd
|
| 3 |
import numpy as np
|
| 4 |
from translate import Translator
|
| 5 |
|
|
@@ -33,56 +32,74 @@ 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 |
-
#
|
| 37 |
-
st.subheader(translate_text("Appliances
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
if wattage > 0 and hours > 0 and quantity > 0:
|
| 47 |
-
appliance_data
|
| 48 |
-
|
| 49 |
-
if not appliance_data.empty:
|
| 50 |
-
st.write(translate_text("Selected Appliances", lang_code))
|
| 51 |
-
st.dataframe(appliance_data)
|
| 52 |
|
| 53 |
-
#
|
| 54 |
if st.button(translate_text("Calculate Recommendations", lang_code)):
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
"
|
| 78 |
-
"
|
| 79 |
-
"
|
| 80 |
-
"
|
| 81 |
-
"
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
|
| 88 |
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
import numpy as np
|
| 3 |
from translate import Translator
|
| 4 |
|
|
|
|
| 32 |
battery_choice = st.selectbox(translate_text("Select Battery Type", lang_code), options=battery_types.keys())
|
| 33 |
battery_efficiency = battery_types[battery_choice]
|
| 34 |
|
| 35 |
+
# Appliance selection
|
| 36 |
+
st.subheader(translate_text("Select Appliances", lang_code))
|
| 37 |
+
appliances = [
|
| 38 |
+
"LED Bulb", "Fan", "Refrigerator", "Microwave Oven",
|
| 39 |
+
"Water Pump", "Iron", "Inverter AC", "Dishwasher",
|
| 40 |
+
"Geyser", "Heater", "Computer", "Water Dispenser", "Others"
|
| 41 |
+
]
|
| 42 |
+
|
| 43 |
+
selected_appliances = st.multiselect(translate_text("Choose Appliances:", lang_code), options=appliances)
|
| 44 |
+
|
| 45 |
+
# Appliance input
|
| 46 |
+
appliance_data = []
|
| 47 |
+
for appliance in selected_appliances:
|
| 48 |
+
wattage = st.number_input(
|
| 49 |
+
translate_text(f"{appliance} - Wattage (W):", lang_code), min_value=0, step=1, key=f"{appliance}_wattage"
|
| 50 |
+
)
|
| 51 |
+
hours = st.number_input(
|
| 52 |
+
translate_text(f"{appliance} - Daily Usage (hours):", lang_code), min_value=0, step=1, key=f"{appliance}_hours"
|
| 53 |
+
)
|
| 54 |
+
quantity = st.number_input(
|
| 55 |
+
translate_text(f"{appliance} - Quantity:", lang_code), min_value=0, step=1, key=f"{appliance}_quantity"
|
| 56 |
+
)
|
| 57 |
if wattage > 0 and hours > 0 and quantity > 0:
|
| 58 |
+
appliance_data.append({"Appliance": appliance, "Wattage": wattage, "Hours": hours, "Quantity": quantity})
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
+
# Calculate recommendations
|
| 61 |
if st.button(translate_text("Calculate Recommendations", lang_code)):
|
| 62 |
+
if not appliance_data:
|
| 63 |
+
st.error(translate_text("Please select and fill details for at least one appliance.", lang_code))
|
| 64 |
+
else:
|
| 65 |
+
total_load = sum(item["Wattage"] * item["Quantity"] for item in appliance_data) # in Watts
|
| 66 |
+
total_energy_consumption = sum(
|
| 67 |
+
item["Wattage"] * item["Hours"] * item["Quantity"] for item in appliance_data
|
| 68 |
+
) / 1000 # in kWh/day
|
| 69 |
+
|
| 70 |
+
# Solar panel calculation
|
| 71 |
+
solar_panel_capacity = 550 # Fixed capacity of a solar panel in Watts
|
| 72 |
+
sunlight_hours = 5 # Average peak sunlight hours
|
| 73 |
+
panels_required = np.ceil(total_energy_consumption / (solar_panel_capacity / 1000 * sunlight_hours))
|
| 74 |
+
|
| 75 |
+
# Inverter calculation (20% buffer added)
|
| 76 |
+
inverter_capacity = np.ceil(total_load * 1.2 / 1000) # in kW
|
| 77 |
+
|
| 78 |
+
# Battery requirement
|
| 79 |
+
battery_capacity_kWh = total_energy_consumption / battery_efficiency # in kWh
|
| 80 |
+
battery_capacity_ah = battery_capacity_kWh * 1000 / 48 # Assuming a 48V system
|
| 81 |
+
batteries_required = np.ceil(battery_capacity_ah / 200) # Assuming 200 Ah per battery
|
| 82 |
+
|
| 83 |
+
# Output
|
| 84 |
+
st.subheader(translate_text("System Recommendations", lang_code))
|
| 85 |
+
st.write(translate_text(f"Total Load: {total_load} Watts", lang_code))
|
| 86 |
+
st.write(translate_text(f"Inverter Required: {inverter_capacity} kW", lang_code))
|
| 87 |
+
st.write(translate_text(f"Solar Panels Required: {int(panels_required)} (550W each)", lang_code))
|
| 88 |
+
st.write(translate_text(f"Batteries Required: {int(batteries_required)} (200 Ah, 48V system)", lang_code))
|
| 89 |
+
|
| 90 |
+
# Suggestions
|
| 91 |
+
st.subheader(translate_text("System Design Suggestions", lang_code))
|
| 92 |
+
suggestions = [
|
| 93 |
+
"Ensure panels are installed at the optimal tilt angle.",
|
| 94 |
+
"Consider a hybrid system for grid integration.",
|
| 95 |
+
"Use MPPT charge controllers for efficiency.",
|
| 96 |
+
"Plan for future system expansion.",
|
| 97 |
+
"Choose high-quality and reliable components.",
|
| 98 |
+
"Consult a certified solar installer for best practices."
|
| 99 |
+
]
|
| 100 |
+
for suggestion in suggestions:
|
| 101 |
+
st.write(translate_text(suggestion, lang_code))
|
| 102 |
+
|
| 103 |
|
| 104 |
|
| 105 |
|