Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an optional multiplier in Laplace(multiplier=1.0) #864

Merged
merged 1 commit into from
Oct 18, 2024
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
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)
]
Loading