-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathold_plotter.py
More file actions
63 lines (53 loc) · 1.84 KB
/
old_plotter.py
File metadata and controls
63 lines (53 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import numpy as np
import plotly.graph_objects as go
import plotly.express as px
from modules.mesh_cube import Mesh as CubeMesh
from modules.mesh_bar import Mesh as BarMesh
from modules.mesh_box import Mesh as BoxMesh
from modules.assembly import Assembly
from modules.solver import Solver
mesh = BoxMesh()
x, y, z = mesh.get_nodes().T
i, j, k = mesh.get_triangles().T
mesh_data_without_displacements = go.Mesh3d(x=x, y=y, z=z, alphahull=5, opacity=0.2, color='cyan', i=i, j=j, k=k)
# Displacement figure
assembly = Assembly(mesh)
assembly.assemble_global_stiffness_matrix()
assembly.apply_boundary_conditions()
solver = Solver(assembly)
U = solver.solve()
U = assembly.solution_tensor_to_matrix(U)
mesh.set_displacements(U)
nx, ny, nz = mesh.get_displaced_nodes().T
mesh_data_with_displacements = go.Mesh3d(x=nx, y=ny, z=nz, alphahull=5, opacity=1, color='red', i=i, j=j, k=k)
# Boundary figure
boundary_points = []
force_points = []
for boundary in mesh.boundary_conditions:
node = mesh.get_nodes()[boundary[0]]
if boundary[4] == 0:
boundary_points.append(node)
else:
force_points.append(node)
boundary_points = np.array(boundary_points)
force_points = np.array(force_points)
bx, by, bz = boundary_points.T
boundary_data = go.Scatter3d(x=bx, y=by, z=bz, mode='markers', marker=dict(size=15, color='black'), name='Randbedingungen')
fx, fy, fz = force_points.T
force_data = go.Scatter3d(x=fx, y=fy, z=fz, mode='markers', marker=dict(size=15, color='red'), name='Externe Kräfte')
data = [
mesh_data_without_displacements,
boundary_data,
force_data,
mesh_data_with_displacements
]
fig = go.Figure(
data=data,
layout=go.Layout(
scene=dict(
aspectmode="data", # Keep aspect ratio based on data values
aspectratio=dict(x=1, y=1, z=1) # Adjust aspect ratio as needed
)
)
)
fig.show()