Skip to content

Separate Static and Kinetic Coefficients of Friction #177

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

Merged
merged 7 commits into from
Jul 18, 2025
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
10 changes: 10 additions & 0 deletions docs/source/cpp-api/adhesion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ Functions
- The first derivative of the tangential adhesion mollifier function divided by y.
* - :func:`tangential_adhesion_f2_x_minus_f1_over_x3`
- The second derivative of the tangential adhesion mollifier function times y minus the first derivative all divided by y cubed.
* - :func:`smooth_mu_a0`
- Compute the value of the ∫ μ(y) a₁(y) dy, where a₁ is the first derivative of the smooth tangential adhesion mollifier.
* - :func:`smooth_mu_a1`
- Compute the value of the μ(y) a₁(y), where a₁ is the first derivative of the smooth tangential adhesion mollifier.
* - :func:`smooth_mu_a2`
- Compute the value of d/dy (μ(y) a₁(y)), where a₁ is the first derivative of the smooth tangential adhesion mollifier.
* - :func:`smooth_mu_a1_over_x`
- Compute the value of the μ(y) a₁(y) / y, where a₁ is the first derivative of the smooth tangential adhesion mollifier.
* - :func:`smooth_mu_a2_x_minus_mu_a1_over_x3`
- Compute the value of the [(d/dy μ(y) a₁(y)) ⋅ y - μ(y) a₁(y)] / y³, where a₁ and a₂ are the first and second derivatives of the smooth tangential adhesion mollifier.


Normal Adhesion Potential
Expand Down
14 changes: 13 additions & 1 deletion docs/source/cpp-api/friction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,16 @@ Smooth Mollifier
.. doxygenfunction:: smooth_friction_f1
.. doxygenfunction:: smooth_friction_f2
.. doxygenfunction:: smooth_friction_f1_over_x
.. doxygenfunction:: smooth_friction_f2_x_minus_f1_over_x3
.. doxygenfunction:: smooth_friction_f2_x_minus_f1_over_x3

Smooth :math:`\mu`
------------------

.. doxygenfunction:: smooth_mu
.. doxygenfunction:: smooth_mu_derivative

.. doxygenfunction:: smooth_mu_f0
.. doxygenfunction:: smooth_mu_f1
.. doxygenfunction:: smooth_mu_f2
.. doxygenfunction:: smooth_mu_f1_over_x
.. doxygenfunction:: smooth_mu_f2_x_minus_f1_over_x3
11 changes: 10 additions & 1 deletion docs/source/python-api/adhesion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,13 @@ Tangential Adhesion Potential
.. autofunction:: ipctk.tangential_adhesion_f1
.. autofunction:: ipctk.tangential_adhesion_f2
.. autofunction:: ipctk.tangential_adhesion_f1_over_x
.. autofunction:: ipctk.tangential_adhesion_f2_x_minus_f1_over_x3
.. autofunction:: ipctk.tangential_adhesion_f2_x_minus_f1_over_x3

Smooth :math:`\mu`
------------------

.. autofunction:: ipctk.smooth_mu_a0
.. autofunction:: ipctk.smooth_mu_a1
.. autofunction:: ipctk.smooth_mu_a2
.. autofunction:: ipctk.smooth_mu_a1_over_x
.. autofunction:: ipctk.smooth_mu_a2_x_minus_mu_a1_over_x3
13 changes: 12 additions & 1 deletion docs/source/python-api/friction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,15 @@ Smooth Mollifier
.. autofunction:: ipctk.smooth_friction_f1
.. autofunction:: ipctk.smooth_friction_f2
.. autofunction:: ipctk.smooth_friction_f1_over_x
.. autofunction:: ipctk.smooth_friction_f2_x_minus_f1_over_x3
.. autofunction:: ipctk.smooth_friction_f2_x_minus_f1_over_x3

Smooth :math:`\mu`
------------------

.. autofunction:: ipctk.smooth_mu
.. autofunction:: ipctk.smooth_mu_derivative
.. autofunction:: ipctk.smooth_mu_f0
.. autofunction:: ipctk.smooth_mu_f1
.. autofunction:: ipctk.smooth_mu_f2
.. autofunction:: ipctk.smooth_mu_f1_over_x
.. autofunction:: ipctk.smooth_mu_f2_x_minus_f1_over_x3
5,447 changes: 5,447 additions & 0 deletions notebooks/separate_mu.ipynb

