Ahsan Ali Shah commited on
Commit
6b3df31
·
verified ·
1 Parent(s): db9a99d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import math
4
+
5
+ def calculate_solar_requirements(load_profile, panel_rating, sunlight_hours):
6
+ total_load = sum(load_profile)
7
+ energy_needed = total_load / 0.85 # Considering 85% efficiency
8
+ panels_needed = math.ceil(energy_needed / (panel_rating * sunlight_hours))
9
+ return total_load, energy_needed, panels_needed
10
+
11
+ def main():
12
+ st.title("Solar Power Plant Load Calculation")
13
+
14
+ st.sidebar.header("Input Parameters")
15
+
16
+ # User inputs
17
+ num_devices = st.sidebar.number_input("Number of Devices", min_value=1, value=3)
18
+ load_profile = []
19
+
20
+ for i in range(num_devices):
21
+ load = st.sidebar.number_input(f"Load of device {i+1} (Watts)", min_value=1, value=100)
22
+ hours = st.sidebar.number_input(f"Operating hours of device {i+1} (per day)", min_value=1, value=6)
23
+ load_profile.append(load * hours)
24
+
25
+ panel_rating = st.sidebar.number_input("Solar Panel Rating (Watts)", min_value=50, value=400)
26
+ sunlight_hours = st.sidebar.number_input("Average Sunlight Hours per Day", min_value=1.0, value=5.0)
27
+
28
+ if st.sidebar.button("Calculate"):
29
+ total_load, energy_needed, panels_needed = calculate_solar_requirements(load_profile, panel_rating, sunlight_hours)
30
+
31
+ st.subheader("Calculation Results")
32
+ st.write(f"**Total Daily Load:** {total_load:.2f} Watt-hours")
33
+ st.write(f"**Energy Needed (with Efficiency Consideration):** {energy_needed:.2f} Watt-hours")
34
+ st.write(f"**Number of Solar Panels Required:** {panels_needed}")
35
+
36
+ st.subheader("Device Load Details")
37
+ device_data = pd.DataFrame({
38
+ "Device": [f"Device {i+1}" for i in range(num_devices)],
39
+ "Load (Watts)": [load_profile[i] // hours for i, hours in enumerate([load_profile[i] / load_profile[i] ** 0] [i **.]}