Potentials¶
Normal Potentials¶
- class ipctk.NormalPotential¶
Bases:
pybind11_objectPublic Methods:
__init__(*args, **kwargs)__call__(*args, **kwargs)Overloaded function.
gradient(*args, **kwargs)Overloaded function.
hessian(*args, **kwargs)Overloaded function.
shape_derivative(*args, **kwargs)Overloaded function.
force_magnitude(self, distance_squared, ...)Compute the force magnitude for a collision.
force_magnitude_gradient(self, ...)Compute the gradient of the force magnitude for a collision.
Inherited from
pybind11_objectPrivate Methods:
-
__annotations__ =
{}¶
- __call__(*args, **kwargs)¶
Overloaded function.
__call__(self: ipctk.NormalPotential, collisions: ipctk.NormalCollisions, mesh: ipc::CollisionMesh, X: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”, “flags.f_contiguous”]) -> float
Compute the potential for a set of collisions.
- Parameters:
collisions: The set of collisions. mesh: The collision mesh. X: Degrees of freedom of the collision mesh (e.g., vertices or velocities).
- Returns:
The potential for a set of collisions.
__call__(self: ipctk.NormalPotential, collision: ipctk.NormalCollision, x: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, 1]”]) -> float
Compute the potential for a single collision.
- Parameters:
collision: The collision. x: The collision stencil’s degrees of freedom.
- Returns:
The potential.
-
__module__ =
'ipctk'¶
- _pybind11_conduit_v1_()¶
- force_magnitude(self, distance_squared: SupportsFloat, dmin: SupportsFloat, barrier_stiffness: SupportsFloat) float¶
Compute the force magnitude for a collision.
- force_magnitude_gradient(self, distance_squared: SupportsFloat, distance_squared_gradient: Annotated[numpy.typing.NDArray[numpy.float64], '[m, 1]'], dmin: SupportsFloat, barrier_stiffness: SupportsFloat) Annotated[numpy.typing.NDArray[numpy.float64], '[m, 1]']¶
Compute the gradient of the force magnitude for a collision.
- Parameters:¶
- distance_squared: SupportsFloat¶
The squared distance between elements.
- distance_squared_gradient: Annotated[numpy.typing.NDArray[numpy.float64], '[m, 1]']¶
The gradient of the squared distance.
- dmin: SupportsFloat¶
The minimum distance offset to the barrier.
- barrier_stiffness: SupportsFloat¶
The stiffness of the barrier.
- Returns:¶
The gradient of the force.
- gradient(*args, **kwargs)¶
Overloaded function.
gradient(self: ipctk.NormalPotential, collisions: ipctk.NormalCollisions, mesh: ipc::CollisionMesh, X: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”, “flags.f_contiguous”]) -> typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, 1]”]
Compute the gradient of the potential.
- Parameters:
collisions: The set of collisions. mesh: The collision mesh. X: Degrees of freedom of the collision mesh (e.g., vertices or velocities).
- Returns:
The gradient of the potential w.r.t. X. This will have a size of X.size.
gradient(self: ipctk.NormalPotential, collision: ipctk.NormalCollision, x: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, 1]”]) -> typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, 1]”]
Compute the gradient of the potential for a single collision.
- Parameters:
collision: The collision. x: The collision stencil’s degrees of freedom.
- Returns:
The gradient of the potential.
- hessian(*args, **kwargs)¶
Overloaded function.
hessian(self: ipctk.NormalPotential, collisions: ipctk.NormalCollisions, mesh: ipc::CollisionMesh, X: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”, “flags.f_contiguous”], project_hessian_to_psd: ipctk.PSDProjectionMethod = <PSDProjectionMethod.NONE: 0>) -> scipy.sparse.csc_matrix[numpy.float64]
Compute the hessian of the potential.
- Parameters:
collisions: The set of collisions. mesh: The collision mesh. X: Degrees of freedom of the collision mesh (e.g., vertices or velocities). project_hessian_to_psd: Make sure the hessian is positive semi-definite.
- Returns:
The Hessian of the potential w.r.t. X. This will have a size of X.size by X.size.
hessian(self: ipctk.NormalPotential, collision: ipctk.NormalCollision, x: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, 1]”], project_hessian_to_psd: ipctk.PSDProjectionMethod = <PSDProjectionMethod.NONE: 0>) -> typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”]
Compute the hessian of the potential for a single collision.
- Parameters:
collision: The collision. x: The collision stencil’s degrees of freedom.
- Returns:
The hessian of the potential.
- shape_derivative(*args, **kwargs)¶
Overloaded function.
shape_derivative(self: ipctk.NormalPotential, collisions: ipctk.NormalCollisions, mesh: ipc::CollisionMesh, vertices: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”, “flags.f_contiguous”]) -> scipy.sparse.csc_matrix[numpy.float64]
Compute the shape derivative of the potential.
std::runtime_error If the collision collisions were not built with shape derivatives enabled.
- Parameters:
collisions: The set of collisions. mesh: The collision mesh. vertices: Vertices of the collision mesh.
- Returns:
The derivative of the force with respect to X, the rest vertices.
shape_derivative(self: ipctk.NormalPotential, collision: ipctk.NormalCollision, vertex_ids: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], “FixedSize(4)”], rest_positions: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, 1]”], positions: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, 1]”]) -> list[Eigen::Triplet<double, int>]
Compute the shape derivative of the potential for a single collision.
- Parameters:
collision: The collision. vertex_ids: The collision stencil’s vertex ids. rest_positions: The collision stencil’s rest positions. positions: The collision stencil’s positions. ,out]: out Store the triplets of the shape derivative here.
-
__annotations__ =
Barrier Potential¶
- class ipctk.BarrierPotential¶
Bases:
NormalPotentialPublic Data Attributes:
Barrier activation distance.
Barrier function used to compute the potential.
Public Methods:
__init__(*args, **kwargs)Overloaded function.
Inherited from
NormalPotential__init__(*args, **kwargs)__call__(*args, **kwargs)Overloaded function.
gradient(*args, **kwargs)Overloaded function.
hessian(*args, **kwargs)Overloaded function.
shape_derivative(*args, **kwargs)Overloaded function.
force_magnitude(self, distance_squared, ...)Compute the force magnitude for a collision.
force_magnitude_gradient(self, ...)Compute the gradient of the force magnitude for a collision.
Inherited from
pybind11_object
-
__annotations__ =
{}¶
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: ipctk.BarrierPotential, dhat: typing.SupportsFloat, use_physical_barrier: bool = False) -> None
Construct a barrier potential.
- Parameters:
dhat: The activation distance of the barrier.
__init__(self: ipctk.BarrierPotential, barrier: ipctk.Barrier, dhat: typing.SupportsFloat, use_physical_barrier: bool = False) -> None
Construct a barrier potential.
- Parameters:
barrier: The barrier function. dhat: The activation distance of the barrier.
-
__module__ =
'ipctk'¶
- _pybind11_conduit_v1_()¶
- property barrier : ipctk.Barrier¶
Barrier function used to compute the potential.
- property dhat : float¶
Barrier activation distance.
-
__annotations__ =
Normal Adhesion Potential¶
- class ipctk.NormalAdhesionPotential¶
Bases:
NormalPotentialPublic Data Attributes:
The distance of largest adhesion force (\(\hat{d}_{p}\)) (\(0 < \hat{d}_{p} < \hat{d}_{a}\)).
The adhesion activation distance (\(\hat{d}_{a}\)).
The Young's modulus (\(Y\))).
The critical strain (\(\varepsilon_{c}\))).
Public Methods:
__init__(self, dhat_p, dhat_a, Y, eps_c)Inherited from
NormalPotential__init__(*args, **kwargs)__call__(*args, **kwargs)Overloaded function.
gradient(*args, **kwargs)Overloaded function.
hessian(*args, **kwargs)Overloaded function.
shape_derivative(*args, **kwargs)Overloaded function.
force_magnitude(self, distance_squared, ...)Compute the force magnitude for a collision.
force_magnitude_gradient(self, ...)Compute the gradient of the force magnitude for a collision.
Inherited from
pybind11_object
- property Y : float¶
The Young’s modulus (\(Y\))).
-
__annotations__ =
{}¶
- __init__(self, dhat_p: SupportsFloat, dhat_a: SupportsFloat, Y: SupportsFloat, eps_c: SupportsFloat)¶
-
__module__ =
'ipctk'¶
- _pybind11_conduit_v1_()¶
- property dhat_a : float¶
The adhesion activation distance (\(\hat{d}_{a}\)).
- property dhat_p : float¶
The distance of largest adhesion force (\(\hat{d}_{p}\)) (\(0 < \hat{d}_{p} < \hat{d}_{a}\)).
- property eps_c : float¶
The critical strain (\(\varepsilon_{c}\))).
Tangential Potentials¶
- class ipctk.TangentialPotential¶
Bases:
pybind11_objectPublic Data Attributes:
Public Methods:
__init__(*args, **kwargs)__call__(*args, **kwargs)Overloaded function.
gradient(*args, **kwargs)Overloaded function.
hessian(*args, **kwargs)Overloaded function.
force(*args, **kwargs)Overloaded function.
force_jacobian(*args, **kwargs)Overloaded function.
Inherited from
pybind11_objectPrivate Methods:
- class DiffWRT¶
Bases:
pybind11_objectMembers:
REST_POSITIONS : Differentiate w.r.t. rest positions
LAGGED_DISPLACEMENTS : Differentiate w.r.t. lagged displacements
VELOCITIES : Differentiate w.r.t. current velocities
-
LAGGED_DISPLACEMENTS =
<DiffWRT.LAGGED_DISPLACEMENTS: 1>¶
-
REST_POSITIONS =
<DiffWRT.REST_POSITIONS: 0>¶
-
VELOCITIES =
<DiffWRT.VELOCITIES: 2>¶
-
__annotations__ =
{}¶
-
__members__ =
{'LAGGED_DISPLACEMENTS': <DiffWRT.LAGGED_DISPLACEMENTS: 1>, 'REST_POSITIONS': <DiffWRT.REST_POSITIONS: 0>, 'VELOCITIES': <DiffWRT.VELOCITIES: 2>}¶
-
__module__ =
'ipctk'¶
- _pybind11_conduit_v1_()¶
- property name : str¶
- property value : int¶
-
LAGGED_DISPLACEMENTS =
-
LAGGED_DISPLACEMENTS =
<DiffWRT.LAGGED_DISPLACEMENTS: 1>¶
-
REST_POSITIONS =
<DiffWRT.REST_POSITIONS: 0>¶
-
VELOCITIES =
<DiffWRT.VELOCITIES: 2>¶
-
__annotations__ =
{}¶
- __call__(*args, **kwargs)¶
Overloaded function.
__call__(self: ipctk.TangentialPotential, collisions: ipctk.TangentialCollisions, mesh: ipc::CollisionMesh, X: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”, “flags.f_contiguous”]) -> float
Compute the potential for a set of collisions.
- Parameters:
collisions: The set of collisions. mesh: The collision mesh. X: Degrees of freedom of the collision mesh (e.g., vertices or velocities).
- Returns:
The potential for a set of collisions.
__call__(self: ipctk.TangentialPotential, collision: ipctk.TangentialCollision, x: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, 1]”]) -> float
Compute the potential for a single collision.
- Parameters:
collision: The collision. x: The collision stencil’s degrees of freedom.
- Returns:
The potential.
-
__module__ =
'ipctk'¶
- _pybind11_conduit_v1_()¶
- force(*args, **kwargs)¶
Overloaded function.
force(self: ipctk.TangentialPotential, collisions: ipctk.TangentialCollisions, mesh: ipc::CollisionMesh, rest_positions: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”, “flags.f_contiguous”], lagged_displacements: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”, “flags.f_contiguous”], velocities: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”, “flags.f_contiguous”], normal_potential: ipctk.NormalPotential, normal_stiffness: typing.SupportsFloat, dmin: typing.SupportsFloat = 0, no_mu: bool = False) -> typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, 1]”]
Compute the friction force from the given velocities.
- Parameters:
collisions: The set of collisions. mesh: The collision mesh. rest_positions: Rest positions of the vertices (rowwise). lagged_displacements: Previous displacements of the vertices (rowwise). velocities: Current displacements of the vertices (rowwise). normal_potential: Normal potential (used for normal force magnitude). normal_stiffness: Normal stiffness (used for normal force magnitude). dmin: Minimum distance (used for normal force magnitude). no_mu: whether to not multiply by mu
- Returns:
The friction force.
force(self: ipctk.TangentialPotential, collision: ipctk.TangentialCollision, rest_positions: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, 1]”], lagged_displacements: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, 1]”], velocities: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, 1]”], normal_potential: ipctk.NormalPotential, normal_stiffness: typing.SupportsFloat, dmin: typing.SupportsFloat = 0, no_mu: bool = False) -> typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, 1]”]
Compute the friction force.
- Parameters:
collision: The collision rest_positions: Rest positions of the vertices (rowwise). lagged_displacements: Previous displacements of the vertices (rowwise). velocities: Current displacements of the vertices (rowwise). normal_potential: Normal potential (used for normal force magnitude). normal_stiffness: Normal stiffness (used for normal force magnitude). dmin: Minimum distance (used for normal force magnitude). no_mu: Whether to not multiply by mu
- Returns:
Friction force
- force_jacobian(*args, **kwargs)¶
Overloaded function.
force_jacobian(self: ipctk.TangentialPotential, collisions: ipctk.TangentialCollisions, mesh: ipc::CollisionMesh, rest_positions: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”, “flags.f_contiguous”], lagged_displacements: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”, “flags.f_contiguous”], velocities: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”, “flags.f_contiguous”], normal_potential: ipctk.NormalPotential, normal_stiffness: typing.SupportsFloat, wrt: ipctk.TangentialPotential.DiffWRT, dmin: typing.SupportsFloat = 0) -> scipy.sparse.csc_matrix[numpy.float64]
Compute the Jacobian of the friction force wrt the velocities.
- Parameters:
collisions: The set of collisions. mesh: The collision mesh. rest_positions: Rest positions of the vertices (rowwise). lagged_displacements: Previous displacements of the vertices (rowwise). velocities: Current displacements of the vertices (rowwise). normal_potential: Normal potential (used for normal force magnitude). normal_stiffness: Normal stiffness (used for normal force magnitude). wrt: The variable to take the derivative with respect to. dmin: Minimum distance (used for normal force magnitude).
- Returns:
The Jacobian of the friction force wrt the velocities.
force_jacobian(self: ipctk.TangentialPotential, collision: ipctk.TangentialCollision, rest_positions: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, 1]”], lagged_displacements: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, 1]”], velocities: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, 1]”], normal_potential: ipctk.NormalPotential, normal_stiffness: typing.SupportsFloat, wrt: ipctk.TangentialPotential.DiffWRT, dmin: typing.SupportsFloat = 0) -> typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”]
Compute the friction force Jacobian.
- Parameters:
collision: The collision rest_positions: Rest positions of the vertices (rowwise). lagged_displacements: Previous displacements of the vertices (rowwise). velocities: Current displacements of the vertices (rowwise). normal_potential: Normal potential (used for normal force magnitude). normal_stiffness: Normal stiffness (used for normal force magnitude). wrt: Variable to differentiate the friction force with respect to. dmin: Minimum distance (used for normal force magnitude).
- Returns:
Friction force Jacobian
- gradient(*args, **kwargs)¶
Overloaded function.
gradient(self: ipctk.TangentialPotential, collisions: ipctk.TangentialCollisions, mesh: ipc::CollisionMesh, X: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”, “flags.f_contiguous”]) -> typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, 1]”]
Compute the gradient of the potential.
- Parameters:
collisions: The set of collisions. mesh: The collision mesh. X: Degrees of freedom of the collision mesh (e.g., vertices or velocities).
- Returns:
The gradient of the potential w.r.t. X. This will have a size of X.size.
gradient(self: ipctk.TangentialPotential, collision: ipctk.TangentialCollision, x: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, 1]”]) -> typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, 1]”]
Compute the gradient of the potential for a single collision.
- Parameters:
collision: The collision. x: The collision stencil’s degrees of freedom.
- Returns:
The gradient of the potential.
- hessian(*args, **kwargs)¶
Overloaded function.
hessian(self: ipctk.TangentialPotential, collisions: ipctk.TangentialCollisions, mesh: ipc::CollisionMesh, X: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”, “flags.f_contiguous”], project_hessian_to_psd: ipctk.PSDProjectionMethod = <PSDProjectionMethod.NONE: 0>) -> scipy.sparse.csc_matrix[numpy.float64]
Compute the hessian of the potential.
- Parameters:
collisions: The set of collisions. mesh: The collision mesh. X: Degrees of freedom of the collision mesh (e.g., vertices or velocities). project_hessian_to_psd: Make sure the hessian is positive semi-definite.
- Returns:
The Hessian of the potential w.r.t. X. This will have a size of X.size by X.size.
hessian(self: ipctk.TangentialPotential, collision: ipctk.TangentialCollision, x: typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, 1]”], project_hessian_to_psd: ipctk.PSDProjectionMethod = <PSDProjectionMethod.NONE: 0>) -> typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”]
Compute the hessian of the potential for a single collision.
- Parameters:
collision: The collision. x: The collision stencil’s degrees of freedom.
- Returns:
The hessian of the potential.
Friction Potential¶
- class ipctk.FrictionPotential¶
Bases:
TangentialPotentialPublic Data Attributes:
The smooth friction mollifier parameter \(\epsilon_{v}\).
Inherited from
TangentialPotentialPublic Methods:
__init__(self, eps_v)Construct a friction potential.
Inherited from
TangentialPotential__init__(*args, **kwargs)__call__(*args, **kwargs)Overloaded function.
gradient(*args, **kwargs)Overloaded function.
hessian(*args, **kwargs)Overloaded function.
force(*args, **kwargs)Overloaded function.
force_jacobian(*args, **kwargs)Overloaded function.
Inherited from
pybind11_object
-
__annotations__ =
{}¶
-
__module__ =
'ipctk'¶
- _pybind11_conduit_v1_()¶
- property eps_v : float¶
The smooth friction mollifier parameter \(\epsilon_{v}\).
-
__annotations__ =
Tangential Adhesion Potential¶
- class ipctk.TangentialAdhesionPotential¶
Bases:
TangentialPotentialPublic Data Attributes:
Get the tangential adhesion mollifier parameter \(\epsilon_a\).
Inherited from
TangentialPotentialPublic Methods:
__init__(self, eps_a)Construct a tangential adhesion potential.
Inherited from
TangentialPotential__init__(*args, **kwargs)__call__(*args, **kwargs)Overloaded function.
gradient(*args, **kwargs)Overloaded function.
hessian(*args, **kwargs)Overloaded function.
force(*args, **kwargs)Overloaded function.
force_jacobian(*args, **kwargs)Overloaded function.
Inherited from
pybind11_object
-
__annotations__ =
{}¶
-
__module__ =
'ipctk'¶
- _pybind11_conduit_v1_()¶
- property eps_a : float¶
Get the tangential adhesion mollifier parameter \(\epsilon_a\).
-
__annotations__ =