-
Notifications
You must be signed in to change notification settings - Fork 632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GDSII import for Scheme #1175
base: master
Are you sure you want to change the base?
GDSII import for Scheme #1175
Conversation
@oskooi, I think this is basically working now? |
meep> (GDSII-layers "coupler.gds")
$1 = (0 1 2 3 4 5 31 32)
meep> (get-GDSII-prisms (material (make medium (index 3.5))) "coupler.gds" 31 0 0)
fewer than 3 vertices in init_prism Calling For comparison, here is the output from PyMeep: >>> import meep as mp
Using MPI version 3.1, 1 processes
>>> mp.GDSII_layers("coupler.gds")
[0, 1, 2, 3, 4, 5, 31, 32]
>>> mp.get_GDSII_prisms(mp.Medium(index=3.5), "coupler.gds", 31, 0, 0)
[<meep.geom.Prism object at 0x7f59cc41d6d8>, <meep.geom.Prism object at 0x7f59cc428128>, <meep.geom.Prism object at 0x7f59cc428588>] Note that |
It sounds like that error is happening in the |
Note the output from meep> (GDSII-vol "coupler.gds" 0 0 0)
$2 = #<collectable-swig-pointer meep::volume * 555943558ab0> |
If you do |
The way you call a volume method is via something like |
If I do meep> (get-GDSII-prisms air "coupler.gds" 31 0 0)
$1 = (((prism geometric-object) (center . #(+nan.0 +nan.0 +nan.0)) (material (medium material-type) (epsilon-diag . #(1.0 1.0 1.0)) (epsilon-offdiag . #(0.0 0.0 0.0)) (mu-diag . #(1.0 1.0 1.0)) (mu-offdiag . #(0.0 0.0 0.0)) (E-susceptibilities) (H-susceptibilities) (E-chi2-diag . #(0.0 0.0 0.0)) (E-chi3-diag . #(0.0 0.0 0.0)) (H-chi2-diag . #(0.0 0.0 0.0)) (H-chi3-diag . #(0.0 0.0 0.0)) (D-conductivity-diag . #(0.0 0.0 0.0)) (B-conductivity-diag . #(0.0 0.0 0.0))) (vertices #(-0.004 1.5e-4 0.0) #(-0.004108 1.5099999999999998e-4 0.0) #(-0.004215 1.5199999999999998e-4 0.0) #(-0.0043219999999999995 1.55e-4 0.0) #(-0.004429 1.5999999999999999e-4 0.0) #(-0.004535 1.65e-4 0.0) #(-0.004641 1.7099999999999998e-4 0.0) #(-0.0047469999999999995 1.79e-4 0.0) #(-0.0048519999999999995 1.87e-4 0.0) #(-0.005062 2.07e-4 0.0) #(-0.005167 2.1899999999999998e-4 0.0) #(-0.005271 2.3099999999999998e-4 0.0) #(-0.0054789999999999995 2.59e-4 0.0) #(-0.005582 2.74e-4 0.0) #(-0.005685 2.9e-4 0.0) #(-0.005788 3.07e-4 0.0) #(-0.0058909999999999995 3.25e-4 0.0) #(-0.005993 3.43e-4 0.0) #(-0.006095 3.6199999999999996e-4 0.0) #(-0.006196999999999999 3.8199999999999996e-4 0.0) #(-0.006299 4.03e-4 0.0) #(-0.0063999999999999994 4.24e-4 0.0) #(-0.006501 4.46e-4 0.0) #(-0.006703 4.919999999999999e-4 0.0) #(-0.006803 5.149999999999999e-4 0.0) #(-0.0069039999999999995 5.4e-4 0.0) #(-0.0072039999999999995 6.15e-4 0.0) #(-0.007303 6.42e-4 0.0) #(-0.007403 6.68e-4 0.0) #(-0.007502 6.95e-4 0.0) #(-0.007600999999999999 7.23e-4 0.0) #(-0.007699999999999999 7.5e-4 0.0) #(-0.0077989999999999995 7.779999999999999e-4 0.0) #(-0.007898 8.07e-4 0.0) #(-0.007996 8.349999999999999e-4 0.0) #(-0.008095 8.64e-4 0.0) #(-0.008192999999999999 8.929999999999999e-4 0.0) #(-0.008291 9.23e-4 0.0) #(-0.008388999999999999 9.519999999999999e-4 0.0) #(-0.008487 9.82e-4 0.0) #(-0.008584999999999999 0.001011 0.0) #(-0.008780999999999999 0.001071 0.0) #(-0.008877999999999999 0.001101 0.0) #(-0.009073999999999999 0.001161 0.0) #(-0.009268 0.0012209999999999999 0.0) #(-0.009366 0.001251 0.0) #(-0.009463 0.001281 0.0) #(-0.009559999999999999 0.00131 0.0) #(-0.009658 0.00134 0.0) #(-0.009949 0.0014269999999999999 0.0) #(-0.010047 0.0014559999999999998 0.0) #(-0.010144 0.001485 0.0) #(-0.010338 0.0015409999999999998 0.0) #(-0.010435999999999999 0.001568 0.0) #(-0.010532999999999999 0.001596 0.0) #(-0.010629999999999999 0.0016229999999999999 0.0) #(-0.010728 0.0016489999999999999 0.0) #(-0.010922 0.0017009999999999998 0.0) #(-0.01102 0.0017259999999999999 0.0) #(-0.011117 0.0017499999999999998 0.0) #(-0.011215 0.0017749999999999999 0.0) #(-0.011313 0.001798 0.0) #(-0.01141 0.001821 0.0) #(-0.011508 0.001844 0.0) #(-0.011606 0.0018659999999999998 0.0) #(-0.011703999999999999 0.001887 0.0) #(-0.011802 0.0019069999999999998 0.0) #(-0.011901 0.001927 0.0) #(-0.011999 0.0019459999999999998 0.0) #(-0.012098 0.0019649999999999997 0.0) #(-0.012196 0.001983 0.0) #(-0.012294999999999999 0.002 0.0) #(-0.012393999999999999 0.002016 0.0) #(-0.012591999999999999 0.002046 0.0) #(-0.012691 0.0020599999999999998 0.0) #(-0.012791 0.002072 0.0) #(-0.012889999999999999 0.002084 0.0) #(-0.01299 0.002095 0.0) #(-0.013189999999999999 0.0021149999999999997 0.0) #(-0.013290999999999999 0.002123 0.0) #(-0.013392 0.00213 0.0) #(-0.013491999999999999 0.002136 0.0) #(-0.013593 0.002141 0.0) #(-0.013694999999999999 0.0021449999999999998 0.0) #(-0.013796 0.0021479999999999997 0.0) #(-0.013999999999999999 0.00215 0.0) #(-0.0172 0.00215 0.0) #(-0.0172 0.00265 0.0) #(-0.013999999999999999 0.00265 0.0) #(-0.013892 0.002649 0.0) #(-0.013784999999999999 0.0026479999999999997 0.0) #(-0.013678 0.0026449999999999998 0.0) #(-0.013571 0.00264 0.0) #(-0.013465 0.0026349999999999998 0.0) #(-0.013359 0.002629 0.0) #(-0.013253 0.002621 0.0) #(-0.013148 0.002613 0.0) #(-0.012938 0.002593 0.0) #(-0.012832999999999999 0.002581 0.0) #(-0.012728999999999999 0.0025689999999999997 0.0) #(-0.012521 0.002541 0.0) #(-0.012418 0.002526 0.0) #(-0.012315 0.00251 0.0) #(-0.012211999999999999 0.002493 0.0) #(-0.012109 0.0024749999999999998 0.0) #(-0.012007 0.002457 0.0) #(-0.011904999999999999 0.002438 0.0) #(-0.011803 0.002418 0.0) #(-0.011701 0.002397 0.0) #(-0.0116 0.002376 0.0) #(-0.011498999999999999 0.0023539999999999998 0.0) #(-0.011297 0.0023079999999999997 0.0) #(-0.011197 0.0022849999999999997 0.0) #(-0.011096 0.00226 0.0) #(-0.010796 0.002185 0.0) #(-0.010697 0.0021579999999999998 0.0) #(-0.010596999999999999 0.0021319999999999998 0.0) #(-0.010498 0.002105 0.0) #(-0.010399 0.002077 0.0) #(-0.0103 0.0020499999999999997 0.0) #(-0.010201 0.002022 0.0) #(-0.010102 0.001993 0.0) #(-0.010003999999999999 0.0019649999999999997 0.0) #(-0.009904999999999999 0.001936 0.0) #(-0.009807 0.0019069999999999998 0.0) #(-0.009708999999999999 0.001877 0.0) #(-0.009611 0.0018479999999999998 0.0) #(-0.009512999999999999 0.001818 0.0) #(-0.009415 0.001789 0.0) #(-0.009219 0.0017289999999999999 0.0) #(-0.009122 0.001699 0.0) #(-0.008926 0.0016389999999999998 0.0) #(-0.008732 0.0015789999999999999 0.0) #(-0.008634 0.001549 0.0) #(-0.008537 0.001519 0.0) #(-0.00844 0.00149 0.0) #(-0.008342 0.00146 0.0) #(-0.008050999999999999 0.0013729999999999999 0.0) #(-0.007953 0.001344 0.0) #(-0.007856 0.001315 0.0) #(-0.0076619999999999995 0.001259 0.0) #(-0.0075639999999999995 0.001232 0.0) #(-0.007467 0.001204 0.0) #(-0.00737 0.0011769999999999999 0.0) #(-0.007272 0.001151 0.0) #(-0.007078 0.001099 0.0) #(-0.00698 0.0010739999999999999 0.0) #(-0.006882999999999999 0.00105 0.0) #(-0.006784999999999999 0.0010249999999999999 0.0) #(-0.006686999999999999 0.0010019999999999999 0.0) #(-0.0065899999999999995 9.79e-4 0.0) #(-0.0064919999999999995 9.559999999999999e-4 0.0) #(-0.0063939999999999995 9.339999999999999e-4 0.0) #(-0.0062959999999999995 9.13e-4 0.0) #(-0.0061979999999999995 8.929999999999999e-4 0.0) #(-0.006098999999999999 8.73e-4 0.0) #(-0.006000999999999999 8.539999999999999e-4 0.0) #(-0.005902 8.349999999999999e-4 0.0) #(-0.005804 8.169999999999999e-4 0.0) #(-0.005705 7.999999999999999e-4 0.0) #(-0.005606 7.84e-4 0.0) #(-0.005408 7.54e-4 0.0) #(-0.0053089999999999995 7.4e-4 0.0) #(-0.005209 7.279999999999999e-4 0.0) #(-0.00511 7.16e-4 0.0) #(-0.00501 7.05e-4 0.0) #(-0.00481 6.85e-4 0.0) #(-0.004709 6.77e-4 0.0) #(-0.004608 6.7e-4 0.0) #(-0.004508 6.64e-4 0.0) #(-0.0044069999999999995 6.59e-4 0.0) #(-0.004305 6.55e-4 0.0) #(-0.004203999999999999 6.52e-4 0.0) #(-0.004 6.5e-4 0.0)) (height . 0.0) (axis . #(0.0 0.0 1.0)) (sidewall_angle . 0) (vertices_p) (top_polygon_diff_vectors_p) (top_polygon_diff_vectors_scaled_p) (vertices_top_p) (vertices_top) (centroid . #(0.0 0.0 0.0)) (workspace) (m_c2p . #(#(1.0 0.0 0.0) #(0.0 1.0 0.0) #(0.0 0.0 1.0))) (m_p2c . #(#(1.0 0.0 0.0) #(0.0 1.0 0.0) #(0.0 0.0 1.0)))) ((prism geometric-object) (center . #(+nan.0 +nan.0 +nan.0)) (material (medium material-type) (epsilon-diag . #(1.0 1.0 1.0)) (epsilon-offdiag . #(0.0 0.0 0.0)) (mu-diag . #(1.0 1.0 1.0)) (mu-offdiag . #(0.0 0.0 0.0)) (E-susceptibilities) (H-susceptibilities) (E-chi2-diag . #(0.0 0.0 0.0)) (E-chi3-diag . #(0.0 0.0 0.0)) (H-chi2-diag . #(0.0 0.0 0.0)) (H-chi3-diag . #(0.0 0.0 0.0)) (D-conductivity-diag . #(0.0 0.0 0.0)) (B-conductivity-diag . #(0.0 0.0 0.0))) (vertices #(0.004 1.5e-4 0.0) #(0.004 6.5e-4 0.0) #(0.004203999999999999 6.52e-4 0.0) #(0.004305 6.55e-4 0.0) #(0.0044069999999999995 6.59e-4 0.0) #(0.004508 6.64e-4 0.0) #(0.004608 6.7e-4 0.0) #(0.004709 6.77e-4 0.0) #(0.00481 6.85e-4 0.0) #(0.00501 7.05e-4 0.0) #(0.00511 7.16e-4 0.0) #(0.005209 7.279999999999999e-4 0.0) #(0.0053089999999999995 7.4e-4 0.0) #(0.005408 7.54e-4 0.0) #(0.005606 7.84e-4 0.0) #(0.005705 7.999999999999999e-4 0.0) #(0.005804 8.169999999999999e-4 0.0) #(0.005902 8.349999999999999e-4 0.0) #(0.006000999999999999 8.539999999999999e-4 0.0) #(0.006098999999999999 8.73e-4 0.0) #(0.0061979999999999995 8.929999999999999e-4 0.0) #(0.0062959999999999995 9.13e-4 0.0) #(0.0063939999999999995 9.339999999999999e-4 0.0) #(0.0064919999999999995 9.559999999999999e-4 0.0) #(0.0065899999999999995 9.79e-4 0.0) #(0.006686999999999999 0.0010019999999999999 0.0) #(0.006784999999999999 0.0010249999999999999 0.0) #(0.006882999999999999 0.00105 0.0) #(0.00698 0.0010739999999999999 0.0) #(0.007078 0.001099 0.0) #(0.007272 0.001151 0.0) #(0.00737 0.0011769999999999999 0.0) #(0.007467 0.001204 0.0) #(0.0075639999999999995 0.001232 0.0) #(0.0076619999999999995 0.001259 0.0) #(0.007856 0.001315 0.0) #(0.007953 0.001344 0.0) #(0.008050999999999999 0.0013729999999999999 0.0) #(0.008342 0.00146 0.0) #(0.00844 0.00149 0.0) #(0.008537 0.001519 0.0) #(0.008634 0.001549 0.0) #(0.008732 0.0015789999999999999 0.0) #(0.008926 0.0016389999999999998 0.0) #(0.009122 0.001699 0.0) #(0.009219 0.0017289999999999999 0.0) #(0.009415 0.001789 0.0) #(0.009512999999999999 0.001818 0.0) #(0.009611 0.0018479999999999998 0.0) #(0.009708999999999999 0.001877 0.0) #(0.009807 0.0019069999999999998 0.0) #(0.009904999999999999 0.001936 0.0) #(0.010003999999999999 0.0019649999999999997 0.0) #(0.010102 0.001993 0.0) #(0.010201 0.002022 0.0) #(0.0103 0.0020499999999999997 0.0) #(0.010399 0.002077 0.0) #(0.010498 0.002105 0.0) #(0.010596999999999999 0.0021319999999999998 0.0) #(0.010697 0.0021579999999999998 0.0) #(0.010796 0.002185 0.0) #(0.011096 0.00226 0.0) #(0.011197 0.0022849999999999997 0.0) #(0.011297 0.0023079999999999997 0.0) #(0.011498999999999999 0.0023539999999999998 0.0) #(0.0116 0.002376 0.0) #(0.011701 0.002397 0.0) #(0.011803 0.002418 0.0) #(0.011904999999999999 0.002438 0.0) #(0.012007 0.002457 0.0) #(0.012109 0.0024749999999999998 0.0) #(0.012211999999999999 0.002493 0.0) #(0.012315 0.00251 0.0) #(0.012418 0.002526 0.0) #(0.012521 0.002541 0.0) #(0.012728999999999999 0.0025689999999999997 0.0) #(0.012832999999999999 0.002581 0.0) #(0.012938 0.002593 0.0) #(0.013148 0.002613 0.0) #(0.013253 0.002621 0.0) #(0.013359 0.002629 0.0) #(0.013465 0.0026349999999999998 0.0) #(0.013571 0.00264 0.0) #(0.013678 0.0026449999999999998 0.0) #(0.013784999999999999 0.0026479999999999997 0.0) #(0.013892 0.002649 0.0) #(0.013999999999999999 0.00265 0.0) #(0.0172 0.00265 0.0) #(0.0172 0.00215 0.0) #(0.013999999999999999 0.00215 0.0) #(0.013796 0.0021479999999999997 0.0) #(0.013694999999999999 0.0021449999999999998 0.0) #(0.013593 0.002141 0.0) #(0.013491999999999999 0.002136 0.0) #(0.013392 0.00213 0.0) #(0.013290999999999999 0.002123 0.0) #(0.013189999999999999 0.0021149999999999997 0.0) #(0.01299 0.002095 0.0) #(0.012889999999999999 0.002084 0.0) #(0.012791 0.002072 0.0) #(0.012691 0.0020599999999999998 0.0) #(0.012591999999999999 0.002046 0.0) #(0.012393999999999999 0.002016 0.0) #(0.012294999999999999 0.002 0.0) #(0.012196 0.001983 0.0) #(0.012098 0.0019649999999999997 0.0) #(0.011999 0.0019459999999999998 0.0) #(0.011901 0.001927 0.0) #(0.011802 0.0019069999999999998 0.0) #(0.011703999999999999 0.001887 0.0) #(0.011606 0.0018659999999999998 0.0) #(0.011508 0.001844 0.0) #(0.01141 0.001821 0.0) #(0.011313 0.001798 0.0) #(0.011215 0.0017749999999999999 0.0) #(0.011117 0.0017499999999999998 0.0) #(0.01102 0.0017259999999999999 0.0) #(0.010922 0.0017009999999999998 0.0) #(0.010728 0.0016489999999999999 0.0) #(0.010629999999999999 0.0016229999999999999 0.0) #(0.010532999999999999 0.001596 0.0) #(0.010435999999999999 0.001568 0.0) #(0.010338 0.0015409999999999998 0.0) #(0.010144 0.001485 0.0) #(0.010047 0.0014559999999999998 0.0) #(0.009949 0.0014269999999999999 0.0) #(0.009658 0.00134 0.0) #(0.009559999999999999 0.00131 0.0) #(0.009463 0.001281 0.0) #(0.009366 0.001251 0.0) #(0.009268 0.0012209999999999999 0.0) #(0.009073999999999999 0.001161 0.0) #(0.008877999999999999 0.001101 0.0) #(0.008780999999999999 0.001071 0.0) #(0.008584999999999999 0.001011 0.0) #(0.008487 9.82e-4 0.0) #(0.008388999999999999 9.519999999999999e-4 0.0) #(0.008291 9.23e-4 0.0) #(0.008192999999999999 8.929999999999999e-4 0.0) #(0.008095 8.64e-4 0.0) #(0.007996 8.349999999999999e-4 0.0) #(0.007898 8.07e-4 0.0) #(0.0077989999999999995 7.779999999999999e-4 0.0) #(0.007699999999999999 7.5e-4 0.0) #(0.007600999999999999 7.23e-4 0.0) #(0.007502 6.95e-4 0.0) #(0.007403 6.68e-4 0.0) #(0.007303 6.42e-4 0.0) #(0.0072039999999999995 6.15e-4 0.0) #(0.0069039999999999995 5.4e-4 0.0) #(0.006803 5.149999999999999e-4 0.0) #(0.006703 4.919999999999999e-4 0.0) #(0.006501 4.46e-4 0.0) #(0.0063999999999999994 4.24e-4 0.0) #(0.006299 4.03e-4 0.0) #(0.006196999999999999 3.8199999999999996e-4 0.0) #(0.006095 3.6199999999999996e-4 0.0) #(0.005993 3.43e-4 0.0) #(0.0058909999999999995 3.25e-4 0.0) #(0.005788 3.07e-4 0.0) #(0.005685 2.9e-4 0.0) #(0.005582 2.74e-4 0.0) #(0.0054789999999999995 2.59e-4 0.0) #(0.005271 2.3099999999999998e-4 0.0) #(0.005167 2.1899999999999998e-4 0.0) #(0.005062 2.07e-4 0.0) #(0.0048519999999999995 1.87e-4 0.0) #(0.0047469999999999995 1.79e-4 0.0) #(0.004641 1.7099999999999998e-4 0.0) #(0.004535 1.65e-4 0.0) #(0.004429 1.5999999999999999e-4 0.0) #(0.0043219999999999995 1.55e-4 0.0) #(0.004215 1.5199999999999998e-4 0.0) #(0.004108 1.5099999999999998e-4 0.0)) (height . 0.0) (axis . #(0.0 0.0 1.0)) (sidewall_angle . 0) (vertices_p) (top_polygon_diff_vectors_p) (top_polygon_diff_vectors_scaled_p) (vertices_top_p) (vertices_top) (centroid . #(0.0 0.0 0.0)) (workspace) (m_c2p . #(#(1.0 0.0 0.0) #(0.0 1.0 0.0) #(0.0 0.0 1.0))) (m_p2c . #(#(1.0 0.0 0.0) #(0.0 1.0 0.0) #(0.0 0.0 1.0)))) ((prism geometric-object) (center . #(+nan.0 +nan.0 +nan.0)) (material (medium material-type) (epsilon-diag . #(1.0 1.0 1.0)) (epsilon-offdiag . #(0.0 0.0 0.0)) (mu-diag . #(1.0 1.0 1.0)) (mu-offdiag . #(0.0 0.0 0.0)) (E-susceptibilities) (H-susceptibilities) (E-chi2-diag . #(0.0 0.0 0.0)) (E-chi3-diag . #(0.0 0.0 0.0)) (H-chi2-diag . #(0.0 0.0 0.0)) (H-chi3-diag . #(0.0 0.0 0.0)) (D-conductivity-diag . #(0.0 0.0 0.0)) (B-conductivity-diag . #(0.0 0.0 0.0))) (vertices #(-0.004 1.5e-4 0.0) #(-0.004 6.5e-4 0.0) #(0.004 6.5e-4 0.0) #(0.004 1.5e-4 0.0)) (height . 0.0) (axis . #(0.0 0.0 1.0)) (sidewall_angle . 0) (vertices_p) (top_polygon_diff_vectors_p) (top_polygon_diff_vectors_scaled_p) (vertices_top_p) (vertices_top) (centroid . #(0.0 0.0 0.0)) (workspace) (m_c2p . #(#(1.0 0.0 0.0) #(0.0 1.0 0.0) #(0.0 0.0 1.0))) (m_p2c . #(#(1.0 0.0 0.0) #(0.0 1.0 0.0) #(0.0 0.0 1.0))))) (3 prism objects). |
try this script: (set-param! resolution 50)
(define-param GDSII-file "coupler.gds")
(define-param CELL-LAYER 0)
(define-param PORT1-LAYER 1)
(define-param PORT2-LAYER 2)
(define-param PORT3-LAYER 3)
(define-param PORT4-LAYER 4)
(define-param SOURCE-LAYER 5)
(define-param UPPER-BRANCH-LAYER 31)
(define-param LOWER-BRANCH-LAYER 32)
(define-param d 0.1) ;; branch separation
(define-param t-oxide 1.0)
(define-param t-Si 0.22)
(define-param t-air 0.78)
(define-param dpml 1)
(define cell-thickness (+ dpml t-oxide t-Si t-air dpml))
(define si-zmin 0)
(define oxide (make medium (epsilon 2.25)))
(define silicon (make medium (epsilon 12.0)))
(define-param wvl-cen 1.55)
(define fcen (/ wvl-cen))
(define df (* 0.2 fcen))
(define-param 3d? false)
(define cell-zmax (if 3d? (* 0.5 cell-thickness) 0))
(define cell-zmin (if 3d? (* -0.5 cell-thickness) 0))
(define si-zmax (if 3d? t-Si 0))
;; read cell size, volumes for source region and flux monitors,
;; and coupler geometry from GDSII file
(define upper-branch (get-GDSII-prisms silicon GDSII-file UPPER-BRANCH-LAYER si-zmin si-zmax))
(define lower-branch (get-GDSII-prisms silicon GDSII-file LOWER-BRANCH-LAYER si-zmin si-zmax))
(set! geometry (list upper-branch lower-branch))
(define cell (GDSII-vol GDSII-file CELL-LAYER cell-zmin cell-zmax))
(define p1 (GDSII-vol GDSII-file PORT1-LAYER si-zmin si-zmax))
(define p2 (GDSII-vol GDSII-file PORT2-LAYER si-zmin si-zmax))
(define p3 (GDSII-vol GDSII-file PORT3-LAYER si-zmin si-zmax))
(define p4 (GDSII-vol GDSII-file PORT4-LAYER si-zmin si-zmax))
(define src-vol (GDSII-vol GDSII-file SOURCE-LAYER si-zmin si-zmax))
(run-until 0 (at-beginning output-epsilon)) |
from the Python tutorial: >>> import meep as mp
Using MPI version 3.1, 1 processes
>>> gdsII_file = 'coupler.gds'
>>> CELL_LAYER = 0
>>> mp.GDSII_vol(gdsII_file, CELL_LAYER, 0, 0).size
Vector3<34.4, 8.0, 0.0>
>>> mp.GDSII_vol(gdsII_file, CELL_LAYER, 0, 0).center
Vector3<0.0, 0.0, 0.0> |
The modified file is (set-param! resolution 20000)
(define-param GDSII-file "coupler.gds")
(define-param CELL-LAYER 0)
(define-param PORT1-LAYER 1)
(define-param PORT2-LAYER 2)
(define-param PORT3-LAYER 3)
(define-param PORT4-LAYER 4)
(define-param SOURCE-LAYER 5)
(define-param UPPER-BRANCH-LAYER 31)
(define-param LOWER-BRANCH-LAYER 32)
(define-param d 0.1) ;; branch separation
(define-param t-oxide 1.0)
(define-param t-Si 0.22)
(define-param t-air 0.78)
(define-param dpml 1)
(define cell-thickness (+ dpml t-oxide t-Si t-air dpml))
(define si-zmin -1)
(define oxide (make medium (epsilon 2.25)))
(define silicon (make medium (epsilon 12.0)))
(define-param wvl-cen 1.55)
(define fcen (/ wvl-cen))
(define df (* 0.2 fcen))
(define-param 3d? false)
(define cell-zmax (if 3d? (* 0.5 cell-thickness) 0))
(define cell-zmin (if 3d? (* -0.5 cell-thickness) 0))
(define si-zmax (if 3d? t-Si 1))
; read cell size, volumes for source region and flux monitors,
; and coupler geometry from GDSII file
(define upper-branch (get-GDSII-prisms silicon GDSII-file UPPER-BRANCH-LAYER si-zmin si-zmax))
(define lower-branch (get-GDSII-prisms silicon GDSII-file LOWER-BRANCH-LAYER si-zmin si-zmax))
(set! geometry (append upper-branch lower-branch))
(define cell (GDSII-vol GDSII-file CELL-LAYER cell-zmin cell-zmax))
(define p1 (GDSII-vol GDSII-file PORT1-LAYER si-zmin si-zmax))
(define p2 (GDSII-vol GDSII-file PORT2-LAYER si-zmin si-zmax))
(define p3 (GDSII-vol GDSII-file PORT3-LAYER si-zmin si-zmax))
(define p4 (GDSII-vol GDSII-file PORT4-LAYER si-zmin si-zmax))
(define src-vol (GDSII-vol GDSII-file SOURCE-LAYER si-zmin si-zmax))
(set! geometry-lattice (make lattice (size (meep-volume-in-direction cell X)
(meep-volume-in-direction cell Y)
no-size)))
(run-until 0 (at-beginning output-epsilon)) |
For some reason, the units seem different from Python by a factor of 1000. |
For some reason, I am not able to reproduce the results in this PR with the latest commit ( SWIG 3.0.12 meep> (get-GDSII-prisms air "coupler.gds" 31 0 0)
fewer than 3 vertices in init_prism meep> (get-GDSII-prism-data "coupler.gds" 31 0 0)
fewer than 3 vertices in init_prism SWIG 4.0.1 meep> (get-GDSII-prisms air "coupler.gds" 31 0 0)
out of memory meep> (get-GDSII-prism-data "coupler.gds" 31 0 0)
out of memory |
@oskooi asked me to try running |
I am using the HomerReid/libGDSII#11 branch, guile 2.2.6, and SWIG Version 3.0.12. |
On a clean Ubuntu 18.04 system, building Meep 1.14 from source with Guile 2.2.3, SWIG 3.0.12, and HomerReid/libGDSII#11,
Same result for
As a sanity check, PyMeep works fine: >>> import meep as mp
Using MPI version 3.1, 1 processes
>>> print(mp.__version__)
1.14.0-3-g4e42ffd7
>>> mp.GDSII_layers("coupler.gds")
[0, 1, 2, 3, 4, 5, 31, 32]
>>> mp.GDSII_vol("coupler.gds", 0, 0, 0)
<meep.simulation.Volume object at 0x7f2ba57a16a0>
>>> mp.get_GDSII_prisms(mp.Medium(index=3.5), "coupler.gds", 31, 0, 0)
[<meep.geom.Prism object at 0x7f2b97d4a908>, <meep.geom.Prism object at 0x7f2b97e08358>, <meep.geom.Prism object at 0x7f2b97e087b8>] |
It's segfaulting in make_prism, which is a libctlgeom function. If you compile libctl with |
output from running
This error is from |
If you can reproduce the segfault with a debug build, that will be easier. Conversely, for the "fewer than 3 vertices error", you could try to step with the debugger to see what that is happening |
I have tracked down the cause of the segmentation fault but do not how to go about fixing it. Compiling with
in the function This is shown in the backtrace:
Note that https://github.com/NanoComp/libctl/blob/master/utils/geom.c#L2838-L2853 The reason https://github.com/NanoComp/meep/blob/master/src/GDSIIgeom.cpp#L147-L152 I verified that the Finding out what is causing this array to be corrupted during the transfer may provide the fix. |
The same error related to the use of the corrupted
Based on this information, is it possible that the different results reported for |
You expect valgrind to report leaks from Scheme because it doesn't know about Scheme's garbage collection. (In any case, the worst that can happen with a leak is running out of memory, so it couldn't cause the problem here.) |
It looks like the problem is that it's calling the wrong geom.cpp. The Scheme code should be calling its own The right way to fix this is probably to ensure that the routines in |
This hasn't bitten us before because it's the first time we've tried to use meepgeom from the Scheme interface. We'd have to set up libctl so that there is an option, e.g. set by a preprocessor |
Implement functions
GDSII-layers
,GDSII-vol
, andget-GDSII-prisms
in Scheme mirroring those in C++ and Python.