[sympy] KanesMethod with linear force-velocity relationship

59 views
Skip to first unread message

Guillaume Gay

unread,
Jan 12, 2015, 8:33:01 AM1/12/15
to sy...@googlegroups.com

Hi,

I'm trying to use sympy KanesMethod to model biological assemblies (i.e.
the mitotic spindle).

Molecular motors in biology follow linear force velocity relationships,
such that F = F_max(1 -ld/V_max) where ld is the relative speed of the
two points on which the force is applied (distant of l).

I strugle to implement this in the Kanes formalism... I tried various
things:
* constraint the generalized speed as u = (V_max - ld)
* declare the above relation in the kinetic differential equation

In both cases, the `to_linearizer` method rises a:

ValueError: Cannot have dynamicsymbols outside dynamic forcing vector.

* use directly ld as the speed, and declare it as auxiliary

Then I have a shape mismatch when I try to linearize.

Bellow is a notebook with the code:

http://nbviewer.ipython.org/github/glyg/Notebooks/blob/master/kt_sim/minimum%20Linear%20Force%20Velocity.ipynb



Best,

Guillaume

--
Guillaume Gay, PhD

http://damcb.com

43 rue Horace Bertin
13005 Marseille

+33 953 55 98 89
+33 651 95 94 00

n°SIRET 751 175 233 00020

Jason Moore

unread,
Jan 12, 2015, 1:09:06 PM1/12/15
to sy...@googlegroups.com
Some notes:

- Since you specified your kinematic relations as u = q', then you should set your velocities with u instead of q, for example: p1.set_vel(N, u1d * N.x)
- I doubt that you need to specify any velocity constraints and thus you will not have any dependent speeds. You've defined ell as some new coordinate, but do not add it as an independent coordinate. I don't think this is correct. It will likely work if you just remove the coordinate constraint stuff.

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscribe@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/54B3C853.5090405%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Jason Moore

unread,
Jan 12, 2015, 1:10:47 PM1/12/15
to sy...@googlegroups.com
I meant: p1.set_vel(N, u1 * N.x)

Guillaume Gay

unread,
Jan 13, 2015, 3:46:05 AM1/13/15
to sy...@googlegroups.com
Hi Jason, thanks a lot for the help.

I simplified a lot the definitions, and used directly the velocities in the definitions.

So the KanesMethod class can be instanciated, and the `to_linearizer` method works. The only issue I'm left with is that the M, A, B matrices output by the `linearizer.linearize()` are not consistent with the equations of motion - when you compare the f_3 equation with the uquations from M[dot q, dot u] = A[q, u]: the constant term is droped - compare cells In [8] and In [10] & In [11] on the notebook bellow:

http://nbviewer.ipython.org/github/glyg/Notebooks/blob/master/kt_sim/minimum%20Linear%20Force%20Velocity.ipynb

I'm not sure if this is my fault, or just that the linearizer wont work in my case because of the form of the contraint...

Best,

Guillaume
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.

To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/54B3C853.5090405%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.

To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.

For more options, visit https://groups.google.com/d/optout.

Guillaume Gay

unread,
Jan 13, 2015, 5:48:14 AM1/13/15
to sy...@googlegroups.com
A follow up:

I believe this comment in kanes.py (l. 206) is related. In my case, the constant is not negligeable.

            # Form of non-holonomic constraints is B*u + C = 0.
            # We partition B into independent and dependent columns:
            # Ars is then -B_dep.inv() * B_ind, and it relates dependent speeds
            # to independent speeds as: udep = Ars*uind, neglecting the C term.
            B_ind = self._k_nh[:, :p]
            B_dep = self._k_nh[:, p:o]
            self._Ars = -B_dep.LUsolve(B_ind)


Best,

Guillaume

Jason Moore

unread,
Jan 13, 2015, 1:44:10 PM1/13/15
to sy...@googlegroups.com
I think you are using a velocity constraint when it is not needed. You have your generalized coordinates: q1 and q2. L is simply sqrt(q1**2 + q2**2), right? I think you need to define ell = sqrt(q1**2 + q2**2). The velocity constraint functionality of KanesMethod is primarily in place to deal with non-holonomic constraints, which you don't have. It can probably be manipulated to be used for other things, but I don't think it is useful for this problem.

Guillaume Gay

unread,
Jan 13, 2015, 3:06:22 PM1/13/15
to sy...@googlegroups.com
Thanks for the follow up, sorry for my bad understanding of the method, I'm not a mechanics guy...

Here is the notebook without defining any dependent coordinates. This yields the same equations, so it's fine.

http://nbviewer.ipython.org/github/glyg/Notebooks/blob/master/kt_sim/minimum%20Linear%20Force%20Velocity.ipynb?flush_cache=true

The only thing that is puzzling me is that the linearization doesn't correspond the equations of motion (because as F=1-u, it can't be written in the form M*[dq, du] = A*[q, u], the constant term is dropped. I - wrongly - thought that defining dependent speeds would get around that.


Thnaks for the help any way, I'll cook something up from here.

Best,

Guillaume

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages