AUTO-ADMIN: Non-MP3, WAV, OGG, SoundCloud, YouTube, Vimeo, Twitter and Facebook links in this post have been protected automatically. Once the member reaches 5 posts the links will function as normal.
I would have BSD licensed it if I could have, but the solver algorithm I used (KLU) is GPL licensed so that forced me. If this is allowed under the GPL, I'll give you full permission to steal components from this, I'm also curious to see how you would improve upon the opamp.mystran wrote: Thu Sep 07, 2023 9:11 pmInteresting.timothyschoen wrote: Thu Sep 07, 2023 8:18 pm It's still very close to the Halite source, but with some components added (op-amp, transformer, gyrator, potmeter, current source). It also has a much faster solver for matrix, which makes quite a difference.
The original currently lives here: https://gist.github.com/signaldust/74ce ... 4a19ce8365 (https://gist.github.com/signaldust/74ce12ae67bf21a8141f9b4a19ce8365)
I can't really take your extra components back to the original, because I don't want to restrict the original with GPL, but .. I wonder how well does the OpAmp converge? Usually with sigmoids, one tends to run into problems with the trivial formulation of Newton in the clipping region especially when the signal changes polarity as the iteration diverges. If I recall correctly, a simple hack to fix this is to simply detect the divergence (ie. polarity changes and magnitude is larger) and reset the voltage to zero for the iteration in this case (which should usually then allow convergence again, though .. this might not be the fastest way overall).
The solver is really the weakest part of Halite though, one could do MUCH better, especially partitioning so that we don't need to refactor the whole thing for every iteration, but I specifically wanted to opt for simplicity. That's why it's the most simple thing that could work and very slow. On the other hand, the original stamps DO kinda assume a more intelligent solver, as some of them could be made smaller if we assume the solver is dumb... oh well.
For best performance it makes sense to partition for fast partial refactor (or rank-n update) and then JIT the whole solver into native code (the speedup over Halite's naive solver is almost always double digits), but that'd been "slightly" overkill for a simulator intended mainly as an example of how this stuff can be put together.
You can post links just fine, with new users it just adds a (temporary) popup confirmation.EDIT: looks like I'm not allowed to post links yet.. but if you find the pd-else repo, go to Code_source/Compiled/Audio/circuit~.
The link doesn't seem to work though 'cos the tilde... but got close enough.
KLU is specifically made for circuit equations, and performs very well, since it can update the factorisation instead of recalculating it every time. I believe it divides the matrix into smaller parts that are faster to solve. I've tested a few solvers, and this one was the fastest by far. Of course, a clever JIT compiled solver would beat it, I've tried writing one in the past but that was no fun.
I'm not as familiar with electronics as you clearly are, so take my implementations with a grain of salt. The components are mostly inspired by implementations from other FOSS apps or docs I could find online, but I've used the OpAmp for filtering and drive circuits, and those behaved very well. Though recently I tried to build a Tube Screamer, which did not seem to work, possibly because of what you just described.
But thanks for your work on this and for making it public, it made me dive down this rabbit hole, and it has been a lot of fun.
