User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 426,500 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,150 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser: Programming Forums

Jupiters period?.. (interpolation)

Join Date: May 2008
Posts: 1
Reputation: afi88 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
afi88 afi88 is offline Offline
Newbie Poster

Jupiters period?.. (interpolation)

  #1  
May 13th, 2008
Hi. I have a problem with a physics assignment I have to finish by tonight.
They have already given me a python code, but I have to find the period T of Jupiter through interpolation.
(It doesnt have to be interpolation, but my teacher recommended it.)
This is the program:

from numpy import *
from scitools . easyviz . gnuplot_ import *
# Physical parameters and constants
G = 6.67259 e -11 # Gravitational constant in SI units
yeard = 365.25636 # Number of days in a year
years = yeard *24.0*60.0*60.0 # Number of seconds in a year .
r0 = 1.49597870691 e11 # AU
GMsun = 1.32712440018 e20 # G * M
MsunDivMjup = 1047.3486 # M / m_J
MsunDivMast = 1.0 e23 # M / m_A
# Simulation parameters
time = 50.0 # In years
dt = 0.01 # In years
nstep = int ( round ( time / dt ) )
rJ = zeros (( nstep ,3) , float )
vJ = rJ . copy ()
t = zeros ( nstep , float )
# Initialize positions and velocities in 3 d
rJ [0] = array ([ -5.758295190842140 E +11 ,
-5.704511997951533 E +11 ,1.525358540575477 E +10])
vJ [0] = array ([9.038714838773942 E +03 ,
-8.674265884570330 E +03 , -1.662886596994482 E +02])
# Convert to dimensionless coordinates
rJ = rJ / r0
vJ = vJ * years / r0
#
gmJ = GMsun * years **2.0/ r0 **3.0
gmA = 0.0
for i in range ( nstep -1) :
rJnorm = sqrt ( dot ( rJ [ i ] , rJ [ i ]) )
a = - gmJ * rJ [ i ]/ rJnorm **3.0
vJ [ i +1] = vJ [ i ] + a * dt
rJ [ i +1] = rJ [ i ] + vJ [ i +1]* dt
t [ i +1] = t [ i ] + dt
# Plot
plot ( rJ [: ,0] , rJ [: ,1])
xlabel ( ’X ( AU ) ’) ;
ylabel ( ’Y ( AU ) ’) ;
axis ( ’ equal ’)

I have searched for interpolation via python online, but I can only find interpolation on strings and stuff...
And I have to find the period T, by studying the time between each time Jupiter passes the xz-plane.
I guess this is when the y-coordinate is zero... I tried an if loop to find what i is when rJ [i ,1]=0...
but that didnt really seem to work. Anyone who can help me?
AddThis Social Bookmark Button
Reply With Quote  
All times are GMT -4. The time now is 5:24 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC