Log in
Log in Simulate Now
Log in Simulate Now

Setting up a model for electromagnetic problems in OnScale Analyst

By Ahmad Ashwah 12 March 2020

We recently presented a webinar on Optical Waveguide Design with OnScale Cloud Engineering Simulation. During this webinar we discussed how to simulate optical waveguide devices and post-process the results in OnScale. In this blog post we will provide an overview of optical waveguides and discuss how to set up a model for electromagnetic problems in OnScale Analyst.

Confining light in a waveguide

Wave refraction at material boundaries is governed by Snell’s law. In the case of light traveling from a high refractive index material to a lower index material, total internal reflection occurs for large incidence angles confining the electromagnetic waves within the structure. This is utilized in optical waveguides by the core material which is always a higher refractive index to ensure the guiding principle. Waveguide devices can serve various functions, such as transporting signals, splitting, mixing, multiplexing, and filtering.

Main types of waveguide

Optical fiber?

  • Cylindrical, layers of various materials for optical wave confinement and mechanical flexibility

Slab waveguides

  • Rectangular layered structure?
  • Silicon on insulator structures are especially favorable – large refractive index difference allows for sharp bends and reduced device footprint

Electromagnetic simulation setup

The main stages of model setup in OnScale Analyst for electromagnetic problems are as follows.

Define model geometry and assign materials to the respective ranges

For simple models, during the model setup phase so-called key points are defined where a fixed mesh node is desired. Therefore, key points must correspond with material boundaries, edges, and corners. Meshing is defined by the maximum edge length of the rectangular mesh domains. Materials can be assigned to rectangular, circular, cylindrical, or spherical regions to build the model. CAD structures can also be imported for more complex geometries.

Apply boundary conditions utilizing absorbing boundaries to truncate infinite domains efficiently

In electromagnetics, the simulation domain is usually an infinite open space. The space must be terminated in a boundary that absorbs outgoing waves and has minimal reflection to allow efficient modeling of these problems. To further minimize reflections, perfectly matched layers (PMLs) are available at a slightly increased simulation cost.

In many cases the expected field distribution is symmetric due to a symmetry in the model geometry. However, for electromagnetic problems care must be taken as two types of symmetries are present, depending on the electric or magnetic fields exhibiting the symmetry.

Select excitation for the problem to generate electromagnetic waves

To approximate wave modes, various spatial distributions are available such as Gaussian or truncated cosine. It is also possible to save the wave mode that is at the output of the model so that it can be imported into another simulation and applied as excitation.

Measure outputs

For visualization purposes, especially for test runs, usually the electric or magnetic fields are plotted in the model. More qualitative characterization of device behaviors is possible by calculating energy flow through various surfaces by a Poynting vector approach. In the case of wave guides the output power to the input power is commonly termed transmission coefficient.

Let’s have a look at some of the model examples in OnScale. First take a straight optical waveguide made of a silicon dioxide substrate. Due to the nature of the symmetry, only the bottom half of the waveguide is needed for the model with the PEC boundary at the top. The animation below shows the wave propagation of one of these structures.

Straight waveguide – model setup

Follow the steps below to carry out your own setup in OnScale Analyst using script.


  1. Parameter definition?
  2. Model dimensions and mesh?
  3. Material assignment?
  4. Boundary conditions?
  5. Calculations and outputs

Parameter definition

Let’s look at some example lines showing how to define variables in OnScale. These always have the same form: the symb keyword is followed by the variable name and either a numerical value or an expression using existing variables.


These example lines define the dimensions of the geometry. Similar lines can be used to set up the permittivity, other material properties, frequency of interest, or the mesh edge length.

Model dimensions and mesh

The most common way of defining key points is by specifying the distance between them. See the example below. In this case the first key point is defaulted at the minimum extent of the model and this key point definition is shown in the top code block along the X direction.Waveguide
Ideally, we would want the key points to be separated by clearance on the left, core in the middle, and clearance on the right. As you can see in the example above, these are well aligned with the ultimate structure of the whole design as in the cross-section of this geometry we have silicon core in the middle of the model, and on the left and right sides are these clearances, which are silicon dioxide substrate. To specify the mesh only the maximum edge length must be given. This is shown in the bottom code block. Note that the XYZ physical coordinate space in this case has an equivalent logical space, IJK. Therefore, the X direction is equivalent to I and the maximum edge length in this case is stored in a variable that’s called box. We use the variable box to define, in this case, the maximum edge length in I.

Material assignment

First the materials have to be defined for the electromagnetic problem. This is done via the matr prop command (example below). For electromagnetic materials, this command always has the same structure: material name, material permittivity, conductivity, and permeability should be given. Afterwards these materials can be assigned to domains of the mesh using the topo command, as shown below.Material Assignment
In this case, first silicon dioxide is assigned to the whole model by stating region silicon dioxide and not specifying any other arguments to this command. Silicon is assigned to the core rectangular region in the following line. Note that again we use the IJK coordinate system and the key points previously defined to define the region to have the silicon material as the core of this structure.

Boundary conditions

The boundaries can be specified using the boun primary command and they are numbered from X-Min through to Z-Max by numbers 1 to 6. So in this case 1 corresponds to X-Min, 2 is X-Max, 3 is Y-Min, and so forth up to 6, which is Z-Max. You can view the full documentation for a command by right-clicking the command and selecting Show help for …Boundary Conditions
In this case for side 5, which is the Z-Min, we defined a wave mode boundary and all the other surfaces are absorbing except for the top. As described previously, the top surface is assigned an asymmetric boundary condition so that we can efficiently model only half of the problem.

Calculations and outputs

Finally, let’s discuss the setup for performing the calculation itself and exporting results. We use the exec command to perform execution of the simulation for the given number of time steps or cycles. It can be quite flexibly changed between the two, whichever is easiest for the application. Usually we encapsulate this execution command within a processing loop and additionally use plotting functionality within the same group. The updated model can then be visualized after every execution step.


In this case the loop definition is shown on the left-hand side between lines 133 and 144. Afterwards we simply use the execution routine on line 147 and we execute it 30 times, which means that in every cycle the model is executed for every time step. As you can see there is a calculation of a steady state between lines 150 and 152. This is required so that afterwards the Poynting vector approach can be used for energy flow calculations. Here you can specify a reference point that will be used to state that the surface is outside or inside a material or inside the domain. Any power flow that is going to be outwards is positive and any power flow that is going to be inwards is negative.

The defn command is used to specify the name of a new surface. So, in this example, if you look at line 163 you can see that there is a new surface defined for the input. We can also specify the reference point so that the solver knows whether the power flow through this surface should be considered positive or negative. Afterwards the node subcommand is used to define the surface itself.

Finally, you can save the results of the Poynting vector integral calculation into variables and export them. They will be saved in a text format which you can open in any text editor and look at the input power flow and output power flow.

You should now be able to set up a model for electromagnetic problems in OnScale Analyst. If you have any questions, please feel free to email one of our simulation specialists at info@onscale.com.

Check out our on-demand webinar to see a design study of a straight waveguide! 


Ahmad Ashwah
Ahmad Ashwah

Ahmad Ashwah is an Application Engineer at OnScale with extensive experience in Computational Fluid dynamics and a Master’s degree in mechanical Engineering.

Discover how customers like you found success by
leaving traditional engineering simulation behind

Try OnScale following
our simulation guides

Simulate Now

Discuss your engineering
applications with us

Request a Demo