-
Notifications
You must be signed in to change notification settings - Fork 104
Unexpected Results in Fish Swimming Simulation #204
Copy link
Copy link
Closed
Description
WaterLily performs so fast and fantastic CFD simulation! However, I've recently encountered some issues which really confused me:
I'm conducting a similar fluid dynamics analysis on a custom fish based on your dogfish shark blog.
I designed a fish with a less streamlined shape and defined a body wave motion similar to that of natural fish. The vortex patterns look reasonable, but when I calculated the forces acting on the fish body, the data appeared quite strange—the waveform differs significantly from what was shown in your blog.
I'm quite puzzled by this. If the vortex patterns are stable, why aren't the forces on the fish body showing periodicity?
Thank you very much for your time!
using WaterLily, StaticArrays, DataInterpolations, Plots
x = [0.0, 0.047, 0.118, 0.158, 0.16, 0.31, 0.46, 0.485, 0.53, 0.58, 0.63, 0.73, 0.82, 0.84, 0.868, 0.89, 0.92, 0.947, 0.97, 1.0]
width = [0.013, 0.084, 0.124, 0.138, 0.139, 0.15, 0.139, 0.13, 0.116, 0.098, 0.082, 0.058, 0.04, 0.033, 0.0185, 0.0106, 0.01, 0.009, 0.0085, 0.0074]
thk = CubicSpline(x, width)
xx = [0, 0.1137, 0.454, 1]
envelop = [0.549,0.265,0.235,1.0]
amp = CubicSpline(xx, envelop)
function fish(n=2^6;Re=1e5,mem=Array,U=1)
L = 2n
ν = U*L/Re
k = 2π
ω = 4π .* U ./ L
function s(x)
return clamp(x[1]./L, 0.0, 1.0)
end
function sdf(x,t)
return √sum(abs2, x .- SVector(L .* s(x), 0)) .- L .* thk(s(x))
end
function map(x, t)
xc = x .- SVector(L, 3L/2) # shift origin
return xc .- SVector(0., 0.1 .* L .* amp(s(xc)) .* cos(ω.*t .- k .* s(xc)))
end
body = AutoBody(sdf, map)
# make the fish simulation
return Simulation((4L,3L),(U,0),L;ν,body,T=Float32,mem)
end
swimmer = fish();
period = 2π / 4π;
cycle = range(0, 47/24*period, length=48)
sim_step!(swimmer, 2, remeasure=true)
forces = [get_force(swimmer, t) for t ∈ sim_time(swimmer) .+ cycle]
scatter(cycle./period, [first.(forces), last.(forces)],
labels=permutedims(["thrust", "side"]),
xlabel="scaled time",
ylabel="scaled force",
)
function plot_vorticity(sim)
σ = zeros(size(sim.flow.σ))
@inside sim.flow.σ[I] = WaterLily.curl(3, I, sim.flow.u) * sim.L / sim.U
copyto!(σ,sim.flow.σ)
contourf(σ', color=palette(:Blues), clims=(-10, 10), linewidth=0, aspect_ratio=:equal, legend=false, border=:none)
end
@gif for t ∈ sim_time(swimmer) .+ cycle
sim_step!(swimmer, t, remeasure=true)
plot_vorticity(swimmer)
end
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels

