void problem_init(int argc, char* argv[]){ // Setup constants dt = 40; // in days N_active = 5; // we treat pluto as a test particle. If all your particles have mass, remove this line. tmax = 7.3e10; // 200 Myr G = k*k; // These are the same units as used by the mercury6 code. #ifdef OPENGL display_wire = 1; // Show orbits. #endif // OPENGL init_boxwidth(200); // Init box with width 200 astronomical units // Initial conditions for (int i=0;i<6;i++){ struct particle p; p.x = ss_pos[i][0]; p.y = ss_pos[i][1]; p.z = ss_pos[i][2]; p.vx = ss_vel[i][0]; p.vy = ss_vel[i][1]; p.vz = ss_vel[i][2]; p.ax = 0; p.ay = 0; p.az = 0; p.m = ss_mass[i]; particles_add(p); } #ifdef INTEGRATOR_WH // Move to heliocentric frame (required by WH integrator) for (int i=1;i<N;i++){ particles[i].x -= particles[0].x; particles[i].y -= particles[0].y; particles[i].z -= particles[0].z; particles[i].vx -= particles[0].vx; particles[i].vy -= particles[0].vy; particles[i].vz -= particles[0].vz; } particles[0].x = 0; particles[0].y = 0; particles[0].z = 0; particles[0].vx= 0; particles[0].vy= 0; particles[0].vz= 0; #endif // INTEGRATOR_WH system("rm -f orbits.txt"); }
void problem_init(int argc, char* argv[]){ dt = 0.01*2.*M_PI; // initial timestep // integrator_epsilon = 1e-2; // accuracy parameter, default is 1e-2 and should work in most cases. #ifdef OPENGL display_wire = 1; // show instantaneous orbits #endif // OPENGL init_boxwidth(10); struct particle star; star.m = 1; star.x = 0; star.y = 0; star.z = 0; star.vx = 0; star.vy = 0; star.vz = 0; particles_add(star); // Add planets int N_planets = 7; for (int i=0;i<N_planets;i++){ double a = 1.+(double)i/(double)(N_planets-1); // semi major axis double v = sqrt(1./a); // velocity (circular orbit) struct particle planet; planet.m = 1e-4; planet.x = a; planet.y = 0; planet.z = 0; planet.vx = 0; planet.vy = v; planet.vz = 0; particles_add(planet); } tools_move_to_center_of_momentum(); // This makes sure the planetary systems stays within the computational domain and doesn't drift. }
void problem_init(int argc, char* argv[]){ dt = 0.01*2.*M_PI; // initial timestep #ifdef OPENGL display_wire = 1; // show instantaneous orbits #endif // OPENGL collision_resolve = collision_resolve_merger; // Setup our own collision routine. init_boxwidth(10); struct particle star; star.m = 1; star.r = 0.1; star.x = 0; star.y = 0; star.z = 0; star.vx = 0; star.vy = 0; star.vz = 0; particles_add(star); // Add planets int N_planets = 7; for (int i=0;i<N_planets;i++){ double a = 1.+(double)i/(double)(N_planets-1); // semi major axis in AU double v = sqrt(1./a); // velocity (circular orbit) struct particle planet; planet.m = 1e-4; planet.r = 4e-2; // radius in AU (it is unphysically large in this example) planet.lastcollision = 0; // The first time particles can collide with each other planet.x = a; planet.y = 0; planet.z = 0; planet.vx = 0; planet.vy = v; planet.vz = 0; particles_add(planet); } tools_move_to_center_of_momentum(); // This makes sure the planetary systems stays within the computational domain and doesn't drift. }
void problem_init(int argc, char* argv[]){ dt = 0.012*2.*M_PI; // initial timestep integrator = HYBRID; //softening = 0.001; //integrator = IAS15; //integrator = WHFAST; integrator_whfast_corrector = 5; integrator_whfast_synchronize_manually = 1; #ifdef OPENGL display_wire = 1; // show instantaneous orbits #endif // OPENGL init_boxwidth(20); struct particle star; star.m = 1; star.x = 0; star.y = 0; star.z = 0; star.vx = 0; star.vy = 0; star.vz = 0; particles_add(star); // Add planets int N_planets = 3; for (int i=0;i<N_planets;i++){ double a = 1.+.1*(double)i; // semi major axis double v = sqrt(1./a); // velocity (circular orbit) struct particle planet; planet.m = 2e-5; planet.x = a; planet.y = 0; planet.z = 0; planet.vx = 0; planet.vy = v; planet.vz = 0; particles_add(planet); } tools_move_to_center_of_momentum(); // This makes sure the planetary systems stays within the computational domain and doesn't drift. e_init = tools_energy(); system("rm -rf energy.txt"); }
void problem_init(int argc, char* argv[]) { // Setup constants integrator = WHFAST; dt = 0.001*2.*M_PI; // initial timestep (in days) init_boxwidth(200); // Initial conditions { struct particle p = {.m=1.,.x=0,.y=0.,.z=0.,.vx=0,.vy=0.,.vz=0.}; particles_add(p); } { double e = 0.999; struct particle p = {.m=0.,.x=0.01,.y=0.,.z=0.,.vx=0,.vy=0.*sqrt((1.+e)/(1.-e)),.vz=0.}; particles_add(p); } tools_move_to_center_of_momentum(); //problem_additional_forces = additional_forces; // Add megno particles //tools_megno_init(1e-16); // N = 6 after this function call. system("rm -f *.txt"); ei = energy(); } void additional_forces() { particles[1].ax += 0.12/6.; } double energy() { double e_kin = 0.; double e_pot = 0.; struct particle pi = particles[1]; e_kin += 0.5 * (pi.vx*pi.vx + pi.vy*pi.vy + pi.vz*pi.vz); struct particle pj = particles[0]; double dx = pi.x - pj.x; double dy = pi.y - pj.y; double dz = pi.z - pj.z; e_pot -= G*pj.m/sqrt(dx*dx + dy*dy + dz*dz); return e_kin +e_pot; } int no =0; void problem_output() { no++; // printf("%d\n", no); if (output_check(1000.*dt)) { output_timing(); } // FILE* f = fopen("Y.txt","a+"); // fprintf(f,"%e %e %e\n",t,(energy()-ei)/ei,tools_megno()); // fclose(f); }
void problem_init(int argc, char* argv[]){ dt = 0; display_pause_sim = 1; boxsize = 100; FILE* f; if (argc<=1){ f = stdin; printf("\n\nReading from stdin.\n"); }else{ f = fopen(argv[1],"r"); printf("\n\nReading from file.\n"); } if (f==NULL){ printf("\n\nERROR. Cannot open file.\n"); exit(-1); } // Read in data. double x, y, z, r; if (fscanf(f,"%lf %lf %lf %lf", &x, &y, &z, &r)==EOF){ printf("\n\nERROR. Empty file.\n"); exit(-1); } double max_x = x, min_x = x; double max_y = y, min_y = y; double max_z = z, min_z = z; init_boxwidth(1); while(fscanf(f, "%lf %lf %lf %lf", &x, &y, &z, &r)!=EOF){ struct particle p = {.x=x, .y=y, .z=z, .r=r}; particles_add_local(p); if (x>max_x) max_x = x; if (y>max_y) max_y = y; if (z>max_z) max_z = z; if (x<min_x) min_x = x; if (y<min_y) min_y = y; if (z<min_z) min_z = z; } printf("\nFound %d particles in file.\n",N); fclose(f); // Resize box. boxsize = max_x - min_x; if (max_y - min_y > boxsize) boxsize = max_y - min_y; if (max_z - min_z > boxsize) boxsize = max_z - min_z; boxsize*=1.01; boxsize_max = boxsize_x = boxsize_y = boxsize_z = boxsize; // Move particles to center. for (int i=0;i<N;i++){ particles[i].x -= (max_x+min_x)/2.; particles[i].y -= (max_y+min_y)/2.; particles[i].z -= (max_z+min_z)/2.; } }
void problem_init(int argc, char* argv[]){ // Setup constants dt = 10; // initial timestep (in days) //integrator = IAS15; integrator = WHFAST; const double k = 0.01720209895; // Gaussian constant G = k*k; // These are the same units that mercury6 uses init_boxwidth(200); // Initial conditions for (int i=0;i<3;i++){ struct particle p; p.x = ss_pos[i][0]; p.y = ss_pos[i][1]; p.z = ss_pos[i][2]; p.vx = ss_vel[i][0]; p.vy = ss_vel[i][1]; p.vz = ss_vel[i][2]; p.ax = 0; p.ay = 0; p.az = 0; p.m = ss_mass[i]; particles_add(p); } tools_move_to_center_of_momentum(); // Add megno particles tools_megno_init(1e-16); // N = 6 after this function call. // The first half of particles are real particles, the second half are particles following the variational equations. }
void problem_init(int argc, char* argv[]){ // Setup constants dt = 4; // in days tmax = 7.3e10; // 200 Myr G = 1.4880826e-34; // in AU^3 / kg / day^2. init_boxwidth(200); // Init box with width 200 astronomical units integrator_whfast_synchronize_manually = 1; // Need to call integrator_synchronize() before outputs. integrator_force_is_velocitydependent = 0; // Force only depends on positions. //integrator = WH; integrator = WHFAST; //integrator = IAS15; // Initial conditions for (int i=0;i<10;i++){ struct particle p; p.x = ss_pos[i][0]; p.y = ss_pos[i][1]; p.z = ss_pos[i][2]; p.vx = ss_vel[i][0]; p.vy = ss_vel[i][1]; p.vz = ss_vel[i][2]; p.ax = 0; p.ay = 0; p.az = 0; p.m = ss_mass[i]; particles_add(p); } if (integrator==WH){ // Move to heliocentric frame (required by WH integrator) for (int i=1;i<N;i++){ particles[i].x -= particles[0].x; particles[i].y -= particles[0].y; particles[i].z -= particles[0].z; particles[i].vx -= particles[0].vx; particles[i].vy -= particles[0].vy; particles[i].vz -= particles[0].vz; } particles[0].x = 0; particles[0].y = 0; particles[0].z = 0; particles[0].vx= 0; particles[0].vy= 0; particles[0].vz= 0; }else{ tools_move_to_center_of_momentum(); } //tools_megno_init(1e-16); e_init = energy(); system("rm -f energy.txt"); system("rm -f pos.txt"); }