arsalan16 commited on
Commit
f61b459
·
verified ·
1 Parent(s): 1297f51

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -25
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import streamlit as st
2
  from translate import Translator
3
- from pvlib import pvsystem, location
4
  import pandas as pd
5
  import numpy as np
6
 
@@ -30,54 +30,76 @@ lang_code = languages[selected_language]
30
  st.title(translate_text("Solar System Designer", lang_code))
31
 
32
  # Solar panel selection
33
- solar_panel_options = {
34
- "300W": 300,
35
- "400W": 400,
36
- "550W": 550
37
- }
38
- panel_choice = st.selectbox(translate_text("Select Solar Panel Capacity", lang_code), options=list(solar_panel_options.keys()))
39
- panel_capacity = solar_panel_options[panel_choice]
40
 
41
  # Battery options
42
  battery_types = {"Lithium-Ion": 0.95, "Lead-Acid": 0.8}
43
  battery_choice = st.selectbox(translate_text("Select Battery Type", lang_code), options=battery_types.keys())
44
  battery_efficiency = battery_types[battery_choice]
45
 
46
- # Appliance entry
47
- st.subheader(translate_text("Add Your Appliances", lang_code))
48
- appliances = []
49
-
50
- if "appliances" not in st.session_state:
51
- st.session_state["appliances"] = []
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
- appliance_name = st.text_input(translate_text("Appliance Name", lang_code))
54
- power = st.number_input(translate_text("Power (Watts)", lang_code), min_value=1)
55
- usage_hours = st.number_input(translate_text("Usage Hours per Day", lang_code), min_value=1)
56
 
57
- if st.button(translate_text("Add Appliance", lang_code)):
58
- st.session_state["appliances"].append({"name": appliance_name, "power": power, "hours": usage_hours})
 
 
 
 
59
 
60
- if st.session_state["appliances"]:
61
- st.table(st.session_state["appliances"])
 
62
 
63
  # Calculate recommendations
64
  if st.button(translate_text("Calculate Recommendations", lang_code)):
65
- total_load = sum(a["power"] * a["hours"] for a in st.session_state["appliances"])
66
  st.write(translate_text(f"Total Load (Watts): {total_load}", lang_code))
67
 
 
 
 
 
68
  # Solar panel calculation
69
  sunlight_hours = 5 # Average peak sunlight hours
70
- panels_required = np.ceil(total_load / (panel_capacity * sunlight_hours))
71
  st.write(translate_text(f"Solar Panels Required: {int(panels_required)}", lang_code))
72
 
 
 
 
 
73
  # Suggestions
74
  st.subheader(translate_text("System Design Suggestions", lang_code))
75
  suggestions = [
76
  "Ensure panels are installed at the optimal tilt angle.",
77
  "Consider a hybrid system for backup and grid integration.",
78
  "Use high-quality MPPT charge controllers.",
79
- "Plan for system expansion in future.",
80
- "Maintain batteries regularly for longevity."
 
 
 
81
  ]
82
  for suggestion in suggestions:
83
  st.write(translate_text(suggestion, lang_code))
@@ -90,3 +112,4 @@ if st.button(translate_text("Calculate Recommendations", lang_code)):
90
 
91
 
92
 
 
 
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
 
 
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:
105
  st.write(translate_text(suggestion, lang_code))
 
112
 
113
 
114
 
115
+