Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from progressive_die_design import generate_die_ANSYS
|
| 3 |
+
from stress_analysis import stress_analysis
|
| 4 |
+
|
| 5 |
+
# UI for Progressive Die Design
|
| 6 |
+
def progressive_die_interface(length, width, thickness, die_shape):
|
| 7 |
+
return generate_die_ANSYS(length, width, thickness, die_shape)
|
| 8 |
+
|
| 9 |
+
# UI for Stress Analysis
|
| 10 |
+
def stress_analysis_interface(force, die_width, die_height, material_strength, youngs_modulus, poisson_ratio, graph_type):
|
| 11 |
+
return stress_analysis(force, die_width, die_height, material_strength, youngs_modulus, poisson_ratio, graph_type)
|
| 12 |
+
|
| 13 |
+
# Gradio UI
|
| 14 |
+
with gr.Blocks() as app:
|
| 15 |
+
gr.Markdown("## Progressive Die Design and Stress Analysis")
|
| 16 |
+
with gr.Tabs():
|
| 17 |
+
with gr.Tab("Progressive Die Design"):
|
| 18 |
+
length = gr.Number(label="Length (mm)", value=100)
|
| 19 |
+
width = gr.Number(label="Width (mm)", value=50)
|
| 20 |
+
thickness = gr.Number(label="Thickness (mm)", value=10)
|
| 21 |
+
die_shape = gr.Dropdown(label="Die Shape", choices=["Rectangle", "Circle", "Ellipse", "Hexagon", "Polygon"], value="Rectangle")
|
| 22 |
+
die_button = gr.Button("Generate Die Design")
|
| 23 |
+
die_output = gr.Textbox(label="Die Design Message", interactive=False)
|
| 24 |
+
die_download = gr.File(label="Download Die Design Image")
|
| 25 |
+
die_button.click(progressive_die_interface, inputs=[length, width, thickness, die_shape], outputs=[die_output, die_download])
|
| 26 |
+
|
| 27 |
+
with gr.Tab("Stress Analysis"):
|
| 28 |
+
force = gr.Number(label="Force (N)", value=10000)
|
| 29 |
+
die_width = gr.Number(label="Width (m)", value=0.05)
|
| 30 |
+
die_height = gr.Number(label="Height (m)", value=0.01)
|
| 31 |
+
material_strength = gr.Number(label="Material Strength (MPa)", value=250)
|
| 32 |
+
youngs_modulus = gr.Number(label="Young's Modulus (GPa)", value=200)
|
| 33 |
+
poisson_ratio = gr.Number(label="Poisson's Ratio", value=0.3)
|
| 34 |
+
graph_type = gr.Dropdown(label="Graph Type", choices=["Bar Plot", "Line Plot", "3D Stress Visualization"], value="3D Stress Visualization")
|
| 35 |
+
safety_factor_output = gr.Textbox(label="Safety Factor")
|
| 36 |
+
stress_chart = gr.Plot()
|
| 37 |
+
stress_button = gr.Button("Analyze Stress")
|
| 38 |
+
stress_button.click(stress_analysis_interface, inputs=[force, die_width, die_height, material_strength, youngs_modulus, poisson_ratio, graph_type], outputs=[safety_factor_output, stress_chart])
|
| 39 |
+
|
| 40 |
+
app.launch()
|