Update app.py
Browse files
app.py
CHANGED
|
@@ -1,52 +1,36 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import math
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
#
|
| 24 |
-
st.
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
st.
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
st.
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
st.
|
| 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
|
| 49 |
-
|
| 50 |
-
# Footer
|
| 51 |
-
st.markdown("---")
|
| 52 |
-
st.markdown("Developed with ❤️ using Streamlit.")
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
|
| 3 |
+
def calculate_steel_required(total_area, unit, steel_length, box_width, box_length):
|
| 4 |
+
# Convert everything to meters for consistency
|
| 5 |
+
conversion = {'m': 1, 'cm': 0.01, 'mm': 0.001}
|
| 6 |
+
total_area_m2 = total_area * (conversion[unit] ** 2) # Convert area to square meters
|
| 7 |
+
steel_length_m = steel_length * conversion[unit] # Convert steel length to meters
|
| 8 |
+
box_width_m = box_width * conversion[unit] # Convert box width to meters
|
| 9 |
+
box_length_m = box_length * conversion[unit] # Convert box length to meters
|
| 10 |
+
|
| 11 |
+
# Number of steel rods required
|
| 12 |
+
num_steel_width = int((total_area_m2 ** 0.5) / box_width_m) + 1
|
| 13 |
+
num_steel_length = int((total_area_m2 ** 0.5) / box_length_m) + 1
|
| 14 |
+
total_steel_rods = num_steel_width + num_steel_length
|
| 15 |
+
|
| 16 |
+
return total_steel_rods
|
| 17 |
+
|
| 18 |
+
# Streamlit UI
|
| 19 |
+
st.title("Steel Rods Calculator")
|
| 20 |
+
st.markdown("### Calculate the number of steel rods required based on the given area and box size.")
|
| 21 |
+
|
| 22 |
+
# Select measurement unit
|
| 23 |
+
unit = st.selectbox("Select measurement unit", ["m", "cm", "mm"], index=1)
|
| 24 |
+
|
| 25 |
+
# Input fields
|
| 26 |
+
total_area = st.number_input(f"Enter total area in {unit}²", min_value=0.0, format="%.2f")
|
| 27 |
+
steel_length = st.number_input(f"Enter length of one steel rod in {unit}", min_value=0.0, format="%.2f")
|
| 28 |
+
box_width = st.number_input(f"Enter width of the box in {unit}", min_value=0.0, format="%.2f")
|
| 29 |
+
box_length = st.number_input(f"Enter length of the box in {unit}", min_value=0.0, format="%.2f")
|
| 30 |
+
|
| 31 |
+
if st.button("Calculate Steel Required"):
|
| 32 |
+
if total_area > 0 and steel_length > 0 and box_width > 0 and box_length > 0:
|
| 33 |
+
result = calculate_steel_required(total_area, unit, steel_length, box_width, box_length)
|
| 34 |
+
st.success(f"Total steel rods required: {result}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
else:
|
| 36 |
+
st.error("Please enter valid positive numbers for all inputs.")
|
|
|
|
|
|
|
|
|
|
|
|