Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
# Define material categories and their properties
|
4 |
+
materials = {
|
5 |
+
"Metals": {"Mechanical": 8, "Chemical": 6, "Thermal": 9, "Electrical": 9, "Magnetic": 8, "Optical": 3},
|
6 |
+
"Non-metals": {"Mechanical": 4, "Chemical": 8, "Thermal": 4, "Electrical": 3, "Magnetic": 1, "Optical": 7},
|
7 |
+
"Metalloids": {"Mechanical": 6, "Chemical": 7, "Thermal": 6, "Electrical": 6, "Magnetic": 4, "Optical": 5},
|
8 |
+
"Ceramics": {"Mechanical": 7, "Chemical": 9, "Thermal": 7, "Electrical": 5, "Magnetic": 3, "Optical": 6},
|
9 |
+
"Polymers": {"Mechanical": 5, "Chemical": 6, "Thermal": 3, "Electrical": 4, "Magnetic": 2, "Optical": 5},
|
10 |
+
"Alloys": {"Mechanical": 9, "Chemical": 7, "Thermal": 8, "Electrical": 7, "Magnetic": 6, "Optical": 4},
|
11 |
+
}
|
12 |
+
|
13 |
+
# App title
|
14 |
+
st.title("Material Selection Tool")
|
15 |
+
|
16 |
+
# Sidebar for filtering properties
|
17 |
+
st.sidebar.header("Filter Properties")
|
18 |
+
property_filters = {}
|
19 |
+
for prop in ["Mechanical", "Chemical", "Thermal", "Electrical", "Magnetic", "Optical"]:
|
20 |
+
property_filters[prop] = st.sidebar.slider(f"{prop} (1-10)", 1, 10, (1, 10))
|
21 |
+
|
22 |
+
# Display filtered materials
|
23 |
+
st.header("Filtered Materials")
|
24 |
+
filtered_materials = []
|
25 |
+
for material, properties in materials.items():
|
26 |
+
if all(
|
27 |
+
property_filters[prop][0] <= value <= property_filters[prop][1]
|
28 |
+
for prop, value in properties.items()
|
29 |
+
):
|
30 |
+
filtered_materials.append(material)
|
31 |
+
|
32 |
+
if filtered_materials:
|
33 |
+
st.write("The materials matching your criteria are:")
|
34 |
+
for material in filtered_materials:
|
35 |
+
st.markdown(f"- **{material}**")
|
36 |
+
else:
|
37 |
+
st.write("No materials match your selected criteria. Please adjust the filters.")
|
38 |
+
|
39 |
+
# Footer
|
40 |
+
st.sidebar.markdown("---")
|
41 |
+
st.sidebar.write("Developed by [Your Name]")
|