simkit.energies.contact_springs_sphere#

Penalty contact springs against a sphere.

A one-sided quadratic penalty: points that fall inside the sphere are pushed back out along the (per-point) contact normal, leaving the tangential component free. This is an external potential, not a per-element material energy, so there is no element / F tier; the functions take vertex positions directly and detect the active (penetrating) set internally.

Functions#

contact_springs_sphere_energy(→ float)

Penalty energy for contact with a sphere.

contact_springs_sphere_gradient(→ numpy.ndarray)

Penalty gradient for contact with a sphere.

contact_springs_sphere_hessian(→ scipy.sparse.spmatrix)

Penalty Hessian for contact with a sphere.

Module Contents#

simkit.energies.contact_springs_sphere.contact_springs_sphere_energy(X: numpy.ndarray, k: float, p: numpy.ndarray, r: float, M: scipy.sparse.spmatrix | None = None) float#

Penalty energy for contact with a sphere.

Parameters:
  • X (np.ndarray (num_verts, dim)) – Vertex positions.

  • k (float) – Penalty stiffness.

  • p (np.ndarray (dim,) or (1, dim)) – Sphere center.

  • r (float) – Sphere radius.

  • M (scipy.sparse matrix (num_verts, num_verts), optional) – Mass matrix. Defaults to the identity.

Returns:

energy – Total contact energy.

Return type:

float

simkit.energies.contact_springs_sphere.contact_springs_sphere_gradient(X: numpy.ndarray, k: float, p: numpy.ndarray, r: float, M: scipy.sparse.spmatrix | None = None) numpy.ndarray#

Penalty gradient for contact with a sphere.

Parameters:
  • X (np.ndarray (num_verts, dim)) – Vertex positions.

  • k (float) – Penalty stiffness.

  • p (np.ndarray (dim,) or (1, dim)) – Sphere center.

  • r (float) – Sphere radius.

  • M (scipy.sparse matrix (num_verts, num_verts), optional) – Mass matrix. Defaults to the identity.

Returns:

gradient – Assembled gradient.

Return type:

np.ndarray (num_verts*dim, 1)

simkit.energies.contact_springs_sphere.contact_springs_sphere_hessian(X: numpy.ndarray, k: float, p: numpy.ndarray, r: float, M: scipy.sparse.spmatrix | None = None) scipy.sparse.spmatrix#

Penalty Hessian for contact with a sphere.

Parameters:
  • X (np.ndarray (num_verts, dim)) – Vertex positions.

  • k (float) – Penalty stiffness.

  • p (np.ndarray (dim,) or (1, dim)) – Sphere center.

  • r (float) – Sphere radius.

  • M (scipy.sparse matrix (num_verts, num_verts), optional) – Mass matrix. Defaults to the identity.

Returns:

H – Assembled Hessian. PSD by construction.

Return type:

scipy.sparse matrix (num_verts*dim, num_verts*dim)