+
Skip to content

Fix the Alexander model #761

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ All notable changes to this project will be documented in this file. The format
## [Unreleased]

### Added
- Add the isotropic-hyperelastic `alexander(C1, C2, C2, gamma)` model.
- Add the isotropic-hyperelastic `alexander(C1, C2, C2, gamma, k)` model.

### Changed
- Recfactor the `constitution` module.

### Fixed
- Fix plotting the keyword-arguments of a constitutive material `ConstitutiveMaterial.plot(show_kwargs=True)`. For list-based material parameters of length 1, the brackets aren't shown now. E.g., this affects optimized material parameters.

## [8.5.1] - 2024-05-08

### Fixed
Expand Down
4 changes: 3 additions & 1 deletion src/felupe/constitution/_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ def plot(self, ax=None, show_title=True, show_kwargs=True, **kwargs):
p = []
for key, value in self.umat.kwargs.items():
if hasattr(value, "__len__"):
val = "[" + " ".join([f"{v:.3g}" for v in value]) + "]"
val = " ".join([f"{v:.3g}" for v in value])
if len(value) > 1:
val = f"[{val}]"
else:
val = f"{value:.3g}"
p.append(f"{key}={val}")
Expand Down
2 changes: 1 addition & 1 deletion src/felupe/constitution/hyperelasticity/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
]

# default (stable) material parameters
alexander.kwargs = dict(C1=0, C2=0, C3=0, gamma=100)
alexander.kwargs = dict(C1=0, C2=0, C3=0, gamma=100, k=0)
arruda_boyce.kwargs = dict(C1=0, limit=100)
extended_tube.kwargs = dict(Gc=0, Ge=0, beta=1, delta=0)
mooney_rivlin.kwargs = dict(C10=0, C01=0)
Expand Down
45 changes: 35 additions & 10 deletions src/felupe/constitution/hyperelasticity/models/_alexander.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
You should have received a copy of the GNU General Public License
along with FElupe. If not, see <http://www.gnu.org/licenses/>.
"""
from tensortrax.math import log, trace
import numpy as np
from tensortrax import Tensor, Δ, Δδ, f, δ
from tensortrax.math import exp, log, trace
from tensortrax.math.linalg import det


def alexander(C, C1, C2, C3, gamma):
def alexander(C, C1, C2, C3, gamma, k):
r"""Strain energy function of the isotropic hyperelastic
`Alexander <https://doi.org/10.1016/0020-7225(68)90006-2>`_ material
formulation [1]_.
Expand All @@ -29,23 +31,34 @@ def alexander(C, C1, C2, C3, gamma):
C : tensortrax.Tensor
Right Cauchy-Green deformation tensor.
C1 : float
First material parameter associated to the first invariant.
Scale factor for the first invariant term.
C2 : float
Second material parameter associated to the second invariant.
Scale factor for the second invariant term.
C3 : float
Third material parameter associated to the second invariant.
Scale factor for the logarithmic second invariant term.
gamma : float
Dimensionless material parameter associated to the second invariant.
Offset-normalization parameter for the logarithmic second invariant term.
k : float
Scale factor for the exponential first invariant term.

Notes
-----
.. warning::
The strain energy function of the Alexander model formulation is not directly
implemented. Only its gradient and hessian w.r.t. the right Cauchy-Green
deformation tensor are defined. This is because the imaginary error-function
:math:`\text{erfi}(x)` is not included in NumPy - this would require SciPy as a
dependency.

The strain energy function is given in Eq. :eq:`psi-alexander`

.. math::
:label: psi-alexander

\psi = C_1 \left(\hat{I}_1 - 3 \right)
+ C_2 \ln{\frac{\hat{I}_2 - 3 + \gamma}{\gamma}}
\psi = C_1 \int_{\hat{I}_1} \exp \left(
k \left(\hat{I}_1 - 3 \right)^2
\right) \ d\hat{I}_1
+ C_2 \ln \left(\frac{\hat{I}_2 - 3 + \gamma}{\gamma} \right)
+ C_3 \left(\hat{I}_2 - 3 \right)

with the first and second main invariant of the distortional part of the right
Expand Down Expand Up @@ -78,7 +91,7 @@ def alexander(C, C1, C2, C3, gamma):
>>> import felupe as fem
>>>
>>> umat = fem.Hyperelastic(
... fem.alexander, C1=0.117, C2=0.137, C3=0.00690, gamma=0.735
... fem.alexander, C1=17, C2=19.85, C3=1, gamma=0.735, k=0.00015
... )
>>> ax = umat.plot(incompressible=True)

Expand All @@ -104,4 +117,16 @@ def alexander(C, C1, C2, C3, gamma):
I1 = J3 * trace(C)
I2 = (I1**2 - J3**2 * trace(C @ C)) / 2

return C1 * (I1 - 3) + C2 * log(((I2 - 3) + gamma) / gamma) + C3 * (I2 - 3)
def W(I1):
"A non-evaluated function with defined first- and second derivatives."

dWdI1 = exp(k * (I1 - 3) ** 2)
return Tensor(
x=np.full_like(f(I1), fill_value=np.nan),
δx=f(dWdI1) * δ(I1),
Δx=f(dWdI1) * Δ(I1),
Δδx=δ(dWdI1) * Δ(I1) + f(dWdI1) * Δδ(I1),
ntrax=I1.ntrax,
)

return C1 * W(I1) + C2 * log(((I2 - 3) + gamma) / gamma) + C3 * (I2 - 3)
3 changes: 2 additions & 1 deletion tests/test_constitution.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def neo_hooke(C, mu=1):
),
(
fem.constitution.alexander,
dict(C1=0.117, C2=0.137, C3=0.00690, gamma=0.735),
dict(C1=0.117, C2=0.137, C3=0.00690, gamma=0.735, k=0.00015),
True,
),
]:
Expand Down Expand Up @@ -550,6 +550,7 @@ def test_optimize():
fem.ogden,
fem.third_order_deformation,
fem.extended_tube,
fem.alexander,
]:
umat = fem.Hyperelastic(model)
umat_new, res = umat.optimize(ux=[stretches, stresses], incompressible=True)
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载