Esempio n. 1
0
void heartbeat(struct reb_simulation* r){
	if(reb_output_check(r, M_PI*2.)){
		reb_output_timing(r, tmax);
	}
	if(reb_output_check(r, M_PI*2.*100.)){ // output every 100 years
		FILE* f = fopen("a.txt","a");
		const struct reb_particle* particles = r->particles;
		const struct reb_particle planet = particles[1];
		const double G = r->G;
		const double t = r->t;
		const int N = r->N;
		for (int i=2;i<N;i++){
			const struct reb_particle p = particles[i]; 
			const double prx  = p.x-planet.x;
			const double pry  = p.y-planet.y;
			const double prz  = p.z-planet.z;
			const double pr   = sqrt(prx*prx + pry*pry + prz*prz); 	// distance relative to star
			
			const double pvx  = p.vx-planet.vx;
			const double pvy  = p.vy-planet.vy;
			const double pvz  = p.vz-planet.vz;
			const double pv   = sqrt(pvx*pvx + pvy*pvy + pvz*pvz); 	// distance relative to star
			
			const double a = -G*planet.m/( pv*pv - 2.*G*planet.m/pr );			// semi major axis
			
			fprintf(f,"%e\t%e\n",t,a);
		}
		fclose(f);
	}
}
Esempio n. 2
0
void heartbeat(struct reb_simulation* r){
	if(reb_output_check(r, 20.*M_PI)){		// outputs to the screen
		reb_output_timing(r, tmax);
	}
	if(reb_output_check(r, 12.)){			// outputs to a file
		reb_output_orbits(r, "orbits.txt");
	}
}
Esempio n. 3
0
void heartbeat(struct reb_simulation* r){
	if(reb_output_check(r,tmax/10000.)){		// outputs to the screen
		reb_output_timing(r, tmax);
	}
	// Output the time and the current timestep. Plot it to see how IAS15 automatically reduces the timestep at pericentre. 
	FILE* of = fopen("timestep.txt","a"); 
	fprintf(of,"%e\t%e\t\n",r->t/tmax,r->dt/tmax);
	fclose(of);
}
Esempio n. 4
0
void heartbeat(struct reb_simulation* const r) {
	if (reb_output_check(r, 1e-3 * 2. * M_PI / r->ri_sei.OMEGA)) {
		reb_output_timing(r, 0);
		//reb_output_append_velocity_dispersion("veldisp.txt");
	}
	if (reb_output_check(r, 2. * M_PI / r->ri_sei.OMEGA)) {
		//reb_output_ascii("position.txt");
	}
}
Esempio n. 5
0
void heartbeat(struct reb_simulation* r){
	if(reb_output_check(r, 20.*M_PI)){
		reb_output_timing(r, tmax);
	}
	if(reb_output_check(r, 40.)){
		reb_integrator_synchronize(r);
		reb_output_orbits(r,"orbits.txt");
		reb_move_to_com(r); 
	}
}
Esempio n. 6
0
void heartbeat(struct reb_simulation* r){
    if (reb_output_check(r, 10000.)){
        reb_output_timing(r, tmax);
        reb_integrator_synchronize(r);
        FILE* f = fopen("energy.txt","a");
        double e = reb_tools_energy(r);
        fprintf(f,"%e %e\n",r->t, fabs((e-e_init)/e_init));
        fclose(f);
    }
}
Esempio n. 7
0
void heartbeat(struct reb_simulation* const r){
	// Output some information to the screen every 100th timestep
	if(reb_output_check(r, 100.*r->dt)){
		reb_output_timing(r, tmax);
	}
	// Output the particle position to a file every timestep.
	const struct reb_particle* const particles = r->particles;
	FILE* f = fopen("r.txt","a");
	fprintf(f,"%e\t%e\t%e\n",r->t,particles[0].x, particles[1].vx);
	fclose(f);
}
Esempio n. 8
0
void heartbeat(struct reb_simulation* const r){
	if (reb_output_check(r, 1000.*r->dt)){
		reb_output_timing(r, tmax);
	}
	if (reb_output_check(r, 362.)){
		// Output the time and the MEGNO to the screen and a file.
		FILE* f = fopen("Y.txt","a+");
		fprintf(f,"        %.20e     %.20e\n",r->t, reb_tools_calculate_megno(r));
		//printf("        %.20e     %.20e\n",r->t, reb_tools_calculate_megno(r));
		fclose(f);
	}
}
Esempio n. 9
0
void heartbeat(struct reb_simulation* r){
    if (reb_output_check(r, 10.*2.*M_PI)){  
        reb_output_timing(r, 0);
    }
    if (reb_output_check(r, 2.*M_PI)){  
        // Once per year, output the relative energy error to a text file
        FILE* f = fopen("energy.txt","a");
        reb_integrator_synchronize(r);
        double e = reb_tools_energy(r);
        fprintf(f,"%e %e\n",r->t, fabs((e-e_init)/e_init));
        fclose(f);
    }
}
Esempio n. 10
0
void heartbeat(struct reb_simulation* r){
	if(reb_output_check(r, 4000.*r->dt)){				// output something to screen	
		reb_output_timing(r, tmax);
	}
	if(reb_output_check(r,M_PI*2.*0.01)){				// output semimajor axis to file
		FILE* f = fopen("a.txt","a");
		const struct reb_particle planet = r->particles[0];
		const int N = r->N;
		for (int i=1;i<N;i++){
			struct reb_orbit o = reb_tools_particle_to_orbit(r->G, r->particles[i],planet);
			fprintf(f,"%.15e\t%.15e\t%.15e\t%.15e\n",r->t,o.a,o.e,o.omega);
		}
		fclose(f);
	}
}
Esempio n. 11
0
void heartbeat(struct reb_simulation* r){
	if (reb_output_check(10.0*dt)) reb_output_timing();
	if (reb_output_check(1.)) reb_output_ascii("ascii.txt");
}
Esempio n. 12
0
void heartbeat(struct reb_simulation* r){
    if (reb_output_check(r, 20.*M_PI)){
        reb_output_timing(r, 0);
        reb_output_orbits(r, "orbit.txt");
    }
}
Esempio n. 13
0
void heartbeat(struct reb_simulation* const r){
	if (reb_output_check(r,10.0*r->dt)){
		reb_output_timing(r,0);
	}
}
Esempio n. 14
0
void heartbeat(struct reb_simulation* r){
	if (reb_output_check(r, 10.*2.*M_PI)){  
		reb_output_timing(r, 0);
	}
}
Esempio n. 15
0
void heartbeat(struct reb_simulation* const r) {
	if (reb_output_check(r, 10000000.)) {
		reb_output_timing(r, tmax);
	}
}