Spaces:
Sleeping
Sleeping
File size: 897 Bytes
3a9d766 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
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
|