Plots a 2D cross section of the simulation domain using `matplotlib`. The plot includes the geometry, boundary layers, sources, and monitors. Fields can also be superimposed on a 2D slice. Requires [matplotlib](https://matplotlib.org). Calling this function would loo
(
self,
ax: Optional[Axes] = None,
output_plane: Optional[Volume] = None,
fields: Optional = None,
labels: bool = False,
label_geometry: bool = True,
eps_parameters: Optional[dict] = None,
boundary_parameters: Optional[dict] = None,
source_parameters: Optional[dict] = None,
monitor_parameters: Optional[dict] = None,
field_parameters: Optional[dict] = None,
colorbar_parameters: Optional[dict] = None,
frequency: Optional[float] = None,
show_epsilon: bool = True,
show_sources: bool = True,
show_monitors: bool = True,
show_boundary_layers: bool = True,
nb: bool = False,
**kwargs,
)
| 4796 | return self.get_array(mp.Sp, cmplx=not self.fields.is_real, snap=snap) |
| 4797 | |
| 4798 | def plot2D( |
| 4799 | self, |
| 4800 | ax: Optional[Axes] = None, |
| 4801 | output_plane: Optional[Volume] = None, |
| 4802 | fields: Optional = None, |
| 4803 | labels: bool = False, |
| 4804 | label_geometry: bool = True, |
| 4805 | eps_parameters: Optional[dict] = None, |
| 4806 | boundary_parameters: Optional[dict] = None, |
| 4807 | source_parameters: Optional[dict] = None, |
| 4808 | monitor_parameters: Optional[dict] = None, |
| 4809 | field_parameters: Optional[dict] = None, |
| 4810 | colorbar_parameters: Optional[dict] = None, |
| 4811 | frequency: Optional[float] = None, |
| 4812 | show_epsilon: bool = True, |
| 4813 | show_sources: bool = True, |
| 4814 | show_monitors: bool = True, |
| 4815 | show_boundary_layers: bool = True, |
| 4816 | nb: bool = False, |
| 4817 | **kwargs, |
| 4818 | ) -> None: |
| 4819 | """ |
| 4820 | Plots a 2D cross section of the simulation domain using `matplotlib`. The plot |
| 4821 | includes the geometry, boundary layers, sources, and monitors. Fields can also be |
| 4822 | superimposed on a 2D slice. Requires [matplotlib](https://matplotlib.org). Calling |
| 4823 | this function would look something like: |
| 4824 | |
| 4825 | ```py |
| 4826 | sim = mp.Simulation(...) |
| 4827 | sim.run(...) |
| 4828 | field_func = lambda x: 20*np.log10(np.abs(x)) |
| 4829 | import matplotlib.pyplot as plt |
| 4830 | sim.plot2D(fields=mp.Ez, |
| 4831 | field_parameters={'alpha':0.8, 'cmap':'RdBu', 'interpolation':'none', 'post_process':field_func}, |
| 4832 | boundary_parameters={'hatch':'o', 'linewidth':1.5, 'facecolor':'y', 'edgecolor':'b', 'alpha':0.3}) |
| 4833 | plt.show() |
| 4834 | plt.savefig('sim_domain.png') |
| 4835 | ``` |
| 4836 | If you just want to quickly visualize the simulation domain without the fields (i.e., when |
| 4837 | setting up your simulation), there is no need to invoke the `run` function prior to calling |
| 4838 | `plot2D`. Just define the `Simulation` object followed by any DFT monitors and then |
| 4839 | invoke `plot2D`. |
| 4840 | |
| 4841 | Note: When running a [parallel simulation](Parallel_Meep.md), the `plot2D` function expects |
| 4842 | to be called on all processes, but only generates a plot on the master process. |
| 4843 | |
| 4844 | **Parameters:** |
| 4845 | |
| 4846 | * `ax`: a `matplotlib` axis object. `plot2D()` will add plot objects, like lines, |
| 4847 | patches, and scatter plots, to this object. If no `ax` is supplied, then the |
| 4848 | routine will create a new figure and grab its axis. |
| 4849 | * `output_plane`: a `Volume` object that specifies the plane over which to plot. |
| 4850 | Must be 2D and a subset of the grid volume (i.e., it should not extend beyond |
| 4851 | the cell). |
| 4852 | * `fields`: the field component (`mp.Ex`, `mp.Ey`, `mp.Ez`, `mp.Hx`, `mp.Hy`, |
| 4853 | `mp.Hz`) to superimpose over the simulation geometry. Default is `None`, where |
| 4854 | no fields are superimposed. |
| 4855 | * `labels`: if `True`, then labels will appear over each of the simulation |
no outgoing calls
no test coverage detected