16 #define Spectral_Index -5./3.
18 #define Minimum_Lambda 4
20 #define frand()((double)(rand()+1)/(RAND_MAX+1.0))
26 int i,
j,
k, i2, j2, k2, te0, NXLim, NYLim;
27 double y_end, xdbl, NXLim_2, NYLim_2;
28 double twoPI, x1r, x2r, twopi_a, twopi_b, twopi_c, scrh1, scrh2;
30 double **Amplitude, **Phase;
38 Out = fopen(
"grid0.out",
"w");
39 fprintf(Out,
"# GEOMETRY: CARTESIAN\n");
43 xL = -0.5 + (double)(
x_end*(i2-0.5)/(Points_X - 1.));
44 xR = -0.5 + (double)(
x_end*(i2+0.5)/(Points_X - 1.));
45 fprintf (Out,
"%d %12.6e %12.6e \n",i2+1, xL, xR);
50 xL = -0.5 + (double)(
x_end*(j2-0.5)/(Points_Y - 1.));
51 xR = -0.5 + (double)(
x_end*(j2+0.5)/(Points_Y - 1.));
52 fprintf (Out,
"%d %12.6e %12.6e \n",j2+1, xL, xR);
55 fprintf(Out,
"%d\n",1);
56 fprintf (Out,
"1 0.0 1.0\n");
69 y_end =
x_end*(Points_Y - 1.)/(Points_X - 1.);
71 Amplitude =
array_2D(NXLim + 1, NYLim + 1);
72 Phase =
array_2D(NXLim + 1, NYLim + 1);
73 twoPI = 2.*3.14159265359;
75 for(i = 0; i <= NXLim; i++)
for(j = 0; j <= NYLim; j++){
78 xdbl = sqrt(-2.*log(x1r))*cos(twoPI*x2r);
81 + pow(twoPI*(j - NYLim_2)/y_end,2.);
84 Out = fopen(
"rho0.dbl",
"wb");
87 twopi_b = twoPI/(Points_Y - 1.)*j2;
89 twopi_a = twoPI/(Points_X - 1.)*i2;
91 for(i = NXLim + 1; i--; ){
92 scrh1 = twopi_a*(i - NXLim_2);
93 for(j = NYLim + 1; j--; ){
94 scrh2 = twopi_b*(j - NYLim_2);
95 xdbl += Amplitude[
i][
j]*cos(scrh1 + scrh2 + Phase[i][j]);
99 fwrite (&xdbl,
sizeof(
double), 1, Out);
116 m = (
double **)malloc((
size_t)nx*
sizeof(
double *));
117 m[0] = (
double *)malloc((
size_t)nx*ny*
sizeof(double));
119 for(i = 1; i < nx; i++) m[i] = m[i - 1] + ny;
double ** array_2D(int nx, int ny)