-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from timcop/tests
Tests and bug fixes - Nice work Tim!
- Loading branch information
Showing
22 changed files
with
417 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,7 @@ | |
*.DS_Store | ||
docs/build/ | ||
Manifest.toml | ||
lcov.info | ||
.vscode/settings.json | ||
.vscode/* | ||
lcov.info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
using Coverage, Pkg | ||
# process '*.cov' files | ||
Pkg.test(; coverage=true) | ||
coverage = process_folder() # defaults to src/; alternatively, supply the folder name as argument | ||
LCOV.writefile("lcov.info", coverage) | ||
clean_folder("src") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,50 @@ | ||
function get_dipoles(xi,yi,n,nplus,Lx,Ly) | ||
|
||
if isempty(xi) || isempty(yi) | ||
@info "Input position vector is empty" | ||
xd = [] | ||
yd = [] | ||
is_dipole = [] | ||
num_found_in_dipoles = 0 | ||
return xd,yd,is_dipole,num_found_in_dipoles | ||
end | ||
if isempty(xi) || isempty(yi) | ||
@info "Input position vector is empty" | ||
xd = [] | ||
yd = [] | ||
is_dipole = [] | ||
num_found_in_dipoles = 0 | ||
return xd,yd,is_dipole,num_found_in_dipoles | ||
end | ||
|
||
κi = [ones(nplus); -ones(n-nplus)] | ||
κi = [ones(nplus); -ones(n-nplus)] | ||
|
||
# x and y distances | ||
xij,yij = distances(xi,yi) | ||
# x and y distances | ||
xij,yij = distances(xi,yi) | ||
|
||
# incorporate periodicity | ||
periodic_distances!(xij,yij,Lx,Ly) | ||
# incorporate periodicity | ||
periodic_distances!(xij,yij,Lx,Ly) | ||
|
||
# inter-vortex distance matrix, set self distance to much larger than box size | ||
rij = hypot.(xij,yij) | ||
rij += diagm(0=>1e6*hypot(Lx,Ly)*ones(n)) | ||
# inter-vortex distance matrix, set self distance to much larger than box size | ||
rij = hypot.(xij,yij) | ||
rij += diagm(0=>1e6*hypot(Lx,Ly)*ones(n)) | ||
|
||
# get index of minimum separations | ||
_, nn_index = findmin(rij,dims=2) | ||
# get index of minimum separations | ||
_, nn_index = findmin(rij,dims=2) | ||
|
||
nn_mat = ones(n)*collect(1:n)' .|> Int | ||
nn_vec = nn_mat[nn_index][:,1] | ||
nn_mat = ones(n)*collect(1:n)' .|> Int | ||
nn_vec = nn_mat[nn_index][:,1] | ||
|
||
mutuals = (collect(1:n) .== nn_vec[nn_vec]) | ||
mutuals = (collect(1:n) .== nn_vec[nn_vec]) | ||
|
||
# find dipoles | ||
is_dipole = zeros(n) | ||
for i in eachindex(mutuals) | ||
is_dipole[i] = (mutuals[i] == 1 && κi[i]*κi[nn_vec[i]] == -1.0) | ||
end | ||
# find dipoles | ||
is_dipole = zeros(n) | ||
for i in eachindex(mutuals) | ||
is_dipole[i] = (mutuals[i] == 1 && κi[i]*κi[nn_vec[i]] == -1.0) | ||
end | ||
|
||
dipoles_index = findall(is_dipole .> 0.0) | ||
dipoles_index2 = nn_vec[dipoles_index] | ||
num_found_in_dipoles = length(dipoles_index) | ||
dipoles_index = findall(is_dipole .> 0.0) | ||
dipoles_index2 = nn_vec[dipoles_index] | ||
num_found_in_dipoles = length(dipoles_index) | ||
|
||
xd = xi[dipoles_index] | ||
yd = yi[dipoles_index] | ||
xd2 = xi[dipoles_index2] | ||
yd2 = yi[dipoles_index2] | ||
xd = [xd[1:Int(end/2)]; xd2[1:Int(end/2)]] | ||
yd = [yd[1:Int(end/2)]; yd2[1:Int(end/2)]] | ||
xd = xi[dipoles_index] | ||
yd = yi[dipoles_index] | ||
xd2 = xi[dipoles_index2] | ||
yd2 = yi[dipoles_index2] | ||
xd = [xd[1:Int(end/2)]; xd2[1:Int(end/2)]] | ||
yd = [yd[1:Int(end/2)]; yd2[1:Int(end/2)]] | ||
|
||
return xd,yd,is_dipole,num_found_in_dipoles | ||
return xd,yd,is_dipole,num_found_in_dipoles | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using VortexDistributions | ||
|
||
## Basic unit testing for coverage | ||
@test scalar_ansatz(1) == scalar_ansatz(-1) | ||
f = Ansatz() | ||
x = LinRange(0, 10, 100) | ||
y = f.(x) | ||
@test length(y) == length(x) | ||
@test f.(3,4) == f(5) | ||
|
||
y, ψ, res = VortexDistributions.gpecore_exact(1,2,100) | ||
@test length(y) == 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using VortexDistributions | ||
|
||
# simple test field | ||
Nx = 400; Ny = 400 | ||
Lx = 200; Ly = Lx | ||
x = LinRange(-Lx/2,Lx/2, Nx+1)[1:end-1]; y = LinRange(-Ly/2,Ly/2, Ny+1)[1:end-1]; | ||
psi0 = one.(x*y') |> complex | ||
|
||
psi = Torus(copy(psi0), x, y); | ||
|
||
|
||
xp = 0.0 | ||
yp = 0.0 | ||
vp = PointVortex(xp,yp,1) | ||
sp = ScalarVortex(vp) | ||
|
||
vortex!(psi, sp) | ||
|
||
vfound = findvortices(psi) | ||
|
||
vortm = keep_vortices(vfound) | ||
|
||
@test length(vfound) == length(vortm) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
using VortexDistributions, Test | ||
|
||
|
||
# @testset "Multivortex creation and detection" begin | ||
@test found_near(30) | ||
# end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
using VortexDistributions, Test | ||
|
||
|
||
# @testset "Multivortex creation and detection" begin | ||
@test found_near(30, 10) | ||
# end |
Oops, something went wrong.