From 11d43d4b378680931c12c778bded4db715e60091 Mon Sep 17 00:00:00 2001 From: tylerflex Date: Fri, 5 Nov 2021 15:40:02 -0700 Subject: [PATCH 1/3] template for near2far improvements --- tidy3d/plugins/near2far/near2far.py | 51 ++++++++----------------- tidy3d/plugins/near2far/near2far_new.py | 42 ++++++++++++++++++++ 2 files changed, 57 insertions(+), 36 deletions(-) create mode 100644 tidy3d/plugins/near2far/near2far_new.py diff --git a/tidy3d/plugins/near2far/near2far.py b/tidy3d/plugins/near2far/near2far.py index 96339c5aa2..b19e854658 100644 --- a/tidy3d/plugins/near2far/near2far.py +++ b/tidy3d/plugins/near2far/near2far.py @@ -4,12 +4,13 @@ from ...constants import C_0, ETA_0 from ...components.data import FieldData +from ...log import SetupError class Near2Far: """Near field to far field transformation tool.""" - def __init__(self, field_data: FieldData): + def __init__(self, field_data: FieldData, frequency : float): """Constructs near field to far field transformation object from monitor data. Parameters @@ -19,41 +20,19 @@ def __init__(self, field_data: FieldData): """ # get frequency info - self.f = float(field_data.data.Ez.f[0].values) - self.k0 = 2 * np.pi * self.f / C_0 - - # get normal axis (ignore components) - xs = field_data.data.Ez.x.values - ys = field_data.data.Ez.y.values - zs = field_data.data.Ez.z.values - mon_size = [xs.shape[-1], ys.shape[-1], zs.shape[-1]] - self.axis = mon_size.index(1) - assert self.axis == 2, "Currently only works for z normal." - - # get normal and planar coordinates - # zs, (xs, ys) = field_data.geometry.pop_axis((xs, ys, zs), axis=self.axis) - self.z0 = zs[0] - self.xs = xs - self.ys = ys - self.xx, self.yy = np.meshgrid(self.xs, self.ys, indexing="ij") - self.dx = np.mean(np.diff(xs)) - self.dy = np.mean(np.diff(ys)) - - # get tangential near fields - # for em_field in "EH": - # for component in "xyz": - # field_name = em_field + component - # assert field_name in field_data.field, f"missing field: {field_name}" - - self.Ex = field_data.data.Ex.values - self.Ey = field_data.data.Ey.values - self.Ez = field_data.data.Ez.values - self.Hx = field_data.data.Hx.values - self.Hy = field_data.data.Hy.values - self.Hz = field_data.data.Hz.values - - # _, (self.Ex, self.Ey) = field_data.geometry.pop_axis(E, axis=self.axis) - # _, (self.Hx, self.Hy) = field_data.geometry.pop_axis(H, axis=self.axis) + self.k0 = 2 * np.pi * frequency / C_0 + + self.xx, self.yy = np.meshgrid(xs, ys, indexing="ij") + + self.Ex = field_data.data['Ex'] + self.Ey = field_data.data['Ey'] + self.Ez = field_data.data['Ez'] + self.Hx = field_data.data['Hx'] + self.Hy = field_data.data['Hy'] + self.Hz = field_data.data['Hz'] + + self.dxs = np.diff(self.Hz.xs.values) + self.dys = np.diff(self.Hz.ys.values) # compute equivalent sources self.Jx = -self.Hy diff --git a/tidy3d/plugins/near2far/near2far_new.py b/tidy3d/plugins/near2far/near2far_new.py new file mode 100644 index 0000000000..61727f030c --- /dev/null +++ b/tidy3d/plugins/near2far/near2far_new.py @@ -0,0 +1,42 @@ +"""Near field to far field transformation plugin.""" +from typing import Dict, Tuple + +import numpy as np +import pydantic as pd +import xarray as xr + +from ...constants import C_0, ETA_0 +from ...components.data import CollectionData, FieldData +from ...components import FieldMonitor +from ...log import SetupError + + +class Near2Far: + """tool for projecting from near field data to far field data""" + + def __init__(self, near_field_data: Dict[str, FieldData], frequency: float): + """create a near2far object""" + + for name, field_data in near_field_data.items(): + pass + # make sure near_field_data is planar. + # make sure near_field_data has planar E, H components. + # make sure frequency is contained in near_field_data. + # construct the J, H data on the surface at frequency + + def _compute_radiation_vectors( + self, theta: float, phi: float, axis: int + ) -> Tuple[CollectionData, CollectionData]: + """computes N and L vectors for theta and phi values using the near field J, M.""" + + def project_fields(self, x: float, y: float, z: float) -> FieldData: + """Project to x,y,z,frequency points described by far field monitor.""" + + def scattered_power(self, phis: float, thetas: float, axis: int) -> CollectionData: + """Get power scattered to various angles.""" + + # for name, field_data in near_field_data.items(): + # try: + # field_data.sel(f=val) + # except Exception as e: + # raise SetupError(f"frequency {frequency} not found in near field data named {name}") From f19639ca88a797b76e75bc90bf86c4426b441b20 Mon Sep 17 00:00:00 2001 From: tylerflex Date: Mon, 8 Nov 2021 17:37:31 -0800 Subject: [PATCH 2/3] old near2far works --- tidy3d/plugins/near2far/near2far.py | 112 ++++++++++++++++++---------- 1 file changed, 72 insertions(+), 40 deletions(-) diff --git a/tidy3d/plugins/near2far/near2far.py b/tidy3d/plugins/near2far/near2far.py index b19e854658..6882caaad7 100644 --- a/tidy3d/plugins/near2far/near2far.py +++ b/tidy3d/plugins/near2far/near2far.py @@ -3,42 +3,64 @@ import numpy as np from ...constants import C_0, ETA_0 -from ...components.data import FieldData +from ...components.data import FieldData, SimulationData from ...log import SetupError class Near2Far: """Near field to far field transformation tool.""" - def __init__(self, field_data: FieldData, frequency : float): + def __init__(self, sim_data : SimulationData, mon_name: str, frequency : float): """Constructs near field to far field transformation object from monitor data. Parameters ---------- - field_data : FieldData - Description + sim_data : :class:`.SimulationData` + Container for simulation data containing a near field monitor. + mon_name : str + Name of the :class:`.FieldMonitor` to use as source of near field. + Must be a :class:`.FieldMonitor` and stored in ``sim_data``. + frequency : float + Frequency to select from the :class:`.FieldMonitor` to use for projection. + Must be a frequency stored in the :class:`FieldMonitor`. + + """ - # get frequency info - self.k0 = 2 * np.pi * frequency / C_0 + try: + field_data = sim_data[mon_name] + except Exception as e: + raise SetupError(f"No data for monitor named '{mon_name}' found in supplied sim_data.") from e + + if any(field_name not in field_data for field_name in ('Ex', 'Ey', 'Ez', 'Hx', 'Hy', 'Hz')): + raise SetupError(f"Monitor named '{mon_name}' doesn't store all field values") - self.xx, self.yy = np.meshgrid(xs, ys, indexing="ij") + try: + self.Ex = field_data['Ex'].sel(f=frequency) + self.Ey = field_data['Ey'].sel(f=frequency) + self.Ez = field_data['Ez'].sel(f=frequency) + self.Hx = field_data['Hx'].sel(f=frequency) + self.Hy = field_data['Hy'].sel(f=frequency) + self.Hz = field_data['Hz'].sel(f=frequency) + except Exception as e: + raise SetupError(f"Frequency {frequency} not found in all fields from monitor '{mon_name}'.") from e - self.Ex = field_data.data['Ex'] - self.Ey = field_data.data['Ey'] - self.Ez = field_data.data['Ez'] - self.Hx = field_data.data['Hx'] - self.Hy = field_data.data['Hy'] - self.Hz = field_data.data['Hz'] + self.k0 = 2 * np.pi * frequency / C_0 - self.dxs = np.diff(self.Hz.xs.values) - self.dys = np.diff(self.Hz.ys.values) + # note: assuming uniform grid + self.dx = np.mean(np.diff(self.Hz.x.values)) + self.dy = np.mean(np.diff(self.Hz.y.values)) + + self.xx_Jx, self.yy_Jx = np.meshgrid(self.Hy.x.values, self.Hy.y.values, indexing="ij") + self.xx_Jy, self.yy_Jy = np.meshgrid(self.Hx.x.values, self.Hx.y.values, indexing="ij") + self.xx_Mx, self.yy_Mx = np.meshgrid(self.Ey.x.values, self.Ey.y.values, indexing="ij") + self.xx_My, self.yy_My = np.meshgrid(self.Ex.x.values, self.Ex.y.values, indexing="ij") # compute equivalent sources - self.Jx = -self.Hy - self.Jy = self.Hx - self.Mx = self.Ey - self.My = -self.Ex + self.Jx = -np.squeeze(self.Hy.values) + self.Jy = np.squeeze(self.Hx.values) + self.Mx = np.squeeze(self.Ey.values) + self.My = -np.squeeze(self.Ex.values) def _radiation_vectors(self, theta, phi): """Compute radiation vectors at an angle in spherical coordinates @@ -65,15 +87,25 @@ def _radiation_vectors(self, theta, phi): cos_phi = np.cos(phi).reshape((-1, 1, 1)) # precompute fourier transform phase term {dx dy e^(ikrcos(psi))} - FT_phase_x = np.exp(1j * self.k0 * self.xx * sin_theta * cos_phi) - FT_phase_y = np.exp(1j * self.k0 * self.yy * sin_theta * sin_phi) - FT_phase = self.dx * self.dy * FT_phase_x * FT_phase_y - - # multiply the phase terms with the current sources - Jx_phased = np.sum(self.Jx * FT_phase, axis=(-2, -1)) - Jy_phased = np.sum(self.Jy * FT_phase, axis=(-2, -1)) - Mx_phased = np.sum(self.Mx * FT_phase, axis=(-2, -1)) - My_phased = np.sum(self.My * FT_phase, axis=(-2, -1)) + FT_phase_x_Jx = np.exp(1j * self.k0 * self.xx_Jx * sin_theta * cos_phi) + FT_phase_y_Jx = np.exp(1j * self.k0 * self.yy_Jx * sin_theta * sin_phi) + FT_phase_Jx = self.dx * self.dy * FT_phase_x_Jx * FT_phase_y_Jx + Jx_integrated = np.sum(self.Jx * FT_phase_Jx, axis=(-2, -1)) + + FT_phase_x_Jy = np.exp(1j * self.k0 * self.xx_Jy * sin_theta * cos_phi) + FT_phase_y_Jy = np.exp(1j * self.k0 * self.yy_Jy * sin_theta * sin_phi) + FT_phase_Jy = self.dx * self.dy * FT_phase_x_Jy * FT_phase_y_Jy + Jy_integrated = np.sum(self.Jy * FT_phase_Jy, axis=(-2, -1)) + + FT_phase_x_Mx = np.exp(1j * self.k0 * self.xx_Mx * sin_theta * cos_phi) + FT_phase_y_Mx = np.exp(1j * self.k0 * self.yy_Mx * sin_theta * sin_phi) + FT_phase_Mx = self.dx * self.dy * FT_phase_x_Mx * FT_phase_y_Mx + Mx_integrated = np.sum(self.Mx * FT_phase_Mx, axis=(-2, -1)) + + FT_phase_x_My = np.exp(1j * self.k0 * self.xx_My * sin_theta * cos_phi) + FT_phase_y_My = np.exp(1j * self.k0 * self.yy_My * sin_theta * sin_phi) + FT_phase_My = self.dx * self.dy * FT_phase_x_My * FT_phase_y_My + My_integrated = np.sum(self.My * FT_phase_My, axis=(-2, -1)) # get rid of extra dimensions cos_phi = np.squeeze(cos_phi) @@ -82,24 +114,24 @@ def _radiation_vectors(self, theta, phi): sin_theta = np.squeeze(sin_theta) # N_theta (8.33a) - integrand_x = +Jx_phased * cos_theta * cos_phi - integrand_y = +Jy_phased * cos_theta * sin_phi - N_theta = integrand_x + integrand_y + contrib_x = +Jx_integrated * cos_theta * cos_phi + contrib_y = +Jy_integrated * cos_theta * sin_phi + N_theta = contrib_x + contrib_y # N_phi (8.33b) - integrand_x = -Jx_phased * sin_phi - integrand_y = +Jy_phased * cos_phi - N_phi = integrand_x + integrand_y + contrib_x = -Jx_integrated * sin_phi + contrib_y = +Jy_integrated * cos_phi + N_phi = contrib_x + contrib_y # L_theta (8.34a) - integrand_x = +Mx_phased * cos_theta * cos_phi - integrand_y = +My_phased * cos_theta * sin_phi - L_theta = integrand_x + integrand_y + contrib_x = +Mx_integrated * cos_theta * cos_phi + contrib_y = +My_integrated * cos_theta * sin_phi + L_theta = contrib_x + contrib_y # L_phi (8.34b) - integrand_x = -Mx_phased * sin_phi - integrand_y = +My_phased * cos_phi - L_phi = integrand_x + integrand_y + contrib_x = -Mx_integrated * sin_phi + contrib_y = +My_integrated * cos_phi + L_phi = contrib_x + contrib_y return N_theta, N_phi, L_theta, L_phi From 8de2bbb4e660073c4d43064fa5454a800624fd13 Mon Sep 17 00:00:00 2001 From: tylerflex Date: Tue, 9 Nov 2021 11:10:58 -0800 Subject: [PATCH 3/3] near2far up to date with current version, awaiting integration --- .pylintrc | 2 +- tidy3d/convert.py | 2 +- tidy3d/plugins/near2far/near2far.py | 122 +++++++++++------------- tidy3d/plugins/near2far/near2far_new.py | 42 -------- 4 files changed, 57 insertions(+), 111 deletions(-) delete mode 100644 tidy3d/plugins/near2far/near2far_new.py diff --git a/.pylintrc b/.pylintrc index 2482c1ed8d..5533de9d3c 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,7 +1,7 @@ [MASTER] extension-pkg-allow-list=pydantic ignore=material_library.py, plugins -good-names=ax, im, Lx, Ly, Lz, x0, y0, z0, x, y, z, f, t, y1, y2, x1, x2, xs, ys, zs, Ax, Nx, Ny, Nz, dl, rr, E, H, xx, yy, zz, dx, dy, Jx, Jy, Jz, Ex, Ey, Ez, Mx, My, Mz, Hx, Hy, Hz, dz, e, fp, dt, a, c, +good-names=ax, im, Lx, Ly, Lz, x0, y0, z0, x, y, z, f, t, y1, y2, x1, x2, xs, ys, zs, Ax, Nx, Ny, Nz, dl, rr, E, H, xx, yy, zz, dx, dy, Jx, Jy, Jz, Ex, Ey, Ez, Mx, My, Mz, Hx, Hy, Hz, dz, e, fp, dt, a, c, k0, Jx_k, Jy_k, My_k, Mx_k, N_theta, N_phi, L_theta, L_phi [BASIC] diff --git a/tidy3d/convert.py b/tidy3d/convert.py index 708af10e5e..1f91c4ce0e 100644 --- a/tidy3d/convert.py +++ b/tidy3d/convert.py @@ -359,7 +359,7 @@ def old_json_monitors(sim: Simulation) -> Dict: { "type": "FrequencyMonitor", "store": store, - "interpolate": True, + "interpolate": False, } ) elif isinstance(monitor, FieldTimeMonitor): diff --git a/tidy3d/plugins/near2far/near2far.py b/tidy3d/plugins/near2far/near2far.py index 6882caaad7..99ad82f8e5 100644 --- a/tidy3d/plugins/near2far/near2far.py +++ b/tidy3d/plugins/near2far/near2far.py @@ -3,14 +3,16 @@ import numpy as np from ...constants import C_0, ETA_0 -from ...components.data import FieldData, SimulationData +from ...components.data import SimulationData from ...log import SetupError +# TODO: implement new version with simulation.discretize + class Near2Far: """Near field to far field transformation tool.""" - def __init__(self, sim_data : SimulationData, mon_name: str, frequency : float): + def __init__(self, sim_data: SimulationData, mon_name: str, frequency: float): """Constructs near field to far field transformation object from monitor data. Parameters @@ -23,44 +25,50 @@ def __init__(self, sim_data : SimulationData, mon_name: str, frequency : float): frequency : float Frequency to select from the :class:`.FieldMonitor` to use for projection. Must be a frequency stored in the :class:`FieldMonitor`. - - """ try: field_data = sim_data[mon_name] except Exception as e: - raise SetupError(f"No data for monitor named '{mon_name}' found in supplied sim_data.") from e + raise SetupError( + f"No data for monitor named '{mon_name}' " "found in supplied sim_data." + ) from e - if any(field_name not in field_data for field_name in ('Ex', 'Ey', 'Ez', 'Hx', 'Hy', 'Hz')): + if any(field_name not in field_data for field_name in ("Ex", "Ey", "Hx", "Hy", "Ez")): raise SetupError(f"Monitor named '{mon_name}' doesn't store all field values") try: - self.Ex = field_data['Ex'].sel(f=frequency) - self.Ey = field_data['Ey'].sel(f=frequency) - self.Ez = field_data['Ez'].sel(f=frequency) - self.Hx = field_data['Hx'].sel(f=frequency) - self.Hy = field_data['Hy'].sel(f=frequency) - self.Hz = field_data['Hz'].sel(f=frequency) + Ex = field_data["Ex"].sel(f=frequency) + Ey = field_data["Ey"].sel(f=frequency) + # self.Ez = field_data['Ez'].sel(f=frequency) + Hx = field_data["Hx"].sel(f=frequency) + Hy = field_data["Hy"].sel(f=frequency) + Hz = field_data["Hz"].sel(f=frequency) except Exception as e: - raise SetupError(f"Frequency {frequency} not found in all fields from monitor '{mon_name}'.") from e + raise SetupError( + f"Frequency {frequency} not found in all fields " f"from monitor '{mon_name}'." + ) from e self.k0 = 2 * np.pi * frequency / C_0 - # note: assuming uniform grid - self.dx = np.mean(np.diff(self.Hz.x.values)) - self.dy = np.mean(np.diff(self.Hz.y.values)) + # grid sizes + self.dx = np.mean(np.diff(Hz.x.values)) + self.dy = np.mean(np.diff(Hz.y.values)) - self.xx_Jx, self.yy_Jx = np.meshgrid(self.Hy.x.values, self.Hy.y.values, indexing="ij") - self.xx_Jy, self.yy_Jy = np.meshgrid(self.Hx.x.values, self.Hx.y.values, indexing="ij") - self.xx_Mx, self.yy_Mx = np.meshgrid(self.Ey.x.values, self.Ey.y.values, indexing="ij") - self.xx_My, self.yy_My = np.meshgrid(self.Ex.x.values, self.Ex.y.values, indexing="ij") + # interpolate to centers + x_centers = Hz.x.values + y_centers = Hz.y.values + Ex = Ex.interp(x=x_centers, y=y_centers) + Ey = Ey.interp(x=x_centers, y=y_centers) + Hx = Hx.interp(x=x_centers, y=y_centers) + Hy = Hy.interp(x=x_centers, y=y_centers) + self.xx, self.yy = np.meshgrid(x_centers, y_centers, indexing="ij") # compute equivalent sources - self.Jx = -np.squeeze(self.Hy.values) - self.Jy = np.squeeze(self.Hx.values) - self.Mx = np.squeeze(self.Ey.values) - self.My = -np.squeeze(self.Ex.values) + self.Jx = -np.squeeze(Hy.values) + self.Jy = np.squeeze(Hx.values) + self.Mx = np.squeeze(Ey.values) + self.My = -np.squeeze(Ex.values) def _radiation_vectors(self, theta, phi): """Compute radiation vectors at an angle in spherical coordinates @@ -79,59 +87,32 @@ def _radiation_vectors(self, theta, phi): """ # precompute trig functions and add extra dimensions - theta = np.array(theta) - phi = np.array(phi) - sin_theta = np.sin(theta).reshape((-1, 1, 1)) - cos_theta = np.cos(theta).reshape((-1, 1, 1)) - sin_phi = np.sin(phi).reshape((-1, 1, 1)) - cos_phi = np.cos(phi).reshape((-1, 1, 1)) + sin_theta = np.sin(theta) + cos_theta = np.cos(theta) + sin_phi = np.sin(phi) + cos_phi = np.cos(phi) # precompute fourier transform phase term {dx dy e^(ikrcos(psi))} - FT_phase_x_Jx = np.exp(1j * self.k0 * self.xx_Jx * sin_theta * cos_phi) - FT_phase_y_Jx = np.exp(1j * self.k0 * self.yy_Jx * sin_theta * sin_phi) - FT_phase_Jx = self.dx * self.dy * FT_phase_x_Jx * FT_phase_y_Jx - Jx_integrated = np.sum(self.Jx * FT_phase_Jx, axis=(-2, -1)) - - FT_phase_x_Jy = np.exp(1j * self.k0 * self.xx_Jy * sin_theta * cos_phi) - FT_phase_y_Jy = np.exp(1j * self.k0 * self.yy_Jy * sin_theta * sin_phi) - FT_phase_Jy = self.dx * self.dy * FT_phase_x_Jy * FT_phase_y_Jy - Jy_integrated = np.sum(self.Jy * FT_phase_Jy, axis=(-2, -1)) - - FT_phase_x_Mx = np.exp(1j * self.k0 * self.xx_Mx * sin_theta * cos_phi) - FT_phase_y_Mx = np.exp(1j * self.k0 * self.yy_Mx * sin_theta * sin_phi) - FT_phase_Mx = self.dx * self.dy * FT_phase_x_Mx * FT_phase_y_Mx - Mx_integrated = np.sum(self.Mx * FT_phase_Mx, axis=(-2, -1)) - - FT_phase_x_My = np.exp(1j * self.k0 * self.xx_My * sin_theta * cos_phi) - FT_phase_y_My = np.exp(1j * self.k0 * self.yy_My * sin_theta * sin_phi) - FT_phase_My = self.dx * self.dy * FT_phase_x_My * FT_phase_y_My - My_integrated = np.sum(self.My * FT_phase_My, axis=(-2, -1)) - - # get rid of extra dimensions - cos_phi = np.squeeze(cos_phi) - sin_phi = np.squeeze(sin_phi) - cos_theta = np.squeeze(cos_theta) - sin_theta = np.squeeze(sin_theta) + phase_x = np.exp(1j * self.k0 * self.xx * sin_theta * cos_phi) + phase_y = np.exp(1j * self.k0 * self.yy * sin_theta * cos_phi) + phase = self.dx * self.dy * phase_x * phase_y + + Jx_k = np.sum(self.Jx * phase) + Jy_k = np.sum(self.Jy * phase) + Mx_k = np.sum(self.Mx * phase) + My_k = np.sum(self.My * phase) # N_theta (8.33a) - contrib_x = +Jx_integrated * cos_theta * cos_phi - contrib_y = +Jy_integrated * cos_theta * sin_phi - N_theta = contrib_x + contrib_y + N_theta = Jx_k * cos_theta * cos_phi + Jy_k * cos_theta * sin_phi # N_phi (8.33b) - contrib_x = -Jx_integrated * sin_phi - contrib_y = +Jy_integrated * cos_phi - N_phi = contrib_x + contrib_y + N_phi = -Jx_k * sin_phi + Jy_k * cos_phi # L_theta (8.34a) - contrib_x = +Mx_integrated * cos_theta * cos_phi - contrib_y = +My_integrated * cos_theta * sin_phi - L_theta = contrib_x + contrib_y + L_theta = Mx_k * cos_theta * cos_phi + My_k * cos_theta * sin_phi # L_phi (8.34b) - contrib_x = -Mx_integrated * sin_phi - contrib_y = +My_integrated * cos_phi - L_phi = contrib_x + contrib_y + L_phi = -Mx_k * sin_phi + My_k * cos_phi return N_theta, N_phi, L_theta, L_phi @@ -154,16 +135,23 @@ def fields_spherical(self, r, theta, phi): (Er, Etheta, Ephi), (Hr, Htheta, Hphi), fields in polar coordinates. """ + + # project radiation vectors to distance r away for given angles N_theta, N_phi, L_theta, L_phi = self._radiation_vectors(theta, phi) scalar_proj_r = 1j * self.k0 * np.exp(-1j * self.k0 * r) / (4 * np.pi * r) + + # assemble E felds E_theta = -scalar_proj_r * (L_phi + ETA_0 * N_theta) E_phi = scalar_proj_r * (L_theta - ETA_0 * N_phi) E_r = np.zeros_like(E_phi) E = np.stack((E_r, E_theta, E_phi)) + + # assemble H fields H_theta = -E_phi / ETA_0 H_phi = E_theta / ETA_0 H_r = np.zeros_like(H_phi) H = np.stack((H_r, H_theta, H_phi)) + return E, H def fields_cartesian(self, x, y, z): diff --git a/tidy3d/plugins/near2far/near2far_new.py b/tidy3d/plugins/near2far/near2far_new.py deleted file mode 100644 index 61727f030c..0000000000 --- a/tidy3d/plugins/near2far/near2far_new.py +++ /dev/null @@ -1,42 +0,0 @@ -"""Near field to far field transformation plugin.""" -from typing import Dict, Tuple - -import numpy as np -import pydantic as pd -import xarray as xr - -from ...constants import C_0, ETA_0 -from ...components.data import CollectionData, FieldData -from ...components import FieldMonitor -from ...log import SetupError - - -class Near2Far: - """tool for projecting from near field data to far field data""" - - def __init__(self, near_field_data: Dict[str, FieldData], frequency: float): - """create a near2far object""" - - for name, field_data in near_field_data.items(): - pass - # make sure near_field_data is planar. - # make sure near_field_data has planar E, H components. - # make sure frequency is contained in near_field_data. - # construct the J, H data on the surface at frequency - - def _compute_radiation_vectors( - self, theta: float, phi: float, axis: int - ) -> Tuple[CollectionData, CollectionData]: - """computes N and L vectors for theta and phi values using the near field J, M.""" - - def project_fields(self, x: float, y: float, z: float) -> FieldData: - """Project to x,y,z,frequency points described by far field monitor.""" - - def scattered_power(self, phis: float, thetas: float, axis: int) -> CollectionData: - """Get power scattered to various angles.""" - - # for name, field_data in near_field_data.items(): - # try: - # field_data.sel(f=val) - # except Exception as e: - # raise SetupError(f"frequency {frequency} not found in near field data named {name}")