Skip to content

Commit

Permalink
fix broadcast check for sim results
Browse files Browse the repository at this point in the history
  • Loading branch information
arturgower committed Nov 30, 2023
1 parent 4eb9c4c commit 8c5b811
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docs/src/example/particles_in_circle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ big_result = run(big_particle_simulation, x, ωs)

#plot(result, lab = "scattering from particles")
#plot!(big_result,
# lab = "scattering from big particle",
# title="Compare scattered wave from one big particle, \n and a circle filled with small particles")
# lab = "scattering from big particle",
# title="Compare scattered wave from one big particle, \n and a circle filled with small particles")
```
![The response comparison](plot_response_compare.png)

1 change: 1 addition & 0 deletions src/physics/physical_medium.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ basisorder_to_basislength(::Type{P}, order::Int) where P <: PhysicalMedium{2,1}
basislength_to_basisorder(::Type{P},len::Int) where P <: PhysicalMedium{3,1} = Int(sqrt(len) - 1)
basislength_to_basisorder(::Type{P},len::Int) where P <: PhysicalMedium{2,1} = Int((len - 1) / 2.0)


function outgoing_radial_basis(medium::PhysicalMedium{2,1}, ω::T, order::Integer, r::T) where {T<:Number}
k = ω/medium.c
return hankelh1.(-order:order,k*r)
Expand Down
4 changes: 2 additions & 2 deletions src/result.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ function +(s::SimulationResult,a::Union{Complex{T},T})::SimulationResult where T
end

function +(s::SimulationResult,a)::SimulationResult
if typeof(s.field .+ a) != typeof(s.field)
if typeof(s.field[1] .+ a) != typeof(s.field[1])
error("Summing SimulationResult with $a would cause SimulationResult.field to change its type.")
end

return typeof(s)([f + a for f in s.field], s.x, getfield(s,3))
return typeof(s)([f .+ a for f in s.field], s.x, getfield(s,3))
end
+(a,s1::SimulationResult) = +(s1::SimulationResult,a)

Expand Down

0 comments on commit 8c5b811

Please sign in to comment.