Skip to content

Commit

Permalink
Add time impulse plot
Browse files Browse the repository at this point in the history
  • Loading branch information
arturgower committed Sep 18, 2019
1 parent 7eef214 commit 16edae9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Binary file modified docs/src/assets/gap-time-diffraction.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 12 additions & 8 deletions docs/src/manual/plot.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,35 +74,39 @@ end
![](../assets/gap-diffraction.gif)

## Movie - Time impulse plane-wave - two gaps
Continuing from [Field - Harmonic two gaps](@ref), we can plot how an impulse plave-wave in time passes through two gaps. See [# Time response](@ref) for more details on the code used below.
Continuing from [Field - Harmonic two gaps](@ref), we can plot how an impulse plave-wave in time passes through two gaps. See [Time response](@ref) for more details on the code used below.

```julia
pyplot(size = (450,300))
ωs = LinRange(0.0,2.0,200)
ωs = LinRange(0.0,2.0,300)[2:end] # avoid using ω = 0

# We use a lower resolution (res = 50) as this is a heavier calculation
result = run(particles, source, region, ωs; res = 40)
result = run(particles, source, region, ωs; res = 50)

# Calculate time response over rect
t_max = real(rect.width / host_medium.c)
ts = LinRange(0.0,t_max,100)
impulse = GaussianImpulse(maximum(ωs)*0.8)
t_max = 0.75 .* real(region.width / host_medium.c)
ts = LinRange(0.0,t_max,75)
impulse = GaussianImpulse(maximum(ωs)*0.6)
timres = frequency_to_time(result; t_vec = ts, impulse = impulse)

maxc = round(10*maximum(field(timres)))/10
minc = round(10*minimum(field(timres)))/10

# timres = TimeSimulationResult(timres.field .+ max_c/100.0 , timres.x, timres.t)

ylims = (-region.height/2,region.height/2)
anim = @animate for t in ts
plot(timres,t,seriestype=:contour, clim = (minc, maxc), leg = false)
plot(timres,t,seriestype=:contour,
clim = (minc, maxc),
leg = false, ylims = ylims
)
plot!(particles)
plot!(frame = :none, title="", xlab="",ylab="")
end

# gif(anim,"gap-diffraction.gif", fps = 7)
```
![](../assets/gap-diffraction.gif)
![](../assets/gap-time-diffraction.gif)

## Movie - Harmonic from random particles

Expand Down

0 comments on commit 16edae9

Please sign in to comment.