karthikmn commited on
Commit
d553cf5
·
verified ·
1 Parent(s): 14a8c20

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -10
app.py CHANGED
@@ -2,37 +2,40 @@ 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__":
 
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, tolerances, forces, acoustic_properties):
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 based on the parameters
13
+ apdl_script = generate_apdl_script(dimensions, material, analysis_type, tolerances, forces, acoustic_properties)
14
 
15
+ # Step 2: Run the simulation (e.g., structural, thermal, or acoustic)
16
  simulation_results = run_simulation(apdl_script, analysis_type)
17
 
18
+ # Step 3: Generate G-Code (optional, based on CAD file or dimensions)
19
  gcode_file = generate_gcode(dimensions)
20
 
21
  return simulation_results, gcode_file
22
 
23
+ # Gradio Interface with additional parameters for forces, tolerances, and acoustic properties
24
  interface = gr.Interface(
25
  fn=automate_workflow,
26
  inputs=[
27
+ gr.Textbox(label="Dimensions (e.g., 100x50x30 mm)", placeholder="Enter dimensions in mm"),
28
+ gr.Textbox(label="Material (e.g., Steel)", placeholder="Enter material"),
29
+ gr.Dropdown(label="Analysis Type", choices=["Structural", "Thermal", "Acoustic"]),
30
+ gr.Textbox(label="Tolerances (e.g., ±0.05 mm)", placeholder="Enter tolerances"),
31
+ gr.Textbox(label="Forces (e.g., 500 N)", placeholder="Enter forces"),
32
+ gr.Textbox(label="Acoustic Properties (e.g., Sound absorption rate)", placeholder="Enter acoustic properties")
33
  ],
34
  outputs=[
35
  gr.Text(label="Simulation Results"),
36
  gr.File(label="Generated G-Code File")
37
  ],
38
+ title="ANSYS Simulation Automation with Additional Parameters"
39
  )
40
 
41
  if __name__ == "__main__":