0

Here is a paragraph I came across:

Since transient analysis is dependent on time, it uses different analysis algorithms, control options with different convergence-related issues and different initialization parameters than DC analysis. However, since a transient analysis first performs a DC operating point analysis (unless the UIC option is specified in the .TRAN statement), most of the DC analysis algorithms, control options, and initialization and convergence issues apply to transient analysis.

As far as I know the traditional transient circuit analysis is done by Laplace transform which superpositions both transient solutions and steady state solutions.

But when it comes to SPICE, for high speed calculations it uses different techniques and algorithms to solve circuits which are very alien to me.

I know about Laplace transforms and circuit theory but I'm curious how SPICE solves a circuit(as a big picture)? I'm totally blank about it.

Can the flow of SPICE be explained in an easy manner as a big picture? What is meant by DC operating point analysis and what is UIC ect.? When we run transient analysis what does SPICE do comparing to a traditional circuit analysis on paper?

user1245
  • 3,955
  • 4
  • 37
  • 87
  • UIC = Use Initial Conditions. You never calculated the DC operation point or any circuit? – G36 Jun 20 '17 at 17:58
  • DC operating point analysis = solve for DC voltage/current in the circuit when all capacitors are treated as a open circuit and inductors as a short circuit. – G36 Jun 20 '17 at 18:00
  • I did for transistor circuits when finding load lines that was it. – user1245 Jun 20 '17 at 18:01
  • Transient analysis divided into how many parts in SPICE? I mean it solves DC and then do Laplace transforms? – user1245 Jun 20 '17 at 18:05
  • But transient analysis is done by Laplace transform isnt it? Not Dc operating point – user1245 Jun 20 '17 at 18:07
  • SPICE first solve for DC (voltage and current) and next start to solve the Transient response. By using some algorithms, but I do not know what kind of. – G36 Jun 20 '17 at 18:12
  • I believe you're asking about how SPICE software is able to make calculations? Try looking at [this question](https://electronics.stackexchange.com/questions/91416/how-do-circuit-simulators-actually-work). –  Jun 20 '17 at 18:12
  • basically more about transient analysis and use of DC operation point in transient analysis – user1245 Jun 20 '17 at 18:18
  • http://www.ecircuitcenter.com/SpiceTopics/Transient%20Analysis/Transient%20Analysis.htm – G36 Jun 20 '17 at 18:20
  • @G36 Really interesting website. Thanks for sharing. –  Jun 20 '17 at 18:25
  • @G36 Yes very informative link thanks I will read it slowly. Are you the author of this? Really cool – user1245 Jun 20 '17 at 18:27
  • No, I'm not the author. – G36 Jun 20 '17 at 18:29
  • The scope of your question is impossible to cover in an answer. Spice supports at least "transient analysis" (book on that topic alone), "DC operating point", "DC small-signal transfer function", "stochastic noise analysis", "DC sweeps", and "small-signal AC analysis." to name those that come to mind. Your question is HUGE. WAY TOO MUCH. – jonk Jun 20 '17 at 18:34
  • @jonk I was asking the big picture or flow. Let me give an example. Lets say you have an LCR circuit, and suddenly you switch it to a sinusoidal voltage source. You will have both initial transient solution and steady state. Laplace transform takes care of this. And there is no DC operating point thing used in Laplace transform when solving a circuit. But in SPICE there is DC operating point in transient analysis. That is my confusion. What is that about. – user1245 Jun 20 '17 at 18:39
  • @user134429, read my answer. SPICE does not use the Laplace transform, so that's not relevant. It uses numerical integration, so it needs to know the starting state of the circuit somehow. You can either let it do a DC analysis to find the starting state, or you can provide the initial conditions using `UIC` directives. – The Photon Jun 20 '17 at 20:51
  • @ThePhoton I see.., I simulated an RC circuit to see this. As you said in default mode before the transient analysis it performed DC analysis and found the capacitor's initial voltage as 0.5V. But when I opt out DC analysis, it attains zero as capacitor's initial voltage. Now I understand what is that about. Since caps are in general empty before the circuits are powered, DC analysis kind of hides the initial power switching response right? – user1245 Jun 21 '17 at 00:00
  • 1
    You can set the initial voltage on the capacitor to anything you want. In LTSpice, Ctrl-rightclick on the capacitor and change the 'SpiceLine' attribute to "IC=", and when you use `UIC` in the simulation card, the capacitor will get the initial voltage you specified. It should also work for inductor initial current. – The Photon Jun 21 '17 at 00:41

