Ask Your Question
0

how to plot solution of differential system

asked 2012-09-21 16:24:40 -0500

5taras gravatar image

updated 2012-09-22 01:49:18 -0500

calc314 gravatar image

Hi, everyone! I got a question. I have a system of three Newton's equations

x''=-x/(x*x+y*y+z*z)^3/2-F(t)
y''=-x/(x*x+y*y+z*z)^3/2
z''=-x/(x*x+y*y+z*z)^3/2

I use ode_solver() to solve numerically the system by using y[0] for x, y[1] for y, y[2] for z like in example in the manual without using jacobian:

j_1= lambda t,y: [ y[3], y[4], y[5],  -y[0]/(y[0]*y[0]+y[1]*y[1]+y[2]*y[2])^(1.5)-F*cos(w*t), -y[1]/(y[0]*y[0]+y[1]*y[1]+y[2]*y[2])^(1.5), -y[2]/(y[0]*y[0]+y[1]*y[1]+y[2]*y[2])^(1.5)]

How may I plot the curve (x(t), y(t)) or (x(t), z(t))? T.plot_solution(i=0, filename=outfile) allows to plot only (x(t), t), (y(t), t) or (z(t), t) Thank you

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
2

answered 2012-09-22 01:48:45 -0500

calc314 gravatar image

You can get access to the list of solution points using the .solution option.

a=T.solution
print a

The code above shows the solution points and you can see the data structure. To plot what you want, try these:

xysoln=[[soln[1][0],soln[1][1]] for soln in a]
list_plot(xysoln)

yzsoln=[[soln[1][1],soln[1][2]] for soln in a]
list_plot(yzsoln)

xzsoln=[[soln[1][0],soln[1][2]] for soln in a]
list_plot(xzsoln)

xyzsoln=[[soln[1][0],soln[1][1],soln[1][2]] for soln in a]
list_plot(xyzsoln)
edit flag offensive delete link more
0

answered 2012-09-22 02:23:29 -0500

5taras gravatar image

thank you for your answer

edit flag offensive delete link more

Comments

If you like it, please "accept" @calc314's answer by hitting the check mark.

kcrisman gravatar imagekcrisman ( 2012-09-27 14:58:05 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-09-21 16:24:40 -0500

Seen: 581 times

Last updated: Sep 22 '12