stratum wrote: ↑
Thu Dec 06, 2018 1:38 pm
Is there any case the solver takes different paths of execution, resulting different contents in that text dump file? i.e. if node 1 voltage is below X, then the circuit behaves roughly linear and use the function generated from text dump file 1, otherwise use the one from text dump file 2 etc? It looks like one could check several such conditions depending on the circuit.
Yeah, there can be a few "corner cases" like that.
Most obvious case is where ideal switch will unify two nodes into one when connected (reducing MNA matrix dimension by one). You could cheat and treat them as very low value resistors instead (after all, wires do have some resistances in real-life), but even then you have to be careful not to pivot LU on those, because in disconnected states your conductance would be zero (although you could treat those as very high value resistors; could be reasonable for semiconductor switches, but not really for mechanicals).
So for switches (ie. "intentional topology changes") you might want to compile multiple versions depending on the configuration of switches. The strategy of adding small series/parallel resistances is pretty good at taking care of "accidental topology changes" with time-varying components though (and you probably need this stuff for robust Newton convergence anyway). Since static resistances can usually be constant folded away, this doesn't usually cost anything either.
The remaining problem then is when you end up choosing LU-pivots that turn out to be numerically very poor after dynamic values in the circuit change. This is not nearly as much of a problem in practice as one might think (as-in: it's actually hard to find good test cases), but it's something that I don't have a completely reliable solution for. For any given circuit, there is usually a pivoting order that is "universally good enough" that you can just set in stone, but finding that order might occasionally take some trial and error.
My current best strategy for the pivoting problem is to simply do a "test run" of the circuit normally, with pivoting heuristics that try to keep the order from the previous time-step/iteration unless there is a much better choice available. Surprisingly enough, this usually finds a stable order pretty quickly (and for most simple audio circuits it just picks the pivots once and never changes them afterwards), but it's not exactly what I'd call a "robust solution."
Anyway.. the thing is.. even if you were doing this stuff "manually" you'd still have to solve all these problems.