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