Skip to content

Commit

Permalink
fdtd import
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafacc committed Jun 6, 2024
1 parent 9dbb639 commit f5e1dce
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 21 deletions.
56 changes: 35 additions & 21 deletions examples/04_import_technology/04b_convergence_sbend.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def convergence_z_span(
tech=tech,
layout=layout,
in_port=0,
wavl_min=1.545,
wavl_max=1.555,
wavl_min=1.500,
wavl_max=1.600,
wavl_pts=51,
mode_index=[0,1],
num_modes=2,
Expand All @@ -44,7 +44,7 @@ def convergence_z_span(
# visualize the results
#sims[-1].visualize_results()

fig, ax = plt.subplots()
fig, ax1 = plt.subplots()
te_log = []
tm_log = []
s12_te = 'S12_idx00'
Expand All @@ -54,11 +54,17 @@ def convergence_z_span(
s_tm = sim.s_parameters.S[s12_tm].s
te_log.append(10*np.log10(np.abs(s_te[len(s_te) // 2])**2)) # middle
tm_log.append(10*np.log10(np.abs(s_tm[len(s_tm) // 2])**2)) # middle entry
ax.plot(z_span, te_log, 'x-', label="TE", color='r')
ax.plot(z_span, tm_log, 'x-', label="TM", color='b')
ax.legend()
ax.set_xlabel('z_span [um]')
ax.set_ylabel(f'Transmission [dB]')
ax1.plot(z_span, te_log, 'x-', label="TE", color='r')
ax1.set_xlabel('Z_span [um]')
ax1.set_ylabel(f'Transmission [dB]', color='r')

ax2 = ax1.twinx()
ax2.plot(z_span, tm_log, 'x-', label="TM", color='b')
ax2.set_ylabel(f'Transmission [dB]', color='b')

fig.tight_layout()
fig.legend()
fig.show()

return sims

Expand All @@ -77,8 +83,8 @@ def convergence_port_width(
tech=tech,
layout=layout,
in_port=0,
wavl_min=1.545,
wavl_max=1.555,
wavl_min=1.500,
wavl_max=1.600,
wavl_pts=51,
mode_index=[0,1],
num_modes=2,
Expand Down Expand Up @@ -133,8 +139,8 @@ def convergence_mesh(
tech=tech,
layout=layout,
in_port=0,
wavl_min=1.545,
wavl_max=1.555,
wavl_min=1.500,
wavl_max=1.600,
wavl_pts=51,
mode_index=[0,1],
num_modes=2,
Expand All @@ -154,7 +160,7 @@ def convergence_mesh(
# visualize the results
#sims[-1].visualize_results()

fig, ax = plt.subplots()
fig, ax1 = plt.subplots()
te_log = []
tm_log = []
s12_te = 'S12_idx00'
Expand All @@ -164,11 +170,17 @@ def convergence_mesh(
s_tm = sim.s_parameters.S[s12_tm].s
te_log.append(10*np.log10(np.abs(s_te[len(s_te) // 2])**2)) # middle
tm_log.append(10*np.log10(np.abs(s_tm[len(s_tm) // 2])**2)) # middle entry
ax.plot(mesh, te_log, 'x-', label="TE", color='r')
ax.plot(mesh, tm_log, 'x-', label="TM", color='b')
ax.legend()
ax.set_xlabel('Mesh [grid cells / wavl]')
ax.set_ylabel(f'Transmission [dB]')
ax1.plot(mesh, te_log, 'x-', label="TE", color='r')
ax1.set_xlabel('Mesh [grid cells / wavl]')
ax1.set_ylabel(f'Transmission [dB]', color='r')

ax2 = ax1.twinx()
ax2.plot(mesh, tm_log, 'x-', label="TM", color='b')
ax2.set_ylabel(f'Transmission [dB]', color='b')

fig.tight_layout()
fig.legend()
fig.show()

return sims

Expand All @@ -182,22 +194,24 @@ def convergence_mesh(

layout = gtd.lyprocessor.load_layout(file_gds)

"""
# log sampling space, i expect output transission to be log too..
z_span_sweep = convergence_z_span(
layout=layout,
tech=technology,
z_span=np.logspace(np.log10(0.221), np.log10(2), num=12),
z_span=np.logspace(np.log10(0.221), np.log10(4), num=14),
)

"""
port_width_sweep = convergence_port_width(
layout=layout,
tech=technology,
port_width=np.logspace(np.log10(0.51), np.log10(3), num=12),
)

"""
mesh_sweep = convergence_mesh(
layout=layout,
tech=technology,
mesh=np.linspace(6, 40, 20)
)
"""
# %%
27 changes: 27 additions & 0 deletions examples/07_lumerical/07b_fdtd_lumerical.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#%% send a component to a lumerical instance
import os
import lumapi
from gds_tidy3d.lum_tools import to_lumerical, setup_lum_fdtd
from gds_tidy3d.core import parse_yaml_tech
from gds_tidy3d.simprocessor import load_component_from_tech
from gds_tidy3d.lyprocessor import load_layout

os.environ['QT_QPA_PLATFORM'] = 'xcb' # i need to do this to get my lumerical gui to work in linux... comment out if not necessary

if __name__ == "__main__":
tech_path = os.path.join(os.path.dirname(__file__), "tech.yaml") # note materials definition format in yaml
technology = parse_yaml_tech(tech_path)

file_gds = os.path.join(os.path.dirname(__file__), "si_sin_escalator.gds")
layout = load_layout(file_gds)
component = load_component_from_tech(ly=layout, tech=technology)

fdtd = lumapi.FDTD() # can also be mode/device
print(type(fdtd))

to_lumerical(c=component, lum=fdtd)

#setup_lum_fdtd(c=component, lum=fdtd)

input('Proceed to terminate the GUI?')
# %%

0 comments on commit f5e1dce

Please sign in to comment.