-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_engine.py
More file actions
43 lines (37 loc) · 1.41 KB
/
Copy pathtest_engine.py
File metadata and controls
43 lines (37 loc) · 1.41 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
import sys
import os
import numpy as np
# Dynamically link the location paths
sys.path.append(os.path.abspath("."))
sys.path.append(os.path.abspath("./build"))
try:
import spatial_math_py as engine
print("[SUCCESS] Found spatial_math_py module.")
except ImportError as e:
print(f"[FAIL] Could not import engine core module: {e}")
print("Hint: Run ./setup.sh again to make sure compilation completed.")
sys.exit(1)
print("--- Initializing Volumetric Stress Test Loop ---")
nodes = []
# Create four nodes forming a solid 3D tetrahedron structure
coords = [[0.,0.,0.], [1.,0.,0.], [0.,1.,0.], [0.,0.,1.]]
for i, coord in enumerate(coords):
n = engine.MeshNode()
n.id = i
n.position = np.array(coord, dtype=np.float64)
n.rest_position = np.array(coord, dtype=np.float64)
n.force = np.zeros(3, dtype=np.float64)
n.von_mises_stress = 0.0
nodes.append(n)
element = engine.TetrahedronElement()
element.id = 0
element.node_indices = [0, 1, 2, 3] # Fixed broken line assignment
element.material_youngs = 2.1e11
element.material_poisson = 0.3
solver = engine.StressSolver()
print("Applying structural stretch manipulation to Node 1...")
solver.apply_external_stretch(1, np.array([0.05, 0.0, 0.0]), nodes)
solver.update_mesh_stress(nodes, [element])
print("\n--- Simulation Results Matrix ---")
for node in nodes:
print(f"Node ID {node.id} | Stress Scalar: {node.von_mises_stress:.4e} Pa")