Couldn't process recipe args: (Array{Float64,2}, Array{Float64,2}, Array{Float64,2}, Array{Float64,2})

I am trying to learn Channel Flow with Navier-Stokes from this link
https://raw.githubusercontent.com/Wallace-dyfq/CFD-Julia-12-steps--o-Navier-Stokes-Equations/master/12-steps-cfd-julia.html.
I am getting error .
nx = 41;
ny = 41;
nt = 500;
nit=50;
c = 1;
dx = 2/(nx-1);
dy = 2/(ny-1);
x=range(0, stop=2, length=nx);
y=range(0, stop=2, length=ny);

rho = 1;
nu = .1;
dt = .001;

u = zeros((ny, nx));
v = zeros((ny, nx));
p = zeros((ny, nx)) ;
b = zeros((ny, nx));

function buildUpB(b, rho, dt, u, v, dx, dy)

b[2:end-1,2:end-1]=rho*(1/dt*((u[2:end-1,3:end]-u[2:end-1,1:end-2])/(2*dx)+(v[3:end,2:end-1]-v[1:end-2,2:end-1])/(2*dy))-
((u[2:end-1,3:end]-u[2:end-1,1:end-2])/(2*dx))^2-
2*((u[3:end,2:end-1]-u[1:end-2,2:end-1])/(2*dy)*(v[2:end-1,3:end]-v[2:end-1,1:end-2])/(2*dx))-
((v[3:end,2:end-1]-v[1:end-2,2:end-1])/(2*dy))^2);

return b;

end

function presPoisson(p, dx, dy, b)
pn = zeros(size§);
pn = copy§;

for q in 1:nit
    pn = copy(p);
    p[2:end-1,2:end-1] = ((pn[2:end-1,3:end]+pn[2:end-1,1:end-2])*dy^2+(pn[3:end,2:end-1]+pn[1:end-2,2:end-1])*dx^2)/
                    (2*(dx^2+dy^2)) -
    dx^2*dy^2/(2*(dx^2+dy^2))*b[2:end-1,2:end-1];

    p[:,end] .=p[:,end-1]; ##dp/dy = 0 at x = 2
    p[1,:] .= p[2,:];  ##dp/dy = 0 at y = 0
    p[:,1].=p[:,2];    ##dp/dx = 0 at x = 0
    p[end,:].=0  ;      ##p = 0 at y = 2
end        
return p;

end

function cavityFlow(nt, u, v, dt, dx, dy, p, rho, nu)
un = zeros(size(u));
vn = zeros(size(v));
b = zeros((ny, nx))

for n in 1:nt
    un = copy(u)
    vn = copy(v)

    b = buildUpB(b, rho, dt, u, v, dx, dy);
    p = presPoisson(p, dx, dy, b);

    u[2:end-1,2:end-1] = un[2:end-1,2:end-1]-
        un[2:end-1,2:end-1]*dt/dx*(un[2:end-1,2:end-1]-un[2:end-1,1:end-2])-
        vn[2:end-1,2:end-1]*dt/dy*(un[2:end-1,2:end-1]-un[1:end-2,2:end-1])-
        dt/(2*rho*dx)*(p[2:end-1,3:end]-p[2:end-1,1:end-2])+
    nu*(dt/dx^2*(un[2:end-1,3:end]-2*un[2:end-1,2:end-1]+un[2:end-1,1:end-2])+
    dt/dy^2*(un[3:end,2:end-1]-2*un[2:end-1,2:end-1]+un[1:end-2,2:end-1]))

    v[2:end-1,2:end-1] = vn[2:end-1,2:end-1]-
    un[2:end-1,2:end-1]*dt/dx*(vn[2:end-1,2:end-1]-vn[2:end-1,1:end-2])-
                    vn[2:end-1,2:end-1]*dt/dy*(vn[2:end-1,2:end-1]-vn[1:end-2,2:end-1])-
                    dt/(2*rho*dy)*(p[3:end,2:end-1]-p[1:end-2,2:end-1])+
                    nu*(dt/dx^2*(vn[2:end-1,3:end]-2*vn[2:end-1,2:end-1]+vn[2:end-1,1:end-2])+
    (dt/dy^2*(vn[3:end,2:end-1]-2*vn[2:end-1,2:end-1]+vn[1:end-2,2:end-1])))

    u[1,:] .= 0
    u[:,1] .= 0
    u[:,end] .= 0
    u[end,:] .= 1    #set velocity on cavity lid equal to 1
    v[1,:] .= 0
    v[end,:].=0
    v[:,1] .= 0
    v[:,end] .= 0

end
return u, v, p

end

u = zeros((ny, nx));
v = zeros((ny, nx));
p = zeros((ny, nx));
b = zeros((ny, nx));
nt = 100;
u, v, p = cavityFlow(nt, u, v, dt, dx, dy, p, rho, nu);
fig = figure(figsize=(11,7), dpi=100)
contourf(x,y,p,alpha=0.5) ###plnttong the pressure field as a contour

#contour(x,y,p)
###plotting the pressure field outlines
xgrid = repeat(x’, nx, 1 )
ygrid = repeat(y, 1, ny )
quiver(xgrid[1:2:end,1:2:end],ygrid[1:2:end,1:2:end],u[1:2:end,1:2:end],v[1:2:end,1:2:end])
ERROR: Couldn’t process recipe args: (Array{Float64,2}, Array{Float64,2}, Array{Float64,2}, Array{Float64,2})
Stacktrace:
[1] error(::String) at .\error.jl:33
[2] macro expansion at C:\Users\hafez.julia\packages\Plots\cc8wh\src\series.jl:299 [inlined]
[3] apply_recipe(::Dict{Symbol,Any}, ::Array{Float64,2}, ::Array{Float64,2}, ::Array{Float64,2}, ::Array{Float64,2}) at C:\Users\hafez.julia\packages\RecipesBase\G4s6f\src\RecipesBase.jl:279
[4] _process_userrecipes(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::NTuple{4,Array{Float64,2}}) at C:\Users\hafez.julia\packages\Plots\cc8wh\src\pipeline.jl:85
[5] _plot!(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::NTuple{4,Array{Float64,2}}) at C:\Users\hafez.julia\packages\Plots\cc8wh\src\plot.jl:178
[6] plot(::Array{Float64,2}, ::Vararg{Array{Float64,2},N} where N; kw::Base.Iterators.Pairs{Symbol,Symbol,Tuple{Symbol},NamedTuple{(:seriestype,),Tuple{Symbol}}}) at C:\Users\hafez.julia\packages\Plots\cc8wh\src\plot.jl:57
[7] quiver(::Array{Float64,2}, ::Vararg{Array{Float64,2},N} where N; kw::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\hafez.julia\packages\RecipesBase\G4s6f\src\RecipesBase.jl:393
[8] quiver(::Array{Float64,2}, ::Vararg{Array{Float64,2},N} where N) at C:\Users\hafez.julia\packages\RecipesBase\G4s6f\src\RecipesBase.jl:393
[9] top-level scope at none:0

Hi and welcome to the Julia Discourse! Please make sure to quote your code using triple backticks to make it easier to read, and try to reduce your problem down to the smallest possible bit of code required to reproduce your problem.

In this instance it seems that you’re issue is just a plotting problem in that you’re calling quiver with incorrect arguments. Here’s a StackOverflow answer that gives an example of how to use quiver.

2 Likes