|
|
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 |
|
|
|
|
|
|
|
|
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)) |
|
|
|
|
|
|
|
|
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)) |
|
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
|
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} m³ |
|
|
**Sand Volume:** {dry_mortar:.2f} × ({sand} / {ratio_sum}) = {sand_vol:.2f} m³ |
|
|
|
|
|
### 🧱 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}** |
|
|
""") |
|
|
|