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

Adding the s_mu and k_mu to the tangent force Collision #139

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

antoinebou12
Copy link
Contributor

Description

Including the addition of multiple friction materials and blending types for friction coefficients. The changes span across documentation, collision mesh structures, and tangential collision calculations.

Documentation Updates:

  • Added a comprehensive tutorial on setting up and working with multiple friction types, including creating collision meshes, defining tangential collisions, specifying blend types, and computing friction forces. (docs/source/tutorial/frictions.rst)

Code Enhancements:

  • Collision Mesh Enhancements:

    • Added support for material IDs in the CollisionMesh class, allowing different friction properties for various materials. (src/ipc/collision_mesh.cpp, src/ipc/collision_mesh.hpp) [1] [2] [3] [4] [5] [6]
  • Tangential Collisions Enhancements:

    • Introduced a BlendType enum and MaterialPairFriction struct to handle various methods of blending friction coefficients and defining friction interactions between materials. (src/ipc/collisions/tangential/tangential_collisions.hpp, src/ipc/collisions/tangential/tangential_collisions.cpp) [1] [2] [3] [4] [5] [6] [7] [8]
  • Friction Potential Calculations:

    • Updated the TangentialPotential::gradient method to use dynamic friction coefficients (k_mu and s_mu) if available, enhancing the accuracy of friction force calculations. (src/ipc/potentials/tangential_potential.cpp)

These changes collectively enhance the IPC Toolkit's ability to model and compute friction forces accurately, accommodating multiple materials.

Fixes # (issue)
polyfem/polyfem#199

Type of change

Please delete options that are not relevant.

  • Enhancement (non-breaking change which improves existing functionality)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
  • Test B

Test Configuration:

  • OS and Version:
  • Compiler and Version:

Checklist

  • I have followed the project style guide
  • My code follows the clang-format style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@zfergus
Copy link
Member

zfergus commented Nov 15, 2024

Thanks again for the PR @antoinebou12!

A few years ago, I thought about how we could have different static and dynamic coefficients of friction. I hit a wall with it for two reasons

  1. unlike the contact potential, we know what the friction force is and we have to work backward to derive a dissipative potential whose negative gradient gives us the expected force
  2. much like the smooth friction mollifier, the transition between $\mu_s$ and $\mu_k$ needs to be smooth

However, I reviewed my notes from then, and I think I figured out a way to fix both problems. Here is a PDF of my Jupyter notebook.

The main idea is to multiply the smooth friction force mollifier $f_1(x)$ by a smooth coefficient of friction function $\mu(x)$. Then to get the correct mollifier for the potential we can integrate this function

$$f_0^\mu(x) = \int \mu(x) f_1(x)~\mathrm{d}x.$$

The nice thing, which I didn't realize back then, is the chain rule of this function will produce the same outcome as the original chain-rule. That is for a potential

$$ D_k(\mathbf{v}) = \lambda_k^n f_0^\mu (|\mathbf{u}|), $$

the force is

$$ F_k(\mathbf{v}) = -\nabla D_k(\mathbf{v}) = \lambda_k^n ~ \mu(|\mathbf{u}|) ~ f_1 (|\mathbf{u}|) / |\mathbf{u}| \mathbf{T}_k \mathbf{u}, $$

where $\mathbf{u}=\mathbf{T}_k^{\top} \mathbf{v}$ is the tangential relative velocity.

Hopefully, implementing this should be pretty easy. If not, let me know and I am happy to help in my spare time.

@zfergus zfergus added the enhancement New feature or request label Nov 23, 2024
@zfergus zfergus added this to the v1.4.0 milestone Nov 23, 2024
antoinebou12 and others added 7 commits December 10, 2024 14:38
* Create Dockerfile devcontainer

* Create devcontainer.json

* Add files via upload

* Update pre-commit-config.yaml

* Update pre-commit-config.yaml

* Update devcontainer.json

* Update Dockerfile

* Update devcontainer.json

* Update Dockerfile

* Create CMakePresets.json

* Update CMakePresets.json

* Update Dockerfile

* Rename pre-commit-config.yaml to .pre-commit-config.yaml

* Update devcontainer.json

* Update devcontainer.json

* Update Dockerfile

* Update devcontainer.json

* Update Dockerfile

* Update Dockerfile

* Update Dockerfile

* Update Dockerfile

* Update Dockerfile

* Update Dockerfile

* Update devcontainer.json

* Update Dockerfile

* Update Dockerfile

* Update devcontainer.json

* Update .pre-commit-config.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants