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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -55
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
- # Solar panel selection
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
- # Predefined appliances
41
- appliances = {
42
- "LED Bulbs": 10,
43
- "Fans": 60,
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 selection and customization
60
- st.subheader(translate_text("Select Appliances", lang_code))
61
- selected_appliances = []
 
 
 
 
62
 
63
- for appliance, power in appliances.items():
64
- if appliance == "Others":
65
- power = st.number_input(translate_text("Enter Power for Others (Watts):", lang_code), min_value=0)
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
- if selected_appliances:
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
- total_load = sum(a["power"] * a["hours"] for a in selected_appliances)
77
- st.write(translate_text(f"Total Load (Watts): {total_load}", lang_code))
78
 
79
- # Inverter requirement
80
- inverter_capacity = total_load / 1000 # Convert to kW
81
- st.write(translate_text(f"Inverter Required: {inverter_capacity:.2f} kW", lang_code))
82
 
83
- # Solar panel calculation
 
84
  sunlight_hours = 5 # Average peak sunlight hours
85
- panels_required = np.ceil(total_load / (solar_panel_capacity * sunlight_hours))
86
- st.write(translate_text(f"Solar Panels Required: {int(panels_required)}", lang_code))
 
 
 
87
 
88
- # Battery calculation
89
- battery_capacity = np.ceil(total_load / (battery_efficiency * sunlight_hours))
90
- st.write(translate_text(f"Number of Batteries Required: {int(battery_capacity)}", lang_code))
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 backup and grid integration.",
97
- "Use high-quality MPPT charge controllers.",
98
- "Plan for system expansion in the future.",
99
- "Maintain batteries regularly for longevity.",
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
+