Utility function that takes a `meep::volume` `vol` and returns the center and size of the volume as a tuple of `Vector3`.
(vol)
| 6182 | |
| 6183 | # extract center and size of a meep::volume |
| 6184 | def get_center_and_size(vol): |
| 6185 | """ |
| 6186 | Utility function that takes a `meep::volume` `vol` and returns the center and size of |
| 6187 | the volume as a tuple of `Vector3`. |
| 6188 | """ |
| 6189 | rmin = vol.get_min_corner() |
| 6190 | rmax = vol.get_max_corner() |
| 6191 | v3rmin = mp.Vector3(rmin.x(), rmin.y(), rmin.z()) |
| 6192 | v3rmax = mp.Vector3(rmax.x(), rmax.y(), rmax.z()) |
| 6193 | |
| 6194 | if vol.dim == mp.D2: |
| 6195 | v3rmin.z = 0 |
| 6196 | v3rmax.z = 0 |
| 6197 | elif vol.dim == mp.D1: |
| 6198 | v3rmin.x = 0 |
| 6199 | v3rmin.y = 0 |
| 6200 | v3rmin.y = 0 |
| 6201 | v3rmax.y = 0 |
| 6202 | |
| 6203 | center = 0.5 * (v3rmin + v3rmax) |
| 6204 | size = v3rmax - v3rmin |
| 6205 | return center, size |
| 6206 | |
| 6207 | |
| 6208 | def GDSII_layers(fname): |
no test coverage detected