On 29. 08. 22 8:50, jhchen via SfePy wrote:
I’ve been able to get the stiffness matrix under your help, but I still get several puzzles about the linear system components  (8):
Is the linear system in the matrix formula: Kx=r ? I exported both K and r to matlab to used the right division to get x: x = r \ K. But this gave me a different result from variables = pb.solve() and x = variables.vec. Analysis showed that pb.solve() gave the appropriate result, what’s the difference between the two approaches?
Not sure. SfePy uses the approach described in , maybe it is related to your issue.
In my project, the measurements (knowns) are Φ on surface (∂Ω) and the unknown is the source distribution Q in attached ProblemDescription.docx. So I need to separate the vectors Φ and Q (nodal values of Φ(x) and Q(x)) explicitly in the matrix form, which means I need to get the matrix F: (FQ is the discretized form of ∫_Ω▒Q(x)s(x)dx in (2), where Q(x) is the source distribution, s(x) is the test function). How can I get this matrix?
I thought Q is a given parameter. In this inverse setup, you probably need to make Q another FE field variable and use dw_dot term for the integral with Q. After discretization, you will obtain a mass matrix * Q.
I found that the solver in SfePy was much faster than the right division in matlab, so I’m curious that which function does SfePy adopts to solve the linear system. Besides, my project requires the inversion of a sub-matrix of the stiffness matrix K, does SfePy offer such methods or which function do you recommend to invert such a banded sparse matrix?
SfePy uses scipy.sparse.linalg.spsolve (SuperLU or UMFPACK, if available).