Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
paulxshen committed Dec 31, 2024
1 parent 00d63cb commit 3c17391
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/pic/run.jl
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function picrun(path; gpuarray=nothing, kw...)
frame = frame .>= 0.99maximum(frame)
# frame = nothing
start = round((bbox[1] - lb) / dl + 1)
b = Blob(szd; solid_frac=0.99, morph=false, lsolid=lsolid / dl, lvoid=lvoid / dl, symmetries, F, frame, start)
b = Blob(szd; solid_frac=0.99, lsolid=lsolid / dl, lvoid=lvoid / dl, symmetries, F, frame, start)
display(heatmap(b.frame))

if !isnothing(sol) && !restart
Expand Down Expand Up @@ -194,7 +194,6 @@ function picrun(path; gpuarray=nothing, kw...)
open(SOL_PATH, "w") do f
write(f, json(cpu(sol)))
end
println("Done in $(time() - t0) s (including compilation).")
elseif study == "inverse_design"
ENV["autodiff"] = "1"
if length(lb) == 3
Expand Down
10 changes: 7 additions & 3 deletions src/pictest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ include("main.jl")
ENV["JULIA_SSL_CA_ROOTS_PATH"] = ""
ENV["JULIA_PKG_PRECOMPILE_AUTO"] = 0

# using CUDA
using CUDA
# picrun(joinpath("runs", "straight");)# gpuarray=cu)
# picrun(joinpath("runs", "bend_R5"))
# picrun(joinpath("runs", "mode_converter"))
# picrun(joinpath("runs", "demux"))
picrun(joinpath("runs", "splitter"))


# picrun(joinpath("runs", "splitter"); gpuarray=cu)
# picrun(joinpath("runs", "splitter"))

# using CUDA
# picrun(joinpath("runs", "tiny"); gpuarray=cu)
picrun(joinpath("runs", "tiny"))#; gpuarray=cu)
models[1]()
9 changes: 8 additions & 1 deletion src/sim/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ function tidy(t, dt)
if round(t) > round(t - dt)
ENV["autodiff"] == "0" && println("simulation time = $t, took $(timepassed()) seconds")
end
if !haskey(ENV, "t0")
ENV["t0"] = time()
end
end

function f1(((u,), p, (dt, field_diffdeltas, field_diffpadvals, source_instances)), t)
Expand Down Expand Up @@ -49,7 +52,7 @@ function solve(prob, ;
init = (us0, p, (dt, field_diffdeltas, field_diffpadvals, source_instances))

ts = 0:dt:T[1]-F(0.001)
nt = -1
delete!(ENV, "t0")
if save_memory
(u,), = adjoint_reduce(f1, ts, init, ulims)
else
Expand Down Expand Up @@ -81,6 +84,10 @@ function solve(prob, ;
else
(u, mf), = reduce(f2, ts; init)
end

t0 = parse(Float64, ENV["t0"])
println("simulation done in $(time() - t0) s.")

# return sum(abs, mf[1][1].Ex + mf[1][1].Ey + mf[1][1].Hz)
ulims = 0
# @assert all([all(!isnan, a) for a = u])
Expand Down

0 comments on commit 3c17391

Please sign in to comment.