Spaces:
Sleeping
Sleeping
File size: 1,040 Bytes
efee3b8 |
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 |
from pycalculix import *
def run_pycalculix_simulation(length, width, thickness, force):
"""
Executes a PyCalculix simulation.
Parameters:
length (float): Length of the plate/beam.
width (float): Width of the plate/beam.
thickness (float): Thickness of the plate/beam.
force (float): Applied force.
Returns:
tuple: (stress, deformation) from the simulation.
"""
# Create a PyCalculix model
model = Model("Plate")
part = model.make_rect(length, width)
# Apply material properties
mat = Material("Steel")
mat.set_mech_props(210e9, 0.3) # Elastic modulus (Pa) and Poisson's ratio
model.set_matl(part, mat)
# Apply boundary conditions
model.set_constr_bc(part.get_edge("LEFT"), 'ALL') # Clamped edge
model.set_force_bc(part.get_edge("RIGHT"), 'FY', force)
# Solve the model
model.run_sim()
# Extract results
stress = model.get_max_stress()
deformation = model.get_max_displacement()
return stress, deformation
|