Large diffs are not rendered by default.

98 changes: 98 additions & 0 deletions python/src/adhesion/adhesion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,102 @@ void define_adhesion(py::module_& m)
The second derivative of the tangential adhesion mollifier function times y minus the first derivative all divided by y cubed.
)ipc_Qu8mg5v7",
"y"_a, "eps_a"_a);

m.def(
"smooth_mu_a0", &smooth_mu_a0,
R"ipc_Qu8mg5v7(
Compute the value of the ∫ μ(y) a₁(y) dy, where a₁ is the first derivative of the smooth tangential adhesion mollifier.

Note:
The `a0`/`a1` are unrelated to the `a0`/`a1` in the normal adhesion.

Parameters:
y: The tangential relative speed.
mu_s: Coefficient of static adhesion.
mu_k: Coefficient of kinetic adhesion.
eps_a: Velocity threshold below which static adhesion force is applied.

Returns:
The value of the integral at y.
)ipc_Qu8mg5v7",
"y"_a, "mu_s"_a, "mu_k"_a, "eps_a"_a);

m.def(
"smooth_mu_a1", &smooth_mu_a1,
R"ipc_Qu8mg5v7(
Compute the value of the μ(y) a₁(y), where a₁ is the first derivative of the smooth tangential adhesion mollifier.

Note:
The `a1` is unrelated to the `a1` in the normal adhesion.

Parameters:
y: The tangential relative speed.
mu_s: Coefficient of static adhesion.
mu_k: Coefficient of kinetic adhesion.
eps_a: Velocity threshold below which static adhesion force is applied.

Returns:
The value of the product at y.
)ipc_Qu8mg5v7",
"y"_a, "mu_s"_a, "mu_k"_a, "eps_a"_a);

m.def(
"smooth_mu_a2", &smooth_mu_a2,
R"ipc_Qu8mg5v7(
Compute the value of d/dy (μ(y) a₁(y)), where a₁ is the first derivative of the smooth tangential adhesion mollifier.

Note:
The `a1`/`a2` are unrelated to the `a1`/`a2` in the normal adhesion.

Parameters:
y: The tangential relative speed.
mu_s: Coefficient of static adhesion.
mu_k: Coefficient of kinetic adhesion.
eps_a: Velocity threshold below which static adhesion force is applied.

Returns:
The value of the derivative at y.
)ipc_Qu8mg5v7",
"y"_a, "mu_s"_a, "mu_k"_a, "eps_a"_a);

m.def(
"smooth_mu_a1_over_x", &smooth_mu_a1_over_x,
R"ipc_Qu8mg5v7(
Compute the value of the μ(y) a₁(y) / y, where a₁ is the first derivative of the smooth tangential adhesion mollifier.

Notes:
The `x` in the function name refers to the parameter `y`.
The `a1` is unrelated to the `a1` in the normal adhesion.

Parameters:
y: The tangential relative speed.
mu_s: Coefficient of static adhesion.
mu_k: Coefficient of kinetic adhesion.
eps_a: Velocity threshold below which static adhesion force is applied.

Returns:
The value of the product at y.
)ipc_Qu8mg5v7",
"y"_a, "mu_s"_a, "mu_k"_a, "eps_a"_a);

m.def(
"smooth_mu_a2_x_minus_mu_a1_over_x3",
&smooth_mu_a2_x_minus_mu_a1_over_x3,
R"ipc_Qu8mg5v7(
Compute the value of the [(d/dy μ(y) a₁(y)) ⋅ y - μ(y) a₁(y)] / y³, where a₁ and a₂ are the first and second derivatives of the smooth tangential adhesion mollifier.

Notes:
The `x` in the function name refers to the parameter `y`.
The `a1`/`a2` are unrelated to the `a1`/`a2` in the normal adhesion.

Parameters:
y: The tangential relative speed.
mu_s: Coefficient of static adhesion.
mu_k: Coefficient of kinetic adhesion.
eps_a: Velocity threshold below which static adhesion force is applied.

Returns:
The value of the expression at y.
)ipc_Qu8mg5v7",
"y"_a, "mu_s"_a, "mu_k"_a, "eps_a"_a);
}
1 change: 1 addition & 0 deletions python/src/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ PYBIND11_MODULE(ipctk, m)

