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

3d detection algo #43

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
43 changes: 43 additions & 0 deletions examples/3d_detection/periodic_64_quench.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using FourierGPE
using VortexDistributions
using GraphMakie
using GLMakie


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

## params
t_idx = 27
psi = sol[t_idx]
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];

## Isosurface
density = abs2.(psi)
pmax = maximum(density)
density = density/pmax
xlims = (X[1][1], X[1][end])
ylims = (X[1][1], X[1][end])
zlims = (X[1][1], X[1][end])
volume(xlims, ylims, zlims, density, algorithm = :iso, transparency=true, alpha=0.2)

## Detection


@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
31 changes: 15 additions & 16 deletions src/VortexDistributions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,15 @@ using SparseArrays
using FFTW
using FileIO
using ProgressMeter
using LightGraphs
# using LightGraphs
using SimpleWeightedGraphs

# 3d deps
# using GLMakie
using ScikitLearn
using NearestNeighbors
using Distances
using FLoops
using FLoops, Graphs, Interpolations
using LinearAlgebra, Distributions, DSP # ccma

# using Colors


# import Plots:stroke,scatter!,plot,plot!
# plots
using GLMakie, GraphPlot, GraphMakie, Colors

const Λ = 0.8249

Expand Down Expand Up @@ -53,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 @@ -69,6 +66,11 @@ 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")
# include("seed_clusters.jl")
Expand All @@ -84,9 +86,6 @@ include("creation.jl")
# utils
include("utils.jl")

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

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

end
Loading
Loading