Why is the Third Mass Moving in the X Direction?

Click For Summary
SUMMARY

The discussion centers on the calculation of the motion of a third mass in a physics simulation involving two stationary masses with equal magnitudes. The user is implementing a numerical solution using C programming, specifically addressing issues with the acceleration calculations in the x-direction. The user has encountered unexpected behavior when the initial velocities are set to zero, resulting in no movement of the third mass. Key insights include the clarification that the terms |r+r_p|^3 and |r-r_p|^3 in the equations are scalar lengths, not vectors, which is crucial for accurate calculations.

PREREQUISITES
  • Understanding of Newtonian physics, specifically gravitational interactions.
  • Proficiency in C programming for numerical simulations.
  • Familiarity with vector calculus and scalar quantities.
  • Knowledge of numerical methods for solving differential equations.
NEXT STEPS
  • Review the principles of gravitational force calculations in physics.
  • Learn about numerical integration techniques, such as the Euler method.
  • Study the implementation of vector operations in C programming.
  • Examine the effects of initial conditions on dynamic systems in simulations.
USEFUL FOR

Students in physics or engineering disciplines, C programmers working on simulations, and anyone interested in computational physics and numerical methods.

Pixter
Messages
29
Reaction score
0

Homework Statement

http://www2.warwick.ac.uk/fac/sci/physics/teach/module_home/px270/projects/c4s_projects07.pdf

it's the first example

Homework Equations


see above

The Attempt at a Solution



right i shouldn't have any probs with the programming but i need to understand the calcs that are put on the site..

as i understand I'm suppose to the first eqn to find a,, then usign the second eqn to find rn+1.. this is done in components so for x and y..

but i tried it for a third mass that is at x=0 and y=positive integer(both the stationary massses are of equal magnitude).. what should happen is that it should be attracted and just go towards negative integers but I get acceleration in x direction.. ((note the printf function are just there for me to see some stuff))..

could someone maybe see where I've gone wrong and maybe give me som pointers:

here is the code:

#include <stdlib.h>
#include <stdio.h>
#include <math.h>main(int argc, char* argv[])
{
float x[101], y[101], mneg, mnegm, mpos, rpnx, rpny, rppx, rppy, ax[101], ay[101], xzero, yzero, vxzero, vyzero, dt;
int n;
FILE *output;

output = fopen("data.dat", "w");

sscanf(argv[1], "%f", &mneg);
sscanf(argv[2], "%f", &mpos);
sscanf(argv[3], "%f", &xzero);
sscanf(argv[4], "%f", &yzero);
sscanf(argv[5], "%f", &vxzero);
sscanf(argv[6], "%f", &vyzero);
dt = 0.005;
x[0] = xzero;
y[0] = yzero;
x[1] = xzero + vxzero*dt;
y[1] =yzero + vyzero*dt;
rpnx= -1;
rpny= 0;
rppx= 1;
rppy= 0;
printf("%f %f\n", x[1], y[1]);

for(n=1; n < 100; ++n)
{
ax[n]=-mneg*((x[n]+rpnx)/(sqrt(pow((x[n]+rpnx),6))))-mpos*((x[n]-rppx)/(sqrt(pow((x[n]-rppx),6))));
ay[n]=-mneg*((y[n]+rpny)/(sqrt(pow((y[n]+rpny),6))))-mpos*((y[n]-rppy)/(sqrt(pow((y[n]-rppy),6))));

x[n+1]=((ax[n])*pow(dt,2))-(x[n-1])+2*(x[n]);
y[n+1]=((ay[n])*pow(dt,2))-(y[n-1])+2*(y[n]);
fprintf(output, "%f %f\n", x[n+1],y[n+1]);

}
printf("%f %f", ax[1], ay[1]);

fclose(output);
}edit: note that the first mass is inputted as a "negative mass" for the equation to work..
also a wird problem if setting inital velocities to zero then the third mass doesn't move at ll which it should
 
Last edited by a moderator:
Physics news on Phys.org
Nothing appears when I open the web page...
 
The attachment worked for me though it was a bit slow to open.

You seem to have misunderstood equation (1) in the attachment. The |r+r_p|^3 and |r-r_p|^3 terms are not vectors. |r+r_p| is the scalar length of the vector r+r_p.
 
Last edited:

Similar threads

  • · Replies 2 ·
Replies
2
Views
5K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
5K
Replies
7
Views
2K
Replies
3
Views
3K