Skip to content

Commit

Permalink
Minor changes to examples
Browse files Browse the repository at this point in the history
  • Loading branch information
hannorein committed Nov 5, 2017
1 parent 0ded313 commit 9ec657b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 179 deletions.
8 changes: 5 additions & 3 deletions examples/simplest/problem.c
Expand Up @@ -10,6 +10,8 @@
#include <stdlib.h>

void heartbeat(struct reb_simulation* r){
// This function gets called after every timestep.
// Here, we simply print out the current simulation time.
printf("%f\n",r->t);
}

Expand All @@ -19,14 +21,14 @@ int main(int argc, char* argv[]) {
r->heartbeat = heartbeat;
r->exact_finish_time = 1; // Finish exactly at tmax in reb_integrate(). Default is already 1.

struct reb_particle p1 = {0};
struct reb_particle p1 = {0}; // always initizialize a struct with this syntax to ensure all variables are set to 0.
p1.m = 1.;
reb_add(r, p1);
reb_add(r, p1); // reb_add makes a copy of the particle and adds it to the simulation.

struct reb_particle p2 = {0};
p2.x = 1;
p2.vy = 1;
reb_add(r, p2);
reb_add(r, p2); // notice that we didn't set a mass. All parameters default to 0.

reb_integrate(r,100.);
}
Expand Down

0 comments on commit 9ec657b

Please sign in to comment.