flexcompute / tidy3d

Fast electromagnetic solver (FDTD) at scale.
https://docs.flexcompute.com/projects/tidy3d/en/latest/
GNU Lesser General Public License v2.1
190 stars 44 forks source link

2D simulations #229

Closed joamatab closed 2 years ago

joamatab commented 2 years ago

How can we define 2D simulations for grating coupler and PIC planar structures?

I've been trying to speed benchmark lumerical and meep grating coupler simulations this is what I get on Meep/lumerical for a 2D grating coupler simulation I want to study the X and fiber angle missalignment tolerances

I've successfully simulated a 3D grating, However that simulation takes a bit of time and takes 1.9GB of data! image

by looking at the 2D ring example https://docs.simulation.cloud/projects/tidy3d/en/latest/notebooks/RingResonator.html I can see that you need to make sim_size = [dx, dy, 1/resolution] for Simulation

However when i implement that on a just a straight planar waveguide I get non-realistic Sparameters, see this file

image

momchil-flex commented 2 years ago

I've successfully simulated a 3D grating, However that simulation takes a bit of time and takes 1.9GB of data!

Why does this generate a lot of data? If you only store e.g. the mode amplitudes in a mode monitor, or the flux, it should be very little data. I guess you wanted to look at fields too?

To your main question, yeah, generally just sim_size = [Lx, Ly, 1/resolution] should work for 2D. Perhaps something else was not set up well in the simulation - could you share the json file that produced the "wrong" S parameters?

joamatab commented 2 years ago

Thank you Momchil,

for the 3D grating I can try without the fields to see if things speed up for the 2D waveguide the S12 of this waveguide should be around 0dB and i get around 10dB

here is the sim.json

