1. Limited time only! Sign up for a free 30min personal 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!

Solve non-dimensionalized spring pendulum system on python

  1. Dec 4, 2013 #1
    1. The problem statement, all variables and given/known data
    I'm supposed to solve the spring pendulum numerically on python 2.7, using odeint. The system is supposed to solved for the y -direction and the x-direction in terms of time. In class we did this for pendulum DE, but that only had x as the dependent variable, this system has two.

    2. Relevant equations
    These are the non-dimensionalized De's I get
    [itex]\frac{d^{2}Y}{d\tau^{2}} = -1+\frac{(1-Y)}{\sigma}-\frac{(1-\sigma)(1-Y)}{\sigma\sqrt{X^{2}+(1-Y)^{2}}}[/itex]

    and
    [itex]\frac{d^{2}X}{d\tau^{2}}=-\frac{X}{\sigma}+\frac{(1-\sigma)X}{\sigma\sqrt{X^{2}+(1-Y)^{2}}}[/itex].
    Where σ is the non-dimensional parameter

    3. The attempt at a solution
    def rhs(xvector,t):

    x1dot=xvector[1]
    x2dot=xvector[3]
    x3dot=yvector[0]
    x4dot=(-xvector[1]/sigma)+((1-sigma)*xvector[0])/(sigma*sqrt((xvector[0])**2+(1-yvector[0])**2))

    return [x1dot,x2dot,x3dot,x4dot]

    This is the beginning of the code, but I don't know how to include the y vector into this function?
     
    Last edited: Dec 4, 2013
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted