About the stiffness matrix

Hi, thank you for the SfePy. I wish to apply SfePy in my research project, but I'm now having a few problems. I want to get the stiffness matrix for postprocessing by my self. The pb (Problem) object has an attribute namely mtx_a, is it the stiffness matrix I'm looking for? If so, I get some puzzles: in my view, after "pb = Problem('name',equations=eqs)" and "pb.set_bcs", the problem has been already clearly defined. But so far the pb.mtx_a is still a non-type object and I can get the pb._mtx_a only after "pb.set_solver(nls)", "pb.solve()". I believe the stiffness matrix is determined only by the problem itself and corresponding essential boundary conditions, not including the solvers. So could you please tell me why is that, or where can I find the proper stiffness of the problem? Looking forward for your answers, and thank you again for this wonderful project!

Hi,
On 20/08/2022 14:30, jiahao chen via SfePy wrote:
Hi, thank you for the SfePy. I wish to apply SfePy in my research project, but I'm now having a few problems. I want to get the stiffness matrix for postprocessing by my self. The pb (Problem) object has an attribute namely mtx_a, is it the stiffness matrix I'm looking for? If so, I get some
Yes, but... (see below).
puzzles: in my view, after "pb = Problem('name',equations=eqs)" and "pb.set_bcs", the problem has been already clearly defined. But so far the pb.mtx_a is still a non-type object and I can get the pb._mtx_a only after "pb.set_solver(nls)", "pb.solve()". I believe the stiffness matrix is determined only by the problem itself and corresponding essential boundary conditions, not including the solvers. So could you please tell me why is that, or where can I find the proper stiffness of the problem?
pb.set_bcs() only sets the BCs, it neither allocates the matrix nor assembles it. pb.time_update() has to be called to actually apply the BCs of the current time-step and pre-allocate the matrix structure, based on the mesh graph. See [1], item 8.
Looking forward for your answers, and thank you again for this wonderful project!
Thanks & cheers,
r.

Thank you for the instructions, but I still got a few problems. First I found the stiffness matrix (pb.mtx_a) was not in the expected shape. In the example file "linear_elastic_interactive.py", the total number of vertices was 258, which means the stiffness matrix should be in shape (258,258), but it turned out to be (1815,1815). I am quite confused and cannot figure out where 1815 comes from. Besides, I tried the code in 1 to get access to the tangent matrix K, but an error occurs: "material data not set! (call time_update())". I called time_update as guided, but this error still exists. The pb object was created in the example file "linear_elastic_interactive.py", so it should be well defined. Could you please tell me where goes wrong? Thanks!

On 23/08/2022 12:49, jiahao chen via SfePy wrote:
Thank you for the instructions, but I still got a few problems. First I found the stiffness matrix (pb.mtx_a) was not in the expected shape. In the example file "linear_elastic_interactive.py", the total number of vertices was 258, which means the stiffness matrix should be in shape (258,258), but it turned out to be (1815,1815). I am quite confused and cannot figure out where 1815 comes from. Besides, I tried the code in 1 to get access to the tangent matrix K, but an error occurs: "material data not set! (call time_update())". I called time_update as guided, but this error still exists. The pb object was created in the example file "linear_elastic_interactive.py", so it should be well defined. Could you please tell me where goes wrong?
First, the FAQ misses one line:
pb.update_materials()
Then it should work.
As for the matrix shape, it is 2 * number of active DOFs. Note that the field has the approximation order 2, so there are additional DOFs to those in the mesh vertices. Try changing the order to 1.
r.
participants (2)
-
jiahao chen
-
Robert Cimrman