arsalan16 commited on
Commit
b9c42db
·
verified ·
1 Parent(s): e810860

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -31
app.py CHANGED
@@ -1,59 +1,58 @@
1
  import streamlit as st
2
  import pandas as pd
3
 
4
- # Title and App Description
5
- st.title("SolarEase: Smart Solar System Designer")
6
- st.markdown("""
7
- Plan your solar system with ease! Input details for your appliances, and this app will recommend the necessary solar panels, batteries, and inverter capacity.
8
  """)
9
 
10
- # Sidebar for appliance input
11
  st.sidebar.header("Add Appliance Details")
12
  appliance_name = st.sidebar.text_input("Appliance Name", "LED Bulb")
13
- wattage = st.sidebar.number_input("Wattage (Watts)", min_value=1, value=10, step=1)
14
- quantity = st.sidebar.number_input("Quantity", min_value=1, value=1, step=1)
15
- usage_hours = st.sidebar.number_input("Daily Usage Hours", min_value=1, value=1, step=1)
16
- add_appliance = st.sidebar.button("Add Appliance")
17
 
18
- # Store appliance data
19
  if "appliances" not in st.session_state:
20
- st.session_state["appliances"] = []
21
 
22
- if add_appliance:
23
- st.session_state["appliances"].append({
24
  "Appliance": appliance_name,
25
  "Wattage": wattage,
26
  "Quantity": quantity,
27
- "Usage Hours": usage_hours,
28
  })
29
 
30
  # Display appliance table
31
- if st.session_state["appliances"]:
32
  st.subheader("Appliance Details")
33
- appliance_df = pd.DataFrame(st.session_state["appliances"])
34
- st.table(appliance_df)
35
 
36
- # Perform backend calculations
37
- appliance_df["Daily Energy (Wh)"] = appliance_df["Wattage"] * appliance_df["Quantity"] * appliance_df["Usage Hours"]
38
- total_energy = appliance_df["Daily Energy (Wh)"].sum() / 1000 # Convert Wh to kWh
 
 
39
 
 
 
40
  sunlight_hours = st.slider("Average Sunlight Hours", min_value=4, max_value=10, value=6)
41
  panel_efficiency = st.slider("Solar Panel Efficiency (%)", min_value=15, max_value=25, value=20) / 100
42
- battery_voltage = 12 # Default battery voltage
43
- battery_efficiency = 0.85 # Default battery efficiency
44
 
45
  # Calculations
46
- total_panel_wattage = total_energy / (sunlight_hours * panel_efficiency)
47
- battery_capacity = total_energy / (battery_voltage * battery_efficiency)
48
- peak_load = appliance_df["Wattage"].sum()
49
 
50
- # Display results
51
- st.subheader("Solar System Recommendations")
52
- st.write(f"**Total Daily Energy Consumption:** {total_energy:.2f} kWh")
53
  st.write(f"**Required Solar Panel Capacity:** {total_panel_wattage:.2f} W")
54
  st.write(f"**Battery Capacity Needed:** {battery_capacity:.2f} Ah")
55
- st.write(f"**Recommended Inverter Size:** {peak_load:.2f} W")
56
 
57
- # Footer
58
  st.markdown("---")
59
- st.markdown("**Designed by Engr. Muhammad Arsalan**")
 
 
1
  import streamlit as st
2
  import pandas as pd
3
 
4
+ # App Title
5
+ st.title("SolarEase: Solar System Planner")
6
+ st.write("""
7
+ This app calculates the total energy requirements and suggests a solar panel, battery, and inverter configuration.
8
  """)
9
 
10
+ # Input Section
11
  st.sidebar.header("Add Appliance Details")
12
  appliance_name = st.sidebar.text_input("Appliance Name", "LED Bulb")
13
+ wattage = st.sidebar.number_input("Wattage (Watts)", min_value=1, value=10)
14
+ quantity = st.sidebar.number_input("Quantity", min_value=1, value=1)
15
+ usage_hours = st.sidebar.number_input("Daily Usage Hours", min_value=1, value=1)
16
+ add_button = st.sidebar.button("Add Appliance")
17
 
18
+ # Session state for storing appliances
19
  if "appliances" not in st.session_state:
20
+ st.session_state.appliances = []
21
 
22
+ if add_button:
23
+ st.session_state.appliances.append({
24
  "Appliance": appliance_name,
25
  "Wattage": wattage,
26
  "Quantity": quantity,
27
+ "Usage Hours": usage_hours
28
  })
29
 
30
  # Display appliance table
31
+ if st.session_state.appliances:
32
  st.subheader("Appliance Details")
33
+ appliances_df = pd.DataFrame(st.session_state.appliances)
34
+ st.table(appliances_df)
35
 
36
+ # Calculate Total Energy Consumption
37
+ appliances_df["Daily Energy (Wh)"] = (
38
+ appliances_df["Wattage"] * appliances_df["Quantity"] * appliances_df["Usage Hours"]
39
+ )
40
+ total_energy_kwh = appliances_df["Daily Energy (Wh)"].sum() / 1000 # Convert to kWh
41
 
42
+ # Input for Solar System Configuration
43
+ st.subheader("Solar System Configuration")
44
  sunlight_hours = st.slider("Average Sunlight Hours", min_value=4, max_value=10, value=6)
45
  panel_efficiency = st.slider("Solar Panel Efficiency (%)", min_value=15, max_value=25, value=20) / 100
 
 
46
 
47
  # Calculations
48
+ total_panel_wattage = total_energy_kwh / (sunlight_hours * panel_efficiency)
49
+ battery_capacity = total_energy_kwh / 12 # Assume 12V system
 
50
 
51
+ # Display Results
52
+ st.write(f"**Total Energy Consumption:** {total_energy_kwh:.2f} kWh")
 
53
  st.write(f"**Required Solar Panel Capacity:** {total_panel_wattage:.2f} W")
54
  st.write(f"**Battery Capacity Needed:** {battery_capacity:.2f} Ah")
 
55
 
 
56
  st.markdown("---")
57
+ st.markdown("**Developed by Engr. Muhammad Arsalan**")
58
+