// friction
define_smooth_friction_mollifier(m);
define_smooth_mu(m);

// implicits
define_plane_implicit(m);
Expand Down
7 changes: 5 additions & 2 deletions python/src/collisions/tangential/tangential_collision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,11 @@ void define_tangential_collision(py::module_& m)
&TangentialCollision::normal_force_magnitude,
"Normal force magnitude")
.def_readwrite(
"mu", &TangentialCollision::mu,
"Ratio between normal and tangential forces (e.g., friction coefficient)")
"mu_s", &TangentialCollision::mu_s,
"Ratio between normal and static tangential forces (e.g., friction coefficient)")
.def_readwrite(
"mu_k", &TangentialCollision::mu_k,
"Ratio between normal and kinetic tangential forces (e.g., friction coefficient)")
.def_readwrite("weight", &TangentialCollision::weight, "Weight")
.def_property(
"weight_gradient",
Expand Down
18 changes: 14 additions & 4 deletions python/src/collisions/tangential/tangential_collisions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,40 @@ void define_tangential_collisions(py::module_& m)
double>(&TangentialCollisions::build),
"mesh"_a, "vertices"_a, "collisions"_a, "normal_potential"_a,
"normal_stiffness"_a, "mu"_a)
.def(
"build",
py::overload_cast<
const CollisionMesh&, Eigen::ConstRef<Eigen::MatrixXd>,
const NormalCollisions&, const NormalPotential&, double, double,
double>(&TangentialCollisions::build),
"mesh"_a, "vertices"_a, "collisions"_a, "normal_potential"_a,
"normal_stiffness"_a, "mu_s"_a, "mu_k"_a)
.def(
"build",
[](TangentialCollisions& self, const CollisionMesh& mesh,
Eigen::ConstRef<Eigen::MatrixXd> vertices,
const NormalCollisions& collisions,
const NormalPotential& normal_potential,
const double normal_stiffness,
Eigen::ConstRef<Eigen::VectorXd> mus) {
Eigen::ConstRef<Eigen::VectorXd> mu_s,
Eigen::ConstRef<Eigen::VectorXd> mu_k) {
self.build(
mesh, vertices, collisions, normal_potential,
normal_stiffness, mus);
normal_stiffness, mu_s, mu_k);
},
"mesh"_a, "vertices"_a, "collisions"_a, "normal_potential"_a,
"normal_stiffness"_a, "mus"_a)
"normal_stiffness"_a, "mu_s"_a, "mu_k"_a)
.def(
"build",
py::overload_cast<
const CollisionMesh&, Eigen::ConstRef<Eigen::MatrixXd>,
const NormalCollisions&, const NormalPotential&, const double,
Eigen::ConstRef<Eigen::VectorXd>,
Eigen::ConstRef<Eigen::VectorXd>,
const std::function<double(double, double)>&>(
&TangentialCollisions::build),
"mesh"_a, "vertices"_a, "collisions"_a, "normal_potential"_a,
"normal_stiffness"_a, "mus"_a, "blend_mu"_a)
"normal_stiffness"_a, "mu_s"_a, "mu_k"_a, "blend_mu"_a)
.def(
"__len__", &TangentialCollisions::size,
"Get the number of friction collisions.")
Expand Down
1 change: 1 addition & 0 deletions python/src/friction/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
set(SOURCES
smooth_friction_mollifier.cpp
smooth_mu.cpp
)

target_sources(ipctk PRIVATE ${SOURCES})
3 changes: 2 additions & 1 deletion python/src/friction/bindings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

#include <pybind11/pybind11.h>

void define_smooth_friction_mollifier(py::module_& m);
void define_smooth_friction_mollifier(py::module_& m);
void define_smooth_mu(py::module_& m);
127 changes: 127 additions & 0 deletions python/src/friction/smooth_mu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
#include <common.hpp>

#include <ipc/friction/smooth_mu.hpp>

using namespace ipc;

