This page describes how to fix diverging simulations. Most diverging simulations are detected by the auto shut-off feature, which displays the message "ERROR: Early termination of simulation, the electromagnetic fields are diverging." when the overall field strength rises above a threshold value.
Determine the type of instability
Most diverging simulations fall into one of two categories. Either the simulation is diverging due to a dt stability factor problem, or a PML boundary condition problem.
It is easy to determine the type of instability by setting all of the simulation boundary conditions to Metal, then re-running the simulation.
- If the simulation still diverges, it is a dt stability factor type of divergence. See the dt stability factor section.
- If the simulation is stable, it is a PML type of divergence. See the PML and dispersive materials section.
dt stability factor
The theoretical maximum time step is calculated from the simulation mesh size based on the Courant stability criterion. By default, Lumerical software uses a time step that is 0.99 of the theoretical maximum time step. This theoretical maximum is calculated assuming propagation of light in a homogeneous vacuum. Once physical structures and interfaces are included in the simulation, particularly when dispersive materials are involved, a smaller time step is sometimes required.
Reduce the dt stability factor
Reduce the dt stability factor until the simulation is stable. In many cases, a value of 0.95 or 0.9 will make the simulation stable. In other cases, a value of 0.5 or smaller may be required.
Reducing the time step does not affect the accuracy or memory requirements of the simulation, but does increase the simulation time. Changing dt from 0.99 to 0.95 will increase the simulation time by 4%.
This parameter can be accessed on the Mesh Settings tab of the Simulation region properties.
Causes of dt stability factor type divergences
Material properties
Some dispersive material models can cause the simulation to be slightly unstable. If you discover that one of your materials causes the simulation to be unstable, use the Material explorer to ensure that the material properties are what you expect. In some cases, the automatic data fitting routine will create fits that are not very good. In this case, you should adjust the fit parameters to obtain a better fit. See this link for more details: Tips for improving material fit. If the fit is good, then reduce the dt stability factor to make the simulation stable.
Mesh aspect ratio
A large mesh aspect ratio can cause the simulation to be unstable. If dx = 5nm and dy = 25nm, the aspect ratio is 5. In principal, there is nothing wrong with having a large aspect ratio, but in practice it can be slightly unstable when dt is near the maximum theoretical limit.
PML and dispersive materials
Generally, we recommend that physical structures be extended through the boundary condition (BC) region. This gives the most accurate simulation results. Unfortunately, some dispersive materials can be unstable when extended through PML BCs. The fields will begin to diverge at the point where the dispersive material touches the PML BC. This is easy to see with a movie monitor.
The steps to take in order to fix a PML divergence depend on the PML implementation that is being used. Stretched Coordinate PML (SCPML) is recommended, but if you are using an older version of the software prior to the 2015a release, only the Uniaxial PML (UPML) type is available.
SCPML Settings
One or more of the following changes should make the simulation stable if you are using SCPML:
1) Set PML profile to stabilized
Changing this setting alone typically solves the divergence problem. The alpha setting and number of PML layers are increased in the stabilized PML profile compared to the standard profile.
2) Increase alpha
Setting the PML profile to "Custom" allows you to set the alpha parameter. Increasing the value of alpha can make the simulation stable, but it can result in increased reflections, so increasing the number of PML layers is also recommended.
3) Increase the mesh size immediately before the PML
Adding a mesh override region to increase the size of the mesh step (in the direction normal to the PML surface) can make the PML more stable. This can affect the performance of the PML as there can be small reflections from the grading of the mesh itself.
4) Do not extend the metal layer through the PML
Reflections from the PML are minimized when structures are extended completely through the PML. However, if this causes the simulation to diverge, the only solution may be to stop this layer at the inside edge of the PML. This may cause higher reflections from the PML, but will make the simulation stable. Please note that by default structures that terminate at the PML are automatically extended through the PML. You must terminate the structure at least 1 dx from the PML, or disable the feature "extend structure through the pml" in the Advanced Options of the simulation region.
Legacy UPML Settings (Prior to 2015a release)
One or more of the following changes should make the simulation stable if you are using UPML:
1) Reduce PML sigma
This setting can be accessed in the Advanced tab of the Simulation region. When you reduce PML sigma, the absorption of the PML is reduced but the number of PML layers used will be automatically increased to compensate (until the number of layers exceeds the maximum number you have allowed). This means that the PML performance will not be affected, but your simulation will take more time and memory due to the increased number of PML layers.
2) Increase PML kappa
This setting can be accessed in the Advanced tab of the Simulation region. The default value is 2. Try increasing kappa to 10 or even 20. Very often this will stop the divergence. Increasing kappa has a very small effect on the rest of your simulation. A larger kappa will cause slightly more reflections from the PML at normal incidence, but will actually cause slightly less reflection at steeper angles. Values of kappa much larger than 20 can cause more significant degradation of the PML performance.
3) Increase the mesh size immediately before the PML
Adding a mesh override region to increase the size of the mesh step (in the direction normal to the PML surface) can make the PML more stable. This can affect the performance of the PML as there can be small reflections from the grading of the mesh itself.
4) Set Type of PML to Stabilized
This setting can be accessed in the Advanced tab of the Simulation region. This can degrade the performance of the PML at steeper angles of incidence.
5) Do not extend the metal layer through the PML.
Reflections from the PML are minimized when structures are extended completely through the PML. However, if this causes the simulation to diverge, the only solution may be to stop this layer at the inside edge of the PML. This may cause higher reflections from the PML, but will make the simulation stable. Please note that by default structures that terminate at the PML are automatically extended through the PML. You must terminate the structure at least 1 dx from the PML, or disable the feature "extend structure through the pml" in the Advanced Options of the simulation region.
Other diverging situations
Material fits with unphysical gain
Occasionally, the fitting routine will generate fits with gain, even though the experimental material data does not have any gain. This will cause a simulation to diverge even if the frequency at which the fit has gain is well outside of the simulation region.
To check if this is the case: open the material editor, select show extended spectrum and fit and plot the index. If Im(index) is negative at some point then there will be a small region of gain. This problem can be solved either by slightly varying the simulation bandwidth or by changing the fit tolerance and maximum coefficients variables.
Incorrect simulation setup
Injecting a source with incompatible simulation region settings such as injecting a plane wave source with PML boundaries at the sides of the source can also cause a simulation to diverge. See Field Truncation.
Automatic divergence checking
Lumerical software has an automatic divergence checking feature. If the total energy in the simulation volume is many times larger than the injected energy, the simulation will be stopped. The following graphical warning shown will appear in the Job Manager and Object tree when a diverging simulation is detected.
The automatic divergence checking feature properties are found in the Advanced tab of the Simulation region properties.
Time and movie monitors can be helpful when debugging diverging simulations. Both will show the fields growing exponentially at some point. Simulations that suddenly become very slow (for example, the time remaining estimate increasing from 5 minutes to 1 hour) is another sign of divergence. The automatic divergence checking normally stops the simulation before the simulation becomes very slow.
Example
The file divergence_example.fsp contains a multilayer OLED structure in a 2D simulation. The dipole source is in a multilayer stack of highly dispersive materials. Some of the materials have complex dispersion characteristics that lead to numerical stability problems (for example, alq3_PFD changes from an index that is almost purely real to an index that is almost purely imaginary).
Even with these challenging materials, the simulation is stable with the default SCPML settings. With the goal of creating an example simulation that diverges, the automatic shut-off has been disabled. (The automatic shut-off feature normally stops the simulation when the simulation fields become very small). With the Auto shut-off disabled, the simulation continues to run past the point it would normally stop. This allows the numerical problems to build, eventually leading to diverging fields.
Confirm that it is a PML type of divergence
Switch all the boundary conditions to metal and rerun the simulation, we can see that it does not diverge. This confirms the divergence is related to the PML boundaries.
Next, we can test the impact of various settings:
Parameter modified | Simulation time until divergence |
Default settings | 27% |
Set PML profile to "stabilized" | No divergence |
Set PML profile to "custom" and increase "alpha" to 0.1 | No divergence |
Terminate structures at PML boundary and uncheck the "extend structures through PML" in the FDTD simulation region | No divergence |
Increase dx to 20nm near the PML boundaries. This can be done by editing the mesh override regions and checking "override x mesh". | 72% |