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