Skip to content

Commit

Permalink
Detection functions, minimum working example, some plotting functions
Browse files Browse the repository at this point in the history
  • Loading branch information
timcop committed Dec 16, 2024
1 parent 16c28ee commit 9ab5a99
Show file tree
Hide file tree
Showing 9 changed files with 2,385 additions and 155 deletions.
2,357 changes: 2,218 additions & 139 deletions Manifest.toml

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@ authors = ["Ashton Bradley <[email protected]>"]
version = "0.3.6"

[deps]
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
Coverage = "a2441757-f6aa-5fb2-8edb-039e3f45d037"
DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2"
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
FLoops = "cc61a311-1640-44b5-9fba-1b764f453329"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
FourierGPE = "f013a474-557c-11e9-3596-438edcad9d97"
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
GraphMakie = "1ecd5474-83a3-4783-bb4f-06765db800d2"
GraphPlot = "a2cc645c-3eea-5389-862e-a155d0052231"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
NearestNeighbors = "b8a86587-4115-5ab1-83bc-aa920d37bbce"
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
Expand All @@ -31,7 +38,6 @@ FLoops = "~0.2"
FileIO = "1, 1.8, 1.9"
Interpolations = "~0.15"
JLD2 = "~0.4"
LightGraphs = "1, 1.3"
NearestNeighbors = "~0.4"
Parameters = "~0.12"
ProgressMeter = "1, 1.5, 1.6, 1.7"
Expand Down
39 changes: 39 additions & 0 deletions examples/3d_detection/periodic_128_quench.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using FourierGPE
using VortexDistributions
using GraphMakie


## Load sim
@load "sim64.jld2" sim
@load "sol64.jld2" sol

## Isosurface plot of the solution

t_idx = 25

psi = sol[t_idx]
density = abs2.(psi)
pmax = maximum(density)
density = density/pmax

# volume(density, algorithm = :iso)

## Get params for detection
X = sim.X;
x = X[1]; y = X[2]; z = X[3];
x = round.(x, digits=3); y = round.(y, digits=3); z = round.(z, digits=3);
dx = x[2] - x[1]; dy = y[2] - y[1]; dz = z[2] - z[1];

@time g, vort_lines, vort_loops, vort_rings, vorts_coords = full_algorithm(psi, x, y, z, n_itp = 4);
graphplot(g, layout = (adj) -> vorts_coords, markersize=0.02, edge_width=1, node_size=5)

## Smoothing

vort_lines_coords = [reduce(vcat, transpose.(vorts_coords[v_line])) for v_line in vort_lines];
vort_loops_coords = [reduce(vcat, transpose.(vorts_coords[v_loop])) for v_loop in vort_loops];
vort_rings_coords = [reduce(vcat, transpose.(vorts_coords[v_ring])) for v_ring in vort_rings];

@time vort_lines_ccma_j, vort_loops_ccma_j, vort_rings_ccma_j = vortex_ccma_j(vort_lines_coords, vort_loops_coords, vort_rings_coords, w_ma = 6, w_cc = 3, distrib = "hanning");

graphplot(g, layout = (adj) -> vorts_coords, markersize=0.02, edge_width=0, node_size=5)
plot_unconnected_vorts_mat(vort_lines_ccma_j, vort_loops_ccma_j, vort_rings_ccma_j, linewidth=5)
34 changes: 34 additions & 0 deletions examples/3d_detection/periodic_64_quench_sim.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using FourierGPE
using VortexDistributions

## Creating a 3D simulation

L=(16.,16.,16.);
N=(64,64,64);
sim = Sim(L,N);
@unpack_Sim sim;

μ = 25.0;
γ = 0.05;
tf = 4/γ;
Nt = 50;
t = LinRange(0.,tf,Nt);

## Run sim
x,y,z = X;
ψi = randn(N)+im*randn(N);
ϕi = kspace(ψi,sim);

@pack_Sim! sim;

## Evolve in k-space
# import FourierGPE
@time sol = runsim(sim); # will take a few minutes to run.

# Mutate the solution to xspace before saving to jld2
for i in eachindex(sol)
sol[i] = xspace(sol[i], sim)
end

@save "sol64.jld2" sol
@save "sim64.jld2" sim
23 changes: 14 additions & 9 deletions src/VortexDistributions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ using SparseArrays
using FFTW
using FileIO
using ProgressMeter
using LightGraphs
# using LightGraphs
using SimpleWeightedGraphs

# 3d deps
using FLoops, Graphs, Interpolations
using LinearAlgebra, Distributions, DSP # ccma

using FLoops

# plots
using GLMakie, GraphPlot, GraphMakie, Colors

const Λ = 0.8249

Expand Down Expand Up @@ -46,9 +48,11 @@ charge, xpos, ypos, pos,

# 3d functions

