[pre-ANN] Differentiable FDTD for inverse design in photonics, acoustics and RF

3d works now :slight_smile: We even did (attempted) 3d inverse design of a silicon photonics signal splitter - it’s converging though the low resolution (for saving time) produced artifacts. Below are 3d scattering and antenna simulations. Previous 1d/2d code broke but will be fixed later

We also reduced malloc without messing up autodiff by using Zygote.Buffer and renamed to FDTDEngine until we find a better name :smiley:

If you’re running 3d simulations feel free to try. Follow the quickstart in docs
If you’re doing inverse design then it’s more complicated since geometry generation and FOM are problem specific. Message me for starter scripts.

We’ll clean up repo and tighten up the inverse design scripts for silicon photonics and RF metamaterials in the coming weeks


11 Likes

Could this simulate arbitrary strip-line antenna geometry and calculate far-field complex polarization responses for arbitrary frequencies and angle of arrivals?

Yes I can add such a postprocessing feature - just need to fft the monitor surfaces and do a far field integration. Or just far field integrate the approximate current distribution on the strip without FDTD. I can make either adjoint differentiable. Feel free to PM me.

Added GPU support, forward and adjoint. Improved API for monitors, modal sources… Did inverse design of a simple 3d signal splitter in silicon photonics

3 Likes

Would it make sense to move this package to JuliaPhysics?

There is also a couple of other wave/optics packages

1 Like

Sweet! Can you link to the file which produced this? Edit - found it

1 Like

Cool - fOr other folks that file is at FDTDEngine.jl/examples/inverse_design_signal_splitter/inverse_design_signal_splitter.jl at master · paulxshen/FDTDEngine.jl · GitHub
sorry missed couple installation issues - fixed now - that example should run

1 Like

Still prerelease but pushed updates:

  • spherical monitor for nearfield radiation pattern (see antenna example)
  • documentation for tutorials
  • inverse design example now does a 2D TE adjoint optimization first as a fast approximation (3D adjoint optimization has stability issues requiring a low Courant #)
  • bug fixes
7 Likes

Update: we’re working with gdsfactory on a python api for photonics IC sim and inverse design. will be ready in a month.

@pxshen So you are you wrapping this package in Python?

Only a specialized wrapper, in same style as gdsfactory gplugin for meep. Workflow is to create IC layout in gdsfactory and call plugin for sparams or inverse design.

1 Like

Here’s a working draft of the python api gdsfactory plugin for photonics. Can get sparams or do inverse design in just few lines of code. LMK of your thoughts :slight_smile:

Great work! I’m trying to install the packages based on the tutorial and running into compatibility issues. Do you have the version info for the julia installation and packages you currently have working? Or any tips on addressing the compatibility issues?

Thanks! Sorry don’t have everything in a Project.toml but everything is latest . I used Julia 10.4 . Is GLMakie failing? What’s error msg?

With the goal of following the tutorial, I’m attempting to install the packages in the " ]add " line.

GLMakie imports fine (has some warnings, but appears to be importing)

I just installed julia today (version 1.4.1).

These are the package versions I have (from checking “status” in the julia console):

BSON v0.3.9
CoordinateTransformations v0.6.3
DataStructures v0.17.20
FileIO v1.16.3
Flux v0.10.4
Functors v0.2.8
GLMakie v0.4.2
ImageTransformations v0.8.13
Images v0.24.1
JSON v0.21.4
Lazy v0.15.1
StatsBase v0.33.21
UnPack v1.0.2
Zygote v0.4.22
Dates


These are the packages that fail:

Meshes
GPUArraysCore
Jello (add https://github.com/paulxshen/Jello.jl)
ArrayPadding
AbbreviatedStackTraces


The all appear to have a similar error:

restricted by julia compatibility requirements to versions: uninstalled — no versions left.

All that said, this may be an error in how I’m setting things up or an issue outside of the scope of this project, but in case it’s an issue other users might encounter, I wanted to put it on your radar.

Ok. Mostly resolved. Installed julia by “curl” directly from julialang.org. Version matches now. The rest of the installation works well. …until GLMakie

ERROR: LoadError: GLFWError (API_UNAVAILABLE): EGL: Failed to get EGL display: Success

Is there a way around this?
(For context, this is on WSL w/ Ubuntu)

Yeah GLMakie (3D plot) is known to fail in many cases eg headless servers. I’ll make a fallback to a 2D plot in tonight’s update to catch GLMakie failures.

pushed - just update the py frontend - also install CairoMakie on Julia. lmk if it works now :slight_smile:

1 Like

Thanks!

I updated the front end, installed CairoMakie (and Uninstalled GLMakie), and also installed Porcupine (not listed in the packages, but it seems like the first example script in the tutorial needs it). The first script runs with this error:

ERROR: LoadError: UndefVarError: heatmap not defined

for

File “/home/blah/blah/python3.11/site-packages/luminescent/gplugins/luminescent/sol.py”, line 73, in write_sparams

Let me know if you need more context.

That’s a plotting error - I pushed again - try pip update now

1 Like