Ansys Insight: Custom TFSF source

gsungsun Ansys Employee Posts: 115
edited April 30 in Photonics

This example shows how to create a customized TFSF source with focused beam for analysis of nano particle scattering and compare the result with regular TFSF source. The TFSF source uses plane wave, and has a built-in reference, which makes the simulation very effective. In some cases, users may want to test some other forms of beam sources in order to explore possibly new properties. This example uses the fundamental idea of TFSF, that is, the differential method for illustration.

Customizing a TFSF source is an advanced feature. In the vast majority of simulations, the plane wave TFSF is sufficient to analyze the scattering of a nano scatter. This is true even when in experiment a Gaussian beam or a NA focus beam is used where the illumination on the particle is almost uniform. Only in the cases where a very large numerical aperture (NA) beam is used, or a beam with specialized polarization form is used, may the custom TFSF be used.

This approach can be used for FDTD and VarFDTD.

here is the script: first run the reference

Due to regulation, it is illustrated only part of script.

then with the scatter in place, run it again

The basic idea of the differential method is to first run a simulation without the scatter and record the fields as the reference, then run another simulation with the scatter. The difference of the fields in the two simulations is the scattering field, and at the same time, any diffraction errors caused by the possible PML cut of the complete beam profile is minimized, if not canceled completely.


  • YevhYevh Posts: 4Member

    Hi gsun,

    Thanks for the post. Could you also advice please where one can download "Associated files"from after the Knowledge Exchange moving?

    Best wishes,


  • gsungsun Posts: 323Ansys Employee

    Hi, Yevhenii,

    Have you tried to visit the website through the link? I clicked the link, the file is there. It seems it does not need log in. Please try.

  • gsungsun Posts: 323Ansys Employee

    The new ALF website does not allow long post, so I have to cut it into 2 sections. And due to Ansys policy, only part of the script is pasted. We encourage users to write their own script based on the principle.

    Simulation settings and analysis

    We take the Mie scattering 3D as an example to use custom NA beam TFSF with NA=0.6. Different from the regular TFSF where the plane wave is limited into the source region, NA beam is composed of many angled plane waves. Due to diffraction, its lateral size can be large. Larger source size means that the simulation region must also be large, which leads to longer simulation time. However, the nano particle is usually quite small, thus the light-matter interaction occurs in a small region. Since the differential method is used, we can use relatively small simulation region, whereas the diffraction effect can be minimized as long as the diffraction fields do not interact with the particle (place the source as close to the particle as possible). In this example, we choose the simulation region as um. In practice, you may do a converging test to choose the proper simulation region. Other settings are the same as the Mie scattering case, except that now we use the wavelength range from 400nm to 900nm.

    In calculation of the scattering cross section and absorption cross section, the source intensity is usually used, please refer the nanowire example. The function sourceintensity gives correct result for a plane wave. However, for a NA beam, the source profile is not uniform and this function does not give the correct result. To get correct result, we use the intensity on the front monitor (in this example it is y1) as the source intensity illuminating the particle.

    Once the scattering and absorption fields are obtained after running the simulations, we use the integration of the Poynting vector to get the power, then use the definition of the cross sections to obtain the scattering and absorption cross sections as shown below:

    The two results show a good agreement. This is because the particle is small and the illumination from the NA source on the particle is quite uniform. If the illumination is not uniform across the particle, the results might be significantly different.

    The minor difference is mainly due to the small simulation region we used. If you use a larger simulation region, you would be able to get a better agreement between the results.

    The Script

    In the first part of the script , choosing doTFSF=1 is to get the regular plane wave TFSF results, which are used to validate the custom TFSF in this example. You can choose doTFSF=0 to avoid it. Next, the reference simulation without the sphere is run, where the illumination profile at the focus and the fields in the monitors are recorded, and the averaged intensity in y1 monitor is calculated as the source intensity to be used later. Then the simulation with the scatter “sphere” is run. Note that to save simulation time, some objects are enabled or disabled. Finally the scattering fields are obtained with the differential method, the powers are calculated though the integration of the Poynting vectors, and the cross sections are obtained by the use of the averaged intensity of the illumination beam. Running the script you can duplicate the figure above.


    1. keep the the same mesh for the two simulations: Usually TFSF gives better results using a uniform mesh in TFSF region. An override mesh can be used for this purpose to have a uniform mesh. Since the differential fields need to be in the same grid, this override mesh should be kept even when there is no particle in the reference simulation.
    2. Far field projection: Some times users want to get the far field properties using the custom TFSF method. If this is the case, users must add a proper analysis group such as the “scat_ff” in Mie scattering 3D . At the same time, the script inside the analysis group should be modified in order to output the fields instead of the intensity. Then in the script file users can add scripts to get the far field projection in the reference simulation and the scatter simulation. Their difference is the scattered far fields and can be easily plotted as intensity.
    3. Refer to the Mie scattering 3D page to get more tips on scattering simulations.

    Note about Custom TFSF

    1. If necessary, the user can always modify the Gaussian source to be a plane wave source instead. The same script and methodology can be employed to obtain the plane-wave custom TFSF results,which will be the same as using the built-in TFSF.
    2. Since BFAST assumes the structure is periodic, users should not use BFAST source at an angle to build the custom TFSF to get broadband, oblique incidence result for a non-periodic structure.

Sign In or Register to comment.