How to create a rate equation laser model using scripted element?



I am trying to create a scripted model for directly modulated laser based on rate equation model. My question is how I can implement coupled differential equation in the scripted element.
Additionally, Can I implement the laser model in MATLAB and then use interconnect to interact with such model?


Hi @z_zhang,

It’s a very good question. There is no build in ODE functions in Lumerical scripts, so to solve coupled differential equations is not trivial. However, there is a primitive Directly Modulated Laser model (DM Laser (DML)) in the INTERCONNECT element library which you can use for your design. You can define your rate equation parameters in this model. Another model which could also be used for your design is the Travelling Wave Laser model (Laser TW (TWLM)). Depends on your design parameters, I suggest to start with the two primitive laser models than to define a scripted one.

You can implement a laser model in MATLAB and interact with INTERCONNECT. The element to load the data into INTERCONNECT could be Mentor Graphics Eldo Import (FROM_ELDO), Agilent ADS Import (FROM_ADS) and Piecewise Linear Import (FROM_PWL) depends on your requirements. They all load in time domain signals within text files, all you need to do is to define the time signal in the first column and then the waveform signal in the second column in the file. An example file is waveform.txt (21.8 KB).

You can also call INTERCONNECT from MATLAB to achieve the Interoperability. A KB example MATLAB Driven Optimization of Grating Coupler 2D-FDTD clearly demonstrates the steps.

I hope this could help. Let me know if you have any difficulties implementing these :slight_smile:


Hi @z_zhang,

I am sorry that I was wrong about the ‘data load in’ part in the previous reply. All the three elements I listed Mentor Graphics Eldo Import (FROM_ELDO), Agilent ADS Import (FROM_ADS) and Piecewise Linear Import (FROM_PWL) are for electrical signals only, so they cannot be used to define laser sources. There are other ways to work around this and load in optical signals, but it is better to have a look at your signal which you defined in MATLAB first to decide which one is the best way to implement this.

Let me know if there is anything unclear and share with me more information if possible :slight_smile:


Hi @gwang
Thanks for the kind reply. I am trying to build a PDK library in INTERCONNECT, which is why I asked the question since we want to have a more complete model for our lasers. For example, to include thermal effect, some laser parameters (photon life time, transparent carrier density etc.) need to change dynamically with the input current. Is there a way for to implement thermal effect based on the direct modulated model?

Also, with the traveling wave laser model, could it be used to model a mode locked laser? Has this been demonstrated before?


Correction to my previous reply, the temperature will not change simultaneously with input current. But I am still curious about if I can vary the laser parameter dynamically with the input current.


Hi @z_zhang,

First of all, they are all good questions.

Regarding your original question, i.e., writing a rate equation laser model using scripted element, I don’t think it is impossible, even though it is really not trivial. To begin with, you need to learn how to build a script element in the time domain (frequency domain is much easier). Some tutorials can be found following this link: You need to know the format for the optical signal frame:, and some other things. If you have already implemented the model in MATLAB, you don’t need to convert your scripts to Lumerical scripts because you can execute your MATLAB codes directly in the Scripted element, through the MATLAB integration: But still, you would need to know the basics of how to set up a scripted element, and how to pull in & push out you data (input current & optical signal). Another thing to keep in mind is that it is not very straightforward to debug things in the Scripted element. The “logmessage” command can be very useful.

Regarding temperature dependency and dynamically changing laser parameters with the input current, I will follow up with another reply.



Regarding temperature effect, right now all the primitive laser elements (CW Laser, DM Laser, Laser TW) do not have built-in temperature dependency, so you kind of have to do it yourself. One approach is wrap up one of the laser elements in a compound element, and a “temperature” property will automatically show up in the property view of the compound. Then you can control the parameters of the inside laser element through setup scripts. As an example, please find the attached project file laser_with_temperature_effects.icp (495.6 KB), where the compound elements also have a “include_T_effects” property (true or false) to illustrate the difference. The actual codes are quite simple and can be found in the Setup Scripts. Assuming the ambient temperature is 300 K, and with a particular injection current, the temperature increases by 0.1 degree (check the temperature property of the Root element, which by default is being inherited by the all the compound elements). For the second laser element where the thermal effects are included, the effective index and gain are slightly modified by the temperature, and thus resulting in a red shift in the spectrum, as shown in the plot below.

So this approach allows you to modify internal laser parameters based on a property (in this case the temperature). Two things to keep in mind: 1) you have to somehow link the input current with the temperature (assuming the temperature is not separately controlled, e.g., by a TEC), this could be done, for example, through a table of experimentally measured data; 2) the change of the property and thus the internal laser parameters are static, i.e., you can’t dynamically change it with the input current. This is indeed a limitation, and the only way to dynamically change the laser parameters with the input current would be integrating more functions directly into the laser models. For example, you could imagine having a property that takes a table of T vs. I as an input, and then add thermal coeffecients for the relevant laser parameters (e.g., gain, neff, ng), or even instead of adding more coefficients and making the list super long, you could replace the existing single-value parameters with a table (you can still use it as a single value if there is only 1 row).

Anyway, you could dream more, but this definitely requires some developement work. If you could provide a list of specific requests (e.g., which parameters you want to change dynamically, and the priority), that will be very helpful.



Regarding mode locked laser, I think in principle you could try the travelling wave laser model for actively mode-locked lasers. Given that I haven’t tried that out myself, I don’t want to comment too much on that at the moment. For passively mode-locked lasers where a nonlinear model is needed for the saturable absorber, I don’t think you can do that right now with INTERCONNECT, even though it is not impossible to add that model in the future. In spite of that, I find in most cases people just need the output pulse of the mode-locked laser, which can be easily represented in INTERCONNECT.

Not directly related, but with the TW laser model, you can do many other things like injection-locked lasers, coupled-cavity lasers, etc.


I just updated my INTERCONNECT to v6.0. I found out that my direct modulated laser model, previously working, is not compatible with the new version. I figured out the reason is I have to change the values of group index and gain suppression factor under the category “waveguide”. I do not understand the purpose of these two inputs, since the model already have group speed and gain suppression factor under “standard”. It would be nice if such change in the model could be posted as a new feature in the manual so that we can make changes to our model accordingly.


Hi @z_zhang,

Thank you for your notification and suggestion. You are the first one who noticed this change :slight_smile:

We are trying to always do backward compatibility, but sometimes it is not easy since we keep adding new features and new elements to the library. You are absolutely right that documentations of the new features can help a lot. We actually post ‘New Features’ online for each of the big releases (twice every year), documenting the major new features. For each of the elements, if you right click on it and select the ‘Help’ option, you will be directed to the element online help page with all details of the element listed.

For this particular element, we made this change to match it better with other waveguide elements in the library. If you open an old file, both the new properties (such as ‘group index’ and ‘gain compression factor’) and the old properties (such as ‘group velocity’ and ‘gain suppression factor’) are listed in the ‘Property View’ window. The new properties are calculated form the old ones, but that’s a one time conversion only and the model will use the new properties for its inner modelling afterwards. That’s being said that any changes of the old properties won’t affect this model any more and we will hide them in the next minor release so that only the new properties are visible. The newly added elements from the library will only have the new properties in the list.

We are sorry for causing this confusion and I will definitely keep you in the loop for availability of the next minor release when this conflict will be gone :slight_smile:


Hi @z_zhang,

As we discussed, your suggestions have been taken into consideration and in the new minor release of IC 2016b, the legacy properties of the old version of elements have been eliminated. You could check out the latest version of INTERCONNECT through the following link:

Thank you for all your suggestions to make our product better :slight_smile: