Add files via upload

This commit is contained in:
Nils Berglund 2025-03-29 20:42:13 +01:00 committed by GitHub
parent 1259de740f
commit b4671480a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
26 changed files with 3212 additions and 340 deletions

View File

@ -63,6 +63,14 @@ void color_scheme(int scheme, double value, double scale, int time, double rgb[3
amp_to_rgb(amplitude, rgb);
break;
}
case (C_BASIC_LINEAR):
{
amplitude = color_amplitude_linear(value, scale, time);
if (amplitude > 1.0) amplitude -= 1.0;
else if (amplitude < 0.0) amplitude += 1.0;
amp_to_rgb(amplitude, rgb);
break;
}
}
}
@ -186,6 +194,17 @@ void color_scheme_palette(int scheme, int palette, double value, double scale, i
amp_to_rgb_palette(amplitude, rgb, palette);
break;
}
case (C_BASIC_LINEAR):
{
if (value > 1.0) value -= 1.0;
else if (value < 0.0) value += 1.0;
amp_to_rgb_palette(value, rgb, palette);
break;
// if (value > 2.0) value -= 2.0;
// else if (value < 0.0) value += 2.0;
// amp_to_rgb_palette(value, rgb, palette);
// break;
}
}
}

View File

@ -49,6 +49,7 @@
#define POLYLINE_PATTERN 1 /* pattern of polyline */
#define ABSORBING_CIRCLES 0 /* set to 1 for circular scatterers to be absorbing */
#define NABSCIRCLES 10 /* number of absorbing circles */
#define NMAXCIRCLES 1000 /* total number of circles (must be at least NCX*NCY for square grid) */
#define NMAXPOLY 1000 /* total number of sides of polygonal line */
@ -70,6 +71,9 @@
#define FOCI 1 /* set to 1 to draw focal points of ellipse */
#define NPOLY 4 /* number of sides of polygon */
#define APOLY 0.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 */

View File

@ -23,7 +23,7 @@
#define NMAXBELTS 10 /* max number of conveyor belts */
#define NMAXSHOVELS 50 /* max number of shovels */
#define NMAX_TRIANGLES_PER_OBSTACLE 10 /* max number of triangles per obstacle */
#define NMAX_TRIANGLES_PER_FACET 5 /* max number of triangles per facet between obstacles */
#define NMAX_TRIANGLES_PER_FACET 4 /* max number of triangles per facet between obstacles */
#define C_SQUARE 0 /* square grid of circles */
#define C_HEX 1 /* hexagonal/triangular grid of circles */
@ -388,7 +388,8 @@
#define C_HUE 1 /* color scheme modifies hue */
#define C_PHASE 2 /* color scheme shows phase */
#define C_ONEDIM 3 /* use preset 1d color scheme (for Turbo, Viridis, Magma, Inferno, Plasma, Twilight) */
#define C_ONEDIM_LINEAR 4 /* use preset 1d color scheme with linear scale */
#define C_ONEDIM_LINEAR 4 /* use preset 1d color scheme with linear scale */
#define C_BASIC_LINEAR 5 /* use preset 1d color scheme with linear scale */
/* Color palettes */

View File

@ -92,6 +92,7 @@ double x_shooter = -0.2, y_shooter = -0.6, x_target = 0.4, y_target = 0.7;
#define P_TOKA_PRIME 6 /* Tokarsky room made of 86 triangles */
#define P_TREE 7 /* pine tree */
#define P_TOKA_NONSELF 8 /* Tokarsky non-self-unilluminable room */
#define P_ISOCELES_TRIANGLE 9 /* rectangle isoceles triangle */
#define P_MAZE 10 /* maze */
#define P_MAZE_DIAG 11 /* maze with 45 degrees angles */
#define P_MAZE_RANDOM 12 /* maze with randomized wall positions */
@ -99,6 +100,7 @@ double x_shooter = -0.2, y_shooter = -0.6, x_target = 0.4, y_target = 0.7;
#define P_MAZE_CIRC_SCATTERER 14 /* circular maze with scatterers */
#define P_MAZE_HEX 15 /* hexagonal maze */
#define P_MAZE_OCT 16 /* maze with octagonal and square cells */
#define P_STAR 17 /* star-shaped domain */
/* Color palettes */

View File

