# Pendulum with dry friction

**URL:** <https://discourse.julialang.org/t/pendulum-with-dry-friction/101123>\
**Category:** Modelling & Simulations\
**Tags:** jump, differentialequation\
**Created:** [July 3, 2023, 12:59pm UTC](https://discourse.julialang.org/t/pendulum-with-dry-friction/101123 "2023-07-03T12:59:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lieskjur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lieskjur/32/27611_2.png) [@lieskjur](https://discourse.julialang.org/u/lieskjur)\
**Post date:** [July 3, 2023, 12:59pm UTC](https://discourse.julialang.org/t/pendulum-with-dry-friction/101123/1 "2023-07-03T12:59:29Z")

</div>

Hi,

I have decided to implement dry friction into one of my simulation models. As a first step, I created a simple [example of a pendulum](https://gist.github.com/lieskjur/883b77f635f3fd810a5f4df3cb6883ca) that I would like to share.

I am already using [DifferentialEquations.jl](https://docs.sciml.ai/DiffEqDocs/) for my project so I decided to implement the friction using the combination of a continuous callback and [mixed complementarity problem](https://en.wikipedia.org/wiki/Mixed_complementarity_problem) solved with [JuMP](https://jump.dev/JuMP.jl/stable/manual/constraints/#Complementarity-constraints). I have taken the general idea from [Russ Tedrake’s “underactuated” course](https://underactuated.mit.edu/multibody.html#example6) and reformulated it so that it works in continuous time while also using a single MCP instead of three LCPs with slack variables.

Altogether I think it’s a concise and readable example that models behavior which can be quite tricky to implement. That being said, I might have made a mistake somewhere so don’t hesitate to correct me.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [July 3, 2023, 3:41pm UTC](https://discourse.julialang.org/t/pendulum-with-dry-friction/101123/2 "2023-07-03T15:41:02Z")

</div>

Yeah it’s cool how simple that turns out to be. Thanks for sharing!
