Metadata-Version: 2.4
Name: dismech-newton
Version: 0.1.0.post2
Summary: Discrete Elastic Rods for NVIDIA Newton.
Keywords: discrete elastic rods,rods,simulation,physics,robotics,newton,warp,gpu
Author: ryanchaiyakul
Author-email: ryanchaiyakul <ryanchaiyakul@gmail.com>
License-Expression: GPL-3.0-or-later
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Environment :: GPU :: NVIDIA CUDA
Classifier: Topic :: Scientific/Engineering :: Physics
Requires-Dist: newton~=1.6.0
Requires-Dist: scipy>=1.14
Requires-Dist: cupy-cuda13x>=14.2.0 ; extra == 'gpu'
Requires-Dist: nvmath-python[cu13]>=1.0 ; extra == 'gpu'
Requires-Dist: gitpython>=3.1 ; extra == 'mujoco'
Requires-Dist: mujoco~=3.12.0 ; extra == 'mujoco'
Requires-Dist: mujoco-warp~=3.12.0 ; extra == 'mujoco'
Requires-Dist: pycollada>=0.9 ; extra == 'mujoco'
Requires-Dist: trimesh>=4 ; extra == 'mujoco'
Requires-Dist: imgui-bundle>=1.92.900 ; extra == 'viewer'
Requires-Dist: pyglet>=2.1.6,<3 ; extra == 'viewer'
Requires-Dist: pyopengl>=3.1 ; extra == 'viewer'
Requires-Dist: pillow>=10 ; extra == 'viewer'
Requires-Dist: matplotlib>=3.8 ; extra == 'viewer'
Requires-Python: >=3.10
Project-URL: Homepage, https://github.com/ryanchaiyakul/dismech-newton
Project-URL: Issues, https://github.com/ryanchaiyakul/dismech-newton/issues
Provides-Extra: gpu
Provides-Extra: mujoco
Provides-Extra: viewer
Description-Content-Type: text/markdown

# DiSMech-Newton

[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://opensource.org/license/gpl-3.0)
![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue)
![CUDA 13](https://img.shields.io/badge/CUDA-13-76B900)

Discrete elastic rods for [NVIDIA Newton](https://github.com/newton-physics/newton).

- **`ADMMDiSMechSolver`**: implicit DER solved with ADMM, inspired by
  [Daviet (2023)](https://research.nvidia.com/labs/prl/admm_hair/), with rod-rod, rod-shape and
  rod-ground contact and Coulomb friction.
- **`DiSMechSolver`**: implicit DER solved with Newton-Raphson.

## Examples

<table>
  <tr>
    <th width="33%">Cantilever</th>
    <th width="33%">Overhand Knot</th>
    <th width="33%">Plectoneme</th>
  </tr>
  <tr>
    <td><img src="https://raw.githubusercontent.com/ryanchaiyakul/dismech-newton/master/docs/admm_cantilever.webp" alt="Cantilever" width="100%"></td>
    <td><img src="https://raw.githubusercontent.com/ryanchaiyakul/dismech-newton/master/docs/admm_knot.webp" alt="Overhand knot" width="100%"></td>
    <td><img src="https://raw.githubusercontent.com/ryanchaiyakul/dismech-newton/master/docs/admm_plectoneme.webp" alt="Plectoneme" width="100%"></td>
  </tr>
  <tr>
    <td valign="top">DER (top) and Newton's VBD (bottom) against Euler-Bernoulli.<br><code>uv run examples/cantilever.py</code></td>
    <td valign="top">A knot pulled tight with friction <a href="https://doi.org/10.1103/PhysRevLett.99.164301">Audoly et al. (2007)</a>.<br><code>uv run examples/overhand_knot.py</code></td>
    <td valign="top">A twisted rod coils into a plectoneme <a href="https://doi.org/10.1016/j.bpj.2009.02.032">Clauvelin et al. (2009)</a>.<br><code>uv run examples/plectoneme.py</code></td>
  </tr>
  <tr>
    <th width="33%">Flagella Bundling</th>
    <th width="33%">System Identification</th>
    <th width="33%">Two-way Coupled Solvers</th>
  </tr>
  <tr>
    <td><img src="https://raw.githubusercontent.com/ryanchaiyakul/dismech-newton/master/docs/admm_flagella.webp" alt="Flagella bundling" width="100%"></td>
    <td><img src="https://raw.githubusercontent.com/ryanchaiyakul/dismech-newton/master/docs/fit_buckling.webp" alt="Fitting stiffness, density and damping to buckling recordings" width="100%"></td>
    <td><img src="https://raw.githubusercontent.com/ryanchaiyakul/dismech-newton/master/docs/admm_franka.webp" alt="Pick and place" width="100%"></td>
  </tr>
  <tr>
    <td valign="top">Flagella bundle in a viscous fluid <a href="https://arxiv.org/abs/2205.10309">Tong et al. (2022)</a>.<br><code>uv run examples/flagella.py --flagella 10</code></td>
    <td valign="top">L-BFGS fits stiffness, density and damping to video and a gripper force sensor by differentiating through the solver.<br><code>uv run examples/fit_buckling.py</code></td>
    <td valign="top">A MuJoCo Franka carries a rod with two-way coupling (experimental).<br><code>uv run --extra mujoco examples/experimental/franka_rod.py</code></td>
  </tr>
</table>

## Install

Requires Python 3.10+ and [uv](https://docs.astral.sh/uv/). Runs on an NVIDIA GPU with CUDA 13 or on the CPU.

```bash
git clone https://github.com/ryanchaiyakul/dismech-newton.git
cd dismech-newton
uv sync --extra gpu --extra viewer
uv run examples/cantilever.py
```