Spaces:
Sleeping
Sleeping
import streamlit as st | |
def calculate_bricks(wall_length, wall_height, wall_thickness, brick_length, brick_height, brick_width, mortar_thickness): | |
# Adjusting brick size to include mortar thickness (convert inches to meters) | |
mortar_thickness_meters = mortar_thickness * 0.0254 # convert from inches to meters | |
effective_brick_length = (brick_length + mortar_thickness) * 0.0254 # convert from inches to meters | |
effective_brick_height = (brick_height + mortar_thickness) * 0.0254 # convert from inches to meters | |
effective_brick_width = (brick_width + mortar_thickness) * 0.0254 # convert from inches to meters | |
# Calculating wall and brick volumes | |
wall_volume = wall_length * wall_height * wall_thickness # wall volume in cubic feet | |
brick_volume = effective_brick_length * effective_brick_height * effective_brick_width # brick volume in cubic meters | |
# Total number of bricks required | |
total_bricks = wall_volume / brick_volume | |
return int(total_bricks) | |
def calculate_mortar_requirements(total_bricks): | |
# Approximate requirements based on standard mix ratios (1:6 for cement:sand) | |
# Cement per 1000 bricks = 3 bags (approx. 50 kg each) | |
# Sand per 1000 bricks = 0.6 m³ | |
# Water per 1000 bricks = 0.3 m³ | |
cement_bags = (total_bricks / 1000) * 3 | |
sand_volume = (total_bricks / 1000) * 0.6 | |
water_volume = (total_bricks / 1000) * 0.3 | |
return round(cement_bags, 2), round(sand_volume, 2), round(water_volume, 2) | |
# Streamlit UI | |
st.set_page_config(page_title="Bricks Estimator", layout="wide") | |
st.title("Bricks Estimator") | |
st.markdown(""" | |
Estimate the number of bricks and the mortar requirements for your construction project. | |
Enter the wall dimensions in feet and the brick size in inches. | |
""") | |
# Sidebar Inputs for Wall Dimensions | |
st.sidebar.header("Enter Wall Dimensions") | |
wall_length = st.sidebar.number_input("Wall Length (in feet)", min_value=0.1, step=0.1, value=10.0) | |
wall_height = st.sidebar.number_input("Wall Height (in feet)", min_value=0.1, step=0.1, value=8.0) | |
wall_thickness = st.sidebar.number_input("Wall Thickness (in feet)", min_value=0.05, step=0.01, value=0.5) | |
# Sidebar Inputs for Brick Dimensions | |
st.sidebar.header("Enter Brick Dimensions (in inches)") | |
brick_length = st.sidebar.number_input("Brick Length (in inches)", min_value=1, step=1, value=8) | |
brick_height = st.sidebar.number_input("Brick Height (in inches)", min_value=1, step=1, value=4) | |
brick_width = st.sidebar.number_input("Brick Width (in inches)", min_value=1, step=1, value=3) | |
# Sidebar Input for Mortar Thickness | |
st.sidebar.header("Enter Mortar Thickness (in inches)") | |
mortar_thickness = st.sidebar.number_input("Mortar Thickness", min_value=0, step=0.1, value=0.5) | |
# Main Area: Display Results after "Generate" button is clicked | |
col1, col2 = st.columns([3, 2]) | |
with col1: | |
if st.button("Generate"): | |
total_bricks = calculate_bricks(wall_length, wall_height, wall_thickness, brick_length, brick_height, brick_width, mortar_thickness) | |
cement_bags, sand_volume, water_volume = calculate_mortar_requirements(total_bricks) | |
st.subheader("Results") | |
st.write(f"**Total Bricks Required:** {total_bricks}") | |
st.write(f"**Cement Required:** {cement_bags} bags (50 kg each)") | |
st.write(f"**Sand Required:** {sand_volume} m³") | |
st.write(f"**Water Required:** {water_volume} m³") | |
with col2: | |
st.image("https://via.placeholder.com/300x200.png?text=Brick+Estimator", caption="Your Construction Partner", use_column_width=True) | |
st.markdown("---") | |
st.markdown(""" | |
<div style="text-align:center;"> | |
<a href="https://huggingface.co/spaces/your_space_url" target="_blank">Deploy on Hugging Face</a> | |
</div> | |
""", unsafe_allow_html=True) | |