Spaces:
Paused
Paused
File size: 1,797 Bytes
b280a54 bd68c65 b280a54 bd68c65 b280a54 bd68c65 b280a54 bd68c65 b280a54 bd68c65 b280a54 bd68c65 b280a54 bd68c65 b280a54 bd68c65 b280a54 bd68c65 | 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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | 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
|