arsalan16 commited on
Commit
5962009
·
verified ·
1 Parent(s): 5bc3747

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +65 -48
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
- # 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:
85
- st.write(translate_text(suggestion, lang_code))
 
 
 
 
 
 
 
 
 
 
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