Hi Andrew,
Il 06/12/23 02:29, Andrew Simper ha scritto:
Thanks for sharing what you're up to! It's a good point with ordering
of variables to be solved, which is critical for a stable solution for
me. I've found solving for all the non-linear dependent voltages (ie
voltages that are inputs to non-linear terms) first really helps. The
linear dependent terms are trivial to solve for after that, and in
fact don't need to be solved for until after the final
convergence iteration.
Actually, the way I do modeling, having the nonlinear part solved first
is sort of implied, and if you think about it that's also how WDFs end
up working after being properly scheduled. This sort of algorithm
structure also naturally popped up while researching explicit solutions
of nonlinear systems (yes, sometimes it's possible, see e.g. [1, 2]).
OTOH I sometimes solve for voltages, other times for currents...
whatever is most convenient in the specific case.
As far as the simplification goes, I want to avoid _any_ hand
optimisations, I want to be able to batch apply any improvements to
all pervious circuit specifications, so to this end I've found full
pattern matching substitutions and simplifications really useful. No
hand optimisations are needed for any of the code generated, and if I
can see any possible optimisations I update the code generator to do
them. The optimising solver can pull out common sub-expressions at
every level of "set" call: derived constants, set sample rate, set
parameter, process call pre convergence loop, inner convergence loop,
post convergence loop. I can crank up the handle on how much time to
spend on such simplifications for the release build, but while testing
I keep it faster so the generated code can be tested quicker for how
it sounds.
I guess if you invest enough time into that, as you seem to have done,
then it could actually be worth it. I always tend to add a few manual
touches afterwards so it doesn't bother me, plus sometimes it's hard to
tell whether storing a limited number of sub-expressions is actually
better than recomputing, given how modern computer architectures work.
Does maxima have a function to generate a psuedo matrix inversion as a
list of optimised steps to solve the matrix? If there is one can you
please let me know the function name?
I don't even think Maxima has a decent matrix pseudo inverse operation.
I might be totally wrong though.
Best,
Stefano
[1] R. Giampiccolo, S. D'Angelo, A. Bernardini, and A. Sarti, "A Quadric
Model of Vacuum Tubes for Virtual Analog Applications", DAFx-23.
[2] S. D'Angelo, L. Gabrielli, and L. Turchet, "Fast Approximation of
the Lambert W Function for Virtual Analog Modelling", DAFx-19.