Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stackoverflow Error in plot of 3D data point #49913

Open
Movicmatics opened this issue May 22, 2023 · 0 comments
Open

Stackoverflow Error in plot of 3D data point #49913

Movicmatics opened this issue May 22, 2023 · 0 comments

Comments

@Movicmatics
Copy link

Hello everyone, I am trying to run my code but I am encountering an error, I would be glad if help can be render.
The Error mesage is:

`ERROR: StackOverflowError:
Stacktrace:
[1] RecipesPipeline.Volume(v::Array{Float64, 3}, x_extents::Array{Float64, 3}, y_extents::Array{Float64, 3}, z_extents::Tuple{Float64, Float64}) (repeats 65054 times)
@ RecipesPipeline C:\Users\morak.julia\packages\RecipesPipeline\BGM3l\src\utils.jl:109
[2] RecipesPipeline.Volume(v::Array{Float64, 3}, x_extents::Array{Float64, 3}, y_extents::Array{Float64, 3})
@ RecipesPipeline C:\Users\morak.julia\packages\RecipesPipeline\BGM3l\src\utils.jl:109
[3] macro expansion
@ C:\Users\morak.julia\packages\RecipesPipeline\BGM3l\src\user_recipe.jl:210 [inlined]
[4] apply_recipe(::AbstractDict{Symbol, Any}, ::AbstractArray{<:Union{Missing, Number}, 3}, ::Any, ::Any)
@ RecipesPipeline C:\Users\morak.julia\packages\RecipesBase\BRe07\src\RecipesBase.jl:300
[5] _process_userrecipes!(plt::Any, plotattributes::Any, args::Any)
@ RecipesPipeline C:\Users\morak.julia\packages\RecipesPipeline\BGM3l\src\user_recipe.jl:38
[6] recipe_pipeline!(plt::Any, plotattributes::Any, args::Any)
@ RecipesPipeline C:\Users\morak.julia\packages\RecipesPipeline\BGM3l\src\RecipesPipeline.jl:72
[7] _plot!(plt::Plots.Plot, plotattributes::Any, args::Any)
@ Plots C:\Users\morak.julia\packages\Plots\esM5q\src\plot.jl:223
[8] plot(::Any, ::Vararg{Any}; kw::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})
@ Plots C:\Users\morak.julia\packages\Plots\esM5q\src\plot.jl:102
[9] scatter(::Any, ::Vararg{Any}; kw::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})
@ Plots C:\Users\morak.julia\packages\RecipesBase\BRe07\src\RecipesBase.jl:427
[10] eval
@ .\boot.jl:370 [inlined]
[11] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base .\loading.jl:1864
[12] invokelatest(::Any, ::Any, ::Vararg{Any}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ Base .\essentials.jl:816
[13] invokelatest(::Any, ::Any, ::Vararg{Any})
@ Base .\essentials.jl:813
[14] inlineeval(m::Module, code::String, code_line::Int64, code_column::Int64, file::String; softscope::Bool)
@ VSCodeServer c:\Users\morak.vscode\extensions\julialang.language-julia-1.47.2\scripts\packages\VSCodeServer\src\eval.jl:233
[15] (::VSCodeServer.var"#66#70"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
@ VSCodeServer c:\Users\morak.vscode\extensions\julialang.language-julia-1.47.2\scripts\packages\VSCodeServer\src\eval.jl:157
[16] withpath(f::VSCodeServer.var"#66#70"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams}, path::String)
@ VSCodeServer c:\Users\morak.vscode\extensions\julialang.language-julia-1.47.2\scripts\packages\VSCodeServer\src\repl.jl:249
[17] (::VSCodeServer.var"#65#69"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
@ VSCodeServer c:\Users\morak.vscode\extensions\julialang.language-julia-1.47.2\scripts\packages\VSCodeServer\src\eval.jl:155
[18] hideprompt(f::VSCodeServer.var"#65#69"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})
@ VSCodeServer c:\Users\morak.vscode\extensions\julialang.language-julia-1.47.2\scripts\packages\VSCodeServer\src\repl.jl:38
[19] (::VSCodeServer.var"#64#68"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
@ VSCodeServer c:\Users\morak.vscode\extensions\julialang.language-julia-1.47.2\scripts\packages\VSCodeServer\src\eval.jl:126
[20] with_logstate(f::Function, logstate::Any)
@ Base.CoreLogging .\logging.jl:514
[21] with_logger
@ .\logging.jl:626 [inlined]
[22] (::VSCodeServer.var"#63#67"{VSCodeServer.ReplRunCodeRequestParams})()
@ VSCodeServer c:\Users\morak.vscode\extensions\julialang.language-julia-1.47.2\scripts\packages\VSCodeServer\src\eval.jl:225
[23] #invokelatest#2
@ .\essentials.jl:816 [inlined]
[24] invokelatest(::Any)
@ Base .\essentials.jl:813
[25] macro expansion
@ c:\Users\morak.vscode\extensions\julialang.language-julia-1.47.2\scripts\packages\VSCodeServer\src\eval.jl:34 [inlined]
[26] (::VSCodeServer.var"#61#62")()
@ VSCodeServer .\task.jl:514``

The code is :

using SpecialFunctions
using Plots
pythonplot() 
using QuadGK
using FastGaussQuadrature


# STEP 1 parameters, coordinate of X(n_1, n_2)
N_1 = 10
N_2 = 10
N_3 = 10
R_1 = 5
R_2 = 5
R_3 = 5
P = 10
N_phi = 45
N_r = 15
N_theta = 30
a_1 = 1
a_2 = 1.3
a_3 = 1.5

# Meshgrid
x_1 = range(-0.5 * R_1, stop = 0.5 * R_1, length = N_1)
x_2 = range(-0.5 * R_2, stop = 0.5 * R_2, length = N_2)
x_3 = range(-0.5 * R_3, stop = 0.5 * R_3, length = N_3)

X1 = similar(x_1, N_1, N_2, N_3)
X2 = similar(x_2, N_1, N_2, N_3)
X3 = similar(x_3, N_1, N_2, N_3)

for i in 1:N_1
    for j in 1:N_2
        for k in 1:N_3
            X1[i, j, k] = x_1[i]
            X2[i, j, k] = x_2[j]
            X3[i, j, k] = x_3[k]
        end
    end
end
#X1, X2, X3 = [collect(it) for it in Iterators.product(x_1, x_2, x_3)]
println("step 1 is done")

# STEP 2: Evaluate Rho at X(n_1, n_2, n_3), Beta, g(X)
B = 1 / a_1 + 1 / a_2 + 1 / a_3
g = zeros(N_1, N_2, N_3)
for i in 1:N_1
    for j in 1:N_2
        for k in 1:N_3
            g[i, j, k] = (x_1[i]^2 / a_1) + (x_2[j]^2 / a_2) + (x_3[k]^2 / a_3)
        end
    end
end


# Computation of Rho
Rho = (-2 * B .+ 4 * ((x_1 .^ 2) ./ a_1 .+ (x_2 .^ 2) ./ a_2 .+ (x_3 .^ 2) ./ a_3)) .* exp.(-g)
println("Step 2 is done")

# Transformation, Spherical grid plot
X_h, W_h = gauss(N_r)        # Nodes

r = 0.5 * P * (X_h .+ 1)   # transformation for node
w = 0.5 * P * W_h         # transformation for weight

K1 = zeros(N_phi, N_r, N_theta)
K2 = zeros(N_phi, N_r, N_theta)
K3 = zeros(N_phi, N_r, N_theta)

h_phi = 2 * π / N_phi       # step size in phi-direction
h_theta = π / N_theta       # step size in theta-direction

phi = range(0, stop=2 * π, length=N_phi)
theta = range(0, stop=π, length=N_theta)

cs = cos.(phi)
sn = sin.(phi)

for q in 1:N_r
    for t in 1:N_theta
        for p in 1:N_phi
            K1[p, q, t] = r[q] * cs[p] * sin(theta[t])
            K2[p, q, t] = r[q] * sn[p] * sin(theta[t])
            K3[p, q, t] = r[q] * cos(theta[t])
        end
    end
end

figk = scatter(K1, K2, K3, marker=:circle, color=:viridis, legend=false)
display(figk)```

![image](https://github.com/JuliaLang/julia/assets/100183174/3c9925ac-3b51-42e8-bb18-03d927fd58b2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant