Closed GenB31415 closed 2 years ago
@GenB31415 I think you can modify the 03-objects-of-arbitrary-shape example into 3d to make the circle into a cylinder, like this:
grid = fdtd.Grid(shape = (300, 300, 100), ...)
...
refractive_index = 1.7
x = y = np.linspace(-1,1,100)
X, Y = np.meshgrid(x, y)
circle_mask = X**2 + Y**2 < 1
permittivity = np.ones((100,100,10,3)) + circle_mask[:,:,None,None]*(refractive_index**2 - 1)
grid[170:270, 100:200, 45:55] = fdtd.Object(permittivity=permittivity, name="object")
That should give a z-axis aligned cylinder with diameter 100 and height 10. There's nothing really special about a cylinder, it's just a stack of circles; the None,None
adds two extra size-1 axes (one for z and one for anisotropic permittivity), and numpy broadcasting makes a stack of the circle_mask along the extra axes to match the (100,100,10,3)
shape.
Indeed. stacking circles is the recommended way.
Hi @aizvorski @flaport Many thanks, this works. Is it possible by similar manner to create the the walled empty cylinder with the internal r1 and external r2 radiuses respectively? Thanks again.
Ideally this would be done by creating two overlapping Objects, however overlapping objects is currently not really supported. Alternatively you can change the grid.inverse_permittivity
array manually. First create the bigger cylinder directly into the grid.inverse_permittivity array, then create the smaller one.
Hi @flaport I've followed your comments in the attached files. In addition, I expanded the task a little. I usually prefer to study a 3D system, so.
Sorry, the number of sources is N=55 (not 1000)
Hey @GenB31415 , this looks cool! Can you add this to the examples folder and create a PR for this?
Hi @flaport, I have to add a cylinder aligned || z in 3D. There are various references in general how to create a cylinder. https://stackoverflow.com/questions/26989131/add-cylinder-to-plot https://stackoverflow.com/questions/64725784/color-of-the-cylinder-in-python
But what may be the optimal way to do that in fdtd? [03-objects-of-arbitrary-shape] Thank you in advance.