Spaces:
Build error
Build error
File size: 595 Bytes
59b9a97 355fa4f 59b9a97 355fa4f 59b9a97 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import pyvista as pv
import matplotlib.pyplot as plt
def visualize_results(simulator, length, width, thickness, stress, deformation):
fig, ax = plt.subplots()
ax.bar(["Stress", "Deformation"], [stress, deformation], color=["red", "blue"])
ax.set_title(f"Results ({simulator})")
plt.savefig("results_2d.png")
plt.close(fig)
mesh = pv.Box(bounds=(0, length, 0, width, 0, thickness))
plotter = pv.Plotter(off_screen=True)
plotter.add_mesh(mesh, color="white", show_edges=True)
plotter.screenshot("results_3d.png")
return "results_2d.png", "results_3d.png"
|