Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
paulxshen committed Feb 23, 2024
1 parent 7afcb2b commit c6af574
Show file tree
Hide file tree
Showing 50 changed files with 273 additions and 417 deletions.
Binary file not shown.
20 changes: 16 additions & 4 deletions examples/3d_dipole_antenna/[simulation]_3d_dipole_antenna.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ dir = pwd()
include("$(dir)/src/main.jl")
include("$dir/../FDTDToolkit.jl/src/main.jl")

dogpu = true
# dogpu = false

name = "3d_quarter_wavelength_antenna"
T = 8.0f0 # simulation duration in [periods]
nx = 16
Expand Down Expand Up @@ -37,17 +40,26 @@ p = apply(geometry_splits; ϵ, μ, σ, σm)
t = 0:dt:T
u = [[similar.(a) for a = u0] for t = t]
u[1] = u0
if dogpu# &&
using CUDA, Flux
@assert CUDA.functional()
u, p, t, field_padding, source_instances = gpu.((u, p, t, field_padding, source_instances))
end

@showtime reduce(
(u, (u1, t)) -> step!(u1, u, p, t, dx, dt, field_padding, source_instances),
zip(u[2:end], t[1:end-1]),
init=u0)
y = hcat([power.((m,), u) for m = monitor_instances]...)
zip(u[2:end], t[2:end]),
init=u[1])
y = [power.((m,), u) for m = monitor_instances]

if dogpu# &&
u, p, t, field_padding, source_instances = cpu.((u, p, t, field_padding, source_instances))
end
Ez = map(u) do u
u[1][3]
end
dir = @__DIR__
@showtime recordsim("$dir/$(name)_nres_$nx.mp4", Ez, y;
recordsim("$dir/$(name)_nres_$nx.mp4", collect.(Ez), collect.(y);
dt,
monitor_instances,
source_instances,
Expand Down
29 changes: 23 additions & 6 deletions examples/3d_periodic_scattering/3d_periodic_scattering.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ using UnPack, LinearAlgebra, GLMakie
# using FDTDEngine,FDTDToolkit
dir = pwd()
include("$(dir)/src/main.jl")
include("$(dir)/scripts/startup.jl")
include("$dir/../FDTDToolkit.jl/src/main.jl")

dogpu = true
# dogpu = false

name = "3d_scattering"
T = 8.0f0 # simulation duration in [periods]
Expand Down Expand Up @@ -46,20 +49,34 @@ p = apply(geometry_splits; ϵ, μ, σ, σm)
t = 0:dt:T
u = [[similar.(a) for a = u0] for t = t]
u[1] = u0
@showtime reduce(
(u, (u1, t)) -> step!(u1, u, p, t, dx, dt, field_padding, source_instances),
zip(u[2:end], t[1:end-1]),

if dogpu# &&
using CUDA, Flux
@assert CUDA.functional()
u, u0, p, t, field_padding, source_instances = gpu.((u, u0, p, t, field_padding, source_instances))
end

# @showtime reduce(
# (u, (u1, t)) -> step!(u1, u, p, t, dx, dt, field_padding, source_instances),
# zip(u[2:end], t[1:end-1]),
# init=u[1])
@showtime u = accumulate(
(u, t) -> step!(deepcopy(u), p, t, dx, dt, field_padding, source_instances),
t,
init=u0)
y = hcat([power.((m,), u) for m = monitor_instances]...)
y = [power.((m,), u) for m = monitor_instances]

# make movie
if dogpu# &&
u, p, t, field_padding, source_instances = cpu.((u, p, t, field_padding, source_instances))
end
Ez = map(u) do u
u[1][3]
end
ϵz = p[1][3]
dir = @__DIR__

recordsim("$dir/$(name)_nres_$nx.mp4", Ez, y;
# error()
recordsim("$dir/$(name)_nres_$nx.mp4", collect.(Ez), collect.(y);
dt,
monitor_instances,
source_instances,
Expand Down
Binary file modified examples/3d_periodic_scattering/3d_scattering_nres_16.mp4
Binary file not shown.

This file was deleted.

Loading

0 comments on commit c6af574

Please sign in to comment.