{"center": [0.0, 0.0, 0.0], "type": "Simulation", "size": [12.0, 2.5, 0.02], "grid_size": [0.02, 0.02, 0.02], "medium": {"name": null, "frequency_range": null, "type": "Medium", "permittivity": 1.0, "conductivity": 0.0}, "run_time": 1.0340486931104608e-11, "symmetry": [0, 0, 0], "structures": [{"geometry": {"center": [0.0, 0.0, 0.0], "type": "Box", "size": [1.0000000200408773e+20, 1.0000000200408773e+20, 1.0000000200408773e+20]}, "medium": {"name": null, "frequency_range": null, "type": "Medium", "permittivity": 2.0736, "conductivity": 0.0}, "name": null, "type": "Structure"}, {"geometry": {"center": [-7.0, 2.4054832200211723e-16, 0.11], "type": "PolySlab", "axis": 2, "length": 0.22, "slab_bounds": [0.0, 0.22], "vertices": [[-5.0, 0.25], [-9.0, 0.2500000000000005], [-9.0, -0.2499999999999995], [-5.0, -0.25]]}, "medium": {"name": null, "frequency_range": null, "type": "Medium", "permittivity": 12.0409, "conductivity": 0.0}, "name": null, "type": "Structure"}, {"geometry": {"center": [7.0, -0.0, 0.11], "type": "PolySlab", "axis": 2, "length": 0.22, "slab_bounds": [0.0, 0.22], "vertices": [[5.0, -0.25], [9.0, -0.25], [9.0, 0.25], [5.0, 0.25]]}, "medium": {"name": null, "frequency_range": null, "type": "Medium", "permittivity": 12.0409, "conductivity": 0.0}, "name": null, "type": "Structure"}, {"geometry": {"center": [-0.0, -0.0, 0.11], "type": "PolySlab", "axis": 2, "length": 0.22, "slab_bounds": [0.0, 0.22], "vertices": [[-5.0, -0.25], [5.0, -0.25], [5.0, 0.25], [-5.0, 0.25]]}, "medium": {"name": null, "frequency_range": null, "type": "Medium", "permittivity": 12.0409, "conductivity": 0.0}, "name": null, "type": "Structure"}], "sources": [{"center": [-5.0, 0.0, 0.0], "type": "ModeSource", "size": [0.0, 1.5, 1.0000000200408773e+20], "source_time": {"amplitude": 1.0, "phase": 0.0, "type": "GaussianPulse", "freq0": 193414489407062.47, "fwidth": 19341448940706.246, "offset": 5.0}, "name": null, "direction": "+", "mode_spec": {"num_modes": 1, "target_neff": null, "num_pml": [0, 0], "bend_radius": null, "bend_axis": null, "type": "ModeSpec"}, "mode_index": 0}], "monitors": [{"center": [0.0, 0.0, 0.0], "type": "FieldMonitor", "size": [1.0000000200408773e+20, 1.0000000200408773e+20, 0.0], "name": "field", "freqs": [193414489407062.47], "fields": ["Ex", "Ey", "Ez", "Hx", "Hy", "Hz"]}, {"center": [-4.8, -2.4492935982947065e-17, 0.0], "type": "ModeMonitor", "size": [0.0, 1.5, 1.0000000200408773e+20], "name": "o1", "freqs": {"data_list": [199861639053964.53, 199590087913945.56, 199319273683397.47, 199049193366753.28, 198779843984660.25, 198511222573870.2, 198243326187130.84, 197976151893078.1, 197709696776129.12, 197443957936376.25, 197178932489481.78, 196914617566573.62, 196651010314141.8, 196388107893935.72, 196125907482862.38, 195864406272885.25, 195603601470924.03, 195343490298755.25, 195084069992913.6, 194825337804594.1, 194567290999554.88, 194309926858021.06, 194053242674589.06, 193797235758131.84, 193541903431704.78, 193287243032452.56, 193033251911516.34, 192779927433942.2, 192527266978589.7, 192275267938041.8, 192023927718514.94, 191773243739770.16, 191523213435024.7, 191273834250864.5, 191025103647157.25, 190777019096966.16, 190529578086464.25, 190282778114849.66, 190036616694261.25, 189791091349695.0, 189546199618921.2, 189301939052401.97, 189058307213209.7, 188815301676945.9, 188572920031661.0, 188331159877774.28, 188090018827994.8, 187849494507242.88, 187609584552572.06, 187370286613091.75]}, "mode_spec": {"num_modes": 1, "target_neff": null, "num_pml": [0, 0], "bend_radius": null, "bend_axis": null, "type": "ModeSpec"}}, {"center": [5.0, 0.0, 0.0], "type": "ModeMonitor", "size": [0.0, 1.5, 1.0000000200408773e+20], "name": "o2", "freqs": {"data_list": [199861639053964.53, 199590087913945.56, 199319273683397.47, 199049193366753.28, 198779843984660.25, 198511222573870.2, 198243326187130.84, 197976151893078.1, 197709696776129.12, 197443957936376.25, 197178932489481.78, 196914617566573.62, 196651010314141.8, 196388107893935.72, 196125907482862.38, 195864406272885.25, 195603601470924.03, 195343490298755.25, 195084069992913.6, 194825337804594.1, 194567290999554.88, 194309926858021.06, 194053242674589.06, 193797235758131.84, 193541903431704.78, 193287243032452.56, 193033251911516.34, 192779927433942.2, 192527266978589.7, 192275267938041.8, 192023927718514.94, 191773243739770.16, 191523213435024.7, 191273834250864.5, 191025103647157.25, 190777019096966.16, 190529578086464.25, 190282778114849.66, 190036616694261.25, 189791091349695.0, 189546199618921.2, 189301939052401.97, 189058307213209.7, 188815301676945.9, 188572920031661.0, 188331159877774.28, 188090018827994.8, 187849494507242.88, 187609584552572.06, 187370286613091.75]}, "mode_spec": {"num_modes": 1, "target_neff": null, "num_pml": [0, 0], "bend_radius": null, "bend_axis": null, "type": "ModeSpec"}}], "pml_layers": [{"num_layers": 12, "parameters": {"sigma_order": 3, "sigma_min": 0.0, "sigma_max": 1.5, "type": "PMLParams", "kappa_order": 3, "kappa_min": 1.0, "kappa_max": 3.0, "alpha_order": 1, "alpha_min": 0.0, "alpha_max": 0.0}, "type": "PML"}, {"num_layers": 12, "parameters": {"sigma_order": 3, "sigma_min": 0.0, "sigma_max": 1.5, "type": "PMLParams", "kappa_order": 3, "kappa_min": 1.0, "kappa_max": 3.0, "alpha_order": 1, "alpha_min": 0.0, "alpha_max": 0.0}, "type": "PML"}, {"num_layers": 0, "parameters": {"sigma_order": 3, "sigma_min": 0.0, "sigma_max": 1.5, "type": "PMLParams", "kappa_order": 3, "kappa_min": 1.0, "kappa_max": 3.0, "alpha_order": 1, "alpha_min": 0.0, "alpha_max": 0.0}, "type": "PML"}], "shutoff": 1e-05, "subpixel": true, "courant": 0.9, "version": "1.0.2"}
momchil-flex commented 2 years ago

for the 3D grating I can try without the fields to see if things speed up

It probably won't speed up the solver time noticably but you won't have to download 1.9GB of data, which may be slower than the solver time itself...

Alright so the issue with the simulation is that it is centered at (0, 0, 0), while the waveguide structures extend from (0, 0, 0) to (0, 0, 0.22). This again produces some weird results since your cell boundary in the z-direction is sitting exactly on the interface between the waveguide and background. I caught this because I looked at the modes and they looked wrong. You have one of two options, center the simulation at the waveguide center (0, 0, 0.11), or make the slab bounds e.g. (-0.11, 0.11) (or much larger). Now I get nice modes (note that the fundamental one is Ez by the way), and I believe the scattering matrix should also look correct.

image

joamatab commented 2 years ago

amazing! thank you Momchil,

i made the polyslabs go from -inf to +inf for the 2D case

the 2D simulations look correct now

image

I will work on the 2D grating, to make a more realistic grating (include fiber and substrate)