-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstarter.c
52 lines (38 loc) · 1.01 KB
/
starter.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
// This generates a random system just for benchmarking purposes.
// For start conditions with astrophysical plausibility look
// up Plummer's Model or King's Model.
int n = -1;
double t = 0.0;
int main(int argc, char **argv)
{
if (argc != 2) {
fprintf(stderr, "Usage is:\n%s n\n", argv[0]);
exit(-1);
}
n = atoi(argv[1]);
if (n<1 || n>1000) {
fprintf(stderr, "n must be between 1 and 1000 inclusively.\n");
exit(-1);
}
fprintf(stderr, "Generating random system with %d bodies.\n", n);
printf("%d\n", n);
printf("%f\n", t);
double mass = 1.0;
double R = sqrt(n);
int i;
for(i=0; i<n; i++)
{
printf("%g ", mass);
printf("%g ", (R*rand())/RAND_MAX );
printf("%g ", (R*rand())/RAND_MAX );
printf("%g ", (R*rand())/RAND_MAX );
printf("%g ", (0.1*rand())/RAND_MAX );
printf("%g ", (0.1*rand())/RAND_MAX );
printf("%g ", (0.1*rand())/RAND_MAX );
printf("\n");
}
return 0;
}