void problem_init(int argc, char* argv[]){ // Setup constants #ifdef GRAVITY_TREE opening_angle2 = .5; #endif OMEGA = 0.00013143527; // 1/s tmax = 2.*M_PI/OMEGA; G = 6.67428e-11; // N / (1e-5 kg)^2 m^2 softening = 0.1; // m dt = 1e-2*2.*M_PI/OMEGA; // s root_nx = 8; root_ny = 8; root_nz = 1; nghostx = 2; nghosty = 2; nghostz = 0; // Use three ghost rings double surfacedensity = 418; // kg/m^2 double particle_density = 400; // kg/m^3 double particle_radius_min = 1; // m double particle_radius_max = 4; // m double particle_radius_slope = -3; boxsize = 70.7; if (argc>1){ // Try to read boxsize from command line boxsize = atof(argv[1]); } init_box(); // Initial conditions // Use Bridges et al coefficient of restitution. coefficient_of_restitution_for_velocity = coefficient_of_restitution_bridges; minimum_collision_velocity = particle_radius_min*OMEGA*0.001; // small fraction of the shear double total_mass = surfacedensity*boxsize*boxsize; for(int i=0;i<root_n;i++){ #ifdef MPI if (communication_mpi_rootbox_is_local(i)==0) continue; #endif // Ring particles double mass = 0; while(mass<total_mass){ struct particle pt; int ri = i%root_nx; int rj = ((i-ri)/root_nx)%root_ny; int xmin = -boxsize_x/2.+(double)(ri)*boxsize; int ymin = -boxsize_y/2.+(double)(rj)*boxsize; pt.x = tools_uniform(xmin,xmin+boxsize); pt.y = tools_uniform(ymin,ymin+boxsize); pt.z = tools_normal(1.); // m pt.vx = 0; pt.vy = -1.5*pt.x*OMEGA; pt.vz = 0; pt.ax = 0; pt.ay = 0; pt.az = 0; double radius = tools_powerlaw(particle_radius_min,particle_radius_max,particle_radius_slope); #ifndef COLLISIONS_NONE pt.r = radius; // m #endif // COLLISIONS_NONE double particle_mass = particle_density*4./3.*M_PI*radius*radius*radius; pt.m = particle_mass; // kg particles_add(pt); mass += particle_mass; } } }
void problem_init(int argc, char* argv[]){ // Setup constants #ifdef GRAVITY_TREE opening_angle2 = .5; #endif // GRAVITY_TREE OMEGA = 0.00013143527; // 1/s G = 6.67428e-11; // N / (1e-5 kg)^2 m^2 softening = 0.1; // m dt = 1e-3*2.*M_PI/OMEGA; // s #ifdef OPENGL display_rotate_z = 20; // Rotate the box by 20 around the z axis, then display_rotate_x = 60; // rotate the box by 60 degrees around the x axis #ifdef LIBPNG system("mkdir png"); #endif // LIBPNG #endif // OPENGL root_nx = 2; root_ny = 2; root_nz = 1; nghostx = 2; nghosty = 2; nghostz = 0; // Use two ghost rings double surfacedensity = 400; // kg/m^2 double particle_density = 400; // kg/m^3 double particle_radius_min = 1; // m double particle_radius_max = 4; // m double particle_radius_slope = -3; boxsize = 100; // m if (argc>1){ // Try to read boxsize from command line boxsize = atof(argv[1]); } init_box(); // Initial conditions printf("Toomre wavelength: %f\n",2.*M_PI*M_PI*surfacedensity/OMEGA/OMEGA*G); // Use Bridges et al coefficient of restitution. coefficient_of_restitution_for_velocity = coefficient_of_restitution_bridges; minimum_collision_velocity = particle_radius_min*OMEGA*0.001; // small fraction of the shear double total_mass = surfacedensity*boxsize_x*boxsize_y; double mass = 0; while(mass<total_mass){ struct particle pt; pt.x = tools_uniform(-boxsize_x/2.,boxsize_x/2.); pt.y = tools_uniform(-boxsize_y/2.,boxsize_y/2.); pt.z = tools_normal(1.); // m pt.vx = 0; pt.vy = -1.5*pt.x*OMEGA; pt.vz = 0; pt.ax = 0; pt.ay = 0; pt.az = 0; double radius = tools_powerlaw(particle_radius_min,particle_radius_max,particle_radius_slope); #ifndef COLLISIONS_NONE pt.r = radius; // m #endif double particle_mass = particle_density*4./3.*M_PI*radius*radius*radius; pt.m = particle_mass; // kg particles_add(pt); mass += particle_mass; } }
void problem_init(int argc, char* argv[]){ // Setup constants #ifdef GRAVITY_TREE opening_angle2 = .5; #endif OMEGA = 0.00013143527; // 1/s G = 6.67428e-11; // N / (1e-5 kg)^2 m^2 softening = 0.1; // m dt = 1e-3*2.*M_PI/OMEGA; // s root_nx = 2; root_ny = 2; root_nz = 1; nghostx = 2; nghosty = 2; nghostz = 0; // Use two ghost rings double surfacedensity = 400; // kg/m^2 double particle_density = 400; // kg/m^3 double particle_radius_min = 1; // m double particle_radius_max = 4; // m double particle_radius_slope = -3; boxsize = 100; if (argc>1){ // Try to read boxsize from command line boxsize = atof(argv[1]); } init_box(); // Initial conditions printf("Toomre wavelength: %f\n",2.*M_PI*M_PI*surfacedensity/OMEGA/OMEGA*G); // Use Bridges et al coefficient of restitution. coefficient_of_restitution_for_velocity = coefficient_of_restitution_bridges; minimum_collision_velocity = particle_radius_min*OMEGA*0.001; // small fraction of the shear double total_mass = surfacedensity*boxsize_x*boxsize_y; #ifdef MPI // Only initialise particles on master. This should also be parallelied but the details depend on the individual problem. if (mpi_id==0){ #endif double mass = 0; while(mass<total_mass){ struct particle pt; pt.x = tools_uniform(-boxsize_x/2.,boxsize_x/2.); pt.y = tools_uniform(-boxsize_y/2.,boxsize_y/2.); pt.z = tools_normal(1.); // m pt.vx = 0; pt.vy = -1.5*pt.x*OMEGA; pt.vz = 0; pt.ax = 0; pt.ay = 0; pt.az = 0; double radius = tools_powerlaw(particle_radius_min,particle_radius_max,particle_radius_slope); #ifndef COLLISIONS_NONE pt.r = radius; // m #endif double particle_mass = particle_density*4./3.*M_PI*radius*radius*radius; pt.m = particle_mass; // kg particles_add(pt); mass += particle_mass; } #ifdef MPI } #endif }
void problem_init(int argc, char* argv[]){ // Setup constants OMEGA = 0.00013143527; // 1/s G = 6.67428e-11; // N / (1e-5 kg)^2 m^2 dt = 1e-3*2.*M_PI/OMEGA; // s root_nx = 10; root_ny = 1; root_nz = 1; nghostx = 1; nghosty = 1; nghostz = 0; // Use two one ring (+cutoff, see below) double surfacedensity = 400; // kg/m^2 double particle_density = 400; // kg/m^3 double particle_radius_min = 1; // m double particle_radius_max = 4; // m double particle_radius_slope = -3; boxsize = 100; if (argc>1){ // Try to read boxsize from command line boxsize = atof(argv[1]); } init_box(); #ifdef GRAVITY_GRAPE gravity_range = boxsize/2.; #endif // GRAVITY_GRAPE // Initial conditions printf("Toomre wavelength: %f\n",2.*M_PI*M_PI*surfacedensity/OMEGA/OMEGA*G); #ifndef COLLISIONS_NONE // Use Bridges et al coefficient of restitution. coefficient_of_restitution_for_velocity = coefficient_of_restitution_bridges; minimum_collision_velocity = particle_radius_min*OMEGA*0.001; // small fraction of the shear softening = 0.1; // m #else // COLLISIONS_NONE softening = particle_radius_max; #endif // COLLISIONS_NONE double total_mass = surfacedensity*boxsize_x*boxsize_y; double mass = 0; while(mass<total_mass){ struct particle pt; pt.x = tools_uniform(-boxsize_x/2.,boxsize_x/2.); pt.y = tools_uniform(-boxsize_y/2.,boxsize_y/2.); pt.z = tools_normal(1.); // m pt.vx = 0; pt.vy = -1.5*pt.x*OMEGA; pt.vz = 0; pt.ax = 0; pt.ay = 0; pt.az = 0; double radius = tools_powerlaw(particle_radius_min,particle_radius_max,particle_radius_slope); #ifndef COLLISIONS_NONE pt.r = radius; // m #endif double particle_mass = particle_density*4./3.*M_PI*radius*radius*radius; pt.m = particle_mass; // kg particles_add(pt); mass += particle_mass; } }
void problem_init(int argc, char* argv[]){ // Setup constants #ifdef GRAVITY_TREE opening_angle2 = .5; #endif // GRAVITY_TREE integrator = SEI; OMEGA = 0.00013143527; // 1/s G = 6.67428e-11; // N / (1e-5 kg)^2 m^2 softening = 0.1; // m dt = 1e-3*2.*M_PI/OMEGA; // s root_nx = 2; root_ny = 2; root_nz = 1; nghostx = 2; nghosty = 2; nghostz = 0; // Use two ghost rings double surfacedensity = 840; // kg/m^2 double particle_density = 900; // kg/m^3 double particle_radius_min = 1.; // m double particle_radius_max = 1.; // m double particle_radius_slope = -3; boxsize = 40; // m if (argc>1){ // Try to read boxsize from command line boxsize = atof(argv[1]); } init_box(); // Initial conditions printf("Toomre wavelength: %f\n",4.*M_PI*M_PI*surfacedensity/OMEGA/OMEGA*G); // Use Bridges et al coefficient of restitution. coefficient_of_restitution_for_velocity = coefficient_of_restitution_bridges; // Change collision_resolve routing from default. collision_resolve = collision_resolve_hardsphere_pullaway; // Small residual velocity to avoid particles from sinking into each other. minimum_collision_velocity = particle_radius_min*OMEGA*0.001; // small fraction of the shear double total_mass = surfacedensity*boxsize_x*boxsize_y; double mass = 0; while(mass<total_mass){ struct particle pt; pt.x = tools_uniform(-boxsize_x/2.,boxsize_x/2.); pt.y = tools_uniform(-boxsize_y/2.,boxsize_y/2.); pt.z = tools_normal(1.); // m pt.vx = 0; pt.vy = -1.5*pt.x*OMEGA; pt.vz = 0; pt.ax = 0; pt.ay = 0; pt.az = 0; double radius = tools_powerlaw(particle_radius_min,particle_radius_max,particle_radius_slope); #ifndef COLLISIONS_NONE pt.r = radius; // m #endif double particle_mass = particle_density*4./3.*M_PI*radius*radius*radius; pt.m = particle_mass; // kg particles_add(pt); mass += particle_mass; } }
void problem_init(int argc, char* argv[]){ // Setup constants opening_angle2 = 1.5; // This constant determines the accuracy of the tree code gravity estimate. G = 1; softening = 0.01; // Gravitational softening length dt = 3e-3; // Timestep boxsize = 1.2; // Particles outside the box are removed root_nx = 1; root_ny = 1; root_nz = 1; nghostx = 0; nghosty = 0; nghostz = 0; init_box(); // Setup particles double disc_mass = 2e-1; // Total disc mass int _N = 10000; // Number of particles // Initial conditions struct particle star; star.x = 0; star.y = 0; star.z = 0; star.vx = 0; star.vy = 0; star.vz = 0; star.ax = 0; star.ay = 0; star.az = 0; star.m = 1; #ifdef INTEGRATOR_WH // Insert particle manually. Don't add it to tree. Nmax += 128; particles = realloc(particles,sizeof(struct particle)*Nmax); particles[N] = star; N++; #else // INTEGRATOR_WH particles_add(star); #endif // INTEGRATOR_WH while(N<_N){ struct particle pt; double a = tools_powerlaw(boxsize/10.,boxsize/2./1.2,-1.5); double phi = tools_uniform(0,2.*M_PI); pt.x = a*cos(phi); pt.y = a*sin(phi); pt.z = a*tools_normal(0.001); double mu = star.m + disc_mass * (pow(a,-3./2.)-pow(boxsize/10.,-3./2.))/(pow(boxsize/2./1.2,-3./2.)-pow(boxsize/10.,-3./2.)); double vkep = sqrt(G*mu/a); pt.vx = vkep * sin(phi); pt.vy = -vkep * cos(phi); pt.vz = 0; pt.ax = 0; pt.ay = 0; pt.az = 0; pt.m = disc_mass/(double)_N; particles_add(pt); } }
void problem_init(int argc, char* argv[]){ // Setup constants G = 1; integrator = LEAPFROG; softening = 0.01; dt = 3e-3; boxsize = 1.2; root_nx = 1; root_ny = 1; root_nz = 1; nghostx = 0; nghosty = 0; nghostz = 0; init_box(); // Setup particles double disc_mass = 2e-1; int _N = 10000; // Initial conditions struct particle star; star.x = 0; star.y = 0; star.z = 0; star.vx = 0; star.vy = 0; star.vz = 0; star.ax = 0; star.ay = 0; star.az = 0; star.m = 1; #ifdef INTEGRATOR_WH // Insert particle manually. Don't add it to tree. Nmax += 128; particles = realloc(particles,sizeof(struct particle)*Nmax); particles[N] = star; N++; #else // INTEGRATOR_WH particles_add(star); #endif // INTEGRATOR_WH while(N<_N){ struct particle pt; double a = tools_powerlaw(boxsize/10.,boxsize/2./1.2,-1.5); double phi = tools_uniform(0,2.*M_PI); pt.x = a*cos(phi); pt.y = a*sin(phi); pt.z = a*tools_normal(0.001); double mu = star.m + disc_mass * (pow(a,-3./2.)-pow(boxsize/10.,-3./2.))/(pow(boxsize/2./1.2,-3./2.)-pow(boxsize/10.,-3./2.)); double vkep = sqrt(G*mu/a); pt.vx = vkep * sin(phi); pt.vy = -vkep * cos(phi); pt.vz = 0; pt.ax = 0; pt.ay = 0; pt.az = 0; pt.m = disc_mass/(double)_N; particles_add(pt); } }
void problem_init(int argc, char* argv[]){ // Setup constants integrator = WH; G = 1; N_active = 1; N_collisions = 1; // Don't detect collisions for the star. softening = 0.01; dt = 1e-3; boxsize = 2.4; root_nx = 1; root_ny = 1; root_nz = 1; nghostx = 0; nghosty = 0; nghostz = 0; init_box(); // Setup particles int _N = 1000; // Initial conditions struct particle star; star.x = 0; star.y = 0; star.z = 0; star.vx = 0; star.vy = 0; star.vz = 0; star.ax = 0; star.ay = 0; star.az = 0; star.m = 1; star.r = 0.01; particles_add(star); while(N<_N){ struct particle pt; double a = tools_powerlaw(boxsize/2.9,boxsize/3.1,.5); double phi = tools_uniform(0,2.*M_PI); pt.x = a*cos(phi); pt.y = a*sin(phi); pt.z = a*tools_normal(0.0001); double vkep = sqrt(G*star.m/a); pt.vx = vkep * sin(phi); pt.vy = -vkep * cos(phi); pt.vz = 0; pt.ax = 0; pt.ay = 0; pt.az = 0; pt.m = 0.0001; pt.r = .3/sqrt((double)_N); particles_add(pt); } }
void problem_init(int argc, char* argv[]){ // Setup constants G = 1; softening = 0.01; dt = 3e-3; boxsize = 2.4; integrator = LEAPFROG; root_nx = 1; root_ny = 1; root_nz = 1; nghostx = 0; nghosty = 0; nghostz = 0; init_box(); // Initial conditions struct particle star; star.x = 0; star.y = 0; star.z = 0; star.vx = 0; star.vy = 0; star.vz = 0; star.ax = 0; star.ay = 0; star.az = 0; star.m = 1; particles_add(star); // Setup disk particles double disc_mass = 2e-1; int _N = 1024*4; while(N<_N){ struct particle pt; double a = tools_powerlaw(boxsize/20.,boxsize/4./1.2,-1.5); double phi = tools_uniform(0,2.*M_PI); pt.x = a*cos(phi); pt.y = a*sin(phi); pt.z = a*tools_normal(0.001); double mu = star.m + disc_mass * (pow(a,-3./2.)-pow(boxsize/20.,-3./2.))/(pow(boxsize/4./1.2,-3./2.)-pow(boxsize/20.,-3./2.)); double vkep = sqrt(G*mu/a); pt.vx = vkep * sin(phi); pt.vy = -vkep * cos(phi); pt.vz = 0; pt.ax = 0; pt.ay = 0; pt.az = 0; pt.m = disc_mass/(double)_N; particles_add(pt); } }