File size: 13,869 Bytes
b072320
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232df16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f4cec47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232df16
f4cec47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232df16
867fdcf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
import streamlit as st

def main():
    # Set up the app title and description
    st.title("Material Selector for Industries and Equipment")
    st.write("""
        This tool helps you identify the right material for designing equipment based on industry type and equipment requirements.
        Select from metals, polymers, ceramics, alloys, and more by specifying the industry and equipment name.
    """)

    # User inputs
    industry = st.text_input("Enter the industry (e.g., Automotive, Aerospace, Medical):")
    equipment = st.text_input("Enter the equipment name (e.g., Pipes, Bearings, Surgical Tools):")

    # Selection categories
    material_type = st.selectbox(
        "Select a material category:",
        ["Metals", "Polymers", "Ceramics", "Alloys"]
    )

    # Output recommendations
    if st.button("Get Material Recommendation"):
        if not industry or not equipment:
            st.warning("Please provide both the industry and equipment name.")
        else:
            recommendation = get_material_recommendation(industry, equipment, material_type)
            st.success("Recommendation:")
            st.write(recommendation)


def get_material_recommendation(industry, equipment, material_type):
    """Returns a material recommendation based on the inputs."""
    if material_type == "Metals":
        return "Metals like stainless steel, aluminum alloys, and titanium are often suitable for industries like {} with equipment such as {}. These materials offer high strength, durability, and corrosion resistance.".format(industry, equipment)
    
    elif material_type == "Polymers":
        return "Polymers such as PVC, polyethylene, and nylon are ideal for lightweight and flexible equipment in the {} industry, especially for {}.".format(industry, equipment)

    elif material_type == "Ceramics":
        return "Ceramics, including alumina and silicon carbide, are excellent choices for {} industry applications requiring high heat resistance and insulation, such as {}.".format(industry, equipment)

    elif material_type == "Alloys":
        return "Alloys like brass, bronze, and nickel-based superalloys are widely used in the {} industry for {} due to their strength, wear resistance, and tailored properties.".format(industry, equipment)

    else:
        return "Invalid material type selected. Please choose a valid category."

if __name__ == "__main__":
    main()

# Dictionary containing material data
MATERIALS = {
    "Metals": {
        "Alkali Metals": [
            "Highly reactive metals",
            "Soft, silvery-white in appearance",
            "Low density and melting points",
            "React vigorously with water to produce hydrogen gas and metal hydroxides",
            "Examples: Lithium, Sodium, Potassium, etc."
        ],
        "Transition Metals": [
            "High melting and boiling points",
            "Good conductors of heat and electricity",
            "Form colored compounds",
            "Examples: Iron, Copper, Gold, etc."
        ],
        # Add more metal categories here
    },
    "Non-metals": {
        "Oxygen": [
            "Essential for respiration and combustion",
            "Reacts with most elements to form oxides",
            "Supports life and used in industrial processes",
        ],
        "Carbon": [
            "Exists in various forms (diamond, graphite)",
            "Backbone of organic compounds",
            "Used in fuels, materials, and electronics",
        ],
        # Add more non-metals here
    },
    "Metalloids": {
        "Silicon": [
            "Essential for electronics as a semiconductor",
            "Used in glass, ceramics, and solar cells",
            "Second most abundant element in Earth’s crust",
        ],
        "Boron": [
            "Used in semiconductors and ceramics",
            "Essential micronutrient for plants",
            "High melting and boiling points",
        ],
        # Add more metalloids here
    },
    "Polymers": {
        "Thermoplastics": [
            "Can be softened and reshaped multiple times",
            "Examples: Polyethylene, Polypropylene",
            "Good electrical insulators and chemical resistance",
        ],
        "Thermosetting Polymers": [
            "Rigid, strong, and heat-resistant",
            "Examples: Epoxy resins, Polyurethane",
            "Good electrical insulators",
        ],
        # Add more polymer types here
    },
    "Ceramics": {
        "Oxide Ceramics": [
            "High melting points and hardness",
            "Examples: Alumina, Zirconia",
            "Used in high-temperature applications",
        ],
        "Carbide Ceramics": [
            "Extremely hard and wear-resistant",
            "Examples: Tungsten carbide, Silicon carbide",
            "Used in cutting tools and engine components",
        ],
        # Add more ceramics here
    },
    "Alloys": {
        "Steel": [
            "High strength and durability",
            "Used in construction and manufacturing",
            "Resistant to corrosion when alloyed with chromium",
        ],
        "Bronze": [
            "Hard and durable",
            "Used in sculptures, bells, and bearings",
            "Resistant to corrosion",
        ],
        # Add more alloys here
    }
}

