FDTD, MODE
farfieldsettings - Script command
Sets the parameters available in the Far field settings window for far field calculations. To get the available parameters for far field settings, as is shown below, right click on a frequency-domain field monitor and visualize the far field. then select the Far field settings.
|
Syntax | Description |
---|---|
farfieldsettings("property", value); | Set the far field filter settings for far field calculations. These settings are applied to all far field projections. Value can be a number or string. This function does not return any data. |
Example
farfieldsettings("far field filter",0.2);farfieldsettings("override near field mesh",1); farfieldsettings("near field samples per wavelength",5);
farfieldfilter - Script command
Sets or gets the filter width for far field filter which is used to remove ripples in the far field projection due to clipping of the near fields. It should be used when the near fields at the edge of the monitor are small but not precisely zero.
The bumpy blue line of the figure shows the near field electric field that will be used for a far field projection. In this case, the field does not go to zero at the edge of the monitor, which will lead to ripples in the far field projection. The green line shows the spatial filter that will be applied to the fields, ensuring they go to zero. The filter parameter defines the width of the filter by the following formula: α=(a)/(a+b).
Syntax | Description |
---|---|
out = farfieldfilter; | Get the current far field filter setting. |
farfieldfilter(α); | Set the current far field filter setting. α=(a)/(a+b). The far field filter has a single input parameter, which is a number between 0 and 1. By default, it is 0, which turns the filter off. This filter is applied to all far field projections. |
Note: Periodic structures The far field filter option should not be used for periodic structures. Set it to zero when using the 'assume periodic' option. |
Example
Far field projection - spatial filtering
farfield2d - Script command
Projects a given power or field profile monitor or a rectilinear dataset to the far field to a 1 meter radius semi-circle. The electric field intensity |E| 2 is returned. Farfield2d does not use a set of linearly spaced angles for the projection, use farfieldangle - Script command to get the appropriate angle vector.
Syntax | Description |
---|---|
out = farfield2d("mname", f, n, illumination, periods, index, direction); | Projects a given power or field profile monitor to the far field at the specified frequency points. The result is an NxM matrix where the first dimension is the resolution of the far field projection, and the second dimension is the number of frequency points projected. |
out = farfield2d(dataset, f, n, illumination, periods, index, direction); | Projects a given rectilinear dataset to the far field at the specified frequency points. The result is an NxM matrix where the first dimension is the resolution of the far field projection, and the second dimension is the number of frequency points projected. |
Parameter | Default value | Type | Description | |
---|---|---|---|---|
mname | required | string | Name of the monitor | |
dataset | required | dataset | Rectilinear dataset containing both E and H | |
f | optional | 1 | vector | Index of the desired frequency point. f can be a single value, or a vector of frequency points. Multithreaded projection was introduced since R2016b. |
n | optional | 2000 | number | The number of points in the far field. |
illumination | optional | 1 | number | For periodic structures Gaussian illumination: 1 Plane wave illumination: 2 |
periods | optional | 1 | number | number of periods to be used |
index | optional | value at monitor center | number | The index of the material to use for the projection. |
direction | optional | direction of max power flow | number | Direction: this can be +1 or -1. |
Example
This example plots the far field projection of a 1D monitor called monitor. In this example the second frequency point is projected. If the monitor only contains data at one frequency, the second argument is not required.
E2=farfield2d("monitor",2,501); theta=farfieldangle("monitor",2,501); plot(theta,E2,"angle (deg)","|E|^2 far field");
The following example plots the far field projection of a rectilinear dataset. Here, the dataset is from a 1D monitor.
dataset=getresult("monitor", "E"); dataset.addattribute("H",getattribute(getresult("monitor","H"),"H")); E2=farfield2d(dataset,2,501); theta=farfieldangle(dataset,2,501); plot(theta,E2,"angle (deg)","|E|^2 far field");
For additional examples see Far field projection .
farfieldvector2d - Script command
Projects a given power or field profile monitor or a rectilinear dataset to the far field to a 1 meter radius semi-circle. This is similar to the farfield2d script command except the complex electric fields are returned, rather than field intensity. The data is returned as matrix of NxP if one frequency point is projected, or NxPx3 when multiple frequency points are projected where N is the resolution of the far field projection, P is the number frequency points projected, and the last index refers to Ex, Ey and Ez which are the complex components of the electric field vector in Cartesian coordinates.
Syntax | Description |
---|---|
out = farfieldvector2d( "mname",...); | Returns the Cartesian complex electric fields. Same arguments as farfield2d. |
out = farfieldvector2d( dataset,...); | Returns the Cartesian complex electric fields. Same arguments as farfield2d. |
Example
This example plots the amplitude of the Ex component of the far field projection of a 1D monitor called "monitor". In this example the second frequency point is projected. If the monitor only contains data at one frequency, the second argument is not required. For the example of far field projection of a rectilinear dataset see farfield2d.
E=farfieldvector2d("monitor",2,501); Ex = abs(pinch(E,2,1)); # amplitude of Ex theta=farfieldangle("monitor",2,501); plot(theta,Ex,"angle (deg)","Ex far field");
For additional examples see Far field projection .
farfieldpolar2d - Script command
Projects a given power or field profile monitor or a rectilinear dataset to the far field to a 1 meter radius semi-circle. This is similar to the farfield2d script command except the complex electric fields are returned, rather than field intensity. The data is returned as matrix of NxP if one frequency point is projected, or NxPx3 when multiple frequency points are projected where N is the resolution of the far field projection, P is the number frequency points projected, and the last index refers to E r , E θ and E z , in cylindrical coordinates. For TM simulations, this function gives precisely the result of farfieldvector2d because the only non-zero field component is Ez.
Syntax | Description |
---|---|
out = farfieldpolar2d( "mname",...); | Returns the polar complex electric fields. Same arguments as farfield2d. |
out = farfieldpolar2d( dataset,...); | Returns the polar complex electric fields. Same arguments as farfield2d. |
Example
This example plots the amplitude of the Er component of the far field projection of a 1D monitor called "monitor". In this example the second frequency point is projected. If the monitor only contains data at one frequency, the second argument is not required. For the example of far field projection of a rectilinear dataset see farfield2d.
E=farfieldpolar2d("monitor",2,501); Er = abs(pinch(E,2,1)); # amplitude of Er theta=farfieldangle("monitor",2,501); plot(theta,Er,"angle (deg)","Er far field");
For additional examples see Far field projection.
farfieldangle - Script command
Returns the vector of angles, in degrees, corresponding to the data from farfield2d for a 2D simulation. Used for 2D simulations. This is required because the farfield2d does not use a set of linearly spaced angles for the projection. It is often useful to re-interpolate the data onto a set of linearly spaced angles using the interp or spline functions.
Syntax | Description |
---|---|
theta = farfieldangle( "mname", f, n, index); | Returns the matrix of angles corresponding to the data in farfield2d |
theta = farfieldangle( dataset, f, n, index); | Returns the matrix of angles corresponding to the data in farfield2d |
Parameter | Default value | Type | Description | |
---|---|---|---|---|
mname | required | string | Name of the monitor from which far field is calculated | |
dataset | required | dataset | Rectilinear dataset containing both E and H | |
f | optional | 1 | vector | Index of the desired frequency point. This can be a single number or a vector. If f is a vector, the second dimension of theta will match the length of the vector of frequency points. Multithreaded projection was introduced since R2016b. |
n | optional | 2000 | number | The number of points in the far field. |
index | optional | value at monitor center | number | The index of the material to use for the projection. |
Example
This example plots the far field projection of a 1D monitor called monitor. In this example the second frequency point is projected. If the monitor only contains data at one frequency, the second argument is not required. For the example of far field projection of a rectilinear dataset see farfield2d.
E2=farfield2d("monitor",2,501); theta=farfieldangle("monitor",2,501); plot(theta,E2,"angle (deg)","|E|^2 far field");
For additional examples see Far field projection .
farfield3d - Script command
Projects a given power or field profile monitor or a rectilinear dataset to the far field in a 3D simulation. The electric field intensity |E| 2 is returned.
Syntax | Description |
---|---|
out = farfield3d("mname",f, na, nb, illumination, periodsa, periodsb, index, direction); | Projects a given power or field profile monitor to the far field. This returns an NxM matrix if 1 frequency point is projected, or a NxMxP matrix if more than 1 frequency point is projected, where N and M correspond to the resolution of the projection (na, and nb), and P corresponds to the number of frequency points projected. |
out = farfield3d(dataset,f, na, nb, illumination, periodsa, periodsb, index, direction); | Projects a given rectilinear dataset to the far field. This returns an NxM matrix if 1 frequency point is projected, or a NxMxP matrix if more than 1 frequency point is projected, where N and M correspond to the resolution of the projection (na, and nb), and P corresponds to the number of frequency points projected. |
Parameter | Default value | Type | Description | |
---|---|---|---|---|
mname | required | string | Name of the monitor | |
dataset | required | dataset | Rectilinear dataset containing both E and H | |
f | optional | 1 | vector | Index of the desired frequency point. This can be a single number or a vector. Multithreaded projection to allow multiple frequency points to be projected simultaneously was introduced in R2016b. |
na | optional | 150 | number | The number of points in the far field. |
nb | optional | 150 | number | The number of points in the far field. |
illumination | optional | 1 | number | For periodic structures. Gaussian illumination: 1 Plane wave illumination: 2 |
periodsa | optional | 1 | number | number of periods to be used for periodic illumination |
periodsb | optional | 1 | number | number of periods to be used for periodic illumination |
index | optional | value at monitor center | number | The index of the material to use for the projection. |
direction | optional | direction of max power flow | number | Direction: this can be +1 or -1. |
The following table summarizes how to interpret the ux, uy coordinate vectors and periods input properties for various monitor orientations.
Monitor orientation | Monitor surface normal | 'na', 'ux', 'periods a' correspond to | 'nb', 'uy', 'periods b' correspond to |
---|---|---|---|
XY plane | Z | x axis | y axis |
XZ plane | Y | x axis | z axis |
YZ plane | X | y axis | z axis |
Example
This example images the far field projection of a 2D monitor called monitor. In this example the second frequency point is projected. If the monitor only contains data at one frequency, the second argument is not required.
E = farfield3d("monitor",2); ux = farfieldux("monitor",2); uy = farfielduy("monitor",2); image(ux,uy,E,"","","title","polar");
The following example images the far field projection of a rectilinear dataset. Here, the dataset is from a 2D monitor.
dataset=getresult("monitor", "E"); dataset.addattribute("H",getattribute(getresult("monitor","H"),"H")); E = farfield3d(dataset,2); ux = farfieldux(dataset,2); uy = farfielduy(dataset,2); image(ux,uy,E,"","","title","polar");
farfieldvector3d - Script command
The function farfieldvector3d is similar to farfield3d, but it returns the complex electric fields, rather than field intensity. The data is returned as matrix of NxMx3 (if one frequency point is projected) or NxMxPx3 (if more than 1 frequency point is projected), where N and M are spatial indices, P is the number of frequency points, and the last index refers to Ex, Ey and Ez. The components Ex, Ey and Ez are the complex components of the electric field vector. See the farfield3d documentation for information on interpreting ux, uy, na, nb for various monitor orientations.
Syntax | Description |
---|---|
out = farfieldvector3d( "mname",...); | Returns the cartesian complex electric fields. Same arguments as farfield3d. |
out = farfieldvector3d( dataset,...); | Returns the cartesian complex electric fields. Same arguments as farfield3d. |
Example
See example in the farfield3d function description.
farfieldpolar3d - Script command
The function farfieldpolar3d is similar to farfield3d, but it returns the complex electric fields, rather than field intensity. The data is returned as matrix of NxMx3 (if one frequency point is projected) or NxMxPx3 (if more than 1 frequency point is projected), where N and M are spatial indices, P is the number of frequency points, and the last index refers to E r , E θ and E φ , in spherical coordinates. The components E r , E θ and E φ are the complex components of the electric field vector. See the farfield3d documentation for information on interpreting ux, uy, na, nb for various monitor orientations.
Note: When viewing far fields from the GUI with the visualizer, three Attributes are available: E2, Ep, Es. E2 corresponds to |E|^2, Ep to Etheta, and Es to Ephi.
Syntax | Description |
---|---|
out = farfieldpolar3d( "mname",...); | Returns the spherical complex electric fields. Same arguments as farfield3d. |
out = farfieldpolar3d( dataset,...); | Returns the spherical complex electric fields. Same arguments as farfield3d. |
Example
See example in the farfield3d function description.
farfieldux - Script command
Returns the matrix of ux corresponding to the far field data from farfield3d for a 3D simulation. See the farfield3d documentation for information on interpreting ux, uy, na, nb for various monitor orientations.
Syntax | Description |
---|---|
out = farfieldux("mname",f,na,nb,index); | See farfield3d help. Arguments are same as for farfield3d. Note that the result is an NxM matrix where N is the spatial index and M is the number of frequency points. |
out = farfieldux(dataset,f,na,nb,index); | See farfield3d help. Arguments are same as for farfield3d. Note that the result is an NxM matrix where N is the spatial index and M is the number of frequency points. |
Example
See example in the farfield3d function description.
farfielduy - Script command
Returns the matrix of uy corresponding to the far field data from farfield3d for a 3D simulation. See the farfield3d documentation for information on interpreting ux, uy, na, nb for various monitor orientations.
Syntax | Description |
---|---|
out = farfielduy("mname",f,na,nb,index); | See farfield3d help. Arguments are same as for farfield3d. Note that the result is an NxM matrix where N is the spatial index and M is the number of frequency points. |
out = farfielduy(dataset,f,na,nb,index); | See farfield3d help. Arguments are same as for farfield3d. Note that the result is an NxM matrix where N is the spatial index and M is the number of frequency points. |
Example
See example in the farfield3d function description.
farfieldspherical - Script command
Interpolates far field data (3D simulations) from E(ux,uy) to spherical coordinates E(theta,phi) 1D array. The far field projections functions generally return the projection as a function of ux,uy (direction cosines). farfieldspherical can be used to interpolate this data into the more common units of theta, phi. See the farfield3d documentation for information on interpreting ux, uy, na, nb for various monitor orientations.
Syntax | Description |
---|---|
out = farfieldspherical( E2, ux, uy, theta, phi); | Interpolate far field data to spherical coordinates. The output has a size of (MxN,1) |
Parameter | Default value | Type | Description | |
---|---|---|---|---|
E2 | required | matrix | E field data from farfield3d | |
ux | required | vector | ux data from farfieldux. Note that the result should be a vector, so it is sufficient to perform the farfieldux script command for only 1 frequency point. | |
uy | required | vector | uy data from farfielduy. Note that the result should be a vector, so it is sufficient to perform the farfieldux script command for only 1 frequency point. | |
theta | required | vector | theta vector, in degrees. Must have length M or 1. | |
phi | required | vector | phi vector, in degrees. Must have length N or 1. |
Example
Create a plot of the E2_far vs theta, for phi=0.
m="Monitor1"; # Monitor name res = 201; # projection resolution E2 = farfield3d(m,1,res,res); ux = farfieldux(m,1,res,res); uy = farfielduy(m,1,res,res); theta = linspace(-90,90,100); phi = 0; plot(theta, farfieldspherical(E2,ux,uy,theta,phi) ,"theta", "E^2", "E^2 at phi=0");
Interpolate field data to a grid of theta and phi angles.
theta = linspace(-90,90,10); phi = linspace(0,45,11); Theta = meshgridx(theta,phi); Phi = meshgridy(theta,phi); E2_angle = farfieldspherical(E2,ux,uy,Theta,Phi); E2_angle = reshape(E2_angle, [length(theta), length(phi)]); image(theta, phi, E2_angle, "theta","phi","E2");
farfieldexact2d - Script command
This function projects complete complex vector fields to specific locations. It is expected to be correct down to distances on the order of one wavelength. The projections from multiple monitors can be added to create a total far field projection - see Projections from a monitor box .
farfieldexact2d projects any surface to the grid points defined by the vectors x, y. If only E field is returned as the result, the data is returned in the form of a matrix that is of dimension NxMxPx3 where N is the length of the x vector, M is the length of the y vector, P is the number of frequency points, and the final index represents Ex, Ey, and Ez. Note that N and M can be 1; when they are both 1, the function is the same as farfieldexact. If both E and H fileds are returned, the data is returned as a dataset with the E and H fields packaged with the corresponding x,y, and frequency/wavelength.
Syntax | Description |
---|---|
out = farfieldexact2d( "mname", x, y, f, index); | Projects a given power or field profile monitor to the far field at grid points specified by the vectors x,y. Returns E field only. |
out = farfieldexact2d( dataset, x, y, f, index); | Projects a given rectilinear dataset to the far field at grid points specified by the vectors x,y. Returns E field only. |
out = farfieldexact2d( "mname", x, y, opt); | Projects a given power or field profile monitor to the far field at grid points specified by the vectors x,y. Returns E filed or E and H fields. Refer to the following table for the options. |
out = farfieldexact2d( dataset, x, y, opt); | Projects a given rectilinear dataset to the far field at grid points specified by the vectors x,y. Returns E filed or E and H fields. Refer to the following table for the options. |
Parameter | Default value | Type | Description | |
---|---|---|---|---|
mname | required | string | name of the monitor from which far field is calculated. | |
dataset | required | dataset | Rectilinear dataset containing both E and H | |
x | required | vector | x coordinates of the grid points where far field is calculated. | |
y | required | vector | y coordinates of the grid points where far field is calculated. | |
f | optional | 1 | vector | Index of the desired frequency point. This can be a single number or a vector. Multithreaded projection was introduced since R2016b. |
index | optional | index at monitor center | number | The index of the material to use for the projection. |
opt | optional | struct | the 'opt' parameter includes the following options: "field": This parameter is optional. It defines the return field, can either be "E" or "E and H". "f": This parameter is optional. It defines the index of the desired frequency point. This can be a single number or a vector. Multi-threaded projection was introduced since R2016b. "index": This parameter is optional. It defines the index of the material to use for the projection. |
Note: When using a dataset, the default value of the refractive index is 1.
Example
See example in farfieldexact3d function description.
farfieldexact3d - Script command
The three dimension form of farfieldexact2d. This function projects complete complex vector fields to specific locations. It is expected to be correct down to distances on the order of one wavelength. The projections from multiple monitors can be added to create a total far field projection - see Projections from a monitor box .
farfieldexact3d projects any surface to the grid points defined by the vectors x,y and z. If only E field is returned as the result, the data is returned in a matrix of dimension NxMxKx3 if one frequency point is projected, and NxMxKx3xP if more than one frequency point is projected where N is the length of the vector x, M the length of the vector y, K is the length of the vector z, P is the number of frequency points, and the fourth index represents Ex, Ey, and Ez. Note that N, M and K can be 1, and when they are all 1, the function is the same as farfieldexact. If both E and H fileds are returned, the data is returned as a dataset with the E and H fields packaged with the corresponding x,y,z and frequency/wavelength.
Syntax | Description |
---|---|
out = farfieldexact3d( "mname", x, y, z, f, index); | Projects a given power or field profile monitor to the far field at grid points specified by the vectors x,y,z. Returns E field only. |
out = farfieldexact3d( dataset, x, y, z, f, index); | Projects a given rectilinear dataset to the far field at grid points specified by the vectors x,y,z. Returns E field only. |
out = farfieldexact3d( "mname", x, y, z, opt); | Projects a given power or field profile monitor to the far field at grid points specified by the vectors x,y,z. Returns E field or E and H fields. Refer to the table below for the options. |
out = farfieldexact3d( dataset, x, y, z, opt); | Projects a given rectilinear dataset to the far field at grid points specified by the vectors x,y,z. Returns E field or E and H fields. Refer to the table below for the options. |
Parameter | Default value | Type | Description | |
---|---|---|---|---|
mname | required | string | name of the monitor from which far field is calculated | |
x | required | vector | x coordinates of the grid points where far field is calculated | |
y | required | vector | y coordinates of the grid points where far field is calculated | |
z | required | vector | z coordinates of the grid points where far field is calculated | |
f | optional | 1 | vector | Index of the desired frequency point. This can be a single number or a vector. Multithreaded projection was introduced since R2016b. |
index | optional | value at monitor centre | number | The index of the material to use for the projection. |
opt | optional | struct | the 'opt' parameter includes the following options: "field": This parameter is optional. It defines the return field, can either be "E" or "E and H". "f": This parameter is optional. It defines the index of the desired frequency point. This can be a single number or a vector. Multi-threaded projection was introduced since R2016b. "index": This parameter is optional. It defines the index of the material to use for the projection. |
Note: When using a dataset, the default value of the refractive index is 1.
Example
This 3D example calculates the far field electric field intensity on a 2mm x 2mm image plane located a distance of z=+1.5mm from the simulation region. For the example of far field projection of a rectilinear dataset see farfield3d.
mname="trans"; # Monitor name num=25; # resolution # define far field plane to image fields x=linspace(-1e-3,1e-3,num); y=x; z=1.5e-3; # compute far field E=farfieldexact3d(mname,x,y,z,{"field":"E"}); # select component Ex=pinch(E,4,1); Ey=pinch(E,4,2); Ez=pinch(E,4,3); # image intensity E2= abs(Ex)^2 + abs(Ey)^2 + abs(Ez)^2; image(x*1e3,y*1e3,E2,"x (mm)","y (mm)","Electric field at z=1.5mm from source");
The following example shows how farfieldexact and farfieldexact3d output data differently.
When x=[1 2], y=[1 2], z=[0],
farfieldexact: The result is a 2*3 matrix. First dimension is position;second is field component. This calculates the far field at the positions [1,1,0] and [2,2,0] .
farfielexact3d: The result is a 2*2*1*3 matrix. First three dimensions are positions; the fourth dimension is field component. This calculates the far field at the positions [x,y,z] = [1,1,0], [1,2,0], [2,1,0], [2,2,0].
x=1:2; y=1:2; z=0; m="monitor"; E_far=farfieldexact3d(m,x,y,z,{"field":"E"}); ?size(E_far); result: 2 2 1 3
farfieldexact - Script command
Projects complete complex vector fields to specific locations. It is expected to be correct down to distances on the order of one wavelength. The projections from multiple monitors can be added to create a total far field projection - see Projections from a monitor box .
farfieldexact projects any surface fields to a series of points defined by vector lists. The x,y, z coordinates of each evaluation point are taken element-by-element from the vector lists. i.e., the i-th point in a 2D simulation would be at [x(i),y(i)]. This command can return either the E field or the E and H fields of the projection.
3D
Vectors lists x,y,z must have the same length L or be length 1. When only the E field is returned, the data is returned in a matrix of dimension Lx3. The first index represents positions defined by one element from each of x,y, z. [x(i),y(i),z(i)]; the second index represents Ex, Ey, and Ez. When both E and H fields are returned, the data is returned as a dataset with the E and H fields packaged with the corresponding x,y,z and frequency/wavelength.
2D
Vector lists x, y must have the same length L or be length 1. When only the E field is returned, the data is returned in the form of a matrix that is of dimension Lx3. The first index represents positions defined by one element from each of x,y. [x(i),y(i)]; The second index represents Ex, Ey, and Ez. When both E and H fields are returned, the data is returned as a dataset with the E and H fields packaged with the corresponding x,y, and frequency/wavelength.
Syntax | Description |
---|---|
out = farfieldexact("mname", x, y, f, index); | 2D far field exact projection. Returns E field only. |
out = farfieldexact(dataset, x, y, f, index); | 2D far field exact projection. Returns E field only. |
out = farfieldexact("mname", x, y, opt); | 2D far field exact projection. Returns E field or E and H fields. Refer to the following table for the options. |
out = farfieldexact(dataset, x, y, opt); | 2D far field exact projection. Returns E field or E and H fields. Refer to the following table for the options. |
out = farfieldexact("mname", x, y, z, f, index); | 3D far field exact projection. Returns E field only. |
out = farfieldexact(dataset, x, y, z, f, index); | 3D far field exact projection. Returns E field only. |
out = farfieldexact("mname", x, y, z, opt); | 3D far field exact projection. Returns E field or E and H fields. Refer to the following table for the options |
out = farfieldexact(dataset, x, y, z, opt); | 3D far field exact projection. Returns E field or E and H fields. Refer to the following table for the options |
Parameter | Default | Default value | Type | Description |
---|---|---|---|---|
mname | required | string | name of the monitor from which far field is calculated | |
dataset | required | dataset | Rectilinear dataset containing both E and H | |
x | required | vector | x coordinates of points where far field is calculated. must have length L or 1. | |
y | required | vector | y coordinates of points where far field is calculated. must have length L or 1. | |
z | required | vector | z coordinates of points where far field is calculated. must have length L or 1. | |
f | optional | 1 | vector | Index of the desired frequency point. This can be a single number or a vector. Multithreaded projection was introduced since R2016b. |
index | optional | value at monitor centre | number | The index of the material to use for the projection. |
opt | optional | struct | the 'opt' parameter includes the following options: "field": This parameter is optional. It defines the return field, can either be "E" or "E and H". "f": This parameter is optional. It defines the index of the desired frequency point. This can be a single number or a vector. Multi-threaded projection was introduced since R2016b. "index": This parameter is optional. It defines the index of the material to use for the projection. |
Note: When using a dataset, the default value of the refractive index is 1.
Example
This example shows how to calculate |E|^2 and |H|^2 on a straight line at y=0, z=1, for x from -1 to 1 meters. For the example of far field projection of a rectilinear dataset see farfield3d.
# Define far field position vector res=100; x=linspace(-1,1,res); y=0; z=1; # do far field projection E_H_far=farfieldexact("monitor",x,y,z,{"field":"E and H", "f":1}); E_far = E_H_far.E; H_far = E_H_far.H; E2_far = sum(abs(E_far)^2,2); # E2 = |Ex|^2 + |Ey|^2 + |Ez|^2 H2_far = sum(abs(H_far)^2,2); # H2 = |Hx|^2 + |Hy|^2 + |Hz|^2 # plot results plot(x,E2_far,"x","y","|E|^2 on line at y=0, z=1"); plot(x,H2_far,"x","y","|H|^2 on line at y=0, z=1");
This example shows how to sum the results from a box of monitors (typically surrounding a scattering particle).
Note: See the online section on Far field projections for more information on why a negative sign is required on some terms.
phi = linspace(0,360,201); E2_xy = matrix(length(phi)); E2_yz = matrix(length(phi)); x = -sin(phi*pi/180); y = cos(phi*pi/180); z = 0; temp = farfieldexact("x2",x,y,z,{"field":"E"}) + farfieldexact("y2",x,y,z,{"field":"E"}) + farfieldexact("z2",x,y,z,{"field":"E"}) - farfieldexact("x1",x,y,z,{"field":"E"}) - farfieldexact("y1",x,y,z,{"field":"E"}) - farfieldexact("z1",x,y,z,{"field":"E"}); E2_xy = sum(abs(temp)^2,2); # E2 = |Ex|^2 + |Ey|^2 + |Ez|^2 plot(phi, E2_xy,"Phi (deg)","|E|^2","in XY plane");
The following example shows how farfieldexact and farfieldexact3d output data differently.
When x=[1 2], y=[1 2], z=[0],
farfieldexact: The result is a 2*3 matrix. First dimension is position;second is field component. This calculates the far field at the positions [1,1,0] and [2,2,0] .
farfielexact3d: The result is a 2*2*1*3 matrix. First three dimensions are positions; the fourth dimension is field component. This calculates the far field at the positions [x,y,z] = [1,1,0], [1,2,0], [2,1,0], [2,2,0].
x=1:2; y=1:2; z=0; m="monitor"; E_far=farfieldexact(m,x,y,z,{"field":"E"}); ?size(E_far); result: 2 3
farfield2dintegrate - Script command
Calculates the integral of the far field projection over some range of theta in 2D simulation. Angles are specified in degrees, but the integral is done in radians.
∫θE2(θ)dθ
Syntax | Description |
---|---|
out = farfield2dintegrate(E2, theta, halfangle, theta0); | Integrate 2D far field projection data. |
Parameter | Default value | Type | Description | |
---|---|---|---|---|
E2 | required | matrix | E field data from farfield2d | |
theta | required | matrix | Theta from farfieldangle | |
halfangle | optional | 90 | vector | Half angle (in degrees) of the integration region. Must have same length as theta0 or length 1. Half angle should be between 0 to 90 degrees. |
theta0 | optional | 0 | vector | Center angle (in degrees) theta of the integration region. Must have same length as halfangle or length 1. Theta0 should be between -90 to 90 degrees. |
Example
Calculate the fraction of power in the far field from 20 to 70 degrees.
m="monitor1"; E2=farfield2d(m); theta=farfieldangle(m); ?farfield2dintegrate(E2,theta,25,45) / farfield2dintegrate(E2,theta);
farfield3dintegrate - Script command
Integrates the far field projection over a cone centered at theta0 and phi0, with a width specified by halfangle for 3D simulations. The far field electric field is a function of the direction cosines (ux,uy), but farfield3dintegrate automatically does the change of variables. Similarly, angles are specified in degrees, but converted to radians before the integral is calculated. See the farfield3d documentation for information on interpreting ux, uy, na, nb for various monitor orientations.
∬θ,ϕE2(ux,uy)sin(θ)dθdϕ
Syntax | Description |
---|---|
out = farfield3dintegrate(E2, ux, uy, halfangle, theta0, phi0); | Integrate 3D far field projection data. |
Parameter | Default value | Type | Description | |
---|---|---|---|---|
E2 | required | matrix | E field data from farfield3d | |
ux | required | vector | ux data from farfieldux. Note that the result should be a vector, so it is sufficient to perform the farfieldux script command for only 1 frequency point. | |
uy | required | vector | uy data from farfielduy. Note that the result should be a vector, so it is sufficient to perform the farfieldux script command for only 1 frequency point. | |
halfangle | optional | 90 | vector | Half angle of the integration cone. unit in degrees. must have length L or 1. Half angle should be between 0 to 90 degrees. |
theta0 | optional | 0 | vector | Center angle theta of the integration cone. unit in degrees. must have length L or 1. Theta0 should be between 0 to 90 degrees. |
phi0 | optional | 0 | vector | Center angle phi of the integration cone. unit in degrees. must have length L or 1. Phi0 should be between 0 to 360 degrees. |
Example
Calculate the fraction of power from the source that is transmitted into the far field within in a 30 degree cone centered at theta=phi=0.
m="monitor1"; res = 201; E2 = farfield3d(m,1,res,res); ux = farfieldux(m,1,res,res); uy = farfielduy(m,1,res,res); halfangle=30; theta0=0; phi0=0; cone_30 = farfield3dintegrate(E2, ux, uy, halfangle, theta0, phi0); # integrate over 30 degree cone total = farfield3dintegrate(E2, ux, uy); # integrate over entire hemisphere T = transmission(m); # fraction of source power transmitted into far field ?cone_30/total; # fraction of far field power within a 30 degree cone ?cone_30/total*T; # fraction of source power transmitted into the far field within a 30 de
DGTD
near2far - Script command
Calculates the far field at the specified points using the provided near field monitor data.
Syntax | Description |
---|---|
out = near2far(nearfield, farfield, n); | Calculates the far field using the provided near field monitor data at the specified far field points. The input unstructured data set specifying the near fields must contain an attribute named 'E' parametrized by frequency. The output is an unstructured data set with an attribute named 'E' containing the far field. The far field frequencies are determined by the near field frequencies while the far field points, connectivity matrix and surface normals associated with the output data set are taken from the unstructured data set specifying the far field points. |
Parameter | Default value | Type | Description | |
---|---|---|---|---|
nearfield | required | unstructured data set | Near field data in the format returned by DFT monitors. The electric field can be sampled on a segmented line or on a triangulated surface. If sampled on a segmented line, the electric field is assumed to come from a 2D simulation and the 2D integral kernel is used for the far field projection. Similarly, if the electric field is sampled on a triangulated surface, it is assumed to come from a 3D simulation and the 3D integral kernel is used for the projection (see the provided reference). | |
farfield | required | unstructured data set | Far field points to be used in the projection. If the near fields are sampled on segmented line, the far field points must be specified using a segmented line. Similarly, if the near fields are sampled on a triangulated surface, the far field points must be sampled on a triangulated surface. The command createsphericalsurface can be used to easily create an unstructured data set with a segmented line or a triangulated surface. | |
n | optional | 1.0 | number or vector | Background refractive index of the far field medium. It can be a single number or a vector with the same length as the near field frequency parameter. |
Note: Far field integration For integration of far field over a range of angles, the script command quadtri can be used. See quadtri for more information. |
Example
This example performs a far field projection on a sphere using the near field data collected from a monitor named "monitor".
surf = createsphericalsurface; E_near = getresult("DGTD::monitor","fields"); E_far = near2far(E_near,surf); visualize(E_far);
For more information on how far field projections are computed please refer to:
John B. Schneider, Understanding the Finite-Difference Time-Domain Method, Chapter 14: Near-to-Far-Field Transformation, 2010 Available at: http://www.eecs.wsu.edu/~schneidj/ufdtd/
createsphericalsurface - Script command
Creates a triangulated spherical surface or a segmented circular arc. It can be used to define the far-field points for a far field projection as these are often specified using a spherical surface (3D simulations) or a circular arc (2D simulations).
Syntax | Description |
---|---|
out = createsphericalsurface([theta1,theta2],[phi1,phi2], [X,Y,Z],radius,lmax); | Creates an unstructured data set with a triangulated surface or a segmented arc. Their dimensions are specified by the input angles, orientation axis and radius. The coarseness of the triangulation (or line segmentation) is specified as the maximum separation between adjacent points. The output data set contains the IDs of each element (triangles or lines) and the corresponding areas (only for triangles). |
Parameter | Default value | Type | Description | |
---|---|---|---|---|
theta1 | optional | 0 | number | Starting value of the elevation angle (theta) range in radians with respect to the reference axis. |
theta2 | optional | pi | number | End value of the elevation angle (theta) range in radians with respect to the reference axis. |
phi1 | optional | 0 | number | Starting value of the azimuthal angle (phi) range in radians with respect to the reference axis. |
phi2 | optional | 2*pi | number | End value of the azimuthal angle (phi) range in radians with respect to the reference axis. |
[X,Y,Z] | optional | [0,0,1] | vector | Orientation axis: [1,0,0] for X-axis, [0,1,0] for Y-axis and [0,0,1] for Z-axis. |
radius | optional | 1 | number | Radius of the sphere or arc to be created in meters. |
lmax | optional | 0.2 | number | Maximum separation between two adjacent data points on far field location in meters. |
Example 1
This example creates a spherical surface and performs a far field projection using the near field data from a surface monitor named "monitor".
surf = createsphericalsurface([0,pi/4],[0,2*pi],[0,0,1],1,0.1); E_near = getresult("DGTD::monitor","fields"); E_far = near2far(E_near,surf); visualize(E_far);
Example 2
This example creates an arc (in the XZ plane) and performs a far field projection using the near field data from a line monitor called "monitor" (also in the XZ plane).
surf = createsphericalsurface([pi/2,pi/2],[pi,2*pi],[0,1,0],1,0.1); E_near = getresult("DGTD::monitor","fields"); E_far = near2far(E_near,surf); visualize(E_far);