Add files via upload
This commit is contained in:
112
wave_billiard.c
112
wave_billiard.c
@@ -44,14 +44,14 @@
|
||||
#include <time.h>
|
||||
|
||||
#define MOVIE 0 /* set to 1 to generate movie */
|
||||
#define DOUBLE_MOVIE 0 /* set to 1 to produce movies for wave height and energy simultaneously */
|
||||
#define DOUBLE_MOVIE 1 /* set to 1 to produce movies for wave height and energy simultaneously */
|
||||
|
||||
/* General geometrical parameters */
|
||||
|
||||
#define WINWIDTH 1920 /* window width */
|
||||
#define WINHEIGHT 1000 /* window height */
|
||||
// #define NX 1920 /* number of grid points on x axis */
|
||||
// #define NY 1000 /* number of grid points on y axis */
|
||||
// #define NY 1000 /* number of grid points on x axis */
|
||||
#define NX 3840 /* number of grid points on x axis */
|
||||
#define NY 2000 /* number of grid points on y axis */
|
||||
|
||||
@@ -65,6 +65,8 @@
|
||||
// #define WINWIDTH 1280 /* window width */
|
||||
// #define WINHEIGHT 720 /* window height */
|
||||
//
|
||||
// // #define NX 640 /* number of grid points on x axis */
|
||||
// // #define NY 360 /* number of grid points on y axis */
|
||||
// // #define NX 1280 /* number of grid points on x axis */
|
||||
// // #define NY 720 /* number of grid points on y axis */
|
||||
// #define NX 2560 /* number of grid points on x axis */
|
||||
@@ -79,11 +81,11 @@
|
||||
|
||||
/* Choice of the billiard table */
|
||||
|
||||
#define B_DOMAIN 20 /* choice of domain shape, see list in global_pdes.c */
|
||||
#define B_DOMAIN 53 /* choice of domain shape, see list in global_pdes.c */
|
||||
|
||||
#define CIRCLE_PATTERN 1 /* pattern of circles or polygons, see list in global_pdes.c */
|
||||
|
||||
#define COMPARISON 0 /* set to 1 to compare two different patterns */
|
||||
#define COMPARISON 0 /* set to 1 to compare two different patterns (beta) */
|
||||
#define B_DOMAIN_B 20 /* second domain shape, for comparisons */
|
||||
#define CIRCLE_PATTERN_B 0 /* second pattern of circles or polygons */
|
||||
|
||||
@@ -91,10 +93,10 @@
|
||||
#define NPOISSON 300 /* number of points for Poisson C_RAND_POISSON arrangement */
|
||||
#define RANDOM_POLY_ANGLE 1 /* set to 1 to randomize angle of polygons */
|
||||
|
||||
#define LAMBDA 0.7 /* parameter controlling the dimensions of domain */
|
||||
#define MU 0.028 /* parameter controlling the dimensions of domain */
|
||||
#define NPOLY 3 /* number of sides of polygon */
|
||||
#define APOLY 0.3333333333333333 /* angle by which to turn polygon, in units of Pi/2 */
|
||||
#define LAMBDA 1.0 /* parameter controlling the dimensions of domain */
|
||||
#define MU 0.3 /* parameter controlling the dimensions of domain */
|
||||
#define NPOLY 6 /* number of sides of polygon */
|
||||
#define APOLY 0.0 /* angle by which to turn polygon, in units of Pi/2 */
|
||||
#define MDEPTH 6 /* depth of computation of Menger gasket */
|
||||
#define MRATIO 3 /* ratio defining Menger gasket */
|
||||
#define MANDELLEVEL 1000 /* iteration level for Mandelbrot set */
|
||||
@@ -120,18 +122,18 @@
|
||||
/* Physical parameters of wave equation */
|
||||
|
||||
#define TWOSPEEDS 1 /* set to 1 to replace hardcore boundary by medium with different speed */
|
||||
#define OSCILLATE_LEFT 1 /* set to 1 to add oscilating boundary condition on the left */
|
||||
#define OSCILLATE_LEFT 0 /* set to 1 to add oscilating boundary condition on the left */
|
||||
#define OSCILLATE_TOPBOT 0 /* set to 1 to enforce a planar wave on top and bottom boundary */
|
||||
#define OSCILLATION_SCHEDULE 3 /* oscillation schedule, see list in global_pdes.c */
|
||||
#define OSCILLATION_SCHEDULE 1 /* oscillation schedule, see list in global_pdes.c */
|
||||
|
||||
#define OMEGA 0.0005 /* frequency of periodic excitation */
|
||||
#define AMPLITUDE 0.8 /* amplitude of periodic excitation */
|
||||
#define ACHIRP 0.25 /* acceleration coefficient in chirp */
|
||||
#define DAMPING 0.0 /* damping of periodic excitation */
|
||||
#define COURANT 0.05 /* Courant number */
|
||||
#define COURANTB 0.0125 /* Courant number in medium B */
|
||||
#define COURANT 0.1 /* Courant number */
|
||||
#define COURANTB 0.05 /* Courant number in medium B */
|
||||
#define GAMMA 0.0 /* damping factor in wave equation */
|
||||
#define GAMMAB 0.0 /* damping factor in wave equation */
|
||||
#define GAMMAB 5.0e-3 /* damping factor in wave equation */
|
||||
#define GAMMA_SIDES 1.0e-4 /* damping factor on boundary */
|
||||
#define GAMMA_TOPBOT 1.0e-7 /* damping factor on boundary */
|
||||
#define KAPPA 0.0 /* "elasticity" term enforcing oscillations */
|
||||
@@ -142,24 +144,26 @@
|
||||
/* Increasing COURANT speeds up the simulation, but decreases accuracy */
|
||||
/* For similar wave forms, COURANT^2*GAMMA should be kept constant */
|
||||
|
||||
#define ADD_OSCILLATING_SOURCE 0 /* set to 1 to add an oscillating wave source */
|
||||
#define OSCILLATING_SOURCE_PERIOD 6 /* period of oscillating source */
|
||||
#define ADD_OSCILLATING_SOURCE 1 /* set to 1 to add an oscillating wave source */
|
||||
#define OSCILLATING_SOURCE_PERIOD 50 /* period of oscillating source */
|
||||
|
||||
/* Boundary conditions, see list in global_pdes.c */
|
||||
|
||||
#define B_COND 3
|
||||
#define B_COND 2
|
||||
|
||||
/* Parameters for length and speed of simulation */
|
||||
|
||||
#define NSTEPS 2700 /* number of frames of movie */
|
||||
#define NVID 15 /* number of iterations between images displayed on screen */
|
||||
// #define NSTEPS 1000 /* number of frames of movie */
|
||||
#define NSTEPS 2400 /* number of frames of movie */
|
||||
#define NVID 12 /* number of iterations between images displayed on screen */
|
||||
#define NSEG 1000 /* number of segments of boundary */
|
||||
#define INITIAL_TIME 50 /* time after which to start saving frames */
|
||||
#define BOUNDARY_WIDTH 1 /* width of billiard boundary */
|
||||
#define INITIAL_TIME 0 /* time after which to start saving frames */
|
||||
// #define INITIAL_TIME 400 /* time after which to start saving frames */
|
||||
#define BOUNDARY_WIDTH 2 /* width of billiard boundary */
|
||||
#define PRINT_SPEED 0 /* print speed of moving source */
|
||||
|
||||
#define PAUSE 200 /* number of frames after which to pause */
|
||||
#define PSLEEP 2 /* sleep time during pause */
|
||||
#define PSLEEP 1 /* sleep time during pause */
|
||||
#define SLEEP1 1 /* initial sleeping time */
|
||||
#define SLEEP2 1 /* final sleeping time */
|
||||
#define MID_FRAMES 20 /* number of still frames between parts of two-part movie */
|
||||
@@ -168,20 +172,22 @@
|
||||
|
||||
/* Parameters of initial condition */
|
||||
|
||||
#define INITIAL_AMP 0.75 /* amplitude of initial condition */
|
||||
#define INITIAL_VARIANCE 0.00005 /* variance of initial condition */
|
||||
#define INITIAL_WAVELENGTH 0.004 /* wavelength of initial condition */
|
||||
// #define INITIAL_AMP 0.75 /* amplitude of initial condition */
|
||||
#define INITIAL_AMP 1.0 /* amplitude of initial condition */
|
||||
#define INITIAL_VARIANCE 0.0002 /* variance of initial condition */
|
||||
#define INITIAL_WAVELENGTH 0.01 /* wavelength of initial condition */
|
||||
|
||||
/* Plot type, see list in global_pdes.c */
|
||||
|
||||
#define PLOT 1
|
||||
#define PLOT 0
|
||||
// #define PLOT 1
|
||||
|
||||
#define PLOT_B 0 /* plot type for second movie */
|
||||
#define PLOT_B 5 /* plot type for second movie */
|
||||
|
||||
/* Color schemes */
|
||||
|
||||
#define COLOR_PALETTE 13 /* Color palette, see list in global_pdes.c */
|
||||
#define COLOR_PALETTE_B 11 /* Color palette, see list in global_pdes.c */
|
||||
#define COLOR_PALETTE 17 /* Color palette, see list in global_pdes.c */
|
||||
#define COLOR_PALETTE_B 13 /* Color palette, see list in global_pdes.c */
|
||||
|
||||
#define BLACK 1 /* background */
|
||||
|
||||
@@ -192,7 +198,7 @@
|
||||
#define PHASE_FACTOR 1.0 /* factor in computation of phase in color scheme P_3D_PHASE */
|
||||
#define PHASE_SHIFT 0.0 /* shift of phase in color scheme P_3D_PHASE */
|
||||
#define ATTENUATION 0.0 /* exponential attenuation coefficient of contrast with time */
|
||||
#define E_SCALE 250.0 /* scaling factor for energy representation */
|
||||
#define E_SCALE 200.0 /* scaling factor for energy representation */
|
||||
#define LOG_SCALE 1.0 /* scaling factor for energy log representation */
|
||||
#define LOG_SHIFT 1.0 /* shift of colors on log scale */
|
||||
#define RESCALE_COLOR_IN_CENTER 0 /* set to 1 to decrease color intentiy in the center (for wave escaping ring) */
|
||||
@@ -205,17 +211,31 @@
|
||||
#define HUEAMP -180.0 /* amplitude of variation of hue for color scheme C_HUE */
|
||||
|
||||
#define DRAW_COLOR_SCHEME 1 /* set to 1 to plot the color scheme */
|
||||
#define COLORBAR_RANGE 5.0 /* scale of color scheme bar */
|
||||
#define COLORBAR_RANGE_B 2.0 /* scale of color scheme bar for 2nd part */
|
||||
#define COLORBAR_RANGE 1.5 /* scale of color scheme bar */
|
||||
#define COLORBAR_RANGE_B 1.5 /* scale of color scheme bar for 2nd part */
|
||||
#define ROTATE_COLOR_SCHEME 0 /* set to 1 to draw color scheme horizontally */
|
||||
|
||||
#define SAVE_TIME_SERIES 0 /* set to 1 to save wave time series at a point */
|
||||
|
||||
#define NXMAZE 7 /* width of maze */
|
||||
#define NYMAZE 7 /* height of maze */
|
||||
#define MAZE_MAX_NGBH 4 /* max number of neighbours of maze cell */
|
||||
#define RAND_SHIFT 24 /* seed of random number generator */
|
||||
#define MAZE_XSHIFT 0.0 /* horizontal shift of maze */
|
||||
|
||||
/* for compatibility with sub_wave and sub_maze */
|
||||
#define ADD_POTENTIAL 0
|
||||
#define POT_MAZE 7
|
||||
#define POTENTIAL 0
|
||||
/* end of constants only used by sub_wave and sub_maze */
|
||||
|
||||
|
||||
/* For debugging purposes only */
|
||||
#define FLOOR 0 /* set to 1 to limit wave amplitude to VMAX */
|
||||
#define VMAX 10.0 /* max value of wave amplitude */
|
||||
|
||||
#include "global_pdes.c" /* constants and global variables */
|
||||
#include "sub_maze.c" /* support for generating mazes */
|
||||
#include "sub_wave.c" /* common functions for wave_billiard, heat and schrodinger */
|
||||
#include "wave_common.c" /* common functions for wave_billiard, wave_comparison, etc */
|
||||
|
||||
@@ -548,7 +568,6 @@ void draw_color_bar_palette(int plot, double range, int palette, int fade, doubl
|
||||
void animation()
|
||||
{
|
||||
double time, scale, ratio, startleft[2], startright[2], sign = 1.0, r2, xy[2], fade_value, yshift, speed = 0.0, a, b, c;
|
||||
// double *phi[NX], *psi[NX], *phi_tmp[NX], *psi_tmp[NX], *total_energy[NX], *color_scale[NX];
|
||||
double *phi[NX], *psi[NX], *tmp[NX], *total_energy[NX], *color_scale[NX];
|
||||
short int *xy_in[NX];
|
||||
int i, j, s, sample_left[2], sample_right[2], period = 0, fade;
|
||||
@@ -566,8 +585,6 @@ void animation()
|
||||
{
|
||||
phi[i] = (double *)malloc(NY*sizeof(double));
|
||||
psi[i] = (double *)malloc(NY*sizeof(double));
|
||||
// phi_tmp[i] = (double *)malloc(NY*sizeof(double));
|
||||
// psi_tmp[i] = (double *)malloc(NY*sizeof(double));
|
||||
tmp[i] = (double *)malloc(NY*sizeof(double));
|
||||
total_energy[i] = (double *)malloc(NY*sizeof(double));
|
||||
xy_in[i] = (short int *)malloc(NY*sizeof(short int));
|
||||
@@ -582,6 +599,9 @@ void animation()
|
||||
/* initialise polyline for von Koch and similar domains */
|
||||
npolyline = init_polyline(MDEPTH, polyline);
|
||||
for (i=0; i<npolyline; i++) printf("vertex %i: (%.3f, %.3f)\n", i, polyline[i].x, polyline[i].y);
|
||||
|
||||
npolyrect = init_polyrect(polyrect);
|
||||
for (i=0; i<npolyrect; i++) printf("polyrect vertex %i: (%.3f, %.3f) - (%.3f, %.3f)\n", i, polyrect[i].x1, polyrect[i].y1, polyrect[i].x2, polyrect[i].y2);
|
||||
|
||||
courant2 = COURANT*COURANT;
|
||||
courantb2 = COURANTB*COURANTB;
|
||||
@@ -619,10 +639,10 @@ void animation()
|
||||
// xy_to_ij(startright[0], startright[1], sample_right);
|
||||
// printf("xleft = (%.3f, %.3f) xright = (%.3f, %.3f)\n", xin_left, yin_left, xin_right, yin_right);
|
||||
|
||||
init_wave_flat(phi, psi, xy_in);
|
||||
// init_wave_flat(phi, psi, xy_in);
|
||||
|
||||
// init_circular_wave(sqrt(LAMBDA*LAMBDA - 1.0), 0.0, phi, psi, xy_in);
|
||||
// init_circular_wave(0.0, 0.0, phi, psi, xy_in);
|
||||
init_circular_wave(0.0, 0.3, phi, psi, xy_in);
|
||||
|
||||
// init_wave_plus(LAMBDA - 0.3*MU, 0.5*MU, phi, psi, xy_in);
|
||||
// init_wave(LAMBDA - 0.3*MU, 0.5*MU, phi, psi, xy_in);
|
||||
@@ -722,18 +742,20 @@ void animation()
|
||||
/* add oscillating waves */
|
||||
if ((ADD_OSCILLATING_SOURCE)&&(i%OSCILLATING_SOURCE_PERIOD == OSCILLATING_SOURCE_PERIOD - 1))
|
||||
{
|
||||
sign = -sign;
|
||||
add_circular_wave(sign, 0.0, 0.3, phi, psi, xy_in);
|
||||
// add_circular_wave(1.0, -1.5*LAMBDA, 0.0, phi, psi, xy_in);
|
||||
// add_circular_wave(-1.0, 0.6*cos((double)(period)*DPI/3.0), 0.6*sin((double)(period)*DPI/3.0), phi, psi, xy_in);
|
||||
sign = -sign;
|
||||
period++;
|
||||
|
||||
yshift = (double)period*a + (double)(period*period)*b;
|
||||
add_circular_wave(sign, -1.5 + yshift, 0.0, phi, psi, xy_in);
|
||||
// speed = (a + 2.0*(double)(period)*b)/((double)(NVID));
|
||||
// speed = 0.55*(a + 2.0*(double)(period)*b)/((double)(NVID*OSCILLATING_SOURCE_PERIOD));
|
||||
speed = (a + 2.0*(double)(period)*b)/((double)(3*NVID*OSCILLATING_SOURCE_PERIOD));
|
||||
printf("v = %.3lg, c = %.3lg\n", speed, c);
|
||||
speed = speed/c;
|
||||
// period++;
|
||||
//
|
||||
// yshift = (double)period*a + (double)(period*period)*b;
|
||||
// add_circular_wave(sign, -1.5 + yshift, 0.0, phi, psi, xy_in);
|
||||
// // speed = (a + 2.0*(double)(period)*b)/((double)(NVID));
|
||||
// // speed = 0.55*(a + 2.0*(double)(period)*b)/((double)(NVID*OSCILLATING_SOURCE_PERIOD));
|
||||
// speed = (a + 2.0*(double)(period)*b)/((double)(3*NVID*OSCILLATING_SOURCE_PERIOD));
|
||||
// printf("v = %.3lg, c = %.3lg\n", speed, c);
|
||||
// speed = speed/c;
|
||||
// speed = 120.0*speed/((double)NVID*COURANT);
|
||||
}
|
||||
if (PRINT_SPEED) print_speed(speed, 0, 1.0);
|
||||
|
||||
Reference in New Issue
Block a user