karthikmn commited on
Commit
341dd47
·
verified ·
1 Parent(s): 14c5d89

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -2
app.py CHANGED
@@ -71,8 +71,25 @@ PRNSOL,U,SUM ! Print total deformation results
71
  file.write(apdl_script)
72
 
73
  print(f"APDL script saved at: simulation_input.inp")
74
- ansys_executable = r"C:\Program Files\ANSYS Inc\v201\ansys\bin\winx64\ANSYS201.exe" # Update this path
75
- mapdl = launch_mapdl(run_location=ansys_executable)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
 
77
  # Run the selected simulator
78
  if simulator == "PyCalculix":
 
71
  file.write(apdl_script)
72
 
73
  print(f"APDL script saved at: simulation_input.inp")
74
+ from time import sleep # Add this at the top to handle sleep
75
+
76
+ print("Running ANSYS simulation...")
77
+ mapdl = launch_mapdl()
78
+ mapdl.input("simulation_input.inp")
79
+ sleep(5) # Wait for 5 seconds to ensure results are calculated
80
+
81
+ # Check if the values are being fetched correctly
82
+ try:
83
+ max_stress = mapdl.get_value("NODE", 0, "S", "EQV")
84
+ deformation = mapdl.get_value("NODE", 0, "U", "SUM")
85
+ except Exception as e:
86
+ print(f"Error reading ANSYS results: {e}")
87
+ max_stress = deformation = 0 # Default values in case of error
88
+
89
+ mapdl.exit()
90
+ stress, deformation = max_stress, deformation
91
+ print(f"Stress: {stress}, Deformation: {deformation}")
92
+
93
 
94
  # Run the selected simulator
95
  if simulator == "PyCalculix":