r""" Like `output_farfields` but returns a dictionary of NumPy arrays instead of writing to a file. The dictionary keys are `Ex`, `Ey`, `Ez`, `Hx`, `Hy`, `Hz`. Each array has the same shape as described in `output_farfields`. Note that far fields have the same units
(
self,
near2far,
resolution: float = None,
where: Volume = None,
center: Vector3Type = None,
size: Vector3Type = None,
greencyl_tol: float = 1e-3,
)
| 3242 | ) |
| 3243 | |
| 3244 | def get_farfields( |
| 3245 | self, |
| 3246 | near2far, |
| 3247 | resolution: float = None, |
| 3248 | where: Volume = None, |
| 3249 | center: Vector3Type = None, |
| 3250 | size: Vector3Type = None, |
| 3251 | greencyl_tol: float = 1e-3, |
| 3252 | ): |
| 3253 | r""" |
| 3254 | Like `output_farfields` but returns a dictionary of NumPy arrays instead of |
| 3255 | writing to a file. The dictionary keys are `Ex`, `Ey`, `Ez`, `Hx`, `Hy`, `Hz`. |
| 3256 | Each array has the same shape as described in `output_farfields`. |
| 3257 | |
| 3258 | Note that far fields have the same units and scaling as the *Fourier transforms* |
| 3259 | of the fields, and hence cannot be directly compared to time-domain fields. In |
| 3260 | practice, it is easiest to use the far fields in computations where overall |
| 3261 | scaling (units) cancel out or are irrelevant, e.g. to compute the fraction of the |
| 3262 | far fields in one region vs. another region. `greencyl_tol` specifies the |
| 3263 | convergence tolerance of the azimuthal ($\phi$) integral in the calculation |
| 3264 | of the far field. |
| 3265 | """ |
| 3266 | if self.fields is None: |
| 3267 | self.init_sim() |
| 3268 | vol = self._volume_from_kwargs(where, center, size) |
| 3269 | self.fields.am_now_working_on(mp.GetFarfieldsTime) |
| 3270 | result = mp._get_farfields_array( |
| 3271 | near2far.swigobj, vol, resolution, greencyl_tol |
| 3272 | ) |
| 3273 | self.fields.finished_working() |
| 3274 | res_ex = complexarray(result[0], result[1]) |
| 3275 | res_ey = complexarray(result[2], result[3]) |
| 3276 | res_ez = complexarray(result[4], result[5]) |
| 3277 | res_hx = complexarray(result[6], result[7]) |
| 3278 | res_hy = complexarray(result[8], result[9]) |
| 3279 | res_hz = complexarray(result[10], result[11]) |
| 3280 | return { |
| 3281 | "Ex": res_ex, |
| 3282 | "Ey": res_ey, |
| 3283 | "Ez": res_ez, |
| 3284 | "Hx": res_hx, |
| 3285 | "Hy": res_hy, |
| 3286 | "Hz": res_hz, |
| 3287 | } |
| 3288 | |
| 3289 | def output_farfields( |
| 3290 | self, |