NanoComp / meep

free finite-difference time-domain (FDTD) software for electromagnetic simulations
GNU General Public License v2.0
1.17k stars 598 forks source link

Add label for geometrical object #2631

Closed Yaraslaut closed 9 months ago

Yaraslaut commented 10 months ago

Closes https://github.com/NanoComp/meep/issues/2614

PR adds labels for geometrical objects to show them on plots

Example

import meep as mp
import argparse
import matplotlib.pyplot as plt

resolution = 50   # pixels/um
lk = mp.Block(size=mp.Vector3(mp.inf,5.0,mp.inf), material=mp.Medium(epsilon=3.0), label="main block")
geometry = [blk]

for i in range(1,2):
    geometry.append(mp.Cylinder(0.2, center=mp.Vector3(2 * i), label = "right hole"))
    geometry.append(mp.Cylinder(0.2, center=mp.Vector3(-2 * i), label = "left hole"))

src = [mp.Source(mp.GaussianSource(1.0, fwidth=0.5),
                     component=mp.Ex,
                     center=mp.Vector3(0.0, -3.0,0.0),
                     size=mp.Vector3(5,0))]

sim = mp.Simulation(cell_size=mp.Vector3(10,10,0),
                    geometry=geometry,
                    boundary_layers= [mp.PML(1.0)],
                    sources= src,
                    resolution=resolution)

sim.run(until=0)
sim.plot2D(label_geometry=True,labels=True)
plt.show()

image

codecov-commenter commented 10 months ago

Codecov Report

Merging #2631 (4730bb5) into master (8d2fd8d) will decrease coverage by 0.11%. Report is 4 commits behind head on master. The diff coverage is 52.00%.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

@@            Coverage Diff             @@
##           master    #2631      +/-   ##
==========================================
- Coverage   73.81%   73.71%   -0.11%     
==========================================
  Files          18       18              
  Lines        5294     5318      +24     
==========================================
+ Hits         3908     3920      +12     
- Misses       1386     1398      +12     
Files Coverage Δ
python/geom.py 94.16% <100.00%> (+0.01%) :arrow_up:
python/simulation.py 77.06% <ø> (ø)
python/visualization.py 37.02% <47.82%> (+0.35%) :arrow_up:
Yaraslaut commented 9 months ago

Would you provide some examples which demonstrate this feature is working as intended?

See example in the PR description