void parse_orbel2D_data(FILE *fi,int Npl,double Mcen){ double mass,a,e,omega,M; add_star(Mcen); int i =0; for(i=0; i<Npl;i++){ if ( fscanf(fi,"%lf %lf %lf %lf %lf",&mass,&a,&e,&omega,&M)!=5){ printf("Error in planet file, line %d\n",i+1); exit(1); } double f = tools_MeanAnom2TrueAnom(M,e); particles_add( tools_init_orbit2d(Mcen,mass,a,e,omega,f) ); } }
void problem_init(int argc, char* argv[]){ /* Setup constants */ boxsize = 3; // in AU integrator = WHFAST; integrator_whfast_corrector = 0; integrator_whfast_synchronize_manually = 0; tmax = atof(argv[2]); // in year/(2*pi) Keplername = argv[1]; //Kepler system being investigated, Must be first string after ./nbody! p_suppress = 0; //If = 1, suppress all print statements double RT = 0.06; //Resonance Threshold - if abs(P2/2*P1 - 1) < RT, then close enough to resonance double timefac = 25.0; //Number of kicks per orbital period (of closest planet) /* Migration constants */ mig_forces = 1; //If ==0, no migration. K = 100; //tau_a/tau_e ratio. I.e. Lee & Peale (2002) e_ini = atof(argv[3]); //atof(argv[3]); //initial eccentricity of the planets afac = atof(argv[4]); //Factor to increase 'a' of OUTER planets by. double iptmig_fac = atof(argv[5]); //reduction factor of inner planet's t_mig (lower value = more eccentricity) double Cin = atof(argv[6]); //migration speed of outer planet inwards. Nominal is 6 /* Tide constants */ tides_on = 1; //If ==0, then no tidal torques on planets. tide_force = 0; //if ==1, implement tides as *forces*, not as e' and a'. double k2fac = atof(argv[7]); //multiply k2 by this factor inner_only = 0; //if =1, allow only the inner planet to evolve under tidal influence //k2fac_check(Keplername,&k2fac); //For special systems, make sure that if k2fac is set too high, it's reduced. #ifdef OPENGL display_wire = 1; #endif // OPENGL init_box(); printf("%f k2fac \n \n \n",k2fac); //Naming naming(Keplername, txt_file, K, iptmig_fac, e_ini, k2fac, tide_force); // Initial vars if(p_suppress == 0) printf("You have chosen: %s \n",Keplername); double Ms,Rs,a,mp,rp,k2,Q,max_t_mig=0, P_temp; int char_val; //Star & Planet 1 readplanets(Keplername,txt_file,&char_val,&_N,&Ms,&Rs,&mp,&rp,&P_temp,p_suppress); if(mig_forces == 0 && p_suppress == 0) printf("--> Migration is *off* \n"); if(tides_on == 0 && p_suppress == 0) printf("--> Tides are *off* \n"); struct particle star; //Star MUST be the first particle added. 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 = Ms; star.r = Rs; particles_add(star); //timestep - units of 2pi*yr (required) dt = 2.*M_PI*P_temp/(365.*timefac); if(p_suppress == 0) printf("The timestep used for this simulation is (2pi*years): %f \n",dt); //Arrays, Extra slot for star, calloc sets values to 0 already. tau_a = calloc(sizeof(double),_N+1); //migration speed of semi-major axis tau_e = calloc(sizeof(double),_N+1); //migration (damp) speed of eccentricity lambda = calloc(sizeof(double),_N+1); //resonant angle for each planet omega = calloc(sizeof(double),_N+1); //argument of periapsis for each planet expmigfac = calloc(sizeof(double),_N+1); t_mig = calloc(sizeof(double),_N+1); t_damp = calloc(sizeof(double),_N+1); phi_i = calloc(sizeof(int),_N+1); //phi index (for outputting resonance angles) if(tide_force == 1){ //tidetau_a = calloc(sizeof(double),_N+1); tidetauinv_e = calloc(sizeof(double),_N+1); } double P[_N+1]; //array of period values, only needed locally P[1] = P_temp; if(inner_only == 1) planets_with_tides = 1; else planets_with_tides = _N+1; //planet 1 calcsemi(&a,Ms,P[1]); //I don't trust archive values. Make it all consistent migration(Keplername,tau_a, t_mig, t_damp, &expmigfac[1], 0, &max_t_mig, P, 1, RT, Ms, mp, iptmig_fac, a, afac, p_suppress, Cin); struct particle p = tools_init_orbit2d(Ms, mp, a*afac, e_ini, 0, 0.); tau_e[1] = tau_a[1]/K; assignk2Q(&k2, &Q, k2fac, rp); p.Q=Q; p.k2=k2; p.r = rp; particles_add(p); //print/writing stuff printf("System Properties: # planets=%d, Rs=%f, Ms=%f \n",_N, Rs, Ms); printwrite(1,txt_file,a,P[1],e_ini,mp,rp,k2/Q,tau_a[1],t_mig[1],t_damp[1],afac,p_suppress); //outer planets (i=0 is star) for(int i=2;i<_N+1;i++){ extractplanets(&char_val,&mp,&rp,&P[i],p_suppress); calcsemi(&a,Ms,P[i]); migration(Keplername,tau_a, t_mig, t_damp, &expmigfac[i], &phi_i[i], &max_t_mig, P, i, RT, Ms, mp, iptmig_fac, a, afac, p_suppress, Cin); struct particle p = tools_init_orbit2d(Ms, mp, a*afac, e_ini, 0, i*M_PI/4.); tau_e[i] = tau_a[i]/K; assignk2Q(&k2, &Q, k2fac, rp); p.Q = Q; p.k2 = k2; p.r = rp; particles_add(p); printwrite(i,txt_file,a,P[i],e_ini,mp,rp,k2/Q,tau_a[i],t_mig[i],t_damp[i],afac,p_suppress); } //tidal delay if(max_t_mig < 20000)tide_delay = 20000.; else tide_delay = max_t_mig + 20000.; //Have at least 30,000 years grace before turning on tides. double tide_delay_output = 0; if(tides_on == 1) tide_delay_output = tide_delay; FILE *write; write=fopen(txt_file, "a"); fprintf(write, "%f \n",tide_delay_output); fclose(write); tide_print = 0; problem_additional_forces = problem_migration_forces; //Set function pointer to add dissipative forces. integrator_force_is_velocitydependent = 1; if (integrator != WH){ // The WH integrator assumes a heliocentric coordinate system. tools_move_to_center_of_momentum(); } }