Scipy performance python gauss seidel

broken image
broken image
broken image

9s simulation times respectively in Numpy and MATLAB). The speed drawbacks in Numpy are more pronounced for the full version (17s vs. The full algorithm uses successive overrelaxation and a checkerboard iteration scheme to improve speed and remove solver directionality, but for purposes of simplicity I provided this easier to understand version. This is actually not the full algorithm which I use. It finishes when the maximum difference between updates on the mesh is less than the indicated tolerance. The algorithm simply solves the discretized Laplace equation on a rectangular mesh (in cylindrical coordinates). I would like to use Numpy, however, since this code is part of a larger program, the almost twice as long simulation time is a significant drawback. The Matlab code runs in ~20 s whereas the Numpy codes takes ~30 s. The code was originally written in MATLAB and then transferred to Python. I currently have a Gauss-Seidel solver implemented in both MATLAB and Numpy which acts on a 2D axisymmetric domain (cylindrical coordinates). This question is a follow-up to a recent question posted regarding MATLAB being twice as fast as Numpy.

broken image