# Knowledge Base

 Navigation: Scripting Language > Near to far field projections farfieldexact

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)].

3D

Vectors lists x,y,z must have the same length L or be length 1. 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.

2D

Vector lists x, y must have the same length L or be length 1. 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.

 Supported Product: FDTD, MODE

 Syntax Description out = farfieldexact("mname", x, y, f, index) 2D far field exact projection out = farfieldexact("mname", x, y, z, f, index); 3D far field exact projection

 Parameter Default Default value Type Description mname required string name of the monitor from which far field is calculated 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 center number The index of the material to use for the projection.

Example

This example shows how to calculate |E|^2 on a straight line at y=0, z=1, for x from -1 to 1 meters.

# Define far field position vector

res=100;

x=linspace(-1,1,res);

y=0;

z=1;

# do far field projection

E_far=farfieldexact("monitor",x,y,z);

E2_far = sum(abs(E_far)^2,2); # E2 = |Ex|^2 + |Ey|^2 + |Ez|^2

# plot results

plot(x,E2_far,"x","y","|E|^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) + farfieldexact("y2",x,y,z) + farfieldexact("z2",x,y,z)

- farfieldexact("x1",x,y,z) - farfieldexact("y1",x,y,z) - farfieldexact("z1",x,y,z);

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);

?size(E_far);

>> result:

>> 2 3