-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #108 from adtzlr/add-morph
Add MORPH material model
- Loading branch information
Showing
8 changed files
with
195 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.1.6" | ||
__version__ = "0.1.7" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
from ._helpers import displacement_pressure_split, volumetric | ||
from ._hyperelasticity_isotropic import neo_hooke | ||
from ..math import ( | ||
det, inv, dev, sym, sqrt, if_else, vertsplit, vertcat, | ||
asvoigt, astensor, tresca, mexp, gradient | ||
) | ||
|
||
|
||
@displacement_pressure_split | ||
def morph(x, param, bulk): | ||
"MORPH consitututive material formulation." | ||
|
||
# split input into the deformation gradient and the vector of state variables | ||
F, statevars = x[0], x[-1] | ||
|
||
# split state variables | ||
CTSn, Cn, SZn = vertsplit(statevars, [0, 1, 7, 13]) | ||
Cn, SZn = astensor(Cn), astensor(SZn) | ||
|
||
# right Cauchy-Green deformation tensor | ||
C = F.T @ F | ||
J = det(F) | ||
dC = C - Cn | ||
|
||
# (Incremental) Inverse of right Cauchy-Green deformation tensor | ||
invC = inv(C) | ||
|
||
# isochoric part of C and L | ||
CG = J ** (-2 / 3) * C | ||
LG = dev(sym(dC @ invC)) @ CG | ||
|
||
# # von mises invariants of C and L | ||
CT = tresca(CG) | ||
LT = tresca(LG) | ||
|
||
# # maximum historical von mises invariant of CG | ||
CTS = if_else(CT > CTSn, CT, CTSn) | ||
|
||
# # stable LG / LT and CT / CTS | ||
LGLT = if_else(LT > 0, LG / LT, LG) | ||
CTCTS = if_else(CTS > 0, CT / CTS, CT) | ||
|
||
# MORPH deformation-dependent material parameters | ||
f = lambda x: 1 / sqrt(1 + x ** 2) | ||
a = param[0] + param[1] * f(param[2] * CTS) | ||
b = param[3] * f(param[2] * CTS) | ||
c = param[4] * CTS * (1 - f(CTS / param[5])) | ||
|
||
# # Hull stress | ||
SH = (c * mexp(param[6] * LGLT * CTCTS) + param[7] * LGLT) @ invC | ||
|
||
# # helper "kappa" for implict euler update of overstress | ||
SZ = (SZn + b * LT * SH) / (1 + b * LT) | ||
|
||
# hyperelastic distortional and volumetric parts of strain energy function | ||
W = neo_hooke(F, a) | ||
U = volumetric(J, bulk) | ||
|
||
# overstress as second Piola-Kirchhoff stress | ||
S = dev(SZ @ C) @ invC | ||
|
||
# update statevars | ||
statevars_new = vertcat(CTS, asvoigt(C), asvoigt(SZ)) | ||
|
||
# first Piola-Kirchhoff stress | ||
return [gradient(W, F) + gradient(U, F) + F @ S, statevars_new] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[metadata] | ||
name = matadi | ||
version = 0.1.6 | ||
version = 0.1.7 | ||
author = Andreas Dutzler | ||
author_email = [email protected] | ||
description = Material Definition with Automatic Differentiation | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import numpy as np | ||
|
||
from matadi import Variable, MaterialTensor | ||
from matadi.models import ( | ||
morph | ||
) | ||
|
||
|
||
def test_up_morph(): | ||
|
||
# deformation gradient | ||
F = Variable("F", 3, 3) | ||
|
||
# state variables | ||
z = Variable("z", 13, 1) | ||
|
||
kwargs = { | ||
"param": [0.035, 0.37, 0.17, 2.4, 0.01, 6.4, 5.5, 0.24], | ||
"bulk": 5000 | ||
} | ||
|
||
p = morph.p | ||
M = MaterialTensor(x=[F, p, z], fun=morph, triu=True, statevars=1, kwargs=kwargs) | ||
|
||
FF = np.random.rand(3, 3, 8, 100) | ||
pp = np.random.rand(1, 8, 100) | ||
zz = np.random.rand(13, 1, 8, 100) | ||
|
||
for a in range(3): | ||
FF[a, a] += 1 | ||
|
||
P = M.function([FF, pp, zz]) # stress, constraint, statevars_new | ||
A = M.gradient([FF, pp, zz]) | ||
|
||
assert len(P) == 3 | ||
assert len(A) == 3 | ||
|
||
|
||
if __name__ == "__main__": | ||
test_up_morph() |