I am getting error when runing code
function alfven_surface(N_r, N_theta, theta, v_r, v_theta, B_r, B_theta, rho, tracer)
"""
Given poloidal velocity field (vp) and poloidal magnetic field (bp), the function
calculates the Alfven surface. It is the surface for which vp = bp/sqrt{4*pi*rho}
"""
v_x = zeros(N_r, N_theta)
v_z = zeros(N_r, N_theta)
for i in 1:N_theta
v_x[:, i] .= v_r[:, i] .* sin(theta[i]) .+ v_theta[:, i] .* cos(theta[i])
v_z[:, i] .= v_r[:, i] .* cos(theta[i]) .- v_theta[:, i] .* sin(theta[i])
end
B_x = zeros(N_r, N_theta)
B_z = zeros(N_r, N_theta)
for i in 1:N_theta
B_x[:, i] .= B_r[:, i] .* sin(theta[i]) .+ B_theta[:, i] .* cos(theta[i])
B_z[:, i] .= B_r[:, i] .* cos(theta[i]) .- B_theta[:, i] .* sin(theta[i])
end
vp2 = zeros(N_r, N_theta)
bp2 = zeros(N_r, N_theta)
alfsurf = zeros(N_r, N_theta)
for i in 1:N_theta
vp2[:, i] .= v_x[:, i] .* v_x[:, i] .+ v_z[:, i] .* v_z[:, i]
bp2[:, i] .= B_x[:, i] .* B_x[:, i] .+ B_z[:, i] .* B_z[:, i]
alfsurf[:, i] .= 4.0 * π * rho[:, i] .* vp2[:, i] ./ bp2[:, i]
if any(alfsurf[:, i] .> 1.0) && any(tracer[:, i] .> 0.1)
alfsurf[:, i] .= 0.0
end
end
return alfsurf
end
alfsurf = zeros(N_files, N_r, N_theta);
for i in 1:N_files
alfsurf[i, :, :] = alfven_surface(N_r, N_theta, theta, v_r[i], v_theta[i], B_r[i], B_theta[i], rho[i], tracer[i])
end
Here N_r
=217 and N_theta
=100.
Size of v_r
, v_theta
, B_r
, B_theta
, rho
, tracer
are (1,217,100)
.