This video is taken from the Scripting Learning Track on Ansys Innovation Courses.
In this unit, we are going to create a simple grating example from scratch and plot the
Through this example, you will get a general idea about how scripting can be used at various
stages of the simulation workflow.
What we are dealing with here is a periodic array of rectangular structures - refractive
index of 3.4, 0.5 by 0.5 microns in size with a period of 1 um.
The goal is to obtain the transmission spectrum of the grating when a planewave with the wavelength
range of 1300 - 1800 nm is injected.
For the actual simulation, we only need to consider a unit cell with periodic boundaries
on these sides.
First, add a rectangle structure by entering 'addrect' in the Script prompt.
This is equivalent to clicking 'Rectangle' in the structures menu.
Next, use set commands to set the x/y spans
and the index of the structure.
To add a simulation region, just enter 'addfdtd'.
We will be doing a 2D simulation for this example.
So set the 'dimension' to '2D.'
Set the x span of the simulation region, which is the same as the period of the grating.
Then, set the x boundaries to 'Periodic'
Next, add a planewave source.
Set the y position,
And set the wavelength ranges.
'Addpower' adds a frequency domain field and power monitor.
Set the y position of the monitor,
set the frequency points to 100.
Once the simulation settings are done, enter 'run' command to run the simulation.
After the simulation has run, get power transmitted through the monitor from the 'T' dataset and
plot it with the visualize command.
We have seen a simple example of the use of scripting in the context of simulation workflow.
In the following sections, we will learn in more detail about individual script commands.