If I run the following example for composite material properties it results in a NaN-filled compliance matrix. I've taken this straight from the docs, only changing the airfoil coordinates. (Proposed solution below)
I traced it to line 492 of afmesh.jl. There, yiu and yil are searched to find their intersection. Because the nodes don't match up exactly (I'm presuming this is the reason), the values are not compared to each other but rather to the value of zero. In the example, this works great. Below I've plotted yiu (blue) and yil (red), and sure enough they intersect when both surfaces cross zero.
But in my example, this isn't the case (see below). In fact, my second point in yil happens to be barely positive. An easy workaround for that is to limit the possible range to the back half or so of the surface. But even then, the intersection doesn't match up with where they cross zero...
I have an idea on how to get around this - I don't know if this would impact the rest of the code much, but I think it does what the current version is trying to do. The idea is to search backwards from the TE, as it appears that in both cases the nodes match up with each other (i.e. node 40 on top is approximately lined up with node 40 on the bottom, etc.), so instead of comparing both sets of nodes against zero you could compare to each other, such as
# index from the end for both top and bottom
idx_intersection_from_TE = findlast(xt->xt<0, (reverse(yiu[end-20:end]) .- reverse(yil[end-20:end])))
# Note: need to specify a specific range so the number of elements is the same - instead of 20 it could
# be half of the total length of one of them, I don't think it really matters as long as it's long enough
# to include the intersection
# since they have different lengths, compute the index from the start separately for both surfaces
iu = length(yiu) - idx_intersection_from_TE + 1
il = length(yil) - idx_intersection_from_TE + 1
This might be overkill or perhaps not robust to every case, but it at least works for these two scenarios.
If I run the following example for composite material properties it results in a NaN-filled compliance matrix. I've taken this straight from the docs, only changing the airfoil coordinates. (Proposed solution below)
I traced it to line
492
ofafmesh.jl
. There,yiu
andyil
are searched to find their intersection. Because the nodes don't match up exactly (I'm presuming this is the reason), the values are not compared to each other but rather to the value of zero. In the example, this works great. Below I've plottedyiu
(blue) andyil
(red), and sure enough they intersect when both surfaces cross zero.But in my example, this isn't the case (see below). In fact, my second point in
yil
happens to be barely positive. An easy workaround for that is to limit the possible range to the back half or so of the surface. But even then, the intersection doesn't match up with where they cross zero...I have an idea on how to get around this - I don't know if this would impact the rest of the code much, but I think it does what the current version is trying to do. The idea is to search backwards from the TE, as it appears that in both cases the nodes match up with each other (i.e. node 40 on top is approximately lined up with node 40 on the bottom, etc.), so instead of comparing both sets of nodes against zero you could compare to each other, such as
This might be overkill or perhaps not robust to every case, but it at least works for these two scenarios.
Thoughts @andrewning?