# A deterministic way to determine states of ideal diodes

How can the states of ideal diodes be determined in simple circuits with only DC sources and resistors without a trial and error approach?

I have been told to use a technique known as analysis by assumed states of ideal diodes which assumes a set of of states of the diodes (ON/OFF), then we proceed by checking if there is an inconsistency with our assumptions (like current flowing from a reverse biased diode or having a higher potential at anode than cathode in forward biased diode). I dislike this technique due to the following reasons:

1. Counter examples can disprove a result but there is no such thing as proof by example. I don't see a justification of the current moving in assumed directions at all.

2. This technique does not show the uniqueness of solution.

3. This is exhaustive enumeration, with $n$ diodes we may have to check $2^n$ cases in the worst case scenario (worst still if you come to the conclusion that no solution exists!).

So, is there a better way (preferably deterministic) to solve such circuits?

• Remark: the same question was asked on the math site: math.stackexchange.com/questions/1448477/… but that's probably ok in this case... it's a rather obscure topic. Commented Sep 25, 2015 at 4:02

## 2 Answers

A "better" way involves changing the model of the diode you're using. The ideal diode model is a discontinuous model so the intermediate value theorem doesn't apply. A better model of the diode is the Shockley diode model, which approximates the V-I relationship as an exponential. Unfortunately, this often leads to a non-linear system of equations with no analytical solution so a numerical algorithm is required. One such algorithm is the Newton-Raphson method, which frames a non-linear smooth system of equations as a root-finding problem, then iterates until a suitably close solution is found. Other methods such as bisection may not require smoothness, but only continuity at the cost of slower convergence/other tradeoffs.

For discontinuous models, the only real solution is to guess and check. You might have some intuition built up from practice on what are good guesses, but at the end of the day there's no alternative.

This method can show uniqueness if you check all possible combinations. However, in most practical cases you can analyze by hand it is often assumed that there is a single unique solution because the cases where there isn't a unique solution are ill-posed mathematically, such as this case:

simulate this circuit – Schematic created using CircuitLab

Assuming $V_1 \gg V_D$ and the two diodes have identical forward voltage drops (close is not good enough!), D1 and D2 would both be forward biased leading to two parallel voltage sources. It's impossible without additional information to solve this network.

• Well, you are right that MNA (like SPICE uses) normally assumes smoothness (not simply continuity). But there are tractable methods for ideal componets; see en.wikipedia.org/wiki/… for a pointer There's only one piece of software that I know of that can do non-smooth analysis (of circuits): Acary's siconos.gforge.inria.fr It's rather experimental. Commented Sep 23, 2015 at 17:07
• Not having continuously differential functions is a recipe for convergence failure in SPICE. It's better to use functions such as tanh that approximate discontinuous functions arbitrarily closely if you want to model an ideal diode. Commented Sep 23, 2015 at 17:09

Dealing with the ideal diode characteristic is actually conceptually harder (mathematically) than dealing with the smooth (not just continuous) Shockley equation.

Since you're actually asking only about R+ideal_diode... (sans LC) things should be simpler than RLC+ideal_diode, since there are no [advanced substitutes of] derivatives to deal with, only piece-wise linear [algebraic] systems of equations. I suggest you read chapter 11 (on piece-wise linear circuits) of Feedback, Nonlinear, and Distributed Circuits (2009) or at least section 11.15, but it will probably not make much sense you sans the background introduced in the previous sections. I haven't read the whole chapter yet, but it seems that even in R+diode circuits (or at least in ideal opamps + resistor circuits):

• solutions aren't necessarily unique (the book defers to http://dx.doi.org/10.1109/31.17586 for details on that)
• algorithms for finding all solutions have indeed to check for all regions of the state-space polyhedron; e.g. those by Yamamura (such as http://dx.doi.org/10.1002/cta.208 which seems practical enough)
• algorithms for finding only one solution, e.g. Katzenelson's can finish sooner if lucky, but it seems worst case is also a full state-space exploration

The book Piecewise Linear Modeling and Analysis (1998) is a more in-depth treatment of the topic with numerous algorithms discussed. It's not as EE-oriented but it does have EE motivating examples, e.g. ideal diode; actually it does have a chapter (5) just on circuit applications.

Regarding 2n state-space search with n-diodes... the 1998 book says on p. 80 that the LCP problem (which is what Katzenelson's algorithm solves) is NP-complete... so I suspect the general formulation of PWL circuit is NP-complete too; but note that LCP allows non-monotonic piecewise functions, such as using ideal opamps [or idealized tunnel diodes] plus resistors. I not 100% sure that just using ideal_diodes+resistors still is an NP-complete problem, but... (see next para)

The 2009 book has this bit

we illustrated with an example how a PWL one-port resistor can be realized with linear resistors and ideal diodes. This can be proven in general. One essentially needs a diode for each breakpoint in the PWL characteristic. Conversely, each one port with diodes and resistors is a PWL one port resistor

So it seems that ideal diodes and resistors are all that's needed to get all the complexity possible with any PWLs.

For practical puproses the intro to this 2005 paper cites half-dozen software pieces that can solve such PWL circuit problems... but practically all of them are two-decades old now and being academic software... tough luck if any are still maintained. But see last paragraph for maintained software (Siconos) that can solve RLC+diodes.

For RLC+ideal_diode circuits you're dealing with a non-smooth dynamical system and simple mathematical notions like the derivative need to replaced with more obscure/advanced mathematical concepts like differential inclusion or subdifferential (those are not the only ways though; other are complementarity theory and differential variational inequality formulations.) Note that complementary theory in the form of LCP is used/useful even for R+diode.

There are algorithms/methods for solving non-smooth systems (in these various math formulations), but they're not commonly used in the EE industry. If you're interested in academic/research-level stuff... Acary and Brogliato have a book and a piece of software called Siconos that can solve such systems. The best intro from a EE-applications perspective is probably the 1st chapter from the aforementioned the book. To get a free preview/summary of the material, try this presentation first; it covers the 4 math formulations I've mentioned for instance... as applied to a RCL+diode_circuit but that presentation won't alas teach you much about the math used.

• I was actually quite wrong about piece-wise linear not being used in the industry. The power supply focused sims (and I think some PLL-focused ones too) use this approximation extensively; SIMPLIS is perhaps the best known. POWER 4-5-6 too I think. Commented Dec 7, 2015 at 6:56
• Also PSIM. Commented Dec 7, 2015 at 7:02