Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
|
4 |
+
# Dictionary containing materials, classes, and their properties
|
5 |
+
materials_data = {
|
6 |
+
"Metals": {
|
7 |
+
"Iron": {"Density (g/cm³)": 7.87, "Melting Point (°C)": 1538, "Conductivity (S/m)": 1.0e7},
|
8 |
+
"Aluminum": {"Density (g/cm³)": 2.7, "Melting Point (°C)": 660.3, "Conductivity (S/m)": 3.77e7},
|
9 |
+
"Copper": {"Density (g/cm³)": 8.96, "Melting Point (°C)": 1085, "Conductivity (S/m)": 5.96e7},
|
10 |
+
},
|
11 |
+
"Non-metals": {
|
12 |
+
"Carbon": {"Density (g/cm³)": 2.26, "Melting Point (°C)": 3550, "Conductivity (S/m)": 0.0},
|
13 |
+
"Sulfur": {"Density (g/cm³)": 2.07, "Melting Point (°C)": 115.2, "Conductivity (S/m)": 0.0},
|
14 |
+
},
|
15 |
+
"Metalloids": {
|
16 |
+
"Silicon": {"Density (g/cm³)": 2.33, "Melting Point (°C)": 1414, "Conductivity (S/m)": 1.56e-3},
|
17 |
+
"Boron": {"Density (g/cm³)": 2.34, "Melting Point (°C)": 2076, "Conductivity (S/m)": 0.0},
|
18 |
+
},
|
19 |
+
"Ceramics": {
|
20 |
+
"Porcelain": {"Density (g/cm³)": 2.4, "Melting Point (°C)": 1200, "Conductivity (S/m)": 0.0},
|
21 |
+
"Zirconia": {"Density (g/cm³)": 5.68, "Melting Point (°C)": 2715, "Conductivity (S/m)": 0.0},
|
22 |
+
},
|
23 |
+
"Polymers": {
|
24 |
+
"Polyethylene": {"Density (g/cm³)": 0.94, "Melting Point (°C)": 115, "Conductivity (S/m)": 0.0},
|
25 |
+
"PVC": {"Density (g/cm³)": 1.38, "Melting Point (°C)": 212, "Conductivity (S/m)": 0.0},
|
26 |
+
},
|
27 |
+
"Alloys": {
|
28 |
+
"Brass": {"Density (g/cm³)": 8.6, "Melting Point (°C)": 930, "Conductivity (S/m)": 1.5e7},
|
29 |
+
"Steel": {"Density (g/cm³)": 7.85, "Melting Point (°C)": 1370, "Conductivity (S/m)": 6.1e6},
|
30 |
+
},
|
31 |
+
}
|
32 |
+
|
33 |
+
# Streamlit app UI
|
34 |
+
st.title("Material Selection Tool")
|
35 |
+
st.sidebar.header("Select Material Class and Properties")
|
36 |
+
|
37 |
+
# User input for selecting material class
|
38 |
+
material_class = st.sidebar.selectbox("Select Material Class", options=materials_data.keys())
|
39 |
+
|
40 |
+
if material_class:
|
41 |
+
# User input for selecting specific material
|
42 |
+
material = st.sidebar.selectbox("Select Material", options=materials_data[material_class].keys())
|
43 |
+
|
44 |
+
# Display properties of the selected material
|
45 |
+
if material:
|
46 |
+
st.subheader(f"Properties of {material}")
|
47 |
+
properties = materials_data[material_class][material]
|
48 |
+
df = pd.DataFrame.from_dict(properties, orient="index", columns=["Value"])
|
49 |
+
df["Units"] = ["g/cm³", "°C", "S/m"] # Example units
|
50 |
+
st.table(df)
|
51 |
+
|
52 |
+
# Allow users to download data as CSV
|
53 |
+
csv = df.to_csv().encode("utf-8")
|
54 |
+
st.download_button(
|
55 |
+
label="Download Properties as CSV",
|
56 |
+
data=csv,
|
57 |
+
file_name=f"{material}_properties.csv",
|
58 |
+
mime="text/csv",
|
59 |
+
)
|
60 |
+
|