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 epsilon colorbar for plot2D #2286

Open
joamatab opened this issue Oct 27, 2022 · 7 comments
Open

add epsilon colorbar for plot2D #2286

joamatab opened this issue Oct 27, 2022 · 7 comments

Comments

@joamatab
Copy link
Contributor

How could we add an epislon or refractive index colorbar for plot2D?

See for example the colorbars here
https://gdsfactory.github.io/gdsfactory/notebooks/plugins/tidy3d/00_tidy3d.html

Also we could improve Meeps' 3D visualization using trimesh?

https://gdsfactory.github.io/gdsfactory/notebooks/plugins/meep/001_meep_sparameters.html#Visualizing-the-3D-Geometry

@SkandanC
Copy link
Contributor

I have been attempting to create 3D scenes of 3D Sim objects. I have a nearly ready solution for this, I just need to work out how to make the cuboids representing the PML boundaries transparent in trimesh.

This is a known issue with trimesh, see: mikedh/trimesh#1372,

@SkandanC
Copy link
Contributor

Meep's current plot3D() function is broken, due to issues with mayavi.

Traceback (most recent call last):
  File "/home/skandanc/plot.py", line 14, in <module>
    sim.plot3D()
  File "/home/skandanc/miniconda3/lib/python3.9/site-packages/meep/simulation.py", line 4213, in plot3D
    return vis.plot3D(self)
  File "/home/skandanc/miniconda3/lib/python3.9/site-packages/meep/visualization.py", line 681, in plot3D
    from mayavi import mlab
  File "/home/skandanc/miniconda3/lib/python3.9/site-packages/mayavi/mlab.py", line 34, in <module>
    from .tools.helper_functions import contour3d, test_contour3d, \
  File "/home/skandanc/miniconda3/lib/python3.9/site-packages/mayavi/tools/helper_functions.py", line 16, in <module>
    from .modules import VectorsFactory, StreamlineFactory, GlyphFactory, \
  File "/home/skandanc/miniconda3/lib/python3.9/site-packages/mayavi/tools/modules.py", line 27, in <module>
    from .filters import new_class
  File "/home/skandanc/miniconda3/lib/python3.9/site-packages/mayavi/tools/filters.py", line 232, in <module>
    _make_functions(locals())
  File "/home/skandanc/miniconda3/lib/python3.9/site-packages/mayavi/tools/filters.py", line 218, in _make_functions
    klass = new_class(
  File "/home/skandanc/miniconda3/lib/python3.9/site-packages/mayavi/tools/filters.py", line 30, in new_class
    return new.classobj(name, bases, dict_)
AttributeError: module 'new' has no attribute 'classobj'

I managed to create a rudimentary 3D representation of the Simulation object using vispy. I need to add the source planes and monitor planes, and fine tune the looks. Sim object for an MMI1X2:

image

@thomasdorch
Copy link
Contributor

thomasdorch commented Oct 28, 2022

How about using pyvista for 3D plotting? I don't have much experience with it but it looks like it has support for opacity, plus it can import hdf files so it would integrate well with meep's default output file format.

Also I just put in a PR (#2289) for the colorbars so let me know how that works for you!

@SkandanC
Copy link
Contributor

image
Final version. The function can now also plot structures with different eps, each of which is given a different shade of grey. We can adopt @thomasdorch's new colorbar and add it to this scene as well.

@smartalecH
Copy link
Collaborator

Final version. The function can now also plot structures with different eps

@SkandanC hey, this is pretty cool!

@SkandanC
Copy link
Contributor

SkandanC commented Nov 3, 2022

Thank you! I think this could be useful to visualize the adjoint optimization simulation objects as well.

@SkandanC
Copy link
Contributor

@joamatab do you think this should be closed? Both the colorbars and 3d visualization PRs have been merged.

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

No branches or pull requests

4 participants