Why do I have to initialize the deformation gradient with zeros?
See original GitHub issueWhy do I have to initialize the deformation gradient with zeros, add the ones to the diagonal terms and finally add the displacement gradient? I mean I tried to write down
F = grad(u)
for i in range(3):
F[i, i] += 1.
instead of
F = zeros_like(grad(u))
for i in range(3):
F[i, i] += 1.
F += grad(u)
but this seems to give a different result. Honestly, I do not understand why. Do you have any explanation for that? (I took the code snippet from example 36)
In addition to that,I find the different import statements for math helpers a bit confusing - although I understand why they are necessary. I mean these imports:
from numpy import (einsum, linalg as nla, zeros,
zeros_like, concatenate, split as npsplit,
hstack, abs as npabs, arange, sqrt)
from skfem.helpers import grad, transpose, det, inv
In the beginning I did not understand why I can’t use det
and inv
from numpy.linalg
but then I realized the special structure of the arrays (3,3,n,m)
. I think this shape is used in order to obtain a reasonable performance with Python/NumPy 😄
Anyway, I’ll experiment with the examples and I hope Github Issues are the right place to ask. Thanks and with best regards, Andreas
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (8 by maintainers)
Top GitHub Comments
This is a classical mistake when using numpy. I did not notice it first but now it’s obvious.
One should write
instead. Otherwise you’ll modify the contents of
w
.This is correct. Here is some information related to the forms: https://scikit-fem.readthedocs.io/en/latest/forms.html#helpers-are-useful-but-not-necessary