1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Lagrange-multiplier constraint for collinear beads in 3d?

  1. Mar 25, 2008 #1
    1. The problem statement, all variables and given/known data

    I'm trying to write a Lagrange-multiplier constraint simulation along the lines of those described by Andrew Witkin here.

    The basic idea for this simulation is that you have a number of objects represented by three collinear beads joined by massless rods; one of the two rods changes length, and the other has a fixed length (the beads are in liquid interacting via rotne-prager tensor interactions, but the physics is not the gist of this question). The simulation works by calculating the Jacobian matrix of the constraints, using it to calculate Lagrange multipliers, finding constraint forces, and proceeding.

    So we have two constraints:

    1) the two beads of the fixed-length leg must remain the same distance apart, and
    2) the three beads must remain collinear.

    Here's the rub: I have the thing working wonderfully in 2d, but cannot for the life of me get it to behave in 3d.

    For terminology, we'll label the beads 1-3 and say that leg 1-2 is changing length and 2-3 is remaining fixed.

    2. Relevant equations

    In 2d, the first constraint is that [tex]r_23 = \delta[/tex], which we can rewrite as [tex]C=r_{23}^2 - \delta^2 = 0[/tex], or


    [tex]C = x_{3}^{2} - 2x_{2}x_{3} + x_{2}^{2} + y_{3}^2 - 2y_{2}y_{3} + y_2{^2} - \delta^2 = 0[/tex]

    So the Jacobian [tex]J_i = \frac{\partial C}{\partial q_{i}}[/tex] is

    [tex]J=[ 0, 0, 2x_{2}-2x_{3}, 2y_{2}-2y{3}, 2x_{3}-2x_{2}, 2y_{3}-2y{2} ][/tex]
    and we can remove the spurious 2's to get

    [tex]J=[ 0, 0, x_{2}-x_{3}, y_{2}-y_{3}, x_{3}-x_{2}, y_{3}-y_{2} ][/tex]

    For the second constraint in 2d (collinear), I used equivalent slopes:

    [tex]\frac{y_{\alpha}}{x_{\alpha}} = \frac{y_{\beta}}{x_{\beta}}[/tex]

    [tex]C=y_{\alpha}x_{\beta}-y_{\beta}x_{\alpha} = 0[/tex]

    [tex]C=(y_{3}-y_{2})(x_{2}-x_{1}) - (y_{2}-y_{1})(x_{3}-x_{2})[/tex]


    and so the Jacobian is

    [tex]J=[y_{2}-y_{3}, x_{3}-x_{2}, y_{3}-y_{1}, x_{1}-x_{3}, y_{1}-y_{2}, x_{2}-x_{1}][/tex]

    (hopefully I've transcribed all that correctly). Okay--so far in 2d, all this works beautifully.

  2. jcsd
  3. Mar 25, 2008 #2
    3. The attempt at a solution

    In 3d, things start going wrong. We can basically extend constraint (1) fairly trivially:

    [tex]J=[ 0, 0, 0, x_{2}-x_{3}, y_{2}-y_{3}, z_{2}-z_{3}, x_{3}-x_2, y_3-y_2, z_3-z_2][/tex]

    ...but the collinear constraint is trickier (to me). So far my attempts have centred around treating the problem as if we were constraining the spherical coordinates [tex]\theta[/tex] and [tex]\phi[/tex], since we can use the 2d "slope" constraint as our [tex]\theta[/tex] constraint, since it works and doesn't depend on z at all:

    [tex]J=[y_{2}-y_{3}, x_{3}-x_{2}, 0, y_{3}-y_{1}, x_{1}-x_{3}, 0, y_{1}-y_{2}, x_{2}-x_{1}, 0][/tex]

    Things go wrong when I attempt to add a third constraint for [tex]\phi[/tex]. Attempts to do variations of [tex]z_{23}/r_{23}=z_{12}/r_{12}[/tex] fail--at best merely failing to constrain [tex]\phi[/tex] properly (at which point the two rods begin flexing like mad, which does interesting but nonphysical things to the simulation), and at worst interfering with the other constraints (in one case forcing the rods to elongate beyond the bounds of the simulation).

    I'm not certain I understand what's going on. My best guess is that attempting to constrain it with separate constraints for [tex]\theta[/tex] and [tex]\phi[/tex] in cartesian coordinates is overconstraining the cartesian coords and going unstable. I'd like to find a nice way to either phrase it as one constraint equation or as three fairly independent ones. But I can't seem to manage it; I keep thinking in circles. Any good ideas?

    Since this is an iterative computer simulation, keeping everything in cartesian is pretty much a must (there's a bunch of matrix math going on). Been hammering at this a while with no good results. The 3d version works just fine as long as everything is coplanar in z, but any variation in z makes it go berserk.

    I even briefly tried leveraging [tex]A\cdotB=AB\cos\theta[/tex], setting [tex]\theta=0[/tex] to try and put everything on one constraint, which was almost interesting but since the Jacobian evaluated to zeros during the simulation turned out to be unuseful.
    Last edited: Mar 25, 2008
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?

Similar Discussions: Lagrange-multiplier constraint for collinear beads in 3d?