<jupyter_start><jupyter_text>03. Objects of arbitrary shape  Imports<jupyter_code>import fdtd
import numpy as np
import matplotlib.pyplot as plt
fdtd.set_backend("numpy")<jupyter_output><empty_output><jupyter_text>Grid Setup<jupyter_code>grid = fdtd.Grid(
    shape = (300, 300, 1), # 25um x 15um x 1 (grid_spacing) --> 2D FDTD
    grid_spacing = 1e-7,
    permittivity = 1,
)

grid[50:250, 50, 0] = fdtd.LineSource(
    period = 1550e-9 / (3e8), name="source"
)

grid[50:250, 250, 0] = fdtd.LineDetector(name="detector")

grid[0:10, :, :] = fdtd.PML(name="pml_xlow")
grid[-10:, :, :] = fdtd.PML(name="pml_xhigh")
grid[:, 0:10, :] = fdtd.PML(name="pml_ylow")
grid[:, -10:, :] = fdtd.PML(name="pml_yhigh")<jupyter_output><empty_output><jupyter_text>Circular Object<jupyter_code>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,1))
permittivity += circle_mask[:,:,None]*(refractive_index**2 - 1)
grid[170:270, 100:200, 0] = fdtd.Object(permittivity=permittivity, name="object")<jupyter_output><empty_output><jupyter_text>Run Simulation<jupyter_code>grid.run(total_time=500)<jupyter_output><empty_output><jupyter_text>Visualize Even though visualization of a circular object is not implemented (for now), one can clearly see the focussing.<jupyter_code>grid.visualize(z=0)
grid.object.inverse_permittivity.min()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16445066480055984, 'fraction_numerical': 0.0615815255423373, 'mean_word_length': 6.857142857142857, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '634745', 'license': 'MIT', 'n_tokens_mistral': 656, 'n_tokens_neox': 592, 'n_words': 99, 'path': 'examples/03-objects-of-arbitrary-shape.ipynb', 'repo_name': '0xDBFB7/fdtd-1', 'size': '1429'}