laser gain simulation


Hi I’m trying to simulate laser spectrum simulation with user defined gain

So I followed TW laser model gain fitting example.

It is working when I use example ‘sampleGainData.txt’ file
but when I use my own test gain file simulation failed(Multi coefficient fitting failed).
And I don’t know what is problem.
testgain.txt (3.3 KB)


Hi @minkyu226,

It seems like the “mczfit” command doesn’t work on 2 gain curves as I tested. It works on all other number of curve(s). Thank you very much for bringing this to our attention and I’ve reported this bug. I will definitely keep you in the loop on the fixing progress :slight_smile:


Hi gwang

Thank you for your help.

But I tried with other number of curves but it failed too.
testgain1.txt (5.6 KB)


Hi @minkyu226,

I dug up a bit and found that, the problem is because you have some empty spaces in your file that our solver does not recognize of, so that the mczfit fails. I modified your file a bit to clean up all the empty spaces and now the fitting works fine. The modified files are attached here: testgain1_modified.txt (5.6 KB), fitplotBasic_modified.lsf (862 Bytes), and the fitting result is as below:

To add on to my previous reply, the “mczfit” function won’t work on 2 gain curves (but it does work on one single gain curve fitting) because the fitting algorithm we are using has an interpolation step if the gain curves have dependence on carrier densities and it cannot perform the interpolation for just 2 gain curves. So if the gain curves do depend on carrier densities, there should be at least 3 curves to be enough for the fitting.

I will file a feature request on this to let the solver detect and remove the unnecessary special characters in the file automatically and will keep you in the loop on the progress.


Thank you for your help


Many thanks!



With your help I was able to get gain file using testgain.txt (3.1 KB) file to make gain file.

And I got this graph

  1. There is some error at boundary how can I fix it?

  2. I want to simulate and get laser spectrum and IV curve with this gain material.
    I tried by using FP-laser example but there is error in TWLM element.
    How can I get laser spectrum and LI curve with this gain material


Hi @minkyu226,

I am glad you made it work. Regarding your questions:

The fitting takes several taps to converge so you may always see some misalignment at the boundary. This is the nature of the fitting algorithm and I don’t think there is a way you can fix it. But you can enlarge the frequency range a bit beyond the exact range you want to fit so that you can guarantee the fitting is converged in the area you are interested.

Please try to use the example file linked in the Gain Fitting page. You have to load the file generated by the ‘mczfit’ command to the TWLM element:

But you will have to carefully tune the other parameters based on your design as well to make it work.

I hope this could help :slight_smile: