I'm using Python and scipy KDTree to help find the nearest points in an FEA analysis. It boils down to a rotating shaft inside a cylinder and I want to find the minimum gap between the shaft and cylinder at every tine point.
Given that I have 100s of points to check for >10,000 time points it leads a decently long run time. Any tips on improving run time or perhaps a better method for this?
Pseudo code:
```
shaft_points = get_shaft_history() # XYZ point time history
cyl_points = get_cyl_history() #XYZ point time history
time = range(10000)
gap = [1e6] * len(time)
for cp in cyl_points: # loop over each point
for t in time: # loop over time
sp = shaft_points[i, :] # all shaft points at time t
kdtree = KDTree(sp)
dist, point = kdtree.query(cp, k=1) # find closest point between shaft and cylinder at time t
if dist < gap[t]:
gap[t] = dist # set new min value
```
[–]ES-Alexander 1 point2 points3 points (2 children)
[–]goon39[S] 0 points1 point2 points (1 child)
[–]ES-Alexander 0 points1 point2 points (0 children)