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
Simulating Gravitational Interactions in a Particle System
Reply to thread
Message
[QUOTE="Jozefina Gramatikova, post: 6096179, member: 648770"] I have a project to make the solar system. I am trying to start from somwhere. On the notes it says that we need to start by creating a System of Particles [LIST] [*]Two-body simulation (Circular motion) [*]Implement Gravitational acceleration Each particle (planet) could have its own field. [LIST] [*]I.e. Each particle loops over all the other bodies to get the effect of all the other fields on it. [/LIST] [*]Extend to three body system [/LIST] Need to create all accelerations in one step before updating the positions and velocities. I have to use the Euler's method. I have my code from last week where we had to simulate a projectile with constant acceleration. Here is my code: [code=python] import numpy as np class Particle: position = np.array([0,0,0]) velocity = np.array([0,0,0]) acceleration = np.array([0,0,0]) def __init__(self, initialPosition, initialVelocity, initialAcceleration, Name, mass): self.position = initialPosition self.velocity = initialVelocity self.acceleration = initialAcceleration self.Name = Name self.mass = mass def update(self, deltaT): self.position = self.position + self.velocity*deltaT self.velocity = self.velocity + self.acceleration*deltaT def __repr__(self): return 'Particle: %10s, Mass: %.5e, Position: %s, Velocity: %s, Acceleration:%s'% (self.Name,self.mass,self.position, self.velocity,self.acceleration) [/code] Pls help! [/QUOTE]
Insert quotes…
Post reply
Forums
Other Sciences
Programming and Computer Science
Simulating Gravitational Interactions in a Particle System
Back
Top