Skip to content

Commit

Permalink
Merge pull request #755 from adtzlr/fix-umat-view-statevars
Browse files Browse the repository at this point in the history
Fix `MaterialStrain.plot()`
  • Loading branch information
adtzlr authored May 8, 2024
2 parents bb76bdb + 8e71214 commit d62ce7c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. The format

### Fixed
- Fix the gradient evaluation in `NeoHookeCompressible(mu=1, lmbda=None)`.
- Fix `MaterialStrain.plot()`.

## [8.5.0] - 2024-04-27

Expand Down
21 changes: 12 additions & 9 deletions src/felupe/constitution/_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,13 @@ def fun(λ3):
λ2 = λ3
F = eye * np.array([λ1, λ2, λ3]).reshape(1, 3, 1, -1)
if self.statevars_included:
if self.statevars is None:
self.statevars = np.zeros((*self.umat.x[-1].shape, 1, 1))
statevars = self.statevars
if statevars is None:
statevars = np.zeros((*self.umat.x[-1].shape, 1, 1))
P = np.zeros_like(F)
for increment, defgrad in enumerate(F.T):
P[..., [increment]], statevars = self.umat.gradient(
[F[..., [increment]], self.statevars]
[F[..., [increment]], statevars]
)
else:
P, statevars = self.umat.gradient([F, None])
Expand Down Expand Up @@ -262,12 +263,13 @@ def planar(self, stretches=None):
def fun(λ3):
F = eye * np.array([λ1, λ2, λ3]).reshape(1, 3, 1, -1)
if self.statevars_included:
if self.statevars is None:
self.statevars = np.zeros((*self.umat.x[-1].shape, 1, 1))
statevars = self.statevars
if statevars is None:
statevars = np.zeros((*self.umat.x[-1].shape, 1, 1))
P = np.zeros_like(F)
for increment, defgrad in enumerate(F.T):
P[..., [increment]], statevars = self.umat.gradient(
[F[..., [increment]], self.statevars]
[F[..., [increment]], statevars]
)
else:
P, statevars = self.umat.gradient([F, None])
Expand Down Expand Up @@ -322,12 +324,13 @@ def biaxial(self, stretches=None):
def fun(λ3):
F = eye * np.array([λ1, λ2, λ3]).reshape(1, 3, 1, -1)
if self.statevars_included:
if self.statevars is None:
self.statevars = np.zeros((*self.umat.x[-1].shape, 1, 1))
statevars = self.statevars
if statevars is None:
statevars = np.zeros((*self.umat.x[-1].shape, 1, 1))
P = np.zeros_like(F)
for increment, defgrad in enumerate(F.T):
P[..., [increment]], statevars = self.umat.gradient(
[F[..., [increment]], self.statevars]
[F[..., [increment]], statevars]
)
else:
P, self.statevars = self.umat.gradient([F, None])
Expand Down

0 comments on commit d62ce7c

Please sign in to comment.