karthikmn commited on
Commit
781da5a
·
verified ·
1 Parent(s): a9d461b

Create ansys_utils.py

Browse files
Files changed (1) hide show
  1. utils/ansys_utils.py +24 -0
utils/ansys_utils.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ansys.mapdl.core import launch_mapdl
2
+
3
+ def run_simulation(cad_file):
4
+ """
5
+ Runs a simulation in ANSYS based on the provided CAD file.
6
+ Returns the simulation results.
7
+ """
8
+ try:
9
+ mapdl = launch_mapdl()
10
+ mapdl.prep7()
11
+ mapdl.et(1, "solid185")
12
+ mapdl.mp("EX", 1, 210e3)
13
+ mapdl.mp("NUXY", 1, 0.3)
14
+ mapdl.mp("DENS", 1, 7.85e-9)
15
+ mapdl.n(1, 0, 0, 0)
16
+ mapdl.n(2, 100, 0, 0)
17
+ mapdl.n(3, 0, 50, 0)
18
+ mapdl.e(1, 2, 3)
19
+ mapdl.solve()
20
+ results = mapdl.post_processing.nodal_solution
21
+ mapdl.exit()
22
+ return f"Simulation completed successfully. Results: {results}"
23
+ except Exception as e:
24
+ return f"Error in ANSYS simulation: {e}"