Dear all,

I developed a hybrid Phase Field-Finite Element Model (PF-FEM) for fracture of electrode particles of Li-ion batteries. Code [Isotropic & Hybrid] Phase Field-Finite Element Model (PF-FE...

I wrote the code in MATLAB and currently, I'm trying to convert it into Python.

One of the main speed problems with FEM codes is solving Q=K\R, in which Q is the field variables vector, K is the tangential stiffness matrix and R is the nodal residual vector.

When I use MATLAB, in order to reduce the speed of the above calculation (and all calculations regarding stiffness matrix), I define K using "sparse" command instead of "zeros" command since most of the arrays of K matrix are equal to zero. This approach dramatically reduces the calculation speed for the large stiffness matrices.

Now that I'm converting the MATLAB code into a Python code, it is very slower than the MATLAB code; I use "numpy.zeros" to define K in the Python code.

So, my question is what is the best way to define K in order to speed-up the FEM code in Python for the large stiffness matrices? Is ther a command like sparse in MATLAB to do this?

Kind regards,

Masoud

More Masoud Ahmadi's questions See All
Similar questions and discussions