# How to avoid numerical overflow in diode current

edited April 2018
All the semiconductor devices have pn junctions, and the pn junction current is an exponential function of the across voltage. In the model, if the equation is written in the following form:

id = Is0*exp(q*vd/kt-1)

it can easily cause simulator run out of the sample-point region. To avoid this, MAST provides a limited exponential function: limexp which makes the equation is same accurate as exp in most practical regions, but more robust. the definition of limexp is:
if (x<0) { y=1/limexp(-x) }
else if (0 <= x <= 80) { y=exp(x) }
else if (80 < x<=88) {y = exp(80)*(x-79)
else if (88 <x < 88.7) {y=exp(80)*(88-79)*(1+1.0e-6*(x-88))
else {y=exp(80)*(88-9)*(1+1.0e-6*(88.7-88))

For VHDL-AMS models, saberhdl also provides same limited function:limiting_exp. In order to use that, you have to use ai_std package in your model.

For such equations, the newton_step will also improve the model robust.

• edited January 2014
I believe I am suffering from convergence issues due to the large number of diodes in my MAST model, and I would like to try using the limexp function that you have described. Could you possibly provide more information on how to make Saber use this as part of a diode model?
• Hi David,
Diode is one of problematic models in any of circuit simulator dut to its intrinsic expontential characteristics. In order to make it more robust to simulator, you may need several techniques together to help the convergence performance:
1. Use the the limexp() function instead of exp(), for simple diode equaiton: id = Is * limexp( vd/vt-1)
2. Use newton_step to limit the step to avoid overflow during newton step. This can be done in control_section in mast model.
3. You should also use dc_help(p,n) in control_section to improve DC convergence performance.
4. If the diode models are used in bridge circuit, it may also help the convergence by adding parasitic junction capacitor across the juncion if your diode model doesn't capacitance effect.

You can refer to the mast language reference manual for more detail infomation on these techniques. You can also send your diode model to me, I can take a quick look to see whetehr it has some potential convergence issue.

Thanks,
Min Zhang

• Thank you very much for that information, my simulation is now far more stable.