-
Notifications
You must be signed in to change notification settings - Fork 4
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 #15 from bblankrot/dev
Weekly PR #4
- Loading branch information
Showing
12 changed files
with
83 additions
and
174 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
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
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
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
@testset "multipole" begin | ||
#let's check that rotation works properly | ||
k0 = 0.1 | ||
kin = 100k0 | ||
λ0 = 2π/k0 | ||
θ_i = 0.0 | ||
|
||
N = 1000 | ||
P = 5 | ||
shapes = [squircle(2π/λ0, N)] | ||
centers = [-1.5λ0 0; 1.5λ0 0] | ||
Ns = size(centers,1) | ||
φs = [0.0; 0.23] | ||
ids = ones(Int, Ns) | ||
sp = ScatteringProblem(shapes, ids, centers, φs) | ||
points = λ0*[5 0; -2 3] | ||
|
||
verify_min_distance(shapes, centers, ids, points) | ||
β1, σ1 = solve_particle_scattering(k0, kin, P, sp, θ_i; | ||
get_inner = true, verbose = false) | ||
Ez1 = scattered_field_multipole(k0, β1, centers, points) | ||
|
||
#now rotate everything by some angle and compare | ||
θ_r = 1.23#2π*rand() | ||
#notation is transposed due to structure of centers | ||
shapes2 = [squircle(2π/λ0, N); CircleParams(15)] #for extra code coverage | ||
centers2 = centers*([cos(θ_r) -sin(θ_r); sin(θ_r) cos(θ_r)].') | ||
φs2 = θ_r + φs | ||
sp2 = ScatteringProblem(shapes2, ids, centers2, φs2) | ||
points2 = points*([cos(θ_r) -sin(θ_r); sin(θ_r) cos(θ_r)].') | ||
|
||
β2, σ2 = solve_particle_scattering(k0, kin, P, sp2, θ_i + θ_r; | ||
get_inner = true, verbose = true) | ||
Ez2 = scattered_field_multipole(k0, β2, centers2, points2) | ||
|
||
@test Ez1 ≈ Ez2 | ||
β2_r = copy(β2) | ||
for ic = 1:Ns, p = -P:P | ||
β2_r[(ic-1)*(2P+1) + p + P + 1] *= exp(1.0im*θ_r*p) | ||
end | ||
@test β1 ≈ β2_r | ||
@test σ1 ≈ σ2 | ||
end | ||
|
||
@testset "circle" begin | ||
k0 = 1 | ||
kin = 0.1 | ||
R = 0.2 | ||
P = 10 | ||
S, gamma = ParticleScattering.circleScatteringMatrix(k0, kin, R, P; gamma = true) | ||
center = [0 2R] | ||
points = center .+ [0 0.5R; 0.1R -0.2R] | ||
E1 = ParticleScattering.innerFieldCircle(kin, gamma, center[1,:], points) | ||
E2 = ParticleScattering.innerFieldCircle(kin, gamma, center[1,:], points[1,:]) | ||
@test E1[1] == E2 | ||
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 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,13 @@ | ||
@testset "utilities" begin | ||
s = rounded_star(1, 0.1, 7, 100) | ||
@test ParticleScattering.pInPolygon([0.0 0.0], s.ft) | ||
@test !ParticleScattering.pInPolygon([0.84 0.35], s.ft) | ||
@test ParticleScattering.pInPolygon([0.84 0.35], s.ft+0.1) | ||
|
||
sp = ScatteringProblem([s],[1],[0.1 0.1], [15π]) | ||
border = find_border(sp) | ||
border2 = find_border(sp,[0.1 0.1]) | ||
@test border == border2 | ||
border3 = find_border(sp,[0.1 0.9999]) | ||
@test border != border3 | ||
end |