2 Answers2

2

In an answer to an old question I gave a run-down of the three main analysis types done by SPICE and SPICE-like simulators.

As far as I know the traditional transient circuit analysis is done by Laplace transform which superpositions both transient solutions and steady state solutions.

This is incorrect. SPICE typically does transient analysis using a time domain integration method, such as Runge-Kutta or Gear's method.

Where a transient simulation is solving a system of ordinary differential equations, DC analysis is solving a system of nonlinear algebraic equations. A simple method for this Newton's method, although a good SPICE will generally use something more robust.

Some simulators (ADS, for example) will let you choose different solution methods in case one method is quicker or more robust for a certain circuit.

Edit

In comments you asked,

My main question is SPICE dealing with DC operating point as a part of transient analysis?

This is answered in the quote you posted:

a transient analysis first performs a DC operating point analysis

This means that when you request a transient analysis (unless you use a .UIC directive, as pointed out in comments), the simulator first does a DC analysis, and uses the result of this as the starting state for the time domain analysis.

Whether this is "part of a transient analysis" or a separate step that isn't "part of" the transient analysis is a semantic question and you could view it however you like.

Note: If you request both DC analysis and TRAN analysis, most SPICE's are smart enough to not do the DC analysis twice. Does this mean the DC analysis is not "part of" the transient analysis? Again, it's really up to you how you want to look at it.

