Spaces:
Sleeping
Sleeping
Create simulators/pycalculix_simulation.py
Browse files
simulators/pycalculix_simulation.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from pycalculix import *
|
2 |
+
|
3 |
+
def run_pycalculix_simulation(simulation_type, **kwargs):
|
4 |
+
if simulation_type == "plate":
|
5 |
+
model = Model("pycalculix_plate")
|
6 |
+
model.set_units("mm")
|
7 |
+
part = Part("block", model)
|
8 |
+
part.make_box(0, kwargs["length"], 0, kwargs["width"], 0, kwargs["thickness"])
|
9 |
+
part.cut_cylinder(0, kwargs["hole_diameter"] / 2, 0, kwargs["hole_diameter"] / 2, kwargs["thickness"])
|
10 |
+
model.make_step_static(kwargs["force"])
|
11 |
+
elif simulation_type == "beam":
|
12 |
+
model = Model("pycalculix_beam")
|
13 |
+
model.set_units("mm")
|
14 |
+
part = Part("block", model)
|
15 |
+
part.make_box(0, kwargs["length"], 0, kwargs["width"], 0, kwargs["thickness"])
|
16 |
+
model.make_step_static(kwargs["load"])
|
17 |
+
|
18 |
+
model.run()
|
19 |
+
stress = model.results().max_stress()
|
20 |
+
deformation = model.results().max_displacement()
|
21 |
+
return stress, deformation
|