We have an exciting announcement about badges coming in May 2025. Until then, we will temporarily stop issuing new badges for course completions and certifications. However, all completions will be recorded and fulfilled after May 2025.

Ansys Learning Forum Forums Discuss Simulation Photonics Calculating the phase in FDTD Reply To: Calculating the phase in FDTD

Guilin Sun
Ansys Employee

There are 2 steps using script to get the phase:
1: get the field components. As you know, the phase is associated with Ex,Ey, Ez (or H components). So you can use
E=getresult("monitor","E");
Ex=E.Ex;
Ey=E.Ey;
Ez=E.Ez;
similarly you can get x,y,z and f.
2: get the phase. for example for Ex, you can write
xphase=angle(Ex);
which will be a function of xyz and f.

In addition:
1: you can use Ex=getdata("monitor","EX") if you know you want Ex
2: you can use pinch to remove singular dimension: https://optics.ansys.com/hc/en-us/articles/360034405674-pinch-Script-command 

Please note that, a plannar frequency-domain monitor gives E/H/P as a function of x,y,z and wavelength/frequency. So in general the phase extracted from a monitor will have 4 dimensions, although one of the xyz will be singleton.

You can specify a particular dimension. Say you have a xy plane monitor. The phase will be

Phase(1:nx,1:ny,1,1:nf)

Using pinch to remove z singleton; phase=pinch(phase).

If you want to image phase or a specific wavelength, you can specify the frequency point, say fn (1<=fn<=nf), then

Image(x,y, pinch(phase(:,:fn)), “x”,”y”,”phase”);