Closed adtzlr closed 2 years ago
Example:
from matadi import MaterialTensor, Variable
from matadi.math import det, dev, inv
import numpy as np
defgrad = np.random.rand(3, 3, 5, 100) - 0.5
for a in range(3):
defgrad[a, a] += 1.0
pressure = np.random.rand(5, 100)
F = Variable("F", 3, 3)
p = Variable("p")
def nh(x, C10=0.5, bulk=5000):
"""Neo-Hookean material formulation with first Piola-Kirchhoff stress
and volumetric constraint equation (u/p formulation)."""
F, p = x
J = det(F)
C = F.T @ F
S = 2 * C10 * dev(J ** (-2 / 3) * C) @ inv(C) + p * J * inv(C)
constraint = (J - 1) - p / bulk
return F @ S, constraint
# (u/p) framework
# ===============
# W(u, p) = w(u) + p (J - 1) - p^2 / (2 K)
# dWdE = dwdE + p J inv(C) (= S)
# dWdp = (J - 1) - p / K (= constraint)
NH = MaterialTensor(x=[F, p], fun=nh)
W = NH.function([defgrad, pressure])
P = NH.gradient([defgrad, pressure])
triu
argument for gradient evaluation (like hessian-method for mixed-field hyperelastic materials) allow state variables (same as default variables but for which no gradient is evaluated) --> as seperate issue/PRWith the above enhancements it will be possible to code a
u/p
- Formulation: