-
Notifications
You must be signed in to change notification settings - Fork 626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Instantiation of geometries from GDSII files #357
Conversation
…ents in periodic geometries
…ckness_dft_array_output
…ckness_dft_array_output
…mpty dimensions; updated python/tests/dft_fields.py unit test to test collapsing of zero-thickness dimensions in DFT arrays and HDF5 output
…try descriptions using libGDSII //.i#
…illustrate GDSII-based geometry descriptions using libGDSII
* update docs * fixes * tweaks * more fixes * more tweaks * fix unicode literals for Python 2
* Update docs for get_eigenmode_coefficients * Update Mode_Decomposition.md Answered some questions posed by @ChristopherHogan. * Add eig_vol description to python get_eigenmode_coefficients
* Added Si3N4 (common material for photonics) * Added Si3N4 * Changed Si3N4 names, added frequency ranges * Fix index * Relabel Si3N4, add additional data from K. Luke
* update mode-decomposition tutorial and other fixes to docs * minor tweaks
* set initial-guess k vector to bloch vector for get_eigenmode_coefficients in periodic geometries * updates to periodic get_eigenmode_coefficient * pulled changes from master * updates * updates * updates * fixed core-dump issue in HDF5 output for DFT fields on volumes with empty dimensions; updated python/tests/dft_fields.py unit test to test collapsing of zero-thickness dimensions in DFT arrays and HDF5 output * tried but failed to fix freezing when calling output_dft for volumes with zero-thickness dimensions * fixed subtlety involving disagreement among processors regarding the number of DFT frequencies, causing freezes in the multiprocessor case for HDF5 output of dft fields * use integer-valued version of max_to_all instead of double-valued version with integer casts
libmeepgeom/GDSIIgeom.cpp
Outdated
// If Text==NULL, find any polygon on the given layer. | ||
// If Layer==-1, search all layers. | ||
// If multiple matching polygons are found, choose one arbitrarily. | ||
dVec get_polygon(char *GDSIIFile, char *Text, int Layer=-1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
char*
arguments should be const char*
if the string isn't modified (otherwise C++ doesn't like you passing literal strings these days)
Needs a rebase — it seems like this PR has commits from the zero-thickness DFT slice branch? |
* Warn if Source is outside Harminv frequency range * Do opposite check with Harminv and sources
* Fix bug with coeffs size in get_eigenmode_coefficients * Clarify get_eigenmode_coefficients return array size
…some function prototypes
Needs another rebase for conflict resolution. |
I deleted my entire repository, re-cloned your master branch, and merged the GDSII updates into that. I hope this addressed the issues. If not, maybe you could recommend a git command or two that would clean things up? |
Looks good, thanks. |
@HomerReid: Here's the workflow I use that seems to prevent these types of issues. In my local fork, I have two remotes:
$ git remote -v
origin [email protected]:ChristopherHogan/meep.git (fetch)
origin [email protected]:ChristopherHogan/meep.git (push)
upstream https://github.com/stevengj/meep.git (fetch)
upstream https://github.com/stevengj/meep.git (push) Whenever there are new changes in the main repo, I sync them with my fork as follows: git checkout master
# Fetch the changes from the main repo
git fetch upstream
# Merge the upstream changes to master into my local master branch
git merge upstream/master
# Push those changes to my forked remote master
git push origin master That's the only kind of merge I ever do. If a PR has a merge conflict, or if I need a feature from master that's not on my local branch, then I rebase my working branch on the HEAD of master. # After updating master as above
git checkout branch_I_am_working_on
git rebase master
git push -f origin branch_I_am_working_on This keeps all my commits nice and clean with no extraneous changes. The only time this doesn't work is when I am working on a branch that's based off another branch that hasn't been merged yet. For example, I have feature git checkout A
git checkout -b B Now I have something like this
Now let's say
Now I need to rebase git checkout master
git checkout -b new_B
git cherry-pick sha_for_commits_on_B
git push origin new_B Now I can delete
|
A simpler alternative is to not maintain a forked master branch at all. Just have (1) Then the workflow is to periodically git checkout master
git pull origin master # sync master with upstream
git checkout myfeature
git rebase master # rebase myfeature onto master
git push me +myfeature # forced push to your myfeature branch When you start working on a new PR, do: git checkout master
git pull origin master # sync master with upstream before starting
git checkout -b newfeature # create and checkout new branch
...add commits...
git push me newfeature Here, |
@ChristopherHogan, thanks a lot for taking the time to put together a detailed tutorial. I'm long overdue to modernize my protocols. I will study these approaches and finally learn how to do it right. |
Initial stab at defining geometries from GDSII files.
Update
configure.ac
to look forlibGDSII
, distributed for now as a separate standalone package.Add new source file
libmeepgeom/GDSIIgeom.cpp
implementing simple routines for defining meep geometries from GDSII files. If compiling without libGDSII, these routines all default to stubs that exit with error messages, like what happens insrc/mpb.cpp
if compiled without MPB.Updated
libmeepgeom/bend-flux-ll.cpp
code to allow optional definition of the bend-flux geometry from a GDSII file, specified on the command line with the--GDSIIFile
option.Instantiating the bend-flux geometry from a GDSII file
The
libGDSII
source distribution comes with a GDSII geometry file calledbend-flux.gds
. (After a successfullibGDSII
installation to prefix$(prefix)
, this file will be installed on your system in the directory$(prefix)/share/libGDSII/examples/bend-flux/
). Here's a screenshot of what this file looks like in the wonderful open-source layout editor KLayout:Note that this simple geometry contains multiple layers, with just one polygon per layer:
The idea is to build up the meep geometry one element at a time by referencing individual layers in the GDSII file. The new source file
libmeepgeom/GDSIIgeom.cpp
includes several routines to facilitate this:grid_volume set_geometry_from_GDSII(double resolution, char *GDSIIFile, int GDSIILayer, double zsize=0.0);
geometric_object get_GDSII_prism(material_type material, char *GDSIIFile, int GDSIILayer, double zmin=0, double zmax=0);
meep::volume
from a polygon on a given layer in the GDSIIFile:volume get_GDSII_volume(char *GDSIIFile, int GDSIILayer, double zsize=0);
The updated
libmeepgeom/bend-flux-ll.cpp
uses these primitives to define the bend-flux geometry (with either the straight or bent waveguides) and to definemeep::volume
s that are later used to add sources and flux regions to the simulation:I have verified that running
bend-flux-ll
with--HDF5File bend-flux.gds
yields the same results as running with--use-prism
, which creates the prism and other geometric elements by hand.Specifying polygons by text instead of (or in addition to) layer
In the example above, the GDSII file contains just one polygon on each layer, and we specify which polygon we want by simply specifying the index of the layer. More generally, users may want to select one of multiple polygons defined on the same layer.
libGDSII
already includes a mechanism to do this: Tag the polygon you want by adding a GDSII text string with reference point lying inside the polygon (for example, in the above screenshot, the computational-cell polygon contains the stringGeometry
). Then instead of the above you could say e.g.grid_volume gv=meep_geom::set_geometry_from_GDSII(resolution, GDSIIFile, "Geometry")
This way multiple polygons can coexist on a single layer and we specify which one we want by tagging with appropriate labels.