Update app.py
Browse files
app.py
CHANGED
|
@@ -4,13 +4,13 @@ import streamlit as st
|
|
| 4 |
FT_TO_M = 0.3048 # 1 foot = 0.3048 meters
|
| 5 |
KG_TO_LB = 2.20462 # 1 kg = 2.20462 pounds
|
| 6 |
|
| 7 |
-
# Function to calculate number of bricks, mortar, and cement bags required
|
| 8 |
-
def
|
| 9 |
# Convert units if necessary
|
| 10 |
if length_unit == 'Feet':
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
brick_length *= FT_TO_M
|
| 15 |
brick_width *= FT_TO_M
|
| 16 |
brick_height *= FT_TO_M
|
|
@@ -22,16 +22,17 @@ def calculate_bricks_and_mortar(wall_length, wall_height, wall_thickness, brick_
|
|
| 22 |
cement_bag_weight = 50 # 50 kg for metric system
|
| 23 |
cement_bag_volume = cement_bag_weight / 1440 # Convert to cubic meters based on density
|
| 24 |
|
| 25 |
-
# Calculate the volume of the
|
| 26 |
-
|
|
|
|
| 27 |
|
| 28 |
# Calculate the volume of a single brick (in cubic meters)
|
| 29 |
brick_volume = brick_length * brick_width * brick_height
|
| 30 |
|
| 31 |
-
# Number of bricks = Volume of
|
| 32 |
number_of_bricks = wall_volume / brick_volume
|
| 33 |
|
| 34 |
-
# Add extra volume for mortar (typically 10% of the total volume)
|
| 35 |
mortar_volume = wall_volume * 0.1 # 10% of wall volume as mortar
|
| 36 |
|
| 37 |
# Cement ratio in mortar mix (1:4, cement:sand), so cement is 1/5 of mortar volume
|
|
@@ -40,37 +41,47 @@ def calculate_bricks_and_mortar(wall_length, wall_height, wall_thickness, brick_
|
|
| 40 |
# Number of cement bags
|
| 41 |
cement_bags = cement_volume / cement_bag_volume
|
| 42 |
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
|
| 46 |
# Set page title and icon
|
| 47 |
-
st.set_page_config(page_title="
|
| 48 |
|
| 49 |
# Title of the app
|
| 50 |
-
st.title("
|
| 51 |
|
| 52 |
# Description of the app
|
| 53 |
st.markdown("""
|
| 54 |
-
## Welcome to the
|
| 55 |
-
This tool helps you estimate the **number of bricks**, the **amount of mortar**, and the **number of cement bags** required to build a
|
| 56 |
You can select the units for measurements (meters/feet and kg/pounds).
|
|
|
|
| 57 |
""")
|
| 58 |
|
| 59 |
# Create unit selection options
|
| 60 |
length_unit = st.radio("Select Unit for Length", ('Meters', 'Feet'))
|
| 61 |
weight_unit = st.radio("Select Unit for Weight", ('Kilograms', 'Pounds'))
|
| 62 |
|
| 63 |
-
# Create input fields for
|
|
|
|
|
|
|
|
|
|
| 64 |
col1, col2 = st.columns(2)
|
| 65 |
|
| 66 |
with col1:
|
| 67 |
-
|
| 68 |
|
| 69 |
with col2:
|
| 70 |
-
|
| 71 |
|
| 72 |
with col1:
|
| 73 |
-
|
| 74 |
|
| 75 |
st.markdown("### Enter Brick Dimensions")
|
| 76 |
|
|
@@ -87,55 +98,58 @@ with col3:
|
|
| 87 |
|
| 88 |
# When the user clicks the "Calculate" button, we compute the number of bricks, mortar, and cement bags
|
| 89 |
if st.button("Calculate"):
|
| 90 |
-
if
|
| 91 |
# Call the calculation function
|
| 92 |
-
|
| 93 |
|
| 94 |
# Display the results with appropriate units
|
| 95 |
if length_unit == 'Feet':
|
| 96 |
st.markdown(f"""
|
| 97 |
-
###
|
| 98 |
-
#### {int(
|
| 99 |
|
| 100 |
-
###
|
| 101 |
-
#### {
|
| 102 |
|
| 103 |
-
###
|
| 104 |
-
#### {int(
|
| 105 |
""")
|
| 106 |
else:
|
| 107 |
st.markdown(f"""
|
| 108 |
-
###
|
| 109 |
-
#### {int(
|
| 110 |
|
| 111 |
-
###
|
| 112 |
-
#### {
|
| 113 |
|
| 114 |
-
###
|
| 115 |
-
#### {int(
|
| 116 |
""")
|
| 117 |
else:
|
| 118 |
st.error("Please enter valid values for all inputs.")
|
| 119 |
|
| 120 |
# Optional: Add an expander for more information
|
| 121 |
-
with st.expander("🔍 Learn More about
|
| 122 |
st.markdown("""
|
| 123 |
-
|
| 124 |
**Formula for calculating bricks, mortar, and cement bags:**
|
| 125 |
\[
|
|
|
|
|
|
|
|
|
|
| 126 |
\text{Number of Bricks} = \frac{\text{Wall Volume}}{\text{Brick Volume}}
|
| 127 |
\]
|
| 128 |
\[
|
| 129 |
-
\text{Mortar Volume} = \text{Wall Volume} \times 0.1
|
| 130 |
\]
|
| 131 |
\[
|
| 132 |
-
\text{Cement Volume} = \frac{\text{Mortar Volume}}{5}
|
| 133 |
\]
|
| 134 |
\[
|
| 135 |
\text{Number of Cement Bags} = \frac{\text{Cement Volume}}{0.0347}
|
| 136 |
\]
|
| 137 |
Where:
|
| 138 |
-
- Wall
|
| 139 |
- Brick Volume = Length × Width × Height (m³ or ft³ based on your selection)
|
| 140 |
- Mortar Volume is assumed to be 10% of the wall volume.
|
| 141 |
- One cement bag = 50 kg (or 110 lbs) = 0.0347 cubic meters of cement.
|
|
@@ -145,8 +159,9 @@ with st.expander("🔍 Learn More about Brick Masonry"):
|
|
| 145 |
st.markdown("""
|
| 146 |
---
|
| 147 |
<footer>
|
| 148 |
-
<p style="text-align:center;">
|
| 149 |
</footer>
|
| 150 |
""", unsafe_allow_html=True)
|
| 151 |
|
| 152 |
|
|
|
|
|
|
| 4 |
FT_TO_M = 0.3048 # 1 foot = 0.3048 meters
|
| 5 |
KG_TO_LB = 2.20462 # 1 kg = 2.20462 pounds
|
| 6 |
|
| 7 |
+
# Function to calculate number of bricks, mortar, and cement bags required for multiple rooms
|
| 8 |
+
def calculate_room_materials(room_length, room_width, room_height, brick_length, brick_width, brick_height, length_unit, weight_unit, number_of_rooms):
|
| 9 |
# Convert units if necessary
|
| 10 |
if length_unit == 'Feet':
|
| 11 |
+
room_length *= FT_TO_M
|
| 12 |
+
room_width *= FT_TO_M
|
| 13 |
+
room_height *= FT_TO_M
|
| 14 |
brick_length *= FT_TO_M
|
| 15 |
brick_width *= FT_TO_M
|
| 16 |
brick_height *= FT_TO_M
|
|
|
|
| 22 |
cement_bag_weight = 50 # 50 kg for metric system
|
| 23 |
cement_bag_volume = cement_bag_weight / 1440 # Convert to cubic meters based on density
|
| 24 |
|
| 25 |
+
# Calculate the volume of the four walls (in cubic meters)
|
| 26 |
+
wall_area = 2 * (room_length + room_width) * room_height # Total wall area
|
| 27 |
+
wall_volume = wall_area * 0.1 # Assume 10% is mortar (for simplicity in calculation)
|
| 28 |
|
| 29 |
# Calculate the volume of a single brick (in cubic meters)
|
| 30 |
brick_volume = brick_length * brick_width * brick_height
|
| 31 |
|
| 32 |
+
# Number of bricks = Volume of walls / Volume of one brick
|
| 33 |
number_of_bricks = wall_volume / brick_volume
|
| 34 |
|
| 35 |
+
# Add extra volume for mortar (typically 10% of the total wall volume)
|
| 36 |
mortar_volume = wall_volume * 0.1 # 10% of wall volume as mortar
|
| 37 |
|
| 38 |
# Cement ratio in mortar mix (1:4, cement:sand), so cement is 1/5 of mortar volume
|
|
|
|
| 41 |
# Number of cement bags
|
| 42 |
cement_bags = cement_volume / cement_bag_volume
|
| 43 |
|
| 44 |
+
# Multiply results by the number of rooms
|
| 45 |
+
total_bricks = number_of_bricks * number_of_rooms
|
| 46 |
+
total_mortar = mortar_volume * number_of_rooms
|
| 47 |
+
total_cement_bags = cement_bags * number_of_rooms
|
| 48 |
+
|
| 49 |
+
# Return results
|
| 50 |
+
return total_bricks, total_mortar, total_cement_bags
|
| 51 |
|
| 52 |
|
| 53 |
# Set page title and icon
|
| 54 |
+
st.set_page_config(page_title="Room Masonry Estimator", page_icon="🧱")
|
| 55 |
|
| 56 |
# Title of the app
|
| 57 |
+
st.title("Room Masonry Estimator")
|
| 58 |
|
| 59 |
# Description of the app
|
| 60 |
st.markdown("""
|
| 61 |
+
## Welcome to the Room Masonry Estimator!
|
| 62 |
+
This tool helps you estimate the **number of bricks**, the **amount of mortar**, and the **number of cement bags** required to build the walls, floor, and ceiling of a room.
|
| 63 |
You can select the units for measurements (meters/feet and kg/pounds).
|
| 64 |
+
Additionally, you can specify the **number of rooms**.
|
| 65 |
""")
|
| 66 |
|
| 67 |
# Create unit selection options
|
| 68 |
length_unit = st.radio("Select Unit for Length", ('Meters', 'Feet'))
|
| 69 |
weight_unit = st.radio("Select Unit for Weight", ('Kilograms', 'Pounds'))
|
| 70 |
|
| 71 |
+
# Create input fields for the number of rooms
|
| 72 |
+
number_of_rooms = st.number_input("Enter the Number of Rooms:", min_value=1, step=1)
|
| 73 |
+
|
| 74 |
+
# Create input fields for room and brick dimensions
|
| 75 |
col1, col2 = st.columns(2)
|
| 76 |
|
| 77 |
with col1:
|
| 78 |
+
room_length = st.number_input(f"Enter Room Length ({length_unit}):", min_value=0.0, step=0.1)
|
| 79 |
|
| 80 |
with col2:
|
| 81 |
+
room_width = st.number_input(f"Enter Room Width ({length_unit}):", min_value=0.0, step=0.1)
|
| 82 |
|
| 83 |
with col1:
|
| 84 |
+
room_height = st.number_input(f"Enter Room Height ({length_unit}):", min_value=0.0, step=0.1)
|
| 85 |
|
| 86 |
st.markdown("### Enter Brick Dimensions")
|
| 87 |
|
|
|
|
| 98 |
|
| 99 |
# When the user clicks the "Calculate" button, we compute the number of bricks, mortar, and cement bags
|
| 100 |
if st.button("Calculate"):
|
| 101 |
+
if room_length > 0 and room_width > 0 and room_height > 0 and brick_length > 0 and brick_width > 0 and brick_height > 0 and number_of_rooms > 0:
|
| 102 |
# Call the calculation function
|
| 103 |
+
total_bricks, total_mortar, total_cement_bags = calculate_room_materials(room_length, room_width, room_height, brick_length, brick_width, brick_height, length_unit, weight_unit, number_of_rooms)
|
| 104 |
|
| 105 |
# Display the results with appropriate units
|
| 106 |
if length_unit == 'Feet':
|
| 107 |
st.markdown(f"""
|
| 108 |
+
### Total Number of Bricks required for {number_of_rooms} rooms:
|
| 109 |
+
#### {int(total_bricks):,} bricks
|
| 110 |
|
| 111 |
+
### Total Mortar required:
|
| 112 |
+
#### {total_mortar:.2f} cubic meters (10% of wall volume)
|
| 113 |
|
| 114 |
+
### Total Cement Bags required:
|
| 115 |
+
#### {int(total_cement_bags):,} bags (50 kg each)
|
| 116 |
""")
|
| 117 |
else:
|
| 118 |
st.markdown(f"""
|
| 119 |
+
### Total Number of Bricks required for {number_of_rooms} rooms:
|
| 120 |
+
#### {int(total_bricks):,} bricks
|
| 121 |
|
| 122 |
+
### Total Mortar required:
|
| 123 |
+
#### {total_mortar:.2f} cubic meters (10% of wall volume)
|
| 124 |
|
| 125 |
+
### Total Cement Bags required:
|
| 126 |
+
#### {int(total_cement_bags):,} bags (50 kg each)
|
| 127 |
""")
|
| 128 |
else:
|
| 129 |
st.error("Please enter valid values for all inputs.")
|
| 130 |
|
| 131 |
# Optional: Add an expander for more information
|
| 132 |
+
with st.expander("🔍 Learn More about Room Masonry"):
|
| 133 |
st.markdown("""
|
| 134 |
+
Room masonry involves constructing walls, floors, and ceilings using bricks and mortar.
|
| 135 |
**Formula for calculating bricks, mortar, and cement bags:**
|
| 136 |
\[
|
| 137 |
+
\text{Wall Volume} = \text{Wall Area} \times \text{Thickness}
|
| 138 |
+
\]
|
| 139 |
+
\[
|
| 140 |
\text{Number of Bricks} = \frac{\text{Wall Volume}}{\text{Brick Volume}}
|
| 141 |
\]
|
| 142 |
\[
|
| 143 |
+
\text{Mortar Volume} = \text{Wall Volume} \times 0.1 \quad \text{(10% of wall volume)}
|
| 144 |
\]
|
| 145 |
\[
|
| 146 |
+
\text{Cement Volume} = \frac{\text{Mortar Volume}}{5} \quad \text{(1:4 cement:sand mix)}
|
| 147 |
\]
|
| 148 |
\[
|
| 149 |
\text{Number of Cement Bags} = \frac{\text{Cement Volume}}{0.0347}
|
| 150 |
\]
|
| 151 |
Where:
|
| 152 |
+
- Wall Area = 2 × (Length + Width) × Height
|
| 153 |
- Brick Volume = Length × Width × Height (m³ or ft³ based on your selection)
|
| 154 |
- Mortar Volume is assumed to be 10% of the wall volume.
|
| 155 |
- One cement bag = 50 kg (or 110 lbs) = 0.0347 cubic meters of cement.
|
|
|
|
| 159 |
st.markdown("""
|
| 160 |
---
|
| 161 |
<footer>
|
| 162 |
+
<p style="text-align:center;">Room Masonry Estimator | Designed with 💻 by Dr.Usman</p>
|
| 163 |
</footer>
|
| 164 |
""", unsafe_allow_html=True)
|
| 165 |
|
| 166 |
|
| 167 |
+
|