(It's been a while since I've worked on this so some of this is foggy)mystran wrote: ↑Wed May 19, 2021 6:25 am Instead of partitioning the solution into just linear and non-linear parts, you can go further and partition the solution into "static", "dynamic" and "non-linear" where you factor out the static parts in precomputation, then compile code that factors the dynamic parts (eg. pots) once per time-step and only iterates the non-linear part (and similarly for the back-substitution part, where you only need to generate code to solve the nodes you actually need for things like capacitors and output).
I don't know what the LiveSPICE solve looks like, but if you use something like LU this is literally just a matter of ordering the rows and columns and then reordering/staging the factorization.
The solver is basically doing LU decomposition. It rewrites the system into an upper triangular matrix, except for the bottom right corner which has the non-linear equations and variables.
The problem I ran into is that I want to do that LU decomposition *symbolically*, so the solution (the back substitution) for the linear part of the system can be compiled code unique to that simulation, and the equations to generate the Jacobian for the non-linear solver are also compiled for that simulation. If you leave pots as variables, that symbolic upper triangular solve step is really messy, the expressions become impractically huge. They're both slow to solve for, and slow to run at runtime.
At runtime, the solver loop for each timestep basically looks like:
Iterate until convergence on all N variables (20-100 for typical circuits):
- Run J, the circuit-specific compiled code that generates the Jacobian for M non-linear variables (4-8 for typical circuits)
- Run dynamic solver on the Jacobian to solve for the next iteration of M non-linear variables
- Run L, the circuit-specific compiled back substitution code that generates the solutions for the N - M linear variables. This depends on the result of the dynamic solver for the last M variables
Skimming the thread to remind myself, I see we talked about this before I guess I'd have to see a more detailed description of what you are proposing to understand it. I've been stumped on this dynamic pot problem for a while now