find_vortex_points_3d, connect_vortex_points_3d, sort_classified_vorts_3d
# , vortInBounds, vortInBounds2, vortInBounds3
# plot_iso, scatterVortsOnIso, plot_line, scatterClassifiedVortices, periodicPlotting, euclid, vorts3DMatri
full_algorithm, vortex_ccma_j,

# plotting
plot_unconnected_vorts_mat


# RCA
# distances, periodic_distances, sparse_distances,
Expand All @@ -62,6 +66,10 @@ include("pointvortex.jl")
include("detection.jl")
include("creation.jl")

# 3d
include("detection_3d.jl")
include("ccma.jl")
include("plotting.jl")

# RCA
# include("get_dipoles.jl")
Expand All @@ -78,9 +86,6 @@ include("creation.jl")
# utils
include("utils.jl")

# 3d utils
include("utils_3d.jl")

@load joinpath(@__DIR__,"cores.jld2") ψi ψa

end
2 changes: 0 additions & 2 deletions src/ccma.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using LinearAlgebra, Distributions, DSP

# Auxiliary Functions
function get_unit_vector(vec)
vec_norm = norm(vec)
Expand Down
15 changes: 13 additions & 2 deletions src/detection_3d.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using FLoops, Graphs, Interpolations

function link_graph_vorts(g; repeat_end_of_ring=true)
g_temp = deepcopy(g)
visited = Set()
Expand Down Expand Up @@ -170,6 +168,19 @@ function connect_vortex_ends(vorts, vort_lines, vort_loops, vort_rings, X)
return connected_vorts
end

function findvortices_jumps_plane(phase)
# phase = angle.(ψ);

Δϕx, Δϕy = phase_jumps(phase,1),phase_jumps(phase,2)

circshift!(phase,Δϕx,(0,1))
Δϕx .-= phase; Δϕx .-= Δϕy
circshift!(phase,Δϕy,(1,0))
Δϕx .+= phase

return abs.(Δϕx)
end

function findvortices_planes_threaded(ψ; n_itr = 1)

ϕ = angle.(ψ)
Expand Down
58 changes: 58 additions & 0 deletions src/plotting.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
function plot_unconnected_vorts_mat(vort_lines, vort_loops, vort_rings; linewidth=5)
colors = distinguishable_colors(length(vort_lines) + length(vort_loops) + length(vort_rings));

all_vorts = []
all_colors = []

for i in eachindex(vort_lines)
for j in 1:size(vort_lines[i])[1]
v_sort = vort_lines[i][j, :]
push!(all_vorts, (v_sort[1], v_sort[2], v_sort[3]))
push!(all_colors, colors[i])
end
push!(all_vorts, (NaN, NaN, NaN))
push!(all_colors, colors[i])
end

# for i in eachindex(vort_loops)
# for j in eachindex(vort_loops[i])
# v_sort = vort_loops[i][j]
# push!(all_vorts, (v_sort[1], v_sort[2], v_sort[3]))
# push!(all_colors, colors[i + length(vort_lines)])
# end
# push!(all_vorts, (NaN, NaN, NaN))
# push!(all_colors, colors[i + length(vort_lines)])
# end

for i in eachindex(vort_loops)
for j in 1:size(vort_loops[i])[1]
v_sort = vort_loops[i][j, :]
push!(all_vorts, (v_sort[1], v_sort[2], v_sort[3]))
push!(all_colors, colors[i + length(vort_lines)])
end
push!(all_vorts, (NaN, NaN, NaN))
push!(all_colors, colors[i + length(vort_lines)])
end

# for i in eachindex(vort_rings)
# for j in eachindex(vort_rings[i])
# v_sort = vort_rings[i][j]
# push!(all_vorts, (v_sort[1], v_sort[2], v_sort[3]))
# push!(all_colors, colors[i + length(vort_lines) + length(vort_loops)])
# end
# push!(all_vorts, (NaN, NaN, NaN))
# push!(all_colors, colors[i + length(vort_lines) + length(vort_loops)])
# end

for i in eachindex(vort_rings)
for j in 1:size(vort_rings[i])[1]
v_sort = vort_rings[i][j, :]
push!(all_vorts, (v_sort[1], v_sort[2], v_sort[3]))
push!(all_colors, colors[i + length(vort_lines) + length(vort_loops)])
end
push!(all_vorts, (NaN, NaN, NaN))
push!(all_colors, colors[i + length(vort_lines) + length(vort_loops)])
end

lines!(all_vorts, color=all_colors, linewidth=linewidth)
end
2 changes: 1 addition & 1 deletion src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ end

mutable struct Cluster <: VortexGroup
vortices::Array{PointVortex,1}
tree::Array{LightGraphs.SimpleGraphs.SimpleEdge{Int64},1}
tree::Array{Graphs.SimpleGraphs.SimpleEdge{Int64},1}
end
Cluster(vort::Array{PointVortex,1}) = Cluster(vort,spanning_tree(xpos(vort),ypos(vort)))

0 comments on commit 9ab5a99

Please sign in to comment.