Dassault Systèmes SIMULIA CST Studio Suite ®
When you set up an electromagnetic simulation using CST Studio Suite ® from within IPKISS, you go through the following steps:
Define the geometry that represents your component.
Specify the simulation job, consisting of the geometry, the expected outputs and simulation settings
Inspect the exported geometry
Retrieve the simulation results
1. Define the geometry
We’ve already covered step 1 by creating a SimulationGeometry for an MMI. The next step is to create an object that will handle the simulations.
2. Define the simulation
To create a simulation using the geometry we’ve just defined, we’ll instantiate
a i3.device_sim.CSTTDSimulation
object:
simulation = i3.device_sim.CSTTDSimulation(
geometry=sim_geom,
outputs=[
i3.device_sim.SMatrixOutput(
name='smatrix',
wavelength_range=(1.5, 1.6, 100),
symmetries=[('out1', 'out2')]
)
],
monitors=[
i3.device_sim.Port(name="in1", box_size=(1.6, 1.0)),
i3.device_sim.Port(name="out1", box_size=(1.6, 1.0)),
i3.device_sim.Port(name="out2", box_size=(1.6, 1.0)),
],
setup_macros=[i3.device_sim.cst_macros.field_monitor()]
)
Apart from the simulation geometry we have to specify an output.
By using SMatrixOutput
, the simulator will perform
an S-parameter sweep and return an SMatrix (i3.circuit_sim.Smatrix1DSweep
).
Note that we can use the symmetry of the MMI to speed up the calculation. This is done by setting
the symmetries
argument of SMatrixOutput
.
The setup_macros
argument allows us to define tool-specific settings.
In this case the field_monitor
macro will
let us visualize the electric field after the simulation is done.
With an output defined, your component is ready to be exported and simulated by CST.
3. Inspect the simulation job
To see what it looks like, you can use the inspect method:
simulation.inspect()
If your simulation tool has a graphical user interface, it will open and the 3D representation of your component will appear. You can now explore the geometry, ports, outputs and other settings as exported by IPKISS. You can make changes and modify settings from here. See Export additional settings below on how to make those settings available for future projects.
After execution, the CST Studio Suite GUI will open:
![../../_images/cst_inspect.png](../../_images/cst_inspect.png)
4. Retrieve and plot simulation results
When you’ve confirmed that the simulation setup is correct, you can continue with running the simulation and retrieving the results from the outputs. You don’t have to launch the simulation explicitly: when you request the results, IPKISS will run the simulation when required.
import numpy as np
smatrix = simulation.get_result(name='smatrix')
transmission = np.abs(smatrix['out1', 'in1']) ** 2
Note
By default, the S-matrix that is returned after the simulation will have its sweep units in micrometer.
This is in contrast to manually importing the S-matrix touchstone file using import_touchstone_smatrix
,
in which case the default sweep units are in GHz.
Since not all tools use the same physics conventions (e.g. \(\exp(-j\omega t)\) vs \(\exp(j \omega t)\)), IPKISS will ensure that the S-parameters are converted from the tool conventions into IPKISS conventions (\(\exp(-j\omega t)\)).
You can now plot these S-parameters with smatrix.visualize() (visualize
),
or they can be stored to disk (S-parameter data handling).
CST Studio Suite will also create a touchstone file named ‘smatrix.s3p’ that can be imported using
import_touchstone_smatrix
.
smatrix = simjob.get_result(name="smatrix")
smatrix.visualize(
scale="dB",
term_pairs=[
("in1", "out1"),
("out1", "out2"),
("in1", "in1"),
],
yrange=[-60, 0.1],
)
![../../_images/cst_sweep.png](../../_images/cst_sweep.png)
Only the transmission to the ‘out1’ port is plotted because the MMI is symmetric. We see that less around half of the power is transmitted to each output port, but the MMI can be optimized further.
The electric field can be visualized by reopening the CST project file and navigating to 2D/3D Results > E-Field in the navigation tree.
![../../_images/cst_electric_field.png](../../_images/cst_electric_field.png)
5. Advanced simulation settings
Monitors
Just as is the case with the geometry, IPKISS sets reasonable defaults for the port monitors
.
When you don’t specify any ports, defaults will automatically be added.
The default position, direction are directly taken from the OpticalPorts of the layout, the dimensions of the Ports are calculated with a heuristic.
Specifically, the width of the port is taken from the core_width
attribute of the trace_template
of the IPKISS OpticalPort.
Any waveguide template that is a WindowWaveguideTemplate will have this attribute.
For the majority of waveguide templates this is the case. The heuristic will add a fixed margin of 1um to this core_width
.
The height of the port is derived from the Material Stack used to virtually fabricate the layer of the core of the Waveguide,
searching for the highest refractive index region but excluding the bottom, top, left and right boundary materials.
You can override these defaults by using the monitors
argument of the simulator class:
simulation = i3.device_sim.CSTTDSimulation(
geometry=sim_geom,
monitors=[
i3.device_sim.Port(
name='in1',
# we make the box of the port quite large for demonstration purposes
box_size=(5., 5.)
),
i3.device_sim.Port(name='out1', box_size=(1.6, 1.0))
i3.device_sim.Port(name='out2', box_size=(1.6, 1.0))
]
)
When you inspect the simulation object you’ll see something similar to the picture below:
![../../_images/cst_monitors.png](../../_images/cst_monitors.png)
Multimode waveguides
By default, waveguide ports will be simulated with a single mode (the fundamental mode). You can override this in order to take multiple modes into account:
simjob = i3.device_sim.CSTTDSimulation(
geometry=sim_geom,
monitors=[
i3.device_sim.Port(name="in1", n_modes=2, box_size=(1.6, 1.0)),
i3.device_sim.Port(name="out1", n_modes=2, box_size=(1.6, 1.0)),
i3.device_sim.Port(name="out2", n_modes=2, box_size=(1.6, 1.0)),
],
outputs=[
i3.device_sim.SMatrixOutput(
name='smatrix',
wavelength_range=(1.5, 1.6, 100),
symmetries=[('out1', 'out2')]
)
]
)
The simulation results will then contain the S-parameters for each port-mode combination:
smatrix = simjob.get_result(name="smatrix")
smatrix.visualize(
scale="dB",
term_pairs=[
("in1:0", "out1:0"),
("in1:1", "out1:1"),
],
)
![../../_images/cst_multimode.png](../../_images/cst_multimode.png)
6. Tool-specific settings
In addition to generic settings which can be applied to multiple solvers, the IPKISS device simulation interface allows also to use the full power of the solver tool. Tool-specific materials can be used and tool-specific macros can be defined.
Using materials defined by the simulation tool
By default, IPKISS exports materials for each material used in the process flow definition.
You can also reuse materials which are already defined by the device solvers by
specifying a dictionary solver_material_map
to the simulation object
(i3.device_sim.CSTTDSimulation
).
It maps IPKISS materials onto materials defined by the tool (name-based).
For example:
simjob = i3.device_sim.CSTTDSimulation(
....
solver_material_map={i3.TECH.MATERIALS.SILICON: 'Silicon (lossy)'}
)
This will map the TECH.MATERIALS.SILICON onto a material defined by the electromagnetic solver. The material name should be know by the solver. Please check the tool documentation to find out which materials are available. In CST Studio Suite, materials are stored in several locations:
<CST INSTALL PATH>\Library\Materials
%AppData%\CST AG\CST STUDIO SUITE\Library\Materials
: contains material defined by the userC:\Program Files (x86)\CST Library Extensions\Materials 1.0\Materials\
: materials installed through the library extensions. Please contact CST Studio Suite to learn how to obtain these library extensions.
Macros
Macros allow you to add tool-specific commands using their API.
IPKISS provides some premade macros which are available under the i3.device_sim.cst_macros
namespace.
Visit the documentation for more information.
You can also use macros to execute tool-specific code to generate output files and retrieve those with simjob.get_result. In the following example we use it to generate a file with the numbers 0 to 5.
macro_body = """
Dim outputfile As Variant
Dim i As Integer
Set outputfile = GetProjectPath("Root")+"\\test.txt"
Open outputfile For Output As #1
For i = 0 To 9
Print #1, i
Next i
Close #1
"""
simjob = i3.device_sim.CSTTDSimulation(
geometry=geometry,
outputs=[
i3.device_sim.SMatrixOutput(
name='smatrix',
wavelength_range=(1.5, 1.6, 100),
symmetries=[('out1', 'out2')]
),
i3.device_sim.MacroOutput(
name='macro-output',
commands=macro_body.splitlines(),
filepath='test.txt'
)
],
)
# get_result will execute the code and take care of copying the file when required.
fpath = simjob.get_result('macro-ouput')
print(open(fpath).read())
# expected output:
# 0
# 1
# 2
# 3
# 4
Export additional settings from CST Studio Suite to IPKISS
Often you will want to tweak certain settings (simulation settings, materials, …) using very tool-specific commands or actions. Since it is not feasible to abstract everything, IPKISS provides a way to store and apply tool-specific settings in the form of macros.
Macros to be executed during the setup of the simulation project can be specified in the CSTTDSimulation
.
The default name of the macro file is cst_additional_cmds.mcs, located in same folder as your script. You can change the filename and location as you wish.
import os
curdir = os.path.dirname(os.path.abspath(__file__))
simjob = i3.device_sim.CSTTDSimulation(
....
setup_macros=[
i3.device_sim.MacroFile(filename=os.path.join(curdir, 'cst_additional_cmds.mcs'))
]
)
When inspecting the simulation project from the CST Studio Suite GUI, one can easily tweak any desired settings from the GUI. Almost anything can be modified, really. Consult the CST manual for information.
As an example, we modify the S-parameter symmetry settings:
![../../_images/cst_symmetries.png](../../_images/cst_symmetries.png)
Now, we can store all the additional settings which were made back into the IPKISS model. These will then automatically be re-applied when you run the same simulation next time, also when you make changes to the device geometry, virtual fabrication process or simulation settings!
Save the settings to IPKISS through the menu item Home: Macros>Results>-Import and Export>Export Additional Settings to Luceda IPKISS:
![../../_images/cst_export_settings.png](../../_images/cst_export_settings.png)
Multiphysics simulations
CST Studio Suite can also perform multiphysics simulations. A project can be set up to contain several type of simulations, including electromagnetic, thermal, etc.
Please contact either Dassault Systèmes (https://www.3ds.com/support/) or us (support@lucedaphotonics.com) if you want to learn more on how to set up this workflow.
7. Building models based on simulation results
Finally, when you are satisfied with the S-matrix you obtained, you can store it in the Touchstone format. Then, you can use it to build a CircuitModel for your PCell, see Physical device simulation guide and Circuit simulation with scatter matrix files.