From 76546aa8c8770d232f4e17bdb8872b164523ec67 Mon Sep 17 00:00:00 2001 From: Andreas Dutzler Date: Thu, 22 May 2025 15:41:57 +0200 Subject: [PATCH 1/3] Fix stability check for new implementation of `LabIncompressible` (#149) * Fix stability in `LabIncompressible` add a (fake) volumetric strain energy function * Update __about__.py --- src/matadi/__about__.py | 2 +- src/matadi/_lab_incompressible.py | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/matadi/__about__.py b/src/matadi/__about__.py index 260c070..f9aa3e1 100644 --- a/src/matadi/__about__.py +++ b/src/matadi/__about__.py @@ -1 +1 @@ -__version__ = "0.3.1" +__version__ = "0.3.2" diff --git a/src/matadi/_lab_incompressible.py b/src/matadi/_lab_incompressible.py index 6ca354b..793dd57 100644 --- a/src/matadi/_lab_incompressible.py +++ b/src/matadi/_lab_incompressible.py @@ -4,7 +4,7 @@ import numpy as np from ._templates import MaterialHyperelastic -from .math import det +from .math import det, log class LabIncompressible: @@ -50,6 +50,10 @@ def stability(stretch): P = self.material.gradient([F])[0] A = self.material.hessian([F])[0] + + # volumetric parts of strain energy function (required for stability) + U = lambda F: 1e6 * log(det(F)) ** 2 / 2 + Ap = MaterialHyperelastic(U).hessian([F])[0] d2JdFdF = MaterialHyperelastic(lambda F: det(F)).hessian([F])[0] # hydrostatic stress @@ -57,11 +61,9 @@ def stability(stretch): # convert hessian to (3, 3) matrix B = np.zeros((3, 3)) - c = [(0, 0), (1, 1), (2, 2)] - - for i, a in enumerate(c): - for j, b in enumerate(c): - B[i, j] = (A + p * d2JdFdF)[(*a, *b)] + for i in range(3): + for j in range(3): + B[i, j] = (A + Ap + p * d2JdFdF)[i, i, j, j] # init unit force in direction 1 # calculate linear solution of stretch 1 resulting from unit load From ed3e97937d767243b882af739699745bd4e066ab Mon Sep 17 00:00:00 2001 From: Sadjad <65682889+Sad-Abd@users.noreply.github.com> Date: Wed, 4 Jun 2025 22:47:26 +0330 Subject: [PATCH 2/3] Added tension-only fiber response to HGO model #150 (#151) --- src/matadi/models/_hyperelasticity_anisotropic.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/matadi/models/_hyperelasticity_anisotropic.py b/src/matadi/models/_hyperelasticity_anisotropic.py index 4c7d7c7..12fa60d 100644 --- a/src/matadi/models/_hyperelasticity_anisotropic.py +++ b/src/matadi/models/_hyperelasticity_anisotropic.py @@ -10,6 +10,7 @@ sqrt, trace, transpose, + if_else ) from ._helpers import isochoric_volumetric_split @@ -73,8 +74,12 @@ def holzapfel_gasser_ogden(F, c, k1, k2, kappa, angle, axis=2): W_iso = c / 2 * (I1 - 3) - w4 = exp(k2 * (kappa * I1 + (1 - 3 * kappa) * I4 - 1) ** 2) - 1 - w6 = exp(k2 * (kappa * I1 + (1 - 3 * kappa) * I6 - 1) ** 2) - 1 + E4 = kappa * I1 + (1 - 3 * kappa) * I4 + E6 = kappa * I1 + (1 - 3 * kappa) * I6 + + # Tension-only fiber response + w4 = if_else(E4 > 1, exp(k2 * (E4 - 1)**2) - 1, 0) + w6 = if_else(E6 > 1, exp(k2 * (E6 - 1)**2) - 1, 0) W_aniso = k1 / (2 * k2) * (w4 + w6) From 5eece1942e9923b8f0eb4f1758d3b71a41be4bfb Mon Sep 17 00:00:00 2001 From: Andreas Dutzler Date: Wed, 4 Jun 2025 21:18:52 +0200 Subject: [PATCH 3/3] format black and run isort --- src/matadi/models/_hyperelasticity_anisotropic.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/matadi/models/_hyperelasticity_anisotropic.py b/src/matadi/models/_hyperelasticity_anisotropic.py index 12fa60d..a80fe1e 100644 --- a/src/matadi/models/_hyperelasticity_anisotropic.py +++ b/src/matadi/models/_hyperelasticity_anisotropic.py @@ -10,7 +10,6 @@ sqrt, trace, transpose, - if_else ) from ._helpers import isochoric_volumetric_split @@ -78,8 +77,8 @@ def holzapfel_gasser_ogden(F, c, k1, k2, kappa, angle, axis=2): E6 = kappa * I1 + (1 - 3 * kappa) * I6 # Tension-only fiber response - w4 = if_else(E4 > 1, exp(k2 * (E4 - 1)**2) - 1, 0) - w6 = if_else(E6 > 1, exp(k2 * (E6 - 1)**2) - 1, 0) + w4 = if_else(E4 > 1, exp(k2 * (E4 - 1) ** 2) - 1, 0) + w6 = if_else(E6 > 1, exp(k2 * (E6 - 1) ** 2) - 1, 0) W_aniso = k1 / (2 * k2) * (w4 + w6)