42 using namespace swarm;
52 const double mass_star = 1;
53 const double mass_planet = 0.0001;
55 const double xpos[4] = { -2.0, +2.0, -4.0, +4.0 };
64 double norm(
double x,
double y){
70 int main(
int argc,
char* argv[]){
74 cout <<
"Usage: parabolic_collision <outputfilename>" << endl;
76 const string outputfn = argv[1];
87 for(
int i = 0; i < nsys ; i++){
88 ensemble::SystemRef s = ens[i];
97 s[0].mass() = mass_star;
98 s[0].x() = 0, s[0].y() = 0, s[0].z() = 0 ;
99 s[0].vx() = 0, s[0].vy() = 0, s[0].vz() = 0 ;
103 for(
int b = 1; b < nbod; b++){
106 double x =
xpos[b-1], y = x*x/4/
R -
R ;
108 double speed = sqrt(2*
mu/norm(x,y)) ;
112 double velocity_direction_x = (x/abs(x))/ norm(1,x/2/R);
113 double velocity_direction_y = (x/2/
R )/ norm(1,x/2/R);
117 s[b].mass() = mass_planet;
118 s[b].x() =
x , s[b].vx() = -speed*velocity_direction_x ;
119 s[b].y() = y , s[b].vy() = -speed*velocity_direction_y ;
120 s[b].z() = 0 , s[b].vz() = 0 ;