The Photon
  • 126,425
  • 3
  • 159
  • 304
  • My main question: is SPICE dealing with DC operating point as a part of transient analysis? Consider for example a passive LCR circuit. Because we don't do "DC op. point." thing when solving with Laplace transform – user1245 Jun 20 '17 at 18:55
  • @user134429 Spice typically has at least two choices in answer to your question here (I'm adding an answer of my own to provide a different perspective): you can request that Spice does NOT do a DC operating point analysis first, or else you can allow it to do that. Most of the time, people let it do the DC operating point analysis as a first step. But you can block it, if you want. You can also set initial conditions for any of the independent state variables. – jonk Jun 20 '17 at 19:05
  • Can you give an example and solve a simple RC circuit as if you are a SPICE program? Would that be too much effort? If so forget about it. – user1245 Jun 20 '17 at 19:06
  • 1
    @user134429 Sure. I could do that. However, it will have to wait as I have plenty of work I have to attend to right now. I'll consider adding a specific example, with details as actually used by Spice, to my answer. But it will be at least another 8 hours before I can take the time. – jonk Jun 20 '17 at 19:17
2

The subject of how Spice handles all the different analysis requests would fill a book. In fact, it fills books! There is no possible way to cover all of that here. (Nor can I pretend that I completely understand all of practical details involved.) However, I can consider the idea of addressing transient analysis, since I do understand that part of Spice better.

First off, I'd recommend that you purchase a copy of Laurence W. Nagel's (who is, to all intents and purposes the "father" of Spice) "Spice2: A Computer Program to Simulate Semiconductor Circuits," Memorandum No. UCB/ERL M520, 9 May 1975, which is available from "Electronics Research Laboratory, College of Engineering, University of California, Berkeley, CA 94720. (The title is slightly misspelled on the document you'll get, saying "Semicoductor" instead of "Semiconductor", but oh well.) This is the seminal and definitive document on Spice's operations. If you want the details, it's all there.

But the overview for transient analysis is something like this: Ideal branch relations are developed, constrained by explicit and implied Kirchoff laws. Then, cutset and loop analysis is applied. (Which, by the way, place limitations on the types of branch relations that can even be included in the circuit. So there are some kinds of equivalent replacements that take place about this time.) For formulating, a modified form of Nodal Analysis, or hybrid analysis (state variable analysis, for example), or the sparse tableau method (all variables in a huge vector and a very, very sparse system of circuit equations) are used.

In the end, numerical methods are also required of course. Some of the details also involve different numerical methods to solve, once all the formulation is complete. Many Spice programs include multiple approaches to numerical solutions. There are various problems that arise here, as the problem is basically very much like an infinite plane with all kinds of local minima and maxima and a very, very difficult time locating and finding the global maximum or minimum across that entire plane. Spice may get "trapped" into a local high/low point and not be able to find its way out of there. So there are other techniques which can help either recognize these issues and apply "tests" to see if it needs to widen the scope (source-stepping methods) or else start up multiple solutions and see which of them find the right global result (simulated annealing.)

A lot has happened over time and not all Spice simulators use all of the exact same tools and/or all in the same way, all of the time. This is one of the reasons that professionals may include several different implementations of Spice in their toolchest or, in the case of IC manufacturers, will have programmers on staff who continue to develop and modify Spice so that it handles cases they care about well.

But seriously, if you are really interested in understanding exact details (including examples provided), then I'd recommend that memorandum I mentioned above. It's not terribly expensive and it is, far and away, the best source for explicit details about how Spice works (with references for still more details, if needed.)

jonk
  • 77,059
  • 6
  • 73
  • 185
  • Did you really read the entire book? Its around 400 pages. Here is the book you mentioned:https://www2.eecs.berkeley.edu/Pubs/TechRpts/1975/ERL-520.pdf Please see page 9. At page 9 DC operating point is not part of transient analysis. It is part of only DC Analysis. But in another source it says: "However, since a transient analysis first performs a DC operating point analysis" Do you get my confusion? – user1245 Jun 20 '17 at 19:22
  • @user, look at page 16: "The initial timepoint, arbitrarily defined as time zero, is determined by a previous dc operating point solution". – The Photon Jun 20 '17 at 19:47
  • @jonk, Are you sure about your statement that "loop analysis is applied."? I've always learned that SPICE uses MNA (modified nodal analysis) and according to your source, "the MNA1 formulation method presently is implemented in SPICE2" [p. 85] – The Photon Jun 20 '17 at 20:08
  • @ThePhoton They mention MNA1 ***and MNA2*** and this is all dated back to 1975, when the doc was written. Anything I write will be "dated" in that sense. However, the document includes worked examples. The OP can draw from those examples. (I have some personal email with Mike, who writes Linear's Spice, and I may refer back to that.) – jonk Jun 20 '17 at 20:17
  • @user134429 Good catch on the PDF being available. I didn't know it was present at that link. THANKS!!! I guess I don't need to write anything at all now! Heck. Now I can just delete my answer and move your link to a comment to your question. ;) I'm really happy to see it publicly available now. – jonk Jun 20 '17 at 20:18
  • @jonk, what it says about MNA2 is "Although the MNA2 method is more efficient, the additional complication of [various things] render the MNA2 method less attractive." He also describes of other methods (mesh analysis, tableau analysis) that aren't in SPICE as part of the background material (this is basically a Ph.D. thesis published as a tech report). AFAIK, SPICE has always used various forms of nodal analysis, not mesh analysis. – The Photon Jun 20 '17 at 20:23
  • @ThePhoton Be aware that what was difficult back then (memory was VERY EXPENSIVE) isn't true, anymore. Sparse arrays are no longer "difficult." Yes, I completely agree with you about nodal analysis. Every single time when I've tried to duplicate spice results in my own software, my nodal analysis approach duplicated Spice's results. I'm sure nodal is used. – jonk Jun 20 '17 at 20:27
  • @ThePhoton However, if you want, I'd be happy to write Mike and ask him about the current state of LTSpice and what he may know about other implementations today. It might be interesting and I could post up his comment. However, he may take a little while to get there. I don't assume that ***only*** nodal analysis is used today, to the absolute exclusion of everything else. Chances are, that some Spice tools will offer various techniques. People are very creative. – jonk Jun 20 '17 at 20:28
  • 1. Even ERL520 talks about using sparse matrix techniques (more necessary then due to limited memory) 2. I think it's still a lot easier to code the nodal analysis (because it's obvious how many nodes there are) than the mesh analysis. I would expect anybody who implemented something with a fancier graph analysis would advertise that fact by calling their tool something other than "SPICE". 3. LTSpice's help says it's based on Berkeley SPICE 3f4, but "has gone through a complete re-write"...I would be surprised though if that includes changing to mesh analysis --- why fix what isn't broke? – The Photon Jun 20 '17 at 20:47
  • @ThePhoton yeah. I don't think mesh is used for the later formulation step. – jonk Jun 20 '17 at 20:48