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

Add label for geometrical object #2631

Merged
merged 4 commits into from
Oct 11, 2023
Merged

Add label for geometrical object #2631

merged 4 commits into from
Oct 11, 2023

Conversation

Yaraslaut
Copy link
Contributor

@Yaraslaut Yaraslaut commented Sep 8, 2023

Closes #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
Copy link

codecov-commenter commented Sep 8, 2023

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%.

❗ 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%) ⬆️
python/simulation.py 77.06% <ø> (ø)
python/visualization.py 37.02% <47.82%> (+0.35%) ⬆️

python/visualization.py Outdated Show resolved Hide resolved
python/simulation.py Outdated Show resolved Hide resolved
@Yaraslaut Yaraslaut marked this pull request as ready for review September 10, 2023 15:32
@Yaraslaut Yaraslaut requested a review from stevengj September 14, 2023 12:51
Copy link
Collaborator

@oskooi oskooi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

python/visualization.py Show resolved Hide resolved
@Yaraslaut
Copy link
Contributor Author

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

See example in the PR description

@Yaraslaut Yaraslaut requested a review from oskooi October 11, 2023 16:30
Copy link
Collaborator

@oskooi oskooi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@oskooi oskooi merged commit 261a3f5 into NanoComp:master Oct 11, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Plot labels for geometric objects
4 participants