So here the point to point phase dependent definition for strange propagation direction.

I define a plane (xy direction) and I put the good phase thank to SetCustomExcite at each point of my plan, to get mainly z propagation, and little bit along x or y...

Still don't work, I don't know why...

I did this :

Most important line are :

Code: Select all

```
for i=1:max(size(indexX))
for j=1:max(size(indexY))
FDTD = SetCustomExcite(FDTD,f0,[ 'sin(2*pi*' num2str(f0) '*t-' num2str(phase(i,j)) ')' ]);
CSX = AddExcitation(CSX,'excitation',0,pola);
CSX = AddPoint(CSX,'excitation',0,[mesh.x(indexX(i)) mesh.y(indexY(j)) z]); %Ajoute l'exitation dans la grille
end
end
```

I get an error all the times. This is :

**Warning: Unused primitive (type: Point) detected in property: excitation**
Total sub-function code :

Code: Select all

```
function [FDTD,CSX] = SetAddOblicSinus(FDTD,CSX,mesh,unit,index,f0,xm,xM,ym,yM,z,theta,phi,pola00)
%Set a sinus generation, in a plan transverse to Z, with phase space depence in rrespect of theta, phi propagation direction
%First theta rotation of the wavevector with axis x
%Phi is angle between plane zx and vecteur
%The plane generation is between [xm xM] and [ym yM] at the z position of the grid
%Grid has to show a constant xstep and ystep, if not => more energy will be present in the direction of higher density grid location...
%The plane emission is inside a medium of refractive index 'index'
%The polarisation is given in the case of theta=0 and phi=0, and next rotate in respect of angle, [0 1 0]
%Direction of the waves
M1=[1 0 0;0 cos(theta) sin(theta);0 -sin(theta) cos(theta)];
M2=[cos(phi) 0 sin(phi);0 1 0;-sin(phi) 0 cos(phi)];
M=M2*M1;
u=M*[0 0 1]';
ux=u(1);
uy=u(2);
uz=u(3);
pola=(M*pola00')';
%Find the index x of grid which is inside the plane (in indexX array)
d=0;
for i=1:max(size(mesh.x))
if (mesh.x(i)>=xm)
if (mesh.x(i)<=xM)
d=d+1;
indexX(d)=i;
endif
endif
end
%Find the index y of grid which is inside the plane (in indexY array)
d=0;
for i=1:max(size(mesh.y))
if (mesh.y(i)>=ym)
if (mesh.y(i)<=yM)
d=d+1;
indexY(d)=i;
endif
endif
end
%We check the phase value of all the grid point inside the plan emission
k0=2*pi*f0/299792458*index;
kx=k0*ux;
ky=k0*uy;
for i=1:max(size(indexX))
for j=1:max(size(indexY))
rx=mesh.x(indexX(i))*unit;
ry=mesh.y(indexY(j))*unit;
phase(i,j)=rx*kx+ry*ky;
end
end
%We put sinus and phase at each point of the emission
for i=1:max(size(indexX))
for j=1:max(size(indexY))
FDTD = SetCustomExcite(FDTD,f0,[ 'sin(2*pi*' num2str(f0) '*t-' num2str(phase(i,j)) ')' ]);
CSX = AddExcitation(CSX,'excitation',0,pola);
CSX = AddPoint(CSX,'excitation',0,[mesh.x(indexX(i)) mesh.y(indexY(j)) z]); %Ajoute l'exitation dans la grille
end
end
endfunction
```

And I call this function with my m-file as follow :

Code: Select all

```
close all
clear
clc
Xsize=40;
Ysize=40;
Zsize=40;
unit = 10e-6;
% init and define FDTD parameter
FDTD = InitFDTD(500,1e-5,'CoordSystem',0);
BC = {'PML_8' 'PML_8' 'PEC' 'PEC' 'PML_8' 'PML_8' };
FDTD = SetBoundaryCond(FDTD,BC);
% init and define FDTD mesh
CSX = InitCSX();
mesh.x =0:Xsize;
mesh.y =0:Ysize;
mesh.z =0:Zsize;
CSX = DefineRectGrid(CSX, unit, mesh);
xm=15;
xM=25;
ym=3;
yM=13;
z=4;
theta=pi/4;
phi=0;
f0=1e12;
pola00=[0 1 0];
[FDTD,CSX]=SetAddOblicSinus(FDTD,CSX,mesh,unit,1,f0,xm,xM,ym,yM,z,theta,phi,pola00);
CSX = AddDump(CSX,'Probe','DumpMode',0);
CSX = AddBox(CSX, 'Probe', 0, [20 0 0],[20 Ysize Zsize]);
rmdir('tmp','s');mkdir('tmp');
WriteOpenEMS('tmp/tmp.xml',FDTD,CSX);
CSXGeomPlot( 'tmp/tmp.xml' );
RunOpenEMS('tmp','tmp.xml','');
disp('use Paraview to visualize the FDTD result...');
```

Did I do it in bad manner ? Sebastian, can you be little bit more explicit ?

Edit : With AddBox instead of addPoint, I get something, but not what I exepted... Maybe some bug in the function as I wrote quickly and not debug yet... Maybe I will be able to do what I want...