void define_smooth_mu(py::module_& m)
{
m.def(
"smooth_mu", &smooth_mu,
R"ipc_Qu8mg5v7(
Smooth coefficient from static to kinetic friction.

Parameters:
y: The tangential relative speed.
mu_s: Coefficient of static friction.
mu_k: Coefficient of kinetic friction.
eps_v: Velocity threshold below which static friction force is applied.

Returns:
The value of the μ at y.
)ipc_Qu8mg5v7",
"y"_a, "mu_s"_a, "mu_k"_a, "eps_v"_a);

m.def(
"smooth_mu_derivative", &smooth_mu_derivative,
R"ipc_Qu8mg5v7(
Compute the derivative of the smooth coefficient from static to kinetic friction.

Parameters:
y: The tangential relative speed.
mu_s: Coefficient of static friction.
mu_k: Coefficient of kinetic friction.
eps_v: Velocity threshold below which static friction force is applied.

Returns:
The value of the derivative at y.
)ipc_Qu8mg5v7",
"y"_a, "mu_s"_a, "mu_k"_a, "eps_v"_a);

m.def(
"smooth_mu_f0", &smooth_mu_f0,
R"ipc_Qu8mg5v7(
Compute the value of the ∫ μ(y) f₁(y) dy, where f₁ is the first derivative of the smooth friction mollifier.

Parameters:
y: The tangential relative speed.
mu_s: Coefficient of static friction.
mu_k: Coefficient of kinetic friction.
eps_v: Velocity threshold below which static friction force is applied.

Returns:
The value of the integral at y.
)ipc_Qu8mg5v7",
"y"_a, "mu_s"_a, "mu_k"_a, "eps_v"_a);

m.def(
"smooth_mu_f1", &smooth_mu_f1,
R"ipc_Qu8mg5v7(
Compute the value of the μ(y) f₁(y), where f₁ is the first derivative of the smooth friction mollifier.

Parameters:
y: The tangential relative speed.
mu_s: Coefficient of static friction.
mu_k: Coefficient of kinetic friction.
eps_v: Velocity threshold below which static friction force is applied.

Returns:
The value of the product at y.
)ipc_Qu8mg5v7",
"y"_a, "mu_s"_a, "mu_k"_a, "eps_v"_a);

m.def(
"smooth_mu_f2", &smooth_mu_f2,
R"ipc_Qu8mg5v7(
Compute the value of d/dy (μ(y) f₁(y)), where f₁ is the first derivative of the smooth friction mollifier.

Parameters:
y: The tangential relative speed.
mu_s: Coefficient of static friction.
mu_k: Coefficient of kinetic friction.
eps_v: Velocity threshold below which static friction force is applied.

Returns:
The value of the derivative at y.
)ipc_Qu8mg5v7",
"y"_a, "mu_s"_a, "mu_k"_a, "eps_v"_a);

m.def(
"smooth_mu_f1_over_x", &smooth_mu_f1_over_x,
R"ipc_Qu8mg5v7(
Compute the value of the μ(y) f₁(y) / y, where f₁ is the first derivative of the smooth friction mollifier.

Note:
The `x` in the function name refers to the parameter `y`.

Parameters:
y: The tangential relative speed.
mu_s: Coefficient of static friction.
mu_k: Coefficient of kinetic friction.
eps_v: Velocity threshold below which static friction force is applied.

Returns:
The value of the product at y.
)ipc_Qu8mg5v7",
"y"_a, "mu_s"_a, "mu_k"_a, "eps_v"_a);

m.def(
"smooth_mu_f2_x_minus_mu_f1_over_x3",
&smooth_mu_f2_x_minus_mu_f1_over_x3,
R"ipc_Qu8mg5v7(
Compute the value of the [(d/dy μ(y) f₁(y)) ⋅ y - μ(y) f₁(y)] / y³, where f₁ and f₂ are the first and second derivatives of the smooth friction mollifier.

Note:
The `x` in the function name refers to the parameter `y`.

Parameters:
y: The tangential relative speed.
mu_s: Coefficient of static friction.
mu_k: Coefficient of kinetic friction.
eps_v: Velocity threshold below which static friction force is applied.

Returns:
The value of the expression at y.
)ipc_Qu8mg5v7",
"y"_a, "mu_s"_a, "mu_k"_a, "eps_v"_a);
}
Loading
Loading