Add plot1D function for visualizing layout of 1D simulation - #3271
Open
oskooi wants to merge 2 commits into
Open
Add plot1D function for visualizing layout of 1D simulation#3271oskooi wants to merge 2 commits into
plot1D function for visualizing layout of 1D simulation#3271oskooi wants to merge 2 commits into
Conversation
Collaborator
|
Rather than add a Python mirror of the boundary information, I'd rather just add a method to |
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Adds a
plot1Dfunction for visualizing the layout of 1D simulation. This mirrors the existingplot2D.PEC detection. A wall is PEC when the cell boundary is metallic — i.e. no
k_pointwas given (Meep's default) orset_boundary(..., mp.Metallic)was called. Sincefields.boundariesis only exposed to Python as an opaque SWIG pointer,Simulation.set_boundarynow records what it set inself._boundary_conditions(cleared byreset_meep), whichplot1Dconsults. This makes the tutorial setup inantenna_pec_ground_plane_1D.py(Blochk_point+ explicit metallic walls) plot correctly.Everything is customizable through the same
*_parametersdict /show_*flag convention asplot2D(index_parameters,pml_parameters,pec_parameters,source_parameters,monitor_parameters,legend_parameters), and the dispersive-permittivity frequency defaults to the first source's frequency (that lookup is now the sharedget_default_frequencyhelper, also used byplot_eps).An example of the output (involving a dielectric slab above a PEC ground plane) produced by
plot1Dis shown below.Files changed
python/visualization.py—plot1Dand itsplot_1d_*helpers, 1D default-parameter dictspython/simulation.py—Simulation.plot1Dwith full docstring; boundary-condition trackingpython/meep.i— exportplot1Dfrom the packagepython/tests/test_visualization.py—test_plot1Dcovering legend contents, artist counts, PEC vs. Bloch-periodic,Absorber,set_boundaryoverride, customization, and the non-1DValueErrordoc/docs/Python_User_Interface.md{, .in}— API docs (inserted exactly the blockgenerate_py_api.pyemits)Verification
python/tests/test_visualization.py: 3 tests pass, serially and undermpirun -np 2Absorber, Bloch-periodic, explicit metallic wall, extended sources, dispersive material (Si reads 3.478 at 1.55 μm), nonzerogeometry_center,dimensions=1and unset-dimensions1D cells