@ -115,6 +115,11 @@
#define D_CARDIOID 90 /* cardioid */
#define D_NEPHROID 91 /* nephroid */
#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_HEX 94 /* hex lattice of connected circles */
#define D_CIRCLE_LATTICE_HONEY 95 /* honeycomb lattice of connected circles */
#define D_CIRCLE_LATTICE_POISSON 96 /* Poisson disc process of connected circles */
/* for wave_sphere.c */
@ -144,6 +149,7 @@
#define NMAXCIRCLES 10000 /* total number of circles/polygons (must be at least NCX*NCY for square grid) */
#define NMAXPOLY 50000 /* maximal number of vertices of polygonal lines (for von Koch et al) */
#define NMAXLINES 1000 /* maximal number of lines (for bounadries) */
#define NMAXSOURCES 30 /* maximal number of sources */
#define C_SQUARE 0 /* square grid of circles */
@ -304,7 +310,9 @@
#define C_HUE 1 /* color scheme modifies hue */
#define C_PHASE 2 /* color scheme shows phase */
#define C_ONEDIM 3 /* use preset 1d color scheme (for Turbo, Viridis, Magma, Inferno, Plasma) */
#define C_ONEDIM_LINEAR 4 /* use preset 1d color scheme with linear scale */
#define C_ONEDIM_LINEAR 4 /* use preset 1d color scheme with linear scale */
#define C_BASIC_LINEAR 5 /* use preset 1d color scheme with linear scale and slope 1, range is assumed to be [0,1] */
/* Color palettes */
@ -330,6 +338,7 @@
/* plot types used by rde */
#define Z_AMPLITUDE 0 /* amplitude of first 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 */
#define Z_NORM_GRADIENT 22 /* gradient of polar angle */
@ -403,6 +412,11 @@ typedef struct
double posi, posj; /* (i,j) coordinates of vertex */
} t_vertex;
// typedef struct
// {
// t_vertex z1, z2; /* extremities of line */
// } t_line;
typedef struct
{
double x1, y1, x2, y2; /* (x,y) coordinates of vertices */
@ -457,6 +471,7 @@ int npolyline = NMAXPOLY; /* actual length of polyline */
int npolyrect = NMAXPOLY; /* actual number of polyrect */
int npolyrect_rot = NMAXPOLY; /* actual number of rotated polyrect */
int npolyarc = NMAXPOLY; /* actual number of arcs */
// int nlines = NMAXLINES; /* actual number of lines */
short int input_signal[NSTEPS]; /* time-dependent source signal */
@ -466,6 +481,7 @@ t_vertex polyline[NMAXPOLY]; /* vertices of polygonal line */
t_rectangle polyrect[NMAXPOLY]; /* vertices of rectangles */
t_rect_rotated polyrectrot[NMAXPOLY]; /* data of rotated rectangles */
t_arc polyarc[NMAXPOLY]; /* data of arcs */
// t_line line[NMAXLINES]; /* data of lines */
/* the same for comparisons between different domains */
int ncircles_b = NMAXCIRCLES; /* actual number of circles, can be decreased e.g. for random patterns */

View File

@ -42,6 +42,7 @@
#define C_PHASE 2 /* color scheme shows phase */
#define C_ONEDIM 3 /* use preset 1d color scheme (for Turbo, Viridis, Magma, Inferno, Plasma) */
#define C_ONEDIM_LINEAR 4 /* use preset 1d color scheme with linear scale */
#define C_BASIC_LINEAR 5 /* use preset 1d color scheme with linear scale */
/* Color palettes */

2
heat.c
View File

@ -222,6 +222,8 @@
#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 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 */
#define INITIAL_TIME 50 /* time after which to start saving frames */
#define OSCIL_YMAX 0.35 /* defines oscillation range */

View File

@ -37,7 +37,7 @@
#include <time.h>
#define MOVIE 0 /* set to 1 to generate movie */
#define DOUBLE_MOVIE 0 /* set to 1 to produce movies for wave height and energy simultaneously */
#define DOUBLE_MOVIE 1 /* set to 1 to produce movies for wave height and energy simultaneously */
#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,25 +58,25 @@
#define YMIN -1.125
#define YMAX 1.125 /* y interval for 9/16 aspect ratio */
#define INITXMIN -1.0
#define INITXMIN -1.95
#define INITXMAX -1.9 /* x interval for initial condition */
#define INITYMIN -0.1
#define INITYMAX 0.1 /* y interval for initial condition */
#define INITYMIN 0.9
#define INITYMAX 1.0 /* 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 -2.2
#define ADDXMAX -2.0 /* x interval for adding particles */
#define ADDYMIN -1.0
#define ADDYMAX 1.0 /* y interval for adding particles */
#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 ADDRMIN 4.75
#define ADDRMAX 6.0 /* r interval for adding particles */
#define BCXMIN -2.5
#define BCXMAX 2.5 /* x interval for boundary condition */
#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 */
@ -90,15 +90,15 @@
#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 1 /* set to 1 do add fixed circular obstacles */
#define OBSTACLE_PATTERN 20 /* pattern of obstacles, see list in global_ljones.c */
#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 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.12 /* minimal distance in Poisson disc process for obstacles, controls density of obstacles */
#define OBSTACLE_COUPLING_DIST 0.18 /* max distance of coupled obstacles */
#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 NMAX_OBSTACLE_NEIGHBOURS 8 /* max number of obstacle neighbours */
#define NMAX_OBSTACLE_PINNED 10 /* max number of neighbours to be pinned */
#define NMAX_OBSTACLE_PINNED 3 /* 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 */
@ -126,7 +126,7 @@
#define CENTER_PY 0 /* set to 1 to center vertical momentum */
#define CENTER_PANGLE 0 /* set to 1 to center angular momentum */
#define INTERACTION 1 /* particle interaction, see list in global_ljones.c */
#define INTERACTION 12 /* particle interaction, see list in global_ljones.c */
#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 */
@ -134,15 +134,16 @@
#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 */
#define PDISC_DISTANCE 1.0 /* minimal distance in Poisson disc process, controls density of particles */
#define PDISC_DISTANCE 5.0 /* minimal distance in Poisson disc process, controls density of particles */
#define PDISC_CANDIDATES 100 /* number of candidates in construction of Poisson disc process */
#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.007 /* parameter controlling radius of particles */
#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 NPOLY 3 /* number of sides of polygon */
#define APOLY 0.075 /* angle by which to turn polygon, in units of Pi/2 */
#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 */
#define MDEPTH 4 /* depth of computation of Menger gasket */
#define MRATIO 3 /* ratio defining Menger gasket */
@ -155,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 20
#define NOBSY 10 /* obstacles for O_HEX obstacle pattern */
#define NOBSX 40
#define NOBSY 24 /* obstacles for O_HEX obstacle pattern */
#define NTREES 15 /* number of trees in S_TREES */
#define X_SHOOTER -0.2
@ -166,10 +167,10 @@
/* Parameters for length and speed of simulation */
#define NSTEPS 4500 /* number of frames of movie */
#define NVID 4500 /* number of iterations between images displayed on screen */
#define NSTEPS 2200 /* number of frames of movie */
#define NVID 150 /* number of iterations between images displayed on screen */
#define NSEG 25 /* number of segments of boundary of circles */
#define INITIAL_TIME 0 /* time after which to start saving frames */
#define INITIAL_TIME 30 /* 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 */
@ -184,25 +185,26 @@
/* Boundary conditions, see list in global_ljones.c */
#define BOUNDARY_COND 23
#define BOUNDARY_COND 1
/* Plot type, see list in global_ljones.c */
#define PLOT 13
#define PLOT_B 12 /* plot type for second movie */
#define PLOT 17
// #define PLOT 23
#define PLOT_B 17 /* plot type for second movie */
/* Background color depending on particle properties */
#define COLOR_BACKGROUND 0 /* set to 1 to color background */
#define BG_COLOR 7 /* type of background coloring, see list in global_ljones.c */
#define BG_COLOR_B 5 /* type of background coloring, see list in global_ljones.c */
#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 OBSTACLE_COLOR 0 /* type of obstacle, see OC_ in global_ljones.c */
#define DRAW_BONDS 0 /* set to 1 to draw bonds between neighbours */
#define COLOR_BONDS 1 /* set to 1 to color bonds according to length */
#define FILL_TRIANGLES 0 /* set to 1 to fill triangles between neighbours */
#define DRAW_CLUSTER_LINKS 0 /* set to 1 to draw links between particles in cluster */
#define DRAW_OBSTACLE_LINKS 1 /* set to 1 to draw links between interacting obstacles */
#define DRAW_OBSTACLE_LINKS 0 /* set to 1 to draw links between interacting obstacles */
#define FILL_OBSTACLE_TRIANGLES 0 /* set to 1 to fill triangles between interacting obstacles */
#define ALTITUDE_LINES 0 /* set to 1 to add horizontal lines to show altitude */
#define COLOR_SEG_GROUPS 0 /* set to 1 to collor segment groups differently */
@ -210,8 +212,8 @@
#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 160.0 /* controls sensitivity of triangle shade for option FILL_OBSTACLE_TRIANGLES */
#define SHADE_OBSTACLE_FACETS 0 /* set to 1 to shade facets instead of triangles */
#define OBSTACLE_AREA_SHADE_FACTOR 80.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 */
@ -263,10 +265,10 @@
#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 3000.0 /* energy of particle with hottest color */
#define PARTICLE_EMAX 100000.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 200.0 /* energy of obstacle with hottest color */
#define OBSTACLE_EMAX 150.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 */
@ -276,7 +278,7 @@
#define HUE_TYPE5 60.0 /* hue of particles of type 5 */
#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 7.5e-8 /* contant in BG_FORCE backgound color scheme*/
#define BG_FORCE_SLOPE 1.0e-6 /* contant in BG_FORCE backgound color scheme*/
#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) */
@ -284,9 +286,9 @@
#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 2.0e-7 /* time step for particle displacement */
#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.5 /* Lennard-Jones equilibrium distance */
#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 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) */
@ -294,10 +296,12 @@
#define INITIAL_DAMPING 1000.0 /* damping coefficient of particles during initial phase */
#define DAMPING_ROT 5.0 /* damping coefficient for rotation of 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 2.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 50.0 /* initial velocity range */
#define V_INITIAL 200.0 /* initial velocity range */
#define V_INITIAL_ADD 50.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 */
@ -324,13 +328,14 @@
#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 1 /* set to 1 to add an electric field */
#define EFIELD 0.0 /* value of electric field */
#define EFIELD_Y 1500.0 /* value of electric field */
#define ADD_BFIELD 1 /* set to 1 to add a magnetic field */
#define BFIELD 1200.0 /* value of magnetic field */
#define CHARGE 1.0 /* charge of particles of first type */
#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 INCREASE_B 0 /* set to 1 to increase magnetic field */
@ -338,8 +343,8 @@
#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 1.0e7 /* spring constant for oscillating obstacles */
#define KSPRING_OBSTACLE_COUPLE 5.0e6 /* spring constant for coupled obstacles */
#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 KSPRING_OBSTACLE_HARDCORE 1.0e11 /* spring constant for obstacle hard core repulsion */
#define KCOULOMB_OBSTACLE 1000.0 /* Coulomb force constant for charged obstacles */
@ -359,8 +364,8 @@
#define KTORQUE_DIFF 500.0 /* force constant in angular dynamics for different particles */
#define DRAW_SPIN 0 /* set to 1 to draw spin vectors of particles */
#define DRAW_SPIN_B 0 /* set to 1 to draw spin vectors of particles */
#define DRAW_CROSS 0 /* set to 1 to draw cross on particles of second type */
#define DRAW_MINUS 0 /* set to 1 to draw cross on particles of negative charge */
#define DRAW_CROSS 1 /* set to 1 to draw cross on particles of second type */
#define DRAW_MINUS 1 /* set to 1 to draw cross on particles of negative charge */
#define SPIN_RANGE 10.0 /* range of spin-spin interaction */
#define SPIN_RANGE_B 10.0 /* range of spin-spin interaction for second type of particle */
#define QUADRUPOLE_RATIO 0.6 /* anisotropy in quadrupole potential */
@ -386,7 +391,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.03 /* radius of obstacle for circle boundary conditions */
#define OBSTACLE_RADIUS 0.015 /* 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 */
@ -413,16 +418,17 @@
#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 150 /* time interval between adding further particles */
#define ADD_PERIOD 35 /* time interval between adding further particles */
#define N_ADD_PARTICLES 1 /* number of particles to add */
#define FINAL_NOADD_PERIOD 500 /* final period where no particles are added */
#define FINAL_NOADD_PERIOD 250 /* 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 TRACER_PARTICLE 1 /* set to 1 to have a tracer particle */
#define N_TRACER_PARTICLES 100 /* number of tracer particles */
#define N_TRACER_PARTICLES 200 /* number of tracer particles */
#define TRACER_STEPS 5 /* number of tracer steps recorded between images */
#define TRAJECTORY_LENGTH 40000 /* length of recorded trajectory */
#define TRACER_LUM_FACTOR 100.0 /* controls luminosity decrease of trajectories with time */
#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_WIDTH 2 /* width of tracer particle trajectory */
@ -567,7 +573,7 @@
#define FLOOR_OMEGA 0 /* set to 1 to limit particle momentum to PMAX */
#define PMAX 1000.0 /* maximal force */
#define HASHX 29 /* size of hashgrid in x direction */
#define HASHX 40 /* size of hashgrid in x direction */
#define HASHY 20 /* size of hashgrid in y direction */
#define HASHMAX 100 /* maximal number of particles per hashgrid cell */
#define HASHGRID_PADDING 0.1 /* padding of hashgrid outside simulation window */
@ -2368,7 +2374,7 @@ void animation()
// draw_container(params.xmincontainer, params.xmaxcontainer, obstacle, segment, conveyor_belt, wall);
/* add a particle */
if ((ADD_PARTICLES)&&(i > ADD_TIME)&&((i - INITIAL_TIME - ADD_TIME)%ADD_PERIOD == 1)&&(i < NSTEPS - FINAL_NOADD_PERIOD))
if ((ADD_PARTICLES)&&(i > ADD_TIME)&&((i - INITIAL_TIME - ADD_TIME)%ADD_PERIOD == 1)&&(i - INITIAL_TIME < NSTEPS - FINAL_NOADD_PERIOD))
{
/* add enzymes */
if ((REACTION_DIFFUSION)&&((RD_REACTION == CHEM_DNA_ENZYME)||(RD_REACTION == CHEM_DNA_ENZYME_REPAIR)))

View File

@ -266,6 +266,8 @@
#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 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 */
#define MESSAGE_LDASH 14 /* length of dash for Morse code message */
#define MESSAGE_LDOT 8 /* length of dot for Morse code message */

View File

@ -35,20 +35,20 @@
#include <omp.h>
#include <time.h>
#define MOVIE 1 /* set to 1 to generate movie */
#define MOVIE 0 /* set to 1 to generate movie */
#define SAVE_MEMORY 1 /* set to 1 to save memory when writing tiff images */
#define INVERT_COUNTER 0 /* set to 1 to save frames in inverse order */
// #define WINWIDTH 1280 /* window width */
#define WINWIDTH 720 /* window width */
#define WINHEIGHT 720 /* window height */
#define WINWIDTH 1200 /* window width */
#define WINHEIGHT 1200 /* window height */
// #define XMIN -1.5
// #define XMAX 2.5 /* x interval */
#define XMIN -1.125
#define XMAX 1.125 /* x interval */
#define YMIN -1.125
#define YMAX 1.125 /* y interval for 9/16 aspect ratio */
#define XMIN -1.2
#define XMAX 1.4 /* x interval */
#define YMIN -1.4
#define YMAX 1.2 /* y interval for 9/16 aspect ratio */
#define SCALING_FACTOR 1.0 /* scaling factor of drawing, needed for flower billiards, otherwise set to 1.0 */
@ -57,9 +57,10 @@
#define B_DOMAIN 30 /* choice of domain shape */
#define CIRCLE_PATTERN 1 /* pattern of circles */
#define POLYLINE_PATTERN 10 /* pattern of polyline */
#define POLYLINE_PATTERN 9 /* pattern of polyline */
#define ABSORBING_CIRCLES 0 /* set to 1 for circular scatterers to be absorbing */
#define ABSORBING_CIRCLES 1 /* set to 1 for circular scatterers to be absorbing */
#define NABSCIRCLES 10 /* number of absorbing circles */
#define NMAXCIRCLES 100000 /* total number of circles (must be at least NCX*NCY for square grid) */
#define NMAXPOLY 100000 /* total number of sides of polygonal line */
@ -70,10 +71,13 @@
#define SDEPTH 1 /* Sierpinski gastket depth */
#define LAMBDA 1.5 /* parameter controlling shape of domain */
#define MU 0.005 /* second parameter controlling shape of billiard */
#define MU 0.02 /* 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 APOLY 0.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 PENROSE_RATIO 2.5 /* parameter controlling the shape of small ellipses in Penrose room */
#define DRAW_BILLIARD 1 /* set to 1 to draw billiard */
@ -85,21 +89,21 @@
/* Simulation parameters */
// #define NPART 10 /* number of particles */
#define NPART 50000 /* number of particles */
#define NPART 21 /* number of particles */
// #define NPART 50000 /* number of particles */
#define NPARTMAX 100000 /* maximal number of particles after resampling */
#define LMAX 0.01 /* minimal segment length triggering resampling */
#define DMIN 0.02 /* minimal distance to boundary for triggering resampling */
#define CYCLE 1 /* set to 1 for closed curve (start in all directions) */
#define SHOWTRAILS 0 /* set to 1 to keep trails of the particles */
#define HEATMAP 1 /* set to 1 to show heat map of particles */
#define DRAW_FINAL_HEATMAP 1 /* set to 1 to show final heat map of particles */
#define SHOWTRAILS 1 /* set to 1 to keep trails of the particles */
#define HEATMAP 0 /* set to 1 to show heat map of particles */
#define DRAW_FINAL_HEATMAP 0 /* set to 1 to show final heat map of particles */
#define DRAW_HEATMAP_HISTOGRAM 0 /* set to 1 to draw a histogram of particle distribution in heat map */
#define NBIN_FACTOR 6.0 /* constant controlling number of bins in histogram */
#define DRAW_HEATMAP_PARTICLES 1 /* set to 1 to draw particles in heat map */
#define DRAW_HEATMAP_PARTICLES 0 /* set to 1 to draw particles in heat map */
#define HEATMAP_MAX_PART_BY_CELL 50 /* set to positive value to draw only limited number of particles in cell */
#define PLOT_HEATMAP_AVERAGE 1 /* set to 1 to plot average number of particles in heat map */
#define SHOWZOOM 0 /* set to 1 to show zoom on specific area */
#define PLOT_HEATMAP_AVERAGE 0 /* set to 1 to plot average number of particles in heat map */
#define SHOWZOOM 1 /* set to 1 to show zoom on specific area */
#define PRINT_PARTICLE_NUMBER 0 /* set to 1 to print number of particles */
#define PRINT_LEFT_RIGHT_PARTICLE_NUMBER 0 /* set to 1 to print number of particles on left and right side */
#define PRINT_CIRCLE_PARTICLE_NUMBER 0 /* set to 1 to print number of particles outside circular maze */
@ -108,11 +112,11 @@
#define TEST_INITIAL_COND 0 /* set to 1 to allow only initial conditions that pass a test */
#define NSTEPS 1300 /* number of frames of movie */
#define TIME 3000 /* time between movie frames, for fluidity of real-time simulation */
#define NSTEPS 6000 /* number of frames of movie */
#define TIME 1000 /* time between movie frames, for fluidity of real-time simulation */
// #define DPHI 0.000002 /* integration step */
#define DPHI 0.00002 /* integration step */
#define NVID 25 /* number of iterations between images displayed on screen */
#define DPHI 0.000005 /* integration step */
#define NVID 50 /* number of iterations between images displayed on screen */
#define END_FRAMES 50 /* number of still frames at the end of the movie */
/* Decreasing TIME accelerates the animation and the movie */
@ -132,7 +136,7 @@
#define RAINBOW_COLOR 1 /* set to 1 to use different colors for all particles */
#define FLOWER_COLOR 0 /* set to 1 to adapt initial colors to flower billiard (tracks vs core) */
#define NSEG 100 /* number of segments of boundary */
#define LENGTH 0.025 /* length of velocity vectors */
#define LENGTH 0.01 /* length of velocity vectors */
#define BILLIARD_WIDTH 2 /* width of billiard */
#define PARTICLE_WIDTH 2 /* width of particles */
#define FRONT_WIDTH 3 /* width of wave front */
@ -328,9 +332,14 @@ void draw_zoom(int color[NPARTMAX], double *configs[NPARTMAX], int active[NPARTM
glEnd();
/* draw billiard boundaries in zoom */
glLineWidth(BILLIARD_WIDTH*2);
glLineWidth(BILLIARD_WIDTH*10);
if (y_target + width > 1.0)
if (POLYLINE_PATTERN == P_ISOCELES_TRIANGLE)
{
draw_line(shiftx, shifty, x1, shifty);
draw_line(shiftx, shifty, x1, y2);
}
else if (y_target + width > 1.0)
{
yb = shifty + 0.5*(1.0 - y_target)/width;
glBegin(GL_LINE_STRIP);
@ -352,6 +361,7 @@ void draw_zoom(int color[NPARTMAX], double *configs[NPARTMAX], int active[NPARTM
// glLineWidth(PARTICLE_WIDTH*2);
/* draw particles */
for (i=0; i<nparticles; i++)
{
cosphi = (configs[i][6] - configs[i][4])/configs[i][3];
@ -393,6 +403,8 @@ void draw_zoom(int color[NPARTMAX], double *configs[NPARTMAX], int active[NPARTM
y1 = yb;
}
// if ((active[i])&&(vabs(x1) < 1.0)&&(vabs(y1) < 1.0)&&(vabs(x2) < 1.0)&&(vabs(y2) < 1.0))
if (((active[i])&&(vabs(x1) < 1.0)&&(vabs(y1) < 1.0))||((vabs(x2) < 1.0)&&(vabs(y2) < 1.0)))
{
@ -406,6 +418,40 @@ void draw_zoom(int color[NPARTMAX], double *configs[NPARTMAX], int active[NPARTM
}
}
/* draw billiard boundaries in zoom */
if (POLYLINE_PATTERN == P_ISOCELES_TRIANGLE)
{
x1 = shiftx - zoomwidth;
y1 = shifty - zoomwidth;
x2 = shiftx + zoomwidth;
y2 = shifty + zoomwidth;
glColor3f(0.0, 0.0, 0.0);
glBegin(GL_TRIANGLE_FAN);
glVertex2d(shiftx, shifty);
glVertex2d(x1,y2);
glVertex2d(x2,y2);
glVertex2d(x2,y1);
glVertex2d(x1,y1);
glVertex2d(x1,shifty);
glEnd ();
glLineWidth(BILLIARD_WIDTH*20);
glColor3f(1.0, 1.0, 1.0);
draw_line(shiftx, shifty, x1, shifty);
draw_line(shiftx, shifty, x1, y2);
}
/* other boundaries not yet implemented */
/* draw target in zoom */
glLineWidth(BILLIARD_WIDTH*2);
if (shooter) glColor3f(1.0, 0.0, 0.0);
else glColor3f(0.0, 0.8, 0.2);
tradius = zoomwidth*MU/width;
draw_circle(shiftx, shifty, tradius, NSEG);
}
@ -485,6 +531,11 @@ void draw_config_showtrails(int color[NPARTMAX], double *configs[NPARTMAX], int
draw_zoom(color, configs, active, 0.0, 0.0, 0.1, 1.65, 0.75, 0.3, 0);
break;
}
case (P_ISOCELES_TRIANGLE):
{
draw_zoom(color, configs, active, 1.0, -1.0, 0.2, 0.6, 0.6, 0.4, 0);
break;
}
}
// if (SHOWZOOM) draw_zoom(color, configs, active, 0.95, 0.0, 0.1);
}
@ -1096,7 +1147,7 @@ void animation()
// alphamax = 2.50949;
// init_drop_config(x_shooter, y_shooter, alphamax, alphamax + DPI, configs);
init_drop_config(0.05, 0.05, 0.0, DPI, configs);
init_drop_config(1.0, -1.0, 1.5*PID, PI, configs);
// init_drop_config(-0.95, 0.95, 0.0, DPI, configs);
// init_sym_drop_config(-1.0, 0.5, -PID, PID, configs);

0
particle_phase_space.c Normal file
View File

View File

@ -59,6 +59,7 @@
// #define CIRCLE_PATTERN 21 /* pattern of circles */
#define ABSORBING_CIRCLES 0 /* set to 1 for circular scatterers to be absorbing */
#define NABSCIRCLES 10 /* number of absorbing circles */
#define NMAXCIRCLES 5000 /* total number of circles (must be at least NCX*NCY for square grid) */
#define NMAXPOLY 1000 /* total number of sides of polygonal line */
@ -77,6 +78,9 @@
#define FOCI 1 /* set to 1 to draw focal points of ellipse */
#define NPOLY 4 /* number of sides of polygon */
#define APOLY 0.5 /* 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 0 /* 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 */

1431
particle_trajectory.c Normal file

File diff suppressed because it is too large Load Diff

171
rde.c
View File

@ -46,45 +46,49 @@
/* General geometrical parameters */
#define WINWIDTH 1920 /* window width */
// #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 NY 575 /* number of grid points on y axis */
#define HRES 6 /* factor for high resolution plots */
// #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 HRES 1 /* factor for high resolution plots */
#define XMIN -2.0
#define XMAX 2.0 /* x interval */
// #define XMIN -2.0
// #define XMAX 2.0 /* x interval */
#define XMIN -1.041666667
#define XMAX 1.041666667 /* x interval */
#define YMIN -1.041666667
#define YMAX 1.041666667 /* y interval for 9/16 aspect ratio */
/* Choice of simulated equation */
#define RDE_EQUATION 8 /* choice of reaction term, see list in global_3d.c */
#define NFIELDS 3 /* number of fields in reaction-diffusion 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 SPHERE 1 /* set to 1 to simulate equation on sphere */
#define SPHERE 0 /* set to 1 to simulate equation on sphere */
#define DPOLE 0 /* safety distance to poles */
#define DSMOOTH 1 /* size of neighbourhood of poles that are smoothed */
#define SMOOTHPOLE 0.05 /* smoothing coefficient at poles */
#define SMOOTHPOLE 0.01 /* 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 1 /* set to 1 to use blocks of points near the poles */
#define BLOCKDIST 64 /* distance to poles where points are blocked */
#define ZERO_MERIDIAN 190.0 /* choice of zero meridian (will be at left/right boundary of 2d plot) */
#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 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 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 */
#define ADD_FORCE_FIELD 1 /* set to 1 to add a foce field (for compressible Euler equation) */
#define ADD_FORCE_FIELD 0 /* set to 1 to add a foce field (for compressible Euler equation) */
#define POTENTIAL 7 /* type of potential or vector potential, see list in global_3d.c */
#define FORCE_FIELD 6 /* type of force field, see list in global_3d.c */
#define ADD_CORIOLIS_FORCE 1 /* set to 1 to add Coriolis force (quasigeostrophic Euler equations) */
#define VARIABLE_DEPTH 1 /* set to 1 for variable depth in shallow water equation */
#define VARIABLE_DEPTH 0 /* set to 1 for variable depth in shallow water equation */
#define SWATER_DEPTH 10 /* variable depth in shallow water equation */
#define ANTISYMMETRIZE_WAVE_FCT 0 /* set tot 1 to make wave function antisymmetric */
#define ADAPT_STATE_TO_BC 1 /* to smoothly adapt initial state to obstacles */
#define ADAPT_STATE_TO_BC 0 /* to smoothly adapt initial state to obstacles */
#define OBSTACLE_GEOMETRY 84 /* geometry of obstacles, as in B_DOMAIN */
#define BC_STIFFNESS 0.25 /* controls region of boundary condition control */
#define CHECK_INTEGRAL 1 /* set to 1 to check integral of first field */
@ -104,6 +108,7 @@
#define NPOISSON 300 /* number of points for Poisson C_RAND_POISSON arrangement */
#define PDISC_FACTOR 3.25 /* controls density of Poisson disc process (default: 3.25) */
#define RANDOM_POLY_ANGLE 0 /* 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.0 /* parameter controlling the dimensions of domain */
#define MU 1.0 /* parameter controlling the dimensions of domain */
@ -118,7 +123,8 @@
#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 RADIUS_FACTOR 0.3 /* controls inner radius for C_RING arrangements */
#define WALL_WIDTH_RND 0.0 /* proportion of width of width for some random arrangements */
#define RADIUS_FACTOR 0.3 /* controls inner radius for C_RING arrangements */
#define X_SHOOTER -0.2
#define Y_SHOOTER -0.6
@ -153,6 +159,9 @@
#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 NU_KURAMOTO 0.0 /* viscosity in Kuramoto model */
#define OMEGA_KURAMOTO 0.02 /* frequency in Kuramoto 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 */
@ -175,10 +184,10 @@
#define OSCILLATING_SOURCE_PERIOD 1 /* period of oscillating source */
#define OSCILLATING_SOURCE_OMEGA 0.2 /* frequency of oscillating source */
#define ADD_TRACERS 1 /* set to 1 tof add tracer particles (for Euler equations) */
#define ADD_TRACERS 0 /* set to 1 tof add tracer particles (for Euler equations) */
#define N_TRACERS 2000 /* number of tracer particles */
#define TRACERS_STEP 0.1 /* step size in tracer evolution */
#define RESPAWN_TRACERS 1 /* set to 1 to randomly move tracer position */
#define RESPAWN_TRACERS 0 /* set to 1 to randomly move tracer position */
#define RESPAWN_PROBABILTY 0.005 /* probability of moving tracer */
#define T_OUT 2.0 /* outside temperature */
@ -186,7 +195,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.01 /* noise intensity */
#define NOISE_INTENSITY 0.5 /* 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 */
@ -218,25 +227,25 @@
#define TANH_FACTOR 5.0 /* steepness of variable depth */
#define EULER_GRADIENT_YSHIFT 0.0 /* y-shift in computation of gradient in Euler equation */
#define ADD_MOON_FORCING 1 /* set to 1 to simulate tidal forces from Moon */
#define ADD_MOON_FORCING 0 /* set to 1 to simulate tidal forces from Moon */
#define FORCING_AMP 5.0e-6 /* amplitude of periodic forcing */
#define FORCING_CONST_AMP 0.0 /* amplitude of periodic forcing */
#define FORCING_PERIOD 1600 /* period of forcing */
#define FORCING_SHIFT 1.5 /* phase shift of forcing in units of Pi */
#define FORCING_SHIFT 0.0 /* phase shift of forcing in units of Pi */
/* Boundary conditions, see list in global_pdes.c */
#define B_COND 1
#define B_COND_LEFT 0
#define B_COND_RIGHT 0
#define B_COND_TOP 0
#define B_COND_BOTTOM 0
#define B_COND_LEFT 1
#define B_COND_RIGHT 1
#define B_COND_TOP 1
#define B_COND_BOTTOM 1
/* Parameters for length and speed of simulation */
#define NSTEPS 1400 /* number of frames of movie */
#define NVID 80 /* number of iterations between images displayed on screen */
#define NSTEPS 2300 /* number of frames of movie */
#define NVID 40 /* 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 */
@ -255,12 +264,12 @@
/* Visualisation */
#define PLOT_3D 0 /* controls whether plot is 2D or 3D */
#define PLOT_SPHERE 1 /* draws fields on a sphere */
#define PLOT_SPHERE 0 /* draws fields on a sphere */
#define ROTATE_VIEW 1 /* set to 1 to rotate position of observer */
#define ROTATE_ANGLE -45.0 /* total angle of rotation during simulation */
#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_2D 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 MAX_LATITUDE 45.0 /* maximal latitude for viewpoint trajectory VP_ORBIT2 */
@ -269,12 +278,12 @@
/* Plot type - color scheme */
#define CPLOT 70
#define CPLOT_B 74
#define CPLOT 10
#define CPLOT_B 251
/* Plot type - height of 3D plot */
#define ZPLOT 70 /* z coordinate in 3D plot */
#define ZPLOT 10 /* z coordinate in 3D plot */
#define ZPLOT_B 71 /* z coordinate in second 3D plot */
#define AMPLITUDE_HIGH_RES 1 /* set to 1 to increase resolution of P_3D_AMPLITUDE plot */
@ -288,11 +297,9 @@
#define DRAW_DEPTH 0 /* set to 1 to draw water depth */
#define DEPTH_SCALE 0.75 /* vertical scaling of depth plot */
#define DEPTH_SHIFT -0.015 /* vertical shift of depth plot */
#define FLOODING 1 /* set to 1 for drawing water when higher than continents */
// #define FLOODING_VSHIFT 0.51 /* controls when wave is considered higher than land */
#define FLOODING_VSHIFT 0.56 /* controls when wave is considered higher than land */
#define FLOODING 0 /* set to 1 for drawing water when higher than continents */
#define FLOODING_VSHIFT -10.0 /* controls when wave is considered higher than land */
#define FLOODING_VSHIFT_2D 0.56 /* controls when wave is considered higher than land */
// #define FLOODING_VSHIFT_2D 0.61 /* controls when wave is considered higher than land */
#define PLOT_SCALE_ENERGY 0.05 /* vertical scaling in energy plot */
@ -322,8 +329,8 @@
/* Color schemes, 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 COLOR_PALETTE 10 /* 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 */
#define COLOR_OUT_R 1.0 /* color outside domain */
@ -332,14 +339,14 @@
#define COLOR_SCHEME 3 /* choice of color scheme */
#define PHASE_SHIFT -0.25 /* 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 15.0 /* additional scaling factor for color scheme P_3D_AMPLITUDE */
#define VSCALE_AMPLITUDE 0.01 /* additional scaling factor for color scheme P_3D_AMPLITUDE */
#define ATTENUATION 0.0 /* exponential attenuation coefficient of contrast with time */
#define CURL_SCALE 1.0 /* scaling factor for curl representation */
#define CURL_SCALE 0.000005 /* 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*/
@ -365,7 +372,7 @@
#define VMEAN_SPEED 0.0 /* mean value around which to scale for color scheme Z_EULER_SPEED */
#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 15.0 /* additional scaling factor for color scheme Z_EULERC_VORTICITY */
#define VSCALE_VORTICITY 0.1 /* additional scaling factor for color scheme Z_EULERC_VORTICITY */
#define VORTICITY_SHIFT 0.0 /* 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 */
@ -383,8 +390,8 @@
#define COLORBAR_RANGE 3.0 /* 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 0 /* set to 1 to draw circular color scheme */
#define CIRC_COLORBAR_B 1 /* set to 1 to draw circular color scheme */
#define CIRC_COLORBAR 1 /* 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 */
#define TWOSPEEDS 0 /* set to 1 to replace hardcore boundary by medium with different speed */
@ -449,10 +456,10 @@ double observer[3] = {0.0, -6.0, 2.5}; /* location of observer for REP_PROJ_3
int reset_view = 0; /* switch to reset 3D view parameters (for option ROTATE_VIEW) */
/* constants for simulations on planets */
#define ADD_DEM 1 /* add DEM (digital elevation model) */
#define ADD_NEGATIVE_DEM 1 /* add DEM with bathymetric data */
#define ADD_DEM 0 /* add DEM (digital elevation model) */
#define ADD_NEGATIVE_DEM 0 /* add DEM with bathymetric data */
#define RSCALE_DEM 0.075 /* scaling factor of radial component for DEM */
#define SMOOTH_DEM 1 /* set to 1 to smoothen DEM (to make altitude less constant) */
#define SMOOTH_DEM 0 /* set to 1 to smoothen DEM (to make altitude less constant) */
#define DEM_SMOOTH_STEPS 10 /* number of smoothening steps */
#define DEM_SMOOTH_HEIGHT 2.0 /* relative height below which to smoothen */
#define DEM_MAXHEIGHT 9000.0 /* max height of DEM (estimated from Everest/Olympus Mons) */
@ -468,11 +475,12 @@ int reset_view = 0; /* switch to reset 3D view parameters (for option RO
#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 RSCALE 0.15 /* scaling factor of radial component */
#define RSHIFT -0.075 /* shift in radial component */
#define RMAX 2.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 */
#define RSCALE 0.005 /* 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 COS_VISIBLE -0.35 /* limit on cosine of normal to shown facets */
/* For debugging purposes only */
#define FLOOR 1 /* set to 1 to limit wave amplitude to VMAX */
@ -1229,7 +1237,7 @@ double gfield[2*NX*NY], t_rde rde[NX*NY], t_wave_sphere wsphere[NX*NY])
{
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;
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;
// 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;
@ -1380,6 +1388,12 @@ double gfield[2*NX*NY], t_rde rde[NX*NY], t_wave_sphere wsphere[NX*NY])
break;
}
case (E_KURAMOTO):
{
kuramoto_int = (double *)malloc(NX*NY*sizeof(double));
compute_kuramoto_interaction(phi_in[0], kuramoto_int, xy_in, wsphere);
}
default:
{
/* do nothing */
@ -1415,6 +1429,40 @@ double gfield[2*NX*NY], t_rde rde[NX*NY], t_wave_sphere wsphere[NX*NY])
phi_out[0][i*NY+j] = phi_in[0][i*NY+j] + intstep*(deltax + K_AC*x*(1.0-x*x));
break;
}
case (E_KURAMOTO):
{
x = K_KURAMOTO*kuramoto_int[i*NY+j] + 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[0][i*NY+j] + intstep*x;
if (x > PI)
{
y = (x + PI)/DPI;
phi_out[0][i*NY+j] = x - DPI*(double)((int)y);
}
else if (x < -PI)
{
y = (-x + PI)/DPI;
phi_out[0][i*NY+j] = x + DPI*(double)((int)y);
}
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_CAHN_HILLIARD):
{
/* TO DO */
@ -1681,6 +1729,10 @@ double gfield[2*NX*NY], t_rde rde[NX*NY], t_wave_sphere wsphere[NX*NY])
free(delta_v);
}
}
else if (RDE_EQUATION == E_KURAMOTO)
{
free(kuramoto_int);
}
if (COMPUTE_PRESSURE)
{
@ -2111,7 +2163,7 @@ void animation()
xy_in = (short int *)malloc(NX*NY*sizeof(short int));
rde = (t_rde *)malloc(NX*NY*sizeof(t_rde));
if (SPHERE)
// if (SPHERE)
{
wsphere = (t_wave_sphere *)malloc(NX*NY*sizeof(t_wave_sphere));
init_wave_sphere_rde(wsphere,1);
@ -2243,8 +2295,11 @@ void animation()
// init_tidal_state(1, 0.0015, SWATER_MIN_HEIGHT, phi, xy_in, wsphere);
// 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_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);
// 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);
// add_gaussian_wave(-1.6, -0.5, 0.015, 0.25, SWATER_MIN_HEIGHT, phi, xy_in);
@ -2507,7 +2562,7 @@ void animation()
free(phi_tmp[i]);
}
free(xy_in);
if (SPHERE)
// if (SPHERE)
{
free(wsphere);
free(wsphere_hr);

View File

@ -202,6 +202,8 @@
#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 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 */
#define INITIAL_TIME 50 /* time after which to start saving frames */
#define OSCIL_YMAX 0.35 /* defines oscillation range */

View File

@ -2018,8 +2018,8 @@ void init_obstacle_config(t_obstacle obstacle[NMAXOBSTACLES], t_otriangle otrian
}
case (O_SQUARE_TWOMASSES):
{
dx = (XMAX - XMIN)/(double)NOBSX;
dy = (YMAX - YMIN)/(double)NOBSY;
dx = (OBSXMAX - OBSXMIN)/(double)NOBSX;
dy = (OBSYMAX - OBSYMIN)/(double)NOBSY;
n = 0;
if ((ADD_FIXED_SEGMENTS)&&(SEGMENT_PATTERN == S_CYLINDER))
@ -2037,9 +2037,9 @@ void init_obstacle_config(t_obstacle obstacle[NMAXOBSTACLES], t_otriangle otrian
for (i=0; i<NOBSX; i++)
for (j=jmin; j<jmax; j++)
{
obstacle[n].xc = XMIN + ((double)i + 0.25)*dx;
obstacle[n].yc = YMIN + ((double)j + 0.5)*dy;
if (obstacle[n].xc > XMAX) obstacle[n].xc += (XMAX - XMIN);
obstacle[n].xc = OBSXMIN + ((double)i + 0.25)*dx;
obstacle[n].yc = OBSYMIN + ((double)j + 0.5)*dy;
if (obstacle[n].xc > OBSXMAX) obstacle[n].xc += (OBSXMAX - OBSXMIN);
obstacle[n].radius = OBSTACLE_RADIUS;
if ((i+j)%2 == 0)
{
@ -7241,13 +7241,14 @@ int add_particle(double x, double y, double vx, double vy, double mass, short in
particle[i].xc = x;
particle[i].yc = y;
particle[i].radius = MU;
particle[i].radius = MU_ADD;
// particle[i].radius = MU*sqrt(mass);
particle[i].active = 1;
particle[i].neighb = 0;
particle[i].diff_neighb = 0;
particle[i].thermostat = 1;
particle[i].charge = CHARGE;
particle[i].charge = CHARGE_ADD;
if ((ADD_ALTERNATE_CHARGE)&&(rand()%2 == 1)) particle[i].charge *= -1.0;
particle[i].energy = 0.0;
particle[i].emean = 0.0;
@ -8357,7 +8358,7 @@ void draw_one_particle(t_particle particle, double xc, double yc, double radius,
}
/* draw crosses/bars on charged particles */
if (TWO_TYPES)
// if (TWO_TYPES)
{
if ((DRAW_CROSS)&&(particle.charge > 0.0))
{
@ -8468,7 +8469,7 @@ void draw_trajectory(t_tracer trajectory[TRAJECTORY_LENGTH*N_TRACER_PARTICLES],
/* draw tracer particle trajectory */
{
int i, j, time, p, width;
double x1, x2, y1, y2, rgb[3], rgbx[3], rgby[3], radius, lum;
double x1, x2, y1, y2, rgb[3], rgbx[3], rgby[3], radius, lum, lum1;
// blank();
glLineWidth(TRAJECTORY_WIDTH);
@ -8493,7 +8494,12 @@ void draw_trajectory(t_tracer trajectory[TRAJECTORY_LENGTH*N_TRACER_PARTICLES],
time = traj_length - i;
lum = 0.9 - TRACER_LUM_FACTOR*(double)time/(double)(TRAJECTORY_LENGTH*TRACER_STEPS);
if (lum < 0.0) lum = 0.0;
glColor3f(lum*rgb[0], lum*rgb[1], lum*rgb[2]);
if (FILL_OBSTACLE_TRIANGLES)
{
lum1 = 0.5*(1.0-lum);
glColor3f(lum1 + lum*rgb[0], lum1 + lum*rgb[1], lum1 + lum*rgb[2]);
}
else glColor3f(lum*rgb[0], lum*rgb[1], lum*rgb[2]);
if ((lum > 0.1)&&(module2(x2 - x1, y2 - y1) < 0.25*(YMAX - YMIN)))
draw_line(x1, y1, x2, y2);
@ -12022,7 +12028,7 @@ int tracer_n[N_TRACER_PARTICLES])
printf("Added a particle at (%.5lg, %.5lg)\n\n\n", x, y);
fprintf(lj_log, "Added a particle at (%.5lg, %.5lg)\n\n\n", x, y);
add_particle(x, y, V_INITIAL, 0.05*V_INITIAL*(double)rand()/RAND_MAX, PARTICLE_MASS, type, particle);
add_particle(x, y, V_INITIAL_ADD, 0.05*V_INITIAL_ADD*(double)rand()/RAND_MAX, PARTICLE_ADD_MASS, type, particle);
printf("Particle number %i\n", ncircles-1);

View File

@ -191,6 +191,7 @@ void rgb_color_scheme_minmax(int i, double rgb[3])
/* saturation = r, luminosity = 0.5 */
}
void rgb_color_scheme_density(int part_number, double rgb[3], double minprop)
/* color scheme with specified color interval */
{
@ -722,6 +723,13 @@ void draw_billiard() /* draws the billiard boundary */
draw_circle(x0, 0.0, r, NSEG);
draw_circle(-x0, 0.0, r, NSEG);
}
if (ABSORBING_CIRCLES)
{
rgb[0] = 0.7; rgb[1] = 0.7; rgb[2] = 0.7;
for (k=0; k<ncircles; k++) draw_colored_circle(circles[k].xc, circles[k].yc, circles[k].radius, NSEG, rgb);
}
break;
}
case (D_STADIUM):
@ -1835,21 +1843,19 @@ void print_colors(int color[NPARTMAX]) /* for debugging purposes */
/* determine position on boundary of ellipse */
{
double theta;
pos[0] = LAMBDA*cos(conf[0]);
pos[1] = sin(conf[0]);
theta = argument(-LAMBDA*pos[1],pos[0]/LAMBDA);
*alpha = theta + conf[1];
*alpha = theta + conf[1];
return(1);
}
int vellipse_xy(double config[8], double alpha, double pos[2])
/* determine initial configuration for start at point pos = (x,y) */
{
double c0, s0, lam2, a, b, c, x1, y1, t, theta;
double c0, s0, lam2, a, b, c, x1, y1, t, theta, margin = 1.0e-12, delta;
int i;
c0 = cos(alpha);
@ -1875,6 +1881,20 @@ void print_colors(int color[NPARTMAX]) /* for debugging purposes */
config[1] = theta - alpha;
while (config[1] < 0.0) config[1] += DPI;
while (config[1] > DPI) config[1] -= DPI;
/* experimental */
if (ABSORBING_CIRCLES) for (i=0; i<ncircles; i++)
{
b = (pos[0]-circles[i].xc)*c0 + (pos[1]-circles[i].yc)*s0;
c = (pos[0]-circles[i].xc)*(pos[0]-circles[i].xc) + (pos[1]-circles[i].yc)*(pos[1]-circles[i].yc) - circles[i].radius*circles[i].radius;
delta = b*b - c;
if ((delta > margin)&&(t > 2.0*MU)) /* there is an intersection with circle i */
{
config[0] = DUMMY_ABSORBING;
config[1] = PI;
}
}
config[2] = 0.0; /* running time */
config[3] = module2(x1-pos[0], y1-pos[1]); /* distance to collision */
@ -6792,7 +6812,7 @@ void init_polyline(t_segment polyline[NMAXPOLY], t_circle circles[NMAXCIRCLES],
int i, j, k, l, n, z, ii, jj, terni[SDEPTH], ternj[SDEPTH], quater[SDEPTH], cond, p, q, block, nblocks, ww;
short int vkoch[NMAXCIRCLES], turnright;
double ratio, omega, angle, sw, length, dist, x, y, ta, tb, a, b, ra, rb, r,
x1, y1, x2, y2, dx, dy, padding = 0.02, width = 0.01, xright, yright, xtop, ytop, rand_factor, rmin, rmax, dr, phi, dphi, rscat;
x1, y1, x2, y2, dx, dy, padding = 0.02, width = 0.01, xright, yright, xtop, ytop, rand_factor, rmin, rmax, dr, phi, dphi, rscat, omegab, swb;
double *maze_coords;
t_maze* maze;
@ -6867,14 +6887,17 @@ void init_polyline(t_segment polyline[NMAXPOLY], t_circle circles[NMAXCIRCLES],
}
case (P_POLYRING):
{
nsides = 2*NPOLY;
ncircles = 0;
nsides = NPOLY + NPOLY_B;
if (ABSORBING_CIRCLES) ncircles = NABSCIRCLES;
else ncircles = 0;
omega = DPI/(double)NPOLY;
omegab = DPI/(double)NPOLY_B;
sw = sin(omega/2.0);
swb = sin(omegab/2.0);
for (i=0; i<NPOLY; i++)
{
angle = APOLY + (double)i*omega;
angle = APOLY*PID + (double)i*omega;
polyline[i].x1 = LAMBDA*cos(angle);
polyline[i].y1 = LAMBDA*sin(angle);
polyline[i].angle = angle + PID + 0.5*omega;
@ -6886,22 +6909,75 @@ void init_polyline(t_segment polyline[NMAXPOLY], t_circle circles[NMAXCIRCLES],
polyline[i].y2 = polyline[(i+1)%NPOLY].y1;
}
for (i=0; i<NPOLY; i++)
for (i=0; i<NPOLY_B; i++)
{
angle = APOLY + ((double)i+0.5)*omega;
polyline[i+NPOLY].x1 = MU*cos(angle);
polyline[i+NPOLY].y1 = MU*sin(angle);
polyline[i+NPOLY].angle = angle + PID + 0.5*omega;
polyline[i+NPOLY].length = 2.0*MU*sw;
angle = APOLY_B*PID + (double)i*omegab;
polyline[i+NPOLY].x1 = LAMBDA_B*cos(angle);
polyline[i+NPOLY].y1 = LAMBDA_B*sin(angle);
polyline[i+NPOLY].angle = angle + PID + 0.5*omegab;
polyline[i+NPOLY].length = 2.0*LAMBDA_B*swb;
}
for (i=0; i<NPOLY; i++)
for (i=0; i<NPOLY_B; i++)
{
polyline[i+NPOLY].x2 = polyline[(i+1)%NPOLY+NPOLY].x1;
polyline[i+NPOLY].y2 = polyline[(i+1)%NPOLY+NPOLY].y1;
polyline[i+NPOLY].x2 = polyline[(i+1)%NPOLY_B+NPOLY].x1;
polyline[i+NPOLY].y2 = polyline[(i+1)%NPOLY_B+NPOLY].y1;
}
for (i=0; i<nsides; i++) polyline[i].color = 0;
for (i=0; i<ncircles; i++)
{
circles[i].xc = polyline[i].x1;
circles[i].yc = polyline[i].y1;
circles[i].radius = MU;
circles[i].active = 1;
}
break;
}
case (P_STAR):
{
nsides = 2*NPOLY;
if (ABSORBING_CIRCLES) ncircles = NABSCIRCLES;
else ncircles = 0;
omega = PI/(double)NPOLY;
for (i=0; i<2*NPOLY; i++)
{
angle = APOLY*PID + (double)i*omega;
if (i%2 == 0)
{
polyline[i].x1 = LAMBDA*cos(angle);
polyline[i].y1 = LAMBDA*sin(angle);
}
else
{
polyline[i].x1 = LAMBDA_B*cos(angle);
polyline[i].y1 = LAMBDA_B*sin(angle);
}
}
for (i=0; i<2*NPOLY; i++)
{
polyline[i].x2 = polyline[(i+1)%(2*NPOLY)].x1;
polyline[i].y2 = polyline[(i+1)%(2*NPOLY)].y1;
}
length = module2(polyline[0].x2 - polyline[0].x1, polyline[0].y2 - polyline[0].y1);
for (i=0; i<nsides; i++)
{
polyline[i].color = 0;
polyline[i].length = length;
polyline[i].angle = argument(polyline[i].x2 - polyline[i].x1, polyline[i].y2 - polyline[i].y1);
}
for (i=0; i<ncircles; i++)
{
circles[i].xc = polyline[i].x1;
circles[i].yc = polyline[i].y1;
circles[i].radius = MU;
circles[i].active = 1;
}
break;
}
case (P_SIERPINSKI):
@ -7047,13 +7123,14 @@ void init_polyline(t_segment polyline[NMAXPOLY], t_circle circles[NMAXCIRCLES],
case (P_POLYGON):
{
nsides = NPOLY;
ncircles = 0;
if (ABSORBING_CIRCLES) ncircles = NABSCIRCLES;
else ncircles = 0;
omega = DPI/(double)NPOLY;
sw = sin(omega/2.0);
for (i=0; i<NPOLY; i++)
{
angle = APOLY + (double)i*omega;
angle = APOLY*PID + (double)i*omega;
polyline[i].x1 = LAMBDA*cos(angle);
polyline[i].y1 = LAMBDA*sin(angle);
polyline[i].angle = angle + PID + 0.5*omega;
@ -7066,7 +7143,14 @@ void init_polyline(t_segment polyline[NMAXPOLY], t_circle circles[NMAXCIRCLES],
}
for (i=0; i<nsides; i++) polyline[i].color = 0;
for (i=0; i<ncircles; i++)
{
circles[i].xc = polyline[i].x1;
circles[i].yc = polyline[i].y1;
circles[i].radius = MU;
circles[i].active = 1;
}
break;
}
case (P_TOKA_PRIME):
@ -7222,6 +7306,43 @@ void init_polyline(t_segment polyline[NMAXPOLY], t_circle circles[NMAXCIRCLES],
}
break;
}
case (P_ISOCELES_TRIANGLE):
{
nsides = 3;
ncircles = 3;
polyline[0].x1 = -1.0; polyline[0].y1 = -1.0; polyline[0].angle = 0.0;
polyline[1].x1 = 1.0; polyline[1].y1 = -1.0; polyline[1].angle = 1.5*PID;
polyline[2].x1 = -1.0; polyline[2].y1 = 1.0; polyline[2].angle = 3.0*PID;
// ratio = (YMAX - YMIN)/4.5;
// for (i=0; i<nsides; i++)
// {
// polyline[i].x1 = ratio*(polyline[i].x1);
// polyline[i].y1 = ratio*(polyline[i].y1);
// }
for (i=0; i<nsides; i++) if (i < nsides-1)
{
polyline[i].x2 = polyline[i+1].x1;
polyline[i].y2 = polyline[i+1].y1;
}
polyline[nsides-1].x2 = polyline[0].x1;
polyline[nsides-1].y2 = polyline[0].y1;
for (i=0; i<nsides; i++)
polyline[i].length = module2(polyline[i].x2 - polyline[i].x1, polyline[i].y2 - polyline[i].y1);
for (i=0; i<ncircles; i++)
{
circles[i].xc = polyline[i].x1;
circles[i].yc = polyline[i].y1;
circles[i].radius = MU;
circles[i].active = 1;
}
break;
}
case (P_MAZE):
{
maze = (t_maze *)malloc(NXMAZE*NYMAZE*sizeof(t_maze));

255
sub_rde.c
View File

@ -2362,6 +2362,26 @@ void compute_theta(double *phi[NFIELDS], short int xy_in[NX*NY], t_rde rde[NX*NY
else rde[i*NY+j].theta = 0.0;
}
void compute_theta_kuramoto(double *phi[NFIELDS], short int xy_in[NX*NY], t_rde rde[NX*NY])
/* compute angle for rock-paper-scissors equation */
{
int i, j;
double angle;
#pragma omp parallel for private(i,j,angle)
for (i=0; i<NX; i++) for (j=0; j<NY; j++)
{
if (xy_in[i*NY+j])
{
angle = phi[0][i*NY+j];
if (angle < -PI) angle += DPI;
else if (angle >= PI) angle -= DPI;
rde[i*NY+j].theta = angle;
}
else rde[i*NY+j].theta = 0.0;
}
}
double colors_rps(int type)
{
switch (type) {
@ -4888,7 +4908,7 @@ void compute_kuramoto_int_planar(double phi_in[NX*NY], double phi_out[NX*NY], sh
for (j=1; j<NY-1; j++){
if (xy_in[i*NY+j]){
phi = phi_in[i*NY+j];
phi_out[i*NY+j] = sin(phi_in[(i+1)*NY+j] - phi) + sin(phi_in[(i-1)*NY+j] - phi) + sin(phi_in[i*NY+j+1] - phi) + sin(phi_in[i*NY+j-1] - phi);
phi_out[i*NY+j] = -sin(phi_in[(i+1)*NY+j] - phi) - sin(phi_in[(i-1)*NY+j] - phi) - sin(phi_in[i*NY+j+1] - phi) - sin(phi_in[i*NY+j-1] - phi);
}
}
}
@ -4905,7 +4925,7 @@ void compute_kuramoto_int_planar(double phi_in[NX*NY], double phi_out[NX*NY], sh
jminus = j-1; if (jminus == -1) jminus = NY-1;
phi = phi_in[j];
phi_out[j] = sin(phi_in[jminus] - phi) + sin(phi_in[jplus] - phi) + sin(phi_in[(NX-1)*NY+j] - phi) + sin(phi_in[NY+j] - phi);
phi_out[j] = -sin(phi_in[jminus] - phi) - sin(phi_in[jplus] - phi) - sin(phi_in[(NX-1)*NY+j] - phi) - sin(phi_in[NY+j] - phi);
}
break;
}
@ -4921,7 +4941,7 @@ void compute_kuramoto_int_planar(double phi_in[NX*NY], double phi_out[NX*NY], sh
jminus = j-1; if (jminus == -1) jminus = NY-1;
phi = phi_in[(NX-1)*NY+j];
phi_out[(NX-1)*NY+j] = sin(phi_in[(NX-1)*NY+jminus] - phi) + sin(phi_in[(NX-1)*NY+jplus] - phi) + sin(phi_in[(NX-2)*NY+j] - phi) + sin(phi_in[j] - phi);
phi_out[(NX-1)*NY+j] = -sin(phi_in[(NX-1)*NY+jminus] - phi) - sin(phi_in[(NX-1)*NY+jplus] - phi) - sin(phi_in[(NX-2)*NY+j] - phi) - sin(phi_in[j] - phi);
}
break;
}
@ -4937,7 +4957,7 @@ void compute_kuramoto_int_planar(double phi_in[NX*NY], double phi_out[NX*NY], sh
iminus = i-1; /*if (iminus == -1) iminus = NX-1;*/
phi = phi_in[i*NY];
phi_out[i*NY] = sin(phi_in[iminus*NY] - phi) + sin(phi_in[iplus*NY] - phi) + sin(phi_in[i*NY+1] - phi) + sin(phi_in[i*NY+NY-1] -phi);
phi_out[i*NY] = -sin(phi_in[iminus*NY] - phi) - sin(phi_in[iplus*NY] - phi) - sin(phi_in[i*NY+1] - phi) - sin(phi_in[i*NY+NY-1] -phi);
}
break;
}
@ -4953,7 +4973,7 @@ void compute_kuramoto_int_planar(double phi_in[NX*NY], double phi_out[NX*NY], sh
iminus = i-1; /*if (iminus == -1) iminus = NX-1;*/
phi = phi_in[i*NY+NY-1];
phi_out[i*NY+NY-1] = sin(phi_in[iminus*NY+NY-1] - phi) + sin(phi_in[iplus*NY+NY-1] - phi) + sin(phi_in[i*NY] - phi) + sin(phi_in[i*NY+NY-2] - phi);
phi_out[i*NY+NY-1] = -sin(phi_in[iminus*NY+NY-1] - phi) - sin(phi_in[iplus*NY+NY-1] - phi) - sin(phi_in[i*NY] - phi) - sin(phi_in[i*NY+NY-2] - phi);
}
break;
}
@ -4961,11 +4981,106 @@ void compute_kuramoto_int_planar(double phi_in[NX*NY], double phi_out[NX*NY], sh
}
void compute_kuramoto_int_sphere(double phi_in[NX*NY], double phi_out[NX*NY], short int xy_in[NX*NY])
/* computes Kuramoto interaction of phi_in and stores it in phi_out - case with whole rectangular domain */
{
int i, j, iplus, iminus, jplus, jminus;
double phi;
// #pragma omp parallel for private(i,j)
// for (i=1; i<NX-1; i++){
// for (j=1; j<NY-1; j++){
// phi_out[i*NY+j] = 0.0;
// }
// }
#pragma omp parallel for private(i,j)
for (i=1; i<NX-1; i++){
for (j=1; j<NY-1; j++){
if (xy_in[i*NY+j]){
phi = phi_in[i*NY+j];
phi_out[i*NY+j] = -sin(phi_in[(i+1)*NY+j] - phi) - sin(phi_in[(i-1)*NY+j] - phi) - sin(phi_in[i*NY+j+1] - phi) - sin(phi_in[i*NY+j-1] - phi);
}
}
}
/* TODO */
/* boundary conditions - left side */
switch (B_COND_LEFT) {
case (BC_PERIODIC):
{
for (j = 1; j < NY-1; j++)
{
jplus = j+1; if (jplus == NY) jplus = 0;
jminus = j-1; if (jminus == -1) jminus = NY-1;
phi = phi_in[j];
phi_out[j] = -sin(phi_in[jminus] - phi) - sin(phi_in[jplus] - phi) - sin(phi_in[(NX-1)*NY+j] - phi) - sin(phi_in[NY+j] - phi);
}
break;
}
}
/* boundary conditions - right side */
switch (B_COND_RIGHT) {
case (BC_PERIODIC):
{
for (j = 1; j < NY-1; j++)
{
jplus = j+1; if (jplus == NY) jplus = 0;
jminus = j-1; if (jminus == -1) jminus = NY-1;
phi = phi_in[(NX-1)*NY+j];
phi_out[(NX-1)*NY+j] = -sin(phi_in[(NX-1)*NY+jminus] - phi) - sin(phi_in[(NX-1)*NY+jplus] - phi) - sin(phi_in[(NX-2)*NY+j] - phi) - sin(phi_in[j] - phi);
}
break;
}
}
/* boundary conditions - bottom side */
switch (B_COND_BOTTOM) {
case (BC_PERIODIC):
{
for (i = 1; i < NX-1; i++)
{
iplus = i+1; /*if (iplus == NX) iplus = 0;*/
iminus = i-1; /*if (iminus == -1) iminus = NX-1;*/
phi_out[i*NY] = 0.0;
phi_out[i*NY+1] = 0.0;
// phi = phi_in[i*NY];
// phi_out[i*NY] = sin(phi_in[iminus*NY] - phi) + sin(phi_in[iplus*NY] - phi) + sin(phi_in[i*NY+1] - phi);
}
break;
}
}
/* boundary conditions - top side */
switch (B_COND_TOP) {
case (BC_PERIODIC):
{
for (i = 1; i < NX-1; i++)
{
iplus = i+1; /*if (iplus == NX) iplus = 0;*/
iminus = i-1; /*if (iminus == -1) iminus = NX-1;*/
phi_out[i*NY+NY-1] = 0.0;
phi_out[i*NY+NY-2] = 0.0;
// phi = phi_in[i*NY+NY-1];
// phi_out[i*NY+NY-1] = sin(phi_in[iminus*NY+NY-1] - phi) + sin(phi_in[iplus*NY+NY-1] - phi) + sin(phi_in[i*NY] - phi);
}
break;
}
}
}
void compute_kuramoto_interaction(double phi_in[NX*NY], double phi_out[NX*NY], short int xy_in[NX*NY], t_wave_sphere wsphere[NX*NY])
/* computes interaction for Kuramoto model */
{
if (SPHERE) compute_kuramoto_int_sphere(phi_in, phi_out, xy_in);
else
compute_kuramoto_int_planar(phi_in, phi_out, xy_in);
}
@ -5225,7 +5340,7 @@ void compute_light_angle_sphere_rde_2d(short int xy_in[NX*NY], t_rde rde[NX*NY],
first = 0;
}
printf("computing gradient\n");
printf("[compute_light_angle_sphere_rde_2d] computing gradient\n");
#pragma omp parallel for private(i,j,gradx, grady, norm, pscal)
for (i=1; i<NX-1; i++)
@ -5261,6 +5376,8 @@ void compute_light_angle_sphere_rde_2d(short int xy_in[NX*NY], t_rde rde[NX*NY],
else rde[i*NY+j].cos_angle = wsphere[i*NY+j].cos_angle;
}
// printf("[compute_light_angle_sphere_rde_2d] computing gradient 2\n");
/* i=0 */
for (j=1; j<NY-1; j++)
{
@ -5292,6 +5409,8 @@ void compute_light_angle_sphere_rde_2d(short int xy_in[NX*NY], t_rde rde[NX*NY],
else rde[j].cos_angle = wsphere[j].cos_angle;
}
// printf("[compute_light_angle_sphere_rde_2d] computing gradient 3\n");
/* i=NX-1 */
for (j=1; j<NY-1; j++)
{
@ -5322,6 +5441,8 @@ void compute_light_angle_sphere_rde_2d(short int xy_in[NX*NY], t_rde rde[NX*NY],
}
else rde[(NX-1)*NY+j].cos_angle = wsphere[(NX-1)*NY+j].cos_angle;
}
printf("[compute_light_angle_sphere_rde_2d] computing gradient done\n");
}
@ -5436,6 +5557,21 @@ void compute_field_color_rde(double value, int cplot, int palette, double rgb[3]
color_scheme_palette(COLOR_SCHEME, palette, value, 1.0, 0, rgb);
break;
}
case (Z_ANGLE):
{
if (PHASE_SHIFT != 0.0)
{
value += PHASE_SHIFT*PI;
if (value > PI) value -= DPI;
}
// if (vabs(value) > PI) printf("Warning, color out of range\n");
color_scheme_palette(C_BASIC_LINEAR, palette, value/PI, 1.0, 1, rgb);
// color_scheme_palette(C_ONEDIM_LINEAR, palette, value/PI, 1.0, 1, rgb);
// if (value > PI) value -= PI;
// if (value < 0.0) value += PI,
// amp_to_rgb_palette(value/PI, rgb, palette);
break;
}
case (Z_RGB):
{
/* TO DO */
@ -5757,6 +5893,18 @@ void compute_rde_fields(double *phi[NFIELDS], short int xy_in[NX*NY], int zplot,
// printf("[compute_rde_fields] zplot = %i\n", zplot);
switch (RDE_EQUATION) {
case (E_KURAMOTO):
{
compute_theta_kuramoto(phi, xy_in, rde);
/* experimental */
if ((zplot == Z_VORTICITY)||(cplot == Z_VORTICITY)||(zplot == Z_VORTICITY_ABS)||(cplot == Z_VORTICITY_ABS))
{
compute_gradient_theta(rde);
compute_curl(rde);
}
break;
}
case (E_RPS):
{
if ((COMPUTE_THETA)||(COMPUTE_THETAZ))
@ -5850,6 +5998,12 @@ void init_zfield_rde(double *phi[NFIELDS], short int xy_in[NX*NY], int zplot, t_
for (i=0; i<NX; i++) for (j=0; j<NY; j++) rde[i*NY+j].p_zfield[movie] = &phi[0][i*NY+j];
break;
}
case (Z_ANGLE):
{
#pragma omp parallel for private(i,j)
for (i=0; i<NX; i++) for (j=0; j<NY; j++) rde[i*NY+j].p_zfield[movie] = &rde[i*NY+j].theta;
break;
}
case (Z_POLAR):
{
#pragma omp parallel for private(i,j)
@ -6040,6 +6194,12 @@ void init_cfield_rde(double *phi[NFIELDS], short int xy_in[NX*NY], int cplot, t_
for (i=0; i<NX; i++) for (j=0; j<NY; j++) rde[i*NY+j].p_cfield[movie] = &phi[0][i*NY+j];
break;
}
case (Z_ANGLE):
{
#pragma omp parallel for private(i,j)
for (i=0; i<NX; i++) for (j=0; j<NY; j++) rde[i*NY+j].p_cfield[movie] = &rde[i*NY+j].theta;
break;
}
case (Z_POLAR):
{
#pragma omp parallel for private(i,j)
@ -6225,9 +6385,12 @@ void compute_cfield_rde(short int xy_in[NX*NY], int cplot, int palette, t_rde rd
double ca, lum;
#pragma omp parallel for private(i,j,k,ca,lum)
for (i=0; i<NX; i++) for (j=0; j<NY; j++)
// for (i=0; i<NX; i++) for (j=0; j<NY; j++)
for (i=0; i<NX-1; i++) for (j=0; j<NY; j++)
{
// printf("Computing field color %i, %i\n", i, j);
compute_field_color_rde(*rde[i*NY+j].p_cfield[movie], cplot, palette, rde[i*NY+j].rgb);
// printf("Computed field color %i, %i\n", i, j);
// if ((cplot == Z_ARGUMENT)||(cplot == Z_REALPART))
// if ((cplot == Z_ARGUMENT)||(cplot == Z_EULER_DIRECTION_SPEED))
@ -6346,33 +6509,40 @@ void draw_wave_2d_rde_ij(int i, int j, int movie, short int xy_in[NX*NY], t_rde
if (FLOODING)
draw = ((wsphere[i*NY+j].indomain)||((*rde[i*NY+j].p_zfield[movie] >= wsphere[i*NY+j].altitude + FLOODING_VSHIFT_2D)));
else draw = wsphere[i*NY+j].indomain;
// else draw = wsphere[i*NY+j].indomain;
else draw = 1;
for (p=0; p<HRES; p++)
for (q=0; q<HRES; q++)
draw_hr[p*HRES+q] = (draw)||(wsphere_hr[(HRES*i+p)*HRES*NY+HRES*j+q].indomain);
if (RDE_PLANET)
{
for (p=0; p<HRES; p++)
for (q=0; q<HRES; q++)
draw_hr[p*HRES+q] = (draw)||(wsphere_hr[(HRES*i+p)*HRES*NY+HRES*j+q].indomain);
}
for (p=0; p<HRES; p++)
for (q=0; q<HRES; q++)
{
i1 = HRES*i + p;
j1 = HRES*j + q;
ca = wsphere_hr[i1*HRES*NY+j1].cos_angle;
ca = (ca + 1.0)*0.4 + 0.2;
if (fade) ca *= fade_value;
if (RDE_PLANET)
if (RDE_PLANET)
{
for (p=0; p<HRES; p++)
for (q=0; q<HRES; q++)
{
r_hr[p*HRES + q] = wsphere_hr[i1*HRES*NY+j1].r*ca;
g_hr[p*HRES + q] = wsphere_hr[i1*HRES*NY+j1].g*ca;
b_hr[p*HRES + q] = wsphere_hr[i1*HRES*NY+j1].b*ca;
i1 = HRES*i + p;
j1 = HRES*j + q;
ca = wsphere_hr[i1*HRES*NY+j1].cos_angle;
ca = (ca + 1.0)*0.4 + 0.2;
if (fade) ca *= fade_value;
if (RDE_PLANET)
{
r_hr[p*HRES + q] = wsphere_hr[i1*HRES*NY+j1].r*ca;
g_hr[p*HRES + q] = wsphere_hr[i1*HRES*NY+j1].g*ca;
b_hr[p*HRES + q] = wsphere_hr[i1*HRES*NY+j1].b*ca;
}
else
{
r_hr[p*HRES + q] = COLOR_OUT_R*ca;
g_hr[p*HRES + q] = COLOR_OUT_G*ca;
b_hr[p*HRES + q] = COLOR_OUT_B*ca;
}
}
else
{
r_hr[p*HRES + q] = COLOR_OUT_R*ca;
g_hr[p*HRES + q] = COLOR_OUT_G*ca;
b_hr[p*HRES + q] = COLOR_OUT_B*ca;
}
}
}
ii = NX-i-1+ishift;
if (ii > NX) ii -= NX;
@ -6419,7 +6589,7 @@ void draw_wave_2d_rde(short int xy_in[NX*NY], t_rde rde[NX*NY], t_wave_sphere ws
first = 0;
}
// printf("Drawing wave\n");
printf("Drawing wave\n");
/* draw the field */
glBegin(GL_QUADS);
for (i=0; i<NX; i++)
@ -6455,16 +6625,22 @@ void draw_wave_sphere_rde_ij(int i, int iplus, int j, int jplus, int jcolor, int
// draw = wsphere[i*NY+j].indomain;
if (FLOODING)
draw = ((wsphere[i*NY+j].indomain)||((*rde[i*NY+j].p_zfield[movie] >= wsphere[i*NY+j].altitude + FLOODING_VSHIFT)));
else draw = wsphere[i*NY+j].indomain;
// draw = 1;
for (p=0; p<HRES; p++)
for (q=0; q<HRES; q++)
draw_hr[p*HRES+q] = (draw)||(wsphere_hr[(HRES*i+p)*HRES*NY+HRES*j+q].indomain);
// else draw = wsphere[i*NY+j].indomain;
else draw = 1;
if (RDE_PLANET)
{
for (p=0; p<HRES; p++)
for (q=0; q<HRES; q++)
draw_hr[p*HRES+q] = (draw)||(wsphere_hr[(HRES*i+p)*HRES*NY+HRES*j+q].indomain);
// draw_hr[p*HRES+q] = (draw)&&(wsphere_hr[(HRES*i+p)*HRES*NY+HRES*j+q].indomain);
}
for (k=0; k<3; k++) rgb[k] = rde[i*NY+jcolor].rgb[k];
glColor3f(rgb[0], rgb[1], rgb[2]);
for (p=0; p<HRES; p++)
if (RDE_PLANET)
{
for (p=0; p<HRES; p++)
for (q=0; q<HRES; q++)
{
i1 = HRES*i + p;
@ -6485,6 +6661,7 @@ void draw_wave_sphere_rde_ij(int i, int iplus, int j, int jplus, int jcolor, int
b_hr[p*HRES + q] = COLOR_OUT_B*ca;
}
}
}
if (draw_bc)
{
@ -7117,7 +7294,9 @@ void draw_wave_rde(int movie, double *phi[NFIELDS], short int xy_in[NX*NY], t_rd
else if (SHADE_2D)
compute_light_angle_sphere_rde_2d(xy_in, rde, wsphere, potential, movie, 0);
}
printf("Computing cfield\n");
compute_cfield_rde(xy_in, cplot, palette, rde, fade, fade_value, movie);
printf("Computed cfield\n");
if (PLOT_3D)
{

File diff suppressed because it is too large Load Diff

View File

@ -921,6 +921,7 @@ int ij_to_sphere(int i, int j, double r, t_wave_sphere wsphere[NX*NY], double xy
if (use_wave_radius)
{
newr = wsphere[i*NY+j].radius;
newr += (RSCALE_B-1.0)*r;
xyz[0] *= newr;
xyz[1] *= newr;
xyz[2] *= newr;
@ -958,6 +959,7 @@ int ij_to_sphere_hres(int i, int j, double r, t_wave_sphere wsphere[HRES*HRES*NX
if (use_wave_radius)
{
newr = wsphere[i*HRES*NY+j].radius;
newr += (RSCALE_B-1.0)*r;
xyz[0] *= newr;
xyz[1] *= newr;
xyz[2] *= newr;
@ -2745,6 +2747,12 @@ void draw_circular_color_scheme_palette_3d(double x1, double y1, double radius,
value = dy_phase*(double)(j);
color_scheme_palette(C_ONEDIM_LINEAR, palette, value, 1.0, 1, rgb);
break;
}
case (Z_AMPLITUDE):
{
value = min + 1.0*dy*(double)(j);
color_scheme_palette(COLOR_SCHEME, palette, 0.7*value, 1.0, 0, rgb);
break;
}
case (Z_POLAR):
{

137
wave_3d.c
View File

@ -43,7 +43,7 @@
#include <omp.h>
#include <time.h>
#define MOVIE 1 /* set to 1 to generate movie */
#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 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 */
@ -52,10 +52,8 @@
#define WINWIDTH 1920 /* window width */
#define WINHEIGHT 1150 /* window height */
// #define NX 1920 /* number of grid points on x axis */
// #define NY 1150 /* number of grid points on y axis */
#define NX 3000 /* number of grid points on x axis */
#define NY 1600 /* number of grid points on y axis */
#define NX 1920 /* number of grid points on x axis */
#define NY 1150 /* number of grid points on y axis */
#define XMIN -2.0
#define XMAX 2.0 /* x interval */
@ -68,36 +66,39 @@
/* Choice of the billiard table */
#define B_DOMAIN 76 /* choice of domain shape, see list in global_pdes.c */
#define B_DOMAIN 96 /* 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 */
#define COMPARISON 0 /* set to 1 to compare two different patterns */
#define B_DOMAIN_B 20 /* second domain shape, for comparisons */
#define CIRCLE_PATTERN_B 0 /* second pattern of circles or polygons */
#define IMAGE_FILE 5 /* for option D_IMAGE */
#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 181 /* choice of index of refraction, see list in global_pdes.c */
#define IOR_TOTAL_TURNS 1.0 /* total angle of rotation for IOR_PERIODIC_WELLS_ROTATING */
#define MANDEL_IOR_SCALE -0.05 /* parameter controlling dependence of IoR on Mandelbrot escape speed */
#define P_PERCOL 0.25 /* probability of having a circle in C_RAND_PERCOL arrangement */
#define NPOISSON 1000 /* number of points for Poisson C_RAND_POISSON arrangement */
#define PDISC_FACTOR 3.25 /* controls density of Poisson disc process (default: 3.25) */
#define PDISC_FACTOR 2.3 /* controls density of Poisson disc process (default: 3.25) */
#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.0 /* parameter controlling the dimensions of domain */
#define MU 0.35 /* parameter controlling the dimensions of domain */
#define NPOLY 6 /* number of sides of polygon */
#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 APOLY 0.0 /* angle by which to turn polygon, in units of Pi/2 */
#define MDEPTH 7 /* 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 FOCI 1 /* set to 1 to draw focal points of ellipse */
#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.1 /* width of wall separating lenses */
#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.022 /* width of wall separating lenses */
#define WALL_WIDTH_RND 0.5 /* proportion of width of width for random arrangements */
#define RADIUS_FACTOR 0.3 /* controls inner radius for C_RING arrangements */
#define X_SHOOTER -0.2
@ -145,8 +146,9 @@
/* 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 9 /* period of oscillating source */
#define OSCILLATING_SOURCE_PERIOD 8 /* 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 */
#define ADD_WAVE_PACKET_SOURCES 0 /* set to 1 to add several sources emitting wave packets */
#define WAVE_PACKET_SOURCE_TYPE 1 /* type of wave packet sources */
@ -155,14 +157,14 @@
/* Boundary conditions, see list in global_pdes.c */
#define B_COND 2
#define B_COND 1
#define PRECOMPUTE_BC 0 /* set to 1 to compute neighbours for Laplacian in advance */
/* Parameters for length and speed of simulation */
#define NSTEPS 1800 /* number of frames of movie */
#define NVID 15 /* number of iterations between images displayed on screen */
#define NSTEPS 3200 /* 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 */
#define BOUNDARY_WIDTH 2 /* width of billiard boundary */
@ -179,10 +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 */
@ -196,7 +197,7 @@
#define FLUX_WINDOW 30 /* size of averaging window of flux intensity */
#define AMPLITUDE_HIGH_RES 1 /* set to 1 to increase resolution of plot */
#define SHADE_3D 1 /* set to 1 to change luminosity according to normal vector */
#define NON_DIRICHLET_BC 0 /* set to 1 to draw only facets in domain, if field is not zero on boundary */
#define NON_DIRICHLET_BC 1 /* set to 1 to draw only facets in domain, if field is not zero on boundary */
#define FLOOR_ZCOORD 1 /* set to 1 to draw only facets with z not too negative */
#define DRAW_BILLIARD 0 /* set to 1 to draw boundary */
#define DRAW_BILLIARD_FRONT 0 /* set to 1 to draw front of boundary after drawing wave */
@ -214,29 +215,29 @@
#define REP_AXO_3D 0 /* linear projection (axonometry) */
#define REP_PROJ_3D 1 /* projection on plane orthogonal to observer line of sight */
#define ROTATE_VIEW 0 /* set to 1 to rotate position of observer */
#define ROTATE_VIEW 1 /* set to 1 to rotate position of observer */
#define ROTATE_ANGLE 360.0 /* total angle of rotation during simulation */
/* Color schemes */
#define COLOR_PALETTE 17 /* Color palette, see list in global_pdes.c */
#define COLOR_PALETTE_B 14 /* Color palette, see list in global_pdes.c */
#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 BLACK 1 /* background */
#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 1.0 /* sensitivity of color on wave amplitude */
#define VSCALE_AMPLITUDE 2.0 /* additional scaling factor for color scheme P_3D_AMPLITUDE */
#define SLOPE 0.75 /* sensitivity of color on wave amplitude */
#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 3.0 /* additional scaling factor for color scheme P_3D_ENERGY */
#define VSCALE_ENERGY 1.0 /* additional scaling factor for color scheme P_3D_ENERGY */
#define PHASE_FACTOR 20.0 /* factor in computation of phase in color scheme P_3D_PHASE */
#define PHASE_SHIFT 0.0 /* shift of phase in color scheme P_3D_PHASE */
#define ATTENUATION 0.0 /* exponential attenuation coefficient of contrast with time */
#define E_SCALE 100.0 /* scaling factor for energy representation */
#define LOG_SCALE 0.75 /* scaling factor for energy log representation */
#define LOG_SHIFT 0.5 /* shift of colors on log scale */
#define ATTENUATION 0.0 /* exponential attenuation coefficient of contrast with time */
#define E_SCALE 30.0 /* scaling factor for energy representation */
#define LOG_SCALE 1.5 /* scaling factor for energy log representation */
#define LOG_SHIFT 0.25 /* shift of colors on log scale */
#define LOG_ENERGY_FLOOR -10.0 /* floor value for log of (total) energy */
#define LOG_MEAN_ENERGY_SHIFT 1.0 /* additional shift for log of mean energy */
#define FLUX_SCALE 4000.0 /* scaling factor for energy flux representation */
@ -266,13 +267,13 @@
#define MAZE_WIDTH 0.02 /* half width of maze walls */
#define DRAW_COLOR_SCHEME 1 /* set to 1 to plot the color scheme */
#define COLORBAR_RANGE 3.0 /* scale of color scheme bar */
#define COLORBAR_RANGE_B 2.0 /* scale of color scheme bar for 2nd part */
#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 ROTATE_COLOR_SCHEME 0 /* set to 1 to draw color scheme horizontally */
#define SAVE_TIME_SERIES 0 /* set to 1 to save wave time series at a point */
#define ADD_POTENTIAL 1 /* set to 1 to add potential to z coordinate */
#define ADD_POTENTIAL 0 /* set to 1 to add potential to z coordinate */
#define POTENTIAL 10
#define POT_FACT 200.0
#define DRAW_WAVE_PROFILE 0 /* set to 1 to draw a profile of the wave */
@ -289,7 +290,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 1 /* number of sources, for option draw_sources */
#define N_SOURCES 2 /* 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 */
@ -304,14 +305,14 @@ 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.816496581, -0.40824829, 0.40824829}; /* vector of "light" direction for P_3D_ANGLE color scheme */
double observer[3] = {8.0, 6.0, 6.0}; /* location of observer for REP_PROJ_3D representation */
double observer[3] = {-8.0, -6.0, 6.0}; /* location of observer for REP_PROJ_3D representation */
int reset_view = 0; /* switch to reset 3D view parameters (for option ROTATE_VIEW) */
#define Z_SCALING_FACTOR 0.15 /* overall scaling factor of z axis for REP_PROJ_3D representation */
#define XY_SCALING_FACTOR 1.7 /* overall scaling factor for on-screen (x,y) coordinates after projection */
#define Z_SCALING_FACTOR 0.05 /* overall scaling factor of z axis for REP_PROJ_3D representation */
#define XY_SCALING_FACTOR 1.8 /* 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.1 /* overall x shift for REP_PROJ_3D representation */
#define YSHIFT_3D 0.3 /* overall y shift for REP_PROJ_3D representation */
#define YSHIFT_3D 0.2 /* overall y shift for REP_PROJ_3D representation */
#include "global_pdes.c" /* constants and global variables */
@ -950,11 +951,11 @@ void viewpoint_schedule(int i)
void animation()
{
double time, scale, ratio, startleft[2], startright[2], sign = 1.0, r2, xy[2], fade_value, yshift, speed = 0.0, a, b, c, angle = 0.0, lambda1, y, x1, sign1, omega, phase_shift;
double time, scale, ratio, startleft[2], startright[2], sign = 1.0, r2, xy[2], fade_value, yshift, speed = 0.0, a, b, c, angle = 0.0, lambda1, y, x1, sign1, omega, phase_shift, source_amp[N_SOURCES];
double *phi, *psi, *tmp, *color_scale, *tc, *tcc, *tgamma;
// double *total_energy;
short int *xy_in;
int i, j, s, sample_left[2], sample_right[2], period = 0, fade, source_counter = 0, k, p, q;
int i, j, s, sample_left[2], sample_right[2], period = 0, fade, source_counter = 0, k, p, q, source, source_periods[N_SOURCES];
static int counter = 0, first_source = 1;
long int wave_value;
t_wave *wave;
@ -1003,15 +1004,26 @@ void animation()
}
printf("Polygons initialized\n");
if (XYIN_INITIALISED) init_xyin_from_image_3d(xy_in);
/* 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);
//
// npolyrect = init_polyrect(polyrect);
//
// 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);
if (COMPARISON) npolyline_b = init_polyline(MDEPTH, polyline);
npolyrect = init_polyrect(polyrect);
for (i=0; i<npolyline; i++) printf("vertex %i: (%.3f, %.3f)\n", i, polyline[i].x, polyline[i].y);
for (i=0; i<npolyrect; i++) printf("polyrect vertex %i: (%.3f, %.3f) - (%.3f, %.3f)\n", i, polyrect[i].x1, polyrect[i].y1, polyrect[i].x2, polyrect[i].y2);
init_polyrect_arc(polyrectrot, polyarc, &npolyrect_rot, &npolyarc);
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].dangle*180.0/PI);
// printf("Rectangles initialized\n");
printf("Rotated rectangles and arcs initialized\n");
printf("%i rotated rectangles, %i arcs\n", npolyrect_rot, npolyarc);
@ -1150,14 +1162,31 @@ void animation()
if (DRAW_COLOR_SCHEME) draw_color_bar_palette(CPLOT, COLORBAR_RANGE, COLOR_PALETTE, fade, fade_value);
/* add oscillating waves */
// if ((ADD_OSCILLATING_SOURCE)&&(i%OSCILLATING_SOURCE_PERIOD == OSCILLATING_SOURCE_PERIOD - 1))
if ((ADD_OSCILLATING_SOURCE)&&(i%OSCILLATING_SOURCE_PERIOD == 1))
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;
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 (ALTERNATE_OSCILLATING_SOURCE) sign = -sign;
add_circular_wave_mod(sign, -1.75, 0.3, phi, psi, xy_in);
add_circular_wave_mod(sign, -1.75, -0.3, phi, psi, xy_in);
if ((ADD_OSCILLATING_SOURCE)&&(i%(OSCILLATING_SOURCE_PERIOD) == 1)&&(i<MAX_PULSING_TIME))
{
if (ALTERNATE_OSCILLATING_SOURCE) sign = -sign;
add_circular_wave_mod(-sign*INITIAL_AMP, wave_source_x[source], wave_source_y[source], phi, psi, xy_in);
}
}
// if ((ADD_OSCILLATING_SOURCE)&&(i%OSCILLATING_SOURCE_PERIOD == 1))
// {
// if (ALTERNATE_OSCILLATING_SOURCE) sign = -sign;
// {
// add_circular_wave_mod(sign, 0.0, 2.0*LAMBDA, phi, psi, xy_in);
// add_circular_wave_mod(sign, 0.0, -2.0*LAMBDA, phi, psi, xy_in);
// }
// }
if (PRINT_SPEED) print_speed_3d(speed, 0, 1.0);
if (!((NO_EXTRA_BUFFER_SWAP)&&(MOVIE))) glutSwapBuffers();

View File

@ -44,7 +44,7 @@
#include <time.h>
#define MOVIE 0 /* set to 1 to generate movie */
#define DOUBLE_MOVIE 0 /* set to 1 to produce movies for wave height and energy simultaneously */
#define DOUBLE_MOVIE 1 /* set to 1 to produce movies for wave height and energy simultaneously */
#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 */
@ -55,17 +55,13 @@
/* General geometrical parameters */
// #define WINWIDTH 1920 /* window width */
#define WINWIDTH 1150 /* window width */
#define WINWIDTH 1920 /* window width */
#define WINHEIGHT 1150 /* window height */
// #define NX 3840 /* number of grid points on x axis */
#define NX 2300 /* number of grid points on x axis */
#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.197916667
#define XMAX 1.197916667 /* x interval */
#define XMIN -2.0
#define XMAX 2.0 /* x interval */
#define YMIN -1.197916667
#define YMAX 1.197916667 /* y interval for 9/16 aspect ratio */
@ -76,9 +72,9 @@
/* Choice of the billiard table */
#define B_DOMAIN 92 /* choice of domain shape, see list in global_pdes.c */
#define B_DOMAIN 96 /* 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 CIRCLE_PATTERN 202 /* pattern of circles or polygons, see list in global_pdes.c */
#define IMAGE_FILE 5 /* for option D_IMAGE */
#define COMPARISON 0 /* set to 1 to compare two different patterns (beta) */
@ -87,22 +83,24 @@
#define P_PERCOL 0.15 /* probability of having a circle in C_RAND_PERCOL arrangement */
#define NPOISSON 1000 /* number of points for Poisson C_RAND_POISSON arrangement */
#define PDISC_FACTOR 3.5 /* controls density of Poisson disc process (default: 3.25) */
#define PDISC_FACTOR 2.3 /* controls density of Poisson disc process (default: 3.25) */
#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 0.8 /* parameter controlling the dimensions of domain */
#define MU 0.75 /* parameter controlling the dimensions of domain */
#define LAMBDA 1.25 /* parameter controlling the dimensions of domain */
#define MU 0.065 /* parameter controlling the dimensions of domain */
#define MU_B 1.0 /* parameter controlling the dimensions of domain */
#define NPOLY 7 /* number of sides of polygon */
#define NPOLY 6 /* number of sides of polygon */
#define APOLY 0.0 /* angle by which to turn polygon, in units of Pi/2 */
#define MDEPTH 6 /* depth of computation of Menger gasket */
#define MRATIO 3 /* ratio defining Menger gasket */
#define MANDELLEVEL 1000 /* iteration level for Mandelbrot set */
#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 60 /* number of grid point for grid of disks */
#define NGRIDY 25 /* number of grid point for grid of disks */
#define WALL_WIDTH 0.05 /* width of wall separating lenses */
#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 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 X_SHOOTER -0.2
@ -110,11 +108,11 @@
#define X_TARGET 0.4
#define Y_TARGET 0.7 /* shooter and target positions in laser fight */
#define ISO_XSHIFT_LEFT -2.9
#define ISO_XSHIFT_LEFT -2.9
#define ISO_XSHIFT_RIGHT 1.4
#define ISO_YSHIFT_LEFT -0.15
#define ISO_YSHIFT_RIGHT -0.15
#define ISO_SCALE 0.5 /* coordinates for isospectral billiards */
#define ISO_YSHIFT_LEFT -0.2
#define ISO_YSHIFT_RIGHT 0.15
#define ISO_SCALE 0.475 /* coordinates for isospectral billiards */
/* You can add more billiard tables by adapting the functions */
/* xy_in_billiard and draw_billiard below */
@ -132,7 +130,7 @@
#define AMPLITUDE 0.5 /* amplitude of periodic excitation */
#define ACHIRP 0.25 /* acceleration coefficient in chirp */
#define DAMPING 0.0 /* damping of periodic excitation */
#define COURANT 0.08 /* Courant number */
#define COURANT 0.1 /* Courant number */
#define COURANTB 0.025 /* Courant number in medium B */
#define GAMMA 0.0 /* damping factor in wave equation */
#define GAMMAB 0.0 /* damping factor in wave equation */
@ -148,11 +146,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 49 /* period of oscillating source */
#define OSCILLATING_SOURCE_PERIOD 8 /* period of oscillating source */
#define ALTERNATE_OSCILLATING_SOURCE 1 /* set to 1 to alternate sign of oscillating source */
#define N_SOURCES 7 /* number of sources, for option draw_sources */
#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 MAX_PULSING_TIME 100 /* max time for adding pulses */
#define MAX_PULSING_TIME 1500 /* 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 */
@ -163,12 +161,12 @@
/* Boundary conditions, see list in global_pdes.c */
#define B_COND 2
#define B_COND 1
/* Parameters for length and speed of simulation */
#define NSTEPS 1350 /* number of frames of movie */
#define NVID 8 /* number of iterations between images displayed on screen */
#define NSTEPS 3200 /* number of frames of movie */
#define NVID 7 /* 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 */
@ -185,20 +183,20 @@
/* Parameters of initial condition */
#define INITIAL_AMP 1.4 /* amplitude of initial condition */
#define INITIAL_VARIANCE 0.00005 /* variance 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 8
#define PLOT 0
#define PLOT_B 0 /* plot type for second movie */
#define PLOT_B 8 /* plot type for second movie */
/* Color schemes */
#define COLOR_PALETTE 12 /* Color palette, see list in global_pdes.c */
#define COLOR_PALETTE_B 11 /* Color palette, see list in global_pdes.c */
#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 BLACK 1 /* background */
@ -209,13 +207,13 @@
#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.5 /* additional shift for wave amplitude */
#define VSHIFT_AMPLITUDE 0.0 /* additional shift for wave amplitude */
#define VSCALE_AMPLITUDE 0.2 /* additional scaling factor for wave amplitude */
#define E_SCALE 13.5 /* scaling factor for energy representation */
#define E_SCALE 30.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.9 /* controls time window size in P_AVERAGE_ENERGY scheme */
#define AVRG_E_FACTOR 0.85 /* 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 */
@ -230,8 +228,8 @@
#define DRAW_COLOR_SCHEME 0 /* set to 1 to plot the color scheme */
#define COLORBAR_RANGE 1.5 /* scale of color scheme bar */
#define COLORBAR_RANGE_B 0.3 /* scale of color scheme bar for 2nd part */
#define ROTATE_COLOR_SCHEME 1 /* set to 1 to draw color scheme horizontally */
#define COLORBAR_RANGE_B 0.12 /* scale of color scheme bar for 2nd part */
#define ROTATE_COLOR_SCHEME 0 /* set to 1 to draw color scheme horizontally */
#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 */
@ -588,7 +586,7 @@ void draw_color_bar_palette(int plot, double range, int palette, int circular, i
// double width = 0.2;
if (ROTATE_COLOR_SCHEME)
draw_color_scheme_palette_fade(-1.0, -0.8, XMAX - 0.1, -1.0, plot, -range, range, palette, fade, fade_value);
draw_color_scheme_palette_fade(-1.0, -0.85, XMAX - 0.1, -1.0, plot, -range, range, palette, fade, fade_value);
else if (circular)
draw_circular_color_scheme_palette_fade(XMAX - 2.0*width, YMIN + 2.0*width, 1.5*width, plot, -range, range, palette, fade, fade_value);
else
@ -597,10 +595,10 @@ 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, 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;
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];
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];
// static int image_counter = 0;
int image_counter = 0;
long int wave_value;
@ -646,16 +644,29 @@ void animation()
printf("Polygons initialized\n");
/* 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);
npolyrect = init_polyrect(polyrect);
for (i=0; i<npolyrect; i++) printf("polyrect vertex %i: (%.3f, %.3f) - (%.3f, %.3f)\n", i, polyrect[i].x1, polyrect[i].y1, polyrect[i].x2, polyrect[i].y2);
printf("Rectangles initialized\n");
/* initialise lines and arcs for drawing some domains */
// nlines = init_lines(line, polyarc, &npolyarc);
init_polyrect_arc(polyrectrot, polyarc, &npolyrect_rot, &npolyarc);
printf("Rotated rectangles and arcs initialized\n");
printf("%i rotated rectangles, %i arcs\n", npolyrect_rot, npolyarc);
// npolyrect = init_polyrect(polyrect);
// 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);
for (i=0; i<ncircles; i++) printf("circle %i: (%.3f, %.3f)\n", i, circles[i].xc, circles[i].yc);
// for (i=0; i<npolyline; i++) printf("vertex %i: (%.3f, %.3f)\n", i, polyline[i].x, polyline[i].y);
// for (i=0; i<npolyrect; i++) printf("polyrect vertex %i: (%.3f, %.3f) - (%.3f, %.3f)\n", i, polyrect[i].x1, polyrect[i].y1, polyrect[i].x2, polyrect[i].y2);
// 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);
// printf("Rectangles initialized\n");
printf("Lines, rotated rectangles and arcs initialized\n");
printf("%i lines, %i rotated rectangles, %i arcs\n", npolyline, npolyrect_rot, npolyarc);
if ((DRAW_WAVE_TIMESERIES)||(USE_INPUT_TIMESERIES)) init_input_signal();
@ -709,7 +720,7 @@ void animation()
if (XYIN_INITIALISED) init_xyin_from_image(xy_in);
// isospectral_initial_point(0.2, 0.0, startleft, startright); /* for isospectral billiards */
// 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);
// printf("xleft = (%.3f, %.3f) xright = (%.3f, %.3f)\n", startleft[0], startleft[1], startright[0], startright[1]);
@ -830,17 +841,21 @@ 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;
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++)
{
angle = ((double)source)*DPI/(double)NPOLY + APOLY*PID - PID;
wave_source_x[source] = 1.0*LAMBDA*cos(angle);
wave_source_y[source] = 1.0*LAMBDA*sin(angle);
source_shift[source] = 0;
// source_shift[source] = OSCILLATING_SOURCE_PERIOD*source/N_SOURCES;
if ((ADD_OSCILLATING_SOURCE)&&(i%(OSCILLATING_SOURCE_PERIOD) == source_shift[source])&&(i<MAX_PULSING_TIME))
// source_shift[source] = 0;
if ((ADD_OSCILLATING_SOURCE)&&(i%(source_periods[source]) == 1)&&(i<MAX_PULSING_TIME))
{
if (ALTERNATE_OSCILLATING_SOURCE) sign[source] = -sign[source];
add_circular_wave(-sign[source]*INITIAL_AMP, wave_source_x[source], wave_source_y[source], phi, psi, xy_in);
add_circular_wave(-sign[source]*source_amp[source], wave_source_x[source], wave_source_y[source], phi, psi, xy_in);
}
}

View File

@ -1899,7 +1899,7 @@ void init_wave_flat_mod(double phi[NX*NY], double psi[NX*NY], short int xy_in[NX
{
#pragma omp parallel for private(i,j,xy)
for (i=0; i<NX; i++) {
if (i%100 == 0) printf("Wave and table xy_in - Initialising column %i of %i\n", i, NX);
if (i%100 == 0) printf("[init_wave_flat_mod] Wave and table xy_in - Initialising column %i of %i\n", i, NX);
for (j=0; j<NY; j++)
{
ij_to_xy(i, j, xy);

View File

@ -97,6 +97,7 @@
#define PDISC_FACTOR 3.25 /* controls density of Poisson disc process (default: 3.25) */
#define RANDOM_POLY_ANGLE 0 /* set to 1 to randomize angle of polygons */
#define RANDOM_POLY_ANGLE_B 0 /* 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 XDEP_POLY_ANGLE 0 /* set to 1 to rotate polygons depending on x coordinate */
#define XDEP_POLY_ANGLE_B 0 /* set to 1 to rotate polygons depending on x coordinate */
@ -259,6 +260,7 @@
#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 */

View File

@ -77,6 +77,7 @@
#define PDISC_FACTOR 3.25 /* controls density of Poisson disc process (default: 3.25) */
#define RANDOM_POLY_ANGLE 1 /* set to 1 to randomize angle of polygons */
#define RANDOM_POLY_ANGLE_B 0 /* 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 XDEP_POLY_ANGLE 0 /* set to 1 to rotate polygons depending on x coordinate */
#define XDEP_POLY_ANGLE_B 1 /* set to 1 to rotate polygons depending on x coordinate */
@ -233,6 +234,7 @@
#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 */

View File

@ -87,6 +87,7 @@
#define NPOISSON 1000 /* number of points for Poisson C_RAND_POISSON arrangement */
#define PDISC_FACTOR 3.25 /* controls density of Poisson disc process (default: 3.25) */
#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 0.75 /* parameter controlling the dimensions of domain */
#define MU 0.1 /* parameter controlling the dimensions of domain */
@ -101,6 +102,7 @@
#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_RND 0.0 /* proportion of width of width for random arrangements */
#define RADIUS_FACTOR 0.3 /* controls inner radius for C_RING arrangements */
#define X_SHOOTER -0.2