engrmuhammadrizwan01 commited on
Commit
1f699ba
Β·
verified Β·
1 Parent(s): 4a2e3a8

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -0
app.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import math
3
+
4
+ # Function to calculate required C Channels/Rods based on spacing
5
+ def calculate_c_channels(area_length, area_width, rod_length, horizontal_spacing, vertical_spacing):
6
+ if rod_length <= 0 or horizontal_spacing <= 0 or vertical_spacing <= 0:
7
+ return None, None
8
+
9
+ # Calculate number of horizontal and vertical rods needed
10
+ num_horizontal_rods = math.ceil(area_width / horizontal_spacing) + 1 # Extra rod at boundary
11
+ num_vertical_rods = math.ceil(area_length / vertical_spacing) + 1 # Extra rod at boundary
12
+
13
+ # Total length required for horizontal and vertical rods
14
+ total_horizontal_length = num_horizontal_rods * area_length
15
+ total_vertical_length = num_vertical_rods * area_width
16
+
17
+ # Compute number of rods needed based on length
18
+ required_horizontal_rods = math.ceil(total_horizontal_length / rod_length)
19
+ required_vertical_rods = math.ceil(total_vertical_length / rod_length)
20
+
21
+ return required_horizontal_rods, required_vertical_rods
22
+
23
+ # Streamlit UI Configuration
24
+ st.set_page_config(page_title="C Channel/Rod Calculator", layout="wide")
25
+
26
+ st.title("πŸ›  C Channel/Rod Calculator")
27
+ st.markdown("Calculate required C Channels/Rods based on area and spacing.")
28
+
29
+ # Area Input
30
+ st.subheader("πŸ“ Area Dimensions")
31
+ area_length = st.number_input("Enter Total Length of Area (meters):", min_value=0.1, format="%.2f")
32
+ area_width = st.number_input("Enter Total Width of Area (meters):", min_value=0.1, format="%.2f")
33
+
34
+ # C Channel/Rod Inputs
35
+ st.subheader("πŸ”© C Channel/Rod Specifications")
36
+ rod_length = st.number_input("Enter Length of One C Channel/Rod (meters):", min_value=0.1, format="%.2f")
37
+ horizontal_spacing = st.number_input("Enter Horizontal Distance Between Rods (meters):", min_value=0.1, format="%.2f")
38
+ vertical_spacing = st.number_input("Enter Vertical Distance Between Rods (meters):", min_value=0.1, format="%.2f")
39
+
40
+ if st.button("Calculate Required C Channels/Rods"):
41
+ num_horizontal, num_vertical = calculate_c_channels(area_length, area_width, rod_length, horizontal_spacing, vertical_spacing)
42
+
43
+ if num_horizontal is not None and num_vertical is not None:
44
+ total_rods = num_horizontal + num_vertical
45
+ st.success(f"πŸ“Œ You will need `{num_horizontal}` Horizontal C Channels/Rods and `{num_vertical}` Vertical C Channels/Rods.")
46
+ st.info(f"βœ… **Total C Channels/Rods Required:** `{total_rods}`")
47
+ else:
48
+ st.error("Please enter valid values for the C Channel/Rod calculation.")
49
+
50
+ # Footer
51
+ st.markdown("---")
52
+ st.markdown("Developed with ❀️ using Streamlit.")