Spaces:
Build error
Build error
| from pycalculix import * | |
| def run_pycalculix_simulation(simulation_type, **kwargs): | |
| if simulation_type == "plate": | |
| model = Model("pycalculix_plate") | |
| model.set_units("mm") | |
| part = Part("block", model) | |
| part.make_box(0, kwargs["length"], 0, kwargs["width"], 0, kwargs["thickness"]) | |
| part.cut_cylinder(0, kwargs["hole_diameter"] / 2, 0, kwargs["hole_diameter"] / 2, kwargs["thickness"]) | |
| model.make_step_static(kwargs["force"]) | |
| elif simulation_type == "beam": | |
| model = Model("pycalculix_beam") | |
| model.set_units("mm") | |
| part = Part("block", model) | |
| part.make_box(0, kwargs["length"], 0, kwargs["width"], 0, kwargs["thickness"]) | |
| model.make_step_static(kwargs["load"]) | |
| model.run() | |
| stress = model.results().max_stress() | |
| deformation = model.results().max_displacement() | |
| return stress, deformation | |