# Ideal Diode and Ideal Switch instability problem

**URL:** <https://discourse.julialang.org/t/ideal-diode-and-ideal-switch-instability-problem/107769>\
**Category:** Modelling & Simulations\
**Tags:** question, modelingtoolkit\
**Created:** [December 18, 2023, 1:33pm UTC](https://discourse.julialang.org/t/ideal-diode-and-ideal-switch-instability-problem/107769 "2023-12-18T13:33:58Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![pierre-haessig](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pierre-haessig/32/217129_2.png) [@pierre-haessig](https://discourse.julialang.org/u/pierre-haessig)\
**Post date:** [December 18, 2023, 11:04pm UTC](https://discourse.julialang.org/t/ideal-diode-and-ideal-switch-instability-problem/107769/4 "2023-12-18T23:04:21Z")

</div>

For the reference, these are the simplified, compactified equations of Modelica Standard Libary’s 4.0 `IdealDiode`:

```Modelica
parameter Real Ron = 1e-5
    "Forward state-on differential resistance (closed resistance)";
parameter Real Goff = 1e-5
    "Backward state-off conductance (opened conductance)";

 Real v "voltage drop";
 Real i "current";
 Boolean off(start=true) "Switching state";
 Real s "Auxiliary variable for actual position on the ideal diode characteristic";
  /* s = 0: knee point
     s < 0: below knee point, blocking
     s > 0: above knee point, conducting */

equation

  v = s * (if off then 1 else Ron);
  i = s * (if off then Goff else 1) ;
  off = s < 0;

```

Would this approach be implementable in MTK?

References:

- [IdealSemiconductor.mo](https://github.com/modelica/ModelicaStandardLibrary/blob/master/Modelica/Electrical/Analog/Interfaces/IdealSemiconductor.mo)
- [IdealDiode.mo](https://github.com/modelica/ModelicaStandardLibrary/blob/master/Modelica/Electrical/Analog/Ideal/IdealDiode.mo)

---

_[View the full topic](https://discourse.julialang.org/t/ideal-diode-and-ideal-switch-instability-problem/107769)._
