Solve non-dimensionalized spring pendulum system on python

In summary, the conversation discusses solving a spring pendulum numerically on python 2.7 using odeint. The system involves two dependent variables in the x and y directions. The homework equations are correctly non-dimensionalized and the solution process is explained. To include the y vector in the function, it can be added as another input and used in the equations accordingly.
  • #1
gothloli
39
0

Homework Statement


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.

Homework 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

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:
Technology news on Phys.org
  • #2


I understand your struggle with using odeint to solve a spring pendulum with two dependent variables. The first step in solving this problem is to make sure that your equations are correctly non-dimensionalized, as this can affect the behavior of the system. From your homework equations, it looks like you have correctly non-dimensionalized the equations.

To include the y vector into your function, you can simply add it as another input to the function. Your function will then take in both the x and y vectors, and you can use them in your equations accordingly. Your code would look something like this:

def rhs(xvector, yvector, t):
x1dot = xvector[1]
x2dot = xvector[3]
y1dot = yvector[1]
y2dot = (-yvector[1]/sigma) + ((1-sigma)*yvector[0])/(sigma*sqrt((xvector[0])**2+(1-yvector[0])**2))

return [x1dot, x2dot, y1dot, y2dot]

This way, you can solve for both the x and y directions simultaneously. I hope this helps and good luck with your assignment!
 

1. What does it mean to non-dimensionalize a spring pendulum system?

Non-dimensionalization is a mathematical technique used to remove units of measurement from a system of equations. In the case of a spring pendulum system, this involves scaling the variables in the equations so that they are expressed in terms of dimensionless parameters.

2. Why is non-dimensionalization important in solving a spring pendulum system on python?

Non-dimensionalization allows for easier computation and analysis of the system by simplifying the equations and removing the need for complex units of measurement. This makes it easier to write and debug code in Python, as well as compare results to theoretical predictions.

3. How do I non-dimensionalize a spring pendulum system in python?

To non-dimensionalize a system in python, you will need to identify the relevant variables and parameters in the equations and assign them appropriate scaling factors. These factors will depend on the specific system being modeled, and may involve using known physical constants or experimental data.

4. Can I use any python library to solve a non-dimensionalized spring pendulum system?

Yes, there are several libraries available in python that can be used to solve non-dimensionalized systems, such as NumPy and SciPy. These libraries provide functions for solving differential equations and performing numerical computations, which are essential for solving a spring pendulum system.

5. How can I verify the accuracy of my python solution for a non-dimensionalized spring pendulum system?

One way to verify the accuracy of your solution is to compare it to theoretical predictions or experimental data. You can also perform sensitivity analyses by varying the input parameters and observing the effects on the output. Additionally, you can check for conservation of energy and other physical principles in your solution.

Similar threads

  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
15
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
5
Views
2K
  • Programming and Computer Science
Replies
3
Views
2K
  • Programming and Computer Science
Replies
1
Views
2K
  • Programming and Computer Science
Replies
3
Views
931
  • Programming and Computer Science
Replies
2
Views
895
  • Programming and Computer Science
Replies
2
Views
916
  • Programming and Computer Science
Replies
2
Views
720
Back
Top