Add files via upload

This commit is contained in:
Nils Berglund 2025-07-29 17:42:52 +02:00 committed by GitHub
parent e619fee32c
commit e64ed967ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 6301 additions and 964 deletions

View File

@ -52,12 +52,13 @@
/* Choice of the billiard table, see global_particles.c */
#define B_DOMAIN 1 /* choice of domain shape */
#define B_DOMAIN 11 /* choice of domain shape */
#define CIRCLE_PATTERN 6 /* pattern of circles */
#define POLYLINE_PATTERN 4 /* pattern of polyline */
#define ABSORBING_CIRCLES 1 /* set to 1 for circular scatterers to be absorbing */
#define NABSCIRCLES 10 /* number of absorbing circles */
#define NMAXCIRCLES 50000 /* total number of circles (must be at least NCX*NCY for square grid) */
#define NMAXPOLY 50000 /* total number of sides of polygonal line */
@ -67,13 +68,16 @@
#define NGOLDENSPIRAL 2000 /* max number of points for C_GOLDEN_SPIRAL arrandement */
#define SDEPTH 2 /* Sierpinski gastket depth */
#define LAMBDAMIN 0.0 /* parameter controlling shape of domain */
#define LAMBDA 1.5 /* parameter controlling shape of domain */
#define LAMBDAMIN 6.0 /* parameter controlling shape of domain */
#define LAMBDA 20.0 /* parameter controlling shape of domain */
#define MU 1.0 /* second parameter controlling shape of billiard */
#define FOCI 1 /* set to 1 to draw focal points of ellipse */
#define NPOLY 6 /* number of sides of polygon */
// #define NPOLY 3 /* number of sides of polygon */
#define APOLY -1.0 /* angle by which to turn polygon, in units of Pi/2 */
#define LAMBDA_B 1.0 /* parameter controlling shape of domain (for P_POLYRING) */
#define NPOLY_B 100000 /* number of sides of second polygon */
#define APOLY_B 1.0 /* angle by which to turn second polygon, in units of Pi/2 */
#define DRAW_BILLIARD 1 /* set to 1 to draw billiard */
#define DRAW_CONSTRUCTION_LINES 1 /* set to 1 to draw additional construction lines for billiard */
#define PERIODIC_BC 0 /* set to 1 to enforce periodic boundary conditions when drawing particles */
@ -96,7 +100,7 @@
#define PRINT_TRAJECTORY_LENGTH 0 /* set to 1 to print length of trajectory 0 */
#define PRINT_TRAJECTORY_PERIOD 0 /* set to 1 to print period of trajectory 0 */
#define DRAW_LENGTHS_PLOT 0 /* set to 1 to plot trajectory lengths */
#define LENGTHS_LOG_SCALE 0 /* set to 1 to use log scale for plot of lengths */
#define LENGTHS_LOG_SCALE 1 /* set to 1 to use log scale for plot of lengths */
#define MAX_ANGLE 90.0 /* range of angles of trajectory */
#define NSTEPS 4000 /* number of frames of movie */
@ -141,7 +145,7 @@
#define PLOT_LYAPUNOV 1 /* set to 1 to add plot of Lyapunov exponents */
#define LOGSCALEX_LYAP 0 /* set to 1 to use log scale on parameter axis of Lyapunov exponents */
#define LYAP_MAX 1.0 /* maximal Lyapunov exponent */
#define ADAPT_TO_SYMMETRY 0 /* set to 1 to show only one symmetric part of phase space */
#define ADAPT_TO_SYMMETRY 1 /* set to 1 to show only one symmetric part of phase space */
#define SYMMETRY_FACTOR 3 /* proportion of phase space to be shown */
#define PAUSE 1000 /* number of frames after which to pause */

View File

@ -13,6 +13,8 @@
#define E_EULER_COMP 7 /* compressible Euler equation */
#define E_SHALLOW_WATER 8 /* shallow water equation */
#define E_KURAMOTO 9 /* Kuramoto-type equation (nearest neighbor coupling) */
#define E_KURAMOTO_SPHERE 91 /* Kuramoto on the sphere, with Poisson grid */
#define E_KELLER_SEGEL 10 /* Keller-Segel model */
/* Choice of potential */
@ -69,6 +71,11 @@
#define DEM_VENUS 3 /* DEM of Venus */
#define DEM_MERCURY 4 /* DEM of Mercury */
/* Type of simulation grid on the sphere */
#define GRID_EQUILONGITUDE 0 /* equally spaced latitudes an longitudes */
#define GRID_CUBIC 1 /* projection of regular grid on cube */
/* macros to avoid unnecessary computations in 3D plots */
#define COMPUTE_THETA ((cplot == Z_POLAR)||(cplot == Z_NORM_GRADIENT)||(cplot == Z_ANGLE_GRADIENT)||(cplot == Z_NORM_GRADIENT_INTENSITY)||(cplot == Z_VORTICITY)||(cplot == Z_VORTICITY_ABS))
@ -95,11 +102,13 @@
// #define RDE_PLANET (((ADAPT_STATE_TO_BC)&&((OBSTACLE_GEOMETRY == D_SPHERE_EARTH)||(OBSTACLE_GEOMETRY == D_SPHERE_MARS)||(OBSTACLE_GEOMETRY == D_SPHERE_VENUS)))||((RDE_EQUATION == E_SHALLOW_WATER)&&(SWATER_DEPTH == SH_EARTH)))
#define NMAXCIRC_SPHERE 100 /* max number of circles on sphere */
#define NMAX_TRACER_PTS 20 /* max number of tracer points recorded per cell */
#define NMAX_TRACER_PTS 20 /* max number of tracer points recorded per cell */
#define NMAX_SPHERE_NEIGHB 10 /* max number of neighbours in Poisson simulation grid */
int global_time = 0;
double max_depth = 1.0;
int moon_position;
int ngridpoints;
/* structure used for color and height representations */
/* possible extra fields: zfield, cfield, interpolated coordinates */
@ -134,6 +143,7 @@ typedef struct
double field_norm; /* norm of field or gradient */
double field_arg; /* argument of field or gradient */
double curl; /* curl of field */
double divergence; /* divergence of field */
double cos_angle; /* cos of angle between normal vector and direction of light */
double log_vorticity; /* logarithm of vorticity (for Euler equation) */
double Lpressure; /* Laplacian of pressure (for Euler equation) */
@ -176,7 +186,13 @@ typedef struct
double altitude; /* altitude in case of Earth with digital elevation model */
double cos_angle; /* cosine of light angle */
double cos_angle_sphere; /* cosing of light angle for perfect sphere */
double force; /* external forcing */
double force; /* external forcing */
double phigrid, thetagrid; /* phi, theta angles for alt simulation grid on sphere */
short int nneighb; /* number of neighbours, for Kuramoto model on sphere */
int neighbor[NMAX_SPHERE_NEIGHB]; /* list of neighbours */
int convert_grid; /* convert field from simulation grid to longitude-latitude */
short int edge; /* has value 1 on edges of cubic simulation grid */
// short int jcoord; /* j coordinate of grid */
} t_wave_sphere;

View File

@ -247,6 +247,7 @@
#define CHEM_2H2O_H3O_OH 21 /* 2 H2O <-> H3O+ + OH- */
#define CHEM_AGGREGATION 22 /* agregation of molecules coming close */
#define CHEM_AGGREGATION_CHARGE 23 /* agregation of charged molecules coming close */
#define CHEM_AGGREGATION_CHARGE_NOTRIANGLE 231 /* agregation of charged molecules coming close, no multiple pairings */
#define CHEM_AGGREGATION_NNEIGH 24 /* agregation of molecules with limitation on neighbours */
#define CHEM_DNA 25 /* aggregation of DNA molecules */
#define CHEM_DNA_ALT 251 /* aggregation of DNA molecules with constraints on connections */
@ -269,8 +270,11 @@
#define IC_CIRCLE 3 /* type 1 in a disc */
#define IC_CATALYSIS 4 /* mix of 1 and 2 in left half, only 1 in right half */
#define IC_LAYERS 5 /* layer of 2 below 1 */
#define IC_STRIPES 51 /* alternating layers of 1 and 2 */
#define IC_BZ 6 /* initial state for BZ reaction */
#define IC_SIGNX 7 /* type 1 or 2 depending on sign of x */
#define IC_SIGNY 71 /* type 1 or 2 depending on sign of y */
#define IC_SIGNY_LAYER 72 /* type 1 or 2 depending on sign of y with safety layer */
#define IC_TWOROCKETS 8 /* type 1 or 2 depending on rocket position */
#define IC_TWOROCKETS_TWOFUELS 9 /* type 1 and 2 or 1 and 3 depending on rocket */
#define IC_DNA_POLYMERASE 10 /* initial condition for DNA polymerase */
@ -315,6 +319,7 @@
#define P_CLUSTER_SELECTED 21 /* colors show which clusters are slected for growth */
#define P_COLLISION 22 /* colors depend on number of collision/reaction */
#define P_RADIUS 23 /* colors depend on particle radius */
#define P_MOL_ANG_MOMENTUM 24 /* colors depend on angular momentum of cluster */
/* Rotation schedules */
@ -358,6 +363,7 @@
#define POLY_KITE 8 /* kite for kites and darts quasicrystal */
#define POLY_DART 81 /* dart for kites and darts quasicrystal */
#define POLY_SEG_POLYGON 9 /* polygon of segments */
#define POLY_NONE 99 /* no pairing */
/* Background color schemes */
@ -370,6 +376,7 @@
#define BG_EKIN_OBSTACLES 6 /* background color depends on kinetic energy plus obstacle energy */
#define BG_DIR_OBSTACLES 7 /* background color depends on direction of velocity of obstacles */
#define BG_POS_OBSTACLES 8 /* background color depends on displacement of obstacles */
#define BG_CURRENTX 9 /* background color depends on x-component of current */
/* Obstacle color schemes */
@ -479,6 +486,7 @@ typedef struct
double fx, fy, torque; /* force and torque */
double energy, emean; /* energy and averaged energy */
double dirmean; /* time-averaged direction */
double lmean; /* time-averaged angular momentum */
int nparticles; /* number of particles in cluster */
int particle[NMAXPARTINCLUSTER]; /* list of particles in cluster */
// int angle_ref; /* reference particle for orientation */
@ -533,7 +541,10 @@ typedef struct
int nneighb; /* number of neighbours, for option OSCILLATING_OBSTACLES */
int neighb[NMAX_OBSTACLE_NEIGHBOURS]; /* list of neighour numbers */
double eqdist[NMAX_OBSTACLE_NEIGHBOURS]; /* equilibrium distance to neighbours */
short int shiftx[NMAX_OBSTACLE_NEIGHBOURS]; /* x shift for periodic boundary conditions */
short int shifty[NMAX_OBSTACLE_NEIGHBOURS]; /* y shift for periodic boundary conditions */
short int pinned; /* has value 1 if particle is pinned to a fixed position */
short int damped; /* obstacle is damped */
short int chessboard; /* has value 1 on a chessboard, for some arrangements */
} t_obstacle;
@ -544,6 +555,7 @@ typedef struct
short int acute; /* value depends on central angle */
short int infacet; /* has value 1 if triangle belongs to a facet */
double area0; /* initial area */
short int shiftx[3], shifty[3]; /* shifts for periodic b.c. */
} t_otriangle;
typedef struct
@ -656,6 +668,7 @@ typedef struct
double efield, bfield; /* electric and magnetic field */
double prop; /* proportion of types */
double thermo_radius; /* radius of thermostat region */
double current; /* electrical current */
} t_lj_parameters;

View File

@ -73,6 +73,7 @@
#define D_WAVEGUIDES_COUPLED_N 525 /* two coupled wave guides, narrow variant */
#define D_WAVEGUIDE_BADSPLICE 526 /* badly spliced fibers, to use with IOR_WAVE_GUIDE_COATED */
#define D_MAZE 53 /* maze */
#define D_MAZE_SMALL 531 /* maze */
#define D_MAZE_CLOSED 54 /* closed maze */
#define D_MAZE_CHANNELS 541 /* maze with two channels attached */
#define D_MAZE_CHANNELS_INT 542 /* maze with two channels attached, distance defined from interior of cells */
@ -117,9 +118,19 @@
#define D_EPICYCLOID 92 /* epicycloid */
#define D_CIRCLE_LATTICE 93 /* lattice of connected circles */
#define D_CIRCLE_LATTICE_RANDOM 931 /* lattice of connected circles with random channel widths */
#define D_CIRCLE_LATTICE_SQUARE_CROSS 932 /* square lattice with next-nearest-neighbours */
#define D_CIRCLE_LATTICE_MAZE 933 /* maze of connected circles */
#define D_CIRCLE_LATTICE_NONISO 934 /* lattice of connected circle with anisotropic channel widths */
#define D_CIRCLE_LATTICE_HALF 935 /* same as D_CIRCLE_LATTICE_NONISO, but empty upper half */
#define D_CIRCLE_LATTICE_HALF_V 936 /* same as D_CIRCLE_LATTICE_NONISO, but empty left half */
#define D_CIRCLE_LATTICE_STRIP 937 /* vertical strip of lattice of circles */
#define D_CIRCLE_LATTICE_HEX 94 /* hex lattice of connected circles */
#define D_CIRCLE_LATTICE_HEX_MAZE 941 /* maze of connected circles based on hex lattice */
#define D_CIRCLE_LATTICE_HEX_NONISO 942 /* hex lattice with anisotropic channel widths */
#define D_CIRCLE_LATTICE_HEX_STRIP 947 /* vertical strip of hex lattice of circles */
#define D_CIRCLE_LATTICE_HONEY 95 /* honeycomb lattice of connected circles */
#define D_CIRCLE_LATTICE_POISSON 96 /* Poisson disc process of connected circles */
#define D_CIRCLE_LATTICE_RHOMBUS 97 /* rhombus-based lattice of connected circles */
/* for wave_sphere.c */
@ -338,6 +349,7 @@
/* plot types used by rde */
#define Z_AMPLITUDE 0 /* amplitude of first field */
#define Z_AMPLITUDE_B 1 /* amplitude of second field */
#define Z_ANGLE 10 /* angle, for Kuramoto model */
#define Z_RGB 20 /* RGB plot */
#define Z_POLAR 21 /* polar angle associated with RBG plot */
@ -349,6 +361,7 @@
#define Z_VORTICITY 25 /* curl of polar angle */
#define Z_VORTICITY_ABS 251 /* absolute value of curl of polar angle */
#define Z_MAXTYPE_RPS 26 /* color or type with maximal density */
#define Z_DIVERGENCE 27 /* divergence in Keller-Segel model */
// #define Z_ZERO 99 /* return zero */
/* for Schrodinger equation */
@ -486,9 +499,15 @@ t_arc polyarc[NMAXPOLY]; /* data of arcs */
/* the same for comparisons between different domains */
int ncircles_b = NMAXCIRCLES; /* actual number of circles, can be decreased e.g. for random patterns */
int npolyline_b = NMAXPOLY; /* actual length of polyline */
int npolyrect_b = NMAXPOLY; /* actual number of polyrect */
int npolyrect_rot_b = NMAXPOLY; /* actual number of rotated polyrect */
int npolyarc_b = NMAXPOLY; /* actual number of arcs */
t_circle circles_b[NMAXCIRCLES]; /* circular scatterers */
t_polygon polygons_b[NMAXCIRCLES]; /* polygonal scatterers */
t_vertex polyline_b[NMAXPOLY]; /* vertices of polygonal line */
t_rectangle polyrect_b[NMAXPOLY]; /* vertices of rectangles */
t_rect_rotated polyrectrot_b[NMAXPOLY]; /* data of rotated rectangles */
t_arc polyarc_b[NMAXPOLY]; /* data of arcs */
double courant2, courantb2; /* Courant parameters squared */

4
heat.c
View File

@ -159,6 +159,7 @@
#define SCALE 0 /* set to 1 to adjust color scheme to variance of field */
// #define SLOPE 0.1 /* sensitivity of color on wave amplitude */
#define SLOPE 0.2 /* sensitivity of color on wave amplitude */
#define COLOR_RANGE 1.0 /* max range of color (default: 1.0) */
#define ATTENUATION 0.0 /* exponential attenuation coefficient of contrast with time */
#define PHASE_SHIFT 0.0 /* shift of phase in color scheme P_3D_PHASE */
@ -222,6 +223,9 @@
#define DRAW_WAVE_PROFILE 0 /* set to 1 to draw a profile of the wave */
#define VERTICAL_WAVE_PROFILE 0 /* set to 1 to draw wave profile vertically */
#define WALL_WIDTH 0.1 /* width of wall separating lenses */
#define WALL_WIDTH_B 0.01 /* width of wall separating lenses */
#define WALL_WIDTH_ASYM 0.75 /* asymmetry of wall width (D_CIRCLE_LATTICE_NONISO) */
#define WALL_WIDTH_ASYM_B 0.75 /* asymmetry of wall width (D_CIRCLE_LATTICE_HEX_NONISO) */
#define PDISC_CONNECT_FACTOR 1.5 /* controls which discs are connected for D_CIRCLE_LATTICE_POISSON domain */
#define WALL_WIDTH_RND 0.0 /* proportion of width of width for random arrangements */
#define RADIUS_FACTOR 0.3 /* controls inner radius for C_RING arrangements */

View File

