Closed tiagovla closed 3 years ago
No, when adding an object to the grid, the inverse_permittivity at the location of the object is set to zero:
https://github.com/flaport/fdtd/blob/73afcb8403aa64193a042680aa0e5dd13d62dae1/fdtd/objects.py#L86
This means that effectively, only the second update equation is used at the location of the object.
Hi flaport,
In that sense, wasn't it better if the method _register_grid
in object.py
set the permittivity of the object directly in the grid. Repeating calculations can be critical when the simulation size is bigger.
That's a fair point and in fact nothing is stopping you to do exactly that... Just do an in-place index replacement within inverse_epsilon...
The reason that I chose the Object route is that back in the day I was working on simulating photo-refractive crystals in which I was also modeling the electro-optic effect. Moreover those objects required non-diagonal epsilon elements which is a much more expensive update. Going the object-route allowed me to just have those expensive update equations in a localized component and still use the quick update equations everywhere else in the grid.
That said, for normal use cases a replacement in the grid is a much better approach and I agree we should probably make that the default.
Here you update E for the whole grid. Then you update E inside the objects, changing E in-place, locally.
Aren't you doing it twice?