def main():
    st.title("Material Selector")
    st.write("Use this app to identify the correct material for designing equipment and industries.")

    # Input fields for industry and equipment type
    industry = st.text_input("Enter the Industry (e.g., Aerospace, Automotive, etc.):")
    equipment = st.text_input("Enter the Equipment Name (e.g., Engine, Pipes, etc.):")

    st.write("### Material Categories")

    # Dropdown menu to select material category
    category = st.selectbox("Select a Material Category:", list(MATERIALS.keys()))

    # Display materials and their properties
    if category:
        st.subheader(f"{category} Properties")
        for subcategory, properties in MATERIALS[category].items():
            with st.expander(subcategory):
                for property in properties:
                    st.write(f"- {property}")

    # Display recommendations based on user inputs (example logic)
    if industry and equipment:
        st.write("### Recommended Materials")
        st.write(f"For **{equipment}** in the **{industry}** industry, consider the following materials:")

        if "steel" in equipment.lower() or "construction" in industry.lower():
            st.write("- **Steel**: High strength and durability, widely used in construction.")
        if "electronics" in industry.lower():
            st.write("- **Silicon**: Essential for semiconductors and electronics.")
        if "high temperature" in equipment.lower() or "aerospace" in industry.lower():
            st.write("- **Titanium Alloys**: High strength-to-weight ratio and excellent corrosion resistance.")
# Create a function for material selection
def material_selector(industry, equipment_material):
    # Material database
    materials_data = {
        "Metals": [
            {"Type": "Alkali Metals", "Properties": "Highly reactive, low density, low melting points, reacts with water", "Examples": "Lithium, Sodium, Potassium"},
            {"Type": "Alkaline Earth Metals", "Properties": "Reactive, higher density than alkali, moderate melting points", "Examples": "Magnesium, Calcium"},
            {"Type": "Transition Metals", "Properties": "High density, high melting points, excellent conductors", "Examples": "Iron, Copper, Gold"},
            {"Type": "Post-Transition Metals", "Properties": "Soft, malleable, moderate conductivity", "Examples": "Aluminum, Lead, Tin"},
        ],
        "Non-Metals": [
            {"Type": "Hydrogen", "Properties": "Highly flammable, colorless, combines with oxygen to form water", "Examples": "H2"},
            {"Type": "Carbon", "Properties": "Versatile, forms organic compounds", "Examples": "Graphite, Diamond"},
            {"Type": "Nitrogen", "Properties": "Essential for life, inert in its gaseous state", "Examples": "N2"},
        ],
        "Polymers": [
            {"Type": "Thermoplastics", "Properties": "Softened and reshaped by heat, lightweight, flexible", "Examples": "Polyethylene, Polypropylene"},
            {"Type": "Thermosetting", "Properties": "Strong, rigid, cannot be reshaped after curing", "Examples": "Epoxy Resin, Polyurethane"},
            {"Type": "Elastomers", "Properties": "Elastic, returns to original shape", "Examples": "Rubber, Silicone"},
        ],
        "Ceramics": [
            {"Type": "Oxide Ceramics", "Properties": "High hardness, heat resistance", "Examples": "Alumina, Silica"},
            {"Type": "Carbide Ceramics", "Properties": "Extremely hard, wear-resistant", "Examples": "Tungsten Carbide"},
            {"Type": "Silicate Ceramics", "Properties": "High strength, chemically resistant", "Examples": "Glass, Porcelain"},
        ],
        "Alloys": [
            {"Type": "Steel", "Properties": "Strong, durable, malleable", "Examples": "Carbon Steel, Stainless Steel"},
            {"Type": "Bronze", "Properties": "Corrosion-resistant, durable", "Examples": "Copper-Tin Alloy"},
            {"Type": "Titanium Alloys", "Properties": "High strength-to-weight ratio, corrosion resistant", "Examples": "Ti-6Al-4V"},
        ],
    }

    # Filter materials based on input
    matching_materials = []
    for category, materials in materials_data.items():
        for material in materials:
            if industry.lower() in material["Properties"].lower() or equipment_material.lower() in material["Examples"].lower():
                matching_materials.append({"Category": category, **material})

    return matching_materials

