Skip to content
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

fix bug in plot_boundaries of plot2D #2079

Merged
merged 1 commit into from
May 24, 2022
Merged

Conversation

oskooi
Copy link
Collaborator

@oskooi oskooi commented May 21, 2022

Fixes #2022.

Currently, the plot_boundaries subroutine of plot2D produces the incorrect output when the output_plane parameter passed to plot2D defines an area which does not include the PML boundaries. This can be demonstrated using the examples/oblique-planewave.py. The output region defined by output_plane does not include the PMLs but they incorrectly appear in the wrong location in the output.

Also includes some general formatting tweaks to visualization.py to improve readability.

cell_size = mp.Vector3(14,10,0)

pml_layers = [mp.PML(thickness=2,direction=mp.X)]

nonpml_vol = mp.Volume(center=mp.Vector3(), size=mp.Vector3(10,10,0))

sim.plot2D(fields=mp.Ez,
           output_plane=nonpml_vol)

pw_bug

With this PR, the output does not include the PML boundaries in the x direction.
pw

cc @hammy4815

@oskooi oskooi added the bug label May 21, 2022
@oskooi oskooi requested a review from smartalecH May 21, 2022 23:10
@stevengj
Copy link
Collaborator

Does it work correctly if the output_plane partially intersects the PML?

@codecov-commenter
Copy link

Codecov Report

Merging #2079 (2928e64) into master (5275f43) will decrease coverage by 0.14%.
The diff coverage is 68.75%.

@@            Coverage Diff             @@
##           master    #2079      +/-   ##
==========================================
- Coverage   73.25%   73.11%   -0.15%     
==========================================
  Files          17       17              
  Lines        4902     4895       -7     
==========================================
- Hits         3591     3579      -12     
- Misses       1311     1316       +5     
Impacted Files Coverage Δ
python/visualization.py 43.47% <68.75%> (-1.61%) ⬇️

@oskooi
Copy link
Collaborator Author

oskooi commented May 22, 2022

Does it work correctly if the output_plane partially intersects the PML?

Yes, it works correctly in this case as well. Here is a demonstration based on the example above with a PML thickness of 2.0. The output_plane only intersects the PML over a distance of 1.0 on each side in the x direction.

nonpml_vol = mp.Volume(center=mp.Vector3(),
                       size=mp.Vector3(12,10,0))
sim.plot2D(fields=mp.Ez,
           output_plane=nonpml_vol)

pw_partial_overlap

For comparison, here is the output using the master branch (5275f43). The PML thickness incorrectly appears as 2.0.

pw_bug_partial

@stevengj stevengj merged commit 5546204 into NanoComp:master May 24, 2022
@oskooi oskooi deleted the plot2D_pml branch May 24, 2022 02:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3D simulation 2D visualization PML bug
3 participants