示例#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);
	}
}
示例#2
0
文件: problem.c 项目: SeanBE/rebound
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");
	}
}
示例#3
0
文件: problem.c 项目: SeanBE/rebound
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");
	}
}
示例#4
0
文件: problem.c 项目: SeanBE/rebound
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); 
	}
}
示例#5
0
文件: problem.c 项目: SeanBE/rebound
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);
	}
}
示例#6
0
文件: problem.c 项目: afcarl/rebound
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);
    }
}
示例#7
0
文件: problem.c 项目: SeanBE/rebound
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);
	}
}
示例#8
0
文件: problem.c 项目: SeanBE/rebound
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);
}
示例#9
0
文件: problem.c 项目: afcarl/rebound
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);
    }
}
示例#10
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);
}
示例#11
0
void heartbeat(struct reb_simulation* sim){
    if(reb_output_check(sim, 1.e8)){
        const struct reb_particle* particles = sim->particles;
        const struct reb_particle saturn = particles[1];
        const double t = sim->t;
        struct reb_orbit orbit = reb_tools_particle_to_orbit(sim->G, sim->particles[2], saturn); /* calculate orbit of particles[2] around Saturn */
        double e2 = orbit.e;
        orbit = reb_tools_particle_to_orbit(sim->G, sim->particles[3], saturn); 
        double e3 = orbit.e;
        printf("%e\t%f\t%f\n", t, e2, e3);

    }
}
示例#12
0
文件: problem.c 项目: SeanBE/rebound
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");
}
示例#13
0
文件: problem.c 项目: afcarl/rebound
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");
    }
}
示例#14
0
文件: problem.c 项目: SeanBE/rebound
void heartbeat(struct reb_simulation* const r){
	if (reb_output_check(r,10.0*r->dt)){
		reb_output_timing(r,0);
	}
}
示例#15
0
void heartbeat(struct reb_simulation* r){
	if (reb_output_check(r, 10.*2.*M_PI)){  
		reb_output_timing(r, 0);
	}
}
示例#16
0
void heartbeat(struct reb_simulation* const r) {
	if (reb_output_check(r, 10000000.)) {
		reb_output_timing(r, tmax);
	}
}