CoolFace
Apppublic

Ubaidullah-Khan/CMD

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
app.py63 linesDownload Raw Back to root
1import streamlit as st2 3# Function to calculate compressive strength (example logic)4def calculate_compressive_strength(cement, coarse_agg, fine_agg, water, wc_ratio):5    # Example formula for compressive strength6    strength = (cement * 0.2 + coarse_agg * 0.15 + fine_agg * 0.1 + water * 0.05) / wc_ratio7    return round(strength, 2)8 9# Function to generate 5 possible mix designs10def generate_mix_designs(cement, coarse_agg, fine_agg, water, wc_ratio):11    designs = []12    for i in range(1, 6):13        factor = 1 + i * 0.0514        designs.append({15            "Cement": round(cement * factor, 2),16            "Coarse Aggregate": round(coarse_agg * factor, 2),17            "Fine Aggregate": round(fine_agg * factor, 2),18            "Water": round(water * factor, 2),19            "Water-Cement Ratio": round(wc_ratio * factor, 2),20        })21    return designs22 23# Streamlit app UI24st.set_page_config(page_title="Concrete Mix Design", page_icon="🏗️", layout="wide")25 26# Background27page_bg = """28<style>29[data-testid="stAppViewContainer"] {30    background-image: url("https://images.unsplash.com/photo-1516709455261-1644eaff5b70");31    background-size: cover;32    background-position: center;33}34[data-testid="stSidebar"] {35    background-color: rgba(255, 255, 255, 0.7);36}37</style>38"""39st.markdown(page_bg, unsafe_allow_html=True)40 41# Title42st.title("🏗️ Concrete Mix Design App")43 44# Input fields45st.header("Input Parameters")46cement = st.number_input("Cement Content (kg/m³)", min_value=100.0, max_value=600.0, value=300.0, step=0.1)47coarse_agg = st.number_input("Coarse Aggregate Content (kg/m³)", min_value=500.0, max_value=1200.0, value=800.0, step=0.1)48fine_agg = st.number_input("Fine Aggregate Content (kg/m³)", min_value=400.0, max_value=800.0, value=600.0, step=0.1)49water = st.number_input("Water Content (kg/m³)", min_value=100.0, max_value=300.0, value=180.0, step=0.1)50wc_ratio = st.number_input("Water-Cement Ratio", min_value=0.3, max_value=0.7, value=0.45, step=0.01)51 52# Calculate results53if st.button("Calculate"):54    # Calculate compressive strength55    compressive_strength = calculate_compressive_strength(cement, coarse_agg, fine_agg, water, wc_ratio)56    st.success(f"Calculated Compressive Strength: {compressive_strength} MPa")57 58    # Generate and display mix designs59    st.subheader("Possible Mix Designs")60    mix_designs = generate_mix_designs(cement, coarse_agg, fine_agg, water, wc_ratio)61    for i, design in enumerate(mix_designs, start=1):62        st.write(f"*Mix Design {i}:*")63        st.json(design)