tidy3d.DiffractionData#
- class DiffractionData[source]#
Bases:
AbstractFieldProjectionData
Data for a
DiffractionMonitor
: complex components of diffracted far fields.- Parameters:
attrs (dict = {}) – Dictionary storing arbitrary metadata for a Tidy3D object. This dictionary can be freely used by the user for storing data without affecting the operation of Tidy3D as it is not used internally. Note that, unlike regular Tidy3D fields,
attrs
are mutable. For example, the following is allowed for setting anattr
obj.attrs['foo'] = bar
. Also note that Tidy3D` will raise aTypeError
ifattrs
contain objects that can not be serialized. One can check ifattrs
are serializable by callingobj.json()
.monitor (DiffractionMonitor) – Diffraction monitor associated with the data.
Er (DiffractionDataArray) – Spatial distribution of r-component of the electric field.
Etheta (DiffractionDataArray) – Spatial distribution of the theta-component of the electric field.
Ephi (DiffractionDataArray) – Spatial distribution of phi-component of the electric field.
Hr (DiffractionDataArray) – Spatial distribution of r-component of the magnetic field.
Htheta (DiffractionDataArray) – Spatial distribution of theta-component of the magnetic field.
Hphi (DiffractionDataArray) – Spatial distribution of phi-component of the magnetic field.
medium (Union[Medium, AnisotropicMedium, PECMedium, PoleResidue, Sellmeier, Lorentz, Debye, Drude, FullyAnisotropicMedium, CustomMedium, CustomPoleResidue, CustomSellmeier, CustomLorentz, CustomDebye, CustomDrude, CustomAnisotropicMedium, PerturbationMedium, PerturbationPoleResidue, Medium2D, AnisotropicMediumFromMedium2D] = Medium(attrs={}, name=None, frequency_range=None, allow_gain=False, nonlinear_spec=None, modulation_spec=None, heat_spec=None, type='Medium', permittivity=1.0, conductivity=0.0)) – Background medium through which to project fields.
is_2d_simulation (bool = False) – Indicates whether the monitor data is for a 2D simulation.
sim_size (Tuple[float, float]) – [units = um]. Size of the near field in the local x and y directions.
bloch_vecs (Tuple[float, float]) – Bloch vectors along the local x and y directions in units of
2 * pi / (simulation size along the respective dimension)
.
Note
The diffraction data are separated into S and P polarizations. At normal incidence when S and P are undefined, P(S) corresponds to
Ey``(``Ez
) polarization for monitor normal to x, P(S) corresponds toEx``(``Ez
) polarization for monitor normal to y, and P(S) corresponds toEx``(``Ey
) polarization for monitor normal to z.Example
>>> from tidy3d import DiffractionDataArray >>> f = np.linspace(1e14, 2e14, 10) >>> orders_x = list(range(-4, 5)) >>> orders_y = list(range(-6, 7)) >>> pol = ["s", "p"] >>> coords = dict(orders_x=orders_x, orders_y=orders_y, f=f) >>> values = (1+1j) * np.random.random((len(orders_x), len(orders_y), len(f))) >>> field = DiffractionDataArray(values, coords=coords) >>> monitor = DiffractionMonitor( ... center=(1,2,3), size=(np.inf,np.inf,0), freqs=f, name='diffraction' ... ) >>> data = DiffractionData( ... monitor=monitor, sim_size=[1,1], bloch_vecs=[1,2], ... Etheta=field, Ephi=field, Er=field, ... Htheta=field, Hphi=field, Hr=field, ... )
Attributes
Complex power amplitude in each order for 's' and 'p' polarizations, normalized so that the power carried by the wave of that order and polarization equals
abs(amps)^2
.The (theta, phi) angles corresponding to each allowed pair of diffraction orders storeds as data arrays.
Coordinates grid for the fields in the spherical system.
Get all field components in Cartesian coordinates relative to the monitor's local origin for all allowed diffraction orders and frequencies specified in the
DiffractionMonitor
.Get all field components in spherical coordinates relative to the monitor's local origin for all allowed diffraction orders and frequencies specified in the
DiffractionMonitor
.Allowed orders along x.
Allowed orders along y.
Total power in each order, summed over both polarizations.
Get the normalized "ux" and "uy" reciprocal vectors.
Normalized wave vector along x relative to
local_origin
and oriented with respect tomonitor.normal_dir
, normalized by the wave number in the projection medium.Normalized wave vector along y relative to
local_origin
and oriented with respect tomonitor.normal_dir
, normalized by the wave number in the projection medium.Methods
adjoint_source_amp
(amp, fwidth)Generate an adjoint
PlaneWave
for a single amplitude.compute_angles
(reciprocal_vectors)Compute the polar and azimuth angles associated with the given reciprocal vectors.
make_adjoint_sources
(dataset_names, fwidth)Get all adjoint sources for the
DiffractionMonitor.amps
.make_adjoint_sources_amps
(fwidth)Make adjoint sources for outputs that depend on DiffractionData.`amps`.
reciprocal_coords
(orders, size, bloch_vec, ...)Get the normalized "u" reciprocal coords for a vector of orders, size, and bloch vec.
shifted_orders
(orders, bloch_vec)Diffraction orders shifted by the Bloch vector.
Inherited Common Usage
- monitor#
- Er#
- Etheta#
- Ephi#
- Hr#
- Htheta#
- Hphi#
- sim_size#
- bloch_vecs#
- static reciprocal_coords(orders, size, bloch_vec, f, medium)[source]#
Get the normalized “u” reciprocal coords for a vector of orders, size, and bloch vec.
- static compute_angles(reciprocal_vectors)[source]#
Compute the polar and azimuth angles associated with the given reciprocal vectors.
- property coords_spherical#
Coordinates grid for the fields in the spherical system.
- property orders_x#
Allowed orders along x.
- property orders_y#
Allowed orders along y.
- property reciprocal_vectors#
Get the normalized “ux” and “uy” reciprocal vectors.
- property ux#
Normalized wave vector along x relative to
local_origin
and oriented with respect tomonitor.normal_dir
, normalized by the wave number in the projection medium.
- property uy#
Normalized wave vector along y relative to
local_origin
and oriented with respect tomonitor.normal_dir
, normalized by the wave number in the projection medium.
- property angles#
The (theta, phi) angles corresponding to each allowed pair of diffraction orders storeds as data arrays. Disallowed angles are set to
np.nan
.
- property amps#
Complex power amplitude in each order for ‘s’ and ‘p’ polarizations, normalized so that the power carried by the wave of that order and polarization equals
abs(amps)^2
.
- property power#
Total power in each order, summed over both polarizations.
- property fields_spherical#
Get all field components in spherical coordinates relative to the monitor’s local origin for all allowed diffraction orders and frequencies specified in the
DiffractionMonitor
.- Returns:
xarray dataset containing (
Er
,Etheta
,Ephi
,Hr
,Htheta
,Hphi
) in spherical coordinates.- Return type:
xarray.Dataset
- property fields_cartesian#
Get all field components in Cartesian coordinates relative to the monitor’s local origin for all allowed diffraction orders and frequencies specified in the
DiffractionMonitor
.- Returns:
xarray dataset containing (
Ex
,Ey
,Ez
,Hx
,Hy
,Hz
) in Cartesian coordinates.- Return type:
xarray.Dataset
- make_adjoint_sources(dataset_names, fwidth)[source]#
Get all adjoint sources for the
DiffractionMonitor.amps
.
- make_adjoint_sources_amps(fwidth)[source]#
Make adjoint sources for outputs that depend on DiffractionData.`amps`.
- __hash__()#
Hash method.