File size: 1,667 Bytes
3c0fe27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st

# List of materials and their properties
materials = {
    "Steel": {"Density": 7.85, "Tensile Strength": 400, "Corrosion Resistance": 7},
    "Aluminum": {"Density": 2.70, "Tensile Strength": 250, "Corrosion Resistance": 9},
    "Titanium": {"Density": 4.51, "Tensile Strength": 900, "Corrosion Resistance": 8},
    "Plastic": {"Density": 0.92, "Tensile Strength": 50, "Corrosion Resistance": 5},
    "Copper": {"Density": 8.96, "Tensile Strength": 210, "Corrosion Resistance": 6},
}

# Streamlit app
st.title("Material Selector for Equipment Design")

st.sidebar.header("Input Conditions")
density_limit = st.sidebar.number_input("Max Density (g/cm³)", min_value=0.0, step=0.1, value=10.0)
min_tensile_strength = st.sidebar.number_input("Min Tensile Strength (MPa)", min_value=0, step=10, value=100)
min_corrosion_resistance = st.sidebar.slider("Min Corrosion Resistance (1-10)", 1, 10, 5)

st.write("### Material Selection Conditions")
st.write(f"Max Density: {density_limit} g/cm³")
st.write(f"Min Tensile Strength: {min_tensile_strength} MPa")
st.write(f"Min Corrosion Resistance: {min_corrosion_resistance}/10")

# Filter materials based on conditions
filtered_materials = {
    material: props
    for material, props in materials.items()
    if props["Density"] <= density_limit
    and props["Tensile Strength"] >= min_tensile_strength
    and props["Corrosion Resistance"] >= min_corrosion_resistance
}

st.write("### Suitable Materials")
if filtered_materials:
    for material, props in filtered_materials.items():
        st.write(f"- **{material}**: {props}")
else:
    st.write("No materials match the given conditions.")