Hi there, I had a question on how to make changes in the definitions which are given in this tutorial.
Right now I try to modify the definition of sigma in this tutorial, but it ends up with an error. I saw this error has been posted previously, but would it be possible to change definitions in a proper way without such an error? If not, could someone explain for which reason?
I modified the definition from
E = 300000
nu = 0.3
mu = Constant(E / (2.0 * (1.0 + nu)))
lambda_ = Constant(E * nu / ((1.0 + nu) * (1.0 - 2.0 * nu)))
# Define Stress tensor
def sigma(u):
return lambda_ * nabla_div(u) * Identity(dim) + 2 * mu * epsilon(u)
to
E = 300000
nu = 0.3
mu = Constant(E / (2.0 * (1.0 + nu)))
lambda_ = Constant(E * nu / ((1.0 + nu) * (1.0 - 2.0 * nu)))
# Define Stress tensor for Neo-Hookean material
def sigma(u):
I = Identity(dim)
F = I + grad(u)
J = np.linalg.det(F)
C = F.T*F
C_inv = np.linalg.inv(C)
I1 = np.trace(C)
return mu/J * (F - (1./3) * I1 * C_inv) + lambda_/J * ln(J) * I
Despite, the following error is received. I guess it might have something to do with the way the determinant of the matrix is determined.
---[precice] iteration: 1 of 30, time-window: 1 of 100, time: 0, time-window-size: 0.0001, max-timestep-length: 0.0001, ongoing: yes, time-window-complete: no, write-iteration-checkpoint
---[precice] initializeData is skipped since no data has to be initialized.
Traceback (most recent call last):
File "/home/username/preCICE/tutorials/elastic-tube-3d/solid-fenics/solid.py", line 169, in <module>
res = m(avg(a_n, a_np1, alpha_m), v) + k(avg(u_n, du, alpha_f), v)
File "/home/username/preCICE/tutorials/elastic-tube-3d/solid-fenics/solid.py", line 112, in k
return inner(sigma(u), sym(grad(v))) * dx
File "/home/username/preCICE/tutorials/elastic-tube-3d/solid-fenics/solid.py", line 93, in sigma
J = np.linalg.det(F)
File "<__array_function__ internals>", line 180, in det
File "/home/username/.local/lib/python3.10/site-packages/numpy/linalg/linalg.py", line 2150, in det
_assert_stacked_2d(a)
File "/home/username/.local/lib/python3.10/site-packages/numpy/linalg/linalg.py", line 197, in _assert_stacked_2d
raise LinAlgError('%d-dimensional array given. Array must be '
numpy.linalg.LinAlgError: 0-dimensional array given. Array must be at least two-dimensional
---[precice] Implicitly finalizing in destructor
---[precice] ERROR: The required actions write-iteration-checkpoint are not fulfilled. Did you forget to call "markActionFulfilled"?
Already thanks for any help & suggestions.