# Overlapping farfield profile with first gaussian mode

Hi,

I am using nearfield to far-field projection in FDTD to calculate the far-field. Now, I am wondering how much the far-field profile overlaps with the first gaussian mode. I remember there was a similar discussion in the previous KB platform that was suggested a mode expansion monitor can be used for this purpose but I don't know how it works.

Apart from the above approach, I am thinking to plot the far-field in the cylindrical form (rather than ux,uy) and then compare the result with the basic Gaussian profile (in 3D). Unfortunately, I don't know if this approach works or not.

Can you please advise?

## Comments

140Ansys EmployeeHello @Hreza ,

I don't think a mode expansion monitor could be used for this, because the mode expansion monitor wouldn't be able to calculate the Gaussian beam profile. I think you will need to use MODE for calculating the overlap between the FDTD monitor result and a Gaussian beam. To do this you will have to:

Let me know if you have any questions about this workflow.

7MemberDear @kjohnson,

Thanks for the comment. This is exactly what I am looking for. I followed the above steps but I got the below error message:

In overlap, no d-card called: mode1 was found

here is the script that I am using:

cleardcard; gaussian1 = loaddata("gaussian"); mode1 = loaddata("mode1"); out1 = overlap("gaussian1","mode1");

Previously, I made a Gaussian beam based on step 3 and saved it as "gaussian". Also, I used the below command for farfield results for FDTD and it seems it worked fine because the *.ldf file is almost 6MB.

?getdata; savedcard("mode1","::model::analysegroup::structure::z2");

It would be great if I have your advice about this issue.

140Ansys EmployeeHello @Hreza ,

After you import the data into MODE, the name of the d-card might not be "mode1". You can see the names of the available d-cards using the "?getdata" command. What happens when you enter this into the script prompt in MODE after importing the mode data?

7MemberHi @kjohnson,

Thanks for the info. I did that...here is the updated code: (as you said, its name was not mode1 but z2.....which I updated it in the below command)

cleardcard; gaussian1 = loaddata("gaussian"); mode1 = loaddata("mode1"); ?getdata; out1 = overlap("gaussian1","z2");

But I got the below error again:

...in overlap, no d-card called: z2 was found

I attached few snapshots here.... in "deck", you can see the names of imported d-cards. Also, I attached the "gaussian1" and "z2" imported profiles. It occurred to me that "z2" is not showing the farfield that I got from FDTD simulation (in the "component" section of the "mode plot options", I couldn't find any farfield options either; please check "component" snapshot).

For clarity, I attached a snapshot of the "Farfield" from FDTD simulation. I am not sure these two issues are related to each other but I thought it worth mentioning.

A few more information about the FDTD: In FDTD simulation, I calculated nearfield2farfield projection for z2 monitor that's why I used below commands:

?getdata; savedcard("mode1","::model::analysegroup::structure::z2");

7MemberHi @kjohnson,

Wondering if you have any advice for me? thank in advance!

140Ansys EmployeeHi @Hreza ,

Sorry for the late reply. I'm not sure what the problem would be, if the imported data is shown in the Deck then you should be able to use them with the overlap command. Ansys employees are not permitted to download attachments from the ALF, can you please include the images directly in your post?

The profiles in the D-cards are the near field data, so they won't match the far field results. The Gaussian beam you are calculating the overlap with is also near field data, so you wouldn't be able to calculate the overlap with the far field results.

7MemberHi @kjohnson ,

no problem. I'll include more images next times. But for now, I wonder what you mentioned in the above comment is slightly different from your first comment; at least this is the way I understand it.

You are saying the Gaussian beam that I calculated is the near-field. Also, what I imported is also a near-field. So, how can I calculate overlap for two far-field modes?

Would you please share with me an available example? Thanks!

140Ansys EmployeeHello @Hreza ,

The overlap calculation is given on the overlap KB page:

This calculation is performed over a 2D plane, so I don't think it would make sense to use the far fields in this calculation, which are written in terms of the direction of propagation. Do you have more details on the calculation you would like to perform?

7MemberHi @kjohnson ,

Thanks for the note.

yes, I want to calculate the overlap between the farfield pattern and the first Gaussian mode. I used "farfield3dintegrate" to calculate the far-field and I already have the data. According to the relevant support page, this function calculates the far-field as a function of the direction cosines (ux,uy); so it is basically a mapped image on a 2D plane.... unless I misunderstand it. Then, as the far-field is calculated based on "z2" monitor, I used the below command to save far-field data (although the saved data is not normalised).

?getdata; savedcard("mode1","::model::analysegroup::structure::z2");

Not sure I addressed what you requested so please let me know if you need more information.

140Ansys EmployeeHi @Hreza ,

It's true that the far field results are a function of two variables, but the overlap calculation is an integral over x and y, not ux and uy. I'm not sure if the calculation still makes sense for fields that are written as a function of ux and uy, which is why I asked for more details on the calculation you are trying to perform. It would be helpful if you had a reference for this calculation, or could provide the exact equation for this calculation. If you want to integrate over ux and uy I think you will have to write the equation manually in a script using the integrate or farfield3dintegrate commands, I don't think you will be able to use the overlap command.

7MemberHi @kjohnson

Thanks for the comment. I don't have any reference regarding calculating far-field overlap based on ux and uy. My data was based on ux and uy because I used "farfield3dintegrate" in the first place; but based on what you mentioned above, I convinced to calculate the far-field based on x and y, in which I used "farfieldexact3d". I can confirm I calculated the overlap in FDTD with the same function I used in the Mode solution but the value was much smaller than my expectation. (I couldn't get any result in Mode though, because I faced the same error message...." in overlap, no d-card called: z2 was found"). I investigated why the overlap value in FDTD is small, and I found a few reasons: 1) The x and y axes range for both the Gaussian mode and the far-field mode do not match each other. 2) The maximum values for the Gaussian mode's matrix and the far-field mode's matrix are in different positions; ie, for one of them, the maxima is in the centre of the matrix and for another one is in the top-left side of the matrix.

Because of this, I am convinced to manually calculate the far-field; for this purpose, I'm wondering how kz (wave vector in z-direction) is calculated in the Lumerical-FDTD. any advice?

P.S: I appreciate your help so far. If you need more details in any steps, please let me know.