import numpy as np def run_python_simulation(apdl_path, simulation_type, thickness, length, width, force, load): """ Simulate stress and deformation based on inputs. Parameters: apdl_path (str): APDL script path. simulation_type (str): 'plate' or 'beam'. thickness (float): Thickness of the material (mm). length (float): Length of the material (mm). width (float): Width of the material (mm). force (float): Applied force (N) (optional). load (float): Applied load (N) (optional). Returns: stress (float): Simulated stress (MPa). deformation (float): Simulated deformation (mm). """ # Elastic modulus (Pa) for steel (rigid material) E = 2e11 # 200 GPa (steel) # Handle plate and beam separately if simulation_type == "plate": # Calculate stress: Force applied over cross-sectional area stress = force / (length * width) if length * width > 0 else 0 # Calculate deformation: Axial deformation based on stress deformation = (stress / E) * thickness elif simulation_type == "beam": # Moment of inertia for a rectangular beam I = (width * thickness**3) / 12 # m^4 # Calculate deformation: Beam deflection under uniform load deformation = (load * (length / 1000)**3) / (8 * E * I) if length > 0 else 0 # Calculate stress: Load applied over the cross-sectional area stress = load / (width * thickness) if width * thickness > 0 else 0 else: raise ValueError("Invalid simulation type.") # Convert stress to MPa and deformation to mm stress_mpa = stress * 1e-6 deformation_mm = deformation * 1e3 # Convert from meters to millimeters return stress_mpa, deformation_mm