Skip to content

Commit

Permalink
Merge pull request #38 from adtzlr/fix-microsphere-langevin
Browse files Browse the repository at this point in the history
fix langevin chain model
  • Loading branch information
adtzlr authored Nov 10, 2021
2 parents 6f3092e + 6b2fe30 commit cbd4667
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 23 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ Available [anisotropic hyperelastic material models](https://github.com/adtzlr/m

Available [micro-sphere hyperelastic material models](https://github.com/adtzlr/matadi/blob/main/matadi/models/microsphere) (Miehe, Göktepe, Lulei) [[2](https://doi.org/10.1016/j.jmps.2004.03.011)]:
- [affine stretch](https://doi.org/10.1016/j.jmps.2004.03.011) ([code](https://github.com/adtzlr/matadi/blob/main/matadi/models/microsphere/affine/_models.py#L5-L15))
- [affine tube](https://doi.org/10.1016/j.jmps.2004.03.011) ([code](https://github.com/adtzlr/matadi/blob/main/matadi/models/microsphere/affine/_models.py#L18-L28))
- [affine tube](https://doi.org/10.1016/j.jmps.2004.03.011) ([code](https://github.com/adtzlr/matadi/blob/main/matadi/models/microsphere/affine/_models.py#L18-L29))
- [non-affine stretch](https://doi.org/10.1016/j.jmps.2004.03.011) ([code](https://github.com/adtzlr/matadi/blob/main/matadi/models/microsphere/nonaffine/_models.py#L5-L15))
- [non-affine tube](https://doi.org/10.1016/j.jmps.2004.03.011) ([code](https://github.com/adtzlr/matadi/blob/main/matadi/models/microsphere/nonaffine/_models.py#L18-L28))
- [non-affine tube](https://doi.org/10.1016/j.jmps.2004.03.011) ([code](https://github.com/adtzlr/matadi/blob/main/matadi/models/microsphere/nonaffine/_models.py#L18-L29))

Any user-defined isotropic hyperelastic strain energy density function may be passed as the `fun` argument of `MaterialHyperelastic` by using the following template:

Expand Down
2 changes: 1 addition & 1 deletion matadi/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.15"
__version__ = "0.0.16"
1 change: 1 addition & 0 deletions matadi/models/microsphere/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
from . import quadrature
from ._chain import (
langevin,
langevin2,
gauss,
)
25 changes: 21 additions & 4 deletions matadi/models/microsphere/_chain.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
from ...math import sqrt, atanh
from ...math import log, sinh, sqrt


def langevin(stretch, mu, N):
"""Langevin model (Padé approximation) given by the free energy
of a single chain as a function of the stretch."""
"""Langevin model given by the free energy of a single chain as a function
of the stretch (assuming a complex valued logarithm). The inverse
Langevin function is defined by a Padé approximation."""

x = stretch / sqrt(N)
L = x * (3 - x ** 2) / (1 - x ** 2)

return mu * N * (x * L + log(L / sinh(L)))


def langevin2(stretch, mu, N):
"""Langevin model given by the free energy of a single chain as a function
of the stretch (assuming a complex valued logarithm). The inverse Langevin
function is defined by a Padé approximation.
**Note**: This function is optimized for fast gradient evaluation but
cannot be used to calculate the actual free energy - only its derivative
w.r.t. the stretch gives a real-valued result for the region of interest
`N > stretch ** 2`."""

return mu * (stretch + 2 * sqrt(N) * atanh(stretch / sqrt(N)))
return mu * (stretch ** 2 / 2 - N * log(stretch ** 2 - N))


def gauss(stretch, mu):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "matadi"
version = "0.0.15"
version = "0.0.16"
description = "Material Definition with Automatic Differentiation"
readme = "README.md"
requires-python = ">=3.6"
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = matadi
version = 0.0.15
version = 0.0.16
author = Andreas Dutzler
author_email = [email protected]
description = Material Definition with Automatic Differentiation
Expand Down
17 changes: 3 additions & 14 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,21 @@ def library():
md.arruda_boyce: {"C1": 1.0, "limit": 3.2},
md.extended_tube: {"Gc": 0.1867, "Ge": 0.2169, "beta": 0.2, "delta": 0.09693},
md.van_der_waals: {"mu": 1.0, "beta": 0.1, "a": 0.5, "limit": 5.0},
md.microsphere.affine.stretch: {
"quadrature": q,
"f": md.microsphere.gauss,
"kwargs": {"mu": 1},
},
md.microsphere.nonaffine.stretch: {
"quadrature": q,
"p": 2.7,
"f": md.microsphere.gauss,
"kwargs": {"mu": 1},
},
md.microsphere.affine.stretch: {
"quadrature": q,
"f": md.microsphere.langevin,
"kwargs": {"mu": 1, "N": 10},
},
md.microsphere.affine.tube: {
"quadrature": q,
"f": md.microsphere.langevin,
"f": md.microsphere.langevin2,
"kwargs": {"mu": 1, "N": 10},
},
md.microsphere.nonaffine.stretch: {
"quadrature": q,
"p": 2.7,
"f": md.microsphere.langevin,
"kwargs": {"mu": 1, "N": 10},
"f": md.microsphere.gauss,
"kwargs": {"mu": 1},
},
md.microsphere.nonaffine.tube: {
"quadrature": q,
Expand Down

0 comments on commit cbd4667

Please sign in to comment.