Multi-component pendulum becomes unstable

Hi everyone,

I have started my journey into using ModelingToolkit. So far it has been working quite well and I am very impressed.

I am going down the component-based path. I have a somewhat complex system in mind but I have started implementing a few components and testing them individually. I have hit an issue with some multi-body dynamics, I have a mass-less rigid Link, which when combined with a Mass component to create a pendulum has issues when crossing vertical. I have attached two files:

  • A single component pendulum which seems to work as expected.
  • A two component pendulum which appears to explode/become unstable when the pendulum crosses vertical (θ = -90). QNDF-solver does seem to stabilize the model but it seems to do so at the cost of dissipating a lot of energy from the system. Also, if gravity is applied in horizontal direction it does become stable as long as the pendulum does not cross vertical.

To the best of my knowledge the two systems should be equivalent.

ModelingToolkit does not generate the same set of equations for both systems but I am not sure that is to be expected. Output of full_equations() below:

Single component system:

 Differential(t)(θ(t)) ~ θ̇(t)
 Differential(t)(θ̇(t)) ~ θˍtt(t)
 0 ~ (-cos(θ(t))*f(t)) / m + l*sin(θ(t))*θˍtt(t) + l*(θ̇(t)^2)*cos(θ(t))
 0 ~ (-g*m - sin(θ(t))*f(t)) / m - l*θˍtt(t)*cos(θ(t)) + l*sin(θ(t))*(θ̇(t)^2)

Two component system:

 Differential(t)(link₊pY₊u(t)) ~ link₊pY₊uˍt(t)
 Differential(t)(link₊pY₊uˍt(t)) ~ link₊l*cos(link₊θ(t))*link₊θˍtt(t) - link₊l*sin(link₊θ(t))*(link₊θˍt(t)^2)
 0 ~ -link₊pY₊u(t) + link₊l*sin(link₊θ(t))
 0 ~ mass₊g*mass₊m + link₊f(t)*sin(link₊θ(t)) + (link₊l*cos(link₊θ(t))*link₊θˍtt(t) - link₊l*sin(link₊θ(t))*(link₊θˍt(t)^2))*mass₊m
 0 ~ -link₊pY₊uˍt(t) + link₊l*cos(link₊θ(t))*link₊θˍt(t)
 0 ~ (cos(link₊θ(t))*link₊f(t)) / mass₊m - link₊l*sin(link₊θ(t))*link₊θˍtt(t) - link₊l*cos(link₊θ(t))*(link₊θˍt(t)^2)

I wonder what I am missing here? Any ideas/inputs on how to stabilize the model would be much appreciated.

pendulum.jl (1.2 KB)
pendulum_split.jl (2.0 KB)

3 Likes

This is a phenomena due to dummy derivatives since there is not a globally stable cartesian coordinate choice for the multi-pendulum. It’s explained in detail in the lecture notes:

This case is also explained in the recent webinar starting at minute 41:

As described, this case might want dummy_derivative=false in the structural simplification, though with the trade-offs as discussed in the video.

1 Like

Thanks Chris. This really helped a lot.

My biggest concern was if I had made a mistake in my model but the issue I was seeing is to be expected for my test case. After seeing and reading through what you shared I converted into a very stiff spring and that seems to eliminate the singularity as well, although it adds some other complexities that may not be worth the trade of.