Insights Blog
-- Browse All Articles --
Physics Articles
Physics Tutorials
Physics Guides
Physics FAQ
Math Articles
Math Tutorials
Math Guides
Math FAQ
Education Articles
Education Guides
Bio/Chem Articles
Technology Guides
Computer Science Tutorials
Forums
Chemistry
Biology and Medical
Earth Sciences
Computer Science
Computing and Technology
DIY Projects
Trending
Featured Threads
Log in
Register
What's new
Search
Search
Search titles only
By:
Chemistry
Biology and Medical
Earth Sciences
Computer Science
Computing and Technology
DIY Projects
Menu
Log in
Register
Navigation
More options
Contact us
Close Menu
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Forums
Other Sciences
Programming and Computer Science
Building a Solar System simulation with python
Reply to thread
Message
[QUOTE="TheJP78, post: 6652566, member: 702787"] Hi, sorry for the delay. I didn't get much done since my code depends of the acc function. I've spoke to my professor again and he told me how to build the function for the earth-sun system (to introduce the other planets and the moon i will have to add an extra factor G*M*((ri - rj)/mod_(ri-rj)**3) to the accelerations in x and y, and other x, y components do the r vector (x1, y1, x2, y2, etc.)): [code] import numpy as np from math import sqrt def acc(r): x0 = r[0] #initial y0 = r[1] #conditions mod_r0 = sqrt(x0**2 + y0**2) #module of the r vector a0x = -G * M_sul * (x0/(mod_r0**3)) #acceleration due to the x component a0y = -G * M_sul * (y0/(mod_r0**3)) #acceleration due to the y component acctot = np.array(a0x, a0y) #acceleration vector return acctot [/code] M_sun is the mass of the sun and G is 6,67408.10^-11 N.kg²/m². The acceleration will be due to the sun, but when I introduce the moon I will have to consider the force that the moon exerts on the Earth as well. Now I have to implement the verlet integration method to calculate the orbit of the Earth around the sun and, later on, the other planets orbits and the moon orbit. I think will be something like this: [code] r[i] = r[0] + v[0]*dt + a[r[0]]*(dt**2)*0.5 #earth-sun r[i+1] = 2*r[i] - r[i-1] + a[r[0]]*(dt**2) #other bodies [/code] My professor said the implementation is almost the same as the Euler and Runge-Kutta methods, so I will try to do that way. Right now, this is all I have done because I have other subjects that are demanding my time. But I will work on it on the weekends to see what more I can do (I have till August 16 to deliver this simulation). Other thing to add is that I don't need to do an animation of the 8 planets orbiting the sun. It can be just a plot with the eliptics of each one plus the moon orbiting around the earth. P.S: He also gives me some more instructions, explaining me how to build the function using an example of the pendulum. [/QUOTE]
Insert quotes…
Post reply
Forums
Other Sciences
Programming and Computer Science
Building a Solar System simulation with python
Back
Top