@ -37,7 +37,7 @@
#include <time.h>
#define MOVIE 0 /* set to 1 to generate movie */
#define DOUBLE_MOVIE 1 /* set to 1 to produce movies for wave height and energy simultaneously */
#define DOUBLE_MOVIE 0 /* set to 1 to produce movies for wave height and energy simultaneously */
#define SAVE_MEMORY 1 /* set to 1 to save memory while saving frames */
#define NO_EXTRA_BUFFER_SWAP 1 /* some OS require one less buffer swap when recording images */
@ -58,47 +58,47 @@
#define YMIN -1.125
#define YMAX 1.125 /* y interval for 9/16 aspect ratio */
#define INITXMIN -1.95
#define INITXMAX -1.9 /* x interval for initial condition */
#define INITYMIN 0.9
#define INITYMAX 1.0 /* y interval for initial condition */
#define INITXMIN -0.1
#define INITXMAX 0.1 /* x interval for initial condition */
#define INITYMIN -0.1
#define INITYMAX 0.1 /* y interval for initial condition */
#define THERMOXMIN -1.25
#define THERMOXMAX 1.25 /* x interval for initial condition */
#define THERMOYMIN 0.0
#define THERMOYMAX 0.75 /* y interval for initial condition */
#define ADDXMIN -1.95
#define ADDXMAX -1.9 /* x interval for adding particles */
#define ADDYMIN 0.0
#define ADDYMAX 0.6 /* y interval for adding particles */
#define ADDXMIN -1.9
#define ADDXMAX 1.9 /* x interval for adding particles */
#define ADDYMIN 1.2
#define ADDYMAX 1.3 /* y interval for adding particles */
#define ADDRMIN 4.75
#define ADDRMAX 6.0 /* r interval for adding particles */
#define BCXMIN -2.0
#define BCXMAX 2.0 /* x interval for boundary condition */
#define BCYMIN -1.125
#define BCYMAX 1.125 /* y interval for boundary condition */
#define BCYMAX 1.325 /* y interval for boundary condition */
#define OBSXMIN -1.8
#define OBSXMIN -2.0
#define OBSXMAX 2.0 /* x interval for motion of obstacle */
#define OBSYMIN -1.125
#define OBSYMAX 1.125 /* x interval for motion of obstacle */
#define CIRCLE_PATTERN 1 /* pattern of circles, see list in global_ljones.c */
#define CIRCLE_PATTERN 0 /* pattern of circles, see list in global_ljones.c */
#define ADD_INITIAL_PARTICLES 0 /* set to 1 to add a second type of particles */
#define CIRCLE_PATTERN_B 0 /* pattern of circles for additional particles */
#define ADD_FIXED_OBSTACLES 0 /* set to 1 do add fixed circular obstacles */
#define OBSTACLE_PATTERN 91 /* pattern of obstacles, see list in global_ljones.c */
#define OBSTACLE_PATTERN 9 /* pattern of obstacles, see list in global_ljones.c */
#define RATTLE_OBSTACLES 0 /* set to 1 to rattle obstacles (for pattern O_SIEVE_B) */
#define OSCILLATE_OBSTACLES 1 /* set to 1 to make obstacles oscillate */
#define COUPLE_OBSTACLES 1 /* set to 1 to couple obstacles to neighbours */
#define OBSTACLE_PISC_DISTANCE 0.08 /* minimal distance in Poisson disc process for obstacles, controls density of obstacles */
#define OBSTACLE_COUPLING_DIST 0.12 /* max distance of coupled obstacles */
#define OBSTACLE_COUPLING_DIST 0.2 /* max distance of coupled obstacles */
#define NMAX_OBSTACLE_NEIGHBOURS 8 /* max number of obstacle neighbours */
#define NMAX_OBSTACLE_PINNED 3 /* max number of neighbours to be pinned */
#define NMAX_OBSTACLE_PINNED 6 /* max number of neighbours to be pinned */
#define OBSTACLE_PINNING_TYPE 0 /* type of obstacle pinning, see OP_ in global_ljones */
#define BDRY_PINNING_STEP 4 /* interval between pinned obstacles on boundary */
#define RECOUPLE_OBSTACLES 0 /* set to 1 to reset obstacle coupling */
@ -130,7 +130,7 @@
#define INTERACTION_B 1 /* particle interaction for second type of particle, see list in global_ljones.c */
#define SPIN_INTER_FREQUENCY 4.0 /* angular frequency of spin-spin interaction */
#define SPIN_INTER_FREQUENCY_B 4.0 /* angular frequency of spin-spin interaction for second particle type */
#define MOL_ANGLE_FACTOR 4.0 /* rotation angle for P_MOL_ANGLE color scheme */
#define MOL_ANGLE_FACTOR 1.0 /* rotation angle for P_MOL_ANGLE color scheme */
#define P_PERCOL 0.25 /* probability of having a circle in C_RAND_PERCOL arrangement */
#define NPOISSON 100 /* number of points for Poisson C_RAND_POISSON arrangement */
@ -139,9 +139,9 @@
#define RANDOM_POLY_ANGLE 0 /* set to 1 to randomize angle of polygons */
#define LAMBDA 0.2 /* parameter controlling the dimensions of domain */
#define MU 0.02 /* parameter controlling radius of particles */
#define MU_B 0.03 /* parameter controlling radius of particles of second type */
#define MU_ADD 0.02 /* parameter controlling radius of added particles */
#define MU 0.016 /* parameter controlling radius of particles */
#define MU_B 0.012 /* parameter controlling radius of particles of second type */
#define MU_ADD 0.016 /* parameter controlling radius of added particles */
#define NPOLY 3 /* number of sides of polygon */
#define APOLY 0.0 /* angle by which to turn polygon, in units of Pi/2 */
#define AWEDGE 0.5 /* opening angle of wedge, in units of Pi/2 */
@ -156,8 +156,8 @@
#define EHRENFEST_WIDTH 0.035 /* width of tube for Ehrenfest urn configuration */
#define TWO_CIRCLES_RADIUS_RATIO 0.8 /* ratio of radii for S_TWO_CIRCLES_EXT segment configuration */
#define DAM_WIDTH 0.05 /* width of dam for S_DAM segment configuration */
#define NOBSX 40
#define NOBSY 24 /* obstacles for O_HEX obstacle pattern */
#define NOBSX 24
#define NOBSY 14 /* obstacles for O_HEX obstacle pattern */
#define NTREES 15 /* number of trees in S_TREES */
#define X_SHOOTER -0.2
@ -167,10 +167,10 @@
/* Parameters for length and speed of simulation */
#define NSTEPS 2200 /* number of frames of movie */
#define NVID 150 /* number of iterations between images displayed on screen */
#define NSTEPS 4800 /* number of frames of movie */
#define NVID 100 /* number of iterations between images displayed on screen */
#define NSEG 25 /* number of segments of boundary of circles */
#define INITIAL_TIME 30 /* time after which to start saving frames */
#define INITIAL_TIME 0 /* time after which to start saving frames */
#define OBSTACLE_INITIAL_TIME 0 /* time after which to start moving obstacle */
#define BOUNDARY_WIDTH 1 /* width of particle boundary */
#define LINK_WIDTH 2 /* width of links between particles */
@ -189,15 +189,14 @@
/* Plot type, see list in global_ljones.c */
#define PLOT 17
// #define PLOT 23
#define PLOT 13
#define PLOT_B 17 /* plot type for second movie */
/* Background color depending on particle properties */
#define COLOR_BACKGROUND 1 /* set to 1 to color background */
#define BG_COLOR 4 /* type of background coloring, see list in global_ljones.c */
#define BG_COLOR_B 2 /* type of background coloring, see list in global_ljones.c */
#define COLOR_BACKGROUND 0 /* set to 1 to color background */
#define BG_COLOR 6 /* type of background coloring, see list in global_ljones.c */
#define BG_COLOR_B 9 /* type of background coloring, see list in global_ljones.c */
#define OBSTACLE_COLOR 0 /* type of obstacle, see OC_ in global_ljones.c */
#define DRAW_BONDS 0 /* set to 1 to draw bonds between neighbours */
@ -212,7 +211,7 @@
#define INITIAL_POS_TYPE 0 /* type of initial position dependence */
#define ERATIO 0.995 /* ratio for time-averaging in P_EMEAN color scheme */
#define DRATIO 0.999 /* ratio for time-averaging in P_DIRECT_EMEAN color scheme */
#define OBSTACLE_AREA_SHADE_FACTOR 80.0 /* controls sensitivity of triangle shade for option FILL_OBSTACLE_TRIANGLES */
#define OBSTACLE_AREA_SHADE_FACTOR 75.0 /* controls sensitivity of triangle shade for option FILL_OBSTACLE_TRIANGLES */
#define SHADE_OBSTACLE_FACETS 1 /* set to 1 to shade facets instead of triangles */
/* Color schemes */
@ -220,7 +219,7 @@
#define COLOR_PALETTE 10 /* Color palette, see list in global_ljones.c */
#define COLOR_PALETTE_EKIN 10 /* Color palette for kinetic energy */
#define COLOR_PALETTE_ANGLE 0 /* Color palette for angle representation */
#define COLOR_PALETTE_DIRECTION 17 /* Color palette for direction representation */
#define COLOR_PALETTE_DIRECTION 0 /* Color palette for direction representation */
#define COLOR_PALETTE_INITIAL_POS 10 /* Color palette for initial position representation */
#define COLOR_PALETTE_DIFFNEIGH 10 /* Color palette for different neighbours representation */
#define COLOR_PALETTE_PRESSURE 11 /* Color palette for different neighbours representation */
@ -228,6 +227,8 @@
#define COLOR_PALETTE_CLUSTER 14 /* Color palette for cluster representation */
#define COLOR_PALETTE_CLUSTER_SIZE 13 /* Color palette for cluster size representation */
#define COLOR_PALETTE_CLUSTER_SELECTED 11 /* Color palette for selected cluster representation */
#define COLOR_PALETTE_ANGULAR_MOMENTUM 17 /* Color palette for angular momentum */
#define COLOR_PALETTE_CURRENT 17 /* Color palette for current */
#define COLOR_HUE_CLUSTER_SELECTED 90.0 /* Color hue for selected cluster */
#define COLOR_HUE_CLUSTER_NOT_SELECTED 220.0 /* Color hue for selected cluster */
@ -237,6 +238,7 @@
#define SCALE 0 /* set to 1 to adjust color scheme to variance of field */
#define SLOPE 0.5 /* sensitivity of color on wave amplitude */
#define COLOR_RANGE 1.0 /* max range of color (default: 1.0) */
#define ATTENUATION 0.0 /* exponential attenuation coefficient of contrast with time */
#define COLORHUE 260 /* initial hue of water color for scheme C_LUM */
@ -245,7 +247,7 @@
#define LUMAMP 0.3 /* amplitude of luminosity variation for scheme C_LUM */
#define HUEMEAN 220.0 /* mean value of hue for color scheme C_HUE */
#define HUEAMP -50.0 /* amplitude of variation of hue for color scheme C_HUE */
#define COLOR_HUESHIFT -0.5 /* shift in color hue (for some cyclic palettes) */
#define COLOR_HUESHIFT 1.0 /* shift in color hue (for some cyclic palettes) */
#define PRINT_PARAMETERS 1 /* set to 1 to print certain parameters */
#define PRINT_TEMPERATURE 0 /* set to 1 to print current temperature */
@ -264,11 +266,11 @@
#define ENERGY_HUE_MAX 50.0 /* color of saturated particle */
#define PARTICLE_HUE_MIN 359.0 /* color of original particle */
#define PARTICLE_HUE_MAX 0.0 /* color of saturated particle */
#define PARTICLE_EMIN 100.0 /* energy of particle with coolest color */
#define PARTICLE_EMAX 100000.0 /* energy of particle with hottest color */
#define PARTICLE_EMIN 0.0 /* energy of particle with coolest color */
#define PARTICLE_EMAX 50000.0 /* energy of particle with hottest color */
#define SEGMENT_HUE_MIN 275.0 /* color of original segment */
#define SEGMENT_HUE_MAX 30.0 /* color of saturated segment */
#define OBSTACLE_EMAX 150.0 /* energy of obstacle with hottest color */
#define OBSTACLE_EMAX 1000000.0 /* energy of obstacle with hottest color */
#define OBSTACLE_VMAX 4.0 /* speed of obstacle with largest luminosity */
#define HUE_TYPE0 320.0 /* hue of particles of type 0 */
#define HUE_TYPE1 60.0 /* hue of particles of type 1 */
@ -279,33 +281,36 @@
#define HUE_TYPE6 130.0 /* hue of particles of type 6 */
#define HUE_TYPE7 150.0 /* hue of particles of type 7 */
#define BG_FORCE_SLOPE 1.0e-6 /* contant in BG_FORCE backgound color scheme*/
#define PARTICLE_LMAX 1.5e4 /* angular momentum particle with brightest color */
#define RANDOM_RADIUS 0 /* set to 1 for random particle radius */
#define RANDOM_RADIUS_MIN 0.4 /* min of random particle radius (default 0.75) */
#define RANDOM_RADIUS_RANGE 1.0 /* range of random particle radius (default 0.5) */
#define ADAPT_MASS_TO_RADIUS 1 /* set to positive value to for mass prop to power of radius */
#define ADAPT_DAMPING_TO_RADIUS 0.5 /* set to positive value to for friction prop to power of radius */
#define ADAPT_DAMPING_FACTOR 0.5 /* factor by which damping is adapted to radius */
#define DT_PARTICLE 1.5e-6 /* time step for particle displacement */
#define KREPEL 50.0 /* constant in repelling force between particles */
#define EQUILIBRIUM_DIST 2.0 /* Lennard-Jones equilibrium distance */
#define EQUILIBRIUM_DIST_B 2.5 /* Lennard-Jones equilibrium distance for second type of particle */
#define ADAPT_MASS_TO_RADIUS 0 /* set to positive value to for mass prop to power of radius */
#define ADAPT_DAMPING_TO_RADIUS 0.0 /* set to positive value to for friction prop to power of radius */
#define ADAPT_DAMPING_FACTOR 0.0 /* factor by which damping is adapted to radius */
#define DT_PARTICLE 1.0e-6 /* time step for particle displacement */
#define KREPEL 20.0 /* constant in repelling force between particles */
#define EQUILIBRIUM_DIST 4.0 /* Lennard-Jones equilibrium distance */
#define EQUILIBRIUM_DIST_B 4.0 /* Lennard-Jones equilibrium distance for second type of particle */
#define SEGMENT_FORCE_EQR 1.0 /* equilibrium distance factor for force from segments (default 1.5) */
#define REPEL_RADIUS 25.0 /* radius in which repelling force acts (in units of particle radius) */
#define DAMPING 0.0 /* damping coefficient of particles */
#define DAMPING 50.0 /* damping coefficient of particles */
#define INITIAL_DAMPING 1000.0 /* damping coefficient of particles during initial phase */
#define DAMPING_ROT 5.0 /* damping coefficient for rotation of particles */
#define DAMPING_PAIRS 0.0 /* damping between paired particles */
#define PARTICLE_MASS 2.0 /* mass of particle of radius MU */
#define PARTICLE_MASS_B 2.0 /* mass of particle of radius MU_B */
#define PARTICLE_MASS_B 1.0 /* mass of particle of radius MU_B */
#define PARTICLE_ADD_MASS 2.0 /* mass of added particles */
#define PARTICLE_INERTIA_MOMENT 0.5 /* moment of inertia of particle */
#define PARTICLE_INERTIA_MOMENT_B 0.5 /* moment of inertia of second type of particle */
#define V_INITIAL 200.0 /* initial velocity range */
#define V_INITIAL_ADD 50.0 /* initial velocity range for added particles */
#define PARTICLE_INERTIA_MOMENT 0.1 /* moment of inertia of particle */
#define PARTICLE_INERTIA_MOMENT_B 0.1 /* moment of inertia of second type of particle */
#define V_INITIAL 100.0 /* initial velocity range */
#define V_INITIAL_ADD 100.0 /* initial velocity range for added particles */
#define OMEGA_INITIAL 100.0 /* initial angular velocity range */
#define VICSEK_VMIN 1.0 /* minimal speed of particles in Vicsek model */
#define VICSEK_VMAX 40.0 /* minimal speed of particles in Vicsek model */
#define COULOMB_LJ_FACTOR 1.0 /* relative intensity of LJ interaction in I_COULOMB_LJ interaction (default: 0.01) */
#define OBSTACLE_DAMPING 0.0 /* damping of oscillating obstacles */
#define V_INITIAL_TYPE 0 /* type of initial speed distribution (see VI_ in global_ljones.c) */
@ -315,9 +320,9 @@
#define BETA 0.004 /* initial inverse temperature */
#define MU_XI 0.005 /* friction constant in thermostat */
#define KSPRING_BOUNDARY 2.0e11 /* confining harmonic potential outside simulation region */
#define KSPRING_OBSTACLE 1.0e9 /* harmonic potential of obstacles */
#define KSPRING_OBSTACLE 5.0e11 /* harmonic potential of obstacles */
#define NBH_DIST_FACTOR 4.0 /* radius in which to count neighbours */
#define GRAVITY 0.0 /* gravity acting on all particles */
#define GRAVITY 10000.0 /* gravity acting on all particles */
#define GRAVITY_X 0.0 /* horizontal gravity acting on all particles */
#define CIRCULAR_GRAVITY 0 /* set to 1 to have gravity directed to center */
#define INCREASE_GRAVITY 0 /* set to 1 to increase gravity during the simulation */
@ -328,34 +333,41 @@
#define KSPRING_VICSEK 0.2 /* spring constant for I_VICSEK_SPEED interaction */
#define VICSEK_REPULSION 10.0 /* repulsion between particles in Vicsek model */
#define ADD_EFIELD 0 /* set to 1 to add an electric field */
#define EFIELD -100.0 /* value of electric field */
#define EFIELD_Y 0.0 /* value of electric field */
#define ADD_BFIELD 0 /* set to 1 to add a magnetic field */
#define BFIELD 0.0 /* value of magnetic field */
#define CHARGE 1.0 /* charge of particles of first type */
#define CHARGE_B 1.0 /* charge of particles of second type */
#define CHARGE_ADD 1.0 /* charge of added particles */
#define INCREASE_E 0 /* set to 1 to increase electric field */
#define EFIELD_FACTOR 5000000.0 /* factor by which to increase electric field */
#define ADD_EFIELD 0 /* set to 1 to add an electric field */
#define EFIELD 150000.0 /* value of electric field */
#define EFIELD_Y 0.0 /* value of electric field */
#define ADD_BFIELD 0 /* set to 1 to add a magnetic field */
#define BFIELD 20000.0 /* value of magnetic field */
#define CHARGE 1.0 /* charge of particles of first type */
#define CHARGE_B -1.0 /* charge of particles of second type */
#define CHARGE_ADD 1.0 /* charge of added particles */
#define INCREASE_E 0 /* set to 1 to increase electric field */
#define OSCILLATE_E 0 /* set to 1 for oscillating electric field */
#define E_PERIOD 1000 /* period of oscillating electric field */
#define EFIELD_FACTOR 180000.0 /* factor by which to increase electric field */
#define INCREASE_B 0 /* set to 1 to increase magnetic field */
#define BFIELD_FACTOR 1.0 /* factor by which to increase magnetic field */
#define CHARGE_OBSTACLES 0 /* set to 1 for obstacles to be charged */
#define OBSTACLE_CHARGE 3.0 /* charge of obstacles */
#define OBSTACLE_MASS 100.0 /* mass of obstacles, if oscillating */
#define KSPRING_OBSTACLE_OSC 5.0e5 /* spring constant for oscillating obstacles */
#define KSPRING_OBSTACLE_COUPLE 2.0e5 /* spring constant for coupled obstacles */
#define OBSTACLE_HARDCORE 1 /* set to 1 to add "hard core" repulsion between obstacles */
#define BFIELD_FACTOR 1000.0 /* factor by which to increase magnetic field */
#define CHARGE_OBSTACLES 1 /* set to 1 for obstacles to be charged */
#define OBSTACLE_CHARGE 1.0 /* charge of obstacles */
#define OBSTACLE_MASS 1000.0 /* mass of obstacles, if oscillating */
#define KSPRING_OBSTACLE_OSC 1.0e10 /* spring constant for oscillating obstacles */
#define KSPRING_OBSTACLE_COUPLE 1.0e8 /* spring constant for coupled obstacles */
#define OBSTACLE_HARDCORE 0 /* set to 1 to add "hard core" repulsion between obstacles */
#define KSPRING_OBSTACLE_HARDCORE 1.0e11 /* spring constant for obstacle hard core repulsion */
#define KCOULOMB_OBSTACLE 1000.0 /* Coulomb force constant for charged obstacles */
#define EFIELD_REGION 0 /* space-dependent magnetic field (0 for constant) */
#define EFIELD_REGION 0 /* space-dependent electric field (0 for constant) */
#define BFIELD_REGION 0 /* space-dependent magnetic field (0 for constant) */
#define DRAW_E_ARROW 0 /* set to 1 to draw E field arrow */
#define E_ARROW_YSHIFT 0.05 /* vertical position of E field arrow */
#define PRINT_CURRENT 0 /* set to 1 to print electric current (x component) */
#define DRAW_CURRENT_ARROW 0 /* set to 1 to draw current arrow */
#define MAX_CURRENT 200.0 /* current scale */
#define ADD_WIND 0 /* set to 1 to add a "wind" friction force */
#define WIND_FORCE 1.35e6 /* force of wind */
#define WIND_YMIN -0.6 /* min altitude of region with wind */
#define ROTATION 0 /* set to 1 to include rotation of particles */
#define ROTATION 0 /* set to 1 to include rotation of particles */
#define COUPLE_ANGLE_TO_THERMOSTAT 0 /* set to 1 to couple angular degrees of freedom to thermostat */
#define DIMENSION_FACTOR 1.0 /* scaling factor taking into account number of degrees of freedom */
#define KTORQUE 1.0e5 /* force constant in angular dynamics */
@ -391,7 +403,7 @@
#define CENTER_VIEW_ON_OBSTACLE 0 /* set to 1 to center display on moving obstacle */
#define RESAMPLE_Y 0 /* set to 1 to resample y coordinate of moved particles (for shock waves) */
#define NTRIALS 2000 /* number of trials when resampling */
#define OBSTACLE_RADIUS 0.015 /* radius of obstacle for circle boundary conditions */
#define OBSTACLE_RADIUS 0.02 /* radius of obstacle for circle boundary conditions */
#define FUNNEL_WIDTH 0.25 /* funnel width for funnel boundary conditions */
#define OBSTACLE_XMIN 0.0 /* initial position of obstacle */
#define OBSTACLE_XMAX 3.0 /* final position of obstacle */
@ -417,19 +429,21 @@
#define ADD_PARTICLES 1 /* set to 1 to add particles */
#define ADD_REGION 0 /* shape of add regions, cf ADD_* in global_ljones */
#define ADD_TIME 0 /* time at which to add first particle */
#define ADD_PERIOD 35 /* time interval between adding further particles */
#define ADD_TIME 0 /* time at which to add first particle */
#define ADD_PERIOD 25 /* time interval between adding further particles */
#define N_ADD_PARTICLES 1 /* number of particles to add */
#define FINAL_NOADD_PERIOD 250 /* final period where no particles are added */
#define FINAL_NOADD_PERIOD 1000 /* final period where no particles are added */
#define SAFETY_FACTOR 4.0 /* no particles are added at distance less than MU*SAFETY_FACTOR of other particles */
#define ADD_ALTERNATE_CHARGE 1 /* set to 1 to randomly select sign of added charge */
#define ALTERNATE_CHARGE_PROPORTION 0.5 /* proportion of particles of opposite charge */
#define TRACER_PARTICLE 1 /* set to 1 to have a tracer particle */
#define N_TRACER_PARTICLES 200 /* number of tracer particles */
#define N_TRACER_PARTICLES 500 /* number of tracer particles */
#define TRACER_STEPS 5 /* number of tracer steps recorded between images */
#define TRAJECTORY_LENGTH 5000 /* length of recorded trajectory */
#define TRACER_LUM_FACTOR 40.0 /* controls luminosity decrease of trajectories with time */
#define TRACER_PARTICLE_MASS 4.0 /* relative mass of tracer particle */
#define TRAJECTORY_LENGTH 5200 /* length of recorded trajectory */
#define TRAJECTORY_DRAW_LENGTH 1000 /* length of drawn trajectory */
#define TRACER_LUM_FACTOR 25.0 /* controls luminosity decrease of trajectories with time */
#define TRACER_PARTICLE_MASS 2.0 /* relative mass of tracer particle */
#define TRAJECTORY_WIDTH 2 /* width of tracer particle trajectory */
#define TRACK_PARTICLE 0 /* set to 1 to track a given particle */
@ -480,26 +494,29 @@
#define POSITION_DEP_X -0.625 /* threshold value for position-dependent type */
#define PRINT_ENTROPY 0 /* set to 1 to compute entropy */
#define SPECIAL_IC 0 /* set to 1 for choosing specaial initial condition RD_INITIAL_COND */
#define REACTION_DIFFUSION 0 /* set to 1 to simulate a chemical reaction (particles may change type) */
#define RD_REACTION 262 /* type of reaction, see list in global_ljones.c */
#define RD_TYPES 1 /* number of types in reaction-diffusion equation */
#define RD_INITIAL_COND 0 /* initial condition of particles */
#define REACTION_DIST 1.2 /* maximal distance for reaction to occur */
#define REACTION_MAX_TIME 100 /* time after which no reactions take place */
#define RD_REACTION 231 /* type of reaction, see list in global_ljones.c */
#define RD_TYPES 2 /* number of types in reaction-diffusion equation */
#define RD_INITIAL_COND 51 /* initial condition of particles */
#define REACTION_DIST 1.8 /* maximal distance for reaction to occur */
#define REACTION_PROB 1.0 /* probability controlling reaction term */
#define DISSOCIATION_PROB 0.0 /* probability controlling dissociation reaction */
#define KILLING_PROB 0.0015 /* probability of enzymes being killed */
#define DELTAMAX 0.1 /* max orientation difference for pairing polygons */
#define CENTER_COLLIDED_PARTICLES 0 /* set to 1 to recenter particles upon reaction (may interfere with thermostat) */
#define EXOTHERMIC 0 /* set to 1 to make reaction exo/endothermic */
#define DELTA_EKIN 2000.0 /* change of kinetic energy in reaction */
#define CENTER_COLLIDED_PARTICLES 1 /* set to 1 to recenter particles upon reaction (may interfere with thermostat) */
#define EXOTHERMIC 1 /* set to 1 to make reaction exo/endothermic */
#define DELTA_EKIN -2.0e10 /* change of kinetic energy in reaction */
#define CORRECT_EQUILIBRIUM_POSITION 1 /* set to 1 to nudge particle dist towards eq dist */
#define COLLISION_TIME 25 /* time during which collisions are shown */
#define COLLISION_RADIUS 2.0 /* radius of discs showing collisions, in units of MU */
#define DELTAVMAX 200.0 /* maximal deltav allowed for pairing molecules */
#define AGREGMAX 6 /* maximal number of partners for CHEM_AGGREGATION reaction */
#define AGREGMAX 1 /* maximal number of partners for CHEM_AGGREGATION reaction */
#define AGREG_DECOUPLE 12 /* minimal number of partners to decouple from thermostat */
#define CLUSTER_PARTICLES 0 /* set to 1 for particles to form rigid clusters */
#define CLUSTER_MAXSIZE 1000 /* max size of clusters */
#define SMALL_CLUSTER_MAXSIZE 10 /* size limitation on smaller cluster */
#define CLUSTER_MAXSIZE 2 /* max size of clusters */
#define SMALL_CLUSTER_MAXSIZE 2 /* size limitation on smaller cluster */
#define SMALL_NP_MAXSIZE 2 /* limitation on number of partners of particle in smaller cluster */
#define NOTSELECTED_CLUSTER_MAXSIZE 0 /* limit on size of clusters that can merge with non-selected cluster */
#define REPAIR_CLUSTERS 0 /* set to 1 to repair alignment in clusters */
@ -515,6 +532,7 @@
#define PLOT_SPEEDS 0 /* set to 1 to add a plot of obstacle speeds (e.g. for rockets) */
#define PLOT_TRAJECTORIES 0 /* set to 1 to add a plot of obstacle trajectories (e.g. for rockets) */
#define VMAX_PLOT_SPEEDS 0.25 /* vertical scale of plot of obstacle speeds */
#define PLOT_CURRENTS 0 /* set to 1 to make current vs E field plot */
#define EHRENFEST_COPY 0 /* set to 1 to add equal number of larger particles (for Ehrenfest model) */
@ -530,21 +548,21 @@
#define PROP_MIN 0.1 /* min proportion of type 1 particles */
#define PROP_MAX 0.9 /* max proportion of type 1 particles */
#define PAIR_PARTICLES 0 /* set to 1 to form particles pairs */
#define PAIR_PARTICLES 1 /* set to 1 to form particles pairs */
#define RANDOMIZE_ANGLE 0 /* set to 1 for random orientation */
#define DEACIVATE_CLOSE_PAIRS 1 /* set to 1 to test for closeness to other particles */
#define DEACIVATE_CLOSE_PAIRS 0 /* set to 1 to test for closeness to other particles */
#define PAIR_SAFETY_FACTOR 1.2 /* distance to deactivate divided by sum of radii */
#define THIRD_TYPE_PROPORTION 1.0 /* proportion of third type pairings, for certain pairing types */
#define KSPRING_PAIRS 5.0e10 /* spring constant for pair interaction */
#define KSPRING_PAIRS 5.0e9 /* spring constant for pair interaction */
#define KTORQUE_PAIRS 1.0e10 /* constant for angular coupling in pair interaction */
#define KTORQUE_PAIR_ANGLE 0.0 /* constant for coupling between orientation in pairs */
#define NPARTNERS 4 /* number of partners of particles - for DNA, set NPARTNERS_DNA */
#define NPARTNERS 1 /* number of partners of particles - for DNA, set NPARTNERS_DNA */
#define NPARTNERS_DNA 8 /* number of partners of particles, case of DNA, should be at least 8 */
#define NARMS 5 /* number of "arms" for certain paring types */
#define PAIRING_TYPE 9 /* type of pairing, see POLY_ in global_ljones.c */
#define PAIRING_TYPE 99 /* type of pairing, see POLY_ in global_ljones.c */
#define PARTNER_ANGLE 104.45 /* angle (in degrees) between ions for POLY_WATER case */
#define PAIR_DRATIO 1.1 /* ratio between equilibrium distance and radius (default: 1.0) */
#define PAIR_DRATIO 1.0 /* ratio between equilibrium distance and radius (default: 1.0) */
#define MU_C 0.035 /* radius of partner particle */
#define PARTICLE_MASS_C 2.0 /* mass or partner particle */
#define CHARGE_C 1.0 /* charge of partner particle */
@ -553,7 +571,7 @@
#define SECONDARY_PAIRING 0 /* set to 1 to pair with secondary partners, experimental */
#define DNA_RIGIDITY 0.5 /* controls rigidity for POLY_DNA_DOUBLE pairs, default = 1 */
#define PAIR_TYPEB_PARTICLES 1 /* set to 1 to pair particle of type 1 */
#define PAIR_TYPEB_PARTICLES 0 /* set to 1 to pair particle of type 1 */
#define NPARTNERS_B 5 /* number of partners of particles */
#define NARMS_B 1 /* number of "arms" for certain paring types */
#define PAIRING_TYPE_B 81 /* type of pairing, see POLY_ in global_ljones.c */
@ -591,7 +609,7 @@
#define COMPUTE_EMEAN ((PLOT == P_EMEAN)||(PLOT_B == P_EMEAN)||(PLOT == P_LOG_EMEAN)||(PLOT_B == P_LOG_EMEAN)||(PLOT == P_DIRECT_EMEAN)||(PLOT_B == P_DIRECT_EMEAN)||(PLOT == P_EMEAN_DENSITY)||(PLOT_B == P_EMEAN_DENSITY))
#define COMPUTE_DIRMEAN ((PLOT == P_DIRECT_EMEAN)||(PLOT_B == P_DIRECT_EMEAN))
#define COUNT_PARTNER_TYPE ((RD_REACTION == CHEM_H2O_H_OH)||(RD_REACTION == CHEM_2H2O_H3O_OH))
#define PAIR_FORCE ((PAIR_PARTICLES)||((REACTION_DIFFUSION)&&((RD_REACTION == CHEM_AGGREGATION)||(RD_REACTION == CHEM_AGGREGATION_CHARGE)||(RD_REACTION == CHEM_AGGREGATION_NNEIGH)||(RD_REACTION == CHEM_POLYGON_AGGREGATION))))
#define PAIR_FORCE ((PAIR_PARTICLES)||((REACTION_DIFFUSION)&&((RD_REACTION == CHEM_AGGREGATION)||(RD_REACTION == CHEM_AGGREGATION_CHARGE)||(RD_REACTION == CHEM_AGGREGATION_CHARGE_NOTRIANGLE)||(RD_REACTION == CHEM_AGGREGATION_NNEIGH)||(RD_REACTION == CHEM_POLYGON_AGGREGATION))))
#define COMPUTE_PAIR_TORQUE (KTORQUE_PAIR_ANGLE != 0.0)
#define ADD_CONVEYOR_FORCE ((ADD_FIXED_SEGMENTS)&&((SEGMENT_PATTERN == S_CONVEYOR_BELT)||(SEGMENT_PATTERN == S_TWO_CONVEYOR_BELTS)||(SEGMENT_PATTERN == S_PERIODIC_CONVEYORS)||(SEGMENT_PATTERN == S_TEST_CONVEYORS)||(SEGMENT_PATTERN == S_CONVEYOR_SHOVELS)||(SEGMENT_PATTERN == S_CONVEYOR_MIXED)||(SEGMENT_PATTERN == S_CONVEYOR_SIEVE)||(SEGMENT_PATTERN == S_CONVEYOR_SIEVE_B)||(SEGMENT_PATTERN == S_CONVEYOR_SIEVE_LONG)||(SEGMENT_PATTERN == S_CONVEYORS_1400)))
#define MOVE_CONVEYOR_BELT ((ADD_FIXED_SEGMENTS)&&((SEGMENT_PATTERN == S_CONVEYOR_SHOVELS)||(SEGMENT_PATTERN == S_CONVEYOR_MIXED)||(SEGMENT_PATTERN == S_CONVEYOR_SIEVE_LONG)||(SEGMENT_PATTERN == S_CONVEYORS_1400)))
@ -647,22 +665,6 @@ double repel_schedule(int i)
}
double efield_schedule(int i)
{
static double efactor;
static int first = 1;
double efield;
if (first)
{
efactor = EFIELD_FACTOR/(double)(NSTEPS);
first = 0;
}
if (i < INITIAL_TIME) efield = EFIELD;
else efield = EFIELD*(double)(i-INITIAL_TIME)*efactor;
printf("E = %.3lg\n", efield);
return(efield);
}
double bfield_schedule(int i)
@ -1141,7 +1143,7 @@ double evolve_particles(t_particle particle[NMAXCIRCLES], t_obstacle obstacle[NM
// particle[j].vy = py[j] + 0.5*DT_PARTICLE*particle[j].fy;
// particle[j].omega = pangle[j] + 0.5*DT_PARTICLE*particle[j].torque;
/* TO DO: move this to function wrap_particle */
/* TO DO: move this to function wrap_particle ? */
if ((BOUNDARY_COND == BC_PERIODIC_CIRCLE)||(BOUNDARY_COND == BC_PERIODIC_FUNNEL)||(BOUNDARY_COND == BC_PERIODIC_TRIANGLE))
{
// if (particle[j].xc < BCXMIN)
@ -1184,18 +1186,24 @@ double evolve_particles(t_particle particle[NMAXCIRCLES], t_obstacle obstacle[NM
}
double evolve_clusters(t_particle particle[NMAXCIRCLES], t_cluster cluster[NMAXCIRCLES],
t_molecule molecule[NMAXCIRCLES],
t_obstacle obstacle[NMAXOBSTACLES],
t_hashgrid hashgrid[HASHX*HASHY],
double cqx[NMAXCIRCLES], double cqy[NMAXCIRCLES], double cqangle[NMAXCIRCLES],
double cpx[NMAXCIRCLES], double cpy[NMAXCIRCLES], double cpangle[NMAXCIRCLES],
double px[NMAXCIRCLES], double py[NMAXCIRCLES],
double beta, int *nactive, int *nsuccess, int *nmove, int *ncoupled, int initial_phase, int verbose)
{
double a, totalenergy = 0.0, damping, direction, dmean, newx, newy, newangle, deltax, deltay, deltaangle;
static double b = 0.25*SIGMA*SIGMA*DT_PARTICLE/MU_XI, xi = 0.0;
int j, move, ncoup;
int j, k, move, ncoup, mol, cl;
short int moved[NMAXCIRCLES];
if (initial_phase) damping = INITIAL_DAMPING;
else damping = DAMPING;
// printf("1-Cluster 110 is at (%.5lg, %.5lg)\n", cluster[110].xg, cluster[110].yg);
#pragma omp parallel for private(j,xi,totalenergy,a,move)
for (j=0; j<ncircles; j++) if (cluster[j].active)
{
@ -1209,6 +1217,8 @@ double evolve_clusters(t_particle particle[NMAXCIRCLES], t_cluster cluster[NMAXC
cluster[j].energy = (cpx[j]*cpx[j] + cpy[j]*cpy[j])*cluster[j].mass_inv;
// if (j == 110) printf("2-Cluster 110 is at (%.3lg, %.3lg)\n", cluster[110].xg, cluster[110].yg);
if (COMPUTE_EMEAN)
cluster[j].emean = ERATIO*cluster[j].emean + (1.0-ERATIO)*cluster[j].energy;
@ -1221,6 +1231,11 @@ double evolve_clusters(t_particle particle[NMAXCIRCLES], t_cluster cluster[NMAXC
cluster[j].dirmean = DRATIO*dmean + (1.0-DRATIO)*direction;
if (cluster[j].dirmean < 0.0) cluster[j].dirmean += DPI;
else if (cluster[j].dirmean > DPI) cluster[j].dirmean -= DPI;
// printf("dirmean = %.3lg\n", cluster[j].dirmean);
for (k=0; k<cluster[j].nparticles; k++)
particle[cluster[j].particle[k]].dirmean = cluster[j].dirmean;
}
if ((COUPLE_ANGLE_TO_THERMOSTAT)&&(cluster[j].thermostat))
@ -1283,13 +1298,23 @@ double evolve_clusters(t_particle particle[NMAXCIRCLES], t_cluster cluster[NMAXC
newy = cqy[j] + 0.5*DT_PARTICLE*cpy[j]*cluster[j].mass_inv;
newangle = cqangle[j] + 0.5*DT_PARTICLE*cpangle[j]*cluster[j].inertia_moment_inv;
// if (j == 110)
// {
// printf("3-Cluster 110 is at (%.5lg, %.5lg)\n", cluster[110].xg, cluster[110].yg);
// printf("newy = %.3lg\n", newy);
// }
deltax = newx - cluster[j].xg;
deltay = newy - cluster[j].yg;
deltaangle = newangle - cluster[j].angle;
// if (j == 110) printf("deltay = %.5lg\n", deltay);
// translate_cluster(j, cluster, particle, deltax, deltay, 0);
// rotate_cluster(j, cluster, particle, deltaangle);
translate_and_rotate_cluster(j, cluster, particle, deltax, deltay, deltaangle);
translate_and_rotate_cluster(j, cluster, particle, deltax, deltay, deltaangle, 1, 0);
// translate_molecule(j, molecule, particle, deltax, deltay);
// if (j == 110) printf("4-Cluster 110 is at (%.5lg, %.5lg)\n", cluster[110].xg, cluster[110].yg);
// cluster[j].vx = cpx[j] + 0.5*DT_PARTICLE*cluster[j].fx;
// cluster[j].vy = cpy[j] + 0.5*DT_PARTICLE*cluster[j].fy;
@ -1308,7 +1333,16 @@ double evolve_clusters(t_particle particle[NMAXCIRCLES], t_cluster cluster[NMAXC
}
// sleep(1);
/* TODO: adapt to other boundary conditions */
// if (BOUNDARY_COND == BC_PERIODIC)
move = wrap_particles(particle, molecule, cluster);
if (move > 0)
{
compute_relative_positions(particle, hashgrid);
update_hashgrid(particle, obstacle, hashgrid, 0); /* REDUNDANT ? */
}
*ncoupled = ncoup;
return(totalenergy);
}
@ -1613,7 +1647,7 @@ void evolve_obstacles(t_obstacle obstacle[NMAXOBSTACLES])
/* evolve obstacles, for option OSCILLATE_OBSTACLES */
{
int i, j, n, m;
double dist, accel, ekin, epot, etot;
double dist, accel, ekin, epot, etot, shiftx, shifty;
// printf("Evolving %i obstacles\n", nobstacles);
/* Verlet scheme */
@ -1631,7 +1665,9 @@ void evolve_obstacles(t_obstacle obstacle[NMAXOBSTACLES])
{
m = obstacle[i].neighb[j];
// printf("Neighbour %i is number %i\n", j, m);
dist = module2(obstacle[i].xc - obstacle[m].xc, obstacle[i].yc - obstacle[m].yc);
shiftx = -(XMAX-XMIN)*(double)obstacle[i].shiftx[j];
shifty = -(YMAX-YMIN)*(double)obstacle[i].shifty[j];
dist = module2(obstacle[i].xc - obstacle[m].xc - shiftx, obstacle[i].yc - obstacle[m].yc - shifty);
/* test */
// if (dist > 4.0*OBSTACLE_COUPLING_DIST) dist = 4.0*OBSTACLE_COUPLING_DIST;
if (dist > 5.0*obstacle[i].eqdist[j]) dist = 5.0*obstacle[i].eqdist[j];
@ -1654,6 +1690,12 @@ void evolve_obstacles(t_obstacle obstacle[NMAXOBSTACLES])
obstacle[i].vy -= DT_PARTICLE*KSPRING_OBSTACLE_OSC*(obstacle[i].yc - obstacle[i].yc0)/obstacle[i].mass;
obstacle[i].energy += KSPRING_OBSTACLE_OSC*((obstacle[i].xc - obstacle[i].xc0)*(obstacle[i].xc - obstacle[i].xc0) + (obstacle[i].yc - obstacle[i].yc0)*(obstacle[i].yc - obstacle[i].yc0));
}
if ((OBSTACLE_DAMPING > 0.0)&&(obstacle[i].damped))
{
obstacle[i].vx *= exp(- DT_PARTICLE*OBSTACLE_DAMPING);
obstacle[i].vy *= exp(- DT_PARTICLE*OBSTACLE_DAMPING);
}
}
for (i = 0; i < nobstacles; i++)
{
@ -1683,6 +1725,8 @@ void evolve_obstacles(t_obstacle obstacle[NMAXOBSTACLES])
obstacle[i].energy = etot;
}
}
/* TODO: wrap obstacles */
// printf("Evolved %i obstacles\n", nobstacles);
}
@ -1690,7 +1734,7 @@ void animation()
{
double time, scale, diss, rgb[3], dissip, gradient[2], x, y, dx, dy, dt, xleft, xright,
a, b, length, fx, fy, force[2], totalenergy = 0.0, pos[2], prop, vx, xi = 0.0, torque, torque_ij, pleft = 0.0, pright = 0.0, entropy[2], speed_ratio, xmin, xmax, ymin, ymax, delta_energy, speed, ratio = 1.0, ratioc, cum_etot = 0.0, emean = 0.0, radius_ratio, t, angle, theta, sum, alpha, bfield, track_x0, track_y0, efield, efieldy;
double *qx, *qy, *px, *py, *qangle, *pangle, *pressure, *obstacle_speeds;
double *qx, *qy, *px, *py, *qangle, *pangle, *pressure, *obstacle_speeds, *currents;
double *cqx, *cqy, *cpx, *cpy, *cqangle, *cpangle;
int i, j, k, n, m, s, ij[2], i0, iplus, iminus, j0, jplus, jminus, p, q, p1, q1, p2, q2, total_neighbours = 0, cl,
min_nb, max_nb, close, wrapx = 0, wrapy = 0, nadd_particle = 0, nmove = 0, nsuccess = 0,
@ -1816,7 +1860,8 @@ void animation()
if (PLOT_SPEEDS) obstacle_speeds = (double *)malloc(2*ngroups*(INITIAL_TIME + NSTEPS)*sizeof(double));
if (PLOT_PARTICLE_NUMBER)
particle_numbers = (int *)malloc((NSTEPS+1)*(RD_TYPES+1)*sizeof(int));
if (PLOT_CURRENTS)
currents = (double *)malloc((INITIAL_TIME + NSTEPS)*sizeof(double));
printf("Initializing configuration\n");
@ -1824,6 +1869,7 @@ void animation()
params.nactive = initialize_configuration(particle, hashgrid, obstacle, px, py, pangle, tracer_n, segment, molecule);
printf("%i active particles\n", params.nactive);
printf("%i tracers\n", n_tracers);
if (CLUSTER_PARTICLES) init_cluster_config(particle, cluster);
@ -1856,7 +1902,7 @@ void animation()
if (INCREASE_KREPEL) params.krepel = repel_schedule(i);
if (INCREASE_BETA) params.beta = temperature_schedule(i);
if (INCREASE_E) params.efield = efield_schedule(i);
if ((INCREASE_E)||(OSCILLATE_E)) params.efield = efield_schedule(i);
else params.efield = EFIELD;
if (INCREASE_B) params.bfield = bfield_schedule(i);
else params.bfield = BFIELD;
@ -2072,7 +2118,8 @@ void animation()
/* add electric force */
if (ADD_EFIELD)
{
if (INCREASE_E) particle[j].fx += params.efield*particle[j].charge;
if ((INCREASE_E)||(OSCILLATE_E))
particle[j].fx += params.efield*particle[j].charge;
else
{
efield = EFIELD;
@ -2120,7 +2167,7 @@ void animation()
/* timestep of thermostat algorithm */
if (CLUSTER_PARTICLES)
{
totalenergy = evolve_clusters(particle, cluster, hashgrid, cqx, cqy, cqangle, cpx, cpy, cpangle, params.beta, &params.nactive, &nsuccess, &nmove, &ncoupled, i < INITIAL_TIME, n == 0);
totalenergy = evolve_clusters(particle, cluster, molecule, obstacle, hashgrid, cqx, cqy, cqangle, cpx, cpy, cpangle, px, py, params.beta, &params.nactive, &nsuccess, &nmove, &ncoupled, i < INITIAL_TIME, n == 0);
/* FIXME: update particle data */
for (j=0; j<ncircles; j++)
@ -2345,7 +2392,7 @@ void animation()
blank();
/* case of reaction-diffusion equation */
if ((i > INITIAL_TIME)&&(REACTION_DIFFUSION))
if ((i > INITIAL_TIME)&&(REACTION_DIFFUSION)&&(i < REACTION_MAX_TIME))
{
ncollisions = update_types(particle, molecule, cluster, collisions, ncollisions, particle_numbers, i - INITIAL_TIME - 1, &delta_energy);
if (EXOTHERMIC) params.beta *= 1.0/(1.0 + delta_energy/totalenergy);
@ -2383,7 +2430,7 @@ void animation()
nadd_particle = add_particles(particle, px, py, nadd_particle, 7, molecule, tracer_n);
}
else for (k=0; k<N_ADD_PARTICLES; k++)
nadd_particle = add_particles(particle, px, py, nadd_particle, 0, molecule, tracer_n);
nadd_particle = add_particles(particle, px, py, nadd_particle, 3, molecule, tracer_n);
// params.nactive = nadd_particle;
params.nactive = 0;
for (j=0; j<ncircles; j++) if (particle[j].active)
@ -2415,6 +2462,12 @@ void animation()
print_entropy(entropy);
}
if (PRINT_CURRENT)
{
params.current = compute_current(particle);
if (PLOT_CURRENTS) currents[i] = params.current;
}
/* these should be moved to draw_frame */
if (PRINT_SEGMENTS_SPEEDS)
{
@ -2426,7 +2479,7 @@ void animation()
count_particle_number(particle, particle_numbers, i - INITIAL_TIME);
draw_frame(i, PLOT, BG_COLOR, ncollisions, traj_position, traj_length,
wall, pressure, pleft, pright, particle_numbers, 1, params, particle, cluster,
wall, pressure, pleft, pright, currents, particle_numbers, 1, params, particle, cluster,
collisions, hashgrid, trajectory, obstacle, segment, group_speeds, segment_group, conveyor_belt, tracer_n, otriangle, ofacet);
if (!((NO_EXTRA_BUFFER_SWAP)&&(MOVIE))) glutSwapBuffers();
@ -2458,7 +2511,7 @@ void animation()
if ((i >= INITIAL_TIME)&&(DOUBLE_MOVIE))
{
draw_frame(i, PLOT_B, BG_COLOR_B, ncollisions, traj_position, traj_length,
wall, pressure, pleft, pright, particle_numbers, 0, params, particle, cluster,
wall, pressure, pleft, pright, currents, particle_numbers, 0, params, particle, cluster,
collisions, hashgrid, trajectory, obstacle, segment, group_speeds, segment_group, conveyor_belt, tracer_n, otriangle, ofacet);
glutSwapBuffers();
save_frame_lj_counter(NSTEPS + MID_FRAMES + 1 + counter);
@ -2499,7 +2552,7 @@ void animation()
{
blank();
draw_frame(NSTEPS, PLOT, BG_COLOR, ncollisions, traj_position, traj_length,
wall, pressure, pleft, pright, particle_numbers, 0, params, particle, cluster,
wall, pressure, pleft, pright, currents, particle_numbers, 0, params, particle, cluster,
collisions, hashgrid, trajectory, obstacle, segment, group_speeds, segment_group, conveyor_belt, tracer_n, otriangle, ofacet);
}
if (DOUBLE_MOVIE) for (i=0; i<MID_FRAMES; i++)
@ -2511,7 +2564,7 @@ void animation()
if (DOUBLE_MOVIE)
{
draw_frame(NSTEPS, PLOT_B, BG_COLOR_B, ncollisions, traj_position, traj_length,
wall, pressure, pleft, pright, particle_numbers, 0, params, particle, cluster,
wall, pressure, pleft, pright, currents, particle_numbers, 0, params, particle, cluster,
collisions, hashgrid, trajectory, obstacle, segment, group_speeds, segment_group, conveyor_belt, tracer_n, otriangle, ofacet);
if (!((NO_EXTRA_BUFFER_SWAP)&&(MOVIE))) glutSwapBuffers();
}
@ -2554,6 +2607,7 @@ void animation()
// printf("7\n");
if (PLOT_PARTICLE_NUMBER) free(particle_numbers);
// printf("8\n");
if (PLOT_CURRENTS) free(currents);
free(hashgrid);
// printf("9\n");
free(qx);

View File

@ -176,6 +176,7 @@
#define SCALE 0 /* set to 1 to adjust color scheme to variance of field */
#define SLOPE 1.0 /* sensitivity of color on wave amplitude */
#define COLOR_RANGE 1.0 /* max range of color (default: 1.0) */
#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 */
@ -266,6 +267,9 @@
#define VERTICAL_WAVE_PROFILE 0 /* set to 1 to draw wave profile vertically */
#define DRAW_WAVE_TIMESERIES 0 /* set to 1 to draw a time series of the wave */
#define WALL_WIDTH 0.1 /* width of wall separating lenses */
#define WALL_WIDTH_B 0.01 /* width of wall separating lenses */
#define WALL_WIDTH_ASYM 0.75 /* asymmetry of wall width (D_CIRCLE_LATTICE_NONISO) */
#define WALL_WIDTH_ASYM_B 0.75 /* asymmetry of wall width (D_CIRCLE_LATTICE_HEX_NONISO) */
#define PDISC_CONNECT_FACTOR 1.5 /* controls which discs are connected for D_CIRCLE_LATTICE_POISSON domain */
#define WALL_WIDTH_RND 0.0 /* proportion of width of width for random arrangements */
#define OSCIL_YMAX 0.35 /* defines oscillation range */

300
rde.c
View File

@ -32,7 +32,7 @@
#include <math.h>
#include <string.h>
#include <GL/glut.h>
#include <GL/glu.h>
#include <GL/glu.h>
#include <unistd.h>
#include <sys/types.h>
#include <tiffio.h> /* Sam Leffler's libtiff library. */
@ -49,9 +49,9 @@
// #define WINWIDTH 1920 /* window width */
#define WINWIDTH 1150 /* window width */
#define WINHEIGHT 1150 /* window height */
// #define NX 960 /* number of grid points on x axis */
#define NX 574 /* number of grid points on x axis */
#define NY 574 /* number of grid points on y axis */
// #define NX 720 /* number of grid points on x axis */
#define NX 432 /* number of grid points on x axis */
#define NY 432 /* number of grid points on y axis */
#define HRES 1 /* factor for high resolution plots */
// #define XMIN -2.0
@ -63,20 +63,20 @@
/* Choice of simulated equation */
#define RDE_EQUATION 9 /* choice of reaction term, see list in global_3d.c */
#define NFIELDS 1 /* number of fields in reaction-diffusion equation */
#define NLAPLACIANS 0 /* number of fields for which to compute Laplacian */
#define RDE_EQUATION 10 /* choice of reaction term, see list in global_3d.c */
#define NFIELDS 2 /* number of fields in reaction-diffusion equation */
#define NLAPLACIANS 2 /* number of fields for which to compute Laplacian */
#define SPHERE 0 /* set to 1 to simulate equation on sphere */
#define DPOLE 0 /* safety distance to poles */
#define DPOLE 1 /* safety distance to poles */
#define DSMOOTH 1 /* size of neighbourhood of poles that are smoothed */
#define SMOOTHPOLE 0.01 /* smoothing coefficient at poles */
#define SMOOTHPOLE 0.00 /* smoothing coefficient at poles */
#define SMOOTHCOTPOLE 0.05 /* smoothing coefficient of cotangent at poles */
#define PHISHIFT 0.0 /* shift of phi in 2D plot (in degrees) */
#define SMOOTHBLOCKS 0 /* set to 1 to use blocks of points near the poles */
#define BLOCKDIST 0 /* distance to poles where points are blocked */
#define BLOCKDIST 16 /* distance to poles where points are blocked */
#define ZERO_MERIDIAN 0.0 /* choice of zero meridian (will be at left/right boundary of 2d plot) */
#define POLE_NODRAW 2 /* distance around poles where wave is not drawn */
#define POLE_NODRAW 3 /* distance around poles where wave is not drawn */
#define ADD_POTENTIAL 0 /* set to 1 to add a potential (for Schrodinger equation) */
#define ADD_MAGNETIC_FIELD 0 /* set to 1 to add a magnetic field (for Schrodinger equation) - then set POTENTIAL 1 */
@ -123,7 +123,10 @@
#define NGRIDY 8 /* number of grid point for grid of disks */
#define REVERSE_TESLA_VALVE 1 /* set to 1 to orient Tesla valve in blocking configuration */
#define WALL_WIDTH 0.05 /* width of wall separating lenses */
#define WALL_WIDTH_RND 0.0 /* proportion of width of width for some random arrangements */
#define WALL_WIDTH_B 0.05 /* width of wall separating lenses */
#define WALL_WIDTH_RND 0.0 /* proportion of width of width for some random arrangements */
#define WALL_WIDTH_ASYM 0.5 /* proportion of width of width for some arrangements */
#define WALL_WIDTH_ASYM_B 1.5 /* asymmetry of wall width (D_CIRCLE_LATTICE_HEX_NONISO) */
#define RADIUS_FACTOR 0.3 /* controls inner radius for C_RING arrangements */
#define X_SHOOTER -0.2
@ -142,7 +145,8 @@
/* Physical parameters of wave equation */
#define DT 0.00000025
#define DT 0.000003
// #define DT 0.00000025
#define VISCOSITY 0.02
#define POISSON_STIFFNESS 1.0 /* stiffness of Poisson equation solver for incompressible Euler */
@ -159,9 +163,15 @@
#define FHNC -0.01 /* parameter in FHN equation */
#define K_HARMONIC 1.0 /* spring constant of harmonic potential */
#define K_COULOMB 0.5 /* constant in Coulomb potential */
#define K_KURAMOTO 12.0 /* constant in Kuramoto model */
#define K_KURAMOTO 20.0 /* constant in Kuramoto model */
#define NU_KURAMOTO 0.0 /* viscosity in Kuramoto model */
#define OMEGA_KURAMOTO 0.02 /* frequency in Kuramoto model */
#define A_KS 0.15 /* coupling constant in Keller-Segel model */
#define C_KS 3.0 /* coupling constant in Keller-Segel model */
#define D_KSU 1.2 /* diffusion in Keller-Segel model */
#define D_KSV 0.75 /* diffusion in Keller-Segel model */
#define KS_RSCALE 0.001 /* scaling factor for reaction term of Keller-Segel model */
#define KS_UMAX 10.0 /* max value for u component of Keller-Segel model */
#define V_MAZE 0.4 /* potential in walls of maze */
#define BZQ 0.0008 /* parameter in BZ equation */
#define BZF 1.2 /* parameter in BZ equation */
@ -195,7 +205,7 @@
#define SPEED 0.0 /* speed of drift to the right */
#define ADD_NOISE 0 /* set to 1 to add noise, set to 2 to add noise in right half */
#define NOISE_INTENSITY 0.5 /* noise intensity */
#define NOISE_INTENSITY 0.025 /* noise intensity */
#define CHANGE_NOISE 0 /* set to 1 to increase noise intensity */
#define NOISE_FACTOR 40.0 /* factor by which to increase noise intensity */
#define NOISE_INITIAL_TIME 100 /* initial time during which noise remains constant */
@ -244,8 +254,8 @@
/* Parameters for length and speed of simulation */
#define NSTEPS 2300 /* number of frames of movie */
#define NVID 40 /* number of iterations between images displayed on screen */
#define NSTEPS 1800 /* number of frames of movie */
#define NVID 100 /* number of iterations between images displayed on screen */
#define ACCELERATION_FACTOR 1.0 /* factor by which to increase NVID in course of simulation */
#define DT_ACCELERATION_FACTOR 1.0 /* factor by which to increase time step in course of simulation */
#define MAX_DT 0.024 /* maximal value of integration step */
@ -263,14 +273,15 @@
/* Visualisation */
#define PLOT_3D 0 /* controls whether plot is 2D or 3D */
#define PLOT_3D 1 /* controls whether plot is 2D or 3D */
#define PLOT_SPHERE 0 /* draws fields on a sphere */
#define SIMULATION_GRID 1 /* type of simulation grid, for certain equations */
#define ROTATE_VIEW 1 /* set to 1 to rotate position of observer */
#define ROTATE_ANGLE 360.0 /* total angle of rotation during simulation */
#define SHADE_3D 0 /* set to 1 to change luminosity according to normal vector */
#define SHADE_3D 1 /* set to 1 to change luminosity according to normal vector */
#define SHADE_2D 0 /* set to 1 to change luminosity according to normal vector */
#define VIEWPOINT_TRAJ 1 /* type of viewpoint trajectory */
#define VIEWPOINT_TRAJ 0 /* type of viewpoint trajectory */
#define MAX_LATITUDE 45.0 /* maximal latitude for viewpoint trajectory VP_ORBIT2 */
#define DRAW_PERIODICISED 0 /* set to 1 to repeat wave periodically in x and y directions */
@ -278,13 +289,13 @@
/* Plot type - color scheme */
#define CPLOT 10
#define CPLOT_B 251
#define CPLOT 0
#define CPLOT_B 0
/* Plot type - height of 3D plot */
#define ZPLOT 10 /* z coordinate in 3D plot */
#define ZPLOT_B 71 /* z coordinate in second 3D plot */
#define ZPLOT 0 /* z coordinate in 3D plot */
#define ZPLOT_B 0 /* z coordinate in second 3D plot */
#define AMPLITUDE_HIGH_RES 1 /* set to 1 to increase resolution of P_3D_AMPLITUDE plot */
#define NON_DIRICHLET_BC 0 /* set to 1 to draw only facets in domain, if field is not zero on boundary */
@ -329,7 +340,7 @@
/* Color schemes, see list in global_pdes.c */
#define COLOR_PALETTE 10 /* Color palette, see list in global_pdes.c */
#define COLOR_PALETTE 11 /* Color palette, see list in global_pdes.c */
#define COLOR_PALETTE_B 11 /* Color palette, see list in global_pdes.c */
#define BLACK 1 /* black background */
@ -339,14 +350,15 @@
#define COLOR_SCHEME 3 /* choice of color scheme */
#define PHASE_SHIFT 0.0 /* phase shift of color scheme, in units of Pi (formerly COLOR_PHASE_SHIFT) */
#define PHASE_SHIFT 0.0 /* phase shift of color scheme, in units of Pi (formerly COLOR_PHASE_SHIFT) */
#define SCALE 0 /* set to 1 to adjust color scheme to variance of field */
#define SLOPE 1.0 /* sensitivity of color on wave amplitude */
#define VSHIFT_AMPLITUDE 0.0 /* additional shift for wave amplitude */
#define VSCALE_AMPLITUDE 0.01 /* additional scaling factor for color scheme P_3D_AMPLITUDE */
#define COLOR_RANGE 1.0 /* max range of color (default: 1.0) */
#define VSHIFT_AMPLITUDE -2.7 /* additional shift for wave amplitude */
#define VSCALE_AMPLITUDE 3.0 /* additional scaling factor for color scheme P_3D_AMPLITUDE */
#define ATTENUATION 0.0 /* exponential attenuation coefficient of contrast with time */
#define CURL_SCALE 0.000005 /* scaling factor for curl representation */
#define CURL_SCALE 1.25 /* scaling factor for curl representation */
#define RESCALE_COLOR_IN_CENTER 0 /* set to 1 to decrease color intentiy in the center (for wave escaping ring) */
#define SLOPE_SCHROD_LUM 10.0 /* sensitivity of luminosity on module, for color scheme Z_ARGUMENT */
#define MIN_SCHROD_LUM 0.1 /* minimal luminosity in color scheme Z_ARGUMENT*/
@ -355,7 +367,7 @@
#define PRESSURE_LOG_SHIFT -2.5 /* shift for color scheme Z_EULER_PRESSURE */
#define VSCALE_WATER_HEIGHT 15.0 /* vertical scaling of water height */
#define ADD_HEIGHT_CONSTANT -0.016 /* constant added to wave height */
#define SHADE_SCALE_2D 0.25 /* controls "depth" of 2D shading */
#define SHADE_SCALE_2D 0.1 /* controls "depth" of 2D shading (lower values increase depth) */
#define COLORHUE 260 /* initial hue of water color for scheme C_LUM */
#define COLORDRIFT 0.0 /* how much the color hue drifts during the whole simulation */
@ -373,10 +385,10 @@
#define SHIFT_DENSITY 1.0 /* shift for color scheme Z_EULER_DENSITY */
#define VSCALE_DENSITY 30.0 /* additional scaling factor for color scheme Z_EULER_DENSITY */
#define VSCALE_VORTICITY 0.1 /* additional scaling factor for color scheme Z_EULERC_VORTICITY */
#define VORTICITY_SHIFT 0.0 /* vertical shift of vorticity */
#define VORTICITY_SHIFT 0.25 /* vertical shift of vorticity */
#define ZSCALE_SPEED 300.0 /* additional scaling factor for z-coord Z_EULER_SPEED and Z_SWATER_SPEED */
#define ZSHIFT_SPEED 0.0 /* additional shift of z-coord Z_EULER_SPEED and Z_SWATER_SPEED */
#define ZSCALE_NORMGRADIENT -0.0001 /* vertical scaling for Z_NORM_GRADIENT */
#define ZSCALE_NORMGRADIENT 1.25 /* vertical scaling for Z_NORM_GRADIENT */
#define VSCALE_SWATER 100.0 /* additional scaling factor for color scheme Z_EULER_DENSITY */
#define NXMAZE 7 /* width of maze */
@ -387,10 +399,10 @@
#define MAZE_WIDTH 0.04 /* half width of maze walls */
#define DRAW_COLOR_SCHEME 0 /* set to 1 to plot the color scheme */
#define COLORBAR_RANGE 3.0 /* scale of color scheme bar */
#define COLORBAR_RANGE 2.5 /* scale of color scheme bar */
#define COLORBAR_RANGE_B 2.5 /* scale of color scheme bar for 2nd part */
#define ROTATE_COLOR_SCHEME 0 /* set to 1 to draw color scheme horizontally */
#define CIRC_COLORBAR 1 /* set to 1 to draw circular color scheme */
#define CIRC_COLORBAR 0 /* set to 1 to draw circular color scheme */
#define CIRC_COLORBAR_B 0 /* set to 1 to draw circular color scheme */
/* only for compatibility with wave_common.c */
@ -452,7 +464,7 @@ double u_3d[2] = {0.75, -0.45}; /* projections of basis vectors for REP_AXO_
double v_3d[2] = {-0.75, -0.45};
double w_3d[2] = {0.0, 0.015};
double light[3] = {0.40824829, -0.816496581, 0.40824829}; /* vector of "light" direction for P_3D_ANGLE color scheme */
double observer[3] = {0.0, -6.0, 2.5}; /* location of observer for REP_PROJ_3D representation */
double observer[3] = {-3.0, -3.0, 2.5}; /* location of observer for REP_PROJ_3D representation */
int reset_view = 0; /* switch to reset 3D view parameters (for option ROTATE_VIEW) */
/* constants for simulations on planets */
@ -467,19 +479,21 @@ int reset_view = 0; /* switch to reset 3D view parameters (for option RO
#define PLANET_SEALEVEL 0.0 /* sea level for flooded planet */
#define VENUS_NODATA_FACTOR 0.5 /* altitude to assign to DEM points without data (fraction of mean altitude) */
#define Z_SCALING_FACTOR 0.8 /* overall scaling factor of z axis for REP_PROJ_3D representation */
#define XY_SCALING_FACTOR 2.1 /* overall scaling factor for on-screen (x,y) coordinates after projection */
#define Z_SCALING_FACTOR 0.75 /* overall scaling factor of z axis for REP_PROJ_3D representation */
#define XY_SCALING_FACTOR 1.5 /* overall scaling factor for on-screen (x,y) coordinates after projection */
#define ZMAX_FACTOR 1.0 /* max value of z coordinate for REP_PROJ_3D representation */
#define XSHIFT_3D 0.0 /* overall x shift for REP_PROJ_3D representation */
#define YSHIFT_3D 0.0 /* overall y shift for REP_PROJ_3D representation */
#define XSHIFT_3D -0.0 /* overall x shift for REP_PROJ_3D representation */
#define YSHIFT_3D -0.5 /* overall y shift for REP_PROJ_3D representation */
#define BORDER_PADDING 0 /* distance from boundary at which to plot points, to avoid boundary effects due to gradient */
#define DRAW_ARROW 0 /* set to 1 to draw arrow above sphere */
#define ZMAX 3.0 /* maximal value of z coordinate */
#define ZMIN -3.0 /* maximal value of z coordinate */
#define RSCALE 0.005 /* scaling factor of radial component */
#define RSCALE 0.02 /* scaling factor of radial component */
#define RSCALE_B 1.00 /* experimental, additional radial scaling factor in ij_to_sphere */
#define RSHIFT 0.0 /* shift in radial component */
#define RMAX 10.0 /* max value of radial component */
#define RMIN 0.0 /* min value of radial component */
#define RMAX 4.0 /* max value of radial component */
#define RMIN 0.5 /* min value of radial component */
#define COS_VISIBLE -0.35 /* limit on cosine of normal to shown facets */
/* For debugging purposes only */
@ -489,7 +503,7 @@ int reset_view = 0; /* switch to reset 3D view parameters (for option RO
#define REFRESH_B (ZPLOT_B != ZPLOT)||(CPLOT_B != CPLOT) /* to save computing time, to be improved */
#define COMPUTE_WRAP_ANGLE ((WRAP_ANGLE)&&((cplot == Z_ANGLE_GRADIENT)||(cplot == Z_ANGLE_GRADIENTX)||(cplot == Z_ARGUMENT)||(cplot == Z_ANGLE_GRADIENTX)||(cplot == Z_EULER_DIRECTION_SPEED)||(cplot == Z_SWATER_DIRECTION_SPEED)))
#define COMPUTE_WRAP_ANGLE ((WRAP_ANGLE)&&((cplot == Z_ANGLE_GRADIENT)||(cplot == Z_ANGLE_GRADIENTX)||(cplot == Z_ARGUMENT)||(cplot == Z_ANGLE_GRADIENTX)||(cplot == Z_EULER_DIRECTION_SPEED)||(cplot == Z_SWATER_DIRECTION_SPEED)||(cplot == Z_ANGLE)))
#define PRINT_PARAMETERS ((PRINT_TIME)||(PRINT_VISCOSITY)||(PRINT_RPSLZB)||(PRINT_PROBABILITIES)||(PRINT_NOISE)||(PRINT_FLOW_SPEED)||(PRINT_AVERAGE_SPEED))
#define COMPUTE_PRESSURE ((ZPLOT == Z_EULER_PRESSURE)||(CPLOT == Z_EULER_PRESSURE)||(ZPLOT_B == Z_EULER_PRESSURE)||(CPLOT_B == Z_EULER_PRESSURE))
@ -1235,9 +1249,9 @@ void evolve_wave_half(double *phi_in[NFIELDS], double *phi_out[NFIELDS], short i
double gfield[2*NX*NY], t_rde rde[NX*NY], t_wave_sphere wsphere[NX*NY])
/* time step of field evolution */
{
int i, j, k, iplus, iminus, jplus, jminus, ropening, w;
double x, y, z, deltax, deltay, deltaz, rho, rhox, rhoy, pot, u, v, ux, uy, vx, vy, test = 0.0, dx, dy, xy[2], padding, a, eta, etax, etay, sum;
double *delta_phi[NLAPLACIANS], *nabla_phi, *nabla_psi, *nabla_omega, *delta_vorticity, *delta_pressure, *delta_p, *delta_u, *delta_v, *nabla_rho, *nabla_u, *nabla_v, *nabla_eta, *kuramoto_int;
int i, j, k, iplus, iminus, jplus, jminus, ropening, w, n;
double x, y, z, deltax, deltay, deltaz, rho, rhox, rhoy, pot, u, v, ux, uy, vx, vy, test = 0.0, dx, dy, xy[2], padding, a, eta, etax, etay, sum, phi0, chi;
double *delta_phi[NLAPLACIANS], *nabla_phi, *nabla_psi, *nabla_omega, *delta_vorticity, *delta_pressure, *delta_p, *delta_u, *delta_v, *nabla_rho, *nabla_u, *nabla_v, *nabla_eta, *kuramoto_int, *keller_segel_drift, *keller_segel_div;
// double u_bc[NY], v_bc[NY];
static double invsqr3 = 0.577350269; /* 1/sqrt(3) */
static int smooth = 0, y_channels, y_channels1, imin, imax, first = 1;
@ -1287,13 +1301,19 @@ double gfield[2*NX*NY], t_rde rde[NX*NY], t_wave_sphere wsphere[NX*NY])
}
first = 0;
}
/* smooth vector fields at poles */
if ((SPHERE)&&(!SMOOTHBLOCKS)) for (k=0; k<NFIELDS; k++) smooth_poles(phi_in[k]);
else for (k=0; k<NFIELDS; k++) block_poles(phi_in[k]);
// if ((SPHERE)&&(!SMOOTHBLOCKS)) for (k=0; k<NFIELDS; k++) smooth_poles(phi_in[k]);
// else for (k=0; k<NFIELDS; k++) block_poles(phi_in[k]);
if (SPHERE)
{
if (!SMOOTHBLOCKS) for (k=0; k<NFIELDS; k++) smooth_poles(phi_in[k]);
else for (k=0; k<NFIELDS; k++) block_poles(phi_in[k]);
}
for (i=0; i<NLAPLACIANS; i++) delta_phi[i] = (double *)malloc(NX*NY*sizeof(double));
if (COMPUTE_PRESSURE)
{
delta_pressure = (double *)malloc(NX*NY*sizeof(double));
@ -1320,8 +1340,8 @@ double gfield[2*NX*NY], t_rde rde[NX*NY], t_wave_sphere wsphere[NX*NY])
{
nabla_psi = (double *)malloc(2*NX*NY*sizeof(double));
nabla_omega = (double *)malloc(2*NX*NY*sizeof(double));
compute_gradient_euler(phi_in[0], nabla_psi, wsphere, EULER_GRADIENT_YSHIFT);
compute_gradient_euler(phi_in[1], nabla_omega, wsphere, 0.0);
compute_gradient_euler(phi_in[0], nabla_psi, rde, wsphere, EULER_GRADIENT_YSHIFT);
compute_gradient_euler(phi_in[1], nabla_omega, rde, wsphere, 0.0);
if (COMPUTE_PRESSURE) compute_pressure_laplacian(phi_in, delta_p);
@ -1392,8 +1412,38 @@ double gfield[2*NX*NY], t_rde rde[NX*NY], t_wave_sphere wsphere[NX*NY])
{
kuramoto_int = (double *)malloc(NX*NY*sizeof(double));
compute_kuramoto_interaction(phi_in[0], kuramoto_int, xy_in, wsphere);
break;
}
case (E_KURAMOTO_SPHERE):
{
kuramoto_int = (double *)malloc(NX*NY*sizeof(double));
compute_kuramoto_interaction_grid(phi_in[1], kuramoto_int, wsphere, ngridpoints);
break;
}
case (E_KELLER_SEGEL):
{
// keller_segel_drift = (double *)malloc(NX*NY*sizeof(double));
// keller_segel_div = (double *)malloc(NX*NY*sizeof(double));
nabla_psi = (double *)malloc(2*NX*NY*sizeof(double));
// compute_gradient_euler_test(phi_in[1], nabla_psi, xy_in, wsphere);
compute_gradient_euler_plane(phi_in[1], nabla_psi, rde, 0.0);
/* multiply gradient by chi */
#pragma omp parallel for private(i)
for (i=0; i<NX*NY; i++)
{
x = phi_in[0][i];
chi = C_KS*x*(1.0+x*x);
nabla_psi[i] *= chi;
nabla_psi[NX*NY + i] *= chi;
}
/* compute divergence */
// compute_divergence(nabla_psi, keller_segel_div, xy_in, wsphere);
compute_divergence_rde(nabla_psi, rde, xy_in, wsphere);
break;
}
default:
{
/* do nothing */
@ -1411,9 +1461,10 @@ double gfield[2*NX*NY], t_rde rde[NX*NY], t_wave_sphere wsphere[NX*NY])
}
#pragma omp parallel for private(i,j,k,x,y,z,deltax,deltay,deltaz,rho)
for (i=imin; i<imax; i++){
if (RDE_EQUATION != E_KURAMOTO_SPHERE)
{
#pragma omp parallel for private(i,j,k,x,y,z,deltax,deltay,deltaz,rho)
for (i=imin; i<imax; i++){
for (j=0; j<NY; j++){
if (xy_in[i*NY+j]) switch (RDE_EQUATION){
case (E_HEAT):
@ -1449,20 +1500,39 @@ double gfield[2*NX*NY], t_rde rde[NX*NY], t_wave_sphere wsphere[NX*NY])
}
else phi_out[0][i*NY+j] = x;
break;
// x = phi_in[0][i*NY+j];
// phi_out[0][i*NY+j] = phi_in[0][i*NY+j] + intstep*(K_KURAMOTO*kuramoto_int[i*NY+j] + OMEGA_KURAMOTO);
// if (phi_out[0][i*NY+j] > PI)
// {
// x = (phi_out[0][i*NY+j] + PI)/DPI;
// phi_out[0][i*NY+j] -= DPI*(double)((int)x);
// }
// else if (phi_out[0][i*NY+j] < -PI)
// {
// x = (-phi_out[0][i*NY+j] + PI)/DPI;
// phi_out[0][i*NY+j] += DPI*(double)((int)x);
// }
// break;
}
case (E_KELLER_SEGEL):
{
x = phi_in[0][i*NY+j];
y = phi_in[1][i*NY+j];
deltax = D_KSU*delta_phi[0][i*NY+j];
deltay = D_KSV*delta_phi[1][i*NY+j];
// phi_out[0][i*NY+j] = x + intstep*(deltax - keller_segel_div[i*NY+j] + KS_RSCALE*x*(1.0-x));
phi_out[0][i*NY+j] = x + intstep*(deltax - rde[i*NY+j].divergence + KS_RSCALE*x*(1.0-x));
if (phi_out[0][i*NY+j] > KS_UMAX) phi_out[0][i*NY+j] = KS_UMAX;
// if (phi_out[0][i*NY+j] < -1.0) phi_out[0][i*NY+j] = -1.0;
phi_out[1][i*NY+j] = y + intstep*(deltay + KS_RSCALE*(x - A_KS*y));
break;
}
// case (E_KURAMOTO_SPHERE):
// {
// x = K_KURAMOTO*kuramoto_int[i*NY+j] + OMEGA_KURAMOTO;
//
// x = phi_in[1][i*NY+j] + intstep*x;
// if (x > PI)
// {
// y = (x + PI)/DPI;
// phi_out[1][i*NY+j] = x - DPI*(double)((int)y);
// }
// else if (x < -PI)
// {
// y = (-x + PI)/DPI;
// phi_out[1][i*NY+j] = x + DPI*(double)((int)y);
// }
// else phi_out[1][i*NY+j] = x;
// break;
// }
case (E_CAHN_HILLIARD):
{
/* TO DO */
@ -1680,6 +1750,37 @@ double gfield[2*NX*NY], t_rde rde[NX*NY], t_wave_sphere wsphere[NX*NY])
}
}
}
}
if (RDE_EQUATION == E_KURAMOTO_SPHERE)
{
#pragma omp parallel for private(i,x)
for (i=0; i<ngridpoints; i++)
{
x = K_KURAMOTO*kuramoto_int[i] + OMEGA_KURAMOTO;
/* add an optional diffusion term */
if ((NU_KURAMOTO != 0.0)&&(NLAPLACIANS > 0))
x += NU_KURAMOTO*delta_phi[0][i*NY+j];
x = phi_in[1][i] + intstep*x;
if (x > PI)
{
y = (x + PI)/DPI;
phi_out[1][i] = x - DPI*(double)((int)y);
}
else if (x < -PI)
{
y = (-x + PI)/DPI;
phi_out[1][i] = x + DPI*(double)((int)y);
}
else phi_out[1][i] = x;
}
/* convert field 1 on simulation grid to field 0 on longitude_latitude grid */
convert_fields_from_grids(phi_out[1], phi_out[0], wsphere);
/* TEST */
// for (i=0; i<NX*NY; i++) rde[i].theta = phi_out[0][i];
}
/* in-flow/out-flow b.c. for incompressible Euler equation */
if (((RDE_EQUATION == E_EULER_INCOMP)||(RDE_EQUATION == E_EULER_COMP))&&(IN_OUT_FLOW_BC > 0))
@ -1711,27 +1812,45 @@ double gfield[2*NX*NY], t_rde rde[NX*NY], t_wave_sphere wsphere[NX*NY])
free(nabla_psi);
}
if (RDE_EQUATION == E_EULER_INCOMP)
{
free(nabla_psi);
free(nabla_omega);
}
else if (RDE_EQUATION == E_EULER_COMP)
{
free(nabla_rho);
}
else if (RDE_EQUATION == E_SHALLOW_WATER)
{
free(nabla_eta);
if (VISCOSITY > 0.0)
switch (RDE_EQUATION) {
case (E_EULER_INCOMP):
{
free(delta_u);
free(delta_v);
free(nabla_psi);
free(nabla_omega);
break;
}
case (E_EULER_COMP):
{
free(nabla_rho);
break;
}
case (E_SHALLOW_WATER):
{
free(nabla_eta);
if (VISCOSITY > 0.0)
{
free(delta_u);
free(delta_v);
}
break;
}
case (E_KURAMOTO):
{
free(kuramoto_int);
break;
}
case (E_KURAMOTO_SPHERE):
{
free(kuramoto_int);
break;
}
case (E_KELLER_SEGEL):
{
// free(keller_segel_drift);
// free(keller_segel_div);
free(nabla_psi);
break;
}
}
else if (RDE_EQUATION == E_KURAMOTO)
{
free(kuramoto_int);
}
if (COMPUTE_PRESSURE)
@ -2219,6 +2338,9 @@ void animation()
// if (ADD_TRACERS) tracers = (double *)malloc(2*NSTEPS*N_TRACERS*sizeof(double));
if (ADD_TRACERS) tracers = (double *)malloc(4*NSTEPS*N_TRACERS*sizeof(double));
if (RDE_EQUATION == E_KURAMOTO_SPHERE)
ngridpoints = initialize_simulation_grid_sphere(wsphere);
dx = (XMAX-XMIN)/((double)NX);
intstep = DT/(dx*dx);
@ -2296,7 +2418,8 @@ void animation()
// init_linear_blob_sphere(0, 1.3*PI, 0.65*PI, 0.0, 0.0, 0.3, 0.1, 0.1, SWATER_MIN_HEIGHT, phi, xy_in, wsphere);
init_random(0.0, 0.4, phi, xy_in, wsphere);
init_random(0.4, 0.4, phi, xy_in, wsphere);
// init_onefield_random(1, 0.2, 0.1, phi, xy_in, wsphere);
// init_random_smoothed(0.0, 0.4, phi, xy_in, wsphere);
// init_expanding_blob_sphere(0, (279.0/180.0)*PI, (115.0/180.0)*PI, 0.75, 0.04, 0.06, SWATER_MIN_HEIGHT, phi, xy_in, wsphere);
@ -2323,6 +2446,9 @@ void animation()
if (ADD_MOON_FORCING) compute_forcing_schedule(0, wsphere);
if (RDE_EQUATION == E_KURAMOTO_SPHERE)
convert_fields_from_grids(phi[1], phi[0], wsphere);
blank();
glColor3f(0.0, 0.0, 0.0);

View File

@ -142,6 +142,7 @@
#define SCALE 1 /* set to 1 to adjust color scheme to variance of field */
#define SLOPE 1.0 /* sensitivity of color on wave amplitude */
#define COLOR_RANGE 1.0 /* max range of color (default: 1.0) */
#define ATTENUATION 0.0 /* exponential attenuation coefficient of contrast with time */
#define PHASE_SHIFT 0.0 /* shift of phase in color scheme P_3D_PHASE */
#define E_SCALE 150.0 /* scaling factor for energy representation */
@ -202,6 +203,9 @@
#define DRAW_WAVE_PROFILE 0 /* set to 1 to draw a profile of the wave */
#define VERTICAL_WAVE_PROFILE 0 /* set to 1 to draw wave profile vertically */
#define WALL_WIDTH 0.1 /* width of wall separating lenses */
#define WALL_WIDTH_B 0.01 /* width of wall separating lenses */
#define WALL_WIDTH_ASYM 0.75 /* asymmetry of wall width (D_CIRCLE_LATTICE_NONISO) */
#define WALL_WIDTH_ASYM_B 0.75 /* asymmetry of wall width (D_CIRCLE_LATTICE_HEX_NONISO) */
#define PDISC_CONNECT_FACTOR 1.5 /* controls which discs are connected for D_CIRCLE_LATTICE_POISSON domain */
#define WALL_WIDTH_RND 0.0 /* proportion of width of width for random arrangements */
#define RADIUS_FACTOR 0.3 /* controls inner radius for C_RING arrangements */

1483
sub_lj.c

File diff suppressed because it is too large Load Diff

1737
sub_rde.c

File diff suppressed because it is too large Load Diff

2324
sub_wave.c

File diff suppressed because it is too large Load Diff

View File

@ -24,7 +24,8 @@ void init_wave_sphere_rde(t_wave_sphere *wsphere, int res)
printf("Initializing wsphere\n");
dphi = DPI/(double)(res*NX);
// dphi = DPI/(double)(res*NX);
dphi = DPI/(double)(res*NX-1);
dtheta = PI/(double)(res*NY);
// dtheta = PI/(double)(NY-2*(DPOLE));
// theta0 = (double)(DPOLE)*dtheta;
@ -2645,7 +2646,7 @@ void draw_color_scheme_palette_3d(double x1, double y1, double x2, double y2, in
void draw_circular_color_scheme_palette_3d(double x1, double y1, double radius, int plot, double min, double max, int palette, int fade, double fade_value)
{
int j, k, ij_center[2], ij_right[2], ic, jc, ir;
double x, y, dy, dy_e, dy_phase, rgb[3], value, lum, amp, dphi, pos[2], phi, xy[2], zscale = 0.95;
double x, y, dy, dy_e, dy_phase, rgb[3], value, lum, amp, dphi, pos[2], phi, xy[2], zscale = 1.0;
// printf("Drawing color bar\n");
@ -2684,6 +2685,15 @@ void draw_circular_color_scheme_palette_3d(double x1, double y1, double radius,
color_scheme_asym_palette(COLOR_SCHEME, palette, value, 1.0, 0, rgb);
break;
}
case (Z_ANGLE):
{
value = min + 1.0*dy*(double)(j);
amp = color_amplitude_linear(value, 1.0, 1)/PI;
while (amp > 1.0) amp -= 2.0;
while (amp < -1.0) amp += 2.0;
amp_to_rgb(0.5*(1.0 + amp), rgb);
break;
}
case (P_3D_AMP_ANGLE):
{
value = min + 1.0*dy*(double)(j);
@ -2766,6 +2776,12 @@ void draw_circular_color_scheme_palette_3d(double x1, double y1, double radius,
color_scheme_palette(C_ONEDIM_LINEAR, palette, value, 1.0, 1, rgb);
break;
}
case (Z_ANGLE_GRADIENT):
{
value = dy_phase*(double)(j);
color_scheme_palette(C_ONEDIM_LINEAR, palette, value, 1.0, 1, rgb);
break;
}
case (Z_EULER_DIRECTION):
{
value = dy_phase*(double)(j);

View File

@ -3,6 +3,7 @@
short int circletop[NMAXCIRCLES]; /* set to 1 if circle is in top half */
void init_circle_config_half(int pattern, int top, t_circle circles[NMAXCIRCLES])
/* initialise the arrays circlex, circley, circlerad and circleactive */
/* for billiard shape D_CIRCLES */
@ -479,7 +480,7 @@ void init_polygon_config_comp(t_polygon polygons[NMAXCIRCLES])
int xy_in_billiard_half(double x, double y, int domain, int pattern, int top)
/* returns 1 if (x,y) represents a point in the billiard */
{
double l2, r2, r2mu, omega, c, angle, z, x1, y1, x2, y2, u, v, u1, v1, dx, dy, width, a, b;
double l2, r2, r2mu, omega, c, angle, z, x1, y1, x2, y2, u, v, u1, v1, dx, dy, width, a, b, r, nx, ny;
int i, j, k, k1, k2, condition, type;
switch (domain) {
@ -591,6 +592,133 @@ int xy_in_billiard_half(double x, double y, int domain, int pattern, int top)
if (module2(x1 - b, y) > LAMBDA) return(1);
return(0);
}
case (D_CIRCLE_LATTICE):
{
dx = (XMAX - XMIN)/(double)NGRIDX;
dy = (YMAX - YMIN)/(double)NGRIDY;
if (top)
{
for (i=0; i<NGRIDX; i++)
{
x1 = XMIN + ((double)i + 0.5)*dx;
if (vabs(x - x1) < WALL_WIDTH) return(1);
for (j=NGRIDY/2; j<NGRIDY; j++)
{
y1 = YMIN + ((double)j + 0.5)*dy;
r = module2(x-x1, y-y1);
if (r < MU) return(1);
if (vabs(y - y1) < WALL_WIDTH) return(1);
}
}
return(0);
}
else
{
for (i=0; i<NGRIDX; i++)
{
x1 = XMIN + ((double)i + 0.5)*dx;
if (vabs(x - x1) < WALL_WIDTH_B) return(1);
for (j=0; j<NGRIDY/2; j++)
{
y1 = YMIN + ((double)j + 0.5)*dy;
r = module2(x-x1, y-y1);
if (r < MU_B) return(1);
if (vabs(y - y1) < WALL_WIDTH_B) return(1);
}
}
return(0);
}
return(0);
}
case (D_CIRCLE_LATTICE_HEX):
{
dx = (XMAX - XMIN)/(double)NGRIDX;
dy = (YMAX - YMIN)/(double)NGRIDY;
r = module2(0.5*dx, dy);
nx = -dy/r;
ny = dx/(2.0*r);
if (top)
{
// printf("xy_in_billiard_half\n");
for (j=0; j<NGRIDY+1; j++)
{
y1 = YMIN + ((double)j)*dy;
if (vabs(y - y1) < WALL_WIDTH) return(1);
for (i=-1; i<NGRIDX; i++)
{
x1 = XMIN + ((double)i + 0.5)*dx;
if (j%2 == 0) x1 += 0.5*dx;
r = module2(x-x1, y-y1);
// printf("r = %.3lg\n", r);
if (r < MU) return(1);
if (vabs(nx*(x - x1) + ny*(y - y1)) < WALL_WIDTH) return(1);
if (vabs(-nx*(x - x1) + ny*(y - y1)) < WALL_WIDTH) return(1);
}
}
}
else
{
for (j=0; j<NGRIDY+1; j++)
{
y1 = YMIN + ((double)j)*dy;
if (vabs(y - y1) < WALL_WIDTH_B) return(1);
for (i=-1; i<NGRIDX; i++)
{
x1 = XMIN + ((double)i + 0.5)*dx;
if (j%2 == 0) x1 += 0.5*dx;
r = module2(x-x1, y-y1);
if (r < MU_B) return(1);
if (vabs(nx*(x - x1) + ny*(y - y1)) < WALL_WIDTH_B) return(1);
if (vabs(-nx*(x - x1) + ny*(y - y1)) < WALL_WIDTH_B) return(1);
}
}
}
return(0);
}
case (D_CIRCLE_LATTICE_STRIP):
{
if (x > LAMBDA) return(1);
if (x < -LAMBDA) return(1);
dx = 2.0*LAMBDA/(double)NGRIDX;
dy = (YMAX - YMIN)/(double)NGRIDY;
for (i=0; i<NGRIDX + 1; i++)
{
x1 = -LAMBDA + ((double)i)*dx;
if (vabs(x - x1) < WALL_WIDTH*WALL_WIDTH_ASYM) return(1);
for (j=0; j<NGRIDY; j++)
{
y1 = YMIN + ((double)j + 0.5)*dy;
r = module2(x-x1, y-y1);
if (r < MU) return(1);
if (vabs(y - y1) < WALL_WIDTH) return(1);
}
}
return(0);
}
case (D_CIRCLE_LATTICE_HEX_STRIP):
{
if (vabs(x) > LAMBDA) return(1);
dx = 2.0*LAMBDA/(double)NGRIDX;
dy = (YMAX - YMIN)/(double)NGRIDY;
r = module2(0.5*dx, dy);
nx = -dy/r;
ny = dx/(2.0*r);
for (j=0; j<NGRIDY+1; j++)
{
y1 = YMIN + ((double)j)*dy;
if (vabs(y - y1) < WALL_WIDTH) return(1);
for (i=-1; i<NGRIDX; i++)
{
x1 = -LAMBDA + ((double)i + 0.5)*dx;
if (j%2 == 0) x1 += 0.5*dx;
r = module2(x-x1, y-y1);
if (r < MU) return(1);
if (vabs(nx*(x - x1) + ny*(y - y1)) < WALL_WIDTH*WALL_WIDTH_ASYM) return(1);
if (vabs(-nx*(x - x1) + ny*(y - y1)) < WALL_WIDTH*WALL_WIDTH_ASYM_B) return(1);
}
}
return(0);
}
default:
{
printf("Function ij_in_billiard not defined for this billiard \n");
@ -628,9 +756,13 @@ void draw_billiard_half(int domain, int pattern, int top, int fade, double fade_
static int first = 1;
glEnable(GL_SCISSOR_TEST);
if (top) glScissor(0.0, YMID, NX, YMID);
// if (top) glScissor(0.0, YMID, NX, YMID);
// if (top) glScissor(0.0, YMID, NX, YMAX);
else glScissor(0.0, 0.0, NX, YMID);
// else glScissor(0.0, 0.0, NX, YMID);
if (top) glScissor(0.0, YMID/(HIGHRES+1), NX, YMID/(HIGHRES+1));
// if (top) glScissor(0.0, YMID, NX, YMAX);
else glScissor(0.0, 0.0, NX, YMID/(HIGHRES+1));
if (fade)
{
@ -642,7 +774,7 @@ void draw_billiard_half(int domain, int pattern, int top, int fade, double fade_
if (BLACK) glColor3f(1.0, 1.0, 1.0);
else glColor3f(0.0, 0.0, 0.0);
}
glLineWidth(5);
glLineWidth(BOUNDARY_WIDTH);
if (top) signtop = 1.0;
else signtop = -1.0;
@ -818,6 +950,100 @@ void draw_billiard_half(int domain, int pattern, int top, int fade, double fade_
/* Do nothing */
break;
}
case (D_CIRCLE_LATTICE):
{
if (top)
{
glBegin(GL_LINES);
for (i=0; i<npolyline; i++)
{
glVertex2d(polyline[i].posi, polyline[i].posj);
}
glEnd();
for (i=0; i<npolyarc; i++)
{
draw_circle_arc(polyarc[i].xc, polyarc[i].yc, polyarc[i].r, polyarc[i].angle1, polyarc[i].dangle, NSEG);
}
}
else
{
glBegin(GL_LINES);
for (i=0; i<npolyline_b; i++)
{
glVertex2d(polyline_b[i].posi, polyline_b[i].posj);
}
glEnd();
for (i=0; i<npolyarc_b; i++)
{
draw_circle_arc(polyarc_b[i].xc, polyarc_b[i].yc, polyarc_b[i].r, polyarc_b[i].angle1, polyarc_b[i].dangle, NSEG);
}
}
break;
}
case (D_CIRCLE_LATTICE_HEX):
{
if (top)
{
glBegin(GL_LINES);
for (i=0; i<npolyline; i++)
{
glVertex2d(polyline[i].posi, polyline[i].posj);
}
glEnd();
for (i=0; i<npolyarc; i++)
{
draw_circle_arc(polyarc[i].xc, polyarc[i].yc, polyarc[i].r, polyarc[i].angle1, polyarc[i].dangle, NSEG);
}
}
else
{
glBegin(GL_LINES);
for (i=0; i<npolyline_b; i++)
{
glVertex2d(polyline_b[i].posi, polyline_b[i].posj);
}
glEnd();
for (i=0; i<npolyarc_b; i++)
{
draw_circle_arc(polyarc_b[i].xc, polyarc_b[i].yc, polyarc_b[i].r, polyarc_b[i].angle1, polyarc_b[i].dangle, NSEG);
}
}
break;
}
case (D_CIRCLE_LATTICE_STRIP):
{
glBegin(GL_LINES);
for (i=0; i<npolyline; i++)
{
glVertex2d(polyline[i].posi, polyline[i].posj);
}
glEnd();
for (i=0; i<npolyarc; i++)
{
draw_circle_arc(polyarc[i].xc, polyarc[i].yc, polyarc[i].r, polyarc[i].angle1, polyarc[i].dangle, NSEG);
}
break;
}
case (D_CIRCLE_LATTICE_HEX_STRIP):
{
glBegin(GL_LINES);
for (i=0; i<npolyline; i++)
{
glVertex2d(polyline[i].posi, polyline[i].posj);
}
glEnd();
for (i=0; i<npolyarc; i++)
{
draw_circle_arc(polyarc[i].xc, polyarc[i].yc, polyarc[i].r, polyarc[i].angle1, polyarc[i].dangle, NSEG);
}
break;
}
case (D_NOTHING):
{
/* Do nothing */
@ -854,7 +1080,8 @@ void int_planar_wave_comp(double x, double y, double *phi[NX], double *psi[NX],
dist2 = (xy[0]-x)*(xy[0]-x);
xy_in[i][j] = xy_in_billiard_comp(xy[0],xy[1]);
if ((xy_in[i][j])||(TWOSPEEDS)) phi[i][j] = 0.01*exp(-dist2/0.0005)*cos(-sqrt(dist2)/0.01);
if ((xy_in[i][j])||(TWOSPEEDS)) phi[i][j] = INITIAL_AMP*exp(-dist2/INITIAL_VARIANCE)*cos(-sqrt(dist2)/INITIAL_WAVELENGTH);
else phi[i][j] = 0.0;
psi[i][j] = 0.0;
}
@ -903,7 +1130,7 @@ void add_circular_wave_comp(double factor, double x, double y, double *phi[NX],
}
}
void draw_wave_comp(double *phi[NX], double *psi[NX], short int *xy_in[NX], double scale, int time, int plot)
void old_draw_wave_comp(double *phi[NX], double *psi[NX], short int *xy_in[NX], double scale, int time, int plot)
/* draw the field */
{
int i, j, iplus, iminus, jplus, jminus;
@ -997,82 +1224,191 @@ void draw_wave_comp(double *phi[NX], double *psi[NX], short int *xy_in[NX], doub
glEnd();
}
void draw_wave_comp_highres_palette(int size, double *phi[NX], double *psi[NX], double *total_energy[NX], short int *xy_in[NX], double scale, int time, int plot, int palette, int fade, double fade_value)
void draw_wave_comp(double *phi[NX], double *psi[NX], short int *xy_in[NX], double scale, int time, int plot)
/* draw the field */
{
int i, j, iplus, iminus, jplus, jminus, k;
double rgb[3], xy[2], x1, y1, x2, y2, velocity, energy, gradientx2, gradienty2, pos[2];
static double dtinverse = ((double)NX)/(COURANT*(XMAX-XMIN)), dx = (XMAX-XMIN)/((double)NX);
int i, j, k, iplus, iminus, jplus, jminus, size = 1;
double rgb[3], xy[2], x1, y1, x2, y2, velocity, energy, gradientx, gradienty, gradientx2, gradienty2, pos[2], norm, pscal, ca, vscale2;
double *values, *shade, *rgbvals;
glBegin(GL_QUADS);
// printf("dtinverse = %.5lg\n", dtinverse);
for (i=0; i<NX; i++)
for (j=0; j<NY; j++)
values = (double *)malloc(NX*NY*sizeof(double));
rgbvals = (double *)malloc(3*NX*NY*sizeof(double));
#pragma omp parallel for private(i,j,rgb)
for (i=0; i<NX; i+=size)
for (j=0; j<NY; j+=size)
{
// values[i*NY+j] = wave_value(i, j, phi, psi, total_energy, average_energy, total_flux, color_scale, xy_in, scale, time, plot, palette, rgb);
if (((TWOSPEEDS)&&(xy_in[i][j] != 2))||(xy_in[i][j] == 1))
{
switch (plot) {
case (P_AMPLITUDE):
{
color_scheme_palette(COLOR_SCHEME, palette, phi[i][j], scale, time, rgb);
values[i*NY+j] = phi[i][j];
color_scheme(COLOR_SCHEME, phi[i][j], scale, time, rgb);
break;
}
case (P_ENERGY):
{
energy = compute_energy(phi, psi, xy_in, i, j);
if (COLOR_PALETTE >= COL_TURBO) color_scheme_asym_palette(COLOR_SCHEME, palette, energy, scale, time, rgb);
else color_scheme_palette(COLOR_SCHEME, palette, energy, scale, time, rgb);
values[i*NY+j] = energy;
if (COLOR_PALETTE >= COL_TURBO) color_scheme_asym(COLOR_SCHEME, energy, scale, time, rgb);
else color_scheme(COLOR_SCHEME, energy, scale, time, rgb);
break;
}
case (P_MIXED):
{
if (j > NY/2) color_scheme_palette(COLOR_SCHEME, palette, phi[i][j], scale, time, rgb);
else color_scheme_palette(COLOR_SCHEME, palette, compute_energy(phi, psi, xy_in, i, j), scale, time, rgb);
break;
}
case (P_MEAN_ENERGY):
{
energy = compute_energy(phi, psi, xy_in, i, j);
total_energy[i][j] += energy;
if (COLOR_PALETTE >= COL_TURBO)
color_scheme_asym_palette(COLOR_SCHEME, palette, total_energy[i][j]/(double)(time+1), scale, time, rgb);
else color_scheme_palette(COLOR_SCHEME, palette, total_energy[i][j]/(double)(time+1), scale, time, rgb);
if (j > NY/2)
{
values[i*NY+j] = phi[i][j];
color_scheme(COLOR_SCHEME, phi[i][j], scale, time, rgb);
}
else
{
energy = compute_energy(phi, psi, xy_in, i, j);
values[i*NY+j] = energy;
color_scheme(COLOR_SCHEME, energy, scale, time, rgb);
}
break;
}
case (P_LOG_ENERGY):
{
energy = compute_energy(phi, psi, xy_in, i, j);
values[i*NY+j] = LOG_SHIFT + LOG_SCALE*log(energy);
color_scheme(COLOR_SCHEME, LOG_SHIFT + LOG_SCALE*log(energy), scale, time, rgb);
break;
}
case (P_LOG_MEAN_ENERGY):
{
energy = compute_energy(phi, psi, xy_in, i, j);
if (energy == 0.0) energy = 1.0e-20;
total_energy[i][j] += energy;
energy = LOG_SHIFT + LOG_SCALE*log(total_energy[i][j]/(double)(time+1));
color_scheme_palette(COLOR_SCHEME, palette, energy, scale, time, rgb);
break;
}
}
// if (PLOT == P_AMPLITUDE)
// color_scheme(COLOR_SCHEME, phi[i][j], scale, time, rgb);
// else if (PLOT == P_ENERGY)
// {
// energy = compute_energy(phi, psi, xy_in, i, j);
// if (COLOR_PALETTE >= COL_TURBO) color_scheme_asym(COLOR_SCHEME, energy, scale, time, rgb);
// else color_scheme(COLOR_SCHEME, energy, scale, time, rgb);
// }
// else if (PLOT == P_MIXED)
// {
// if (j > NY/2) color_scheme(COLOR_SCHEME, phi[i][j], scale, time, rgb);
// else color_scheme(COLOR_SCHEME, compute_energy(phi, psi, xy_in, i, j), scale, time, rgb);
// }
if (fade) for (k=0; k<3; k++) rgb[k] *= fade_value;
glColor3f(rgb[0], rgb[1], rgb[2]);
}
rgbvals[i*NY+j] = rgb[0];
rgbvals[NX*NY+i*NY+j] = rgb[1];
rgbvals[2*NX*NY+i*NY+j] = rgb[2];
}
// glBegin(GL_QUADS);
if (SHADE_2D)
{
vscale2 = SHADE_SCALE_2D*SHADE_SCALE_2D;
shade = (double *)malloc(NX*NY*sizeof(double));
#pragma omp parallel for private(i,j,gradientx,gradienty,norm,pscal,ca)
for (i=0; i<NX-size; i+=size)
{
for (j=0; j<NY-size; j+=size)
{
gradientx = values[(i+1)*NY+j] - values[i*NY+j];
gradienty = values[i*NY+j+1] - values[i*NY+j];
norm = sqrt(vscale2 + gradientx*gradientx + gradienty*gradienty);
pscal = -gradientx*light[0] - gradienty*light[1] + SHADE_SCALE_2D;
ca = pscal/norm;
ca = (ca + 1.0)*0.4 + 0.2;
for (k=0; k<3; k++) rgbvals[k*NX*NY+i*NY+j] *= ca;
printf("ca = %.3lg\n", ca);
}
}
}
glBegin(GL_QUADS);
for (i=0; i<NX; i+=size)
for (j=0; j<NY; j+=size)
{
if ((TWOSPEEDS)||(xy_in[i][j]))
{
glColor3f(rgbvals[i*NY+j], rgbvals[NX*NY+i*NY+j], rgbvals[2*NX*NY+i*NY+j]);
glVertex2i(i, j);
glVertex2i(i+size, j);
glVertex2i(i+size, j+size);
glVertex2i(i, j+size);
}
}
glEnd ();
if (SHADE_2D) free(shade);
/* draw horizontal mid line */
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_LINE_STRIP);
xy_to_pos(XMIN, 0.5*(YMIN+YMAX), pos);
glVertex2d(pos[0], pos[1]);
xy_to_pos(XMAX, 0.5*(YMIN+YMAX), pos);
glVertex2d(pos[0], pos[1]);
glEnd();
free(values);
free(rgbvals);
}
void draw_wave_comp_highres_palette(int size, double *phi[NX], double *psi[NX], double *total_energy[NX], double *average_energy[NX], double *total_flux, double *color_scale[NX], short int *xy_in[NX], double scale, int time, int plot, int palette, int fade, double fade_value)
/* draw the field */
{
int i, j, iplus, iminus, jplus, jminus, k;
double rgb[3], xy[2], x1, y1, x2, y2, velocity, energy, gradientx2, gradienty2, pos[2], gradientx, gradienty, norm, pscal, ca, vscale2, val;
static double dtinverse = ((double)NX)/(COURANT*(XMAX-XMIN)), dx = (XMAX-XMIN)/((double)NX), col_ratio;
double *values, *shade, *rgbvals;
static int first = 1;
if (first)
{
col_ratio = 1.0/1.01;
first = 0;
}
values = (double *)malloc(NX*NY*sizeof(double));
rgbvals = (double *)malloc(3*NX*NY*sizeof(double));
#pragma omp parallel for private(i,j,rgb)
for (i=0; i<NX; i+=size)
for (j=0; j<NY; j+=size)
{
values[i*NY+j] = wave_value(i, j, phi, psi, total_energy, average_energy, total_flux, color_scale, xy_in, scale, time, plot, palette, rgb);
rgbvals[i*NY+j] = rgb[0];
rgbvals[NX*NY+i*NY+j] = rgb[1];
rgbvals[2*NX*NY+i*NY+j] = rgb[2];
}
if (SHADE_2D)
{
vscale2 = SHADE_SCALE_2D*SHADE_SCALE_2D;
shade = (double *)malloc(NX*NY*sizeof(double));
#pragma omp parallel for private(i,j,gradientx,gradienty,norm,pscal,ca)
for (i=0; i<NX-size; i+=size)
{
for (j=0; j<NY-size; j+=size)
{
gradientx = values[(i+1)*NY+j] - values[i*NY+j];
gradienty = values[i*NY+j+1] - values[i*NY+j];
norm = sqrt(vscale2 + gradientx*gradientx + gradienty*gradienty);
pscal = -gradientx*light[0] - gradienty*light[1] + SHADE_SCALE_2D;
ca = pscal/norm;
ca = (ca + 1.0)*0.4 + 0.2;
if (RESCALE_COLOR_IN_CENTER) for (k=0; k<3; k++)
rgbvals[k*NX*NY+i*NY+j] = 1.0 + (ca*rgbvals[k*NX*NY+i*NY+j] - 1.0)*(color_scale[i][j]+0.01)*col_ratio;
// rgbvals[k*NX*NY+i*NY+j] = 0.5 + (ca*rgbvals[k*NX*NY+i*NY+j] - 0.5)*(color_scale[i][j]+0.01)*col_ratio;
else for (k=0; k<3; k++) rgbvals[k*NX*NY+i*NY+j] *= ca;
}
}
}
// D_CIRCLE_LATTICE_HEX printf("3\n");
glBegin(GL_QUADS);
// printf("dtinverse = %.5lg\n", dtinverse);
for (i=0; i<NX; i+=size)
for (j=0; j<NY; j+=size)
{
if (((TWOSPEEDS)&&(xy_in[i][j] != 2))||(xy_in[i][j] == 1))
{
if (fade) for (k=0; k<3; k++) rgbvals[k*NX*NY+i*NY+j] *= fade_value;
glColor3f(rgbvals[i*NY+j], rgbvals[NX*NY+i*NY+j], rgbvals[2*NX*NY+i*NY+j]);
glVertex2i(i, j);
glVertex2i(i+size, j);
@ -1086,12 +1422,18 @@ void draw_wave_comp_highres_palette(int size, double *phi[NX], double *psi[NX],
/* draw horizontal mid line */
if (fade) glColor3f(fade_value, fade_value, fade_value);
else glColor3f(1.0, 1.0, 1.0);
glLineWidth(BOUNDARY_WIDTH);
glBegin(GL_LINE_STRIP);
xy_to_pos(XMIN, 0.5*(YMIN+YMAX), pos);
glVertex2d(pos[0], pos[1]);
xy_to_pos(XMAX, 0.5*(YMIN+YMAX), pos);
glVertex2d(pos[0], pos[1]);
glEnd();
free(values);
free(rgbvals);
}
void compute_energy_tblr(double *phi[NX], double *psi[NX], short int *xy_in[NX], double energies[6])

View File

@ -44,7 +44,7 @@
#include <time.h>
#define MOVIE 0 /* set to 1 to generate movie */
#define DOUBLE_MOVIE 1 /* set to 1 to produce movies for wave height and energy simultaneously */
#define DOUBLE_MOVIE 0 /* set to 1 to produce movies for wave height and energy simultaneously */
#define SAVE_MEMORY 1 /* set to 1 to save memory when writing tiff images */
#define NO_EXTRA_BUFFER_SWAP 1 /* some OS require one less buffer swap when recording images */
@ -66,7 +66,7 @@
/* Choice of the billiard table */
#define B_DOMAIN 96 /* choice of domain shape, see list in global_pdes.c */
#define B_DOMAIN 97 /* choice of domain shape, see list in global_pdes.c */
#define CIRCLE_PATTERN 2 /* pattern of circles or polygons, see list in global_pdes.c */
@ -86,20 +86,24 @@
#define RANDOM_POLY_ANGLE 1 /* set to 1 to randomize angle of polygons */
#define PDISC_CONNECT_FACTOR 1.5 /* controls which discs are connected for D_CIRCLE_LATTICE_POISSON domain */
#define LAMBDA 1.25 /* parameter controlling the dimensions of domain */
#define MU 0.065 /* parameter controlling the dimensions of domain */
#define NPOLY 4 /* number of sides of polygon */
#define LAMBDA 0.6 /* parameter controlling the dimensions of domain */
#define MU 0.11 /* parameter controlling the dimensions of domain */
#define MU_B 1.0 /* 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 7 /* depth of computation of Menger gasket */
#define MDEPTH 6 /* depth of computation of Menger gasket */
#define MRATIO 3 /* ratio defining Menger gasket */
#define MANDELLEVEL 2000 /* iteration level for Mandelbrot set */
#define MANDELLIMIT 20.0 /* limit value for approximation of Mandelbrot set */
#define MANDELLEVEL 1000 /* iteration level for Mandelbrot set */
#define MANDELLIMIT 10.0 /* limit value for approximation of Mandelbrot set */
#define FOCI 1 /* set to 1 to draw focal points of ellipse */
#define NGRIDX 15 /* number of grid point for grid of disks */
#define NGRIDY 10 /* number of grid point for grid of disks */
#define NGRIDX 12 /* number of grid point for grid of disks */
#define NGRIDY 8 /* number of grid point for grid of disks */
#define WALL_WIDTH 0.022 /* width of wall separating lenses */
#define WALL_WIDTH_RND 0.5 /* proportion of width of width for random arrangements */
#define WALL_WIDTH_B 0.01 /* width of wall separating lenses */
#define WALL_WIDTH_RND 0.0 /* proportion of width of width for random arrangements */
#define RADIUS_FACTOR 0.3 /* controls inner radius for C_RING arrangements */
#define WALL_WIDTH_ASYM 0.75 /* asymmetry of wall width (D_CIRCLE_LATTICE_NONISO) */
#define WALL_WIDTH_ASYM_B 0.75 /* asymmetry of wall width (D_CIRCLE_LATTICE_HEX_NONISO) */
#define X_SHOOTER -0.2
#define Y_SHOOTER -0.6
@ -146,7 +150,7 @@
/* For similar wave forms, COURANT^2*GAMMA should be kept constant */
#define ADD_OSCILLATING_SOURCE 1 /* set to 1 to add an oscillating wave source */
#define OSCILLATING_SOURCE_PERIOD 8 /* period of oscillating source */
#define OSCILLATING_SOURCE_PERIOD 18 /* period of oscillating source */
#define ALTERNATE_OSCILLATING_SOURCE 1 /* set to 1 to alternate sign of oscillating source */
#define MAX_PULSING_TIME 1500 /* max time for adding pulses */
@ -163,7 +167,7 @@
/* Parameters for length and speed of simulation */
#define NSTEPS 3200 /* number of frames of movie */
#define NSTEPS 2800 /* number of frames of movie */
#define NVID 3 /* number of iterations between images displayed on screen */
#define NSEG 1000 /* number of segments of boundary */
#define INITIAL_TIME 0 /* time after which to start saving frames */
@ -220,8 +224,8 @@
/* Color schemes */
#define COLOR_PALETTE 11 /* Color palette, see list in global_pdes.c */
#define COLOR_PALETTE_B 10 /* Color palette, see list in global_pdes.c */
#define COLOR_PALETTE 10 /* Color palette, see list in global_pdes.c */
#define COLOR_PALETTE_B 17 /* Color palette, see list in global_pdes.c */
#define BLACK 1 /* background */
@ -229,6 +233,7 @@
#define SCALE 0 /* set to 1 to adjust color scheme to variance of field */
#define SLOPE 0.75 /* sensitivity of color on wave amplitude */
#define COLOR_RANGE 1.0 /* max range of color (default: 1.0) */
#define VSCALE_AMPLITUDE 0.5 /* additional scaling factor for color scheme P_3D_AMPLITUDE */
#define VSHIFT_AMPLITUDE 0.0 /* additional shift for wave amplitude */
#define VSCALE_ENERGY 1.0 /* additional scaling factor for color scheme P_3D_ENERGY */
@ -268,7 +273,7 @@
#define DRAW_COLOR_SCHEME 1 /* set to 1 to plot the color scheme */
#define COLORBAR_RANGE 2.5 /* scale of color scheme bar */
#define COLORBAR_RANGE_B 0.6 /* scale of color scheme bar for 2nd part */
#define COLORBAR_RANGE_B 1.0 /* 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 */
@ -290,7 +295,7 @@
#define HRES 1 /* dummy, only used by rde.c */
#define SHADE_2D 0 /* set to 1 to add pseudo-3d shading effect */
#define SHADE_SCALE_2D 0.05 /* lower value increases sensitivity of shading */
#define N_SOURCES 2 /* number of sources, for option draw_sources */
#define N_SOURCES 1 /* number of sources, for option draw_sources */
#define XYIN_INITIALISED (B_DOMAIN == D_IMAGE)
/* end of constants only used by sub_wave and sub_maze */
@ -1014,7 +1019,7 @@ void animation()
// init_polyrect_arc(polyrectrot, polyarc, &npolyrect_rot, &npolyarc);
/* initialise polyline and similar for drawing some domains */
npolyline = init_poly(MDEPTH, polyline, polyrect, polyrectrot, polyarc, circles, &npolyrect, &npolyrect_rot, &npolyarc, &ncircles);
npolyline = init_poly(MDEPTH, polyline, polyrect, polyrectrot, polyarc, circles, &npolyrect, &npolyrect_rot, &npolyarc, &ncircles, 1);
if (COMPARISON) npolyline_b = init_polyline(MDEPTH, polyline);
for (i=0; i<npolyline; i++) printf("vertex %i: (%.3f, %.3f)\n", i, polyline[i].x, polyline[i].y);
@ -1162,14 +1167,10 @@ void animation()
if (DRAW_COLOR_SCHEME) draw_color_bar_palette(CPLOT, COLORBAR_RANGE, COLOR_PALETTE, fade, fade_value);
/* add oscillating waves */
wave_source_x[0] = circles[10].xc;
wave_source_y[0] = circles[10].yc;
wave_source_x[1] = circles[214].xc;
wave_source_y[1] = circles[214].yc;
wave_source_x[0] = 0.0;
wave_source_y[0] = 0.0;
source_periods[0] = OSCILLATING_SOURCE_PERIOD;
source_periods[1] = OSCILLATING_SOURCE_PERIOD/2;
source_amp[0] = INITIAL_AMP;
source_amp[1] = INITIAL_AMP*2.0;
for (source = 0; source < N_SOURCES; source++)
{
if ((ADD_OSCILLATING_SOURCE)&&(i%(OSCILLATING_SOURCE_PERIOD) == 1)&&(i<MAX_PULSING_TIME))

View File

@ -44,7 +44,7 @@
#include <time.h>
#define MOVIE 0 /* set to 1 to generate movie */
#define DOUBLE_MOVIE 1 /* set to 1 to produce movies for wave height and energy simultaneously */
#define DOUBLE_MOVIE 0 /* set to 1 to produce movies for wave height and energy simultaneously */
#define SAVE_MEMORY 1 /* set to 1 to save memory when writing tiff images */
#define NO_EXTRA_BUFFER_SWAP 1 /* some OS require one less buffer swap when recording images */
@ -60,8 +60,8 @@
#define NX 3840 /* number of grid points on x axis */
#define NY 2300 /* number of grid points on y axis */
#define XMIN -2.0
#define XMAX 2.0 /* x interval */
#define XMIN -1.5
#define XMAX 2.5 /* x interval */
#define YMIN -1.197916667
#define YMAX 1.197916667 /* y interval for 9/16 aspect ratio */
@ -72,7 +72,7 @@
/* Choice of the billiard table */
#define B_DOMAIN 96 /* choice of domain shape, see list in global_pdes.c */
#define B_DOMAIN 947 /* choice of domain shape, see list in global_pdes.c */
#define CIRCLE_PATTERN 202 /* pattern of circles or polygons, see list in global_pdes.c */
#define IMAGE_FILE 5 /* for option D_IMAGE */
@ -87,8 +87,8 @@
#define RANDOM_POLY_ANGLE 1 /* set to 1 to randomize angle of polygons */
#define PDISC_CONNECT_FACTOR 1.5 /* controls which discs are connected for D_CIRCLE_LATTICE_POISSON domain */
#define LAMBDA 1.25 /* parameter controlling the dimensions of domain */
#define MU 0.065 /* parameter controlling the dimensions of domain */
#define LAMBDA 0.6 /* parameter controlling the dimensions of domain */
#define MU 0.075 /* parameter controlling the dimensions of domain */
#define MU_B 1.0 /* 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 */
@ -97,11 +97,14 @@
#define MANDELLEVEL 1000 /* iteration level for Mandelbrot set */
#define MANDELLIMIT 10.0 /* limit value for approximation of Mandelbrot set */
#define FOCI 1 /* set to 1 to draw focal points of ellipse */
#define NGRIDX 15 /* number of grid point for grid of disks */
#define NGRIDY 10 /* number of grid point for grid of disks */
#define WALL_WIDTH 0.017 /* width of wall separating lenses */
#define NGRIDX 6 /* number of grid point for grid of disks */
#define NGRIDY 14 /* number of grid point for grid of disks */
#define WALL_WIDTH 0.013 /* width of wall separating lenses */
#define WALL_WIDTH_B 0.01 /* width of wall separating lenses */
#define WALL_WIDTH_RND 0.0 /* proportion of width of width for random arrangements */
#define RADIUS_FACTOR 0.3 /* controls inner radius for C_RING arrangements */
#define WALL_WIDTH_ASYM 0.75 /* asymmetry of wall width (D_CIRCLE_LATTICE_NONISO) */
#define WALL_WIDTH_ASYM_B 0.75 /* asymmetry of wall width (D_CIRCLE_LATTICE_HEX_NONISO) */
#define X_SHOOTER -0.2
#define Y_SHOOTER -0.6
@ -118,20 +121,20 @@
/* xy_in_billiard and draw_billiard below */
/* Physical parameters of wave equation */
#define TWOSPEEDS 0 /* set to 1 to replace hardcore boundary by medium with different speed */
#define OSCILLATE_LEFT 0 /* set to 1 to add oscilating boundary condition on the left */
#define TWOSPEEDS 1 /* set to 1 to replace hardcore boundary by medium with different speed */
#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 61 /* oscillation schedule, see list in global_pdes.c */
#define OSCILLATION_SCHEDULE 0 /* oscillation schedule, see list in global_pdes.c */
#define OSCIL_YMAX 0.35 /* defines oscillation range */
#define INITIAL_SHIFT 20.0 /* time shift of initial wave packet (in oscillation periods) */
#define WAVE_PACKET_SHIFT 200.0 /* time shift between wave packets (in oscillation periods) */
#define OMEGA 0.025 /* frequency of periodic excitation */
#define AMPLITUDE 0.5 /* amplitude of periodic excitation */
#define OMEGA 0.0125 /* frequency of periodic excitation */
#define AMPLITUDE 1.0 /* amplitude of periodic excitation */
#define ACHIRP 0.25 /* acceleration coefficient in chirp */
#define DAMPING 0.0 /* damping of periodic excitation */
#define COURANT 0.1 /* Courant number */
#define COURANTB 0.025 /* Courant number in medium B */
#define COURANTB 0.035 /* Courant number in medium B */
#define GAMMA 0.0 /* damping factor in wave equation */
#define GAMMAB 0.0 /* damping factor in wave equation */
#define GAMMA_SIDES 1.0e-4 /* damping factor on boundary */
@ -146,11 +149,11 @@
/* For similar wave forms, COURANT^2*GAMMA should be kept constant */
#define ADD_OSCILLATING_SOURCE 1 /* set to 1 to add an oscillating wave source */
#define OSCILLATING_SOURCE_PERIOD 8 /* period of oscillating source */
#define OSCILLATING_SOURCE_PERIOD 12.5 /* period of oscillating source */
#define ALTERNATE_OSCILLATING_SOURCE 1 /* set to 1 to alternate sign of oscillating source */
#define N_SOURCES 2 /* number of sources, for option draw_sources */
#define N_SOURCES 1 /* number of sources, for option draw_sources */
#define ALTERNATE_SOURCE_PHASES 0 /* set to 1 to alternate initial phases of sources */
#define MAX_PULSING_TIME 1500 /* max time for adding pulses */
#define MAX_PULSING_TIME 500 /* max time for adding pulses */
#define ADD_WAVE_PACKET_SOURCES 0 /* set to 1 to add several sources emitting wave packets */
#define WAVE_PACKET_SOURCE_TYPE 3 /* type of wave packet sources */
@ -161,12 +164,12 @@
/* Boundary conditions, see list in global_pdes.c */
#define B_COND 1
#define B_COND 2
/* Parameters for length and speed of simulation */
#define NSTEPS 3200 /* number of frames of movie */
#define NVID 7 /* number of iterations between images displayed on screen */
#define NSTEPS 4800 /* number of frames of movie */
#define NVID 8 /* number of iterations between images displayed on screen */
#define NSEG 1000 /* number of segments of boundary */
#define INITIAL_TIME 0 /* time after which to start saving frames */
#define BOUNDARY_WIDTH 2 /* width of billiard boundary */
@ -183,7 +186,7 @@
/* Parameters of initial condition */
#define INITIAL_AMP 0.75 /* amplitude of initial condition */
#define INITIAL_AMP 0.75 /* amplitude of initial condition */
#define INITIAL_VARIANCE 0.0005 /* variance of initial condition */
#define INITIAL_WAVELENGTH 0.025 /* wavelength of initial condition */
@ -195,8 +198,8 @@
/* Color schemes */
#define COLOR_PALETTE 15 /* Color palette, see list in global_pdes.c */
#define COLOR_PALETTE_B 10 /* Color palette, see list in global_pdes.c */
#define COLOR_PALETTE 11 /* Color palette, see list in global_pdes.c */
#define COLOR_PALETTE_B 16 /* Color palette, see list in global_pdes.c */
#define BLACK 1 /* background */
@ -204,20 +207,21 @@
#define SCALE 0 /* set to 1 to adjust color scheme to variance of field */
#define SLOPE 1.0 /* sensitivity of color on wave amplitude */
#define COLOR_RANGE 1.0 /* max range of color (default: 1.0) */
#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 VSHIFT_AMPLITUDE 0.0 /* additional shift for wave amplitude */
#define VSCALE_AMPLITUDE 0.2 /* additional scaling factor for wave amplitude */
#define E_SCALE 30.0 /* scaling factor for energy representation */
#define VSHIFT_AMPLITUDE -0.1 /* additional shift for wave amplitude */
#define VSCALE_AMPLITUDE 1.0 /* additional scaling factor for wave amplitude */
#define E_SCALE 750.0 /* scaling factor for energy representation */
#define LOG_SCALE 0.75 /* scaling factor for energy log representation */
#define LOG_SHIFT 0.75 /* shift of colors on log scale */
#define FLUX_SCALE 250.0 /* scaling factor for energy flux represtnation */
#define AVRG_E_FACTOR 0.85 /* controls time window size in P_AVERAGE_ENERGY scheme */
#define AVRG_E_FACTOR 0.75 /* controls time window size in P_AVERAGE_ENERGY scheme */
#define RESCALE_COLOR_IN_CENTER 0 /* set to 1 to decrease color intentiy in the center (for wave escaping ring) */
#define FADE_IN_OBSTACLE 1 /* set to 1 to fade color inside obstacles */
#define SHADE_2D 1 /* set to 1 to add pseudo-3d shading effect */
#define SHADE_SCALE_2D 0.05 /* lower value increases sensitivity of shading */
#define SHADE_SCALE_2D 0.01 /* lower value increases sensitivity of shading */
#define COLORHUE 260 /* initial hue of water color for scheme C_LUM */
#define COLORDRIFT 0.0 /* how much the color hue drifts during the whole simulation */
@ -233,7 +237,7 @@
#define CIRC_COLORBAR 0 /* set to 1 to draw circular color scheme */
#define CIRC_COLORBAR_B 0 /* set to 1 to draw circular color scheme */
#define DRAW_WAVE_PROFILE 0 /* set to 1 to draw a profile of the wave */
#define DRAW_WAVE_PROFILE 1 /* set to 1 to draw a profile of the wave */
#define HORIZONTAL_WAVE_PROFILE 0 /* set to 1 to draw wave profile vertically */
#define VERTICAL_WAVE_PROFILE 1 /* set to 1 to draw wave profile vertically */
#define WAVE_PROFILE_X 1.9 /* value of x to sample wave profile */
@ -252,9 +256,9 @@
#define MESSAGE_LSPACE 48 /* length of space for Morse code message */
#define MESSAGE_INITIAL_TIME 100 /* initial time before starting message for Morse code message */
#define NXMAZE 8 /* width of maze */
#define NYMAZE 32 /* height of maze */
#define MAZE_MAX_NGBH 5 /* max number of neighbours of maze cell */
#define NXMAZE 18 /* width of maze */
#define NYMAZE 9 /* height of maze */
#define MAZE_MAX_NGBH 6 /* max number of neighbours of maze cell */
#define RAND_SHIFT 0 /* seed of random number generator */
#define MAZE_XSHIFT 0.0 /* horizontal shift of maze */
#define MAZE_WIDTH 0.02 /* half width of maze walls */
@ -595,12 +599,12 @@ void draw_color_bar_palette(int plot, double range, int palette, int circular, i
void animation()
{
double time, scale, ratio, startleft[2], startright[2], sign[N_SOURCES], r2, xy[2], fade_value, yshift, speed = 0.0, a, b, c, x, y, angle = 0.0, x1, ior_angle = 0.0, omega, phase_shift, vshift, dsource, finv, source_amp[N_SOURCES], nx, ny, r;
double time, scale, ratio, startleft[2], startright[2], sign[N_SOURCES], r2, xy[2], fade_value, yshift, speed = 0.0, a, b, c, x, y, angle = 0.0, x1, ior_angle = 0.0, omega, phase_shift, vshift, dsource, finv, source_amp[N_SOURCES], nx, ny, r, source_periods[N_SOURCES], dperiod;
double *phi[NX], *psi[NX], *tmp[NX], *total_energy[NX], *average_energy[NX], *color_scale[NX], *total_flux, *tcc_table[NX], *tgamma_table[NX], *fade_table;
short int *xy_in[NX];
int i, j, k, s, sample_left[2], sample_right[2], period = 0, fade, source_counter = 0, p, q, first_source = 1, imin, imax, ij[2], source, source_period, source_shift[N_SOURCES], source_periods[N_SOURCES];
int i, j, k, s, sample_left[2], sample_right[2], period = 0, fade, source_counter = 0, p, q, first_source = 1, imin, imax, ij[2], source, source_period, source_shift[N_SOURCES], phase;
// static int image_counter = 0;
int image_counter = 0;
int image_counter = 0, add_counter[N_SOURCES];
long int wave_value;
t_wave_packet *packet;
t_wave_source wave_source[25];
@ -654,7 +658,7 @@ void animation()
// init_polyrect_arc(polyrectrot, polyarc, &npolyrect_rot, &npolyarc);
/* initialise polyline and similar for drawing some domains */
npolyline = init_poly(MDEPTH, polyline, polyrect, polyrectrot, polyarc, circles, &npolyrect, &npolyrect_rot, &npolyarc, &ncircles);
npolyline = init_poly(MDEPTH, polyline, polyrect, polyrectrot, polyarc, circles, &npolyrect, &npolyrect_rot, &npolyarc, &ncircles, 1);
for (i=0; i<ncircles; i++) printf("circle %i: (%.3f, %.3f)\n", i, circles[i].xc, circles[i].yc);
@ -720,6 +724,8 @@ void animation()
if (XYIN_INITIALISED) init_xyin_from_image(xy_in);
for (i=0; i<N_SOURCES; i++) add_counter[i] = 0;
// isospectral_initial_point(0.1, 0.0, startleft, startright); /* for isospectral billiards */
// homophonic_initial_point(0.5, -0.25, 1.5, -0.25, startleft, startright);
// homophonic_initial_point(0.5, -0.25, 1.5, -0.25, startleft, startright);
@ -798,7 +804,7 @@ void animation()
b = 0.00015;
// speed = a/((double)(NVID)*c);
// speed = 0.55*a/((double)(NVID*OSCILLATING_SOURCE_PERIOD)*c);
speed = a/((double)(3*NVID*OSCILLATING_SOURCE_PERIOD)*c);
speed = a/((double)(3*NVID)*OSCILLATING_SOURCE_PERIOD*c);
/* the factor 3 is due to evolve_wave calling evolve_wave_half 3 times */
print_speed(speed, 0, 1.0);
}
@ -841,19 +847,18 @@ void animation()
if (DRAW_COLOR_SCHEME) draw_color_bar_palette(PLOT, COLORBAR_RANGE, COLOR_PALETTE, CIRC_COLORBAR, fade, fade_value);
/* add oscillating waves */
wave_source_x[0] = circles[10].xc;
wave_source_y[0] = circles[10].yc;
wave_source_x[1] = circles[214].xc;
wave_source_y[1] = circles[214].yc;
wave_source_x[0] = -1.0;
wave_source_y[0] = 0.0;
source_periods[0] = OSCILLATING_SOURCE_PERIOD;
source_periods[1] = OSCILLATING_SOURCE_PERIOD/2;
source_amp[0] = INITIAL_AMP;
source_amp[1] = INITIAL_AMP*2.0;
for (source = 0; source < N_SOURCES; source++)
{
// source_shift[source] = 0;
if ((ADD_OSCILLATING_SOURCE)&&(i%(source_periods[source]) == 1)&&(i<MAX_PULSING_TIME))
dperiod = source_periods[source];
phase = i - (int)(dperiod*(double)((int)((double)i/dperiod)));
if ((ADD_OSCILLATING_SOURCE)&&(phase == 1)&&(i<MAX_PULSING_TIME))
{
printf("Source %i: Adding pulse %i\n", source, add_counter[source]);
add_counter[source]++;
if (ALTERNATE_OSCILLATING_SOURCE) sign[source] = -sign[source];
add_circular_wave(-sign[source]*source_amp[source], wave_source_x[source], wave_source_y[source], phi, psi, xy_in);
}

View File

@ -44,11 +44,11 @@
#include <time.h>
#define MOVIE 0 /* set to 1 to generate movie */
#define DOUBLE_MOVIE 1 /* set to 1 to produce movies for wave height and energy simultaneously */
#define DOUBLE_MOVIE 0 /* set to 1 to produce movies for wave height and energy simultaneously */
#define SAVE_MEMORY 1 /* set to 1 to save memory when writing tiff images */
#define NO_EXTRA_BUFFER_SWAP 1 /* some OS require one less buffer swap when recording images */
#define VARIABLE_IOR 1 /* set to 1 for a variable index of refraction */
#define VARIABLE_IOR 0 /* set to 1 for a variable index of refraction */
#define IOR 10 /* choice of index of refraction, see list in global_pdes.c */
#define IOR_TOTAL_TURNS 1.5 /* total angle of rotation for IOR_PERIODIC_WELLS_ROTATING */
#define MANDEL_IOR_SCALE -0.05 /* parameter controlling dependence of IoR on Mandelbrot escape speed */
@ -58,9 +58,6 @@
#define WINWIDTH 1920 /* window width */
#define WINHEIGHT 1150 /* window height */
// #define NX 1920 /* number of grid points on x axis */
// #define NY 1000 /* number of grid points on y axis */
// #define YMID 500 /* mid point of display */
#define NX 3840 /* number of grid points on x axis */
#define NY 2300 /* number of grid points on y axis */
#define YMID 1150 /* mid point of display */
@ -69,24 +66,14 @@
#define YMIN -1.197916667
#define YMAX 1.197916667 /* y interval for 9/16 aspect ratio */
// #define WINWIDTH 1280 /* window width */
// #define WINHEIGHT 720 /* window height */
// #define NX 1280 /* number of grid points on x axis */
// #define NY 720 /* number of grid points on y axis */
// #define YMID 360 /* mid point of display */
// #define XMIN -2.0
// #define XMAX 2.0 /* x interval */
// #define YMIN -1.125
// #define YMAX 1.125 /* y interval for 9/16 aspect ratio */
#define HIGHRES 1 /* set to 1 if resolution of grid is double that of displayed image */
#define JULIA_SCALE 1.0 /* scaling for Julia sets */
/* Choice of the billiard table */
#define B_DOMAIN 63 /* choice of domain shape, see list in global_pdes.c */
#define B_DOMAIN_B 63 /* choice of domain shape, see list in global_pdes.c */
#define B_DOMAIN 94 /* choice of domain shape, see list in global_pdes.c */
#define B_DOMAIN_B 94 /* choice of domain shape, see list in global_pdes.c */
#define CIRCLE_PATTERN 13 /* pattern of circles, see list in global_pdes.c */
#define CIRCLE_PATTERN_B 13 /* pattern of circles, see list in global_pdes.c */
@ -106,8 +93,9 @@
#define HEX_NONUNIF_COMPRESSSION_B -0.15 /* compression factor for HEX_NONUNIF pattern */
#define LAMBDA 1.5 /* parameter controlling the dimensions of domain */
#define MU 0.7 /* parameter controlling the dimensions of domain */
#define MUB 0.2 /* parameter controlling the dimensions of domain */
#define MU 0.06 /* parameter controlling the dimensions of domain */
#define MU_B 0.06 /* parameter controlling the dimensions of domain */
#define MUB 0.06 /* parameter controlling the dimensions of domain */
#define NPOLY 3 /* number of sides of polygon */
#define APOLY 0.0 /* angle by which to turn polygon, in units of Pi/2 */
#define APOLY_B 2.0 /* angle by which to turn polygon, in units of Pi/2 */
@ -116,8 +104,14 @@
#define MANDELLEVEL 1000 /* iteration level for Mandelbrot set */
#define MANDELLIMIT 10.0 /* limit value for approximation of Mandelbrot set */
#define FOCI 1 /* set to 1 to draw focal points of ellipse */
#define NGRIDX 20 /* number of grid point for grid of disks */
#define NGRIDY 20 /* number of grid point for grid of disks */
#define NGRIDX 17 /* number of grid point for grid of disks */
#define NGRIDY 12 /* number of grid point for grid of disks */
#define WALL_WIDTH 0.012 /* width of channels/wall separating lenses */
#define WALL_WIDTH_B 0.012 /* width of channels/wall separating lenses */
#define WALL_WIDTH_RND 0.0 /* proportion of width of width for random arrangements */
#define RADIUS_FACTOR 0.3 /* controls inner radius for C_RING arrangements */
#define WALL_WIDTH_ASYM 0.75 /* asymmetry of wall width (D_CIRCLE_LATTICE_NONISO) */
#define WALL_WIDTH_ASYM_B 0.75 /* asymmetry of wall width (D_CIRCLE_LATTICE_HEX_NONISO) */
#define X_SHOOTER -0.2
#define Y_SHOOTER -0.6
@ -135,7 +129,7 @@
/* Physical parameters of wave equation */
#define TWOSPEEDS 1 /* set to 1 to replace hardcore boundary by medium with different speed */
#define TWOSPEEDS 0 /* set to 1 to replace hardcore boundary by medium with different speed */
#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 */
@ -157,21 +151,23 @@
/* For similar wave forms, COURANT^2*GAMMA should be kept constant */
#define ADD_OSCILLATING_SOURCE 1 /* set to 1 to add an oscillating wave source */
#define OSCILLATING_SOURCE_PERIOD 20 /* period of oscillating source */
#define OSCILLATING_SOURCE_PERIOD 15.625 /* period of oscillating source */
#define ALTERNATE_OSCILLATING_SOURCE 1 /* set to 1 to alternate sign of oscillating source */
#define N_SOURCES 2 /* number of sources, for option draw_sources */
#define ALTERNATE_SOURCE_PHASES 0 /* set to 1 to alternate initial phases of sources */
#define NSOURCES 48 /* number of sources */
#define MAX_PULSING_TIME 10000 /* max time for adding pulses */
/* Boundary conditions, see list in global_pdes.c */
#define B_COND 4
#define B_COND 1
/* Parameters for length and speed of simulation */
// #define NSTEPS 500 /* number of frames of movie */
#define NSTEPS 2600 /* number of frames of movie */
#define NVID 7 /* number of iterations between images displayed on screen */
#define NSTEPS 3900 /* number of frames of movie */
#define NVID 7 /* number of iterations between images displayed on screen */
#define NSEG 100 /* number of segments of boundary */
#define INITIAL_TIME 100 /* time after which to start saving frames */
#define INITIAL_TIME 0 /* time after which to start saving frames */
#define COMPUTE_ENERGIES 0 /* set to 1 to compute and print energies */
#define BOUNDARY_WIDTH 2 /* width of billiard boundary */
@ -185,9 +181,9 @@
/* Parameters of initial condition */
#define INITIAL_AMP 1.0 /* amplitude of initial condition */
#define INITIAL_VARIANCE 0.00001 /* variance of initial condition */
#define INITIAL_WAVELENGTH 0.025 /* wavelength of initial condition */
#define INITIAL_AMP 0.75 /* amplitude of initial condition */
#define INITIAL_VARIANCE 0.0005 /* variance of initial condition */
#define INITIAL_WAVELENGTH 0.025 /* wavelength of initial condition */
/* Plot type, see list in global_pdes.c */
@ -197,8 +193,8 @@
/* Color schemes */
#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 COLOR_PALETTE 14 /* Color palette, see list in global_pdes.c */
#define COLOR_PALETTE_B 14 /* Color palette, see list in global_pdes.c */
#define BLACK 1 /* background */
#define BLACK_TEXT 1 /* set to 1 to write text in black instead of white */
@ -207,12 +203,13 @@
#define SCALE 0 /* set to 1 to adjust color scheme to variance of field */
#define SLOPE 1.0 /* sensitivity of color on wave amplitude */
#define COLOR_RANGE 1.0 /* max range of color (default: 1.0) */
#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 VSHIFT_AMPLITUDE 0.0 /* additional shift for wave amplitude */
#define VSCALE_AMPLITUDE 0.5 /* additional scaling factor for wave amplitude */
#define E_SCALE 100.0 /* scaling factor for energy representation */
#define VSHIFT_AMPLITUDE -0.2 /* additional shift for wave amplitude */
#define VSCALE_AMPLITUDE 0.4 /* additional scaling factor for wave amplitude */
#define E_SCALE 10.0 /* scaling factor for energy representation */
#define LOG_SCALE 1.0 /* scaling factor for energy log representation */
#define LOG_SHIFT 2.0 /* shift of colors on log scale */
#define FLUX_SCALE 5.0e3 /* scaling factor for enegy flux represtnation */
@ -245,7 +242,7 @@
/* for compatibility with sub_wave and sub_maze */
#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 MAZE_MAX_NGBH 6 /* 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 */
#define ADD_POTENTIAL 0
@ -256,11 +253,8 @@
#define N_WAVE_PACKETS 15 /* number of wave packets */
#define OSCIL_LEFT_YSHIFT 0.0 /* y-dependence of left oscillation (for non-horizontal waves) */
#define DRAW_WAVE_PROFILE 0 /* set to 1 to draw a profile of the wave */
#define MU_B 1.0 /* parameter controlling the dimensions of domain */
#define VERTICAL_WAVE_PROFILE 0 /* set to 1 to draw wave profile vertically */
#define DRAW_WAVE_TIMESERIES 0 /* set to 1 to draw a time series of the wave */
#define WALL_WIDTH 0.1 /* width of wall separating lenses */
#define WALL_WIDTH_RND 0.0 /* proportion of width of width for random arrangements */
#define RADIUS_FACTOR 0.3 /* controls inner radius for C_RING arrangements */
#define OSCIL_YMAX 0.35 /* defines oscillation range */
#define MESSAGE_LDASH 14 /* length of dash for Morse code message */
@ -281,9 +275,10 @@
#define INITIAL_SHIFT 20.0 /* time shift of initial wave packet (in oscillation periods) */
#define WAVE_PACKET_SHIFT 200.0 /* time shift between wave packets (in oscillation periods) */
#define FADE_IN_OBSTACLE 0 /* set to 1 to fade color inside obstacles */
#define SHADE_2D 0 /* set to 1 to add pseudo-3d shading effect */
#define SHADE_2D 1 /* set to 1 to add pseudo-3d shading effect */
#define SHADE_SCALE_2D 0.05 /* lower value increases sensitivity of shading */
#define N_SOURCES 1 /* number of sources, for option draw_sources */
#define MEAN_FLUX (PLOT == P_TOTAL_ENERGY_FLUX)||(PLOT_B == P_TOTAL_ENERGY_FLUX)
#define XYIN_INITIALISED (B_DOMAIN == D_IMAGE)
double light[2] = {0.40824829, 0.816496581}; /* location of light source for SHADE_2D option*/
/* end of constants only used by sub_wave and sub_maze */
@ -734,10 +729,10 @@ void draw_color_bar_palette(int plot, double range, int palette, int fade, doubl
void animation()
{
double time, scale, energies[6], top_energy, bottom_energy, omega, angle, fade_value, sign = 1.0, ior_angle = 0.0;
double *phi[NX], *psi[NX], *tmp[NX], *total_energy[NX], *tcc_table[NX];
double time, scale = 1.0, energies[6], top_energy, bottom_energy, omega, angle, fade_value, sign[N_SOURCES], ior_angle = 0.0, source_amp[N_SOURCES], source_periods[N_SOURCES], dperiod;
double *phi[NX], *psi[NX], *tmp[NX], *total_energy[NX], *tcc_table[NX], *color_scale[NX], *total_flux, *fade_table, *average_energy[NX];
short int *xy_in[NX];
int i, j, s, counter = 0, k, first_source = 1, fade, resol = HIGHRES + 1;
int i, j, s, counter = 0, k, first_source = 1, fade, source, resol = HIGHRES + 1, phase, add_counter[N_SOURCES];
t_wave_source wave_source[NSOURCES];
monitor_sources = fopen("monitor_sources.dat", "w");
@ -749,10 +744,18 @@ void animation()
psi[i] = (double *)malloc(NY*sizeof(double));
tmp[i] = (double *)malloc(NY*sizeof(double));
total_energy[i] = (double *)malloc(NY*sizeof(double));
average_energy[i] = (double *)malloc(NY*sizeof(double));
xy_in[i] = (short int *)malloc(NY*sizeof(short int));
tcc_table[i] = (double *)malloc(NX*sizeof(double));
}
if (FADE_IN_OBSTACLE) fade_table = (double *)malloc(NX*NY*sizeof(double));
if (MEAN_FLUX) total_flux = (double *)malloc(4*NX*NY*sizeof(double));
if (ALTERNATE_SOURCE_PHASES) for (i=0; i<N_SOURCES; i++) sign[i] = pow(-1.0,(double)i);
else for (i=0; i<N_SOURCES; i++) sign[i] = 1.0;
/* initialise positions and radii of circles */
printf("initializing circle configuration\n");
if ((B_DOMAIN == D_CIRCLES)||(B_DOMAIN_B == D_CIRCLES)) init_circle_config_comp(circles);
@ -760,8 +763,18 @@ void animation()
// for (i=0; i<ncircles; i++) printf("polygon %i at (%.3f, %.3f) radius %.3f\n", i, polygons[i].xc, polygons[i].yc, polygons[i].radius);
/* 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);
// npolyline = init_polyline(MDEPTH, polyline);
// for (i=0; i<npolyline; i++) printf("vertex %i: (%.3f, %.3f)\n", i, polyline[i].x, polyline[i].y);
/* initialise polyline and similar for drawing some domains */
npolyline = init_poly(MDEPTH, polyline, polyrect, polyrectrot, polyarc, circles, &npolyrect, &npolyrect_rot, &npolyarc, &ncircles, 1);
npolyline_b = init_poly(MDEPTH, polyline_b, polyrect_b, polyrectrot_b, polyarc_b, circles_b, &npolyrect_b, &npolyrect_rot_b, &npolyarc_b, &ncircles_b, 0);
// for (i=0; i<npolyarc; i++) printf("polyarc %i: center (%.3f, %.3f) angles (%.3f, %.3f)\n", i, polyarc[i].xc, polyarc[i].yc, polyarc[i].angle1*180.0/PI, (polyarc[i].angle1 + polyarc[i].dangle)*180.0/PI);
// for (i=0; i<npolyarc_b; i++) printf("polyarc_b %i: center (%.3f, %.3f) angles (%.3f, %.3f)\n", i, polyarc_b[i].xc, polyarc_b[i].yc, polyarc_b[i].angle1*180.0/PI, (polyarc_b[i].angle1 + polyarc_b[i].dangle)*180.0/PI);
for (i=0; i<ncircles; i++) printf("circle %i: (%.3f, %.3f) radius %.3f\n", i, circles[i].xc, circles[i].yc, circles[i].radius);
for (i=0; i<ncircles_b; i++) printf("circle %i: (%.3f, %.3f) radius %.3f\n", i, circles_b[i].xc, circles_b[i].yc, circles_b[i].radius);
/* initialize total energy table */
if ((PLOT == P_MEAN_ENERGY)||(PLOT_B == P_MEAN_ENERGY)||(PLOT == P_LOG_MEAN_ENERGY)||(PLOT_B == P_LOG_MEAN_ENERGY))
@ -802,7 +815,8 @@ void animation()
blank();
glColor3f(0.0, 0.0, 0.0);
printf("drawing wave\n");
draw_wave_comp(phi, psi, xy_in, 1.0, 0, PLOT);
// draw_wave_comp(phi, psi, xy_in, 1.0, 0, PLOT);
draw_wave_comp_highres_palette(2, phi, psi, total_energy, average_energy, total_flux, color_scale, xy_in, 1.0, 0, PLOT, COLOR_PALETTE, 0, 1.0);
printf("drawing billiard\n");
draw_billiard_comp(0, 1.0);
@ -828,7 +842,7 @@ void animation()
else scale = 1.0;
// draw_wave_comp(phi, psi, xy_in, scale, i, PLOT);
draw_wave_comp_highres_palette(resol, phi, psi, total_energy, xy_in, scale, i, PLOT, COLOR_PALETTE, 0, 1.0);
draw_wave_comp_highres_palette(2, phi, psi, total_energy, average_energy, total_flux, color_scale, xy_in, 1.0, i, PLOT, COLOR_PALETTE, 0, 1.0);
for (j=0; j<NVID; j++)
{
@ -837,11 +851,33 @@ void animation()
}
/* add oscillating waves */
if ((ADD_OSCILLATING_SOURCE)&&(i%OSCILLATING_SOURCE_PERIOD == 1))
wave_source_x[0] = circles[81].xc;
wave_source_y[0] = circles[81].yc;
source_periods[0] = OSCILLATING_SOURCE_PERIOD;
source_amp[0] = INITIAL_AMP;
wave_source_x[1] = circles[189].xc;
wave_source_y[1] = circles[189].yc;
source_periods[1] = OSCILLATING_SOURCE_PERIOD/1.5;
source_amp[1] = INITIAL_AMP;
for (source = 0; source < N_SOURCES; source++)
{
if (ALTERNATE_OSCILLATING_SOURCE) sign = -sign;
add_circular_wave(sign, -1.75, 0.16, phi, psi, xy_in);
add_circular_wave(sign, -1.75, -0.16, phi, psi, xy_in);
dperiod = source_periods[source];
phase = i - (int)(dperiod*(double)((int)((double)i/dperiod)));
if ((ADD_OSCILLATING_SOURCE)&&(phase == 1)&&(i<MAX_PULSING_TIME))
{
printf("Source %i: Adding pulse %i at (%.3lg, %.3lg)\n", source, add_counter[source], wave_source_x[source], wave_source_y[source]);
add_counter[source]++;
if (ALTERNATE_OSCILLATING_SOURCE) sign[source] = -sign[source];
add_circular_wave(-sign[source]*source_amp[source], wave_source_x[source], wave_source_y[source], phi, psi, xy_in);
}
}
/* add oscillating waves */
// if ((ADD_OSCILLATING_SOURCE)&&(i%OSCILLATING_SOURCE_PERIOD == 1))
// {
// if (ALTERNATE_OSCILLATING_SOURCE) sign = -sign;
// add_circular_wave(sign, -1.75, 0.16, phi, psi, xy_in);
// add_circular_wave(sign, -1.75, -0.16, phi, psi, xy_in);
// if (first_source) for (k=0; k<NSOURCES; k++)
// {
@ -882,7 +918,7 @@ void animation()
// wave_source[k].sign *= -1;
// }
// }
}
// }
draw_billiard_comp(0, 1.0);
@ -919,7 +955,7 @@ void animation()
else /*if (DOUBLE_MOVIE)*/
{
// draw_wave_comp(phi, psi, xy_in, scale, i, PLOT_B);
draw_wave_comp_highres_palette(resol, phi, psi, total_energy, xy_in, scale, i, PLOT_B, COLOR_PALETTE_B, 0, 1.0);
draw_wave_comp_highres_palette(2, phi, psi, total_energy, average_energy, total_flux, color_scale, xy_in, 1.0, i, PLOT_B, COLOR_PALETTE_B, 0, 1.0);
draw_billiard_comp(0, 1.0);
if (DRAW_COLOR_SCHEME) draw_color_bar_palette(PLOT_B, COLORBAR_RANGE_B, COLOR_PALETTE_B, 0, 1.0);
glutSwapBuffers();
@ -950,7 +986,7 @@ void animation()
if (DOUBLE_MOVIE)
{
// draw_wave_comp(phi, psi, xy_in, scale, i, PLOT);
draw_wave_comp_highres_palette(resol, phi, psi, total_energy, xy_in, scale, NSTEPS, PLOT, COLOR_PALETTE, 0, 1.0);
draw_wave_comp_highres_palette(2, phi, psi, total_energy, average_energy, total_flux, color_scale, xy_in, 1.0, NSTEPS, PLOT, COLOR_PALETTE, 0, 1.0);
draw_billiard_comp(0, 1.0);
if (DRAW_COLOR_SCHEME) draw_color_bar_palette(PLOT, COLORBAR_RANGE, COLOR_PALETTE, 0, 1.0);
glutSwapBuffers();
@ -959,7 +995,7 @@ void animation()
else for (i=0; i<MID_FRAMES; i++)
{
fade_value = 1.0 - (double)i/(double)MID_FRAMES;
draw_wave_comp_highres_palette(resol, phi, psi, total_energy, xy_in, scale, NSTEPS, PLOT, COLOR_PALETTE, 1, fade_value);
draw_wave_comp_highres_palette(2, phi, psi, total_energy, average_energy, total_flux, color_scale, xy_in, 1.0, NSTEPS, PLOT, COLOR_PALETTE, 1, fade_value);
draw_billiard_comp(1, fade_value);
if (DRAW_COLOR_SCHEME) draw_color_bar_palette(PLOT, COLORBAR_RANGE, COLOR_PALETTE, 1, fade_value);
if (!NO_EXTRA_BUFFER_SWAP) glutSwapBuffers();
@ -968,7 +1004,7 @@ void animation()
if (DOUBLE_MOVIE)
{
// draw_wave_comp(phi, psi, xy_in, scale, i, PLOT_B);
draw_wave_comp_highres_palette(resol, phi, psi, total_energy, xy_in, scale, NSTEPS, PLOT_B, COLOR_PALETTE_B, 0, 1.0);
draw_wave_comp_highres_palette(2, phi, psi, total_energy, average_energy, total_flux, color_scale, xy_in, 1.0, NSTEPS, PLOT_B, COLOR_PALETTE_B, 0, 1.0);
draw_billiard_comp(0, 1.0);
if (DRAW_COLOR_SCHEME) draw_color_bar_palette(PLOT_B, COLORBAR_RANGE_B, COLOR_PALETTE_B, 0, 1.0);
glutSwapBuffers();
@ -977,7 +1013,7 @@ void animation()
else for (i=0; i<END_FRAMES; i++)
{
fade_value = 1.0 - (double)i/(double)END_FRAMES;
draw_wave_comp_highres_palette(resol, phi, psi, total_energy, xy_in, scale, NSTEPS, PLOT_B, COLOR_PALETTE_B, 1, fade_value);
draw_wave_comp_highres_palette(2, phi, psi, total_energy, average_energy, total_flux, color_scale, xy_in, 1.0, NSTEPS, PLOT_B, COLOR_PALETTE_B, 1, fade_value);
draw_billiard_comp(1, fade_value);
if (DRAW_COLOR_SCHEME) draw_color_bar_palette(PLOT_B, COLORBAR_RANGE_B, COLOR_PALETTE_B, 1, fade_value);
glutSwapBuffers();
@ -995,9 +1031,17 @@ void animation()
free(psi[i]);
free(tmp[i]);
free(total_energy[i]);
free(average_energy[i]);
free(xy_in[i]);
free(color_scale[i]);
free(tcc_table[i]);
}
if (FADE_IN_OBSTACLE) free(fade_table);
if (MEAN_FLUX) free(total_flux);
}

View File

@ -41,21 +41,19 @@
#include <sys/types.h>
#include <tiffio.h> /* Sam Leffler's libtiff library. */
#include <omp.h>
#include <time.h>
#define MOVIE 0 /* set to 1 to generate movie */
#define SAVE_MEMORY 0 /* set to 1 to save memory when writing tiff images */
#define SAVE_MEMORY 1 /* set to 1 to save memory when writing tiff images */
#define WINWIDTH 1280 /* window width */
#define WINHEIGHT 720 /* window height */
#define WINWIDTH 1920 /* window width */
#define WINHEIGHT 1150 /* window height */
#define HIGHRES 1 /* set to 1 if resolution of grid is double that of displayed image */
#define NX 1280 /* number of grid points on x axis */
#define NY 720 /* number of grid points on y axis */
#define YMID 360 /* mid point of display */
#define NX 3840 /* number of grid points on x axis */
#define NY 2300 /* number of grid points on y axis */
#define YMID 1150 /* mid point of display */
// #define XMIN -1.777777778
// #define XMAX 1.777777778 /* x interval */
// #define YMIN -1.0
// #define YMAX 1.0 /* y interval for 9/16 aspect ratio */
#define XMIN -2.0
#define XMAX 2.0 /* x interval */
#define YMIN -1.125
@ -65,8 +63,8 @@
/* Choice of the billiard table */
#define B_DOMAIN 20 /* choice of domain shape, see list in global_pdes.c */
#define B_DOMAIN_B 20 /* choice of domain shape, see list in global_pdes.c */
#define B_DOMAIN 947 /* choice of domain shape, see list in global_pdes.c */
#define B_DOMAIN_B 947 /* choice of domain shape, see list in global_pdes.c */
#define CIRCLE_PATTERN 2 /* pattern of circles, see list in global_pdes.c */
#define CIRCLE_PATTERN_B 11 /* pattern of circles, see list in global_pdes.c */
@ -85,9 +83,9 @@
#define HEX_NONUNIF_COMPRESSSION 0.15 /* compression factor for HEX_NONUNIF pattern */
#define HEX_NONUNIF_COMPRESSSION_B -0.15 /* compression factor for HEX_NONUNIF pattern */
#define LAMBDA 0.75 /* parameter controlling the dimensions of domain */
#define MU 0.03 /* parameter controlling the dimensions of domain */
#define MUB 0.03 /* parameter controlling the dimensions of domain */
#define LAMBDA 0.6 /* parameter controlling the dimensions of domain */
#define MU 0.075 /* parameter controlling the dimensions of domain */
#define MUB 1.0 /* parameter controlling the dimensions of domain */
#define NPOLY 3 /* number of sides of polygon */
#define APOLY 1.0 /* angle by which to turn polygon, in units of Pi/2 */
#define APOLY_B 0.335 /* angle by which to turn polygon, in units of Pi/2 */
@ -96,8 +94,15 @@
#define MANDELLEVEL 1000 /* iteration level for Mandelbrot set */
#define MANDELLIMIT 10.0 /* limit value for approximation of Mandelbrot set */
#define FOCI 1 /* set to 1 to draw focal points of ellipse */
#define NGRIDX 15 /* number of grid point for grid of disks */
#define NGRIDY 20 /* number of grid point for grid of disks */
#define NGRIDX 6 /* number of grid point for grid of disks */
#define NGRIDY 12 /* number of grid point for grid of disks */
#define WALL_WIDTH 0.013 /* width of wall separating lenses */
#define WALL_WIDTH_B 0.01 /* width of wall separating lenses */
#define WALL_WIDTH_RND 0.0 /* proportion of width of width for random arrangements */
#define RADIUS_FACTOR 0.3 /* controls inner radius for C_RING arrangements */
#define WALL_WIDTH_ASYM 1.25 /* asymmetry of wall width (D_CIRCLE_LATTICE_NONISO) */
#define WALL_WIDTH_ASYM_B 0.75 /* asymmetry of wall width (D_CIRCLE_LATTICE_HEX_NONISO) */
#define X_SHOOTER -0.2
#define Y_SHOOTER -0.6
@ -115,16 +120,16 @@
/* Physical parameters of wave equation */
#define TWOSPEEDS 0 /* set to 1 to replace hardcore boundary by medium with different speed */
#define TWOSPEEDS 1 /* set to 1 to replace hardcore boundary by medium with different speed */
#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 OSCILLATE_TOPBOT 1 /* set to 1 to enforce a planar wave on top and bottom boundary */
#define OMEGA 0.0 /* frequency of periodic excitation */
#define AMPLITUDE 0.025 /* amplitude of periodic excitation */
#define COURANT 0.02 /* Courant number */
#define COURANTB 0.004 /* Courant number in medium B */
#define OMEGA 0.0125 /* frequency of periodic excitation */
#define AMPLITUDE 0.5 /* amplitude of periodic excitation */
#define COURANT 0.1 /* Courant number */
#define COURANTB 0.035 /* Courant number in medium B */
#define GAMMA 0.0 /* damping factor in wave equation */
#define GAMMAB 1.0e-8 /* damping factor in wave equation */
#define GAMMAB 0.0 /* damping factor in wave equation */
#define GAMMA_SIDES 1.0e-4 /* damping factor on boundary */
#define GAMMA_TOPBOT 1.0e-6 /* damping factor on boundary */
#define KAPPA 0.0 /* "elasticity" term enforcing oscillations */
@ -135,6 +140,13 @@
/* Increasing COURANT speeds up the simulation, but decreases accuracy */
/* For similar wave forms, COURANT^2*GAMMA should be kept constant */
#define ADD_OSCILLATING_SOURCE 1 /* set to 1 to add an oscillating wave source */
#define OSCILLATING_SOURCE_PERIOD 12.5 /* period of oscillating source */
#define ALTERNATE_OSCILLATING_SOURCE 1 /* set to 1 to alternate sign of oscillating source */
#define N_SOURCES 1 /* number of sources, for option draw_sources */
#define ALTERNATE_SOURCE_PHASES 0 /* set to 1 to alternate initial phases of sources */
#define MAX_PULSING_TIME 500 /* max time for adding pulses */
/* Boundary conditions, see list in global_pdes.c */
// #define B_COND 2
@ -142,10 +154,10 @@
/* Parameters for length and speed of simulation */
#define NSTEPS 3750 /* number of frames of movie */
#define NVID 25 /* number of iterations between images displayed on screen */
#define NSTEPS 4500 /* number of frames of movie */
#define NVID 8 /* number of iterations between images displayed on screen */
#define NSEG 100 /* number of segments of boundary */
#define INITIAL_TIME 200 /* time after which to start saving frames */
#define INITIAL_TIME 0 /* time after which to start saving frames */
#define COMPUTE_ENERGIES 1 /* set to 1 to compute and print energies */
#define BOUNDARY_WIDTH 2 /* width of billiard boundary */
@ -157,13 +169,13 @@
/* Parameters of initial condition */
#define INITIAL_AMP 0.2 /* amplitude of initial condition */
#define INITIAL_VARIANCE 0.002 /* variance of initial condition */
#define INITIAL_WAVELENGTH 0.1 /* wavelength of initial condition */
#define INITIAL_AMP 0.75 /* amplitude of initial condition */
#define INITIAL_VARIANCE 0.0005 /* variance of initial condition */
#define INITIAL_WAVELENGTH 0.025 /* wavelength of initial condition */
/* Plot type, see list in global_pdes.c */
#define PLOT 1
#define PLOT 0
/* Color schemes */
@ -175,13 +187,17 @@
#define COLOR_SCHEME 3 /* choice of color scheme, see list in global_pdes.c */
#define SCALE 0 /* set to 1 to adjust color scheme to variance of field */
#define SLOPE 10.0 /* sensitivity of color on wave amplitude */
#define SLOPE 1.5 /* sensitivity of color on wave amplitude */
#define COLOR_RANGE 1.0 /* max range of color (default: 1.0) */
#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 VSHIFT_AMPLITUDE 0.0 /* additional shift for wave amplitude */
#define VSCALE_AMPLITUDE 0.5 /* additional scaling factor for wave amplitude */
#define E_SCALE 500.0 /* scaling factor for energy representation */
#define E_SCALE 20.0 /* scaling factor for energy representation */
#define PLOT_ESCALE 1.0e-3 /* vertical scale for energy plot */
#define PLOT_ESCALE_LOG 0.1 /* vertical scale for log energy plot */
#define PLOT_ESCALE_LOG_SHIFT 0.5 /* shift of log energy plot */
#define LOG_SCALE 1.5 /* scaling factor for energy log representation */
#define LOG_SHIFT 1.0 /* shift of colors on log scale */
#define FLUX_SCALE 1.0e4 /* scaling factor for enegy flux represtnation */
@ -205,7 +221,7 @@
/* the following constants are only used by wave_billiard and wave_3d so far */
#define COMPARISON 0 /* set to 1 to compare two different patterns */
#define OSCILLATION_SCHEDULE 3 /* oscillation schedule, see list in global_pdes.c */
#define OSCILLATION_SCHEDULE 0 /* oscillation schedule, see list in global_pdes.c */
#define ACHIRP 0.2 /* acceleration coefficient in chirp */
#define DAMPING 0.0 /* damping of periodic excitation */
/* end of constants only used by wave_billiard and wave_3d */
@ -226,15 +242,12 @@
#define MANDEL_IOR_SCALE -0.05 /* parameter controlling dependence of IoR on Mandelbrot escape speed */
#define WAVE_PACKET_SOURCE_TYPE 1 /* type of wave packet sources */
#define N_WAVE_PACKETS 15 /* number of wave packets */
#define OSCIL_LEFT_YSHIFT 0.0 /* y-dependence of left oscillation (for non-horizontal waves) */
#define OSCIL_LEFT_YSHIFT 40.0 /* y-dependence of left oscillation (for non-horizontal waves) */
#define DRAW_WAVE_PROFILE 0 /* set to 1 to draw a profile of the wave */
#define OSCILLATING_SOURCE_PERIOD 20 /* period of oscillating source */
#define MU_B 1.0 /* parameter controlling the dimensions of domain */
#define DRAW_WAVE_PROFILE 0 /* set to 1 to draw a profile of the wave */
#define VERTICAL_WAVE_PROFILE 0 /* set to 1 to draw wave profile vertically */
#define DRAW_WAVE_TIMESERIES 0 /* set to 1 to draw a time series of the wave */
#define WALL_WIDTH 0.1 /* width of wall separating lenses */
#define WALL_WIDTH_RND 0.0 /* proportion of width of width for random arrangements */
#define RADIUS_FACTOR 0.3 /* controls inner radius for C_RING arrangements */
#define OSCIL_YMAX 0.35 /* defines oscillation range */
#define MESSAGE_LDASH 14 /* length of dash for Morse code message */
@ -255,8 +268,8 @@
#define INITIAL_SHIFT 20.0 /* time shift of initial wave packet (in oscillation periods) */
#define WAVE_PACKET_SHIFT 200.0 /* time shift between wave packets (in oscillation periods) */
#define FADE_IN_OBSTACLE 0 /* set to 1 to fade color inside obstacles */
#define SHADE_2D 0 /* set to 1 to add pseudo-3d shading effect */
#define SHADE_SCALE_2D 0.05 /* lower value increases sensitivity of shading */
#define SHADE_2D 1 /* set to 1 to add pseudo-3d shading effect */
#define SHADE_SCALE_2D 0.01 /* lower value increases sensitivity of shading */
#define N_SOURCES 1 /* number of sources, for option draw_sources */
#define XYIN_INITIALISED (B_DOMAIN == D_IMAGE)
double light[2] = {0.40824829, 0.816496581}; /* location of light source for SHADE_2D option*/
@ -291,27 +304,30 @@ double logscale_y(double energy)
{
ymid = 0.5*(YMIN + YMAX);
yscale = (YMAX - YMIN)*0.5/2.25;
first = 0;
}
return(ymid + yscale*(1.0 + 0.2*log(energy)));
return(ymid + yscale*(PLOT_ESCALE_LOG_SHIFT + 0.2*log(energy)));
// return(ymid + 0.5*(1.0 + 0.2*log(energy)));
}
void draw_wave_energy(double *phi[NX], double *psi[NX], short int *xy_in[NX], double scale, int time)
/* draw the field */
{
int i, j, iplus, iminus, jplus, jminus;
double rgb[3], xy[2], x, y, x1, y1, x2, y2, velocity, energy, gradientx2, gradienty2, pos[2], escale;
double energies[NX], ymid;
int i, j, k, iplus, iminus, jplus, jminus, size = 1;
double rgb[3], xy[2], x, y, x1, y1, x2, y2, velocity, energy, gradientx, gradienty, gradientx2, gradienty2, pos[2], norm, pscal, ca, vscale2, escale;
double energies[NX], ymid, *values, *shade, *rgbvals;
static double dtinverse = ((double)NX)/(COURANT*(XMAX-XMIN)), dx = (XMAX-XMIN)/((double)NX);
char message[50];
values = (double *)malloc(NX*NY*sizeof(double));
rgbvals = (double *)malloc(3*NX*NY*sizeof(double));
ymid = 0.5*(YMIN + YMAX);
glBegin(GL_QUADS);
// printf("dtinverse = %.5lg\n", dtinverse);
#pragma omp parallel for private(i,j,rgb)
for (i=0; i<NX; i++)
for (j=0; j<NY/2; j++)
{
@ -319,6 +335,7 @@ void draw_wave_energy(double *phi[NX], double *psi[NX], short int *xy_in[NX], do
switch (PLOT) {
case (P_AMPLITUDE):
{
values[i*NY+j] = phi[i][j];
/* make wave luminosity larger inside obstacles */
if (!(xy_in[i][j])) color_scheme_lum(COLOR_SCHEME, phi[i][j], scale, time, 0.7, rgb);
else color_scheme(COLOR_SCHEME, phi[i][j], scale, time, rgb);
@ -327,6 +344,7 @@ void draw_wave_energy(double *phi[NX], double *psi[NX], short int *xy_in[NX], do
case (P_ENERGY):
{
energy = compute_energy(phi, psi, xy_in, i, j);
values[i*NY+j] = energy;
/* adjust energy to color palette */
if (COLOR_PALETTE >= COL_TURBO) color_scheme_asym(COLOR_SCHEME, energy, scale, time, rgb);
else color_scheme(COLOR_SCHEME, energy, scale, time, rgb);
@ -334,26 +352,74 @@ void draw_wave_energy(double *phi[NX], double *psi[NX], short int *xy_in[NX], do
}
case (P_MIXED):
{
if (j > NY/2) color_scheme(COLOR_SCHEME, phi[i][j], scale, time, rgb);
else color_scheme(COLOR_SCHEME, compute_energy(phi, psi, xy_in, i, j), scale, time, rgb);
if (j > NY/2)
{
values[i*NY+j] = phi[i][j];
color_scheme(COLOR_SCHEME, phi[i][j], scale, time, rgb);
}
else
{
energy = compute_energy(phi, psi, xy_in, i, j);
values[i*NY+j] = energy;
color_scheme(COLOR_SCHEME, energy, scale, time, rgb);
}
break;
}
}
glColor3f(rgb[0], rgb[1], rgb[2]);
rgbvals[i*NY+j] = rgb[0];
rgbvals[NX*NY+i*NY+j] = rgb[1];
rgbvals[2*NX*NY+i*NY+j] = rgb[2];
}
}
if (SHADE_2D)
{
vscale2 = SHADE_SCALE_2D*SHADE_SCALE_2D;
shade = (double *)malloc(NX*NY*sizeof(double));
#pragma omp parallel for private(i,j,gradientx,gradienty,norm,pscal,ca)
for (i=0; i<NX-size; i+=size)
{
for (j=0; j<NY/2-size; j+=size)
{
gradientx = values[(i+1)*NY+j] - values[i*NY+j];
gradienty = values[i*NY+j+1] - values[i*NY+j];
norm = sqrt(vscale2 + gradientx*gradientx + gradienty*gradienty);
pscal = -gradientx*light[0] - gradienty*light[1] + SHADE_SCALE_2D;
ca = pscal/norm;
ca = (ca + 1.0)*0.4 + 0.2;
for (k=0; k<3; k++) rgbvals[k*NX*NY+i*NY+j] *= ca;
}
}
}
glBegin(GL_QUADS);
for (i=0; i<NX; i+=size)
for (j=0; j<NY/2; j+=size)
{
if ((TWOSPEEDS)||(xy_in[i][j]))
{
glColor3f(rgbvals[i*NY+j], rgbvals[NX*NY+i*NY+j], rgbvals[2*NX*NY+i*NY+j]);
glVertex2i(i, j);
glVertex2i(i+1, j);
glVertex2i(i+1, j+1);
glVertex2i(i, j+1);
glVertex2i(i+size, j);
glVertex2i(i+size, j+size);
glVertex2i(i, j+size);
}
}
glEnd ();
if (SHADE_2D) free(shade);
/* compute and plot energies */
for (i=0; i<NX; i++) energies[i] = compute_energy_x(i, phi, psi, xy_in);
glEnable(GL_SCISSOR_TEST);
glScissor(0.0, YMID/(HIGHRES+1), NX, YMID/(HIGHRES+1));
glColor3f(0.0, 0.0, 0.0);
glBegin(GL_QUADS);
glVertex2i(0, NY/2);
@ -365,7 +431,7 @@ void draw_wave_energy(double *phi[NX], double *psi[NX], short int *xy_in[NX], do
/* log coordinate lines */
glLineWidth(1);
glColor3f(1.0, 1.0, 1.0);
for (i=-2; i<3; i++)
for (i=-2; i<6; i++)
{
energy = pow(10.0, (double)i);
y = logscale_y(energy);
@ -379,7 +445,7 @@ void draw_wave_energy(double *phi[NX], double *psi[NX], short int *xy_in[NX], do
glEnd();
}
glColor3f(0.5, 0.5, 0.5);
for (i=-2; i<3; i++)
for (i=-2; i<6; i++)
{
for (j=2; j<10; j++)
{
@ -423,7 +489,7 @@ void draw_wave_energy(double *phi[NX], double *psi[NX], short int *xy_in[NX], do
glEnd();
/* y axis labels */
for (i=-2; i<3; i++)
for (i=-2; i<6; i++)
{
y = logscale_y(pow(10.0, (double)i));
erase_area_hsl(XMIN + 0.06, y + 0.025, 0.12, 0.02, 0.0, 1.0, 0.0);
@ -435,7 +501,7 @@ void draw_wave_energy(double *phi[NX], double *psi[NX], short int *xy_in[NX], do
/* energy */
glColor3f(1.0, 0.0, 0.0);
escale = 0.01;
escale = PLOT_ESCALE;
glBegin(GL_LINE_STRIP);
for (i=0; i<NX; i++)
{
@ -446,6 +512,7 @@ void draw_wave_energy(double *phi[NX], double *psi[NX], short int *xy_in[NX], do
}
glEnd();
glDisable(GL_SCISSOR_TEST);
/* draw horizontal mid line */
glColor3f(1.0, 1.0, 1.0);
@ -455,6 +522,9 @@ void draw_wave_energy(double *phi[NX], double *psi[NX], short int *xy_in[NX], do
xy_to_pos(XMAX, 0.5*(YMIN+YMAX), pos);
glVertex2d(pos[0], pos[1]);
glEnd();
free(values);
free(rgbvals);
}
/*********************/
@ -563,7 +633,9 @@ void evolve_wave_half_old(double *phi_in[NX], double *psi_in[NX], double *phi_ou
}
/* add oscillating boundary condition on the left */
if ((i == 0)&&(OSCILLATE_LEFT)) phi_out[i][j] = AMPLITUDE*cos((double)time*OMEGA);
if ((i == 0)&&(OSCILLATE_LEFT))
phi_out[0][j] = oscillating_bc(time, j);
// phi_out[i][j] = AMPLITUDE*cos((double)time*OMEGA);
psi_out[i][j] = x;
@ -587,13 +659,15 @@ void evolve_wave_half(double *phi_in[NX], double *psi_in[NX], double *phi_out[NX
/* phi is value of field at time t, psi at time t-1 */
{
int i, j, iplus, iminus, jplus, jminus, jmid = NY/2;
double delta, x, y, c, cc, gamma;
double delta, x, y, c, cc, gamma, tb_shift;
static long time = 0;
static double tc[NX][NY/2], tcc[NX][NY/2], tgamma[NX][NY/2];
static short int first = 1;
time++;
if (OSCILLATE_TOPBOT) tb_shift = (int)((XMAX - XMIN)*(double)NX/(XMAX - XMIN));
/* initialize tables with wave speeds and dissipation */
if (first)
{
@ -634,7 +708,9 @@ void evolve_wave_half(double *phi_in[NX], double *psi_in[NX], double *phi_out[NX
}
/* left boundary */
if (OSCILLATE_LEFT) for (j=1; j<jmid; j++) phi_out[0][j] = AMPLITUDE*cos((double)time*OMEGA);
if (OSCILLATE_LEFT) for (j=1; j<jmid; j++)
phi_out[0][j] = oscillating_bc(time, j);
// phi_out[0][j] = AMPLITUDE*cos((double)time*OMEGA);
else for (j=1; j<jmid-1; j++){
if ((TWOSPEEDS)||(xy_in[0][j] != 0)){
x = phi_in[0][j];
@ -710,7 +786,15 @@ void evolve_wave_half(double *phi_in[NX], double *psi_in[NX], double *phi_out[NX
x = phi_in[i][jmid-1];
y = psi_in[i][jmid-1];
switch (B_COND) {
if ((OSCILLATE_TOPBOT)&&(i < tb_shift)&&(i<NX-1)&&(i>0))
{
iplus = i+1;
iminus = i-1; if (iminus < 0) iminus = 0;
delta = phi_in[iplus][NY-1] + phi_in[iminus][NY-1] + - 2.0*x;
phi_out[i][NY-1] = -y + 2*x + tcc[i][NY-1]*delta - KAPPA*x - tgamma[i][NY-1]*(x-y);
}
else switch (B_COND) {
case (BC_DIRICHLET):
{
iplus = i+1; if (iplus == NX) iplus = NX-1;
@ -838,10 +922,10 @@ void evolve_wave(double *phi[NX], double *psi[NX], double *tmp[NX], short int *x
void animation()
{
double time, scale, energies[6], top_energy, bottom_energy;
double time, scale, energies[6], top_energy, bottom_energy, source_amp[N_SOURCES], source_periods[N_SOURCES], sign[N_SOURCES];
double *phi[NX], *psi[NX], *tmp[NX];
short int *xy_in[NX];
int i, j, s;
int i, j, s, source, source_period, source_shift[N_SOURCES], phase, dperiod, add_counter[N_SOURCES];
/* Since NX and NY are big, it seemed wiser to use some memory allocation here */
for (i=0; i<NX; i++)
@ -857,13 +941,18 @@ void animation()
if ((B_DOMAIN == D_CIRCLES)||(B_DOMAIN_B == D_CIRCLES)) init_circle_config_energy(circles);
else if (B_DOMAIN == D_POLYGONS) init_polygon_config(polygons);
npolyline = init_poly(MDEPTH, polyline, polyrect, polyrectrot, polyarc, circles, &npolyrect, &npolyrect_rot, &npolyarc, &ncircles, 1);
courant2 = COURANT*COURANT;
courantb2 = COURANTB*COURANTB;
for (i=0; i<N_SOURCES; i++) add_counter[i] = 0;
if (ALTERNATE_SOURCE_PHASES) for (i=0; i<N_SOURCES; i++) sign[i] = pow(-1.0,(double)i);
else for (i=0; i<N_SOURCES; i++) sign[i] = 1.0;
/* initialize wave with a drop at one point, zero elsewhere */
// init_wave_flat_comp(phi, psi, xy_in);
int_planar_wave_comp(XMIN + 0.015, 0.0, phi, psi, xy_in);
init_wave_flat_comp(phi, psi, xy_in);
// int_planar_wave_comp(XMIN + 0.015, 0.0, phi, psi, xy_in);
// int_planar_wave_comp(XMIN + 0.5, 0.0, phi, psi, xy_in);
printf("initializing wave\n");
// int_planar_wave_comp(XMIN + 0.1, 0.0, phi, psi, xy_in);
@ -907,7 +996,23 @@ void animation()
draw_billiard_half(B_DOMAIN, CIRCLE_PATTERN, 0, 0, 1.0);
/* add oscillating waves */
wave_source_x[0] = -1.0;
wave_source_y[0] = 0.5*YMIN;
source_periods[0] = OSCILLATING_SOURCE_PERIOD;
source_amp[0] = INITIAL_AMP;
for (source = 0; source < N_SOURCES; source++)
{
dperiod = source_periods[source];
phase = i - (int)(dperiod*(double)((int)((double)i/dperiod)));
if ((ADD_OSCILLATING_SOURCE)&&(phase == 1)&&(i<MAX_PULSING_TIME))
{
printf("Source %i: Adding pulse %i\n", source, add_counter[source]);
add_counter[source]++;
if (ALTERNATE_OSCILLATING_SOURCE) sign[source] = -sign[source];
add_circular_wave_comp(-sign[source]*source_amp[source], wave_source_x[source], wave_source_y[source], phi, psi, xy_in, 0);
}
}
for (j=0; j<NVID; j++)
{
@ -952,6 +1057,12 @@ void animation()
void display(void)
{
time_t rawtime;
struct tm * timeinfo;
time(&rawtime);
timeinfo = localtime(&rawtime);
glPushMatrix();
blank();
@ -966,6 +1077,10 @@ void display(void)
glutDestroyWindow(glutGetWindow());
printf("Start local time and date: %s", asctime(timeinfo));
time(&rawtime);
timeinfo = localtime(&rawtime);
printf("Current local time and date: %s", asctime(timeinfo));
}

View File

@ -39,7 +39,7 @@
#include <omp.h>
#include <time.h>
#define MOVIE 0 /* set to 1 to generate movie */
#define MOVIE 1 /* set to 1 to generate movie */
#define DOUBLE_MOVIE 0 /* set to 1 to produce movies for wave height and energy simultaneously */
#define SAVE_MEMORY 1 /* set to 1 to save memory when writing tiff images */
#define NO_EXTRA_BUFFER_SWAP 1 /* some OS require one less buffer swap when recording images */
@ -102,8 +102,11 @@
#define NGRIDX 30 /* number of grid point for grid of disks */
#define NGRIDY 18 /* number of grid point for grid of disks */
#define WALL_WIDTH 0.6 /* width of wall separating lenses */
#define WALL_WIDTH_B 0.01 /* width of wall separating lenses */
#define WALL_WIDTH_RND 0.0 /* proportion of width of width for random arrangements */
#define RADIUS_FACTOR 0.3 /* controls inner radius for C_RING arrangements */
#define WALL_WIDTH_ASYM 0.75 /* asymmetry of wall width (D_CIRCLE_LATTICE_NONISO) */
#define WALL_WIDTH_ASYM_B 0.75 /* asymmetry of wall width (D_CIRCLE_LATTICE_HEX_NONISO) */
#define X_SHOOTER -0.2
#define Y_SHOOTER -0.6
@ -255,6 +258,7 @@
#define SCALE 0 /* set to 1 to adjust color scheme to variance of field */
#define SLOPE 1.0 /* sensitivity of color on wave amplitude */
#define COLOR_RANGE 1.0 /* max range of color (default: 1.0) */
#define VSCALE_AMPLITUDE 0.5 /* additional scaling factor for color scheme P_3D_AMPLITUDE */
#define VSHIFT_AMPLITUDE 0.0 /* additional shift for wave amplitude */
#define VSCALE_ENERGY 5.0 /* additional scaling factor for color scheme P_3D_ENERGY */