karthikmn commited on
Commit
2c5de21
·
verified ·
1 Parent(s): b1cc5bc

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from utils.ansys_utils import generate_apdl_script, run_simulation
3
+ from utils.gcode_utils import generate_gcode
4
+
5
+ def automate_workflow(dimensions, material, analysis_type):
6
+ """
7
+ Automates the workflow:
8
+ 1. Generates APDL scripts based on input parameters.
9
+ 2. Runs the simulation (structural, thermal, or acoustic).
10
+ 3. Generates G-Code for CNC machining (optional).
11
+ """
12
+ # Step 1: Generate APDL script
13
+ apdl_script = generate_apdl_script(dimensions, material, analysis_type)
14
+
15
+ # Step 2: Run the simulation
16
+ simulation_results = run_simulation(apdl_script, analysis_type)
17
+
18
+ # Step 3: Generate G-Code (optional)
19
+ gcode_file = generate_gcode(dimensions)
20
+
21
+ return simulation_results, gcode_file
22
+
23
+ # Gradio Interface
24
+ interface = gr.Interface(
25
+ fn=automate_workflow,
26
+ inputs=[
27
+ gr.Textbox(label="Dimensions (e.g., 100x50x30 mm)"),
28
+ gr.Textbox(label="Material (e.g., Steel)"),
29
+ gr.Dropdown(label="Analysis Type", choices=["Structural", "Thermal", "Acoustic"])
30
+ ],
31
+ outputs=[
32
+ gr.Text(label="Simulation Results"),
33
+ gr.File(label="Generated G-Code File")
34
+ ],
35
+ title="ANSYS Simulation Automation"
36
+ )
37
+
38
+ if __name__ == "__main__":
39
+ interface.launch()