# Streamlit App Layout
st.title("Material Selector for Industries and Equipment")
st.subheader("Select the best material for your industrial application")

# User Inputs
industry = st.text_input("Enter Industry Type (e.g., Aerospace, Automotive, Construction):")
equipment_material = st.text_input("Enter Equipment Material Requirement (e.g., Lightweight, Corrosion Resistant):")

if st.button("Find Materials"):
    if industry and equipment_material:
        # Get matching materials
        results = material_selector(industry, equipment_material)
        if results:
            st.success(f"Found {len(results)} matching materials:")
            for result in results:
                st.write(f"**Category:** {result['Category']}")
                st.write(f"**Type:** {result['Type']}")
                st.write(f"**Properties:** {result['Properties']}")
                st.write(f"**Examples:** {result['Examples']}")
                st.write("---")
        else:
            st.warning("No matching materials found. Please refine your search.")
    else:
        st.error("Please provide both inputs to search for materials.")
if __name__ == "__main__":
    main()
# Load data for materials
@st.cache_data
def load_data():
    # Material properties data
    materials_data = {
        "Metals": {
            "Alkali Metals": ["Lithium", "Sodium", "Potassium"],
            "Alkaline Earth Metals": ["Magnesium", "Calcium"],
            "Transition Metals": ["Iron", "Copper", "Gold"],
        },
        "Polymers": {
            "Thermoplastics": ["Polyethylene", "Polypropylene"],
            "Thermosetting": ["Epoxy", "Phenolic"],
            "Elastomers": ["Rubber", "Neoprene"],
        },
        "Ceramics": {
            "Oxide Ceramics": ["Alumina", "Zirconia"],
            "Carbide Ceramics": ["Silicon Carbide", "Tungsten Carbide"],
        },
        "Alloys": {
            "Steel": ["High Carbon Steel", "Stainless Steel"],
            "Titanium Alloys": ["Ti-6Al-4V", "CP-Titanium"],
        }
    }
    return materials_data

materials_data = load_data()

# App Header
st.title("Material Selector App")
st.write("Identify the best material for making new objects based on your requirements.")

# Input from the user
industry = st.text_input("Enter the name of the industry (e.g., Aerospace, Construction, Medical, etc.):")
equipment_type = st.selectbox(
    "Select the type of material group:",
    options=["Metals", "Polymers", "Ceramics", "Alloys"]
)

# Display options based on material type
if equipment_type:
    st.write(f"### Material Options for {equipment_type}:")
    material_options = materials_data.get(equipment_type, {})
    for category, items in material_options.items():
        st.write(f"#### {category}:")
        st.write(", ".join(items))

# Material property viewer (for further details)
st.write("\n")
st.write("---")
st.write("### View Material Properties")
selected_material = st.text_input("Enter the name of a material to view its properties:")

if selected_material:
    # Mock property data for simplicity; you can expand this further
    properties_data = {
        "Lithium": {"Density (g/cm³)": 0.534, "Melting Point (°C)": 180.5, "Boiling Point (°C)": 1342},
        "Iron": {"Density (g/cm³)": 7.874, "Melting Point (°C)": 1538, "Boiling Point (°C)": 2862},
        "Polyethylene": {"Density (g/cm³)": 0.94, "Melting Point (°C)": 115, "Tensile Strength (MPa)": 37},
        "Alumina": {"Density (g/cm³)": 3.95, "Melting Point (°C)": 2072, "Hardness (Mohs)": 9},
        "Stainless Steel": {"Density (g/cm³)": 8.0, "Melting Point (°C)": 1510, "Tensile Strength (MPa)": 505}
    }

    material_properties = properties_data.get(selected_material)

    if material_properties:
        st.write(f"#### Properties of {selected_material}:")
        st.json(material_properties)
    else:
        st.write(f"Properties for {selected_material} are not available. Please try another material.")

# Footer
st.write("---")
st.write("Developed by [Your Name]. Powered by Streamlit and Deployable on Hugging Face Spaces.")