Skip to content
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ A = Mat.hessian([defgrad])[0]
```

## Template classes for hyperelasticity
matADi provides several simple template classes suitable for simple hyperelastic materials. Some isotropic hyperelastic material formulations are located in `matadi.models` (see list below). These strain energy functions have to be passed as the `fun` argument into an instance of `MaterialHyperelastic`. Usage is exactly the same as described above. To convert a hyperelastic material based on the deformation gradient into a mixed three-field formulation suitable for nearly-incompressible behavior (*displacements*, *pressure* and *volume ratio*) an instance of a `MaterialHyperelastic` class has to be passed to `ThreeFieldVariation`. For *plane strain* or *plane stress* use `MaterialHyperelasticPlaneStrain` or `MaterialHyperelasticPlaneStressIncompressible` instead of `MaterialHyperelastic`.
matADi provides several simple template classes suitable for simple hyperelastic materials. Some isotropic hyperelastic material formulations are located in `matadi.models` (see list below). These strain energy functions have to be passed as the `fun` argument into an instance of `MaterialHyperelastic`. Usage is exactly the same as described above. To convert a hyperelastic material based on the deformation gradient into a mixed three-field formulation suitable for nearly-incompressible behavior (*displacements*, *pressure* and *volume ratio*) an instance of a `MaterialHyperelastic` class has to be passed to `ThreeFieldVariation`. For *plane strain* or *plane stress* use `MaterialHyperelasticPlaneStrain`, `MaterialHyperelasticPlaneStressIncompressible` or `MaterialHyperelasticPlaneStressLinearElastic` instead of `MaterialHyperelastic`.

```python

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.22"
__version__ = "0.0.23"
1 change: 1 addition & 0 deletions matadi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
MaterialComposite,
MaterialHyperelasticPlaneStrain,
MaterialHyperelasticPlaneStressIncompressible,
MaterialHyperelasticPlaneStressLinearElastic,
)
from ._lab import Lab

Expand Down
16 changes: 16 additions & 0 deletions matadi/_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,22 @@ def _fun_wrapper(self, x, **kwargs):
return self.fun(F, **kwargs)


class MaterialHyperelasticPlaneStressLinearElastic(MaterialHyperelasticPlaneStrain):
def __init__(self, fun, **kwargs):
super().__init__(fun, **kwargs)

def _fun_wrapper(self, x, **kwargs):
F = horzcat(vertcat(x[0], zeros(1, 2)), zeros(3, 1))
# stress-free thickness ratio for linear elastic material
# s_33 != 0 = 2 mu e_33 + lmbda (e_11 + e_22 + e_33)
# e_33 = - (e_11 + e_22) * lmbda / (2 mu + lmbda)
# F_33 = 1 + e_33
F[2, 2] = 1 - (F[0, 0] + F[1, 1] - 2) * (
kwargs["lmbda"] / (2 * kwargs["mu"] + kwargs["lmbda"])
)
return self.fun(F, **kwargs)


class MaterialComposite:
def __init__(self, materials):
"Composite Material as a sum of a list of materials."
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.22"
version = "0.0.23"
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.22
version = 0.0.23
author = Andreas Dutzler
author_email = a.dutzler@gmail.com
description = Material Definition with Automatic Differentiation
Expand Down
33 changes: 30 additions & 3 deletions tests/test_plane.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
from matadi import (
MaterialHyperelasticPlaneStrain,
MaterialHyperelasticPlaneStressIncompressible,
MaterialHyperelasticPlaneStressLinearElastic,
)
from matadi.models import neo_hooke
from matadi.models import neo_hooke, linear_elastic


def pre():
Expand Down Expand Up @@ -40,7 +41,7 @@ def test_plane_strain():
assert DW[0].shape == (2, 2, 2, 2, 8, 1000)


def test_plane_stress():
def test_plane_stress_incompr():

# data
FF = pre()
Expand All @@ -64,6 +65,32 @@ def test_plane_stress():
assert DW[0].shape == (2, 2, 2, 2, 8, 1000)


def test_plane_stress_linear():

# data
FF = pre()

# init Material
W = MaterialHyperelasticPlaneStressLinearElastic(
fun=linear_elastic,
mu=1.0,
lmbda=200.0,
)

W0 = W.function([FF])
dW = W.gradient([FF])
DW = W.hessian([FF])

assert W0[0].shape == (8, 1000)
assert dW[0].shape == (2, 2, 8, 1000)
assert DW[0].shape == (2, 2, 2, 2, 8, 1000)

assert W0[0].shape == (8, 1000)
assert dW[0].shape == (2, 2, 8, 1000)
assert DW[0].shape == (2, 2, 2, 2, 8, 1000)


if __name__ == "__main__":
test_plane_strain()
test_plane_stress()
test_plane_stress_incompr()
test_plane_stress_linear()