Spaces:
Runtime error
Runtime error
File size: 732 Bytes
f23118c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
from ansys.mapdl.core import launch_mapdl
def run_ansys_simulation(apdl_file):
"""
Run ANSYS simulation using a dynamically generated APDL script.
Parameters:
apdl_file (str): Path to the APDL script file.
Returns:
max_stress (float): Maximum stress from the simulation.
deformation (float): Total deformation from the simulation.
"""
mapdl = launch_mapdl()
# Load and execute the APDL script
mapdl.input(apdl_file)
# Extract results
max_stress = mapdl.get_value("NODE", 0, "S", "EQV") # Max equivalent stress
deformation = mapdl.get_value("NODE", 0, "U", "SUM") # Total deformation
mapdl.exit() # Close the session
return max_stress, deformation
|