For future reference, it’s really difficult to debug something based on “it’s not working” and separate pieces of code that I don’t know how to stitch together. Please read: make it easier to help you.
One thing I see immediately is that the surface plot takes the arguments in the order x, y, Z
. But when I run your code, u_real
is all NaN
, so it’s probably not going to be a very pretty plot.
Here’s a rewrite from the math:
using Roots, Plots
B = 1
Λ_s = 0
N = 20
v(y, t; B, α, Λ_s) = (B*y + 1)/(B + 1) - 2*sum(α_k -> sin(α_k*(1-y))/(α_k*(1 + cos(α_k)^2/(B*(1-Λ_s*α_k^2)) + 2*B*Λ_s*sin(α_k)^2))*exp(-α_k^2*t), α)
f(x) = tan(x) + x/(B*(1-Λ_s*x^2))
α = zeros(N)
for k in 1:N
α[k] = find_zero(f, (nextfloat(π*(k-3//2)), prevfloat(π*(k-1//2))))
end
plot(α)
plot(range(0,2,100), range(0,1,100), (y,t)->v(y, t; B, α, Λ_s); seriestype=:surface)