File size: 2,574 Bytes
eabbd86
 
0ca044c
eabbd86
4091ac7
eabbd86
0ca044c
eabbd86
0ca044c
eabbd86
 
0ca044c
 
 
 
 
eabbd86
0ca044c
 
 
 
 
eabbd86
0ca044c
 
 
 
 
eabbd86
4091ac7
0ca044c
4091ac7
0ca044c
eabbd86
 
0ca044c
 
 
 
 
 
 
 
 
 
 
4091ac7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import streamlit as st

st.set_page_config(page_title="🧱 Block Quantity Calculator", layout="centered")

st.title("🧱 Block Quantity Calculator with Formula Explanation")

unit = st.selectbox("Choose Unit", ["m", "cm"])

def convert(val):
    return val / 100 if unit == "cm" else val

# Wall Dimensions
st.subheader("Wall Dimensions")
L = convert(st.number_input("Wall Length", value=0.0))
H = convert(st.number_input("Wall Height", value=0.0))
T = convert(st.number_input("Wall Thickness", value=0.0))

# Block Dimensions
st.subheader("Block Dimensions")
BL = convert(st.number_input("Block Length", value=0.0))
BH = convert(st.number_input("Block Height", value=0.0))
BW = convert(st.number_input("Block Width", value=0.0))

# Mortar Ratio
st.subheader("Cement-Sand Ratio")
cement = st.number_input("Cement Ratio", value=1.0)
sand = st.number_input("Sand Ratio", value=2.5)
ratio_sum = cement + sand

# Additional Inputs
st.subheader("Additional Inputs")
deduct_area = st.number_input("Deducted Area (e.g., doors/windows) in m²", value=0.0)
block_price = st.number_input("Block Price (optional)", value=0.0)

if st.button("Calculate"):
    wall_vol = (L * H * T) - deduct_area
    block_vol = BL * BH * BW
    num_blocks = wall_vol / block_vol
    dry_mortar = wall_vol * 0.21
    cement_vol = dry_mortar * (cement / ratio_sum)
    sand_vol = dry_mortar * (sand / ratio_sum)
    cement_bags = cement_vol / 0.0347
    cost = num_blocks * block_price

    st.markdown("## 📘 Calculation Breakdown")

    st.markdown(f"""### 🧱 Wall Volume
**Formula:** `Length × Height × Thickness - Deducted Area`  
**=** {L:.2f} × {H:.2f} × {T:.2f} - {deduct_area:.2f}  
**= {wall_vol:.2f} m³**

### 🧱 Block Volume
**Formula:** `Length × Height × Width`  
**=** {BL:.2f} × {BH:.2f} × {BW:.2f}  
**= {block_vol:.4f} m³**

### 🔢 Number of Blocks
**Formula:** `Wall Volume ÷ Block Volume`  
**=** {wall_vol:.2f} ÷ {block_vol:.4f}  
**= {num_blocks:.0f} blocks**

### 🧪 Dry Mortar Volume
**Formula:** `Wall Volume × 0.21`  
**=** {wall_vol:.2f} × 0.21  
**= {dry_mortar:.2f} m³**

### 🧱 Cement & Sand Volume
**Cement Volume:** {dry_mortar:.2f} × ({cement} / {ratio_sum}) = {cement_vol:.2f}
**Sand Volume:** {dry_mortar:.2f} × ({sand} / {ratio_sum}) = {sand_vol:.2f}

### 🧱 Cement Bags
**Formula:** `Cement Volume ÷ 0.0347`  
**=** {cement_vol:.2f} ÷ 0.0347  
**= {cement_bags:.0f} bags**

### 💰 Total Cost (Optional)
**Formula:** `Number of Blocks × Block Price`  
**=** {num_blocks:.0f} × {block_price:.2f}  
**= ${cost:.2f}**
""")