Skip to content

Commit

Permalink
Add an optional multiplier in Laplace(multiplier=1.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
adtzlr committed Oct 18, 2024
1 parent 90db4e8 commit 19bf43e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. The format
### Added
- Add the hessian of the element shape functions for a quadratic quad element `QuadraticQuad.hessian()`.
- Add the `order`-argument to `FieldContainer.extract(order="C")` as well as for `Field`, `FieldAxisymmetric`, `FieldPlaneStrain` to return C-contiguous arrays by default.
- Add an optional multiplier to `Laplace(multiplier=1.0)`.

### Changed
- Change default `np.einsum(..., order="K")` to `np.einsum(..., order="C")` in the methods of `Field`, `FieldAxisymmetric`, `FieldPlaneStrain` and `FieldContainer`.
Expand Down
20 changes: 13 additions & 7 deletions src/felupe/constitution/poisson/_laplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ class Laplace(ConstitutiveMaterial):
r"""Laplace equation as hessian of one half of the second main invariant of the
field gradient.
Parameters
----------
multiplier : float, optional
A multiplier which scales the potential (default is 1.0).
Notes
-----
The potential is given by the second main invariant of the field gradient w.r.t.
Expand Down Expand Up @@ -64,8 +69,9 @@ class Laplace(ConstitutiveMaterial):
"""

def __init__(self):
self.kwargs = {}
def __init__(self, multiplier=1.0):
self.multiplier = multiplier
self.kwargs = {"multiplier": self.multiplier}

# aliases for gradient and hessian
self.stress = self.gradient
Expand Down Expand Up @@ -93,7 +99,7 @@ def function(self, x):
F = x[0]
H = F - identity(F)

return [ddot(H, H) / 2]
return [self.multiplier * ddot(H, H) / 2]

def gradient(self, x):
r"""Evaluate the stress tensor.
Expand All @@ -113,7 +119,7 @@ def gradient(self, x):
F, statevars = x[0], x[-1]
H = F - identity(F)

return [H, statevars]
return [self.multiplier * H, statevars]

def hessian(self, x):
r"""Evaluate the elasticity tensor.
Expand All @@ -122,8 +128,6 @@ def hessian(self, x):
----------
x : list of ndarray
List with Deformation gradient :math:`\boldsymbol{F}` as first item.
shape : tuple of int, optional
Tuple with shape of the trailing axes (default is (1, 1)).
Returns
-------
Expand All @@ -136,4 +140,6 @@ def hessian(self, x):
ntrax = len(x[0].shape) - 2
ones = np.ones(ntrax, dtype=int)

return [cdya_ik(np.eye(n), np.eye(m)).reshape(n, m, n, m, *ones)]
return [
self.multiplier * cdya_ik(np.eye(n), np.eye(m)).reshape(n, m, n, m, *ones)
]

0 comments on commit 19bf43e

Please sign in to comment.