Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
# Set page config
|
| 4 |
+
st.set_page_config(page_title="Slab Concrete Calculator", layout="centered")
|
| 5 |
+
st.title("🧱 Slab Concrete Calculator")
|
| 6 |
+
|
| 7 |
+
# Units selection
|
| 8 |
+
unit = st.selectbox("Select unit for dimensions:", ["m", "cm", "mm"])
|
| 9 |
+
|
| 10 |
+
# Input fields
|
| 11 |
+
col1, col2, col3 = st.columns(3)
|
| 12 |
+
with col1:
|
| 13 |
+
length = st.number_input("Length (L)", min_value=0.0, format="%.2f")
|
| 14 |
+
with col2:
|
| 15 |
+
width = st.number_input("Width (W)", min_value=0.0, format="%.2f")
|
| 16 |
+
with col3:
|
| 17 |
+
thickness = st.number_input("Thickness (T)", min_value=0.0, format="%.2f")
|
| 18 |
+
|
| 19 |
+
# Convert all dimensions to meters
|
| 20 |
+
conversion_factor = {"m": 1, "cm": 0.01, "mm": 0.001}
|
| 21 |
+
factor = conversion_factor[unit]
|
| 22 |
+
length_m = length * factor
|
| 23 |
+
width_m = width * factor
|
| 24 |
+
thickness_m = thickness * factor
|
| 25 |
+
|
| 26 |
+
# Concrete Ratio Inputs
|
| 27 |
+
st.markdown("### 🧮 Concrete Mix Ratio")
|
| 28 |
+
col1, col2, col3 = st.columns(3)
|
| 29 |
+
with col1:
|
| 30 |
+
cement_ratio = st.number_input("Cement", min_value=0.0, value=1.0)
|
| 31 |
+
with col2:
|
| 32 |
+
sand_ratio = st.number_input("Sand", min_value=0.0, value=2.0)
|
| 33 |
+
with col3:
|
| 34 |
+
aggregate_ratio = st.number_input("Aggregate", min_value=0.0, value=4.0)
|
| 35 |
+
|
| 36 |
+
total_ratio = cement_ratio + sand_ratio + aggregate_ratio
|
| 37 |
+
|
| 38 |
+
# Additional inputs
|
| 39 |
+
cement_bag_weight = st.number_input("Cement Bag Weight (kg)", value=50.0)
|
| 40 |
+
cement_bag_price = st.number_input("Cement Bag Price ($)", value=0.0)
|
| 41 |
+
water_cement_ratio = st.number_input("Water-Cement Ratio", value=0.5)
|
| 42 |
+
concrete_price = st.number_input("Concrete Price per m³ ($)", value=0.0)
|
| 43 |
+
|
| 44 |
+
# Calculate button
|
| 45 |
+
if st.button("Calculate"):
|
| 46 |
+
# Step 1: Concrete Volume
|
| 47 |
+
concrete_volume = length_m * width_m * thickness_m
|
| 48 |
+
|
| 49 |
+
# Step 2: Dry volume
|
| 50 |
+
dry_volume = concrete_volume * 1.54
|
| 51 |
+
|
| 52 |
+
# Step 3: Material Volumes
|
| 53 |
+
cement_volume = (cement_ratio / total_ratio) * dry_volume
|
| 54 |
+
sand_volume = (sand_ratio / total_ratio) * dry_volume
|
| 55 |
+
aggregate_volume = (aggregate_ratio / total_ratio) * dry_volume
|
| 56 |
+
|
| 57 |
+
# Step 4: Cement weight & bags
|
| 58 |
+
cement_density = 1440 # kg/m³
|
| 59 |
+
cement_weight = cement_volume * cement_density
|
| 60 |
+
cement_bags = cement_weight / cement_bag_weight
|
| 61 |
+
|
| 62 |
+
# Step 5: Water
|
| 63 |
+
water_liters = cement_weight * water_cement_ratio
|
| 64 |
+
|
| 65 |
+
# Step 6: Costs
|
| 66 |
+
cement_cost = cement_bags * cement_bag_price
|
| 67 |
+
total_concrete_cost = concrete_volume * concrete_price
|
| 68 |
+
concrete_weight = cement_weight + (sand_volume + aggregate_volume) * 1600 # estimated total mass
|
| 69 |
+
|
| 70 |
+
# Results
|
| 71 |
+
st.markdown("### 📊 Results")
|
| 72 |
+
st.write(f"**Concrete Volume:** {concrete_volume:.2f} m³")
|
| 73 |
+
st.write(f"**Dry Concrete Volume:** {dry_volume:.2f} m³")
|
| 74 |
+
st.write(f"**Cement Volume:** {cement_volume:.2f} m³")
|
| 75 |
+
st.write(f"**Cement Weight:** {cement_weight:.2f} kg")
|
| 76 |
+
st.write(f"**Cement Bags:** {cement_bags:.2f} bags")
|
| 77 |
+
st.write(f"**Sand Volume:** {sand_volume:.2f} m³")
|
| 78 |
+
st.write(f"**Aggregate Volume:** {aggregate_volume:.2f} m³")
|
| 79 |
+
st.write(f"**Water Required:** {water_liters:.2f} liters")
|
| 80 |
+
st.write(f"**Cement Cost:** ${cement_cost:.2f}")
|
| 81 |
+
st.write(f"**Concrete Cost:** ${total_concrete_cost:.2f}")
|
| 82 |
+
st.write(f"**Estimated Concrete Weight:** {concrete_weight:.2f} kg")
|