Integration With Eigen
Clone this wiki locally
It would be useful to integrate Eigen library in ktechlab, because the following benefits:
- less code to maintain
- tested solution, actively developed
The decomposition is done at the construction of the LU. At this step it allocates memory for its data structures and performs LU decomposition in O(n^3^) operations.
When the solve method is called, is gives result in O(n^2^) operations.
The problems with integration:
- The caching algorithm is not clear to me, so I just skipped it. This has performance impact
- For nonlinear circuits, the equations must be solved more than once per step. Because the LU must be rebuilt for each iteration, it allocates memory and frees it in each step many times.
Also the fact that the equations don't change very much in each step could be exploited. If A0 * X0 = B0 from the previous iteration, in the next step (A0 + A1)*X = B0 should be solved, wheree A1 is sparse and contains small valued elements.
TODO: graphic here
Internally the simulator runs 1000 steps in one second. Each step takes a number of operations. So if the CPU usage is too high, the number of ticks could be reduced, so the CPU usage could be reduced.
Another possible tuning parameter can be the elapsed time in the circuit between two simulator steps. This way we could set the tradeoff between the precision (and possible convergence problems) in the circuit and the length of time interval simulated.