flaport / fdtd

A 3D electromagnetic FDTD simulator written in Python with optional GPU support
https://fdtd.readthedocs.io
MIT License
455 stars 116 forks source link

Paraview exporting with pyEVTK #14

Open 0xDBFB7 opened 3 years ago

0xDBFB7 commented 3 years ago

When testing 3D geometries, it seemed pretty helpful to dump .vtk files with object and field grids. The pyEVTK lib makes this pretty clean, might perhaps be worth an optional dependency?

On the other hand, perhaps this is something best handled by user code...

flaport commented 3 years ago

I think this is something that fits pretty well in fdtd.visualize. It's indeed something that generally speaking can be useful to handle in user code too, but I think having a default way of visualizing in 3D is definitely something we need.

Feel free to open a PR for this, maybe just move the vtk related imports into the dump_to_vtk function to ensure this remains an optional dependency.

sofroniewn commented 3 years ago

I'd be happy to contribute an example showing how to integrate these simulations with napari a python multidimensional image viewer (note, I'm one of the maintainers of that package so am heavily biased!). We do 2D and 3D rendering, including timeseries, so should be able to cover the needs here. What's nice about the napari approach is I can be working on my simulations in a notebook and interacting with them in napari at the same time.

I've been using napari to visualize some of my own simulations, here's a 2D one with a lens :-)

https://user-images.githubusercontent.com/6531703/117239577-ec62a000-ade3-11eb-9c99-8d0eb35d377a.mov

flaport commented 3 years ago

Hey @sofroniewn , This is pretty cool! I would definitely like to see a PR for such an example 🙂

sofroniewn commented 3 years ago

Hey @sofroniewn , This is pretty cool! I would definitely like to see a PR for such an example 🙂

Great, I'll try and put this together into an example script when I get a chance!