Spaces:
Build error
Build error
Update app.py
Browse files
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 |
-
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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":
|