smartalech / meep_adjoint_simple Goto Github PK
View Code? Open in Web Editor NEWSimple adjoint variable method for meep that works out of the box.
License: GNU General Public License v2.0
Simple adjoint variable method for meep that works out of the box.
License: GNU General Public License v2.0
This is a simplified version of Homer's adjoint variable method. Homer's current version has several great features, but the core functionality still seems slightly buggy. Specifically, the adjoint gradients don't match the finite difference approximates. I've stripped the extra features, and am focusing on objective functions that only have eigenmode coefficient features (q). A test script for the current version is examples/check_gradients.py
, which simulates a simple waveguide crossing with the following geometry:
The design region is the center square (with both blue and green hashes). It's parameterized using a first-degree continuous Galerkin finite element basis (implemented in fenics). It uses just two triangles, which corresponds to just 4 nodes/design variables. This makes calculating the finite-difference gradient relatively easy (compared to having hundreds of partials to choose from).
There is an eigenmode source (red line) and various eigenmode monitors to optimize over. The script currently optimizes abs(P1_north)**2 where P1_north corresponds to the forward propagating mode coefficient from the north monitor.
Unfortunately, the adjoint gradient still doesn't match the finite difference approximate. I'm assuming the issue has to do with the source/fields scaling.
I've slightly modified Homer's implementation. The resulting procedure is as follows:
I think the issue is with the scaling of the adjoint sources (or fields, depending on which you want to do). I'm scaling the adjoint source with the following:
scale factor = - ∂J/∂q / (2.0*ω).
(from Homer's code)
where ω is meep's ω (i.e. no 2π).
Potential values that need correction/normalization:
Any ideas?
A common task with practical inverse design is to "filter" the design region with a gaussian kernel so that the resulting geometry is smoothed. This is one of many ways to implement a minimum feature size constraint.
Accomplishing this with meep's user interface seems tricky. While material functions make it easy to "continuously" modify the permittivity profile of a geometry with position, it only accesses one point at a time. Consequently, functions like filters (or any other integrating function) can't be used because they require feedback/feedforward terms.
One solution could leverage a special material function that provides the user with an array of all the points it plans to fill. The user can then supply an array with the post-processed values corresponding to these points. This is similar to the user_file feature, but without the interpolation (which would defeat the whole purpose). Maybe there's an easy fix that I'm missing?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.