Add files via upload

This commit is contained in:
Nils Berglund 2024-03-09 18:17:55 +01:00 committed by GitHub
parent 9ff0b44339
commit d5be739977
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 5382 additions and 1060 deletions

View File

@ -86,6 +86,7 @@
int global_time = 0;
double max_depth = 1.0;
int moon_position;
/* structure used for color and height representations */
/* possible extra fields: zfield, cfield, interpolated coordinates */
@ -148,12 +149,15 @@ typedef struct
double ctheta, stheta, cottheta; /* cos, sin and cotangent of theta */
double x, y, z; /* x, y, z coordinates of point on sphere */
double radius; /* radius with wave height */
double radius_dem; /* radius with digital elevation model */
double r, g, b; /* RGB values for image */
short int indomain; /* has value 1 if lattice point is in domain */
short int draw_wave; /* has value 1 if wave instead of DEM is drawn */
double x2d, y2d; /* x and y coordinates for 2D representation */
double altitude; /* altitude in case of Earth with digital elevation model */
double cos_angle; /* cosine of light angle */
double cos_angle_sphere; /* cosing of light angle for perfect sphere */
double force; /* external forcing */
} t_wave_sphere;

View File

@ -17,7 +17,7 @@
#define NMAXSEGMENTS 1000 /* max number of repelling segments */
#define NMAXGROUPS 50 /* max number of groups of segments */
#define NMAXCOLLISIONS 200000 /* max number of collisions */
#define NMAXPARTNERS 10 /* max number of partners in molecule */
#define NMAXPARTNERS 30 /* max number of partners in molecule */
#define C_SQUARE 0 /* square grid of circles */
#define C_HEX 1 /* hexagonal/triangular grid of circles */
@ -75,6 +75,7 @@
#define S_HLINE_HOLE_SPOKES 181 /* horizontal line with a hole in the bottom and extra spokes */
#define S_EXT_CIRCLE_RECT 19 /* particles outside a circle and a rectangle */
#define S_BIN_OPENING 20 /* bin containing particles opening at deactivation time */
#define S_BIN_LARGE 201 /* larger bin */
#define S_POLYGON_EXT 21 /* exterior of a regular polygon */
#define S_WEDGE_EXT 22 /* exterior of a wedge */
#define S_MIXER 23 /* exterior of a blender made of rectangles */
@ -83,6 +84,7 @@
#define S_COANDA_SHORT 26 /* shorter wall for Coanda effect */
#define S_CYLINDER 27 /* walls at top and bottom, for cylindrical b.c. */
#define S_TREE 28 /* Christmas tree(s) */
#define S_CONE 29 /* cone */
/* particle interaction */
@ -127,11 +129,26 @@
#define TH_INBOX 2 /* only particles in a given box are coupled */
#define TH_LAYER 3 /* only particles above PARTIAL_THERMO_HEIGHT are coupled */
#define TH_LAYER_TYPE2 4 /* only particles above highest type 2 particle are coupled */
#define TH_RING 5 /* only particles outside disc of radius PARTIAL_THERMO_WIDTH are coupled */
#define TH_RING_EXPAND 6 /* only particles outside disc of radius changing from PARTIAL_THERMO_RIN to PARTIAL_THERMO_RFIN are coupled */
#define TH_INIT 7 /* only particles in region defined by INITXMIN, etc are coupled */
#define TH_THERMO 8 /* only particles in region defined by THERMOXMIN, etc are coupled */
#define TH_CONE 9 /* cone defined by S_CONE */
/* temperature schedules */
#define TS_EXPONENTIAL 0 /* temperature follows an exponential in time */
#define TS_CYCLING 1 /* temperature cycling */
#define TS_PERIODIC 2 /* periodic time dependence */
#define TS_LINEAR 3 /* linear time dependence */
#define TS_COSINE 4 /* periodic time dependence, cosine */
#define TS_EXPCOS 5 /* periodic time dependence, exponential of cosine */
#define TS_ASYM_EXPCOS 6 /* periodic time dependence, asymmetric exponential of cosine */
/* Gravity schedules */
#define G_INCREASE_RELEASE 1 /* slow increase and instant release */
#define G_INCREASE_DECREASE 2 /* slow increase an decrease */
#define G_INCREASE_DECREASE 2 /* slow increase and decrease */
/* Rocket shapes */
@ -170,9 +187,14 @@
#define CHEM_BZ 14 /* simplified Belousov-Zhabotinski reaction with 6 types (Oregonator) */
#define CHEM_BRUSSELATOR 15 /* Brusselator oscillating reaction */
#define CHEM_ABDACBE 16 /* A + B -> D, A + C -> B + E */
#define CHEM_H2O_H_OH 20 /* H2O <-> H+ + OH- */
#define CHEM_2H2O_H3O_OH 21 /* 2 H2O <-> H3O+ + OH- */
#define CHEM_AGGREGATION 22 /* agregation of molecules coming close */
#define CHEM_AGGREGATION_CHARGE 23 /* agregation of charged molecules coming close */
/* Initial conditions for chemical reactions */
#define IC_NOTHING 99 /* do not change particle types */
#define IC_UNIFORM 0 /* all particles have type 1 */
#define IC_UNIFORM2 20 /* all particles have type 2 */
#define IC_RANDOM_UNIF 1 /* particle type chosen uniformly at random */
@ -212,8 +234,13 @@
#define P_INITIAL_POS 11 /* colors depend on initial position of particle */
#define P_NUMBER 12 /* colors depend on particle number */
#define P_EMEAN 13 /* averaged kinetic energy (with exponential damping) */
#define P_LOG_EMEAN 131 /* log of averaged kinetic energy (with exponential damping) */
#define P_DIRECT_EMEAN 14 /* averaged version of P_DIRECT_ENERGY */
#define P_NOPARTICLE 15 /* particles are not drawn (only the links between them) */
#define P_NPARTNERS 16 /* number of partners */
#define P_CHARGE 17 /* colors represent charge */
#define P_MOL_ANGLE 18 /* orientation of molecule defined by partners */
#define P_CLUSTER 19 /* colors depend on connected component */
/* Rotation schedules */
@ -230,6 +257,12 @@
#define POLY_STAR 0 /* star-shaped graph (central molecule attracts outer ones) */
#define POLY_ALL 1 /* all-to-all coupling */
#define POLY_WATER 2 /* star-shaped with a 120° separation between anions */
#define POLY_SOAP 3 /* polymers with all-to-all coupling and polar end */
#define POLY_SOAP_B 4 /* polymers with pairwise coupling and polar end */
#define POLY_PLUSMINUS 5 /* polymers with ends of opposite charge */
#define POLY_HYDRA 6 /* star-shaped with longer arms */
#define POLY_HYDRA_RIGID 61 /* star-shaped with longer arms and rigid first ring */
// #define POLY_GLUE 99 /* dummy value for option CHEM_AGGREGATION */
/* Background color schemes */
@ -239,6 +272,11 @@
#define BG_EKIN 3 /* background color depends on kinetic energy */
#define BG_FORCE 4 /* background color depends on total force */
/* Particle add regions */
#define ADD_RECTANGLE 0 /* rectangular region, defined by ADDXMIN, etc */
#define ADD_RING 1 /* ring_shaped region, defined by ADDRMIN, ADDRMAX */
/* Color schemes */
#define C_LUM 0 /* color scheme modifies luminosity (with slow drift of hue) */
@ -300,9 +338,12 @@ typedef struct
double spin_freq; /* angular frequency of spin-spin interaction */
double color_hue; /* color hue of particle, for P_INITIAL_POS plot type */
int color_rgb[3]; /* RGB colors code of particle, for use in ljones_movie.c */
int partner[NMAXPARTNERS]; /* partners particle for option PAIR_PARTICLES */
int partner[NMAXPARTNERS]; /* partner particles for option PAIR_PARTICLES */
short int npartners; /* number of partner particles */
double partner_eqd[NMAXPARTNERS]; /* equilibrium distances between partners */
int p0, p1; /* numbers of two first partners (for P_MOL_ANGLE color scheme) */
int cluster; /* number of cluster */
short int tested, cactive; /* for cluster search */
} t_particle;
typedef struct
@ -410,7 +451,10 @@ typedef struct
double bdry_fx, bdry_fy; /* components of boundary force */
double efield, bfield; /* electric and magnetic field */
double prop; /* proportion of types */
double thermo_radius; /* radius of thermostat region */
} t_lj_parameters;
int ncircles, nobstacles, nsegments, ngroups = 1, counter = 0;

View File

@ -69,6 +69,9 @@
#define D_WAVEGUIDES_W 521 /* two W-shaped wave guides */
#define D_WAVEGUIDES_COUPLED 522 /* two coupled wave guides */
#define D_WAVEGUIDE_S 523 /* S-shaped wave guide */
#define D_WAVEGUIDE_S_SHORT 524 /* short S-shaped wave guide */
#define D_WAVEGUIDES_COUPLED_N 525 /* two coupled wave guides, narrow variant */
#define D_WAVEGUIDE_BADSPLICE 526 /* badly spliced fibers, to use with IOR_WAVE_GUIDE_COATED */
#define D_MAZE 53 /* maze */
#define D_MAZE_CLOSED 54 /* closed maze */
#define D_MAZE_CHANNELS 541 /* maze with two channels attached */
@ -95,6 +98,9 @@
#define D_TESLA_FOUR 72 /* four Tesla valves */
#define D_TREE 73 /* Christmas tree, to use with IOR_TREE */
#define D_MICHELSON 74 /* Michelson interferometer, to use with IOR_MICHELSON */
#define D_MICHELSON_MOVING 741 /* moving Michelson interferometer, to use with IOR_MICHELSON */
#define D_RITCHEY_CHRETIEN 75 /* Ritchey-Chrétien telescope */
/* for wave_sphere.c */
@ -176,6 +182,9 @@
#define IOR_LENS_CONVEX_CONCAVE 13 /* lens with separating wall (to use with D_LENS_CONVEX_CONCAVE) */
#define IOR_TREE 14 /* Christmas tree, to use with D_TREE */
#define IOR_WAVE_GUIDES_COUPLED 15 /* coupled wave guides */
#define IOR_WAVE_GUIDES_COUPLED_B 151 /* coupled wave guides, variant where only corners are reflecting */
#define IOR_WAVE_GUIDE_COATED 16 /* short coated S-shaped optical fiber, to use with D_WAVEGUIDE_S_SHORT */
#define IOR_MICHELSON 17 /* Michelson interferometer, to use with D_MICHELSON */
#define IOR_EARTH_DEM 20 /* digital elevation model (for waves on sphere) */
@ -196,12 +205,17 @@
#define OSC_SLOWING 1 /* oscillation of slowing frequency (anti-chirp) */
#define OSC_WAVE_PACKET 2 /* Gaussian wave packet */
#define OSC_CHIRP 3 /* chirp (linearly accelerating frequency) */
#define OSC_BEAM 4 /* periodic oscillation modulated by y cut-off */
#define OSC_BEAM_GAUSSIAN 41 /* periodic oscillation modulated by Gaussian in y */
#define OSC_BEAM_SINE 42 /* periodic oscillation modulated by sine in y */
#define OSC_BEAM_TWOPERIODS 5 /* sum of two periodic oscillations modulated by y cut-off */
/* Wave packet types */
#define WP_RANDOM1 0 /* random, variant 1 */
#define WP_RANDOM2 1 /* random, variant 2 */
#define WP_PAIR 2 /* 2 sources */
#define WP_FIVE 3 /* 5 sources with different envelope */
/* Wave packet envelope types */
@ -224,6 +238,8 @@
#define P_LOG_MEAN_ENERGY 5 /* log of energy averaged over time */
#define P_ENERGY_FLUX 6 /* energy flux */
#define P_TOTAL_ENERGY_FLUX 7 /* energy flux averaged over time */
#define P_AVERAGE_ENERGY 8 /* energy averaged over sliding window */
#define P_LOG_AVERAGE_ENERGY 9 /* log of energy averaged over sliding window */
/* For Schrodinger equation */
#define P_MODULE 10 /* plot module of wave function squared */
@ -425,3 +441,5 @@ t_vertex polyline_b[NMAXPOLY]; /* vertices of polygonal line */
// double julia_x = -0.5, julia_y = 0.5; /* parameters for Julia sets */
// double julia_x = 0.33267, julia_y = 0.06395; /* parameters for Julia sets */
double julia_x = 0.37468, julia_y = 0.21115; /* parameters for Julia sets */
double wave_source_x, wave_source_y; /* position of wave source */
double michelson_position = 0.0; /* position of mirror in Michelson interferometer */

9
heat.c
View File

@ -218,6 +218,15 @@
#define GAMMAB 0.0 /* damping factor in wave equation */
#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 INITIAL_TIME 50 /* time after which to start saving frames */
#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 */
#define MESSAGE_LINTERVAL 54 /* length of interval between dashes/dots for Morse code message */
#define MESSAGE_LINTERLETTER 60 /* length of interval between letters for Morse code message */
#define MESSAGE_LSPACE 48 /* length of space for Morse code message */
#define MESSAGE_INITIAL_TIME 100 /* initial time before starting message for Morse code message */
/* end of constants only used by sub_wave and sub_maze */
#include "global_pdes.c"

View File

@ -36,8 +36,8 @@
#include <omp.h>
#include <time.h>
#define MOVIE 0 /* set to 1 to generate movie */
#define DOUBLE_MOVIE 1 /* set to 1 to produce movies for wave height and energy simultaneously */
#define 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 while saving frames */
#define NO_EXTRA_BUFFER_SWAP 1 /* some OS require one less buffer swap when recording images */
@ -50,23 +50,32 @@
/* General geometrical parameters */
#define WINWIDTH 1600 /* window width */
#define WINHEIGHT 900 /* window height */
// #define WINWIDTH 1440 /* window width */
// #define WINHEIGHT 810 /* window height */
#define WINWIDTH 1760 /* window width */
#define WINHEIGHT 990 /* window height */
#define XMIN -2.0
#define XMAX 2.0 /* x interval */
#define YMIN -1.125
#define YMAX 1.125 /* y interval for 9/16 aspect ratio */
#define INITXMIN -2.0
#define INITXMAX 2.0 /* x interval for initial condition */
#define INITYMIN -1.125
#define INITYMAX 1.125 /* y interval for initial condition */
#define INITXMIN -1.9
#define INITXMAX 2.1 /* x interval for initial condition */
#define INITYMIN -1.0
#define INITYMAX 1.0 /* y interval for initial condition */
#define ADDXMIN 1.9
#define ADDXMAX 2.0 /* x interval for adding particles */
#define ADDYMIN -0.9
#define ADDYMAX 0.9 /* y interval for adding particles */
#define THERMOXMIN -1.25
#define THERMOXMAX 1.25 /* x interval for initial condition */
#define THERMOYMIN 0.0
#define THERMOYMAX 0.75 /* y interval for initial condition */
#define ADDXMIN -1.95
#define ADDXMAX 1.95 /* x interval for adding particles */
#define ADDYMIN 1.4
#define ADDYMAX 3.7 /* y interval for adding particles */
#define ADDRMIN 4.75
#define ADDRMAX 6.0 /* r interval for adding particles */
#define BCXMIN -2.0
#define BCXMAX 2.0 /* x interval for boundary condition */
@ -85,34 +94,37 @@
#define OBSTACLE_PATTERN 6 /* pattern of obstacles, see list in global_ljones.c */
#define ADD_FIXED_SEGMENTS 0 /* set to 1 to add fixed segments as obstacles */
#define SEGMENT_PATTERN 27 /* pattern of repelling segments, see list in global_ljones.c */
#define SEGMENT_PATTERN 29 /* pattern of repelling segments, see list in global_ljones.c */
#define ROCKET_SHAPE 3 /* shape of rocket combustion chamber, see list in global_ljones.c */
#define ROCKET_SHAPE_B 3 /* shape of second rocket */
#define NOZZLE_SHAPE 6 /* shape of nozzle, see list in global_ljones.c */
#define NOZZLE_SHAPE_B 6 /* shape of nozzle for second rocket, see list in global_ljones.c */
#define TWO_TYPES 1 /* set to 1 to have two types of particles */
#define TYPE_PROPORTION 1.0 /* proportion of particles of first type */
#define TYPE_PROPORTION 0.5 /* proportion of particles of first type */
#define TWOTYPE_CONFIG 0 /* choice of types, see TTC_ list in global_ljones.c */
#define SYMMETRIZE_FORCE 1 /* set to 1 to symmetrize two-particle interaction, only needed if particles are not all the same */
#define CENTER_PX 0 /* set to 1 to center horizontal momentum */
#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_B 1 /* particle interaction for second type of particle, see list in global_ljones.c */
#define INTERACTION 12 /* particle interaction, see list in global_ljones.c */
#define INTERACTION_B 12 /* particle interaction for second type of particle, see list in global_ljones.c */
#define SPIN_INTER_FREQUENCY 4.0 /* angular frequency of spin-spin interaction */
#define SPIN_INTER_FREQUENCY_B 4.0 /* angular frequency of spin-spin interaction for second particle type */
#define MOL_ANGLE_FACTOR 4.0 /* rotation angle for P_MOL_ANGLE color scheme */
#define 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 2.8 /* minimal distance in Poisson disc process, controls density of particles */
#define PDISC_DISTANCE 9.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.01 /* parameter controlling radius of particles */
#define MU_B 0.012 /* parameter controlling radius of particles of second type */
#define LAMBDA 0.75 /* parameter controlling the dimensions of domain */
#define MU 0.009 /* parameter controlling radius of particles */
#define MU_B 0.009 /* parameter controlling radius of particles of second type */
#define NPOLY 40 /* number of sides of polygon */
#define APOLY 0.0 /* angle by which to turn polygon, in units of Pi/2 */
#define AWEDGE 0.5 /* opening angle of wedge, in units of Pi/2 */
@ -121,14 +133,14 @@
#define MANDELLEVEL 1000 /* iteration level for Mandelbrot set */
#define MANDELLIMIT 10.0 /* limit value for approximation of Mandelbrot set */
#define FOCI 1 /* set to 1 to draw focal points of ellipse */
#define NGRIDX 60 /* number of grid point for grid of disks */
#define NGRIDY 30 /* number of grid point for grid of disks */
#define NGRIDX 20 /* number of grid point for grid of disks */
#define NGRIDY 10 /* number of grid point for grid of disks */
#define EHRENFEST_RADIUS 0.9 /* radius of container for Ehrenfest urn configuration */
#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 30
#define NOBSY 20 /* obstacles for O_HEX obstacle pattern */
#define NOBSX 10
#define NOBSY 5 /* obstacles for O_HEX obstacle pattern */
#define NTREES 15 /* number of trees in S_TREES */
#define X_SHOOTER -0.2
@ -138,11 +150,12 @@
/* Parameters for length and speed of simulation */
#define NSTEPS 2400 /* number of frames of movie */
#define NVID 30 /* number of iterations between images displayed on screen */
#define NSEG 25 /* number of segments of boundary of circles */
#define NSTEPS 1600 /* number of frames of movie */
// #define NSTEPS 7275 /* number of frames of movie */
#define NVID 65 /* 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 OBSTACLE_INITIAL_TIME 150 /* time after which to start moving obstacle */
#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 */
#define CONTAINER_WIDTH 2 /* width of container boundary */
@ -152,7 +165,8 @@
#define SLEEP1 1 /* initial sleeping time */
#define SLEEP2 1 /* final sleeping time */
#define MID_FRAMES 20 /* number of still frames between parts of two-part movie */
#define END_FRAMES 250 /* number of still frames at end of movie */
// #define END_FRAMES 250 /* number of still frames at end of movie */
#define END_FRAMES 100 /* number of still frames at end of movie */
/* Boundary conditions, see list in global_ljones.c */
@ -160,14 +174,15 @@
/* Plot type, see list in global_ljones.c */
#define PLOT 5
#define PLOT_B 13 /* plot type for second movie */
#define PLOT 19
// #define PLOT_B 1 /* plot type for second movie */
#define PLOT_B 18 /* plot type for second movie */
/* Background color depending on particle properties */
#define COLOR_BACKGROUND 1 /* set to 1 to color background */
#define BG_COLOR 2 /* type of background coloring, see list in global_ljones.c */
#define BG_COLOR_B 0 /* type of background coloring, see list in global_ljones.c */
#define COLOR_BACKGROUND 0 /* set to 1 to color background */
#define BG_COLOR 0 /* 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 DRAW_BONDS 1 /* set to 1 to draw bonds between neighbours */
#define COLOR_BONDS 1 /* set to 1 to color bonds according to length */
@ -175,19 +190,21 @@
#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 */
#define N_PARTICLE_COLORS 200 /* number of colors for P_NUMBER color scheme */
#define INITIAL_POS_TYPE 0 /* type of initial position dependence */
#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.995 /* ratio for time-averaging in P_DIRECT_EMEAN color scheme */
/* Color schemes */
#define COLOR_PALETTE 10 /* Color palette, see list in global_ljones.c */
#define COLOR_PALETTE_EKIN 10 /* Color palette for kinetic energy */
#define COLOR_PALETTE_ANGLE 10 /* Color palette for angle representation */
#define COLOR_PALETTE_DIRECTION 17 /* Color palette for direction representation */
#define COLOR_PALETTE_INITIAL_POS 0 /* Color palette for initial position representation */
#define COLOR_PALETTE 10 /* Color palette, see list in global_ljones.c */
#define COLOR_PALETTE_EKIN 10 /* Color palette for kinetic energy */
#define COLOR_PALETTE_ANGLE 0 /* Color palette for angle representation */
#define COLOR_PALETTE_DIRECTION 0 /* Color palette for direction representation */
#define COLOR_PALETTE_INITIAL_POS 10 /* Color palette for initial position representation */
#define COLOR_PALETTE_DIFFNEIGH 10 /* Color palette for different neighbours representation */
#define COLOR_PALETTE_PRESSURE 11 /* Color palette for different neighbours representation */
#define COLOR_PALETTE_PRESSURE 11 /* Color palette for different neighbours representation */
#define COLOR_PALETTE_CHARGE 18 /* Color palette for charge representation */
#define COLOR_PALETTE_CLUSTER 0 /* Color palette for cluster representation */
#define BLACK 1 /* background */
@ -222,27 +239,29 @@
#define ENERGY_HUE_MAX 50.0 /* color of saturated particle */
#define PARTICLE_HUE_MIN 359.0 /* color of original particle */
#define PARTICLE_HUE_MAX 0.0 /* color of saturated particle */
#define PARTICLE_EMAX 10000.0 /* energy of particle with hottest color */
#define HUE_TYPE0 60.0 /* hue of particles of type 0 */
// #define PARTICLE_EMAX 50000.0 /* energy of particle with hottest color */
#define PARTICLE_EMIN 10.0 /* energy of particle with coolest color */
#define PARTICLE_EMAX 50000.0 /* energy of particle with hottest color */
#define HUE_TYPE0 280.0 /* hue of particles of type 0 */
#define HUE_TYPE1 280.0 /* hue of particles of type 1 */
#define HUE_TYPE2 140.0 /* hue of particles of type 2 */
#define HUE_TYPE3 200.0 /* hue of particles of type 3 */
#define HUE_TYPE2 70.0 /* hue of particles of type 2 */
#define HUE_TYPE3 60.0 /* hue of particles of type 3 */
#define BG_FORCE_SLOPE 7.5e-8 /* contant in BG_FORCE backgound color scheme*/
#define RANDOM_RADIUS 0 /* set to 1 for random circle radius */
#define DT_PARTICLE 3.0e-6 /* time step for particle displacement */
#define KREPEL 50.0 /* constant in repelling force between particles */
#define KREPEL 150.0 /* constant in repelling force between particles */
#define EQUILIBRIUM_DIST 5.0 /* Lennard-Jones equilibrium distance */
#define EQUILIBRIUM_DIST_B 5.0 /* Lennard-Jones equilibrium distance for second type of particle */
#define REPEL_RADIUS 20.0 /* radius in which repelling force acts (in units of particle radius) */
#define DAMPING 3000.0 /* damping coefficient of particles */
#define REPEL_RADIUS 25.0 /* radius in which repelling force acts (in units of particle radius) */
#define DAMPING 20.0 /* damping coefficient of particles */
#define INITIAL_DAMPING 5000.0 /* damping coefficient of particles during initial phase */
#define DAMPING_ROT 100.0 /* dampint coefficient for rotation of particles */
#define PARTICLE_MASS 2.0 /* mass of particle of radius MU */
#define PARTICLE_MASS_B 1.0 /* mass of particle of radius MU */
#define PARTICLE_MASS 1.0 /* mass of particle of radius MU */
#define PARTICLE_MASS_B 2.0 /* mass of particle of radius MU_B */
#define PARTICLE_INERTIA_MOMENT 0.2 /* moment of inertia of particle */
#define PARTICLE_INERTIA_MOMENT_B 0.02 /* moment of inertia of second type of particle */
#define V_INITIAL -50.0 /* initial velocity range */
#define V_INITIAL 50.0 /* initial velocity range */
#define OMEGA_INITIAL 10.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 */
@ -252,32 +271,33 @@
#define THERMOSTAT 1 /* set to 1 to switch on thermostat */
#define VARY_THERMOSTAT 0 /* set to 1 for time-dependent thermostat schedule */
#define SIGMA 5.0 /* noise intensity in thermostat */
#define BETA 0.00004 /* initial inverse temperature */
#define MU_XI 0.01 /* friction constant in thermostat */
#define BETA 0.0005 /* initial inverse temperature */
#define MU_XI 0.005 /* friction constant in thermostat */
#define KSPRING_BOUNDARY 2.0e11 /* confining harmonic potential outside simulation region */
#define KSPRING_OBSTACLE 2.0e11 /* harmonic potential of obstacles */
#define NBH_DIST_FACTOR 3.2 /* radius in which to count neighbours */
#define NBH_DIST_FACTOR 5.0 /* radius in which to count neighbours */
#define GRAVITY 0.0 /* gravity acting on all particles */
#define GRAVITY_X 0.0 /* horizontal gravity acting on all particles */
#define CIRCULAR_GRAVITY 0 /* set to 1 to have gravity directed to center */
#define INCREASE_GRAVITY 0 /* set to 1 to increase gravity during the simulation */
#define GRAVITY_SCHEDULE 2 /* type of gravity schedule, see list in global_ljones.c */
#define GRAVITY_FACTOR 100.0 /* factor by which to increase gravity */
#define GRAVITY_SCHEDULE 1 /* type of gravity schedule, see list in global_ljones.c */
#define GRAVITY_FACTOR 10.0 /* factor by which to increase gravity */
#define GRAVITY_INITIAL_TIME 200 /* time at start of simulation with constant gravity */
#define GRAVITY_RESTORE_TIME 700 /* time at end of simulation with gravity restored to initial value */
#define GRAVITY_RESTORE_TIME 500 /* time at end of simulation with gravity restored to initial value */
#define KSPRING_VICSEK 0.2 /* spring constant for I_VICSEK_SPEED interaction */
#define VICSEK_REPULSION 10.0 /* repulsion between particles in Vicsek model */
#define ADD_EFIELD 0 /* set to 1 to add an electric field */
#define EFIELD 200000.0 /* value of electric field */
#define EFIELD 50000.0 /* value of electric field */
#define ADD_BFIELD 0 /* set to 1 to add a magnetic field */
#define BFIELD 10000.0 /* value of magnetic field */
#define CHARGE 1.5 /* charge of particles of first type */
#define CHARGE_B -1.0 /* charge of particles of second type */
#define BFIELD 2.666666667 /* value of magnetic field */
#define CHARGE -0.0 /* charge of particles of first type */
#define CHARGE_B 0.0 /* charge of particles of second type */
#define INCREASE_E 0 /* set to 1 to increase electric field */
#define EFIELD_FACTOR 1000000.0 /* factor by which to increase electric field */
// #define EFIELD_FACTOR 2500000.0 /* factor by which 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 */
#define BFIELD_FACTOR 10000.0 /* factor by which to increase magnetic field */
#define BFIELD_FACTOR 20000.0 /* factor by which to increase magnetic field */
#define CHARGE_OBSTACLES 1 /* set to 1 for obstacles to be charged */
#define OBSTACLE_CHARGE 3.0 /* charge of obstacles */
#define KCOULOMB_OBSTACLE 1000.0 /* Coulomb force constant for charged obstacles */
@ -292,23 +312,27 @@
#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 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 5.0 /* range of spin-spin interaction for second type of particle */
#define QUADRUPOLE_RATIO 0.6 /* anisotropy in quadrupole potential */
#define INCREASE_BETA 1 /* set to 1 to increase BETA during simulation */
#define BETA_FACTOR 5.0 /* factor by which to change BETA during simulation */
#define N_TOSCILLATIONS 2.5 /* number of temperature oscillations in BETA schedule */
#define INCREASE_BETA 0 /* set to 1 to increase BETA during simulation */
#define BETA_SCHEDULE 0 /* type of temperature schedule, see TS_* in global_ljones */
// #define BETA_FACTOR 0.000001 /* factor by which to change BETA during simulation */
#define BETA_FACTOR 1000.0 /* factor by which to change BETA during simulation */
#define N_TOSCILLATIONS 1.0 /* number of temperature oscillations in BETA schedule */
#define NO_OSCILLATION 0 /* set to 1 to have exponential BETA change only */
#define MIDDLE_CONSTANT_PHASE 0 /* final phase in which temperature is constant */
#define FINAL_DECREASE_PHASE 0 /* final phase in which temperature decreases */
#define FINAL_CONSTANT_PHASE -1 /* final phase in which temperature is constant */
#define DECREASE_CONTAINER_SIZE 0 /* set to 1 to decrease size of container */
#define SMOOTH_CONTAINER_DECREASE 1 /* set to 1 to decrease size smoothly at each simulation step */
#define SYMMETRIC_DECREASE 0 /* set tp 1 to decrease container symmetrically */
#define COMPRESSION_RATIO 0.3 /* final size of container */
#define COMPRESSION_RATIO 0.25 /* final size of container */
#define RESTORE_CONTAINER_SIZE 1 /* set to 1 to restore container to initial size at end of simulation */
#define RESTORE_TIME 1200 /* time before end of sim at which to restore size */
#define RESTORE_TIME 800 /* time before end of sim at which to restore size */
#define MOVE_OBSTACLE 0 /* set to 1 to have a moving obstacle */
#define CENTER_VIEW_ON_OBSTACLE 0 /* set to 1 to center display on moving obstacle */
@ -324,10 +348,12 @@
#define N_T_AVERAGE 1 /* size of temperature averaging window */
#define MAX_PRESSURE 3.0e10 /* pressure shown in "hottest" color */
#define PARTIAL_THERMO_COUPLING 0 /* set to 1 to couple only some particles to thermostat */
#define PARTIAL_THERMO_REGION 1 /* region for partial thermostat coupling (see list in global_ljones.c) */
#define PARTIAL_THERMO_REGION 9 /* region for partial thermostat coupling (see list in global_ljones.c) */
#define PARTIAL_THERMO_SHIFT 0.2 /* distance from obstacle at the right of which particles are coupled to thermostat */
#define PARTIAL_THERMO_WIDTH 0.5 /* vertical size of partial thermostat coupling */
#define PARTIAL_THERMO_HEIGHT 0.25 /* vertical size of partial thermostat coupling */
#define PARTIAL_THERMO_WIDTH 1.0 /* vertical size of partial thermostat coupling */
#define PARTIAL_THERMO_HEIGHT 0.0 /* vertical size of partial thermostat coupling */
#define PARTIAL_THERMO_RIN 0.5 /* initial radius of region without coupling */
#define PARTIAL_THERMO_RFIN 1.3 /* final radius of region without coupling */
#define INCREASE_KREPEL 0 /* set to 1 to increase KREPEL during simulation */
#define KREPEL_FACTOR 1000.0 /* factor by which to change KREPEL during simulation */
@ -337,11 +363,12 @@
#define NPART_BOTTOM 100 /* number of particles at the bottom */
#define ADD_PARTICLES 0 /* 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 4 /* time interval between adding further particles */
#define N_ADD_PARTICLES 3 /* number of particles to add */
#define ADD_PERIOD 5 /* time interval between adding further particles */
#define N_ADD_PARTICLES 5 /* number of particles to add */
#define FINAL_NOADD_PERIOD 0 /* final period where no particles are added */
#define SAFETY_FACTOR 2.0 /* no particles are added at distance less than MU*SAFETY_FACTOR of other particles */
#define SAFETY_FACTOR 4.0 /* no particles are added at distance less than MU*SAFETY_FACTOR of other particles */
#define TRACER_PARTICLE 0 /* set to 1 to have a tracer particle */
#define N_TRACER_PARTICLES 3 /* number of tracer particles */
@ -368,7 +395,7 @@
#define SEGMENTS_VX0 0.0 /* initial velocity of segments */
#define SEGMENTS_VY0 0.0 /* initial velocity of segments */
#define DAMP_SEGS_AT_NEGATIVE_Y 0 /* set to 1 to dampen segments when y coordinate is negative */
#define SHOW_SEGMENTS_PRESSURE 1 /* set to 1 to show (averaged) pressure acting on segments */
#define SHOW_SEGMENTS_PRESSURE 0 /* set to 1 to show (averaged) pressure acting on segments */
#define SEGMENT_PMAX 7.5e7 /* pressure of segment with hottest color */
#define P_AVRG_FACTOR 0.02 /* factor in computation of mean pressure */
@ -390,24 +417,27 @@
#define POSITION_DEP_X -0.625 /* threshold value for position-dependent type */
#define PRINT_ENTROPY 0 /* set to 1 to compute entropy */
#define REACTION_DIFFUSION 0 /* set to 1 to simulate a chemical reaction (particles may change type) */
#define RD_REACTION 16 /* type of reaction, see list in global_ljones.c */
#define RD_TYPES 5 /* number of types in reaction-diffusion equation */
#define RD_INITIAL_COND 9 /* initial condition of particles */
#define REACTION_DIST 4.0 /* maximal distance for reaction to occur */
#define REACTION_PROB 1.0 /* probability controlling reaction term */
#define DISSOCIATION_PROB 0.002 /* probability controlling dissociation reaction */
#define REACTION_DIFFUSION 1 /* set to 1 to simulate a chemical reaction (particles may change type) */
#define RD_REACTION 23 /* type of reaction, see list in global_ljones.c */
#define RD_TYPES 2 /* number of types in reaction-diffusion equation */
#define RD_INITIAL_COND 99 /* initial condition of particles */
#define REACTION_DIST 3.5 /* maximal distance for reaction to occur */
#define REACTION_PROB 1.0 /* probability controlling reaction term */
#define DISSOCIATION_PROB 0.0001 /* probability controlling dissociation reaction */
#define CENTER_COLLIDED_PARTICLES 0 /* set to 1 to recenter particles upon reaction (may interfere with thermostat) */
#define EXOTHERMIC 1 /* set to 1 to make reaction exo/endothermic */
#define DELTA_EKIN 2000.0 /* change of kinetic energy in reaction */
#define COLLISION_TIME 15 /* time during which collisions are shown */
#define EXOTHERMIC 0 /* set to 1 to make reaction exo/endothermic */
#define DELTA_EKIN 2000.0 /* change of kinetic energy in reaction */
#define COLLISION_TIME 25 /* time during which collisions are shown */
#define DELTAVMAX 150.0 /* maximal deltav allowed for pairing molecules */
#define AGREGMAX 6 /* maximal number of partners for CHEM_AGGREGATION reaction */
#define AGREG_DECOUPLE 10 /* minimal number of partners to decouple from thermostat */
#define CHANGE_RADIUS 0 /* set to 1 to change particle radius during simulation */
#define MU_RATIO 0.666666667 /* ratio by which to increase radius */
#define PRINT_PARTICLE_NUMBER 0 /* set to 1 to print total number of particles */
#define PLOT_PARTICLE_NUMBER 0 /* set to 1 to make of plot of particle number over time */
#define PARTICLE_NB_PLOT_FACTOR 0.5 /* expected final number of particles over initial number */
#define PARTICLE_NB_PLOT_FACTOR 1.0 /* expected final number of particles over initial number */
#define PRINT_LEFT 0 /* set to 1 to print certain parameters at the top left instead of right */
#define PLOT_SPEEDS 0 /* set to 1 to add a plot of obstacle speeds (e.g. for rockets) */
#define PLOT_TRAJECTORIES 0 /* set to 1 to add a plot of obstacle trajectories (e.g. for rockets) */
@ -419,7 +449,7 @@
#define LID_WIDTH 0.1 /* width of lid for BC_RECTANGLE_LID b.c. */
#define WALL_MASS 2000.0 /* mass of wall for BC_RECTANGLE_WALL b.c. */
#define WALL_FRICTION 0.0 /* friction on wall for BC_RECTANGLE_WALL b.c. */
#define WALL_WIDTH 0.1 /* width of wall for BC_RECTANGLE_WALL b.c. */
#define WALL_WIDTH 0.025 /* width of wall for BC_RECTANGLE_WALL b.c. */
#define WALL_VMAX 100.0 /* max speed of wall */
#define WALL_TIME 0 /* time during which to keep wall */
@ -428,10 +458,29 @@
#define PROP_MAX 0.9 /* max proportion of type 1 particles */
#define PAIR_PARTICLES 1 /* set to 1 to form particles pairs */
#define KSPRING_PAIRS 1.0e10 /* spring constant for pair interaction */
#define NPARTNERS 2 /* number of partners of particles */
#define PAIRING_TYPE 1 /* type of pairing, see POLY_ in global_ljones.c */
#define PARTNER_ANGLE 104.45 /* angle (in degrees) between anions for POLY_WATER case */
#define RANDOMIZE_ANGLE 1 /* set to 1 for random orientation */
#define DEACIVATE_CLOSE_PAIRS 0 /* set to 1 to test for closeness to other particles */
#define PAIR_SAFETY_FACTOR 1.2 /* distance to deactivate divided by sum of radii */
#define KSPRING_PAIRS 2.0e10 /* spring constant for pair interaction */
#define NPARTNERS 16 /* number of partners of particles */
#define NARMS 4 /* number of "arms" for certain paring types */
#define PAIRING_TYPE 61 /* type of pairing, see POLY_ in global_ljones.c */
#define PARTNER_ANGLE 104.45 /* angle (in degrees) between ions for POLY_WATER case */
#define PAIR_DRATIO 1.0 /* ratio between equilibrium distance and radius (default: 1.0) */
#define MU_C 0.014 /* radius of partner particle */
#define PARTICLE_MASS_C 2.0 /* mass or partner particle */
#define CHARGE_C 1.5 /* charge of partner particle */
#define CLUSTER_COLOR_FACTOR 400 /* factor for initialization of cluster colors */
#define ALTERNATE_POLY_CHARGE 1 /* set to 1 for alternating charges in molecule */
#define PAIR_TYPEB_PARTICLES 1 /* set to 1 to pair particle of type 1 */
#define NPARTNERS_B 16 /* number of partners of particles */
#define NARMS_B 4 /* number of "arms" for certain paring types */
#define PAIRING_TYPE_B 61 /* type of pairing, see POLY_ in global_ljones.c */
#define MU_D 0.014 /* radius of partner particle */
#define PARTICLE_MASS_D 2.0 /* mass or partner particle */
#define CHARGE_D -1.5 /* charge of partner particle */
// #define PARTNER_ANGLE_B 104.45 /* angle (in degrees) between anions for POLY_WATER case */
#define NXMAZE 12 /* width of maze */
#define NYMAZE 12 /* height of maze */
@ -445,8 +494,8 @@
#define FLOOR_OMEGA 0 /* set to 1 to limit particle momentum to PMAX */
#define PMAX 1000.0 /* maximal force */
#define HASHX 100 /* size of hashgrid in x direction */
#define HASHY 50 /* size of hashgrid in y direction */
#define HASHX 60 /* size of hashgrid in x direction */
#define HASHY 30 /* 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 */
@ -460,8 +509,10 @@
#define NO_WRAP_BC ((BOUNDARY_COND != BC_PERIODIC)&&(BOUNDARY_COND != BC_PERIODIC_CIRCLE)&&(BOUNDARY_COND != BC_PERIODIC_TRIANGLE)&&(BOUNDARY_COND != BC_KLEIN)&&(BOUNDARY_COND != BC_PERIODIC_FUNNEL)&&(BOUNDARY_COND != BC_BOY)&&(BOUNDARY_COND != BC_GENUS_TWO))
#define PERIODIC_BC ((BOUNDARY_COND == BC_PERIODIC)||(BOUNDARY_COND == BC_PERIODIC_CIRCLE)||(BOUNDARY_COND == BC_PERIODIC_FUNNEL)||(BOUNDARY_COND == BC_PERIODIC_TRIANGLE))
#define TWO_OBSTACLES ((SEGMENT_PATTERN == S_TWO_CIRCLES_EXT)||(SEGMENT_PATTERN == S_TWO_ROCKETS))
#define COMPUTE_EMEAN ((PLOT == P_EMEAN)||(PLOT_B == P_EMEAN)||(PLOT == P_DIRECT_EMEAN)||(PLOT_B == P_DIRECT_EMEAN))
#define COMPUTE_EMEAN ((PLOT == P_EMEAN)||(PLOT_B == P_EMEAN)||(PLOT == P_LOG_EMEAN)||(PLOT_B == P_LOG_EMEAN)||(PLOT == P_DIRECT_EMEAN)||(PLOT_B == P_DIRECT_EMEAN))
#define COMPUTE_DIRMEAN ((PLOT == P_DIRECT_EMEAN)||(PLOT_B == P_DIRECT_EMEAN))
#define COUNT_PARTNER_TYPE ((RD_REACTION == CHEM_H2O_H_OH)||(RD_REACTION == CHEM_2H2O_H3O_OH))
#define PAIR_FORCE ((PAIR_PARTICLES)||((REACTION_DIFFUSION)&&(RD_REACTION == CHEM_AGGREGATION)))
double xshift = 0.0; /* x shift of shown window */
double xspeed = 0.0; /* x speed of obstacle */
@ -519,10 +570,11 @@ double efield_schedule(int i)
if (first)
{
efactor = EFIELD_FACTOR/(double)(INITIAL_TIME + NSTEPS);
efactor = EFIELD_FACTOR/(double)(NSTEPS);
first = 0;
}
efield = EFIELD*(double)i*efactor;
if (i < INITIAL_TIME) efield = EFIELD;
else efield = EFIELD*(double)(i-INITIAL_TIME)*efactor;
printf("E = %.3lg\n", efield);
return(efield);
}
@ -536,10 +588,11 @@ double bfield_schedule(int i)
if (first)
{
bfactor = BFIELD_FACTOR/(double)(INITIAL_TIME + NSTEPS);
bfactor = BFIELD_FACTOR/(double)(NSTEPS);
first = 0;
}
bfield = BFIELD*(double)i*bfactor;
if (i < INITIAL_TIME) bfield = BFIELD;
else bfield = BFIELD*(double)(i-INITIAL_TIME)*bfactor;
printf("B = %.3lg\n", bfield);
return(bfield);
}
@ -547,9 +600,9 @@ double bfield_schedule(int i)
double temperature_schedule(int i)
{
static double bexponent, omega, bexp2;
static double bexponent, omega, bexp2, factor2, logf, ac, bc;
static int first = 1, t1, t2, t3;
double beta;
double beta, t;
if (first)
{
@ -558,16 +611,103 @@ double temperature_schedule(int i)
t3 = NSTEPS - FINAL_CONSTANT_PHASE;
bexponent = log(BETA_FACTOR)/(double)(t1);
omega = N_TOSCILLATIONS*DPI/(double)(t1);
bexp2 = -log(BETA_FACTOR)/(double)(FINAL_DECREASE_PHASE);
logf = log(BETA_FACTOR);
switch (BETA_SCHEDULE)
{
case (TS_EXPONENTIAL):
{
factor2 = BETA_FACTOR;
break;
}
case (TS_CYCLING):
{
factor2 = BETA_FACTOR*2.0/(1.0 + cos(N_TOSCILLATIONS*DPI));
break;
}
case (TS_PERIODIC):
{
factor2 = exp(logf*sin(N_TOSCILLATIONS*DPI));
break;
}
case (TS_LINEAR):
{
factor2 = BETA_FACTOR;
break;
}
case (TS_COSINE):
{
factor2 = BETA_FACTOR;
ac = 2.0*BETA*BETA_FACTOR/(1.0 + BETA_FACTOR);
bc = (BETA_FACTOR - 1.0)/(1.0 + BETA_FACTOR);
break;
}
case (TS_EXPCOS):
{
factor2 = BETA_FACTOR;
bc = -0.5*log(BETA_FACTOR);
break;
}
case (TS_ASYM_EXPCOS):
{
factor2 = BETA_FACTOR;
bc = -0.5*log(BETA_FACTOR);
break;
}
}
bexp2 = -log(factor2)/(double)(FINAL_DECREASE_PHASE);
first = 0;
// printf("t1 = %i, factor2 = %.3lg\n", t1, factor2);
}
if (i < INITIAL_TIME) beta = BETA;
else if (i < INITIAL_TIME + t1)
{
beta = BETA*exp(bexponent*(double)(i - INITIAL_TIME));
if (!NO_OSCILLATION) beta = beta*2.0/(1.0 + cos(omega*(double)(i - INITIAL_TIME)));
switch (BETA_SCHEDULE)
{
case (TS_EXPONENTIAL):
{
beta = BETA*exp(bexponent*(double)(i - INITIAL_TIME));
break;
}
case (TS_CYCLING):
{
beta = BETA*exp(bexponent*(double)(i - INITIAL_TIME));
beta = beta*2.0/(1.0 + cos(omega*(double)(i - INITIAL_TIME)));
break;
}
case (TS_PERIODIC):
{
beta = BETA*exp(logf*sin(omega*(double)(i - INITIAL_TIME)));
break;
}
case (TS_LINEAR):
{
beta = BETA/(1.0 + (1.0/BETA_FACTOR - 1.0)*(double)(i - INITIAL_TIME)/(double)(t1));
// printf("i = %i, beta = %.3lg\n", i, beta);
break;
}
case (TS_COSINE):
{
beta = ac/(1.0 + bc*cos(omega*(double)(i - INITIAL_TIME)));
printf("i = %i, beta = %.3lg\n", i, beta);
break;
}
case (TS_EXPCOS):
{
beta = BETA*exp(bc*(-1.0 + cos(omega*(double)(i - INITIAL_TIME))));
// printf("i = %i, beta = %.3lg\n", i, beta);
break;
}
case (TS_ASYM_EXPCOS):
{
t = (double)(i - INITIAL_TIME)/(double)(t1);
beta = BETA*exp(bc*(-1.0 + cos(N_TOSCILLATIONS*DPI*(t - 0.5*t*(1.0-t)))));
break;
}
}
}
else if (i < INITIAL_TIME + t2) beta = BETA*BETA_FACTOR;
else if (i < INITIAL_TIME + t2) beta = BETA*factor2;
else if (i < INITIAL_TIME + t3)
{
beta = BETA*exp(bexp2*(double)(i - INITIAL_TIME - t3));
@ -584,6 +724,18 @@ double container_size_schedule(int i)
return(INITXMIN + (1.0-COMPRESSION_RATIO)*(INITXMAX-INITXMIN)*(double)(i-INITIAL_TIME)/(double)(NSTEPS-RESTORE_TIME));
}
double container_size_schedule_smooth(int i, int j)
{
double t;
if ((i < INITIAL_TIME)||(i > INITIAL_TIME + NSTEPS - RESTORE_TIME)) return(INITXMIN);
else
{
t = (double)(i-INITIAL_TIME) + (double)j/(double)NVID;
return(INITXMIN + (1.0-COMPRESSION_RATIO)*(INITXMAX-INITXMIN)*t/(double)(NSTEPS-RESTORE_TIME));
}
}
double obstacle_schedule_old(int i)
{
double time;
@ -1213,7 +1365,7 @@ void evolve_segment_groups(t_segment segment[NMAXSEGMENTS], int time, t_group_se
void animation()
{
double time, scale, diss, rgb[3], dissip, gradient[2], x, y, dx, dy, dt, xleft, xright,
a, b, length, fx, fy, force[2], totalenergy = 0.0, pos[2], prop, vx, xi = 0.0, torque, torque_ij, pleft = 0.0, pright = 0.0, entropy[2], speed_ratio, ymin, ymax, delta_energy, speed, ratio = 1.0, ratioc, cum_etot = 0.0, emean = 0.0, radius_ratio, t;
a, b, length, fx, fy, force[2], totalenergy = 0.0, pos[2], prop, vx, xi = 0.0, torque, torque_ij, pleft = 0.0, pright = 0.0, entropy[2], speed_ratio, xmin, xmax, ymin, ymax, delta_energy, speed, ratio = 1.0, ratioc, cum_etot = 0.0, emean = 0.0, radius_ratio, t;
double *qx, *qy, *px, *py, *qangle, *pangle, *pressure, *obstacle_speeds;
int i, j, k, n, m, s, ij[2], i0, iplus, iminus, j0, jplus, jminus, p, q, p1, q1, p2, q2, total_neighbours = 0,
min_nb, max_nb, close, wrapx = 0, wrapy = 0, nadd_particle = 0, nmove = 0, nsuccess = 0,
@ -1340,6 +1492,8 @@ void animation()
if (INCREASE_BETA) params.beta = temperature_schedule(i);
if (INCREASE_E) params.efield = efield_schedule(i);
if (INCREASE_B) params.bfield = bfield_schedule(i);
if ((PARTIAL_THERMO_COUPLING)&&(PARTIAL_THERMO_REGION == TH_RING_EXPAND))
params.thermo_radius = PARTIAL_THERMO_RIN + (double)i/(double)NSTEPS*(PARTIAL_THERMO_RFIN - PARTIAL_THERMO_RIN);
if (DECREASE_CONTAINER_SIZE)
{
params.xmincontainer = container_size_schedule(i);
@ -1361,15 +1515,31 @@ void animation()
if ((i <= INITIAL_TIME-1)&&(i%10 == 0)&&((PLOT == P_INITIAL_POS)||(PLOT_B == P_INITIAL_POS)))
{
printf("Recoloring particles\n");
xmin = particle[0].xc;
xmax = particle[0].xc;
ymin = particle[0].yc;
ymax = particle[0].yc;
for (j=1; j<ncircles; j++) if (particle[j].active)
{
if (particle[j].xc < xmin) xmin = particle[j].xc;
if (particle[j].xc > xmax) xmax = particle[j].xc;
if (particle[j].yc < ymin) ymin = particle[j].yc;
if (particle[j].yc > ymax) ymax = particle[j].yc;
}
for (j=0; j<ncircles; j++) if (particle[j].active)
particle[j].color_hue = 360.0*(particle[j].yc - ymin)/(ymax - ymin);
switch (INITIAL_POS_TYPE) {
case (IP_X):
{
particle[j].color_hue = 360.0*(particle[j].xc - xmin)/(xmax - xmin);
break;
}
case (IP_Y):
{
particle[j].color_hue = 360.0*(particle[j].yc - ymin)/(ymax - ymin);
break;
}
}
// particle[j].color_hue = 360.0*(particle[j].yc - ymin)/(ymax - ymin);
}
blank();
@ -1394,6 +1564,12 @@ void animation()
params.omega = angular_speed;
params.angle = rotation_schedule_smooth(i,n);
}
if ((DECREASE_CONTAINER_SIZE)&&(SMOOTH_CONTAINER_DECREASE))
{
params.xmincontainer = container_size_schedule_smooth(i, n);
if (SYMMETRIC_DECREASE) params.xmaxcontainer = -container_size_schedule_smooth(i, n);
}
if (INCREASE_GRAVITY) params.gravity = gravity_schedule(i,n);
if ((BOUNDARY_COND == BC_RECTANGLE_WALL)&&(i < INITIAL_TIME + WALL_TIME)) wall = 1;
@ -1444,7 +1620,15 @@ void animation()
}
/* add gravity */
if (INCREASE_GRAVITY) particle[j].fy -= params.gravity/particle[j].mass_inv;
if (INCREASE_GRAVITY)
{
if (CIRCULAR_GRAVITY)
{
particle[j].fx -= params.gravity*particle[j].xc/particle[j].mass_inv;
particle[j].fy -= params.gravity*particle[j].yc/particle[j].mass_inv;
}
else particle[j].fy -= params.gravity/particle[j].mass_inv;
}
else if (CIRCULAR_GRAVITY)
{
particle[j].fx -= GRAVITY*particle[j].xc/particle[j].mass_inv;
@ -1541,7 +1725,7 @@ void animation()
// if ((PARTIAL_THERMO_COUPLING))
if ((PARTIAL_THERMO_COUPLING)&&(i>N_T_AVERAGE))
{
nthermo = partial_thermostat_coupling(particle, xshift + PARTIAL_THERMO_SHIFT, segment);
nthermo = partial_thermostat_coupling(particle, xshift + PARTIAL_THERMO_SHIFT, segment, params);
printf("%i particles coupled to thermostat out of %i active\n", nthermo, params.nactive);
params.mean_energy = compute_mean_energy(particle);
}
@ -1643,14 +1827,14 @@ void animation()
}
if (TRACER_PARTICLE) draw_trajectory(trajectory, traj_position, traj_length);
draw_particles(particle, PLOT, params.beta, collisions, ncollisions, BG_COLOR, hashgrid);
draw_particles(particle, PLOT, params.beta, collisions, ncollisions, BG_COLOR, hashgrid, params);
draw_container(params.xmincontainer, params.xmaxcontainer, obstacle, segment, wall);
/* add a particle */
if ((ADD_PARTICLES)&&(i > ADD_TIME)&&((i - INITIAL_TIME - ADD_TIME)%ADD_PERIOD == 1)&&(i < NSTEPS - FINAL_NOADD_PERIOD))
{
for (k=0; k<N_ADD_PARTICLES; k++)
nadd_particle = add_particles(particle, px, py, nadd_particle);
nadd_particle = add_particles(particle, px, py, nadd_particle, params);
// params.nactive = nadd_particle;
params.nactive = 0;
for (j=0; j<ncircles; j++) if (particle[j].active) params.nactive++;
@ -1670,17 +1854,7 @@ void animation()
if (PRINT_SEGMENTS_FORCE) compute_segments_force(&params, segment);
update_hashgrid(particle, hashgrid, 1);
if (PRINT_PARAMETERS) print_parameters(params, PRINT_LEFT, pressure, 1);
if ((BOUNDARY_COND == BC_EHRENFEST)||(BOUNDARY_COND == BC_RECTANGLE_WALL))
print_ehrenfest_parameters(particle, pleft, pright);
else if (PRINT_PARTICLE_NUMBER)
{
if (REACTION_DIFFUSION)
print_particle_types_number(particle, RD_TYPES);
else print_particle_number(ncircles);
}
if ((i > INITIAL_TIME + WALL_TIME)&&(PRINT_ENTROPY))
{
compute_entropy(particle, entropy);
@ -1688,20 +1862,19 @@ void animation()
print_entropy(entropy);
}
if (PLOT_SPEEDS) draw_speed_plot(group_speeds, i);
if (PLOT_TRAJECTORIES) draw_trajectory_plot(group_speeds, i);
else if (PRINT_PARTICLE_SPEEDS) print_particles_speeds(particle);
else if (PRINT_SEGMENTS_SPEEDS)
/* these should be moved to draw_frame */
if (PRINT_SEGMENTS_SPEEDS)
{
if (MOVE_BOUNDARY) print_segments_speeds(vxsegments, vysegments);
else print_segment_group_speeds(segment_group);
}
if ((i > INITIAL_TIME)&&(PLOT_PARTICLE_NUMBER))
{
count_particle_number(particle, particle_numbers, i - INITIAL_TIME);
draw_particle_nb_plot(particle_numbers, i - INITIAL_TIME);
}
draw_frame(i, PLOT, BG_COLOR, ncollisions, traj_position, traj_length,
wall, pressure, pleft, pright, particle_numbers, 1, params, particle,
collisions, hashgrid, trajectory, obstacle, segment, group_speeds, segment_group);
if (!((NO_EXTRA_BUFFER_SWAP)&&(MOVIE))) glutSwapBuffers();
@ -1731,22 +1904,9 @@ void animation()
if ((i >= INITIAL_TIME)&&(DOUBLE_MOVIE))
{
if (TRACER_PARTICLE) draw_trajectory(trajectory, traj_position, traj_length);
draw_particles(particle, PLOT_B, params.beta, collisions, ncollisions, BG_COLOR_B, hashgrid);
draw_container(params.xmincontainer, params.xmaxcontainer, obstacle, segment, wall);
if (PRINT_PARAMETERS) print_parameters(params, PRINT_LEFT, pressure, 0);
if (PLOT_SPEEDS) draw_speed_plot(group_speeds, i);
if (PLOT_TRAJECTORIES) draw_trajectory_plot(group_speeds, i);
if (BOUNDARY_COND == BC_EHRENFEST) print_ehrenfest_parameters(particle, pleft, pright);
else if (PRINT_PARTICLE_NUMBER)
{
if (REACTION_DIFFUSION)
print_particle_types_number(particle, RD_TYPES);
else print_particle_number(ncircles);
}
else if (PRINT_PARTICLE_SPEEDS) print_particles_speeds(particle);
else if (PRINT_SEGMENTS_SPEEDS) print_segment_group_speeds(segment_group);
// print_segments_speeds(vxsegments, vysegments);
draw_frame(i, PLOT_B, BG_COLOR_B, ncollisions, traj_position, traj_length,
wall, pressure, pleft, pright, particle_numbers, 0, params, particle,
collisions, hashgrid, trajectory, obstacle, segment, group_speeds, segment_group);
glutSwapBuffers();
save_frame_lj_counter(NSTEPS + MID_FRAMES + 1 + counter);
counter++;
@ -1783,23 +1943,9 @@ void animation()
if (DOUBLE_MOVIE)
{
blank();
if (TRACER_PARTICLE) draw_trajectory(trajectory, traj_position, traj_length);
draw_particles(particle, PLOT, params.beta, collisions, ncollisions, BG_COLOR, hashgrid);
draw_container(params.xmincontainer, params.xmaxcontainer, obstacle, segment, wall);
if (PRINT_PARAMETERS) print_parameters(params, PRINT_LEFT, pressure, 1);
if (PLOT_SPEEDS) draw_speed_plot(group_speeds, i);
if (PLOT_TRAJECTORIES) draw_trajectory_plot(group_speeds, i);
if (BOUNDARY_COND == BC_EHRENFEST) print_ehrenfest_parameters(particle, pleft, pright);
else if (PRINT_PARTICLE_NUMBER)
{
if (REACTION_DIFFUSION)
print_particle_types_number(particle, RD_TYPES);
else print_particle_number(ncircles);
}
else if (PRINT_PARTICLE_SPEEDS) print_particles_speeds(particle);
else if (PRINT_SEGMENTS_SPEEDS) print_segment_group_speeds(segment_group);
// print_segments_speeds(vxsegments, vysegments);
// glutSwapBuffers();
draw_frame(NSTEPS, PLOT, BG_COLOR, ncollisions, traj_position, traj_length,
wall, pressure, pleft, pright, particle_numbers, 0, params, particle,
collisions, hashgrid, trajectory, obstacle, segment, group_speeds, segment_group);
}
for (i=0; i<MID_FRAMES; i++)
{
@ -1809,22 +1955,9 @@ void animation()
glutSwapBuffers();
if (DOUBLE_MOVIE)
{
if (TRACER_PARTICLE) draw_trajectory(trajectory, traj_position, traj_length);
draw_particles(particle, PLOT_B, params.beta, collisions, ncollisions, BG_COLOR_B, hashgrid);
draw_container(params.xmincontainer, params.xmaxcontainer, obstacle, segment, wall);
if (PRINT_PARAMETERS) print_parameters(params, PRINT_LEFT, pressure, 0);
if (PLOT_SPEEDS) draw_speed_plot(group_speeds, i);
if (PLOT_TRAJECTORIES) draw_trajectory_plot(group_speeds, i);
if (BOUNDARY_COND == BC_EHRENFEST) print_ehrenfest_parameters(particle, pleft, pright);
else if (PRINT_PARTICLE_NUMBER)
{
if (REACTION_DIFFUSION)
print_particle_types_number(particle, RD_TYPES);
else print_particle_number(ncircles);
}
else if (PRINT_PARTICLE_SPEEDS) print_particles_speeds(particle);
else if (PRINT_SEGMENTS_SPEEDS) print_segment_group_speeds(segment_group);
// print_segments_speeds(vxsegments, vysegments);
draw_frame(NSTEPS, PLOT_B, BG_COLOR_B, ncollisions, traj_position, traj_length,
wall, pressure, pleft, pright, particle_numbers, 0, params, particle,
collisions, hashgrid, trajectory, obstacle, segment, group_speeds, segment_group);
if (!((NO_EXTRA_BUFFER_SWAP)&&(MOVIE))) glutSwapBuffers();
}
if ((TIME_LAPSE)&&(!DOUBLE_MOVIE))

View File

@ -260,6 +260,22 @@
#define DRAW_WAVE_PROFILE 0 /* set to 1 to draw a profile of the wave */
#define VERTICAL_WAVE_PROFILE 0 /* set to 1 to draw wave profile vertically */
#define DRAW_WAVE_TIMESERIES 0 /* set to 1 to draw a time series of the wave */
#define WALL_WIDTH 0.1 /* width of wall separating lenses */
#define 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 */
#define MESSAGE_LINTERVAL 54 /* length of interval between dashes/dots for Morse code message */
#define MESSAGE_LINTERLETTER 60 /* length of interval between letters for Morse code message */
#define MESSAGE_LSPACE 48 /* length of space for Morse code message */
#define MESSAGE_INITIAL_TIME 100 /* initial time before starting message for Morse code message */
#define AVRG_E_FACTOR 0.95 /* controls time window size in P_AVERAGE_ENERGY scheme */
#define HORIZONTAL_WAVE_PROFILE 0 /* set to 1 to draw wave profile vertically */
#define WAVE_PROFILE_X 2.1 /* value of x to sample wave profile */
#define WAVE_PROFILE_Y -1.0 /* value of y to sample wave profile */
#define PROFILE_AT_BOTTOM 1 /* draw wave profile at bottom instead of top */
#define AVERAGE_WAVE_PROFILE 1 /* set to 1 to draw time-average of wave profile squared*/
#define TIMESERIES_NVALUES 400 /* number of values plotted in time series */
#define DRAW_WAVE_SOURCE 0 /* set to 1 to draw source of wave at (wave_source_x, wave_source_y) */
/* end of constants only used by sub_wave and sub_maze */
#include "global_pdes.c"

269
rde.c
View File

@ -48,35 +48,29 @@
#define WINWIDTH 1920 /* window width */
#define WINHEIGHT 1150 /* window height */
// #define NY 575 /* number of grid points on y axis */
#define NX 960 /* number of grid points on x axis */
#define NY 575 /* number of grid points on y axis */
#define NX 1500 /* number of grid points on x axis */
#define NY 750 /* number of grid points on y axis */
// #define WINWIDTH 1280 /* window width */
// #define WINHEIGHT 720 /* window height */
// #define NX 640 /* number of grid points on x axis */
// #define NY 360 /* number of grid points on y axis */
// #define NX 320 /* number of grid points on x axis */
// #define NY 180 /* number of grid points on y axis */
// #define XMIN -1.2
// #define XMAX 1.2 /* x interval */
// #define YMIN -1.2
// #define YMAX 1.2 /* y interval for 9/16 aspect ratio */
#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 */
#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 NLAPLACIANS 0 /* number of fields for which to compute Laplacian */
#define RDE_EQUATION 41 /* choice of reaction term, see list in global_3d.c */
#define NFIELDS 5 /* number of fields in reaction-diffusion equation */
#define NLAPLACIANS 5 /* number of fields for which to compute Laplacian */
#define SPHERE 1 /* set to 1 to simulate equation on sphere */
#define DPOLE 1 /* safety distance to poles */
#define DSMOOTH 10 /* size of neighbourhood of poles that are smoothed */
#define SMOOTHPOLE 0.24 /* smoothing coefficient at poles */
#define PHISHIFT 0.0 /* shift of phi in 2D plot (in degrees) */
#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 5 /* type of force field, see list in global_3d.c */
#define ADD_CORIOLIS_FORCE 0 /* set to 1 to add Coriolis force (quasigeostrophic Euler equations) */
@ -84,13 +78,15 @@
#define SWATER_DEPTH 4 /* 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 1 /* geometry of obstacles, as in B_DOMAIN */
// #define BC_STIFFNESS 100.0 /* controls region of boundary condition control */
#define BC_STIFFNESS 50.0 /* controls region of boundary condition control */
#define CHECK_INTEGRAL 1 /* set to 1 to check integral of first field */
#define JULIA_SCALE 0.5 /* scaling for Julia sets */
#define JULIA_ROT -20.0 /* rotation of Julia set, in degrees */
#define JULIA_RE 0.5
#define JULIA_IM 0.462 /* parameters for Julia sets */
/* Choice of the billiard table */
@ -102,7 +98,7 @@
#define NPOISSON 300 /* number of points for Poisson C_RAND_POISSON arrangement */
#define RANDOM_POLY_ANGLE 0 /* set to 1 to randomize angle of polygons */
#define LAMBDA 1.2 /* parameter controlling the dimensions of domain */
#define LAMBDA 0.9 /* parameter controlling the dimensions of domain */
#define MU 0.06 /* parameter controlling the dimensions of domain */
#define NPOLY 5 /* number of sides of polygon */
#define APOLY 2.0 /* angle by which to turn polygon, in units of Pi/2 */
@ -114,6 +110,7 @@
#define NGRIDX 6 /* number of grid point for grid of disks */
#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 X_SHOOTER -0.2
#define Y_SHOOTER -0.6
@ -131,18 +128,16 @@
/* Physical parameters of wave equation */
#define DT 0.00000025
#define DT 0.0000002
// #define VISCOSITY 0.0001
#define VISCOSITY 1.5e-5
// #define VISCOSITY 5.0e-4
// #define VISCOSITY 1.0e-3
#define DISSIPATION 1.0e-8
// #define DISSIPATION 1.0e-7
#define VISCOSITY 0.075
#define POISSON_STIFFNESS 1.0 /* stiffness of Poisson equation solver for incompressible Euler */
#define DISSIPATION 0.0
#define RPSA 0.75 /* parameter in Rock-Paper-Scissors-type interaction */
#define RPSLZB 0.75 /* second parameter in Rock-Paper-Scissors-Lizard-Spock type interaction */
#define K_AC 0.1 /* force constant in Allen-Cahn equation */
#define EPSILON 0.8 /* time scale separation */
#define DELTA 0.1 /* time scale separation */
#define FHNA 1.0 /* parameter in FHN equation */
@ -160,15 +155,15 @@
#define K_EULER_INC 0.5 /* constant in incompressible Euler equation */
#define SMOOTHEN_VORTICITY 0 /* set to 1 to smoothen vorticity field in Euler equation */
#define SMOOTHEN_VELOCITY 1 /* set to 1 to smoothen velocity field in Euler equation */
#define SMOOTHEN_VELOCITY 0 /* set to 1 to smoothen velocity field in Euler equation */
#define SMOOTHEN_PERIOD 10 /* period between smoothenings */
#define SMOOTH_FACTOR 0.15 /* factor by which to smoothen */
#define ADD_OSCILLATING_SOURCE 1 /* set to 1 to add an oscillating wave source */
#define ADD_OSCILLATING_SOURCE 0 /* set to 1 to add an oscillating wave source */
#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 to add tracer particles (for Euler equations) */
#define ADD_TRACERS 0 /* set to 1 to add tracer particles (for Euler equations) */
#define N_TRACERS 1000 /* number of tracer particles */
#define TRACERS_STEP 0.005 /* step size in tracer evolution */
@ -177,8 +172,8 @@
#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.005 /* noise intensity */
#define CHANGE_NOISE 1 /* set to 1 to increase noise intensity */
#define NOISE_INTENSITY 0.01 /* 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 */
@ -189,7 +184,7 @@
#define VISCOSITY_MAX 2.0 /* max value of viscosity beyond which NVID is increased and integration step is decrase,
for numerical stability */
#define CHANGE_RPSLZB 0 /* set to 1 to change second parameter in Rock-Paper-Scissors-Lizard-Spock equation */
#define CHANGE_RPSLZB 1 /* set to 1 to change second parameter in Rock-Paper-Scissors-Lizard-Spock equation */
#define RPSLZB_CHANGE 0.75 /* factor by which to rpslzb parameter */
#define RPSLZB_INITIAL_TIME 0 /* initial time during which rpslzb remains constant */
#define RPSLZB_FINAL_TIME 500 /* final time during which rpslzb remains constant */
@ -206,13 +201,6 @@
#define PRESSURE_GRADIENT 0.2 /* amplitude of pressure gradient for Euler equation */
#define SWATER_MIN_HEIGHT 0.5 /* min height of initial condition for shallow water equation */
// #define DEPTH_FACTOR 0.0125 /* proportion of min height in variable depth */
// #define DEPTH_FACTOR 0.001 /* proportion of min height in variable depth */
// #define DEPTH_FACTOR 0.0012 /* proportion of min height in variable depth */
// #define DEPTH_FACTOR 0.0015 /* proportion of min height in variable depth */
// #define DEPTH_FACTOR 0.002 /* proportion of min height in variable depth */
// #define DEPTH_FACTOR 0.005 /* proportion of min height in variable depth */
// #define DEPTH_FACTOR 0.01 /* proportion of min height in variable depth */
#define DEPTH_FACTOR 0.015 /* proportion of min height in variable depth */
#define TANH_FACTOR 1.0 /* steepness of variable depth */
@ -220,7 +208,7 @@
/* Boundary conditions, see list in global_pdes.c */
#define B_COND 0
#define B_COND 1
#define B_COND_LEFT 0
#define B_COND_RIGHT 0
@ -230,10 +218,8 @@
/* Parameters for length and speed of simulation */
#define NSTEPS 1300 /* number of frames of movie */
// #define NSTEPS 500 /* number of frames of movie */
// #define NVID 100 /* number of iterations between images displayed on screen */
#define NVID 45 /* number of iterations between images displayed on screen */
#define NSTEPS 3500 /* number of frames of movie */
#define NVID 8 /* 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 */
@ -245,28 +231,31 @@
#define SLEEP1 2 /* initial sleeping time */
#define SLEEP2 1 /* final sleeping time */
#define INITIAL_TIME 0 /* initial still time */
#define MID_FRAMES 50 /* number of still frames between parts of two-part movie */
#define END_FRAMES 50 /* number of still frames at end of movie */
#define MID_FRAMES 100 /* number of still frames between parts of two-part movie */
#define END_FRAMES 250 /* number of still frames at end of movie */
#define FADE 1 /* set to 1 to fade at end of movie */
/* Visualisation */
#define PLOT_3D 1 /* controls whether plot is 2D or 3D */
#define PLOT_SPHERE 1 /* draws fields on a sphere */
#define ROTATE_VIEW 1 /* set to 1 to rotate position of observer */
#define ROTATE_ANGLE 360.0 /* total angle of rotation during simulation */
#define SHADE_3D 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 DRAW_PERIODICISED 0 /* set to 1 to repeat wave periodically in x and y directions */
/* Plot type - color scheme */
#define CPLOT 70
#define CPLOT_B 74
#define CPLOT 40
#define CPLOT_B 42
/* Plot type - height of 3D plot */
#define ZPLOT 70 /* z coordinate in 3D plot */
#define ZPLOT_B 71 /* z coordinate in second 3D plot */
#define ZPLOT 42 /* z coordinate in 3D plot */
#define ZPLOT_B 42 /* z coordinate in second 3D plot */
#define AMPLITUDE_HIGH_RES 1 /* set to 1 to increase resolution of P_3D_AMPLITUDE plot */
#define SHADE_3D 1 /* set to 1 to change luminosity according to normal vector */
@ -286,7 +275,7 @@
#define PRINT_TIME 0 /* set to 1 to print running time */
#define PRINT_VISCOSITY 0 /* set to 1 to print viscosity */
#define PRINT_RPSLZB 0 /* set to 1 to print rpslzb parameter */
#define PRINT_RPSLZB 1 /* set to 1 to print rpslzb parameter */
#define PRINT_PROBABILITIES 0 /* set to 1 to print probabilities (for Ehrenfest urn configuration) */
#define PRINT_NOISE 0 /* set to 1 to print noise intensity */
#define PRINT_FLOW_SPEED 0 /* set to 1 to print speed of flow */
@ -310,19 +299,21 @@
/* Color schemes, see list in global_pdes.c */
#define COLOR_PALETTE 14 /* Color palette, see list in global_pdes.c */
// #define COLOR_PALETTE_B 17 /* Color palette, see list in global_pdes.c */
#define COLOR_PALETTE_B 0 /* Color palette, see list in global_pdes.c */
#define COLOR_PALETTE 0 /* Color palette, see list in global_pdes.c */
#define COLOR_PALETTE_B 17 /* Color palette, see list in global_pdes.c */
#define BLACK 1 /* black background */
#define COLOR_OUT_R 1.0 /* color outside domain */
#define COLOR_OUT_G 1.0
#define COLOR_OUT_B 1.0
#define COLOR_SCHEME 3 /* choice of color scheme */
#define COLOR_PHASE_SHIFT 0.5 /* phase shift of color scheme, in units of Pi */
#define COLOR_PHASE_SHIFT 0.25 /* phase shift of color scheme, in units of Pi */
#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 15.0 /* additional scaling factor for color scheme P_3D_AMPLITUDE */
#define VSCALE_AMPLITUDE 0.5 /* additional scaling factor for color scheme P_3D_AMPLITUDE */
#define ATTENUATION 0.0 /* exponential attenuation coefficient of contrast with time */
#define CURL_SCALE 0.000015 /* 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) */
@ -332,6 +323,7 @@
#define PRESSURE_SHIFT 10.0 /* shift for color scheme Z_EULER_PRESSURE */
#define PRESSURE_LOG_SHIFT -2.5 /* shift for color scheme Z_EULER_PRESSURE */
#define VSCALE_WATER_HEIGHT 0.4 /* vertical scaling of water height */
#define SHADE_SCALE_2D 1.0 /* controls "depth" of 2D shading */
#define COLORHUE 260 /* initial hue of water color for scheme C_LUM */
#define COLORDRIFT 0.0 /* how much the color hue drifts during the whole simulation */
@ -360,11 +352,11 @@
#define MAZE_XSHIFT 0.0 /* horizontal shift of maze */
#define MAZE_WIDTH 0.04 /* half width of maze walls */
#define DRAW_COLOR_SCHEME 1 /* set to 1 to plot the color scheme */
#define DRAW_COLOR_SCHEME 0 /* set to 1 to plot the color scheme */
#define COLORBAR_RANGE 2.5 /* scale of color scheme bar */
#define COLORBAR_RANGE_B 2.5 /* scale of color scheme bar for 2nd part */
#define ROTATE_COLOR_SCHEME 0 /* set to 1 to draw color scheme horizontally */
#define CIRC_COLORBAR 0 /* set to 1 to draw circular color scheme */
#define CIRC_COLORBAR 1 /* set to 1 to draw circular color scheme */
#define CIRC_COLORBAR_B 1 /* set to 1 to draw circular color scheme */
/* only for compatibility with wave_common.c */
@ -374,6 +366,7 @@
#define IOR_TOTAL_TURNS 1.5 /* total angle of rotation for IOR_PERIODIC_WELLS_ROTATING */
#define MANDEL_IOR_SCALE -0.05 /* parameter controlling dependence of IoR on Mandelbrot escape speed */
#define OMEGA 0.005 /* frequency of periodic excitation */
#define OSCIL_YMAX 0.2 /* defines oscillation range */
#define COURANT 0.08 /* Courant number */
#define COURANTB 0.03 /* Courant number in medium B */
#define INITIAL_AMP 0.5 /* amplitude of initial condition */
@ -382,6 +375,7 @@
#define VSCALE_ENERGY 200.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 AVRG_E_FACTOR 0.99 /* controls time window size in P_AVERAGE_ENERGY scheme */
#define OSCILLATION_SCHEDULE 0 /* oscillation schedule, see list in global_pdes.c */
#define AMPLITUDE 0.8 /* amplitude of periodic excitation */
#define ACHIRP 0.2 /* acceleration coefficient in chirp */
@ -390,17 +384,31 @@
#define B_DOMAIN_B 20 /* second domain shape, for comparisons */
#define CIRCLE_PATTERN_B 0 /* second pattern of circles or polygons */
#define FLUX_WINDOW 20 /* averaging window for energy flux */
#define ADD_WAVE_PACKET_SOURCES 1 /* set to 1 to add several sources emitting wave packets */
#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 */
#define N_WAVE_PACKETS 15 /* number of wave packets */
#define WAVE_PACKET_RADIUS 20 /* radius of wave packets */
#define OSCIL_LEFT_YSHIFT 25.0 /* y-dependence of left oscillation (for non-horizontal waves) */
#define DRAW_WAVE_PROFILE 1 /* set to 1 to draw a profile of the wave */
#define DRAW_WAVE_PROFILE 0 /* set to 1 to draw a profile of the wave */
#define HORIZONTAL_WAVE_PROFILE 0 /* set to 1 to draw wave profile vertically */
#define VERTICAL_WAVE_PROFILE 0 /* set to 1 to draw wave profile vertically */
#define WAVE_PROFILE_X 1.9 /* value of x to sample wave profile */
#define WAVE_PROFILE_Y -1.0 /* value of y to sample wave profile */
#define PROFILE_AT_BOTTOM 1 /* draw wave profile at bottom instead of top */
#define AVERAGE_WAVE_PROFILE 1 /* set to 1 to draw time-average of wave profile squared*/
#define MU_B 1.0 /* parameter controlling the dimensions of domain */
#define GAMMA 0.0 /* damping factor in wave equation */
#define GAMMAB 0.0 /* damping factor in wave equation */
#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 TIMESERIES_NVALUES 400 /* number of values plotted in time series */
#define DRAW_WAVE_SOURCE 0 /* set to 1 to draw source of wave at (wave_source_x, wave_source_y) */
#define MESSAGE_LDASH 14 /* length of dash for Morse code message */
#define MESSAGE_LDOT 8 /* length of dot for Morse code message */
#define MESSAGE_LINTERVAL 54 /* length of interval between dashes/dots for Morse code message */
#define MESSAGE_LINTERLETTER 60 /* length of interval between letters for Morse code message */
#define MESSAGE_LSPACE 48 /* length of space for Morse code message */
#define MESSAGE_INITIAL_TIME 100 /* initial time before starting message for Morse code message */
/* end of constants added only for compatibility with wave_common.c */
@ -411,13 +419,18 @@ double light[3] = {0.816496581, 0.40824829, 0.40824829}; /* vector of "ligh
double observer[3] = {8.0, 8.0, 7.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 150.0 /* overall scaling factor of z axis for REP_PROJ_3D representation */
#define XY_SCALING_FACTOR 2.5 /* overall scaling factor for on-screen (x,y) coordinates after projection */
#define Z_SCALING_FACTOR 0.8 /* overall scaling factor of z axis for REP_PROJ_3D representation */
#define XY_SCALING_FACTOR 2.0 /* overall scaling factor for on-screen (x,y) coordinates after projection */
#define ZMAX_FACTOR 1.0 /* max value of z coordinate for REP_PROJ_3D representation */
#define XSHIFT_3D 0.0 /* overall x shift for REP_PROJ_3D representation */
#define YSHIFT_3D 0.1 /* overall y shift for REP_PROJ_3D representation */
#define YSHIFT_3D 0.0 /* overall y shift for REP_PROJ_3D representation */
#define BORDER_PADDING 0 /* distance from boundary at which to plot points, to avoid boundary effects due to gradient */
#define RSCALE -0.01 /* scaling factor of radial component */
#define RMAX 1.005 /* max value of radial component */
#define RMIN 0.995 /* min value of radial component */
#define COS_VISIBLE -1.1 /* limit on cosine of normal to shown facets */
/* For debugging purposes only */
#define FLOOR 1 /* set to 1 to limit wave amplitude to VMAX */
#define VMAX 100.0 /* max value of wave amplitude */
@ -920,15 +933,14 @@ double initialize_water_depth(t_rde rde[NX*NY])
}
void evolve_wave_half(double *phi_in[NFIELDS], double *phi_out[NFIELDS], short int xy_in[NX*NY], double potential_field[NX*NY], double vector_potential_field[2*NX*NY],
double gfield[2*NX*NY], t_rde rde[NX*NY])
double gfield[2*NX*NY], t_rde rde[NX*NY], t_wave_sphere wsphere[NX*NY])
/* time step of field evolution */
{
int i, j, k, iplus, iminus, jplus, jminus, ropening, w;
double x, y, z, deltax, deltay, deltaz, rho, rhox, rhoy, pot, u, v, ux, uy, vx, vy, test = 0.0, dx, dy, xy[2], padding, a, eta, etax, etay;
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 u_bc[NY], v_bc[NY];
static double invsqr3 = 0.577350269; /* 1/sqrt(3) */
static double stiffness = 2.0; /* stiffness of Poisson equation solver */
static int smooth = 0, y_channels, y_channels1, imin, imax, first = 1;
if (first) /* for D_MAZE_CHANNELS boundary conditions in Euler equation */
@ -952,9 +964,34 @@ double gfield[2*NX*NY], t_rde rde[NX*NY])
imin = 0;
imax = NX;
}
/* average values at poles on sphere */
if (SPHERE) for (k=0; k<NFIELDS; k++)
{
sum = 0.0;
for (i=0; i<NX; i++) for (j=0; j<DPOLE; j++)
sum += phi_in[k][i*NY+j];
sum = sum/(double)(NX*DPOLE);
if (sum > 1.0) sum = 1.0;
if (sum < -1.0) sum = -1.0;
for (i=0; i<NX; i++) for (j=0; j<DPOLE; j++)
phi_in[k][i*NY+j] = sum;
sum = 0.0;
for (i=0; i<NX; i++) for (j=NY-DPOLE-1; j<NY; j++)
sum += phi_in[k][i*NY+j];
sum = sum/(double)(NX*DPOLE);
if (sum > 1.0) sum = 1.0;
if (sum < -1.0) sum = -1.0;
for (i=0; i<NX; i++) for (j=NY-DPOLE-1; j<NY; j++)
phi_in[k][i*NY+j] = sum;
}
first = 0;
}
/* smooth vector fields at poles */
if (SPHERE) for (k=0; k<NFIELDS; k++) smooth_poles(phi_in[k]);
for (i=0; i<NLAPLACIANS; i++) delta_phi[i] = (double *)malloc(NX*NY*sizeof(double));
if (COMPUTE_PRESSURE)
@ -964,9 +1001,9 @@ double gfield[2*NX*NY], t_rde rde[NX*NY])
}
/* compute the Laplacian of phi */
for (i=0; i<NLAPLACIANS; i++) compute_laplacian_rde(phi_in[i], delta_phi[i], xy_in);
for (i=0; i<NLAPLACIANS; i++) compute_laplacian_rde(phi_in[i], delta_phi[i], xy_in, wsphere);
if (COMPUTE_PRESSURE) compute_laplacian_rde(phi_in[2], delta_pressure, xy_in);
if (COMPUTE_PRESSURE) compute_laplacian_rde(phi_in[2], delta_pressure, xy_in, wsphere);
/* compute the gradient of phi if there is a magnetic field */
if (ADD_MAGNETIC_FIELD)
@ -983,8 +1020,8 @@ double gfield[2*NX*NY], t_rde rde[NX*NY])
{
nabla_psi = (double *)malloc(2*NX*NY*sizeof(double));
nabla_omega = (double *)malloc(2*NX*NY*sizeof(double));
compute_gradient_euler(phi_in[0], nabla_psi, EULER_GRADIENT_YSHIFT);
compute_gradient_euler(phi_in[1], nabla_omega, 0.0);
compute_gradient_euler(phi_in[0], nabla_psi, wsphere, EULER_GRADIENT_YSHIFT);
compute_gradient_euler(phi_in[1], nabla_omega, wsphere, 0.0);
if (COMPUTE_PRESSURE) compute_pressure_laplacian(phi_in, delta_p);
@ -996,7 +1033,7 @@ double gfield[2*NX*NY], t_rde rde[NX*NY])
if (smooth == 0)
{
delta_vorticity = (double *)malloc(NX*NY*sizeof(double));
compute_laplacian_rde(phi_in[1], delta_vorticity, xy_in);
compute_laplacian_rde(phi_in[1], delta_vorticity, xy_in, wsphere);
// #pragma omp parallel for private(i,delta_vorticity)
for (i=0; i<NX*NY; i++) phi_in[1][i] += intstep*SMOOTH_FACTOR*delta_vorticity[i];
free(delta_vorticity);
@ -1020,8 +1057,8 @@ double gfield[2*NX*NY], t_rde rde[NX*NY])
{
delta_u = (double *)malloc(NX*NY*sizeof(double));
delta_v = (double *)malloc(NX*NY*sizeof(double));
compute_laplacian_rde(phi_in[1], delta_u, xy_in);
compute_laplacian_rde(phi_in[2], delta_v, xy_in);
compute_laplacian_rde(phi_in[1], delta_u, xy_in, wsphere);
compute_laplacian_rde(phi_in[2], delta_v, xy_in, wsphere);
#pragma omp parallel for private(i)
for (i=0; i<NX*NY; i++) phi_in[1][i] += intstep*SMOOTH_FACTOR*delta_u[i];
#pragma omp parallel for private(i)
@ -1045,11 +1082,16 @@ double gfield[2*NX*NY], t_rde rde[NX*NY])
{
delta_u = (double *)malloc(NX*NY*sizeof(double));
delta_v = (double *)malloc(NX*NY*sizeof(double));
compute_laplacian_rde(phi_in[1], delta_u, xy_in);
compute_laplacian_rde(phi_in[2], delta_v, xy_in);
compute_laplacian_rde(phi_in[1], delta_u, xy_in, wsphere);
compute_laplacian_rde(phi_in[2], delta_v, xy_in, wsphere);
}
break;
}
default:
{
/* do nothing */
}
}
if (TEST_GRADIENT) {
@ -1063,6 +1105,7 @@ double gfield[2*NX*NY], t_rde rde[NX*NY])
}
#pragma omp parallel for private(i,j,k,x,y,z,deltax,deltay,deltaz,rho)
for (i=imin; i<imax; i++){
for (j=0; j<NY; j++){
@ -1077,7 +1120,7 @@ double gfield[2*NX*NY], t_rde rde[NX*NY])
{
x = phi_in[0][i*NY+j];
deltax = viscosity*delta_phi[0][i*NY+j];
phi_out[0][i*NY+j] = phi_in[0][i*NY+j] + intstep*(deltax + x*(1.0-x*x));
phi_out[0][i*NY+j] = phi_in[0][i*NY+j] + intstep*(deltax + K_AC*x*(1.0-x*x));
break;
}
case (E_CAHN_HILLIARD):
@ -1144,14 +1187,14 @@ double gfield[2*NX*NY], t_rde rde[NX*NY])
}
case (E_EULER_INCOMP):
{
phi_out[0][i*NY+j] = phi_in[0][i*NY+j] + intstep*stiffness*(delta_phi[0][i*NY+j] + phi_in[1][i*NY+j]*dx*dx);
phi_out[0][i*NY+j] = phi_in[0][i*NY+j] + intstep*POISSON_STIFFNESS*(delta_phi[0][i*NY+j] + phi_in[1][i*NY+j]*dx*dx);
// phi_out[0][i*NY+j] += intstep*EULER_GRADIENT_YSHIFT;
phi_out[1][i*NY+j] = phi_in[1][i*NY+j] - intstep*K_EULER*(nabla_omega[i*NY+j]*nabla_psi[NX*NY+i*NY+j]);
phi_out[1][i*NY+j] += intstep*K_EULER*(nabla_omega[NX*NY+i*NY+j]*nabla_psi[i*NY+j]);
if (COMPUTE_PRESSURE)
{
phi_out[2][i*NY+j] = phi_in[2][i*NY+j] + intstep*stiffness*(delta_pressure[i*NY+j] - delta_p[i*NY+j]);
phi_out[2][i*NY+j] = phi_in[2][i*NY+j] + intstep*POISSON_STIFFNESS*(delta_pressure[i*NY+j] - delta_p[i*NY+j]);
phi_out[2][i*NY+j] *= exp(-2.0e-3);
}
break;
@ -1290,11 +1333,11 @@ double gfield[2*NX*NY], t_rde rde[NX*NY])
void evolve_wave(double *phi[NFIELDS], double *phi_tmp[NFIELDS], short int xy_in[NX*NY],
double potential_field[NX*NY], double vector_potential_field[2*NX*NY],
double gfield[2*NX*NY], t_rde rde[NX*NY])
double gfield[2*NX*NY], t_rde rde[NX*NY], t_wave_sphere wsphere[NX*NY])
/* time step of field evolution */
{
evolve_wave_half(phi, phi_tmp, xy_in, potential_field, vector_potential_field, gfield, rde);
evolve_wave_half(phi_tmp, phi, xy_in, potential_field, vector_potential_field, gfield, rde);
evolve_wave_half(phi, phi_tmp, xy_in, potential_field, vector_potential_field, gfield, rde, wsphere);
evolve_wave_half(phi_tmp, phi, xy_in, potential_field, vector_potential_field, gfield, rde, wsphere);
}
@ -1490,13 +1533,15 @@ void draw_color_bar_palette(int plot, double range, int palette, int circular, i
if (ROTATE_COLOR_SCHEME)
draw_color_scheme_palette_3d(XMIN + 0.3, YMIN + 0.1, XMAX - 0.3, YMIN + 0.1 + width, plot, -range, range, palette, fade, fade_value);
else if (circular)
draw_circular_color_scheme_palette_3d(XMAX - 2.0*width, YMAX - 2.0*width, 1.5*width, plot, -range, range, palette, fade, fade_value);
draw_circular_color_scheme_palette_3d(XMAX - 2.0*width, YMAX - 2.0*width, 1.0*width, plot, -range, range, palette, fade, fade_value);
else
draw_color_scheme_palette_3d(XMAX - 1.5*width, YMIN + 0.1, XMAX - 0.5*width, YMAX - 0.1, plot, -range, range, palette, fade, fade_value);
}
else
{
if (ROTATE_COLOR_SCHEME)
if (circular)
draw_circular_color_scheme_palette_fade(XMAX - 2.0*width, YMAX - 2.0*width, 1.0*width, plot, -range, range, palette, fade, fade_value);
else if (ROTATE_COLOR_SCHEME)
draw_color_scheme_palette_fade(XMIN + 0.8, YMIN + 0.1, XMAX - 0.8, YMIN + 0.1 + width, plot, -range, range, palette, fade, fade_value);
else
draw_color_scheme_palette_fade(XMAX - 1.5*width, YMIN + 0.1, XMAX - 0.5*width, YMAX - 0.1, plot, -range, range, palette, fade, fade_value);
@ -1582,7 +1627,7 @@ void animation()
int i, j, k, s, nvid, field;
static int counter = 0;
t_rde *rde;
// t_swater_depth *water_depth;
t_wave_sphere *wsphere;
/* Since NX and NY are big, it seemed wiser to use some memory allocation here */
for (i=0; i<NFIELDS; i++)
@ -1594,6 +1639,12 @@ void animation()
xy_in = (short int *)malloc(NX*NY*sizeof(short int));
rde = (t_rde *)malloc(NX*NY*sizeof(t_rde));
if (SPHERE)
{
wsphere = (t_wave_sphere *)malloc(NX*NY*sizeof(t_wave_sphere));
init_wave_sphere_rde(wsphere);
}
npolyline = init_polyline(MDEPTH, polyline);
for (i=0; i<npolyline; i++) printf("vertex %i: (%.3f, %.3f)\n", i, polyline[i].x, polyline[i].y);
@ -1656,9 +1707,16 @@ void animation()
/* initialize field */
// init_random(0.5, 0.4, phi, xy_in);
// init_random(0.0, 0.4, phi, xy_in);
init_random(0.5, 0.25, phi, xy_in, wsphere);
// init_random_smoothed(0.5, 0.25, phi, xy_in, wsphere);
// init_gaussian(x, y, mean, amplitude, scalex, phi, xy_in)
// init_coherent_state(-1.2, 0.35, 5.0, -2.0, 0.1, phi, xy_in);
// init_coherent_state(0.0, 0.0, 10.0, 0.0, 0.1, phi, xy_in);
// init_coherent_state_sphere(0, 0.0, PID, 10.0, 5.0, 0.1, phi, xy_in, wsphere);
// init_coherent_state_sphere(1, PI, PID, -10.0, 5.0, 0.1, phi, xy_in, wsphere);
// init_coherent_state_sphere(1, PID, PID, 10.0, -5.0, 0.1, phi, xy_in, wsphere);
// init_coherent_state_sphere(1, 3.0*PID, PID, -10.0, -5.0, 0.1, phi, xy_in, wsphere);
// add_coherent_state(-0.75, -0.75, 0.0, 5.0, 0.1, phi, xy_in);
// init_fermion_state(-0.5, 0.5, 2.0, 0.0, 0.1, phi, xy_in);
// init_boson_state(-0.5, 0.5, 2.0, 0.0, 0.1, phi, xy_in);
@ -1677,9 +1735,9 @@ void animation()
// add_vortex_state(0.1, -0.3, 0.7, 0.1, -0.5, phi, xy_in);
// init_pressure_gradient_flow(flow_speed_schedule(0), 1.0 + PRESSURE_GRADIENT, 1.0 - PRESSURE_GRADIENT, phi, xy_in, bc_field);
// init_shear_flow(-1.0, 0.1, 0.2, 1, 1, 0.2, phi, xy_in);
// init_shear_flow(1.0, 0.02, 0.15, 1, 1, 0.0, phi, xy_in);
// init_shear_flow_sphere(0.2, 0.05, 0.15, 6, 5, 0.75, phi, xy_in, wsphere);
// init_shear_flow_sphere(1.0, 0.25, 0.25, 8, 7, 0.75, phi, xy_in, wsphere);
// init_gaussian_wave(-1.0, 0.0, 0.005, 0.25, SWATER_MIN_HEIGHT, phi, xy_in);
@ -1687,19 +1745,19 @@ void animation()
// init_linear_blob(0.0, -0.75, 0.025, 0.0, 0.001, 0.25, 0.5, SWATER_MIN_HEIGHT, phi, xy_in);
init_elliptical_vibration(0.0, 0.0, 0.0075, LAMBDA, 1.0, 0.0003, 0.1, 1.0, SWATER_MIN_HEIGHT, phi, xy_in);
// init_elliptical_vibration(0.0, 0.0, 0.0075, LAMBDA, 1.0, 0.0003, 0.1, 1.0, SWATER_MIN_HEIGHT, phi, xy_in);
// add_gaussian_wave(-1.6, -0.5, 0.015, 0.25, SWATER_MIN_HEIGHT, phi, xy_in);
if (ADAPT_STATE_TO_BC) adapt_state_to_bc(phi, bc_field, xy_in);
init_cfield_rde(phi, xy_in, CPLOT, rde, 0);
if (PLOT_3D) init_zfield_rde(phi, xy_in, ZPLOT, rde, 0);
if ((PLOT_3D)||(SHADE_2D)) init_zfield_rde(phi, xy_in, ZPLOT, rde, 0);
if (DOUBLE_MOVIE)
{
init_cfield_rde(phi, xy_in, CPLOT_B, rde, 1);
if (PLOT_3D) init_zfield_rde(phi, xy_in, ZPLOT_B, rde, 1);
if ((PLOT_3D)||(SHADE_2D)) init_zfield_rde(phi, xy_in, ZPLOT_B, rde, 1);
}
if (ADD_TRACERS) for (i=0; i<N_TRACERS; i++)
@ -1716,7 +1774,7 @@ void animation()
printf("Drawing wave\n");
draw_wave_rde(0, phi, xy_in, rde, potential_field, ZPLOT, CPLOT, COLOR_PALETTE, 0, 1.0, 1);
draw_wave_rde(0, phi, xy_in, rde, wsphere, potential_field, ZPLOT, CPLOT, COLOR_PALETTE, 0, 1.0, 1);
// draw_billiard();
if (PRINT_PARAMETERS) print_parameters(phi, rde, xy_in, time, PRINT_LEFT, VISCOSITY, noise);
if (DRAW_COLOR_SCHEME) draw_color_bar_palette(CPLOT, COLORBAR_RANGE, COLOR_PALETTE, CIRC_COLORBAR, 0, 1.0);
@ -1754,7 +1812,7 @@ void animation()
}
printf("Drawing wave %i\n", i);
draw_wave_rde(0, phi, xy_in, rde, potential_field, ZPLOT, CPLOT, COLOR_PALETTE, 0, 1.0, 1);
draw_wave_rde(0, phi, xy_in, rde, wsphere, potential_field, ZPLOT, CPLOT, COLOR_PALETTE, 0, 1.0, 1);
// nvid = (int)((double)NVID*(1.0 + (ACCELERATION_FACTOR - 1.0)*(double)i/(double)NSTEPS));
/* increase integration step */
@ -1768,7 +1826,7 @@ void animation()
// printf("Integration step %.5lg\n", intstep);
printf("Evolving wave\n");
for (j=0; j<nvid; j++) evolve_wave(phi, phi_tmp, xy_in, potential_field, vector_potential_field, gfield, rde);
for (j=0; j<nvid; j++) evolve_wave(phi, phi_tmp, xy_in, potential_field, vector_potential_field, gfield, rde, wsphere);
if (ADAPT_STATE_TO_BC) adapt_state_to_bc(phi, bc_field, xy_in);
@ -1848,7 +1906,7 @@ void animation()
if ((i >= INITIAL_TIME)&&(DOUBLE_MOVIE))
{
draw_wave_rde(1, phi, xy_in, rde, potential_field, ZPLOT_B, CPLOT_B, COLOR_PALETTE_B, 0, 1.0, REFRESH_B);
draw_wave_rde(1, phi, xy_in, rde, wsphere, potential_field, ZPLOT_B, CPLOT_B, COLOR_PALETTE_B, 0, 1.0, REFRESH_B);
if (ADD_TRACERS) draw_tracers(phi, tracers, i, 0, 1.0);
// draw_billiard();
if (PRINT_PARAMETERS) print_parameters(phi, rde, xy_in, time, PRINT_LEFT, viscosity_printed, noise);
@ -1880,7 +1938,7 @@ void animation()
{
if (DOUBLE_MOVIE)
{
draw_wave_rde(0, phi, xy_in, rde, potential_field, ZPLOT, CPLOT, COLOR_PALETTE, 0, 1.0, 1);
draw_wave_rde(0, phi, xy_in, rde, wsphere, potential_field, ZPLOT, CPLOT, COLOR_PALETTE, 0, 1.0, 1);
if (ADD_TRACERS) draw_tracers(phi, tracers, NSTEPS, 0, 1.0);
// draw_billiard();
if (PRINT_PARAMETERS) print_parameters(phi, rde, xy_in, time, PRINT_LEFT, viscosity_printed, noise);
@ -1892,7 +1950,7 @@ void animation()
else for (i=0; i<MID_FRAMES; i++)
{
fade_value = 1.0 - (double)i/(double)MID_FRAMES;
draw_wave_rde(0, phi, xy_in, rde, potential_field, ZPLOT, CPLOT, COLOR_PALETTE, 1, fade_value, 0);
draw_wave_rde(0, phi, xy_in, rde, wsphere, potential_field, ZPLOT, CPLOT, COLOR_PALETTE, 1, fade_value, 0);
if (ADD_TRACERS) draw_tracers(phi, tracers, NSTEPS, 1, fade_value);
// draw_billiard();
if (PRINT_PARAMETERS) print_parameters(phi, rde, xy_in, time, PRINT_LEFT, viscosity_printed, noise);
@ -1900,7 +1958,7 @@ void animation()
if (!NO_EXTRA_BUFFER_SWAP) glutSwapBuffers();
save_frame_counter(NSTEPS + i + 1);
}
draw_wave_rde(1, phi, xy_in, rde, potential_field, ZPLOT_B, CPLOT_B, COLOR_PALETTE_B, 0, 1.0, REFRESH_B);
draw_wave_rde(1, phi, xy_in, rde, wsphere, potential_field, ZPLOT_B, CPLOT_B, COLOR_PALETTE_B, 0, 1.0, REFRESH_B);
if (ADD_TRACERS) draw_tracers(phi, tracers, NSTEPS, 0, 1.0);
if (PRINT_PARAMETERS) print_parameters(phi, rde, xy_in, time, PRINT_LEFT, viscosity_printed, noise);
if (DRAW_COLOR_SCHEME) draw_color_bar_palette(CPLOT_B, COLORBAR_RANGE_B, COLOR_PALETTE_B, CIRC_COLORBAR_B, 0, 1.0);
@ -1910,7 +1968,7 @@ void animation()
else for (i=0; i<END_FRAMES; i++)
{
fade_value = 1.0 - (double)i/(double)END_FRAMES;
draw_wave_rde(1, phi, xy_in, rde, potential_field, ZPLOT_B, CPLOT_B, COLOR_PALETTE_B, 1, fade_value, 0);
draw_wave_rde(1, phi, xy_in, rde, wsphere, potential_field, ZPLOT_B, CPLOT_B, COLOR_PALETTE_B, 1, fade_value, 0);
if (ADD_TRACERS) draw_tracers(phi, tracers, NSTEPS, 1, fade_value);
if (PRINT_PARAMETERS) print_parameters(phi, rde, xy_in, time, PRINT_LEFT, viscosity_printed, noise);
if (DRAW_COLOR_SCHEME) draw_color_bar_palette(CPLOT_B, COLORBAR_RANGE_B, COLOR_PALETTE_B, CIRC_COLORBAR_B, 1, fade_value);
@ -1924,7 +1982,7 @@ void animation()
else for (i=0; i<END_FRAMES; i++)
{
fade_value = 1.0 - (double)i/(double)END_FRAMES;
draw_wave_rde(0, phi, xy_in, rde, potential_field, ZPLOT, CPLOT, COLOR_PALETTE, 1, fade_value, 0);
draw_wave_rde(0, phi, xy_in, rde, wsphere, potential_field, ZPLOT, CPLOT, COLOR_PALETTE, 1, fade_value, 0);
if (ADD_TRACERS) draw_tracers(phi, tracers, NSTEPS, 1, fade_value);
if (DRAW_COLOR_SCHEME) draw_color_bar_palette(CPLOT, COLORBAR_RANGE, COLOR_PALETTE, CIRC_COLORBAR, 1, fade_value);
glutSwapBuffers();
@ -1941,6 +1999,7 @@ void animation()
free(phi_tmp[i]);
}
free(xy_in);
if (SPHERE) free(wsphere);
if (ADD_POTENTIAL) free(potential_field);
else if (ADD_MAGNETIC_FIELD)
{

View File

@ -198,6 +198,15 @@
#define GAMMAB 0.0 /* damping factor in wave equation */
#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 INITIAL_TIME 50 /* time after which to start saving frames */
#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 */
#define MESSAGE_LINTERVAL 54 /* length of interval between dashes/dots for Morse code message */
#define MESSAGE_LINTERLETTER 60 /* length of interval between letters for Morse code message */
#define MESSAGE_LSPACE 48 /* length of space for Morse code message */
#define MESSAGE_INITIAL_TIME 100 /* initial time before starting message for Morse code message */
/* end of constants only used by sub_wave and sub_maze */

1685
sub_lj.c

File diff suppressed because it is too large Load Diff

1039
sub_rde.c

File diff suppressed because it is too large Load Diff

View File

@ -54,6 +54,7 @@ void init_wave_sphere(t_wave_sphere wsphere[NX*NY])
wsphere[i*NY+j].z = -wsphere[i*NY+j].ctheta;
wsphere[i*NY+j].radius = 1.0;
wsphere[i*NY+j].radius_dem = 1.0;
ij_to_xy(NX-1-i,j,xy);
// xy[0] = XMIN + ((double)(NX-i-1))*(XMAX-XMIN)/((double)NX);
@ -237,7 +238,7 @@ void init_dem(t_wave_sphere wsphere[NX*NY], int dem_number)
{
int i, j, ii, jj, k, nx, ny, maxrgb, nmaxpixels = 4915200, scan, rgbval, diff, sshift, nshift, hmin, hmax, ishift, hsum;
int *rgb_values;
double cratio, rx, ry, cy, dx, dy, pscal, norm, vscale1, vscale2, gradx, grady, deltar, deltai[3], deltaj[3], dphi, dtheta, n[3], hsea, hmean;
double cratio, rx, ry, cy, dx, dy, pscal, norm, vscale1, vscale2, gradx, grady, deltar, deltai[3], deltaj[3], dphi, dtheta, n[3], hsea, hmean, vshift;
double *height_values, *height_values_tmp;
FILE *image_file;
@ -262,7 +263,7 @@ void init_dem(t_wave_sphere wsphere[NX*NY], int dem_number)
{
nmaxpixels = 2097152;
image_file = fopen("Moon_LRO_LOLA_global_LDEM_1024.ppm", "r");
hsea = 255.0*PLANET_SEALEVEL/DEM_MAXHEIGHT;
hsea = 255.0*PLANET_SEALEVEL/(DEM_MAXHEIGHT - DEM_MAXDEPTH);
break;
}
case (DEM_VENUS):
@ -345,6 +346,7 @@ void init_dem(t_wave_sphere wsphere[NX*NY], int dem_number)
ry = (double)ny/(double)(NY - sshift - nshift);
/* build height table */
vshift = PLANET_SEALEVEL/(DEM_MAXHEIGHT - DEM_MAXDEPTH);
for (i=0; i<NX; i++)
for (j=0; j<NY; j++)
{
@ -365,7 +367,7 @@ void init_dem(t_wave_sphere wsphere[NX*NY], int dem_number)
}
if (OTHER_PLANET)
wsphere[i*NY+j].indomain = (wsphere[i*NY+j].altitude < 0.0);
wsphere[i*NY+j].indomain = (wsphere[i*NY+j].altitude < vshift);
// if (wsphere[i*NY+j].indomain) printf("rgb = %i, altitude = %.3lg\n", rgb_values[3*(jj*nx+ii)], height_values[i*NY+j]);
}
@ -476,7 +478,7 @@ void init_dem(t_wave_sphere wsphere[NX*NY], int dem_number)
for (j=0; j<NY; j++)
// if (!wsphere[i*NY+j].indomain) wsphere[i*NY+j].radius = 1.0 + RSCALE_DEM*wsphere[i*NY+j].altitude;
// else wsphere[i*NY+j].radius = 1.0;
wsphere[i*NY+j].radius = 1.0 + RSCALE_DEM*wsphere[i*NY+j].altitude;
wsphere[i*NY+j].radius_dem = 1.0 + RSCALE_DEM*(wsphere[i*NY+j].altitude - vshift);
/* compute light angle */
dx = 2.0*(XMAX - XMIN)/(double)NX;
@ -489,8 +491,8 @@ void init_dem(t_wave_sphere wsphere[NX*NY], int dem_number)
for (i=1; i<NX-1; i++)
for (j=1; j<NY-1; j++)
{
gradx = (wsphere[(i+1)*NY+j].radius - wsphere[(i-1)*NY+j].radius)/dx;
grady = (wsphere[i*NY+j+1].radius - wsphere[i*NY+j-1].radius)/dy;
gradx = (wsphere[(i+1)*NY+j].radius_dem - wsphere[(i-1)*NY+j].radius_dem)/dx;
grady = (wsphere[i*NY+j+1].radius_dem - wsphere[i*NY+j-1].radius_dem)/dy;
norm = sqrt(vscale2 + gradx*gradx + grady*grady);
pscal = -gradx*light[0] - grady*light[1] + vscale1;
@ -500,8 +502,8 @@ void init_dem(t_wave_sphere wsphere[NX*NY], int dem_number)
/* i = 0 */
for (j=1; j<NY-1; j++)
{
gradx = (wsphere[NY+j].radius - wsphere[(NX-1)*NY+j].radius)/dx;
grady = (wsphere[j+1].radius - wsphere[j-1].radius)/dy;
gradx = (wsphere[NY+j].radius_dem - wsphere[(NX-1)*NY+j].radius_dem)/dx;
grady = (wsphere[j+1].radius_dem - wsphere[j-1].radius_dem)/dy;
norm = sqrt(vscale2 + gradx*gradx + grady*grady);
pscal = -gradx*light[0] - grady*light[1] + vscale1;
@ -511,8 +513,8 @@ void init_dem(t_wave_sphere wsphere[NX*NY], int dem_number)
/* i = N-1 */
for (j=1; j<NY-1; j++)
{
gradx = (wsphere[j].radius - wsphere[(NX-2)*NY+j].radius)/dx;
grady = (wsphere[(NX-1)*NY+j+1].radius - wsphere[(NX-1)*NY+j-1].radius)/dy;
gradx = (wsphere[j].radius_dem - wsphere[(NX-2)*NY+j].radius_dem)/dx;
grady = (wsphere[(NX-1)*NY+j+1].radius_dem - wsphere[(NX-1)*NY+j-1].radius_dem)/dy;
norm = sqrt(vscale2 + gradx*gradx + grady*grady);
pscal = -gradx*light[0] - grady*light[1] + vscale1;
@ -529,25 +531,25 @@ void init_dem(t_wave_sphere wsphere[NX*NY], int dem_number)
for (j=1; j<NY-1; j++)
{
/* computation of tangent vectors */
deltar = (wsphere[(i+1)*NY+j].radius - wsphere[i*NY+j].radius)/dphi;
deltar = (wsphere[(i+1)*NY+j].radius_dem - wsphere[i*NY+j].radius_dem)/dphi;
deltai[0] = -wsphere[i*NY+j].radius*wsphere[i*NY+j].sphi;
deltai[0] = -wsphere[i*NY+j].radius_dem*wsphere[i*NY+j].sphi;
deltai[0] += deltar*wsphere[i*NY+j].cphi;
deltai[1] = wsphere[i*NY+j].radius*wsphere[i*NY+j].cphi;
deltai[1] = wsphere[i*NY+j].radius_dem*wsphere[i*NY+j].cphi;
deltai[1] += deltar*wsphere[i*NY+j].sphi;
deltai[2] = -deltar*wsphere[i*NY+j].cottheta;
deltar = (wsphere[i*NY+j+1].radius - wsphere[i*NY+j].radius)/dtheta;
deltar = (wsphere[i*NY+j+1].radius_dem - wsphere[i*NY+j].radius_dem)/dtheta;
deltaj[0] = wsphere[i*NY+j].radius*wsphere[i*NY+j].cphi*wsphere[i*NY+j].ctheta;
deltaj[0] = wsphere[i*NY+j].radius_dem*wsphere[i*NY+j].cphi*wsphere[i*NY+j].ctheta;
deltaj[0] += deltar*wsphere[i*NY+j].cphi*wsphere[i*NY+j].stheta;
deltaj[1] = wsphere[i*NY+j].radius*wsphere[i*NY+j].sphi*wsphere[i*NY+j].ctheta;
deltaj[1] = wsphere[i*NY+j].radius_dem*wsphere[i*NY+j].sphi*wsphere[i*NY+j].ctheta;
deltaj[1] += deltar*wsphere[i*NY+j].sphi*wsphere[i*NY+j].stheta;
deltaj[2] = wsphere[i*NY+j].radius*wsphere[i*NY+j].stheta;
deltaj[2] = wsphere[i*NY+j].radius_dem*wsphere[i*NY+j].stheta;
deltaj[2] += -deltar*wsphere[i*NY+j].ctheta;
/* computation of normal vector */
@ -565,25 +567,25 @@ void init_dem(t_wave_sphere wsphere[NX*NY], int dem_number)
for (j=1; j<NY-1; j++)
{
/* computation of tangent vectors */
deltar = (wsphere[NY+j].radius - wsphere[j].radius)/dphi;
deltar = (wsphere[NY+j].radius_dem - wsphere[j].radius_dem)/dphi;
deltai[0] = -wsphere[j].radius*wsphere[j].sphi;
deltai[0] = -wsphere[j].radius_dem*wsphere[j].sphi;
deltai[0] += deltar*wsphere[j].cphi;
deltai[1] = wsphere[j].radius*wsphere[j].cphi;
deltai[1] = wsphere[j].radius_dem*wsphere[j].cphi;
deltai[1] += deltar*wsphere[j].sphi;
deltai[2] = -deltar*wsphere[j].cottheta;
deltar = (wsphere[j+1].radius - wsphere[j].radius)/dtheta;
deltar = (wsphere[j+1].radius_dem - wsphere[j].radius_dem)/dtheta;
deltaj[0] = wsphere[j].radius*wsphere[j].cphi*wsphere[j].ctheta;
deltaj[0] = wsphere[j].radius_dem*wsphere[j].cphi*wsphere[j].ctheta;
deltaj[0] += deltar*wsphere[j].cphi*wsphere[j].stheta;
deltaj[1] = wsphere[j].radius*wsphere[j].sphi*wsphere[j].ctheta;
deltaj[1] = wsphere[j].radius_dem*wsphere[j].sphi*wsphere[j].ctheta;
deltaj[1] += deltar*wsphere[j].sphi*wsphere[j].stheta;
deltaj[2] = wsphere[j].radius*wsphere[j].stheta;
deltaj[2] = wsphere[j].radius_dem*wsphere[j].stheta;
deltaj[2] += -deltar*wsphere[j].ctheta;
/* computation of normal vector */
@ -601,25 +603,25 @@ void init_dem(t_wave_sphere wsphere[NX*NY], int dem_number)
for (j=1; j<NY-1; j++)
{
/* computation of tangent vectors */
deltar = (wsphere[j].radius - wsphere[(NX-1)*NY+j].radius)/dphi;
deltar = (wsphere[j].radius_dem - wsphere[(NX-1)*NY+j].radius_dem)/dphi;
deltai[0] = -wsphere[(NX-1)*NY+j].radius*wsphere[(NX-1)*NY+j].sphi;
deltai[0] = -wsphere[(NX-1)*NY+j].radius_dem*wsphere[(NX-1)*NY+j].sphi;
deltai[0] += deltar*wsphere[(NX-1)*NY+j].cphi;
deltai[1] = wsphere[(NX-1)*NY+j].radius*wsphere[(NX-1)*NY+j].cphi;
deltai[1] = wsphere[(NX-1)*NY+j].radius_dem*wsphere[(NX-1)*NY+j].cphi;
deltai[1] += deltar*wsphere[(NX-1)*NY+j].sphi;
deltai[2] = -deltar*wsphere[(NX-1)*NY+j].cottheta;
deltar = (wsphere[(NX-1)*NY+j+1].radius - wsphere[(NX-1)*NY+j].radius)/dtheta;
deltar = (wsphere[(NX-1)*NY+j+1].radius_dem - wsphere[(NX-1)*NY+j].radius_dem)/dtheta;
deltaj[0] = wsphere[(NX-1)*NY+j].radius*wsphere[(NX-1)*NY+j].cphi*wsphere[(NX-1)*NY+j].ctheta;
deltaj[0] = wsphere[(NX-1)*NY+j].radius_dem*wsphere[(NX-1)*NY+j].cphi*wsphere[(NX-1)*NY+j].ctheta;
deltaj[0] += deltar*wsphere[(NX-1)*NY+j].cphi*wsphere[(NX-1)*NY+j].stheta;
deltaj[1] = wsphere[(NX-1)*NY+j].radius*wsphere[(NX-1)*NY+j].sphi*wsphere[(NX-1)*NY+j].ctheta;
deltaj[1] = wsphere[(NX-1)*NY+j].radius_dem*wsphere[(NX-1)*NY+j].sphi*wsphere[(NX-1)*NY+j].ctheta;
deltaj[1] += deltar*wsphere[(NX-1)*NY+j].sphi*wsphere[(NX-1)*NY+j].stheta;
deltaj[2] = wsphere[(NX-1)*NY+j].radius*wsphere[(NX-1)*NY+j].stheta;
deltaj[2] = wsphere[(NX-1)*NY+j].radius_dem*wsphere[(NX-1)*NY+j].stheta;
deltaj[2] += -deltar*wsphere[(NX-1)*NY+j].ctheta;
/* computation of normal vector */
@ -739,7 +741,7 @@ void init_planet_map(t_wave_sphere wsphere[NX*NY], int planet)
{
int i, j, ii, jj, k, nx, ny, maxrgb, nmaxpixels, scan, rgbval, diff, sshift, nshift, ishift, dem_number;
int *rgb_values;
double cratio, rx, ry, cy;
double cratio, rx, ry, cy, vshift;
FILE *image_file;
switch (planet){
@ -831,6 +833,7 @@ void init_planet_map(t_wave_sphere wsphere[NX*NY], int planet)
/* decide which points are in the Sea */
wsphere[i*NY+j].indomain = 1;
wsphere[i*NY+j].draw_wave = 1;
// wsphere[i*NY+j].indomain = 0;
// wsphere[i*NY+j].indomain = (diff < 15);
}
@ -864,12 +867,13 @@ void init_planet_map(t_wave_sphere wsphere[NX*NY], int planet)
if (ADD_DEM) init_dem(wsphere, dem_number);
vshift = PLANET_SEALEVEL/(DEM_MAXHEIGHT - DEM_MAXDEPTH);
for (i=0; i<NX; i++)
for (j=0; j<NY; j++)
wsphere[i*NY+j].indomain = (wsphere[i*NY+j].altitude < PLANET_SEALEVEL/DEM_MAXHEIGHT);
wsphere[i*NY+j].indomain = (wsphere[i*NY+j].altitude < vshift);
}
int ij_to_sphere(int i, int j, double r, t_wave_sphere wsphere[NX*NY], double xyz[3])
int ij_to_sphere(int i, int j, double r, t_wave_sphere wsphere[NX*NY], double xyz[3], int use_wave_radius)
/* convert spherical to rectangular coordinates */
{
double pscal, newr;
@ -888,10 +892,20 @@ int ij_to_sphere(int i, int j, double r, t_wave_sphere wsphere[NX*NY], double xy
pscal = xyz[0]*observer[0] + xyz[1]*observer[1] + xyz[2]*observer[2];
newr = wsphere[i*NY+j].radius;
xyz[0] *= newr;
xyz[1] *= newr;
xyz[2] *= newr;
if (use_wave_radius)
{
newr = wsphere[i*NY+j].radius;
xyz[0] *= newr;
xyz[1] *= newr;
xyz[2] *= newr;
}
else
{
newr = wsphere[i*NY+j].radius_dem;
xyz[0] *= newr;
xyz[1] *= newr;
xyz[2] *= newr;
}
return(pscal/norm_observer > COS_VISIBLE);
}
@ -1421,24 +1435,54 @@ void init_speed_dissipation_sphere(short int xy_in[NX*NY], double tc[NX*NY], dou
switch (IOR) {
case (IOR_EARTH_DEM):
{
#pragma omp parallel for private(i,j)
// #pragma omp parallel for private(i,j,courant2,courantb2,speed)
for (i=0; i<NX; i++){
for (j=0; j<NY; j++){
tc[i*NY+j] = COURANT;
tgamma[i*NY+j] = GAMMA;
}
for (j=DPOLE; j<NY-DPOLE; j++){
if (wsphere[i*NY+j].indomain)
tcc[i*NY+j] = COURANT;
{
tcc[i*NY+j] = courant2;
tc[i*NY+j] = COURANT;
tgamma[i*NY+j] = GAMMA;
}
else
{
speed = 1.0 - 10.0*wsphere[i*NY+j].altitude;
if (speed < 0.0) speed = 0.0;
tcc[i*NY+j] = COURANT*speed + COURANTB*(1.0 - speed);
tcc[i*NY+j] = courant2*speed + courantb2*(1.0 - speed);
tc[i*NY+j] = COURANT*speed + COURANTB*(1.0 - speed);
tgamma[i*NY+j] = GAMMA*speed + GAMMAB*(1.0 - speed);
}
}
for (j=0; j<DPOLE; j++) tcc[i*NY+j] = COURANT;
for (j=NY-DPOLE; j<NY; j++) tcc[i*NY+j] = COURANT;
for (j=0; j<DPOLE; j++)
{
if (wsphere[i*NY+j].indomain)
{
tcc[i*NY+j] = courant2;
tc[i*NY+j] = COURANT;
tgamma[i*NY+j] = GAMMA;
}
else
{
tcc[i*NY+j] = courantb2;
tc[i*NY+j] = COURANTB;
tgamma[i*NY+j] = GAMMAB;
}
}
for (j=NY-DPOLE; j<NY; j++)
{
if (wsphere[i*NY+j].indomain)
{
tcc[i*NY+j] = courant2;
tc[i*NY+j] = COURANT;
tgamma[i*NY+j] = GAMMA;
}
else
{
tcc[i*NY+j] = courantb2;
tc[i*NY+j] = COURANTB;
tgamma[i*NY+j] = GAMMAB;
}
}
}
break;
}
@ -1447,7 +1491,7 @@ void init_speed_dissipation_sphere(short int xy_in[NX*NY], double tc[NX*NY], dou
for (i=0; i<NX; i++){
for (j=0; j<NY; j++){
tc[i*NY+j] = COURANT;
tcc[i*NY+j] = COURANT;
tcc[i*NY+j] = courant2;
tgamma[i*NY+j] = GAMMA;
}
}
@ -1580,38 +1624,158 @@ void add_circular_wave_sphere(double amp, double phi0, double theta0, double phi
}
void compute_light_angle_sphere(short int xy_in[NX*NY], t_wave wave[NX*NY], t_wave_sphere wsphere[NX*NY], int movie)
void init_tidal_wave_sphere(double phi0, double land_factor, double phi[NX*NY], double psi[NX*NY], short int xy_in[NX*NY], t_wave_sphere wsphere[NX*NY])
/* initialise field for "tidal" simulation - phi is wave height, psi is phi at time t-1 */
/* phi0 is longidude, theta0 is latitude */
{
int i, j, jmin, jmax;
double xy[2], pscal, dist, dist2, stheta, ctheta, phishift, phaseshift;
phishift = ZERO_MERIDIAN*PI/180.0;
phaseshift = 0.0;
/* safety distance to avoid singularity at poles */
jmin = DPOLE;
jmax = NY-DPOLE;
printf("Initializing wave\n");
// #pragma omp parallel for private(i,j,xy,dist2)
for (i=0; i<NX; i++)
{
if (i%100 == 0) printf("Initializing column %i of %i\n", i, NX);
for (j=jmin; j<jmax; j++)
{
xy_in[i*NY+j] = xy_in_billiard_sphere(i, j, wsphere);
if ((xy_in[i*NY+j])||(TWOSPEEDS))
// if (xy_in[i*NY+j])
{
phi[i*NY+j] = INITIAL_AMP*wsphere[i*NY+j].stheta*sin(2.0*(wsphere[i*NY+j].phi - phi0 - phishift));
if (xy_in[i*NY+j] == 0) phi[i*NY+j] *= land_factor;
}
else phi[i*NY+j] = 0.0;
psi[i*NY+j] = 0.0;
}
for (j=0; j<jmin; j++)
{
phi[i*NY+j] = 0.0;
psi[i*NY+j] = 0.0;
}
for (j=jmax; j<NY; j++)
{
phi[i*NY+j] = 0.0;
psi[i*NY+j] = 0.0;
}
}
}
void init_moving_tidal_wave_sphere(double phi0, double voverc, double land_factor, double phi[NX*NY], double psi[NX*NY], short int xy_in[NX*NY], t_wave_sphere wsphere[NX*NY])
/* initialise field for "tidal" simulation - phi is wave height, psi is phi at time t-1 */
/* phi0 is longidude, theta0 is latitude */
{
int i, j, jmin, jmax, inew;
double xy[2], pscal, dist, dist2, stheta, ctheta, phishift, deltaphi, factor;
phishift = ZERO_MERIDIAN*PI/180.0;
deltaphi = voverc*COURANT/(double)NX;
// phi1 = phi0 - vphi*DPI/(double)NX;
/* safety distance to avoid singularity at poles */
jmin = DPOLE;
jmax = NY-DPOLE;
printf("Initializing wave\n");
// #pragma omp parallel for private(i,j,xy,dist2)
for (i=0; i<NX; i++)
{
if (i%100 == 0) printf("Initializing column %i of %i\n", i, NX);
for (j=jmin; j<jmax; j++)
{
xy_in[i*NY+j] = xy_in_billiard_sphere(i, j, wsphere);
if ((xy_in[i*NY+j])||(TWOSPEEDS))
{
phi[i*NY+j] = INITIAL_AMP*wsphere[i*NY+j].stheta*sin(2.0*(wsphere[i*NY+j].phi - phi0 - phishift));
psi[i*NY+j] = INITIAL_AMP*wsphere[i*NY+j].stheta*sin(2.0*(wsphere[i*NY+j].phi - phi0 - phishift - deltaphi));
// phi[i*NY+j] += 0.1*INITIAL_AMP*sin(2.0*wsphere[i*NY+j].theta)*sin(7.0*(wsphere[i*NY+j].phi - phi0 - phishift));
// psi[i*NY+j] += 0.1*INITIAL_AMP*sin(2.0*wsphere[i*NY+j].theta)*sin(7.0*(wsphere[i*NY+j].phi - phi0 - phishift - deltaphi));
}
else
{
phi[i*NY+j] = 0.0;
psi[i*NY+j] = 0.0;
}
}
for (j=0; j<jmin; j++)
{
phi[i*NY+j] = 0.0;
psi[i*NY+j] = 0.0;
}
for (j=jmax; j<NY; j++)
{
phi[i*NY+j] = 0.0;
psi[i*NY+j] = 0.0;
}
}
for (i=0; i<NX; i++)
{
// if (i%100 == 0) printf("Initializing column %i of %i\n", i, NX);
for (j=jmin; j<jmax; j++) if (xy_in[i*NY+j] == 0)
{
factor = 1.0 - land_factor*wsphere[i*NY+j].altitude;
if (factor < 0.0) factor = 0.0;
phi[i*NY+j] *= factor;
psi[i*NY+j] *= factor;
}
}
}
void compute_light_angle_sphere(double phi[NX*NY], short int xy_in[NX*NY], t_wave wave[NX*NY], t_wave_sphere wsphere[NX*NY], int movie, int transparent)
/* computes cosine of angle between normal vector and vector light */
{
int i, j;
double x, y, z, norm, pscal, deltai[3], deltaj[3], deltar, n[3], r;
static double dphi, dtheta;
static double dphi, dtheta, vshift;
static int first = 1;
if (first)
{
dphi = DPI/(double)NX;
dtheta = PI/(double)NY;
vshift = PLANET_SEALEVEL/(DEM_MAXHEIGHT - DEM_MAXDEPTH);
first = 0;
}
#pragma omp parallel for private(i,j)
for (i=0; i<NX; i++)
{
for (j=0; j<NY - DPOLE; j++) if (xy_in[i*NY+j])
for (j=0; j<NY - DPOLE; j++) if ((TWOSPEEDS)||(xy_in[i*NY+j]))
{
// r = 1.01 + RSCALE*(*wave[i*NY+j].p_zfield[movie]);
r = 1.0 + RSCALE*(*wave[i*NY+j].p_zfield[movie]);
if (r > RMAX) r = RMAX;
if (r < RMIN) r = RMIN;
wsphere[i*NY+j].radius = r;
if (FLOODING)
wsphere[i*NY+j].draw_wave = (phi[i*NY+j] >= wsphere[i*NY+j].altitude - vshift);
// wsphere[i*NY+j].draw_wave = ((wsphere[i*NY+j].indomain)||(phi[i*NY+j] >= wsphere[i*NY+j].altitude - vshift));
}
/* TODO ? Avoid artifacts due to singularity at north pole */
for (j=NY - DPOLE; j<NY; j++) if (xy_in[i*NY+j])
for (j=NY - DPOLE; j<NY; j++) if ((TWOSPEEDS)||(xy_in[i*NY+j]))
{
r = 1.0 + RSCALE*(*wave[i*NY+j].p_zfield[movie]);
// r = 1.0 + RSCALE*(*wave[i*NY+j].p_zfield[movie]);
r = 1.01 + RSCALE*(*wave[i*NY+j].p_zfield[movie]);
if (r > RMAX) r = RMAX;
if (r < 1.0) r = 1.0;
wsphere[i*NY+j].radius = r;
if (FLOODING)
wsphere[i*NY+j].draw_wave = (phi[i*NY+j] >= wsphere[i*NY+j].altitude - vshift);
// wsphere[i*NY+j].draw_wave = ((wsphere[i*NY+j].indomain)||(phi[i*NY+j] >= wsphere[i*NY+j].altitude - vshift));
}
}
@ -1624,27 +1788,53 @@ void compute_light_angle_sphere(short int xy_in[NX*NY], t_wave wave[NX*NY], t_wa
if ((TWOSPEEDS)||(xy_in[i*NY+j]))
{
/* computation of tangent vectors */
deltar = (wsphere[(i+1)*NY+j].radius - wsphere[i*NY+j].radius)/dphi;
if (transparent)
{
deltar = (wsphere[(i+1)*NY+j].radius_dem - wsphere[i*NY+j].radius_dem)/dphi;
deltai[0] = -wsphere[i*NY+j].radius*wsphere[i*NY+j].sphi;
deltai[0] += deltar*wsphere[i*NY+j].cphi;
deltai[0] = -wsphere[i*NY+j].radius_dem*wsphere[i*NY+j].sphi;
deltai[0] += deltar*wsphere[i*NY+j].cphi;
deltai[1] = wsphere[i*NY+j].radius*wsphere[i*NY+j].cphi;
deltai[1] += deltar*wsphere[i*NY+j].sphi;
deltai[1] = wsphere[i*NY+j].radius_dem*wsphere[i*NY+j].cphi;
deltai[1] += deltar*wsphere[i*NY+j].sphi;
deltai[2] = -deltar*wsphere[i*NY+j].cottheta;
deltai[2] = -deltar*wsphere[i*NY+j].cottheta;
deltar = (wsphere[i*NY+j+1].radius - wsphere[i*NY+j].radius)/dtheta;
deltar = (wsphere[i*NY+j+1].radius_dem - wsphere[i*NY+j].radius_dem)/dtheta;
deltaj[0] = wsphere[i*NY+j].radius*wsphere[i*NY+j].cphi*wsphere[i*NY+j].ctheta;
deltaj[0] += deltar*wsphere[i*NY+j].cphi*wsphere[i*NY+j].stheta;
deltaj[0] = wsphere[i*NY+j].radius_dem*wsphere[i*NY+j].cphi*wsphere[i*NY+j].ctheta;
deltaj[0] += deltar*wsphere[i*NY+j].cphi*wsphere[i*NY+j].stheta;
deltaj[1] = wsphere[i*NY+j].radius*wsphere[i*NY+j].sphi*wsphere[i*NY+j].ctheta;
deltaj[1] += deltar*wsphere[i*NY+j].sphi*wsphere[i*NY+j].stheta;
deltaj[1] = wsphere[i*NY+j].radius_dem*wsphere[i*NY+j].sphi*wsphere[i*NY+j].ctheta;
deltaj[1] += deltar*wsphere[i*NY+j].sphi*wsphere[i*NY+j].stheta;
deltaj[2] = wsphere[i*NY+j].radius*wsphere[i*NY+j].stheta;
deltaj[2] += -deltar*wsphere[i*NY+j].ctheta;
deltaj[2] = wsphere[i*NY+j].radius_dem*wsphere[i*NY+j].stheta;
deltaj[2] += -deltar*wsphere[i*NY+j].ctheta;
}
else
{
deltar = (wsphere[(i+1)*NY+j].radius - wsphere[i*NY+j].radius)/dphi;
deltai[0] = -wsphere[i*NY+j].radius*wsphere[i*NY+j].sphi;
deltai[0] += deltar*wsphere[i*NY+j].cphi;
deltai[1] = wsphere[i*NY+j].radius*wsphere[i*NY+j].cphi;
deltai[1] += deltar*wsphere[i*NY+j].sphi;
deltai[2] = -deltar*wsphere[i*NY+j].cottheta;
deltar = (wsphere[i*NY+j+1].radius - wsphere[i*NY+j].radius)/dtheta;
deltaj[0] = wsphere[i*NY+j].radius*wsphere[i*NY+j].cphi*wsphere[i*NY+j].ctheta;
deltaj[0] += deltar*wsphere[i*NY+j].cphi*wsphere[i*NY+j].stheta;
deltaj[1] = wsphere[i*NY+j].radius*wsphere[i*NY+j].sphi*wsphere[i*NY+j].ctheta;
deltaj[1] += deltar*wsphere[i*NY+j].sphi*wsphere[i*NY+j].stheta;
deltaj[2] = wsphere[i*NY+j].radius*wsphere[i*NY+j].stheta;
deltaj[2] += -deltar*wsphere[i*NY+j].ctheta;
}
/* computation of normal vector */
n[0] = deltai[1]*deltaj[2] - deltai[2]*deltaj[1];
n[1] = deltai[2]*deltaj[0] - deltai[0]*deltaj[2];
@ -1666,8 +1856,81 @@ void compute_light_angle_sphere(short int xy_in[NX*NY], t_wave wave[NX*NY], t_wa
}
for (i=0; i<NX-1; i++) wave[i*NY+NY-1].cos_angle = wave[i*NY+NY-2].cos_angle;
for (j=0; j<NY-1; j++) wave[(NX-1)*NY+j].cos_angle = wave[(NX-2)*NY+j].cos_angle;
// for (j=0; j<NY-1; j++) wave[(NX-1)*NY+j].cos_angle = wave[(NX-2)*NY+j].cos_angle;
wave[(NX-1)*NY+NY-1].cos_angle = wave[(NX-1)*NY+NY-2].cos_angle;
/* i = NX-1 */
for (j=0; j<NY-1; j++)
{
if ((TWOSPEEDS)||(xy_in[(NX-1)*NY+j]))
{
/* computation of tangent vectors */
if (transparent)
{
deltar = (wsphere[j].radius_dem - wsphere[(NX-1)*NY+j].radius_dem)/dphi;
deltai[0] = -wsphere[(NX-1)*NY+j].radius_dem*wsphere[(NX-1)*NY+j].sphi;
deltai[0] += deltar*wsphere[(NX-1)*NY+j].cphi;
deltai[1] = wsphere[(NX-1)*NY+j].radius_dem*wsphere[(NX-1)*NY+j].cphi;
deltai[1] += deltar*wsphere[(NX-1)*NY+j].sphi;
deltai[2] = -deltar*wsphere[(NX-1)*NY+j].cottheta;
deltar = (wsphere[(NX-1)*NY+j+1].radius_dem - wsphere[(NX-1)*NY+j].radius_dem)/dtheta;
deltaj[0] = wsphere[(NX-1)*NY+j].radius_dem*wsphere[(NX-1)*NY+j].cphi*wsphere[(NX-1)*NY+j].ctheta;
deltaj[0] += deltar*wsphere[(NX-1)*NY+j].cphi*wsphere[(NX-1)*NY+j].stheta;
deltaj[1] = wsphere[(NX-1)*NY+j].radius_dem*wsphere[(NX-1)*NY+j].sphi*wsphere[(NX-1)*NY+j].ctheta;
deltaj[1] += deltar*wsphere[(NX-1)*NY+j].sphi*wsphere[(NX-1)*NY+j].stheta;
deltaj[2] = wsphere[(NX-1)*NY+j].radius_dem*wsphere[(NX-1)*NY+j].stheta;
deltaj[2] += -deltar*wsphere[(NX-1)*NY+j].ctheta;
}
else
{
deltar = (wsphere[j].radius - wsphere[(NX-1)*NY+j].radius)/dphi;
deltai[0] = -wsphere[(NX-1)*NY+j].radius*wsphere[(NX-1)*NY+j].sphi;
deltai[0] += deltar*wsphere[(NX-1)*NY+j].cphi;
deltai[1] = wsphere[(NX-1)*NY+j].radius*wsphere[(NX-1)*NY+j].cphi;
deltai[1] += deltar*wsphere[(NX-1)*NY+j].sphi;
deltai[2] = -deltar*wsphere[(NX-1)*NY+j].cottheta;
deltar = (wsphere[(NX-1)*NY+j+1].radius - wsphere[(NX-1)*NY+j].radius)/dtheta;
deltaj[0] = wsphere[(NX-1)*NY+j].radius*wsphere[(NX-1)*NY+j].cphi*wsphere[(NX-1)*NY+j].ctheta;
deltaj[0] += deltar*wsphere[(NX-1)*NY+j].cphi*wsphere[(NX-1)*NY+j].stheta;
deltaj[1] = wsphere[(NX-1)*NY+j].radius*wsphere[(NX-1)*NY+j].sphi*wsphere[(NX-1)*NY+j].ctheta;
deltaj[1] += deltar*wsphere[(NX-1)*NY+j].sphi*wsphere[(NX-1)*NY+j].stheta;
deltaj[2] = wsphere[(NX-1)*NY+j].radius*wsphere[(NX-1)*NY+j].stheta;
deltaj[2] += -deltar*wsphere[(NX-1)*NY+j].ctheta;
}
/* computation of normal vector */
n[0] = deltai[1]*deltaj[2] - deltai[2]*deltaj[1];
n[1] = deltai[2]*deltaj[0] - deltai[0]*deltaj[2];
n[2] = deltai[0]*deltaj[1] - deltai[1]*deltaj[0];
norm = sqrt(n[0]*n[0] + n[1]*n[1] + n[2]*n[2]);
pscal = n[0]*light[0] + n[1]*light[1] + n[2]*light[2];
wave[(NX-1)*NY+j].cos_angle = pscal/norm;
}
// else wave[i*NY+j].cos_angle = wsphere[i*NY+j].cos_angle;
else
{
pscal = wsphere[(NX-1)*NY+j].x*light[0] + wsphere[(NX-1)*NY+j].y*light[1] + wsphere[(NX-1)*NY+j].z*light[2];
wave[(NX-1)*NY+j].cos_angle = pscal;
}
}
}
else
{
@ -1685,13 +1948,13 @@ void compute_light_angle_sphere(short int xy_in[NX*NY], t_wave wave[NX*NY], t_wa
}
}
void compute_light_angle_sphere_2d(short int xy_in[NX*NY], double phi[NX*NY], t_wave wave[NX*NY], t_wave_sphere wsphere[NX*NY], int movie)
void compute_light_angle_sphere_2d(short int xy_in[NX*NY], double phi[NX*NY], t_wave wave[NX*NY], t_wave_sphere wsphere[NX*NY], int movie, int transparent)
/* computes cosine of angle between normal vector and vector light */
{
int i, j;
short int draw;
double gradx, grady, norm, pscal;
static double dx, dy, vscale2;
static double dx, dy, vscale2, vshift;
static int first = 1;
if (first)
@ -1699,6 +1962,7 @@ void compute_light_angle_sphere_2d(short int xy_in[NX*NY], double phi[NX*NY], t_
dx = 2.0*(XMAX - XMIN)/(double)NX;
dy = 2.0*(YMAX - YMIN)/(double)NY;
vscale2 = SHADE_SCALE_2D*SHADE_SCALE_2D;
vshift = PLANET_SEALEVEL/(DEM_MAXHEIGHT-DEM_MAXDEPTH);
first = 0;
}
@ -1708,12 +1972,25 @@ void compute_light_angle_sphere_2d(short int xy_in[NX*NY], double phi[NX*NY], t_
{
// if ((TWOSPEEDS)||(xy_in[i*NY+j]))
// if ((wsphere[i*NY+j].indomain)||(phi[i*NY+j] >= wsphere[i*NY+j].altitude + 0.001))
if (FLOODING) draw = ((wsphere[i*NY+j].indomain)||(phi[i*NY+j] >= wsphere[i*NY+j].altitude + 0.001));
else draw = ((TWOSPEEDS)||(xy_in[i*NY+j]));
if (FLOODING)
{
draw = (phi[i*NY+j] >= wsphere[i*NY+j].altitude - vshift);
wsphere[i*NY+j].draw_wave = draw;
}
// else draw = ((TWOSPEEDS)||(xy_in[i*NY+j]));
else draw = ((xy_in[i*NY+j]));
if (draw)
{
gradx = (*wave[(i+1)*NY+j].p_zfield[movie] - *wave[(i-1)*NY+j].p_zfield[movie])/dx;
grady = (*wave[i*NY+j+1].p_zfield[movie] - *wave[i*NY+j-1].p_zfield[movie])/dy;
if (transparent)
{
gradx = (wsphere[(i+1)*NY+j].radius_dem - wsphere[(i-1)*NY+j].radius_dem)/dx;
grady = (wsphere[i*NY+j+1].radius_dem - wsphere[i*NY+j-1].radius_dem)/dy;
}
else
{
gradx = (*wave[(i+1)*NY+j].p_zfield[movie] - *wave[(i-1)*NY+j].p_zfield[movie])/dx;
grady = (*wave[i*NY+j+1].p_zfield[movie] - *wave[i*NY+j-1].p_zfield[movie])/dy;
}
norm = sqrt(vscale2 + gradx*gradx + grady*grady);
pscal = -gradx*light[0] - grady*light[1] + SHADE_SCALE_2D;
@ -1727,11 +2004,26 @@ void compute_light_angle_sphere_2d(short int xy_in[NX*NY], double phi[NX*NY], t_
for (j=1; j<NY-1; j++)
{
// if ((TWOSPEEDS)||(xy_in[j]))
if ((wsphere[j].indomain)||(phi[j] >= wsphere[j].altitude + 0.001))
if (FLOODING)
{
gradx = (*wave[NY+j].p_zfield[movie] - *wave[(NY-1)*NY+j].p_zfield[movie])/dx;
grady = (*wave[j+1].p_zfield[movie] - *wave[j-1].p_zfield[movie])/dy;
draw = (phi[j] >= wsphere[j].altitude - vshift);
wsphere[j].draw_wave = draw;
}
else draw = ((xy_in[j]));
if (draw)
{
if (transparent)
{
gradx = (wsphere[NY+j].radius_dem - wsphere[(NX-1)*NY+j].radius_dem)/dx;
grady = (wsphere[j+1].radius_dem - wsphere[j-1].radius_dem)/dy;
}
else
{
gradx = (*wave[NY+j].p_zfield[movie] - *wave[(NY-1)*NY+j].p_zfield[movie])/dx;
grady = (*wave[j+1].p_zfield[movie] - *wave[j-1].p_zfield[movie])/dy;
}
norm = sqrt(vscale2 + gradx*gradx + grady*grady);
pscal = -gradx*light[0] - grady*light[1] + SHADE_SCALE_2D;
@ -1744,11 +2036,26 @@ void compute_light_angle_sphere_2d(short int xy_in[NX*NY], double phi[NX*NY], t_
for (j=1; j<NY-1; j++)
{
// if ((TWOSPEEDS)||(xy_in[(NX-1)*NY+j]))
if ((wsphere[(NX-1)*NY+j].indomain)||(phi[(NX-1)*NY+j] >= wsphere[(NX-1)*NY+j].altitude + 0.001))
if (FLOODING)
{
gradx = (*wave[j].p_zfield[movie] - *wave[(NX-2)*NY+j].p_zfield[movie])/dx;
grady = (*wave[(NX-1)*NY+j+1].p_zfield[movie] - *wave[(NX-1)*NY+j-1].p_zfield[movie])/dy;
draw = (phi[(NX-1)*NY+j] >= wsphere[(NX-1)*NY+j].altitude - vshift);
wsphere[(NX-1)*NY+j].draw_wave = draw;
}
else draw = ((xy_in[(NX-1)*NY+j]));
if (draw)
{
if (transparent)
{
gradx = (wsphere[j].radius_dem - wsphere[(NX-2)*NY+j].radius_dem)/dx;
grady = (wsphere[(NX-1)*NY+j+1].radius_dem - wsphere[(NX-1)*NY+j-1].radius_dem)/dy;
}
else
{
gradx = (*wave[NY+j].p_zfield[movie] - *wave[(NY-1)*NY+j].p_zfield[movie])/dx;
grady = (*wave[j+1].p_zfield[movie] - *wave[j-1].p_zfield[movie])/dy;
}
norm = sqrt(vscale2 + gradx*gradx + grady*grady);
pscal = -gradx*light[0] - grady*light[1] + SHADE_SCALE_2D;
@ -1798,11 +2105,12 @@ void draw_wave_sphere_2D(int movie, double phi[NX*NY], double psi[NX*NY], short
static int ishift;
static double dx, dy;
if (refresh)
if (1)
{
compute_wave_fields(phi, psi, xy_in, zplot, cplot, wave);
if (SHADE_3D) compute_light_angle_sphere(xy_in, wave, wsphere, movie);
else if (SHADE_2D) compute_light_angle_sphere_2d(xy_in, phi, wave, wsphere, movie);
if (SHADE_3D) compute_light_angle_sphere(phi, xy_in, wave, wsphere, movie, TRANSPARENT_WAVE);
else if (SHADE_2D)
compute_light_angle_sphere_2d(xy_in, phi, wave, wsphere, movie, TRANSPARENT_WAVE);
compute_cfield_sphere(xy_in, cplot, palette, wave, fade, fade_value, movie);
dx = (XMAX - XMIN)/(double)NX;
dy = (YMAX - YMIN)/(double)(NY-2*DPOLE);
@ -1814,8 +2122,10 @@ void draw_wave_sphere_2D(int movie, double phi[NX*NY], double psi[NX*NY], short
for (i=0; i<NX; i++)
for (j=0; j<NY; j++)
{
if (FLOODING) draw = (wsphere[i*NY+j].indomain)||(phi[i*NY+j] >= wsphere[i*NY+j].altitude + 0.001);
else draw = (TWOSPEEDS)||(xy_in[i*NY+j]);
// if (FLOODING) draw = (wsphere[i*NY+j].indomain)||(phi[i*NY+j] >= wsphere[i*NY+j].altitude + 0.001);
// else draw = (TWOSPEEDS)||(xy_in[i*NY+j]);
if (FLOODING) draw = wsphere[i*NY+j].draw_wave;
else draw = (xy_in[i*NY+j]);
if (draw)
glColor3f(wave[i*NY+j].rgb[0], wave[i*NY+j].rgb[1], wave[i*NY+j].rgb[2]);
else
@ -1840,13 +2150,25 @@ void draw_wave_sphere_2D(int movie, double phi[NX*NY], double psi[NX*NY], short
glVertex2i(ii, j+1);
}
glEnd ();
if (DRAW_MOON_POSITION)
{
ii = NX-moon_position-1+ishift;
if (ii > NX) ii -= NX;
else if (ii < 0) ii += NX;
glColor3f(fade_value, fade_value, fade_value);
glBegin(GL_LINE_STRIP);
glVertex2i(ii, 0);
glVertex2i(ii, NY);
glEnd();
}
}
void draw_wave_sphere_ij(int i, int iplus, int j, int jplus, int jcolor, int movie, double phi[NX*NY], double psi[NX*NY], short int xy_in[NX*NY], t_wave wave[NX*NY], t_wave_sphere wsphere[NX*NY], int zplot, int cplot, int palette, int fade, double fade_value)
/* draw wave at simulation grid point (i,j) */
{
int k, l;
short int draw, draw_bc=1;
short int draw, notdraw, draw_bc=1;
double xyz[3], ca;
if (NON_DIRICHLET_BC)
@ -1855,8 +2177,11 @@ void draw_wave_sphere_ij(int i, int iplus, int j, int jplus, int jcolor, int mov
// if ((TWOSPEEDS)||(xy_in[i*NY+j]))
// if (wsphere[i*NY+j].indomain)
// if ((wsphere[i*NY+j].indomain)||(phi[i*NY+j] >= wsphere[i*NY+j].altitude + 0.001))
if (FLOODING) draw = (wsphere[i*NY+j].indomain)||(phi[i*NY+j] >= wsphere[i*NY+j].altitude + 0.001);
else draw = ((TWOSPEEDS)||(xy_in[i*NY+j]));
// if (FLOODING) draw = (wsphere[i*NY+j].indomain)||(phi[i*NY+j] >= wsphere[i*NY+j].altitude + 0.001);
// if (FLOODING) draw = (wsphere[i*NY+j].indomain)||(phi[i*NY+j] >= wsphere[i*NY+j].altitude);
if (FLOODING) draw = wsphere[i*NY+j].draw_wave;
// else draw = ((TWOSPEEDS)||(xy_in[i*NY+j]));
else draw = (xy_in[i*NY+j]);
if (draw) glColor3f(wave[i*NY+jcolor].rgb[0], wave[i*NY+jcolor].rgb[1], wave[i*NY+jcolor].rgb[2]);
else
{
@ -1868,16 +2193,30 @@ void draw_wave_sphere_ij(int i, int iplus, int j, int jplus, int jcolor, int mov
glColor3f(wsphere[i*NY+j].r*ca, wsphere[i*NY+j].g*ca, wsphere[i*NY+j].b*ca);
else glColor3f(COLOR_OUT_R*ca, COLOR_OUT_G*ca, COLOR_OUT_B*ca);
}
if (draw_bc)
if (FLOODING)
{
glBegin(GL_TRIANGLE_FAN);
if (ij_to_sphere(i, j, *wave[i*NY+j].p_zfield[movie], wsphere, xyz))
if (ij_to_sphere(i, j, *wave[i*NY+j].p_zfield[movie], wsphere, xyz, wsphere[i*NY+j].draw_wave))
draw_vertex_sphere(xyz);
if (ij_to_sphere(iplus, j, *wave[iplus*NY+j].p_zfield[movie], wsphere, xyz))
if (ij_to_sphere(iplus, j, *wave[iplus*NY+j].p_zfield[movie], wsphere, xyz, wsphere[iplus*NY+j].draw_wave))
draw_vertex_sphere(xyz);
if (ij_to_sphere(iplus, jplus, *wave[iplus*NY+j+1].p_zfield[movie], wsphere, xyz))
if (ij_to_sphere(iplus, jplus, *wave[iplus*NY+j+1].p_zfield[movie], wsphere, xyz, wsphere[iplus*NY+j+1].draw_wave))
draw_vertex_sphere(xyz);
if (ij_to_sphere(i, jplus, *wave[i*NY+j+1].p_zfield[movie], wsphere, xyz))
if (ij_to_sphere(i, jplus, *wave[i*NY+j+1].p_zfield[movie], wsphere, xyz, wsphere[i*NY+j+1].draw_wave))
draw_vertex_sphere(xyz);
glEnd ();
}
else if (draw_bc)
{
notdraw = (!draw);
glBegin(GL_TRIANGLE_FAN);
if (ij_to_sphere(i, j, *wave[i*NY+j].p_zfield[movie], wsphere, xyz, notdraw))
draw_vertex_sphere(xyz);
if (ij_to_sphere(iplus, j, *wave[iplus*NY+j].p_zfield[movie], wsphere, xyz, notdraw))
draw_vertex_sphere(xyz);
if (ij_to_sphere(iplus, jplus, *wave[iplus*NY+j+1].p_zfield[movie], wsphere, xyz, notdraw))
draw_vertex_sphere(xyz);
if (ij_to_sphere(i, jplus, *wave[i*NY+j+1].p_zfield[movie], wsphere, xyz, notdraw))
draw_vertex_sphere(xyz);
glEnd ();
}
@ -1894,8 +2233,8 @@ void draw_wave_sphere_3D(int movie, double phi[NX*NY], double psi[NX*NY], short
if (refresh)
{
compute_wave_fields(phi, psi, xy_in, zplot, cplot, wave);
if (SHADE_3D) compute_light_angle_sphere(xy_in, wave, wsphere, movie);
else if (SHADE_2D) compute_light_angle_sphere_2d(xy_in, phi, wave, wsphere, movie);
if (SHADE_3D) compute_light_angle_sphere(phi, xy_in, wave, wsphere, movie, TRANSPARENT_WAVE);
else if (SHADE_2D) compute_light_angle_sphere_2d(xy_in, phi, wave, wsphere, movie, TRANSPARENT_WAVE);
compute_cfield_sphere(xy_in, cplot, palette, wave, fade, fade_value, movie);
}

View File

@ -632,6 +632,15 @@ void draw_tpolygon(t_polygon polygon)
glEnd();
}
double michelson_schedule(int i)
{
double t;
t = (double)(i - INITIAL_TIME)/(double)NSTEPS;
return(4.0*t*WALL_WIDTH);
// return(2.0*t*WALL_WIDTH);
}
int init_circle_config_pattern(t_circle circles[NMAXCIRCLES], int circle_pattern)
/* initialise the arrays circlex, circley, circlerad and circleactive */
@ -2444,7 +2453,7 @@ int xy_in_arc(double x, double y, t_arc arc)
int xy_in_billiard_single_domain(double x, double y, int b_domain, int ncirc, t_circle *circles)
/* returns 1 if (x,y) represents a point in the billiard */
{
double l2, r2, r2mu, omega, b, c, angle, z, x1, y1, x2, y2, y3, u, v, u1, v1, dx, dy, width, alpha, s, a, r, height, ca, sa, l, ht, xshift, zz[9][2], x5, x6, f, fp;
double l2, r1, r2, r2mu, omega, b, c, d, angle, z, x1, y1, x2, y2, y3, u, v, u1, v1, dx, dy, width, alpha, s, a, r, height, ca, sa, l, ht, xshift, zz[9][2], x5, x6, f, fp, h1;
int i, j, k, k1, k2, condition = 0, m;
static int first = 1, nsides;
static double h, hh, ra, rb, ll, salpha;
@ -3067,7 +3076,7 @@ int xy_in_billiard_single_domain(double x, double y, int b_domain, int ncirc, t_
}
case (D_WAVEGUIDES_COUPLED):
{
x1 = vabs(x);
x1 = vabs(x)*2.0/XMAX;
y1 = vabs(y);
width = 0.03;
@ -3082,6 +3091,26 @@ int xy_in_billiard_single_domain(double x, double y, int b_domain, int ncirc, t_
return(vabs(f - y1) < MU*sqrt(1.0 + fp*fp));
}
case (D_WAVEGUIDES_COUPLED_N):
{
x1 = vabs(x);
y1 = vabs(y);
width = 0.01;
b = 1.0*(1.0 - 2.0*MU - width);
a = MU + 0.5*width - b;
c = 15.0;
x6 = x1*x1*x1;
x5 = x6*x1*x1;
x6 = x5*x1;
f = a + b*(1.0 + 2.0*c*x6)/(1.0 + c*x6);
fp = 6.0*b*c*x5/((1.0 + c*x6)*(1.0 + c*x6));
if (vabs(f - y1) < 0.9*MU*sqrt(1.0 + fp*fp)) return(1);
if (vabs(f - y1) < MU*sqrt(1.0 + fp*fp)) return(2);
return(0);
}
case (D_WAVEGUIDE_S):
{
a = 0.5*(1.0 - MU);
@ -3099,7 +3128,40 @@ int xy_in_billiard_single_domain(double x, double y, int b_domain, int ncirc, t_
}
r = module2(x-LAMBDA, y-a);
return(vabs(r - a) < MU);
}
case (D_WAVEGUIDE_S_SHORT):
{
a = -1.0 + MU;
if (y < 0.0)
{
x = -x;
y = -y;
}
if (x < -LAMBDA)
{
if (vabs(y - 1.0 + MU) > MU) return(0);
if (vabs(y - 1.0 + MU) > 0.8*MU) return(2);
return(1);
}
r = module2(x-a, y);
if (vabs(r - 1.0 + MU) < 0.8*MU) return(1);
if (vabs(r - 1.0 + MU) < MU) return(2);
return(0);
}
case (D_WAVEGUIDE_BADSPLICE):
{
if (x < 0.0)
{
y1 = vabs(vabs(y) - 0.5);
}
else
{
if (y > 0.0) y1 = vabs(y - 0.5 - MU);
else y1 = vabs(y + 0.5 - MU_B);
}
if (y1 < 0.9*LAMBDA) return(1);
if (y1 < LAMBDA) return(2);
return(0);
}
case (D_MAZE):
{
@ -3226,6 +3288,7 @@ int xy_in_billiard_single_domain(double x, double y, int b_domain, int ncirc, t_
a = 1.9;
b = 1.9 - 2.0*LAMBDA + 2.0*width;
x1 = vabs(x);
if ((x1 < WALL_WIDTH)&&(vabs(y) > MU)) return(2);
if (module2(x1 - a, y) > LAMBDA) return(1);
if (module2(x1 - b, y) > LAMBDA) return(1);
return(0);
@ -3332,6 +3395,54 @@ int xy_in_billiard_single_domain(double x, double y, int b_domain, int ncirc, t_
return(1);
}
case (D_MICHELSON):
{
if ((vabs(x) > LAMBDA)&&(vabs(y) > LAMBDA)) return(2);
r = 0.5*sqrt(2.0);
h = YMAX - 0.5*WALL_WIDTH;
x1 = (x + y)*r;
y1 = (-x + y)*r;
if ((vabs(y1) < 0.5*WALL_WIDTH)&&(vabs(x1) < LAMBDA*sqrt(2.0))) return(1);
if ((vabs(x - h) < 0.5*WALL_WIDTH)&&(vabs(y) < LAMBDA)) return(2);
if ((vabs(x) < LAMBDA)&&(vabs(y - h) < 0.5*WALL_WIDTH)) return(2);
return(0);
}
case (D_MICHELSON_MOVING):
{
if ((vabs(x) > LAMBDA)&&(vabs(y) > LAMBDA)) return(2);
r = 0.5*sqrt(2.0);
h = YMAX - MU - 0.5*WALL_WIDTH;
h1 = YMAX - MU - 0.5*WALL_WIDTH + michelson_position;
x1 = (x + y)*r;
y1 = (-x + y)*r;
if ((vabs(y1) < 0.5*WALL_WIDTH)&&(vabs(x1) < LAMBDA*sqrt(2.0))) return(1);
if ((vabs(x - h1) < 0.5*WALL_WIDTH)&&(vabs(y) < LAMBDA)) return(2);
if ((vabs(x) < LAMBDA)&&(vabs(y - h) < 0.5*WALL_WIDTH)) return(2);
return(0);
}
case (D_RITCHEY_CHRETIEN):
{
/* LAMBDA is magnification M */
d = 2.5;
b = 3.5;
r1 = 2.0*(d + b/LAMBDA);
r2 = 6.0/(LAMBDA - 1.0);
x1 = 0.5*d - r1;
x2 = -0.5*d - r2;
y1 = vabs(y);
if (x < 0.0)
{
if (y1 > 0.3) return(1);
if (x < -0.5*d - WALL_WIDTH) return(1);
return(module2(x-x2, y1) > r2);
}
else
{
if (y1 < MU) return(1);
if (x > 0.5*d + WALL_WIDTH) return(1);
return(module2(x-x1, y1) < r1);
}
}
case (D_MENGER):
{
x1 = 0.5*(x+1.0);
@ -3542,10 +3653,11 @@ void hex_transfo(double u, double v, double *x, double *y)
void draw_billiard(int fade, double fade_value) /* draws the billiard boundary */
{
double x0, y0, x, y, x1, y1, x2, y2, dx, dy, phi, r = 0.01, pos[2], pos1[2], alpha, dphi, omega, z, l, width, a, b, c, ymax, height, xmax, ca, sa, xshift, x5, x6, f, fp;
double x0, y0, x, y, x1, y1, x2, y2, dx, dy, phi, r = 0.01, pos[2], pos1[2], alpha, dphi, omega, z, l, width, a, b, c, d, r1, r2, ymax, height, xmin, xmax, ca, sa, xshift, x5, x6, f, fp, xratio, w;
int i, j, k, k1, k2, mr2, ntiles;
static int first = 1, nsides;
static double h, hh, sqr3, ll, salpha, arcangle;
char message[100];
if (fade)
{
@ -4542,18 +4654,21 @@ void draw_billiard(int fade, double fade_value) /* draws the billiard bound
case (D_WAVEGUIDES_COUPLED):
{
width = 0.03;
xratio = XMAX/2.0;
b = 1.0*(1.0 - 2.0*MU - width);
a = MU + 0.5*width - b;
if ((DRAW_WAVE_PROFILE)&&(VERTICAL_WAVE_PROFILE))
dx = (XMAX - XMIN - 0.06)/(double)NSEG;
else dx = (XMAX - XMIN + 0.1)/(double)NSEG;
dx = dx/xratio;
xmin = XMIN/xratio;
x1 = XMIN - 0.1;
x1 = xmin - 0.1;
y1 = 1.0;
for (i=0; i<NSEG; i++)
{
x2 = XMIN - 0.1 + (double)i*dx;
x2 = xmin - 0.1 + (double)i*dx;
x6 = x2*x2*x2;
x5 = x6*x2*x2;
x6 = x5*x2;
@ -4563,16 +4678,16 @@ void draw_billiard(int fade, double fade_value) /* draws the billiard bound
y2 = f + MU*sqrt(1.0 + fp*fp);
draw_line(x1, y1, x2, y2);
draw_line(x1*xratio, y1, x2*xratio, y2);
x1 = x2;
y1 = y2;
}
x1 = XMIN - 0.1;
x1 = xmin - 0.1;
y1 = 1.0;
for (i=0; i<NSEG; i++)
{
x2 = XMIN - 0.1 + (double)i*dx;
x2 = xmin - 0.1 + (double)i*dx;
x6 = x2*x2*x2;
x5 = x6*x2*x2;
x6 = x5*x2;
@ -4582,16 +4697,16 @@ void draw_billiard(int fade, double fade_value) /* draws the billiard bound
y2 = f - MU*sqrt(1.0 + fp*fp);
draw_line(x1, y1, x2, y2);
draw_line(x1*xratio, y1, x2*xratio, y2);
x1 = x2;
y1 = y2;
}
x1 = XMIN - 0.1;
x1 = xmin - 0.1;
y1 = -1.0;
for (i=0; i<NSEG; i++)
{
x2 = XMIN - 0.1 + (double)i*dx;
x2 = xmin - 0.1 + (double)i*dx;
x6 = x2*x2*x2;
x5 = x6*x2*x2;
x6 = x5*x2;
@ -4601,16 +4716,16 @@ void draw_billiard(int fade, double fade_value) /* draws the billiard bound
y2 = -(f + MU*sqrt(1.0 + fp*fp));
draw_line(x1, y1, x2, y2);
draw_line(x1*xratio, y1, x2*xratio, y2);
x1 = x2;
y1 = y2;
}
x1 = XMIN - 0.1;
x1 = xmin - 0.1;
y1 = -1.0;
for (i=0; i<NSEG; i++)
{
x2 = XMIN - 0.1 + (double)i*dx;
x2 = xmin - 0.1 + (double)i*dx;
x6 = x2*x2*x2;
x5 = x6*x2*x2;
x6 = x5*x2;
@ -4620,12 +4735,12 @@ void draw_billiard(int fade, double fade_value) /* draws the billiard bound
y2 = -f + MU*sqrt(1.0 + fp*fp);
draw_line(x1, y1, x2, y2);
draw_line(x1*xratio, y1, x2*xratio, y2);
x1 = x2;
y1 = y2;
}
x2 = LAMBDA;
x2 = LAMBDA/xratio;
x6 = x2*x2*x2;
x5 = x6*x2*x2;
x6 = x5*x2;
@ -4636,6 +4751,8 @@ void draw_billiard(int fade, double fade_value) /* draws the billiard bound
y1 = f - MU*sqrt(1.0 + fp*fp);
y2 = f + MU*sqrt(1.0 + fp*fp);
x2 = LAMBDA;
draw_line(x2, YMIN, x2, -y2);
draw_line(x2, -y1, x2, y1);
draw_line(x2, y2, x2, YMAX);
@ -4645,6 +4762,126 @@ void draw_billiard(int fade, double fade_value) /* draws the billiard bound
break;
}
case (D_WAVEGUIDES_COUPLED_N):
{
width = 0.01;
xratio = XMAX/2.0;
b = 1.0*(1.0 - 2.0*MU - width);
a = MU + 0.5*width - b;
c = 15.0;
if ((DRAW_WAVE_PROFILE)&&(VERTICAL_WAVE_PROFILE))
dx = (XMAX - XMIN - 0.06)/(double)NSEG;
else dx = (XMAX - XMIN + 0.1)/(double)NSEG;
dx = dx/xratio;
xmin = XMIN/xratio;
x1 = xmin - 0.1;
y1 = 1.0;
for (i=0; i<NSEG; i++)
{
x2 = xmin - 0.1 + (double)i*dx;
x6 = x2*x2*x2;
x5 = x6*x2*x2;
x6 = x5*x2;
f = a + b*(1.0 + 2.0*c*x6)/(1.0 + c*x6);
fp = 6.0*b*c*x5/((1.0 + c*x6)*(1.0 + c*x6));
y2 = f + MU*sqrt(1.0 + fp*fp);
draw_line(x1*xratio, y1, x2*xratio, y2);
x1 = x2;
y1 = y2;
}
x1 = xmin - 0.1;
y1 = 1.0;
for (i=0; i<NSEG; i++)
{
x2 = xmin - 0.1 + (double)i*dx;
x6 = x2*x2*x2;
x5 = x6*x2*x2;
x6 = x5*x2;
f = a + b*(1.0 + 2.0*c*x6)/(1.0 + c*x6);
fp = 6.0*b*c*x5/((1.0 + c*x6)*(1.0 + c*x6));
y2 = f - MU*sqrt(1.0 + fp*fp);
draw_line(x1*xratio, y1, x2*xratio, y2);
x1 = x2;
y1 = y2;
}
x1 = xmin - 0.1;
y1 = -1.0;
for (i=0; i<NSEG; i++)
{
x2 = xmin - 0.1 + (double)i*dx;
x6 = x2*x2*x2;
x5 = x6*x2*x2;
x6 = x5*x2;
f = a + b*(1.0 + 2.0*c*x6)/(1.0 + c*x6);
fp = 6.0*b*c*x5/((1.0 + c*x6)*(1.0 + c*x6));
y2 = -(f + MU*sqrt(1.0 + fp*fp));
draw_line(x1*xratio, y1, x2*xratio, y2);
x1 = x2;
y1 = y2;
}
x1 = xmin - 0.1;
y1 = -1.0;
for (i=0; i<NSEG; i++)
{
x2 = xmin - 0.1 + (double)i*dx;
x6 = x2*x2*x2;
x5 = x6*x2*x2;
x6 = x5*x2;
f = a + b*(1.0 + 2.0*c*x6)/(1.0 + c*x6);
fp = 6.0*b*c*x5/((1.0 + c*x6)*(1.0 + c*x6));
y2 = -f + MU*sqrt(1.0 + fp*fp);
draw_line(x1*xratio, y1, x2*xratio, y2);
x1 = x2;
y1 = y2;
}
x2 = LAMBDA/xratio;
x6 = x2*x2*x2;
x5 = x6*x2*x2;
x6 = x5*x2;
f = a + b*(1.0 + 2.0*c*x6)/(1.0 + c*x6);
fp = 6.0*b*c*x5/((1.0 + c*x6)*(1.0 + c*x6));
y1 = f - MU*sqrt(1.0 + fp*fp);
y2 = f + MU*sqrt(1.0 + fp*fp);
x2 = LAMBDA;
b = 0.7;
draw_line(x2, YMIN, x2, -y2);
draw_line(x2, -y1, x2, -b);
draw_line(x2, -b, XMAX, -b);
draw_line(XMAX, b, x2, b);
draw_line(x2, b, x2, y1);
draw_line(x2, y2, x2, YMAX);
draw_line(-x2, YMIN, -x2, -y2);
draw_line(-x2, -y1, -x2, -b);
draw_line(-x2, -b, XMIN, -b);
draw_line(XMIN, b, -x2, b);
draw_line(-x2, b, -x2, y1);
draw_line(-x2, y2, -x2, YMAX);
break;
}
case (D_WAVEGUIDE_S):
{
a = 0.5*(1.0 - MU);
@ -4666,6 +4903,32 @@ void draw_billiard(int fade, double fade_value) /* draws the billiard bound
draw_line(LAMBDA, -2.0*a+MU, -LAMBDA, -2.0*a+MU);
break;
}
case (D_WAVEGUIDE_S_SHORT):
{
a = -1.0 + MU;
draw_circle_arc(-1.0+MU, 0.0, 1.0-2.0*MU, 0.0, PID, NSEG);
draw_circle_arc(-1.0+MU, 0.0, 1.0, 0.0, PID, NSEG);
draw_circle_arc(1.0-MU, 0.0, 1.0-2.0*MU, PI, PID, NSEG);
draw_circle_arc(1.0-MU, 0.0, 1.0, PI, PID, NSEG);
draw_line(-1.0, 1.0, -1.0+MU, 1.0);
draw_line(-1.0, 1.0, -1.0, 1.0-2.0*MU);
draw_line(-1.0, 1.0-2.0*MU, -1.0+MU, 1.0-2.0*MU);
draw_line(1.0, -1.0, 1.0-MU, -1.0);
draw_line(1.0, -1.0, 1.0, -1.0+2.0*MU);
draw_line(1.0, -1.0+2.0*MU, 1.0-MU, -1.0+2.0*MU);
break;
}
case (D_WAVEGUIDE_BADSPLICE):
{
draw_rectangle(XMIN-1.0, 0.5-LAMBDA, 0.0, 0.5+LAMBDA);
draw_rectangle(0.0, 0.5-LAMBDA+MU, XMAX + 1.0, 0.5+LAMBDA+MU);
draw_rectangle(XMIN-1.0, -0.5-LAMBDA, 0.0, -0.5+LAMBDA);
draw_rectangle(0.0, -0.5-LAMBDA+MU_B, XMAX + 1.0, -0.5+LAMBDA+MU_B);
break;
}
case (D_CIRCLE_SEGMENT):
{
glLineWidth(BOUNDARY_WIDTH);
@ -4963,7 +5226,7 @@ void draw_billiard(int fade, double fade_value) /* draws the billiard bound
draw_circle_arc(-a, 0.0, LAMBDA, -arcangle, 2.0*arcangle, NSEG);
draw_circle_arc(-b, 0.0, LAMBDA, PI-arcangle, 2.0*arcangle, NSEG);
width = 0.05;
width = WALL_WIDTH;
draw_rectangle(-width, MU, width, YMAX + 1.0);
draw_rectangle(-width, YMIN-1.0, width, -MU);
break;
@ -5089,6 +5352,91 @@ void draw_billiard(int fade, double fade_value) /* draws the billiard bound
/* do nothing */
break;
}
case (D_MICHELSON):
{
w = 0.25*sqrt(2.0)*WALL_WIDTH;
h = YMAX - 0.5*WALL_WIDTH;
glBegin(GL_LINE_LOOP);
xy_to_pos(LAMBDA + w, LAMBDA - w, pos);
glVertex2d(pos[0], pos[1]);
xy_to_pos(LAMBDA - w, LAMBDA + w, pos);
glVertex2d(pos[0], pos[1]);
xy_to_pos(-LAMBDA - w, -LAMBDA + w, pos);
glVertex2d(pos[0], pos[1]);
xy_to_pos(-LAMBDA + w, -LAMBDA - w, pos);
glVertex2d(pos[0], pos[1]);
glEnd();
draw_rectangle(h - 0.5*WALL_WIDTH, -LAMBDA, h + 0.5*WALL_WIDTH, LAMBDA);
draw_rectangle(-LAMBDA, h - 0.5*WALL_WIDTH, LAMBDA, h + 0.5*WALL_WIDTH);
draw_rectangle(LAMBDA, LAMBDA, XMAX + 1.0, YMAX + 1.0);
draw_rectangle(LAMBDA, -LAMBDA, XMAX + 1.0, YMIN - 1.0);
draw_rectangle(-LAMBDA, -LAMBDA, XMIN - 1.0, YMIN - 1.0);
draw_rectangle(-LAMBDA, LAMBDA, XMIN - 1.0, YMAX + 1.0);
break;
}
case (D_MICHELSON_MOVING):
{
w = 0.25*sqrt(2.0)*WALL_WIDTH;
h = YMAX - MU - 0.5*WALL_WIDTH;
glBegin(GL_LINE_LOOP);
xy_to_pos(LAMBDA + w, LAMBDA - w, pos);
glVertex2d(pos[0], pos[1]);
xy_to_pos(LAMBDA - w, LAMBDA + w, pos);
glVertex2d(pos[0], pos[1]);
xy_to_pos(-LAMBDA - w, -LAMBDA + w, pos);
glVertex2d(pos[0], pos[1]);
xy_to_pos(-LAMBDA + w, -LAMBDA - w, pos);
glVertex2d(pos[0], pos[1]);
glEnd();
draw_rectangle(h - 0.5*WALL_WIDTH + michelson_position, -LAMBDA, h + 0.5*WALL_WIDTH + michelson_position, LAMBDA);
draw_rectangle(-LAMBDA, h - 0.5*WALL_WIDTH, LAMBDA, h + 0.5*WALL_WIDTH);
draw_rectangle(LAMBDA, LAMBDA, XMAX + 1.0, YMAX + 1.0);
draw_rectangle(LAMBDA, -LAMBDA, XMAX + 1.0, YMIN - 1.0);
draw_rectangle(-LAMBDA, -LAMBDA, XMIN - 1.0, YMIN - 1.0);
draw_rectangle(-LAMBDA, LAMBDA, XMIN - 1.0, YMAX + 1.0);
x = h - 0.5*WALL_WIDTH + michelson_schedule(INITIAL_TIME);
draw_line(x, LAMBDA, x, LAMBDA + WALL_WIDTH);
draw_line(x, -LAMBDA, x, -LAMBDA - WALL_WIDTH);
if (fade) glColor3f(fade_value, fade_value, fade_value);
else glColor3f(1.0, 1.0, 1.0);
xy_to_pos(YMAX - MU - 0.1*XMAX, LAMBDA + 0.1*YMAX + 0.1, pos);
// xy_to_pos(YMAX - MU - 0.3*XMAX, LAMBDA + 0.1*YMAX + 0.1, pos);
sprintf(message, "Mirror position");
write_text(pos[0], pos[1], message);
xy_to_pos(YMAX - MU - 0.1*XMAX, LAMBDA + 0.1*YMAX, pos);
/* wavelength eyeballed from simulation result, should be improved */
sprintf(message, "%.3f wavelengths", michelson_position/0.0667);
write_text(pos[0], pos[1], message);
break;
}
case (D_RITCHEY_CHRETIEN):
{
d = 2.5;
b = 3.5;
r1 = 2.0*(d + b/LAMBDA);
r2 = 6.0/(LAMBDA - 1.0);
x1 = 0.5*d - r1;
x2 = -0.5*d - r2;
alpha = asin(0.3/r2);
ca = cos(alpha);
draw_circle_arc(x2, 0.0, r2, -alpha, 2.0*alpha, NSEG);
draw_line(x2 + r2*ca, 0.3, -0.5*d - WALL_WIDTH, 0.3);
draw_line(-0.5*d - WALL_WIDTH, 0.3, -0.5*d - WALL_WIDTH, -0.3);
draw_line(-0.5*d - WALL_WIDTH, -0.3, x2 + r2*ca, -0.3);
alpha = asin(MU/r1);
ca = cos(alpha);
draw_circle_arc(x1, 0.0, r1, alpha, 0.5*PID, NSEG);
draw_circle_arc(x1, 0.0, r1, -alpha, -0.5*PID, NSEG);
draw_line(x1 + r1*ca, MU, 0.5*d + WALL_WIDTH, MU);
draw_line(0.5*d + WALL_WIDTH, MU, 0.5*d + WALL_WIDTH, YMAX);
draw_line(x1 + r1*ca, -MU, 0.5*d + WALL_WIDTH, -MU);
draw_line(0.5*d + WALL_WIDTH, -MU, 0.5*d + WALL_WIDTH, YMIN);
break;
}
case (D_MENGER):
{
glLineWidth(3);
@ -5679,6 +6027,19 @@ void draw_color_scheme_palette_fade(double x1, double y1, double x2, double y2,
color_scheme_palette(C_ONEDIM_LINEAR, palette, value, 1.0, 1, rgb);
break;
}
case (P_AVERAGE_ENERGY):
{
value = dy_e*(double)(j - jmin)*100.0/E_SCALE;
if (COLOR_PALETTE >= COL_TURBO) color_scheme_asym_palette(COLOR_SCHEME, palette, value, 1.0, 1, rgb);
else color_scheme_palette(COLOR_SCHEME, palette, value, 1.0, 1, rgb);
break;
}
case (P_LOG_AVERAGE_ENERGY):
{
value = LOG_SCALE*log(dy_e*(double)(j - jmin)*100.0/E_SCALE);
color_scheme_palette(COLOR_SCHEME, palette, value, 1.0, 1, rgb);
break;
}
case (P_PHASE):
{
value = min + 1.0*dy*(double)(j - jmin);
@ -5783,9 +6144,9 @@ void draw_color_scheme_palette_fade(double x1, double y1, double x2, double y2,
void draw_circular_color_scheme_palette_fade(double x1, double y1, double radius, int plot, double min, double max, int palette, int fade, double fade_value)
{
int j, k;
double x, y, dy, dy_e, dy_phase, rgb[3], value, lum, amp, dphi, pos[2], phi, xy[2];
double x, y, dy, dy_e, dy_phase, rgb[3], value, lum, amp, dphi, pos[2], phi, xy[2], zscale = 0.9;
glBegin(GL_TRIANGLE_FAN);
// glBegin(GL_TRIANGLE_FAN);
xy_to_pos(x1, y1, xy);
glVertex2d(xy[0], xy[1]);
dy = (max - min)/360.0;
@ -5841,6 +6202,19 @@ void draw_circular_color_scheme_palette_fade(double x1, double y1, double radius
color_scheme_palette(C_ONEDIM_LINEAR, palette, value, 1.0, 1, rgb);
break;
}
case (P_AVERAGE_ENERGY):
{
value = dy_e*(double)(j)*100.0/E_SCALE;
if (COLOR_PALETTE >= COL_TURBO) color_scheme_asym_palette(COLOR_SCHEME, palette, value, 1.0, 1, rgb);
else color_scheme_palette(COLOR_SCHEME, palette, value, 1.0, 1, rgb);
break;
}
case (P_LOG_AVERAGE_ENERGY):
{
value = LOG_SCALE*log(dy_e*(double)(j)*100.0/E_SCALE);
color_scheme_palette(COLOR_SCHEME, palette, value, 1.0, 1, rgb);
break;
}
case (P_PHASE):
{
value = min + 1.0*dy*(double)(j);
@ -5908,12 +6282,18 @@ void draw_circular_color_scheme_palette_fade(double x1, double y1, double radius
if (fade) for (k=0; k<3; k++) rgb[k] *= fade_value;
glColor3f(rgb[0], rgb[1], rgb[2]);
xy_to_pos(x1 + radius*cos(dphi*(double)j), y1 + radius*sin(dphi*(double)j), xy);
glBegin(GL_TRIANGLE_FAN);
xy_to_pos(x1, y1, xy);
glVertex2d(xy[0], xy[1]);
xy_to_pos(x1 + radius*cos(dphi*(double)(j-1)), y1 + zscale*radius*sin(dphi*(double)(j-1)), xy);
glVertex2d(xy[0], xy[1]);
xy_to_pos(x1 + radius*cos(dphi*(double)j), y1 + zscale*radius*sin(dphi*(double)j), xy);
glVertex2d(xy[0], xy[1]);
glEnd ();
}
xy_to_pos(x1 + radius*cos(dphi), y1 + radius*sin(dphi), xy);
glVertex2d(xy[0], xy[1]);
glEnd ();
// glVertex2d(xy[0], xy[1]);
// glEnd ();
if (fade) glColor3f(fade_value, fade_value, fade_value);
else glColor3f(1.0, 1.0, 1.0);
@ -5924,7 +6304,7 @@ void draw_circular_color_scheme_palette_fade(double x1, double y1, double radius
glBegin(GL_LINE_LOOP);
for (j = 0; j < NSEG; j++)
{
xy_to_pos(x1 + radius*cos(dphi*(double)j), y1 + radius*sin(dphi*(double)j), xy);
xy_to_pos(x1 + radius*cos(dphi*(double)j), y1 + zscale*radius*sin(dphi*(double)j), xy);
glVertex2d(xy[0], xy[1]);
glVertex2d(xy[0], xy[1]);
}
@ -6388,7 +6768,8 @@ void compute_laplacian(double phi[NX*NY], t_laplacian laplace[NX*NY], double del
double oscillating_bc(int time, int j)
{
double t, phase, a, envelope, omega;
int ij[2], jmin, jmax;
double t, phase, a, envelope, omega, amp, dist2;
switch (OSCILLATION_SCHEDULE)
{
@ -6413,7 +6794,8 @@ double oscillating_bc(int time, int j)
{
t = (double)time*OMEGA;
// a = 10.0;
a = 0.02/OMEGA;
// a = 0.02/OMEGA;
a = sqrt(INITIAL_VARIANCE)/OMEGA;
phase = AMPLITUDE*cos(t);
envelope = exp(-(t-0.2)*(t-0.2)/(a*a))*sqrt(DPI/a);
return(phase*envelope);
@ -6425,6 +6807,56 @@ double oscillating_bc(int time, int j)
phase = t + ACHIRP*t*t;
return(AMPLITUDE*sin(phase)*exp(-phase*DAMPING));
}
case (OSC_BEAM):
{
xy_to_ij(0.0, OSCIL_YMAX, ij);
jmax = ij[1];
jmin = NY - jmax;
if (j < jmin) dist2 = (double)(jmin-1-j)*(YMAX-YMIN)/(double)NY;
else if (j > jmax) dist2 = (double)(j - jmax)*(YMAX-YMIN)/(double)NY;
else dist2 = 0.0;
dist2 = 500.0*dist2*dist2;
t = (double)time*OMEGA;
amp = AMPLITUDE*cos(t)*exp(-(double)t*DAMPING);
amp *= exp(-dist2/INITIAL_VARIANCE);
return(amp);
}
case (OSC_BEAM_GAUSSIAN):
{
dist2 = (double)(j - NY/2)*(YMAX-YMIN)/(double)NY;
dist2 = dist2*dist2;
t = (double)time*OMEGA;
amp = AMPLITUDE*cos(t)*exp(-(double)t*DAMPING);
amp *= exp(-dist2/INITIAL_VARIANCE);
return(amp);
}
case (OSC_BEAM_SINE):
{
xy_to_ij(0.0, OSCIL_YMAX, ij);
jmax = ij[1];
jmin = NY - jmax;
dist2 = (double)(j - NY/2)/(double)(jmax - NY/2);
if (j > jmax) return(0.0);
if (j < jmin) return(0.0);
t = (double)time*OMEGA;
amp = AMPLITUDE*cos(t)*exp(-(double)t*DAMPING);
amp *= cos(PID*dist2);
return(amp);
}
case (OSC_BEAM_TWOPERIODS):
{
xy_to_ij(0.0, OSCIL_YMAX, ij);
jmax = ij[1];
jmin = NY - jmax;
if (j < jmin) dist2 = (double)(jmin-1-j)*(YMAX-YMIN)/(double)NY;
else if (j > jmax) dist2 = (double)(j - jmax)*(YMAX-YMIN)/(double)NY;
else dist2 = 0.0;
dist2 = 500.0*dist2*dist2;
t = (double)time*OMEGA;
amp = AMPLITUDE*(0.5*cos(t) + 0.5*cos(sqrt(7.0)*t))*exp(-(double)t*DAMPING);
amp *= exp(-dist2/INITIAL_VARIANCE);
return(amp);
}
}
}
@ -6433,7 +6865,7 @@ void init_ior_2d(short int *xy_in[NX], double *tcc_table[NX], double *tgamma_tab
/* should be at some point merged with 3D version in suv_wave_3d.c */
{
int i, j, k, n, inlens, ncircles;
double courant2 = COURANT*COURANT, courantb2 = COURANTB*COURANTB, lambda1, mu1;
double courant2 = COURANT*COURANT, courantb2 = COURANTB*COURANTB, lambda1, mu1, courant_med, courant_med2;
double a, u, v, u1, x, y, xy[2], norm2, speed, r2, c, salpha, h, ll, ca, sa, x1, y1, dx, dy, sum, sigma, x0, y0, rgb[3];
double xc[NGRIDX*NGRIDY], yc[NGRIDX*NGRIDY], height[NGRIDX*NGRIDY];
static double xc_stat[NGRIDX*NGRIDY], yc_stat[NGRIDX*NGRIDY], sigma_stat;
@ -6835,16 +7267,21 @@ void init_ior_2d(short int *xy_in[NX], double *tcc_table[NX], double *tgamma_tab
}
else
{
if (xy_in[i][j] != 0)
if (xy_in[i][j] == 1)
{
tcc_table[i][j] = courant2;
tgamma_table[i][j] = GAMMA;
}
else
else if (xy_in[i][j] == 0)
{
tcc_table[i][j] = courantb2;
tgamma_table[i][j] = GAMMAB;
}
else
{
tcc_table[i][j] = 0.0;
tgamma_table[i][j] = 1.0;
}
}
}
}
@ -6985,7 +7422,7 @@ void init_ior_2d(short int *xy_in[NX], double *tcc_table[NX], double *tgamma_tab
ij_to_xy(i, j, xy);
x = xy[0];
y = xy[1];
if (xy_in[i][j])
if (xy_in[i][j] == 1)
{
tcc_table[i][j] = courant2;
tgamma_table[i][j] = GAMMA;
@ -7004,6 +7441,83 @@ void init_ior_2d(short int *xy_in[NX], double *tcc_table[NX], double *tgamma_tab
}
break;
}
case (IOR_WAVE_GUIDES_COUPLED_B):
{
for (i=0; i<NX; i++){
for (j=0; j<NY; j++){
ij_to_xy(i, j, xy);
x = xy[0];
y = xy[1];
if (xy_in[i][j] == 1)
{
tcc_table[i][j] = courant2;
tgamma_table[i][j] = GAMMA;
}
else if ((vabs(x) > LAMBDA)&&(vabs(y) > 0.7))
{
tcc_table[i][j] = 0.0;
tgamma_table[i][j] = 1.0;
}
else
{
tcc_table[i][j] = courantb2;
tgamma_table[i][j] = GAMMAB;
}
}
}
break;
}
case (IOR_WAVE_GUIDE_COATED):
{
courant_med = 0.8*COURANT + 0.2*COURANTB;
courant_med2 = courant_med*courant_med;
for (i=0; i<NX; i++){
for (j=0; j<NY; j++){
// ij_to_xy(i, j, xy);
// x = xy[0];
// y = xy[1];
if (xy_in[i][j] == 1)
{
tcc_table[i][j] = courant2;
tgamma_table[i][j] = GAMMA;
}
else if (xy_in[i][j] == 2)
{
tcc_table[i][j] = courant_med2;
tgamma_table[i][j] = GAMMA;
}
else
{
tcc_table[i][j] = courantb2;
tgamma_table[i][j] = GAMMAB;
}
}
}
break;
}
case (IOR_MICHELSON):
{
for (i=0; i<NX; i++){
for (j=0; j<NY; j++){
if (xy_in[i][j] == 0)
{
tcc_table[i][j] = courant2;
tgamma_table[i][j] = GAMMA;
}
else if (xy_in[i][j] == 2)
{
tcc_table[i][j] = 0.0;
tgamma_table[i][j] = 1.0;
}
else
{
tcc_table[i][j] = courantb2;
tgamma_table[i][j] = GAMMAB;
}
}
}
break;
}
default:
{
for (i=0; i<NX; i++){
@ -7102,7 +7616,6 @@ void init_wave_packets(t_wave_packet *packet, int radius)
packet[i].ix = ij[0];
packet[i].iy = ij[1];
}
break;
}
case (WP_RANDOM2):
@ -7122,7 +7635,6 @@ void init_wave_packets(t_wave_packet *packet, int radius)
packet[i].ix = ij[0];
packet[i].iy = ij[1];
}
break;
}
case (WP_PAIR):
@ -7143,7 +7655,25 @@ void init_wave_packets(t_wave_packet *packet, int radius)
packet[i].ix = ij[0];
packet[i].iy = ij[1];
}
break;
}
case (WP_FIVE):
{
for (i=0; i<5; i++)
{
packet[i].xc = -1.75;
packet[i].yc = 0.3*(double)(i-2);
packet[i].period = OSCILLATING_SOURCE_PERIOD;
packet[i].amp = INITIAL_AMP;
packet[i].phase = 0.0;
packet[i].var_envelope = 550.0;
packet[i].time_shift = ((3*i)%5)*400;
xy_to_ij(packet[i].xc, packet[i].yc, ij);
if(ij[0] <= radius) ij[0] = radius+1;
packet[i].ix = ij[0];
packet[i].iy = ij[1];
}
break;
}
}
@ -7266,32 +7796,35 @@ void add_circular_wave_loc(double factor, double x, double y, double *phi[NX], d
}
}
void add_wave_packets_globally(double *phi[NX], double *psi[NX], short int * xy_in[NX], t_wave_packet *packet, int time)
void add_wave_packets_globally(double *phi[NX], double *psi[NX], short int * xy_in[NX], t_wave_packet *packet, int time, int add_period, int type_envelope)
/* add some wave packet sources */
{
int i, ij[2];
double amp, t, omega;
double amp, t, omega, wave_height;
static int xmin, xmax, ymin, ymax, first=1;
if (first)
{
xy_to_ij(XMIN, -0.2*(YMAX - YMIN), ij);
xy_to_ij(XMIN, YMIN, ij);
xmin = ij[0];
ymin = ij[1];
xy_to_ij(XMIN + 0.15*(XMAX - XMIN), 0.2*(YMAX - YMIN), ij);
xy_to_ij(XMIN + 0.15*(XMAX - XMIN), YMAX, ij);
xmax = ij[0];
ymax = ij[1];
first = 0;
}
for (i=0; i<N_WAVE_PACKETS; i++)
if (time%add_period == 0) for (i=0; i<N_WAVE_PACKETS; i++)
{
t = (double)(time - packet[i].time_shift);
omega = DPI/packet[i].period;
amp = packet[i].amp*omega*sin(omega*t + packet[i].phase);
if (t > (double)packet[i].var_envelope) amp *= exp(-0.1*(t - (double)packet[i].var_envelope));
if (t < (double)packet[i].var_envelope + 100.0)
add_circular_wave_loc(amp, packet[i].xc, packet[i].yc, phi, psi, xy_in, xmin, xmax, ymin, ymax);
wave_height = wave_packet_height(t, packet[i], type_envelope);
add_circular_wave_loc(wave_height, packet[i].xc, packet[i].yc, phi, psi, xy_in, xmin, xmax, ymin, ymax);
// omega = DPI/packet[i].period;
// amp = packet[i].amp*omega*sin(omega*t + packet[i].phase);
// if (t > (double)packet[i].var_envelope) amp *= exp(-0.1*(t - (double)packet[i].var_envelope));
// if (t < (double)packet[i].var_envelope + 100.0)
// add_circular_wave_loc(amp, packet[i].xc, packet[i].yc, phi, psi, xy_in, xmin, xmax, ymin, ymax);
}
}
@ -7300,7 +7833,7 @@ void add_wave_packets(double *phi[NX], double *psi[NX], short int * xy_in[NX], t
/* add some wave packet sources */
{
if (local) add_wave_packets_locally(phi, psi, packet, time, radius, add_period, type_envelope);
else add_wave_packets_globally(phi, psi, xy_in, packet, time);
else add_wave_packets_globally(phi, psi, xy_in, packet, time, add_period, type_envelope);
}
int old_source_schedule(int i)
@ -7323,16 +7856,14 @@ void old_init_input_signal()
int init_input_signal()
{
int i, j, k, mod, ldash, ldot, lspace, linter, initial_time;
char text[200] = "dddd_dD_dDDd_dDDd_DdDD__Dd_d_dDD__DdDD_d_dD_dDd__ddDDD_DDDDD_ddDDD_ddddD", c;
ldash = 12;
ldot = 3;
linter = 30;
lspace = 36;
initial_time = 200;
for (i=0; i<initial_time; i++) input_signal[i] = 0;
int i, j, k, mod, tailcounter = 0;
char text[200] = "..|--/-...|.-|-../..|--/-...|.-|-../", c;
// char text[200] = "..|.../-|....|.|.-.|./.-|-.|-.--|-...|--- -..|-.--/---|..-|-/-|....|.|.-.|.", c;
// char text[200] = "..|--/.-|-./..|--|.--.|.-.|---|...-|.|-../..-.|..|-...|.|.-.", c;
// char text[200] = "...._.-_.--._.--._-.--__-._._.--__-.--_._.-_.-.__..---_-----_..---_....-", c;
for (i=0; i<MESSAGE_INITIAL_TIME; i++) input_signal[i] = 0;
j = 0;
while (i < NSTEPS)
@ -7342,27 +7873,36 @@ int init_input_signal()
c = text[j];
switch(c) {
case ('D'):
case ('-'):
{
for (k=0; k<ldash; k++)
for (k=0; k<MESSAGE_LDASH; k++)
{
input_signal[i] = 1;
i++;
}
break;
}
case ('d'):
case ('.'):
{
for (k=0; k<ldot; k++)
for (k=0; k<MESSAGE_LDOT; k++)
{
input_signal[i] = 1;
i++;
}
break;
}
case ('_'):
case ('|'):
{
for (k=0; k<lspace; k++)
for (k=0; k<MESSAGE_LINTERLETTER; k++)
{
input_signal[i] = 0;
i++;
}
break;
}
case ('/'):
{
for (k=0; k<MESSAGE_LSPACE; k++)
{
input_signal[i] = 0;
i++;
@ -7371,7 +7911,7 @@ int init_input_signal()
}
}
for (k=0; k<linter; k++)
for (k=0; k<MESSAGE_LINTERVAL; k++)
{
input_signal[i] = 0;
i++;
@ -7382,10 +7922,14 @@ int init_input_signal()
input_signal[i] = 0;
i++;
tailcounter++;
}
for (i=0; i<NSTEPS; i++) printf("%i ", input_signal[i]);
printf("\n\n j = %i, string length = %i\n", j, (int)strlen(text));
printf("Tail frames: %i\n", tailcounter);
}

View File

@ -1004,9 +1004,11 @@ void compute_energy_field(double phi[NX*NY], double psi[NX*NY], short int xy_in[
if (COMPUTE_LOG_MEAN_ENERGY)
{
logenergy = log(wave[i*NY+j].mean_energy) + LOG_MEAN_ENERGY_SHIFT;
logenergy = wave[i*NY+j].mean_energy;
if (logenergy == 0.0) logenergy = 1.0e-10;
logenergy = log(logenergy) + LOG_MEAN_ENERGY_SHIFT;
if (logenergy > LOG_ENERGY_FLOOR) wave[i*NY+j].log_mean_energy = LOG_SHIFT + PLOT_SCALE_LOG_ENERGY*logenergy;
else wave[i*NY+j].mean_energy = LOG_SHIFT + PLOT_SCALE_LOG_ENERGY*LOG_ENERGY_FLOOR;
else wave[i*NY+j].log_mean_energy = LOG_SHIFT + PLOT_SCALE_LOG_ENERGY*LOG_ENERGY_FLOOR;
}
if (COMPUTE_ENERGY_FLUX)

View File

@ -14,6 +14,108 @@ void init_3d() /* initialisation of window */
glOrtho(XMIN, XMAX, YMIN, YMAX , -1.0, 1.0);
}
void init_wave_sphere_rde(t_wave_sphere wsphere[NX*NY])
/* initialize sphere data, taken from sub_sphere.c */
{
int i, j;
double dphi, dtheta, theta0, xy[2], phishift;
printf("Initializing wsphere\n");
dphi = DPI/(double)NX;
dtheta = PI/(double)NY;
// dtheta = PI/(double)(NY-2*(DPOLE));
// theta0 = (double)(DPOLE)*dtheta;
theta0 = 0;
phishift = PHISHIFT*(XMAX-XMIN)/360.0;
#pragma omp parallel for private(i,j)
for (i=0; i<NX; i++)
{
// for (j=DPOLE; j<NY-DPOLE; j++)
// wsphere[i*NY+j].theta = (double)j*dtheta - theta0;
// for (j=0; j<DPOLE; j++) wsphere[i*NY+j].theta = 0.0;
// for (j=NY-DPOLE; j<NY; j++) wsphere[i*NY+j].theta = PI;
for (j=0; j<NY; j++)
{
wsphere[i*NY+j].phi = (double)i*dphi;
wsphere[i*NY+j].theta = (double)j*dtheta;
wsphere[i*NY+j].cphi = cos(wsphere[i*NY+j].phi);
wsphere[i*NY+j].sphi = sin(wsphere[i*NY+j].phi);
wsphere[i*NY+j].ctheta = cos(wsphere[i*NY+j].theta);
wsphere[i*NY+j].stheta = sin(wsphere[i*NY+j].theta);
wsphere[i*NY+j].x = wsphere[i*NY+j].cphi*wsphere[i*NY+j].stheta;
wsphere[i*NY+j].y = wsphere[i*NY+j].sphi*wsphere[i*NY+j].stheta;
wsphere[i*NY+j].z = -wsphere[i*NY+j].ctheta;
wsphere[i*NY+j].radius = 1.0;
wsphere[i*NY+j].radius_dem = 1.0;
ij_to_xy(NX-1-i,j,xy);
// xy[0] = XMIN + ((double)(NX-i-1))*(XMAX-XMIN)/((double)NX);
// xy[1] = YMIN + ((double)(j-DPOLE))*(YMAX-YMIN)/((double)(NY-2*DPOLE));
xy[0] += phishift;
if (xy[0] > XMAX) xy[0] += XMIN - XMAX;
xy[1] *= (double)NY/(double)(NY-2*DPOLE);
wsphere[i*NY+j].x2d = xy[0];
wsphere[i*NY+j].y2d = xy[1];
wsphere[i*NY+j].cos_angle_sphere = wsphere[i*NY+j].x*light[0] + wsphere[i*NY+j].y*light[1] + wsphere[i*NY+j].z*light[2];
}
/* cotangent, taking care of not dividing by zero */
/* TODO clean up cottheta range ? */
for (j=DPOLE; j<NY-DPOLE; j++) wsphere[i*NY+j].cottheta = wsphere[i*NY+j].ctheta/wsphere[i*NY+j].stheta;
for (j=0; j<DPOLE; j++) wsphere[i*NY+j].cottheta = wsphere[i*NY+DPOLE].cottheta;
for (j=NY-DPOLE; j<NY; j++) wsphere[i*NY+j].cottheta = wsphere[i*NY+DPOLE-1].cottheta;
}
}
int ij_to_sphere(int i, int j, double r, t_wave_sphere wsphere[NX*NY], double xyz[3], int use_wave_radius)
/* convert spherical to rectangular coordinates */
{
double pscal, newr;
static double norm_observer;
static int first = 1;
if (first)
{
norm_observer = sqrt(observer[0]*observer[0] + observer[1]*observer[1] + observer[2]*observer[2]);
first = 0;
}
xyz[0] = wsphere[i*NY+j].x;
xyz[1] = wsphere[i*NY+j].y;
xyz[2] = wsphere[i*NY+j].z;
pscal = xyz[0]*observer[0] + xyz[1]*observer[1] + xyz[2]*observer[2];
if (use_wave_radius)
{
newr = wsphere[i*NY+j].radius;
xyz[0] *= newr;
xyz[1] *= newr;
xyz[2] *= newr;
}
else
{
newr = wsphere[i*NY+j].radius_dem;
xyz[0] *= newr;
xyz[1] *= newr;
xyz[2] *= newr;
}
return(pscal/norm_observer > COS_VISIBLE);
}
void xyz_to_xy(double x, double y, double z, double xy_out[2])
{
int i;
@ -63,6 +165,127 @@ void xyz_to_xy(double x, double y, double z, double xy_out[2])
}
}
int xy_in_billiard_sphere(int i, int j, t_wave_sphere wsphere[NX*NY])
/* returns 1 if (x,y) represents a point in the billiard */
{
int k;
double pscal, dist, r, u, v, u1, v1;
static double cos_rot, sin_rot;
static int first = 1;
if (first)
{
// if (B_DOMAIN == D_SPHERE_EARTH) init_earth_map(wsphere);
// else if (OTHER_PLANET) init_planet_map(wsphere, B_DOMAIN);
// else
if ((B_DOMAIN == D_SPHERE_JULIA)||(B_DOMAIN == D_SPHERE_JULIA_INV)||(B_DOMAIN == D_SPHERE_JULIA_CUBIC))
{
cos_rot = cos(JULIA_ROT*DPI/360.0);
sin_rot = sin(JULIA_ROT*DPI/360.0);
}
// else if (B_DOMAIN == D_SPHERE_MAZE) init_sphere_maze(wsphere, 0, 0, 0);
// else if (B_DOMAIN == D_SPHERE_MAZE_SPIRAL) init_sphere_maze(wsphere, 1, 0, 1);
// else if (B_DOMAIN == D_SPHERE_MAZE_WAVE) init_sphere_maze(wsphere, 0, 1, 1);
first = 0;
}
switch (B_DOMAIN) {
case (D_NOTHING):
{
return(1);
}
case (D_LATITUDE):
{
return(vabs(wsphere[i*NY+j].theta - PID) < LAMBDA*PID);
}
case (D_SPHERE_CIRCLES):
{
for (k=0; k<ncircles; k++)
{
pscal = cos(wsphere[i*NY+j].phi - circ_sphere[k].phi)*wsphere[i*NY+j].stheta*sin(circ_sphere[k].theta);
pscal += wsphere[i*NY+j].ctheta*cos(circ_sphere[k].theta);
dist = acos(pscal);
if (dist < circ_sphere[k].radius) return(0);
}
return(1);
}
case (D_SPHERE_JULIA):
{
if (wsphere[i*NY+j].z == 1.0) return(1);
if (wsphere[i*NY+j].z == -1.0) return(0);
r = (1.0 + wsphere[i*NY+j].ctheta)/wsphere[i*NY+j].stheta;
u1 = r*wsphere[i*NY+j].cphi*JULIA_SCALE;
v1 = r*wsphere[i*NY+j].sphi*JULIA_SCALE;
u = u1*cos_rot + v1*sin_rot;
v = -u1*sin_rot + v1*cos_rot;
i = 0;
while ((i<MANDELLEVEL)&&(u*u+v*v < 1000.0*MANDELLIMIT))
{
u1 = u*u - v*v + JULIA_RE;
v = 2.0*u*v + JULIA_IM;
u = u1;
i++;
}
if (u*u + v*v < MANDELLIMIT) return(1);
return(0);
}
case (D_SPHERE_JULIA_INV):
{
if (wsphere[i*NY+j].z == 1.0) return(1);
if (wsphere[i*NY+j].z == -1.0) return(0);
r = (1.0 - wsphere[i*NY+j].ctheta)/wsphere[i*NY+j].stheta;
u1 = r*wsphere[i*NY+j].cphi*JULIA_SCALE;
v1 = r*wsphere[i*NY+j].sphi*JULIA_SCALE;
u = u1*cos_rot + v1*sin_rot;
v = -u1*sin_rot + v1*cos_rot;
i = 0;
while ((i<MANDELLEVEL)&&(u*u+v*v < 1000.0*MANDELLIMIT))
{
u1 = u*u - v*v + JULIA_RE;
v = 2.0*u*v + JULIA_IM;
u = u1;
i++;
}
if (u*u + v*v < MANDELLIMIT) return(0);
return(1);
}
case (D_SPHERE_JULIA_CUBIC):
{
if (wsphere[i*NY+j].z == 1.0) return(1);
if (wsphere[i*NY+j].z == -1.0) return(0);
r = (1.0 + wsphere[i*NY+j].ctheta)/wsphere[i*NY+j].stheta;
u1 = r*wsphere[i*NY+j].cphi*JULIA_SCALE;
v1 = r*wsphere[i*NY+j].sphi*JULIA_SCALE;
u = u1*cos_rot + v1*sin_rot;
v = -u1*sin_rot + v1*cos_rot;
i = 0;
while ((i<MANDELLEVEL)&&(u*u+v*v < 1000.0*MANDELLIMIT))
{
u1 = u*u*u - 3.0*u*v*v + JULIA_RE;
v = 3.0*u*u*v - v*v*v + JULIA_IM;
u = u1;
i++;
}
if (u*u + v*v < MANDELLIMIT) return(1);
return(0);
}
default:
{
return(wsphere[i*NY+j].indomain);
}
}
}
void draw_vertex_sphere(double xyz[3])
{
double xy_screen[2];
xyz_to_xy(xyz[0], xyz[1], xyz[2], xy_screen);
glVertex2d(xy_screen[0], xy_screen[1]);
}
void draw_vertex_ij(int i, int j)
{
@ -1530,11 +1753,10 @@ void draw_color_scheme_palette_3d(double x1, double y1, double x2, double y2, in
}
void draw_circular_color_scheme_palette_3d(double x1, double y1, double radius, int plot,
double min, double max, int palette, int fade, double fade_value)
void draw_circular_color_scheme_palette_3d(double x1, double y1, double radius, int plot, double min, double max, int palette, int fade, double fade_value)
{
int j, k, ij_center[2], ij_right[2], ic, jc, ir;
double x, y, dy, dy_e, dy_phase, rgb[3], value, lum, amp, dphi, pos[2], phi, xy[2];
double x, y, dy, dy_e, dy_phase, rgb[3], value, lum, amp, dphi, pos[2], phi, xy[2], zscale = 0.9;
// printf("Drawing color bar\n");
@ -1551,14 +1773,14 @@ void draw_circular_color_scheme_palette_3d(double x1, double y1, double radius,
// jmax = ij_topright[1];
glBegin(GL_TRIANGLE_FAN);
draw_vertex_ij(ic, jc);
// glBegin(GL_TRIANGLE_FAN);
// draw_vertex_ij(ic, jc);
dy = (max - min)/360.0;
dy_e = max/360.0;
dy_phase = 1.0/360.0;
dphi = DPI/360.0;
for (j = 0; j < 360; j++)
for (j = 0; j < 361; j++)
{
switch (plot) {
case (P_3D_AMPLITUDE):
@ -1637,6 +1859,18 @@ void draw_circular_color_scheme_palette_3d(double x1, double y1, double radius,
color_scheme_palette(C_ONEDIM_LINEAR, palette, value, 1.0, 1, rgb);
break;
}
case (Z_POLAR):
{
value = dy_phase*(double)(j);
color_scheme_palette(C_ONEDIM_LINEAR, palette, value, 1.0, 1, rgb);
break;
}
case (Z_ARGUMENT):
{
value = dy_phase*(double)(j);
color_scheme_palette(C_ONEDIM_LINEAR, palette, value, 1.0, 1, rgb);
break;
}
case (Z_EULER_VORTICITY):
{
value = min + 1.0*dy*(double)(j);
@ -1678,13 +1912,26 @@ void draw_circular_color_scheme_palette_3d(double x1, double y1, double radius,
}
if (fade) for (k=0; k<3; k++) rgb[k] *= fade_value;
glColor3f(rgb[0], rgb[1], rgb[2]);
glBegin(GL_TRIANGLE_FAN);
draw_vertex_ij(ic, jc);
x = cos(dphi*(double)j)*(double)ir;
y = sin(dphi*(double)j)*(double)ir;
ij_to_xy(ic + x, jc + y, xy);
y = zscale*sin(dphi*(double)j)*(double)ir;
xy[0] = XMIN + ((double)ic + x)*(XMAX-XMIN)/((double)NX);
xy[1] = YMIN + ((double)jc + y)*(YMAX-YMIN)/((double)NY);
// ij_to_xy(ic + x, jc + y, xy);
glVertex2d(xy[0], xy[1]);
x = cos(dphi*(double)(j+1))*(double)ir;
y = zscale*sin(dphi*(double)(j+1))*(double)ir;
xy[0] = XMIN + ((double)ic + x)*(XMAX-XMIN)/((double)NX);
xy[1] = YMIN + ((double)jc + y)*(YMAX-YMIN)/((double)NY);
// ij_to_xy(ic + x, jc + y, xy);
glVertex2d(xy[0], xy[1]);
glEnd ();
}
draw_vertex_ij(ic + ir, jc);
glEnd ();
// draw_vertex_ij(ic + ir, jc);
// draw_vertex_ij(ic, jc);
// glEnd ();
if (fade) glColor3f(fade_value, fade_value, fade_value);
else glColor3f(1.0, 1.0, 1.0);
@ -1696,7 +1943,7 @@ void draw_circular_color_scheme_palette_3d(double x1, double y1, double radius,
for (j = 0; j < NSEG; j++)
{
x = cos(dphi*(double)j)*(double)ir;
y = sin(dphi*(double)j)*(double)ir;
y = zscale*sin(dphi*(double)j)*(double)ir;
xy[0] = XMIN + ((double)ic + x)*(XMAX-XMIN)/((double)NX);
xy[1] = YMIN + ((double)jc + y)*(YMAX-YMIN)/((double)NY);
glVertex2d(xy[0], xy[1]);

105
wave_3d.c
View File

@ -44,7 +44,7 @@
#include <time.h>
#define MOVIE 0 /* set to 1 to generate movie */
#define DOUBLE_MOVIE 1 /* set to 1 to produce movies for wave height and energy simultaneously */
#define DOUBLE_MOVIE 0 /* set to 1 to produce movies for wave height and energy simultaneously */
#define SAVE_MEMORY 1 /* set to 1 to save memory when writing tiff images */
#define NO_EXTRA_BUFFER_SWAP 1 /* some OS require one less buffer swap when recording images */
@ -52,21 +52,21 @@
#define WINWIDTH 1920 /* window width */
#define WINHEIGHT 1150 /* window height */
// // // #define NX 2500 /* number of grid points on x axis */
// // // #define NY 1250 /* 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 NX 2840 /* number of grid points on x axis */
// // #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 3840 /* number of grid points on x axis */
// #define NY 2300 /* number of grid points on y axis */
// #define NX 2500 /* number of grid points on x axis */
// #define NY 1250 /* number of grid points on y axis */
// #define NX 1700 /* number of grid points on x axis */
// #define NY 1700 /* number of grid points on y axis */
#define XMIN -1.0
#define XMAX 3.0 /* x interval */
#define YMIN -1.041666667
#define YMAX 1.041666667 /* y interval for 9/16 aspect ratio */
// #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 */
#define XMIN -1.669565217
#define XMAX 1.669565217 /* x interval */
#define YMIN -1.0
#define YMAX 1.0 /* y interval for 9/16 aspect ratio */
#define HIGHRES 0 /* set to 1 if resolution of grid is double that of displayed image */
@ -92,7 +92,7 @@
/* Choice of the billiard table */
#define B_DOMAIN 10 /* choice of domain shape, see list in global_pdes.c */
#define B_DOMAIN 17 /* 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 */
@ -109,17 +109,18 @@
#define NPOISSON 1000 /* number of points for Poisson C_RAND_POISSON arrangement */
#define RANDOM_POLY_ANGLE 1 /* set to 1 to randomize angle of polygons */
#define LAMBDA 0.1197916667 /* parameter controlling the dimensions of domain */
#define MU 0.035 /* parameter controlling the dimensions of domain */
#define LAMBDA 3.0 /* parameter controlling the dimensions of domain */
#define MU 0.14 /* parameter controlling the dimensions of domain */
#define NPOLY 6 /* number of sides of polygon */
#define APOLY 0.0 /* angle by which to turn polygon, in units of Pi/2 */
#define MDEPTH 7 /* depth of computation of Menger gasket */
#define MDEPTH 2 /* 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 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 X_SHOOTER -0.2
#define Y_SHOOTER -0.6
@ -139,12 +140,13 @@
/* Physical parameters of wave equation */
#define TWOSPEEDS 0 /* set to 1 to replace hardcore boundary by medium with different speed */
#define OSCILLATE_LEFT 0 /* set to 1 to add oscilating boundary condition on the left */
#define OSCILLATE_LEFT 1 /* set to 1 to add oscilating boundary condition on the left */
#define OSCILLATE_TOPBOT 0 /* set to 1 to enforce a planar wave on top and bottom boundary */
#define OSCILLATION_SCHEDULE 3 /* oscillation schedule, see list in global_pdes.c */
#define OSCIL_YMAX 0.35 /* defines oscillation range */
#define OMEGA 0.001 /* frequency of periodic excitation */
#define AMPLITUDE 0.8 /* amplitude of periodic excitation */
#define OMEGA 0.015 /* frequency of periodic excitation */
#define AMPLITUDE 1.0 /* amplitude of periodic excitation */
#define ACHIRP 0.2 /* acceleration coefficient in chirp */
#define DAMPING 0.0 /* damping of periodic excitation */
#define COURANT 0.1 /* Courant number */
@ -162,7 +164,7 @@
/* Increasing COURANT speeds up the simulation, but decreases accuracy */
/* For similar wave forms, COURANT^2*GAMMA should be kept constant */
#define ADD_OSCILLATING_SOURCE 1 /* set to 1 to add an oscillating wave source */
#define ADD_OSCILLATING_SOURCE 0 /* set to 1 to add an oscillating wave source */
#define OSCILLATING_SOURCE_PERIOD 30 /* period of oscillating source */
#define ALTERNATE_OSCILLATING_SOURCE 1 /* set to 1 to alternate sign of oscillating source */
@ -174,15 +176,15 @@
/* Boundary conditions, see list in global_pdes.c */
// #define B_COND 1
#define B_COND 2
#define B_COND 3
#define PRECOMPUTE_BC 0 /* set to 1 to compute neighbours for Laplacian in advance */
/* Parameters for length and speed of simulation */
#define NSTEPS 2300 /* number of frames of movie */
#define NSTEPS 1000 /* number of frames of movie */
// #define NSTEPS 300 /* number of frames of movie */
#define NVID 4 /* number of iterations between images displayed on screen */
#define NVID 20 /* number of iterations between images displayed on screen */
// #define NVID 10 /* 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 */
@ -200,7 +202,7 @@
/* Parameters of initial condition */
#define INITIAL_AMP 2.0 /* amplitude of initial condition */
#define INITIAL_AMP 0.75 /* amplitude of initial condition */
// #define INITIAL_VARIANCE 0.000025 /* variance of initial condition */
#define INITIAL_VARIANCE 0.00005 /* variance of initial condition */
#define INITIAL_WAVELENGTH 0.05 /* wavelength of initial condition */
@ -208,11 +210,11 @@
/* Plot type, see list in global_pdes.c */
#define ZPLOT 103 /* wave height */
#define CPLOT 103 /* color scheme */
#define ZPLOT 108 /* wave height */
#define CPLOT 108 /* color scheme */
#define ZPLOT_B 107
#define CPLOT_B 107 /* plot type for second movie */
#define ZPLOT_B 103
#define CPLOT_B 103 /* plot type for second movie */
#define CHANGE_LUMINOSITY 1 /* set to 1 to let luminosity depend on energy flux intensity */
#define FLUX_WINDOW 30 /* size of averaging window of flux intensity */
@ -242,8 +244,8 @@
/* Color schemes */
#define COLOR_PALETTE 11 /* Color palette, see list in global_pdes.c */
#define COLOR_PALETTE_B 13 /* Color palette, see list in global_pdes.c */
#define COLOR_PALETTE 13 /* Color palette, see list in global_pdes.c */
#define COLOR_PALETTE_B 17 /* Color palette, see list in global_pdes.c */
#define BLACK 1 /* background */
@ -252,17 +254,18 @@
#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 VSCALE_ENERGY 10.0 /* additional scaling factor for color scheme P_3D_ENERGY */
#define VSCALE_ENERGY 1.5 /* 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 20.0 /* scaling factor for energy representation */
#define E_SCALE 50.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 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 */
#define FLUX_CSCALE 2.0 /* scaling factor for color in energy flux representation */
#define AVRG_E_FACTOR 0.95 /* 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 COLORHUE 260 /* initial hue of water color for scheme C_LUM */
@ -272,6 +275,13 @@
#define HUEMEAN 240.0 /* mean value of hue for color scheme C_HUE */
#define HUEAMP -200.0 /* amplitude of variation of hue for color scheme C_HUE */
#define MESSAGE_LDASH 14 /* length of dash for Morse code message */
#define MESSAGE_LDOT 8 /* length of dot for Morse code message */
#define MESSAGE_LINTERVAL 54 /* length of interval between dashes/dots for Morse code message */
#define MESSAGE_LINTERLETTER 60 /* length of interval between letters for Morse code message */
#define MESSAGE_LSPACE 48 /* length of space for Morse code message */
#define MESSAGE_INITIAL_TIME 100 /* initial time before starting message for Morse code message */
#define NXMAZE 8 /* width of maze */
#define NYMAZE 32 /* height of maze */
#define MAZE_MAX_NGBH 5 /* max number of neighbours of maze cell */
@ -280,8 +290,8 @@
#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 2.5 /* scale of color scheme bar */
#define COLORBAR_RANGE_B 0.5 /* scale of color scheme bar for 2nd part */
#define COLORBAR_RANGE 1.0 /* scale of color scheme bar */
#define COLORBAR_RANGE_B 1.5 /* scale of color scheme bar for 2nd part */
#define ROTATE_COLOR_SCHEME 0 /* set to 1 to draw color scheme horizontally */
#define SAVE_TIME_SERIES 0 /* set to 1 to save wave time series at a point */
@ -292,8 +302,15 @@
#define POT_FACT 20.0
#define DRAW_WAVE_PROFILE 0 /* set to 1 to draw a profile of the wave */
#define MU_B 1.0 /* parameter controlling the dimensions of domain */
#define HORIZONTAL_WAVE_PROFILE 0 /* set to 1 to draw wave profile vertically */
#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 WAVE_PROFILE_X 2.1 /* value of x to sample wave profile */
#define WAVE_PROFILE_Y -1.0 /* value of y to sample wave profile */
#define PROFILE_AT_BOTTOM 1 /* draw wave profile at bottom instead of top */
#define AVERAGE_WAVE_PROFILE 1 /* set to 1 to draw time-average of wave profile squared*/
#define TIMESERIES_NVALUES 400 /* number of values plotted in time series */
#define DRAW_WAVE_SOURCE 0 /* set to 1 to draw source of wave at (wave_source_x, wave_source_y) */
/* end of constants only used by sub_wave and sub_maze */
@ -307,14 +324,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, 5.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.1 /* overall scaling factor of z axis for REP_PROJ_3D representation */
#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 ZMAX_FACTOR 1.0 /* max value of z coordinate for REP_PROJ_3D representation */
#define XSHIFT_3D 0.2 /* overall x shift for REP_PROJ_3D representation */
#define YSHIFT_3D 0.5 /* overall y shift for REP_PROJ_3D representation */
#define XSHIFT_3D 0.1 /* overall x shift for REP_PROJ_3D representation */
#define YSHIFT_3D 0.1 /* overall y shift for REP_PROJ_3D representation */
#include "global_pdes.c" /* constants and global variables */
@ -1071,8 +1088,8 @@ void animation()
// for (j=1; j<NPOLY; j++)
// add_circular_wave_mod(1.0, lambda1*cos(((double)j+0.5)*angle), lambda1*sin(((double)j+0.5)*angle), phi, psi, xy_in);
// init_wave_flat_mod(phi, psi, xy_in);
init_circular_wave_mod(-0.5, 0.0, phi, psi, xy_in);
init_wave_flat_mod(phi, psi, xy_in);
// init_circular_wave_mod(-0.5, 0.0, phi, psi, xy_in);
// add_circular_wave_mod(1.0, 1.0, 0.0, phi, psi, xy_in);
// printf("Wave initialized\n");

View File

@ -49,7 +49,7 @@
#define NO_EXTRA_BUFFER_SWAP 1 /* some OS require one less buffer swap when recording images */
#define VARIABLE_IOR 0 /* set to 1 for a variable index of refraction */
#define IOR 13 /* choice of index of refraction, see list in global_pdes.c */
#define IOR 17 /* choice of index of refraction, see list in global_pdes.c */
#define IOR_TOTAL_TURNS 1.5 /* total angle of rotation for IOR_PERIODIC_WELLS_ROTATING */
#define MANDEL_IOR_SCALE -0.05 /* parameter controlling dependence of IoR on Mandelbrot escape speed */
@ -60,8 +60,8 @@
#define NX 3840 /* number of grid points on x axis */
#define NY 2300 /* number of grid points on y axis */
#define XMIN -2.0
#define XMAX 2.0 /* x interval */
#define XMIN -1.6
#define XMAX 2.4 /* x interval */
#define YMIN -1.197916667
#define YMAX 1.197916667 /* y interval for 9/16 aspect ratio */
@ -71,7 +71,7 @@
/* Choice of the billiard table */
#define B_DOMAIN 521 /* choice of domain shape, see list in global_pdes.c */
#define B_DOMAIN 75 /* choice of domain shape, see list in global_pdes.c */
#define CIRCLE_PATTERN 103 /* pattern of circles or polygons, see list in global_pdes.c */
@ -83,8 +83,8 @@
#define NPOISSON 1000 /* number of points for Poisson C_RAND_POISSON arrangement */
#define RANDOM_POLY_ANGLE 1 /* set to 1 to randomize angle of polygons */
#define LAMBDA 1.0 /* parameter controlling the dimensions of domain */
#define MU 0.48 /* parameter controlling the dimensions of domain */
#define LAMBDA 3.0 /* parameter controlling the dimensions of domain */
#define MU 0.14 /* parameter controlling the dimensions of domain */
#define MU_B 0.42 /* parameter controlling the dimensions of domain */
#define NPOLY 6 /* number of sides of polygon */
#define APOLY -0.666666666666 /* angle by which to turn polygon, in units of Pi/2 */
@ -95,6 +95,7 @@
#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 10 /* number of grid point for grid of disks */
#define WALL_WIDTH 0.1 /* width of wall separating lenses */
#define X_SHOOTER -0.2
#define Y_SHOOTER -0.6
@ -112,19 +113,20 @@
/* Physical parameters of wave equation */
#define TWOSPEEDS 1 /* set to 1 to replace hardcore boundary by medium with different speed */
#define OSCILLATE_LEFT 0 /* set to 1 to add oscilating boundary condition on the left */
#define TWOSPEEDS 0 /* set to 1 to replace hardcore boundary by medium with different speed */
#define OSCILLATE_LEFT 1 /* set to 1 to add oscilating boundary condition on the left */
#define OSCILLATE_TOPBOT 0 /* set to 1 to enforce a planar wave on top and bottom boundary */
#define OSCILLATION_SCHEDULE 0 /* oscillation schedule, see list in global_pdes.c */
#define OSCIL_YMAX 0.35 /* defines oscillation range */
#define OMEGA 0.01 /* frequency of periodic excitation */
#define OMEGA 0.015 /* frequency of periodic excitation */
#define AMPLITUDE 1.0 /* amplitude of periodic excitation */
#define ACHIRP 0.25 /* acceleration coefficient in chirp */
#define DAMPING 0.0 /* damping of periodic excitation */
#define COURANT 0.06 /* Courant number */
#define COURANTB 0.18 /* Courant number in medium B */
#define COURANT 0.1 /* Courant number */
#define COURANTB 0.03 /* Courant number in medium B */
#define GAMMA 0.0 /* damping factor in wave equation */
#define GAMMAB 0.007 /* damping factor in wave equation */
#define GAMMAB 0.0 /* damping factor in wave equation */
#define GAMMA_SIDES 1.0e-4 /* damping factor on boundary */
#define GAMMA_TOPBOT 1.0e-7 /* damping factor on boundary */
#define KAPPA 0.0 /* "elasticity" term enforcing oscillations */
@ -136,25 +138,27 @@
/* Increasing COURANT speeds up the simulation, but decreases accuracy */
/* For similar wave forms, COURANT^2*GAMMA should be kept constant */
#define ADD_OSCILLATING_SOURCE 1 /* set to 1 to add an oscillating wave source */
#define OSCILLATING_SOURCE_PERIOD 8 /* period of oscillating source */
#define ADD_OSCILLATING_SOURCE 0 /* set to 1 to add an oscillating wave source */
#define OSCILLATING_SOURCE_PERIOD 4 /* period of oscillating source */
#define ALTERNATE_OSCILLATING_SOURCE 1 /* set to 1 to alternate sign of oscillating source */
#define ADD_WAVE_PACKET_SOURCES 0 /* set to 1 to add several sources emitting wave packets */
#define WAVE_PACKET_SOURCE_TYPE 2 /* type of wave packet sources */
#define N_WAVE_PACKETS 2 /* number of wave packets */
#define WAVE_PACKET_RADIUS 25 /* radius of wave packets */
#define WAVE_PACKET_SOURCE_TYPE 3 /* type of wave packet sources */
#define N_WAVE_PACKETS 5 /* number of wave packets */
#define WAVE_PACKET_RADIUS 50 /* radius of wave packets */
#define USE_INPUT_TIMESERIES 1 /* set to 1 to use a time series (Morse code) as input * /
/* Boundary conditions, see list in global_pdes.c */
#define B_COND 2
#define B_COND 3
/* Parameters for length and speed of simulation */
#define NSTEPS 2700 /* number of frames of movie */
#define NVID 20 /* number of iterations between images displayed on screen */
#define NSTEPS 2200 /* number of frames of movie */
#define NVID 15 /* 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 INITIAL_TIME 50 /* time after which to start saving frames */
#define BOUNDARY_WIDTH 2 /* width of billiard boundary */
#define PRINT_SPEED 0 /* print speed of moving source */
#define PRINT_FREQUENCY 0 /* print frequency (for phased array) */
@ -169,15 +173,15 @@
/* Parameters of initial condition */
#define INITIAL_AMP 0.5 /* amplitude of initial condition */
#define INITIAL_VARIANCE 0.000012 /* variance of initial condition */
#define INITIAL_WAVELENGTH 0.05 /* wavelength of initial condition */
#define INITIAL_AMP 0.75 /* amplitude of initial condition */
#define INITIAL_VARIANCE 0.01 /* variance of initial condition */
#define INITIAL_WAVELENGTH 0.025 /* wavelength of initial condition */
/* Plot type, see list in global_pdes.c */
#define PLOT 0
#define PLOT_B 5 /* plot type for second movie */
#define PLOT_B 8 /* plot type for second movie */
/* Color schemes */
@ -192,11 +196,12 @@
#define SLOPE 1.0 /* sensitivity of color on wave amplitude */
#define PHASE_FACTOR 1.0 /* factor in computation of phase in color scheme P_3D_PHASE */
#define PHASE_SHIFT 0.0 /* shift of phase in color scheme P_3D_PHASE */
#define ATTENUATION 0.0 /* exponential attenuation coefficient of contrast with time */
#define E_SCALE 40.0 /* scaling factor for energy representation */
#define LOG_SCALE 1.0 /* scaling factor for energy log representation */
#define LOG_SHIFT 1.25 /* shift of colors on log scale */
#define FLUX_SCALE 5.0e3 /* scaling factor for enegy flux represtnation */
#define ATTENUATION 0.0 /* exponential attenuation coefficient of contrast with time */
#define E_SCALE 75.0 /* scaling factor for energy representation */
#define LOG_SCALE 0.75 /* scaling factor for energy log representation */
#define LOG_SHIFT 1.5 /* shift of colors on log scale */
#define FLUX_SCALE 5.0e3 /* scaling factor for energy flux represtnation */
#define AVRG_E_FACTOR 0.95 /* 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 COLORHUE 260 /* initial hue of water color for scheme C_LUM */
@ -206,17 +211,31 @@
#define HUEMEAN 180.0 /* mean value of hue for color scheme C_HUE */
#define HUEAMP -180.0 /* amplitude of variation of hue for color scheme C_HUE */
#define DRAW_COLOR_SCHEME 1 /* set to 1 to plot the color scheme */
#define COLORBAR_RANGE 1.5 /* scale of color scheme bar */
#define COLORBAR_RANGE_B 0.4 /* scale of color scheme bar for 2nd part */
#define ROTATE_COLOR_SCHEME 0 /* set to 1 to draw color scheme horizontally */
#define DRAW_COLOR_SCHEME 0 /* set to 1 to plot the color scheme */
#define COLORBAR_RANGE 3.0 /* scale of color scheme bar */
#define COLORBAR_RANGE_B 1.5 /* scale of color scheme bar for 2nd part */
#define ROTATE_COLOR_SCHEME 1 /* 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 */
#define DRAW_WAVE_PROFILE 0 /* set to 1 to draw a profile of the wave */
#define VERTICAL_WAVE_PROFILE 0 /* set to 1 to draw wave profile vertically */
#define DRAW_WAVE_TIMESERIES 0 /* set to 1 to draw a time series of the wave */
#define DRAW_WAVE_PROFILE 1 /* set to 1 to draw a profile of the wave */
#define HORIZONTAL_WAVE_PROFILE 0 /* set to 1 to draw wave profile vertically */
#define VERTICAL_WAVE_PROFILE 1 /* set to 1 to draw wave profile vertically */
#define WAVE_PROFILE_X 2.1 /* value of x to sample wave profile */
#define WAVE_PROFILE_Y -1.0 /* value of y to sample wave profile */
#define PROFILE_AT_BOTTOM 1 /* draw wave profile at bottom instead of top */
#define AVERAGE_WAVE_PROFILE 1 /* set to 1 to draw time-average of wave profile squared*/
#define DRAW_WAVE_TIMESERIES 0 /* set to 1 to draw a time series of the wave, 2 to also draw it at the top */
#define TIMESERIES_NVALUES 400 /* number of values plotted in time series */
#define SAVE_TIME_SERIES 0 /* set to 1 to save wave time series at a point */
#define DRAW_WAVE_SOURCE 0 /* set to 1 to draw source of wave at (wave_source_x, wave_source_y) */
#define MESSAGE_LDASH 14 /* length of dash for Morse code message */
#define MESSAGE_LDOT 8 /* length of dot for Morse code message */
#define MESSAGE_LINTERVAL 54 /* length of interval between dashes/dots for Morse code message */
#define MESSAGE_LINTERLETTER 60 /* length of interval between letters for Morse code message */
#define MESSAGE_LSPACE 48 /* length of space for Morse code message */
#define MESSAGE_INITIAL_TIME 100 /* initial time before starting message for Morse code message */
#define NXMAZE 8 /* width of maze */
#define NYMAZE 32 /* height of maze */
@ -259,7 +278,7 @@ void evolve_wave_half(double *phi_in[NX], double *psi_in[NX], double *phi_out[NX
/* phi is value of field at time t, psi at time t-1 */
/* this version of the function has been rewritten in order to minimize the number of if-branches */
{
int i, j, iplus, iminus, jplus, jminus;
int i, j, iplus, iminus, jplus, jminus, ij[2];
double delta, x, y, c, cc, gamma, tb_shift;
static long time = 0;
static double tc[NX][NY];
@ -339,13 +358,13 @@ void evolve_wave_half(double *phi_in[NX], double *psi_in[NX], double *phi_out[NX
}
case (BC_ABSORBING):
{
delta = phi_in[1][j] + phi_in[0][j+1] + phi_in[0][j-1] - 3.0*x;
// delta = phi_in[1][j] + phi_in[0][j+1] + phi_in[0][j-1] - 3.0*x;
phi_out[0][j] = x - tc[0][j]*(x - phi_in[1][j]) - KAPPA_SIDES*x - GAMMA_SIDES*(x-y);
break;
}
case (BC_VPER_HABS):
{
delta = phi_in[1][j] + phi_in[0][j+1] + phi_in[0][j-1] - 3.0*x;
// delta = phi_in[1][j] + phi_in[0][j+1] + phi_in[0][j-1] - 3.0*x;
phi_out[0][j] = x - tc[0][j]*(x - phi_in[1][j]) - KAPPA_SIDES*x - GAMMA_SIDES*(x-y);
break;
}
@ -375,13 +394,13 @@ void evolve_wave_half(double *phi_in[NX], double *psi_in[NX], double *phi_out[NX
}
case (BC_ABSORBING):
{
delta = phi_in[NX-2][j] + phi_in[NX-1][j+1] + phi_in[NX-1][j-1] - 3.0*x;
// delta = phi_in[NX-2][j] + phi_in[NX-1][j+1] + phi_in[NX-1][j-1] - 3.0*x;
phi_out[NX-1][j] = x - tc[NX-1][j]*(x - phi_in[NX-2][j]) - KAPPA_SIDES*x - GAMMA_SIDES*(x-y);
break;
}
case (BC_VPER_HABS):
{
delta = phi_in[NX-2][j] + phi_in[NX-1][j+1] + phi_in[NX-1][j-1] - 3.0*x;
// delta = phi_in[NX-2][j] + phi_in[NX-1][j+1] + phi_in[NX-1][j-1] - 3.0*x;
phi_out[NX-1][j] = x - tc[NX-1][j]*(x - phi_in[NX-2][j]) - KAPPA_SIDES*x - GAMMA_SIDES*(x-y);
break;
}
@ -426,10 +445,10 @@ void evolve_wave_half(double *phi_in[NX], double *psi_in[NX], double *phi_out[NX
}
case (BC_ABSORBING):
{
iplus = (i+1); if (iplus == NX) iplus = NX-1;
iminus = (i-1); if (iminus == -1) iminus = 0;
// iplus = (i+1); if (iplus == NX) iplus = NX-1;
// iminus = (i-1); if (iminus == -1) iminus = 0;
delta = phi_in[iplus][NY-1] + phi_in[iminus][NY-1] + phi_in[i][NY-2] - 3.0*x;
// delta = phi_in[iplus][NY-1] + phi_in[iminus][NY-1] + phi_in[i][NY-2] - 3.0*x;
phi_out[i][NY-1] = x - tc[i][NY-1]*(x - phi_in[i][NY-2]) - KAPPA_TOPBOT*x - GAMMA_TOPBOT*(x-y);
break;
}
@ -484,10 +503,10 @@ void evolve_wave_half(double *phi_in[NX], double *psi_in[NX], double *phi_out[NX
}
case (BC_ABSORBING):
{
iplus = (i+1); if (iplus == NX) iplus = NX-1;
iminus = (i-1); if (iminus == -1) iminus = 0;
delta = phi_in[iplus][0] + phi_in[iminus][0] + phi_in[i][1] - 3.0*x;
// iplus = (i+1); if (iplus == NX) iplus = NX-1;
// iminus = (i-1); if (iminus == -1) iminus = 0;
//
// delta = phi_in[iplus][0] + phi_in[iminus][0] + phi_in[i][1] - 3.0*x;
phi_out[i][0] = x - tc[i][0]*(x - phi_in[i][1]) - KAPPA_TOPBOT*x - GAMMA_TOPBOT*(x-y);
break;
}
@ -571,11 +590,12 @@ void draw_color_bar_palette(int plot, double range, int palette, int circular, i
void animation()
{
double time, scale, ratio, startleft[2], startright[2], sign = 1.0, r2, xy[2], fade_value, yshift, speed = 0.0, a, b, c, x, y, angle = 0.0, x1, sign1, ior_angle = 0.0, omega, phase_shift;
double *phi[NX], *psi[NX], *tmp[NX], *total_energy[NX], *color_scale[NX], *total_flux, *tcc_table[NX], *tgamma_table[NX];
double time, scale, ratio, startleft[2], startright[2], sign = 1.0, r2, xy[2], fade_value, yshift, speed = 0.0, a, b, c, x, y, angle = 0.0, x1, sign1, ior_angle = 0.0, omega, phase_shift, vshift;
double *phi[NX], *psi[NX], *tmp[NX], *total_energy[NX], *average_energy[NX], *color_scale[NX], *total_flux, *tcc_table[NX], *tgamma_table[NX];
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;
static int counter = 0;
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];
// static int image_counter = 0;
int image_counter = 0;
long int wave_value;
t_wave_packet *packet;
t_wave_source wave_source[25];
@ -593,6 +613,7 @@ void animation()
psi[i] = (double *)malloc(NY*sizeof(double));
tmp[i] = (double *)malloc(NY*sizeof(double));
total_energy[i] = (double *)malloc(NY*sizeof(double));
average_energy[i] = (double *)malloc(NY*sizeof(double));
xy_in[i] = (short int *)malloc(NY*sizeof(short int));
color_scale[i] = (double *)malloc(NY*sizeof(double));
tcc_table[i] = (double *)malloc(NX*sizeof(double));
@ -624,7 +645,7 @@ void animation()
printf("Rotated rectangles and arcs initialized\n");
printf("%i rotated rectangles, %i arcs\n", npolyrect_rot, npolyarc);
if (DRAW_WAVE_TIMESERIES) init_input_signal();
if ((DRAW_WAVE_TIMESERIES)||(USE_INPUT_TIMESERIES)) init_input_signal();
courant2 = COURANT*COURANT;
courantb2 = COURANTB*COURANTB;
@ -650,6 +671,12 @@ void animation()
for (i=0; i<NX; i++)
for (j=0; j<NY; j++)
total_energy[i][j] = 0.0;
/* initialize average energy table */
if ((PLOT == P_AVERAGE_ENERGY)||(PLOT_B == P_AVERAGE_ENERGY)||(PLOT == P_LOG_AVERAGE_ENERGY)||(PLOT_B == P_LOG_AVERAGE_ENERGY))
for (i=0; i<NX; i++)
for (j=0; j<NY; j++)
average_energy[i][j] = 0.0;
if (MEAN_FLUX)
for (i=0; i<4*NX*NY; i++)
@ -657,6 +684,17 @@ void animation()
ratio = (XMAX - XMIN)/8.4; /* for Tokarsky billiard */
if (B_DOMAIN == D_MICHELSON_MOVING)
{
xy_to_ij(michelson_schedule(0) - 0.1, YMIN, ij);
imin = ij[0];
xy_to_ij(michelson_schedule(NSTEPS) + 0.1, YMIN, ij);
imax = ij[0];
// imin = NX/2;
// imax = NX;
printf("imin = %i, imax = %i\n", imin, imax);
}
// isospectral_initial_point(0.2, 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);
@ -707,7 +745,9 @@ void animation()
// init_circular_wave(-2.0*ratio, 0.0, phi, psi, xy_in);
// init_planar_wave(XMIN + 0.015, 0.0, phi, psi, xy_in);
// init_planar_wave(XMIN + 0.02, 0.0, phi, psi, xy_in);
// init_planar_wave(XMIN + 0.5, 0.0, phi, psi, xy_in);
// init_planar_travelling_wave(XMIN + 0.1, 0.3, 1.0, phi, psi, xy_in);
// add_planar_travelling_wave(XMIN + 0.05, 0.0, 1.0, 0.3, phi, psi, xy_in);
// init_wave(-1.5, 0.0, phi, psi, xy_in);
// init_wave(0.0, 0.0, phi, psi, xy_in);
@ -719,10 +759,10 @@ void animation()
blank();
glColor3f(0.0, 0.0, 0.0);
// draw_wave(phi, psi, xy_in, 1.0, 0, PLOT);
if (HIGHRES) draw_wave_highres_palette(2, phi, psi, total_energy, total_flux, xy_in, 1.0, 0, PLOT, COLOR_PALETTE, 0, 1.0);
else draw_wave_epalette(phi, psi, total_energy, total_flux, color_scale, xy_in, 1.0, 0, PLOT, COLOR_PALETTE, 0, 1.0);
if (HIGHRES) draw_wave_highres_palette(2, phi, psi, total_energy, average_energy, total_flux, xy_in, 1.0, 0, PLOT, COLOR_PALETTE, 1, 0, 1.0);
else draw_wave_epalette(phi, psi, total_energy, average_energy, total_flux, color_scale, xy_in, 1.0, 0, PLOT, COLOR_PALETTE, 0, 1.0);
draw_billiard(0, 1.0);
// draw_billiard(0, 1.0);
if (DRAW_COLOR_SCHEME) draw_color_bar_palette(PLOT, COLORBAR_RANGE, COLOR_PALETTE, CIRC_COLORBAR, fade, fade_value);
@ -756,8 +796,8 @@ void animation()
else scale = 1.0;
// draw_wave(phi, psi, xy_in, scale, i, PLOT);
if (HIGHRES) draw_wave_highres_palette(2, phi, psi, total_energy, total_flux, xy_in, scale, i, PLOT, COLOR_PALETTE, 0, 1.0);
else draw_wave_epalette(phi, psi, total_energy, total_flux, color_scale, xy_in, scale, i, PLOT, COLOR_PALETTE, 0, 1.0);
if (HIGHRES) draw_wave_highres_palette(2, phi, psi, total_energy, average_energy, total_flux, xy_in, scale, i, PLOT, COLOR_PALETTE, 0, 0, 1.0);
else draw_wave_epalette(phi, psi, total_energy, average_energy, total_flux, color_scale, xy_in, scale, i, PLOT, COLOR_PALETTE, 0, 1.0);
for (j=0; j<NVID; j++)
{
evolve_wave(phi, psi, tmp, xy_in, tcc_table, tgamma_table);
@ -773,94 +813,34 @@ void animation()
// if (i % 10 == 9) oscillate_linear_wave(0.2*scale, 0.15*(double)(i*NVID + j), -1.5, YMIN, -1.5, YMAX, phi, psi);
}
draw_billiard(0, 1.0);
// draw_billiard(0, 1.0);
if (DRAW_COLOR_SCHEME) draw_color_bar_palette(PLOT, COLORBAR_RANGE, COLOR_PALETTE, CIRC_COLORBAR, fade, fade_value);
/* add oscillating waves */
// if (ADD_OSCILLATING_SOURCE)
if ((ADD_OSCILLATING_SOURCE)&&(i%OSCILLATING_SOURCE_PERIOD == 1))
{
if (ALTERNATE_OSCILLATING_SOURCE) sign = -sign;
add_circular_wave(sign, -1.5, 0.8, phi, psi, xy_in);
add_circular_wave(sign, -1.5, -0.35, phi, psi, xy_in);
// p = phased_array_schedule(i);
// phase_shift = 0.02 + 0.06*(double)i/(double)NSTEPS;
wave_source_x = -1.75;
wave_source_y = -0.5 + (YMAX - YMIN)*(double)i/(double)NSTEPS;
add_circular_wave(sign, wave_source_x, wave_source_y, phi, psi, xy_in);
// if (first_source) for (k=0; k<25; k++)
// {
// omega = DPI/25.0;
// wave_source[k].xc = 0.05*cos((double)k*omega);;
// wave_source[k].yc = 0.05*sin((double)k*omega);
// wave_source[k].phase = 0.99 - 1.4*sin(0.7*(1.0 + wave_source[k].xc/0.05));
// wave_source[k].amp = 1.0;
// if (wave_source[k].phase) wave_source[k].sign = 1;
// else wave_source[k].sign = -1;
// first_source = 0;
// }
//
// for (k=0; k<25; k++)
// wave_source[k].phase += 1.4*sin(0.7*(1.0 + wave_source[k].xc*cos(angle)/0.05 + wave_source[k].yc*sin(angle)/0.05));
//
// angle = DPI*(double)i/(double)NSTEPS;
//
// for (k=0; k<25; k++)
// {
// wave_source[k].phase += 0.07;
// wave_source[k].phase -= 1.4*sin(0.7*(1.0 + wave_source[k].xc*cos(angle)/0.05 + wave_source[k].yc*sin(angle)/0.05));
//
// if (wave_source[k].phase > 1.0)
// {
// add_circular_wave((double)wave_source[k].sign*wave_source[k].amp, wave_source[k].xc, wave_source[k].yc, phi, psi, xy_in);
// printf("Adding wave at (%.2lg, %.2lg)\n", wave_source[k].xc, wave_source[k].yc);
// wave_source[k].phase -= 1.0;
// wave_source[k].sign *= -1;
// }
// }
// p = 3;
// y = -1.0;
// sign1 = sign;
// printf("p = %i\n", p);
// for (k=-12; k<13; k++)
// if (input_signal[i])
// {
// x1 = 0.05*((double)source_counter/(double)p + (double)k);
// if ((x1 > 0.1*XMIN)&&(x1 < 0.1*XMAX))
// {
// add_circular_wave(sign1, x1, y, phi, psi, xy_in);
// printf("Adding wave at (%.2lg, %.2lg)\n", x1, y);
// }
// sign1 = -sign1;
// add_vertical_wave(sign, -2.0, 0.5 - y, 0.5 + y, phi, psi, xy_in);
// add_vertical_wave(sign, -2.0, -0.5 - y, -0.5 + y, phi, psi, xy_in);
// }
// source_counter++;
// if (p > 0) q = p;
// else q = -p;
// if (source_counter >= q)
// {
// source_counter = 0;
// sign = -sign;
// else
// {
// damp_vertical_wave(0.01, 20, -2.0, 0.5 - y, 0.5 + y, phi, psi);
// damp_vertical_wave(0.01, 20, -2.0, -0.5 - y, -0.5 + y, phi, psi);
// }
// for (j=0; j<NPOLY; j++)
// add_circular_wave(sign, 2.0*LAMBDA*cos((double)j*angle + APOLY*PID), 2.0*LAMBDA*sin((double)j*angle + APOLY*PID), phi, psi, xy_in);
// x = XMIN + (XMAX - XMIN)*rand()/RAND_MAX;
// y = YMIN + (YMAX - YMIN)*rand()/RAND_MAX;
// add_circular_wave(sign, 0.0, 0.0, phi, psi, xy_in);
// add_circular_wave(1.0, -1.5*LAMBDA, 0.0, phi, psi, xy_in);
// add_circular_wave(-1.0, 0.6*cos((double)(period)*DPI/3.0), 0.6*sin((double)(period)*DPI/3.0), phi, psi, xy_in);
// period++;
//
// yshift = (double)period*a + (double)(period*period)*b;
// add_circular_wave(sign, -1.5 + yshift, 0.0, phi, psi, xy_in);
// // speed = (a + 2.0*(double)(period)*b)/((double)(NVID));
// // speed = 0.55*(a + 2.0*(double)(period)*b)/((double)(NVID*OSCILLATING_SOURCE_PERIOD));
// speed = (a + 2.0*(double)(period)*b)/((double)(3*NVID*OSCILLATING_SOURCE_PERIOD));
// printf("v = %.3lg, c = %.3lg\n", speed, c);
// speed = speed/c;
// speed = 120.0*speed/((double)NVID*COURANT);
}
if (ADD_WAVE_PACKET_SOURCES) add_wave_packets(phi, psi, xy_in, packet, i, WAVE_PACKET_RADIUS, 1, 4, 2);
if (ADD_WAVE_PACKET_SOURCES) add_wave_packets(phi, psi, xy_in, packet, i, WAVE_PACKET_RADIUS, 1, 4, 1);
if (PRINT_SPEED) print_speed(speed, 0, 1.0);
if (PRINT_FREQUENCY) print_frequency(phase_shift, 0, 1.0);
if ((VARIABLE_IOR)&&(REFRESH_IOR)&&(i%3 == 0))
@ -870,6 +850,12 @@ void animation()
init_ior_2d(xy_in, tcc_table, tgamma_table, ior_angle);
printf("speed = %.5lg\n", tcc_table[3*NX/4][NY/2]);
}
if (B_DOMAIN == D_MICHELSON_MOVING)
{
michelson_position = michelson_schedule(i);
printf("Michelson mirror position %.3lg\n", michelson_position);
init_xy_tcc_in_xrange(xy_in, tcc_table, tgamma_table, imin, imax);
}
if (!((NO_EXTRA_BUFFER_SWAP)&&(MOVIE))) glutSwapBuffers();
@ -882,15 +868,17 @@ void animation()
{
// draw_wave(phi, psi, xy_in, scale, i, PLOT_B);
if (HIGHRES)
draw_wave_highres_palette(2, phi, psi, total_energy, total_flux, xy_in, scale, i, PLOT_B, COLOR_PALETTE_B, 0, 1.0);
else draw_wave_epalette(phi, psi, total_energy, total_flux, color_scale, xy_in, scale, i, PLOT_B, COLOR_PALETTE_B, 0, 1.0);
draw_billiard(0, 1.0);
draw_wave_highres_palette(2, phi, psi, total_energy, average_energy, total_flux, xy_in, scale, i, PLOT_B, COLOR_PALETTE_B, 1, 0, 1.0);
else draw_wave_epalette(phi, psi, total_energy, average_energy, total_flux, color_scale, xy_in, scale, i, PLOT_B, COLOR_PALETTE_B, 0, 1.0);
// draw_billiard(0, 1.0);
if (DRAW_COLOR_SCHEME) draw_color_bar_palette(PLOT_B, COLORBAR_RANGE_B, COLOR_PALETTE_B, CIRC_COLORBAR_B, 0, 1.0);
if (PRINT_SPEED) print_speed(speed, 0, 1.0);
if (PRINT_FREQUENCY) print_frequency(phase_shift, 0, 1.0);
glutSwapBuffers();
save_frame_counter(NSTEPS + MID_FRAMES + 1 + counter);
counter++;
// printf("image_counter = %i\n", image_counter);
// printf("image number = %i\n", NSTEPS + MID_FRAMES + 1 + image_counter);
save_frame_counter(NSTEPS + MID_FRAMES + 1 + image_counter);
image_counter++;
}
else if (NO_EXTRA_BUFFER_SWAP) glutSwapBuffers();
@ -911,9 +899,9 @@ void animation()
if (DOUBLE_MOVIE)
{
// draw_wave(phi, psi, xy_in, scale, i, PLOT);
if (HIGHRES) draw_wave_highres_palette(2, phi, psi, total_energy, total_flux, xy_in, scale, NSTEPS, PLOT, COLOR_PALETTE, 0, 1.0);
else draw_wave_epalette(phi, psi, total_energy, total_flux, color_scale, xy_in, scale, NSTEPS, PLOT, COLOR_PALETTE, 0, 1.0);
draw_billiard(0, 1.0);
if (HIGHRES) draw_wave_highres_palette(2, phi, psi, total_energy, average_energy, total_flux, xy_in, scale, NSTEPS, PLOT, COLOR_PALETTE, 0, 0, 1.0);
else draw_wave_epalette(phi, psi, total_energy, average_energy, total_flux, color_scale, xy_in, scale, NSTEPS, PLOT, COLOR_PALETTE, 0, 1.0);
// draw_billiard(0, 1.0);
if (DRAW_COLOR_SCHEME) draw_color_bar_palette(PLOT, COLORBAR_RANGE, COLOR_PALETTE, CIRC_COLORBAR, 0, 1.0);
if (PRINT_SPEED) print_speed(speed, 0, 1.0);
if (PRINT_FREQUENCY) print_frequency(phase_shift, 0, 1.0);
@ -924,9 +912,9 @@ void animation()
{
fade_value = 1.0 - (double)i/(double)MID_FRAMES;
if (HIGHRES)
draw_wave_highres_palette(2, phi, psi, total_energy, total_flux, xy_in, scale, NSTEPS, PLOT, COLOR_PALETTE, 1, fade_value);
else draw_wave_epalette(phi, psi, total_energy, total_flux, color_scale, xy_in, scale, NSTEPS, PLOT, COLOR_PALETTE, 1, fade_value);
draw_billiard(1, fade_value);
draw_wave_highres_palette(2, phi, psi, total_energy, average_energy, total_flux, xy_in, scale, NSTEPS, PLOT, COLOR_PALETTE, 0, 1, fade_value);
else draw_wave_epalette(phi, psi, total_energy, average_energy, total_flux, color_scale, xy_in, scale, NSTEPS, PLOT, COLOR_PALETTE, 1, fade_value);
// draw_billiard(1, fade_value);
if (DRAW_COLOR_SCHEME) draw_color_bar_palette(PLOT, COLORBAR_RANGE, COLOR_PALETTE, CIRC_COLORBAR, 1, fade_value);
if (PRINT_SPEED) print_speed(speed, 1, fade_value);
if (PRINT_FREQUENCY) print_frequency(phase_shift, 1, fade_value);
@ -937,27 +925,27 @@ void animation()
{
// draw_wave(phi, psi, xy_in, scale, i, PLOT_B);
if (HIGHRES)
draw_wave_highres_palette(2, phi, psi, total_energy, total_flux, xy_in, scale, NSTEPS, PLOT_B, COLOR_PALETTE_B, 0, 1.0);
else draw_wave_epalette(phi, psi, total_energy, total_flux, color_scale, xy_in, scale, NSTEPS, PLOT_B, COLOR_PALETTE_B, 0, 1.0);
draw_billiard(0, 1.0);
draw_wave_highres_palette(2, phi, psi, total_energy, average_energy, total_flux, xy_in, scale, NSTEPS, PLOT_B, COLOR_PALETTE_B, 1, 0, 1.0);
else draw_wave_epalette(phi, psi, total_energy, average_energy, total_flux, color_scale, xy_in, scale, NSTEPS, PLOT_B, COLOR_PALETTE_B, 0, 1.0);
// draw_billiard(0, 1.0);
if (DRAW_COLOR_SCHEME) draw_color_bar_palette(PLOT_B, COLORBAR_RANGE_B, COLOR_PALETTE_B, CIRC_COLORBAR_B, 0, 1.0);
if (PRINT_SPEED) print_speed(speed, 0, 1.0);
if (PRINT_FREQUENCY) print_frequency(phase_shift, 0, 1.0);
glutSwapBuffers();
if (!FADE) for (i=0; i<END_FRAMES; i++) save_frame_counter(NSTEPS + MID_FRAMES + 1 + counter + i);
if (!FADE) for (i=0; i<END_FRAMES; i++) save_frame_counter(NSTEPS + MID_FRAMES + 1 + image_counter + i);
else for (i=0; i<END_FRAMES; i++)
{
fade_value = 1.0 - (double)i/(double)END_FRAMES;
if (HIGHRES)
draw_wave_highres_palette(2, phi, psi, total_energy, total_flux, xy_in, scale, NSTEPS, PLOT_B, COLOR_PALETTE_B, 1, fade_value);
else draw_wave_epalette(phi, psi, total_energy, total_flux, color_scale, xy_in, scale, NSTEPS, PLOT_B, COLOR_PALETTE_B, 1, fade_value);
draw_billiard(1, fade_value);
draw_wave_highres_palette(2, phi, psi, total_energy, average_energy, total_flux, xy_in, scale, NSTEPS, PLOT_B, COLOR_PALETTE_B, 1, 1, fade_value);
else draw_wave_epalette(phi, psi, total_energy, average_energy, total_flux, color_scale, xy_in, scale, NSTEPS, PLOT_B, COLOR_PALETTE_B, 1, fade_value);
// draw_billiard(1, fade_value);
if (DRAW_COLOR_SCHEME) draw_color_bar_palette(PLOT_B, COLORBAR_RANGE_B, COLOR_PALETTE_B, CIRC_COLORBAR_B, 1, fade_value);
if (PRINT_SPEED) print_speed(speed, 1, fade_value);
if (PRINT_FREQUENCY) print_frequency(phase_shift, 0, 1.0);
glutSwapBuffers();
save_frame_counter(NSTEPS + MID_FRAMES + 1 + counter + i);
save_frame_counter(NSTEPS + MID_FRAMES + 1 + image_counter + i);
}
}
@ -967,10 +955,9 @@ void animation()
{
free(phi[i]);
free(psi[i]);
// free(phi_tmp[i]);
// free(psi_tmp[i]);
free(tmp[i]);
free(total_energy[i]);
free(average_energy[i]);
free(xy_in[i]);
free(color_scale[i]);
free(tcc_table[i]);

View File

@ -32,6 +32,38 @@ void init_xyin_xrange(short int * xy_in[NX], int imin, int imax)
}
}
void init_xy_tcc_in_xrange(short int * xy_in[NX], double *tcc_table[NX], double *tgamma_table[NX], int imin, int imax)
/* initialise table xy_in, needed when obstacles are killed */
// short int * xy_in[NX];
//
{
int i, j;
double xy[2];
// for (i=imin; i<imax; i++)
for (i=NX/2; i<NX; i++)
for (j=0; j<NY; j++)
{
ij_to_xy(i, j, xy);
xy_in[i][j] = xy_in_billiard(xy[0],xy[1]);
// xy_in[i][j] = 1;
if (xy_in[i][j] == 0)
{
tcc_table[i][j] = COURANT*COURANT;
tgamma_table[i][j] = GAMMA;
}
else if (xy_in[i][j] == 2)
{
tcc_table[i][j] = 0.0;
tgamma_table[i][j] = 1.0;
}
else
{
tcc_table[i][j] = COURANTB*COURANTB;
tgamma_table[i][j] = GAMMAB;
}
}
}
void init_wave(double x, double y, double *phi[NX], double *psi[NX], short int * xy_in[NX])
/* initialise field with drop at (x,y) - phi is wave height, psi is phi at time t-1 */
@ -78,6 +110,36 @@ void init_circular_wave(double x, double y, double *phi[NX], double *psi[NX], sh
}
}
void damp_circular_wave(double factor, int range, double x, double y, double *phi[NX], double *psi[NX])
/* damp field around (x,y) - phi is wave height, psi is phi at time t-1 */
{
int i, j, ij[2], imin, imax, jmin, jmax;
double r2, v;
// printf("Damping wave\n");
xy_to_ij(x, y, ij);
imin = ij[0] - range;
if (imin < 0) imin = 0;
imax = ij[0] + range;
if (imax > NX-1) imax = NX-1;
jmin = ij[1] - range;
if (jmin < 0) jmin = 0;
jmax = ij[1] + range;
if (jmax > NY-1) jmax = NY-1;
v = (double)(range*range);
for (i=imin; i<imax; i++)
{
for (j=jmin; j<jmax; j++)
{
r2 = (double)((i - ij[0])*(i - ij[0]) + (j - ij[1])*(j - ij[1]));
factor *= 1.0 - exp(-0.5*r2/v);
phi[i][j] *= factor;
psi[i][j] *= factor;
}
}
}
void init_wave_plus(double x, double y, double *phi[NX], double *psi[NX], short int * xy_in[NX])
/* initialise field with drop at (x,y) for y > 0 - phi is wave height, psi is phi at time t-1 */
{
@ -151,6 +213,84 @@ void init_planar_wave(double x, double y, double *phi[NX], double *psi[NX], shor
}
void init_planar_travelling_wave(double x, double y, double vx, double *phi[NX], double *psi[NX], short int * xy_in[NX])
/* initialise field with drop at (x,y) - phi is wave height, psi is phi at time t-1 */
/* beta version, works for vertical planar wave only so far */
{
int i, j, ij[2], jmin, jmax;
double xy[2], dist2, dist2_shifted, xshift, y1;
xy_to_ij(x, y, ij);
jmax = ij[1];
jmin = NY - jmax;
xshift = vx*COURANT/(double)NX;
for (i=0; i<NX; i++)
{
for (j=0; j<NY; j++)
// for (j=jmin; j<jmax; j++)
{
ij_to_xy(i, j, xy);
dist2 = (xy[0]-x)*(xy[0]-x);
dist2_shifted = (xy[0]-x-xshift)*(xy[0]-x-xshift);
xy_in[i][j] = xy_in_billiard(xy[0],xy[1]);
if ((xy_in[i][j])||(TWOSPEEDS))
{
phi[i][j] = INITIAL_AMP*exp(-dist2/INITIAL_VARIANCE)*cos(-sqrt(dist2)/INITIAL_WAVELENGTH);
psi[i][j] = INITIAL_AMP*exp(-dist2_shifted/INITIAL_VARIANCE)*cos(-sqrt(dist2_shifted)/INITIAL_WAVELENGTH);
}
else
{
phi[i][j] = 0.0;
psi[i][j] = 0.0;
}
}
for (j=0; j<jmin; j++)
{
dist2 = (double)(jmin-1-j)*(YMAX-YMIN)/(double)NY;
dist2 = 500.0*dist2*dist2;
phi[i][j] *= exp(-dist2/INITIAL_VARIANCE);
psi[i][j] *= exp(-dist2/INITIAL_VARIANCE);
}
for (j=jmax; j<NY; j++)
{
phi[i][j] = phi[i][NY-1-j];
psi[i][j] = psi[i][NY-1-j];
}
}
}
void add_planar_travelling_wave(double x, double y, double vx, double wavelength_factor, double *phi[NX], double *psi[NX], short int * xy_in[NX])
/* initialise field with drop at (x,y) - phi is wave height, psi is phi at time t-1 */
/* beta version, works for vertical planar wave only so far */
{
int i, j;
double xy[2], dist2, dist2_shifted, xshift, wavelength;
xshift = vx*COURANT/(double)NX;
wavelength = INITIAL_WAVELENGTH*wavelength_factor;
for (i=0; i<NX; i++)
{
for (j=0; j<NY; j++)
{
ij_to_xy(i, j, xy);
dist2 = (xy[0]-x)*(xy[0]-x);
dist2_shifted = (xy[0]-x-xshift)*(xy[0]-x-xshift);
if ((xy_in[i][j])||(TWOSPEEDS))
{
phi[i][j] += INITIAL_AMP*exp(-dist2/INITIAL_VARIANCE)*cos(-sqrt(dist2)/wavelength);
psi[i][j] += INITIAL_AMP*exp(-dist2_shifted/INITIAL_VARIANCE)*cos(-sqrt(dist2_shifted)/wavelength);
}
else
{
phi[i][j] = 0.0;
psi[i][j] = 0.0;
}
}
}
}
void init_wave_flat( double *phi[NX], double *psi[NX], short int * xy_in[NX])
/* initialise flat field - phi is wave height, psi is phi at time t-1 */
{
@ -203,6 +343,57 @@ void add_circular_wave(double factor, double x, double y, double *phi[NX], doubl
}
void add_vertical_wave(double factor, double x, double y1, double y2, double *phi[NX], double *psi[NX], short int * xy_in[NX])
/* add wave around vertical segment (x,y1)-(x,y2) to the field with given prefactor */
{
int i, j;
double xy[2], dist2;
for (i=0; i<NX; i++)
for (j=0; j<NY; j++)
{
ij_to_xy(i, j, xy);
if (xy[1] < y1) dist2 = (xy[0]-x)*(xy[0]-x) + (xy[1]-y1)*(xy[1]-y1);
else if (xy[1] > y2) dist2 = (xy[0]-x)*(xy[0]-x) + (xy[1]-y2)*(xy[1]-y2);
else dist2 = (xy[0]-x)*(xy[0]-x);
if ((xy_in[i][j])||(TWOSPEEDS))
phi[i][j] += INITIAL_AMP*factor*exp(-dist2/INITIAL_VARIANCE)*cos(-sqrt(dist2)/INITIAL_WAVELENGTH);
}
}
void damp_vertical_wave(double factor, int range, double x, double y1, double y2, double *phi[NX], double *psi[NX])
/* damp field around (x,y) - phi is wave height, psi is phi at time t-1 */
{
int i, j, ij1[2], ij2[2], imin, imax, jmin, jmax;
double r2, v;
xy_to_ij(x, y1, ij1);
xy_to_ij(x, y2, ij2);
imin = ij1[0] - range;
if (imin < 0) imin = 0;
imax = ij2[0] + range;
if (imax > NX-1) imax = NX-1;
jmin = ij1[1] - range;
if (jmin < 0) jmin = 0;
jmax = ij2[1] + range;
if (jmax > NY-1) jmax = NY-1;
v = (double)(range*range);
for (i=imin; i<imax; i++)
{
for (j=jmin; j<jmax; j++)
{
if (j < ij1[1]) r2 = (double)((i - ij1[0])*(i - ij1[0]) + (j - ij1[1])*(j - ij1[1]));
else if (j > ij2[1]) r2 = (double)((i - ij2[0])*(i - ij2[0]) + (j - ij2[1])*(j - ij2[1]));
else r2 = (double)((i - ij1[0])*(i - ij1[0]));
factor *= 1.0 - exp(-0.5*r2/v);
phi[i][j] *= factor;
psi[i][j] *= factor;
}
}
}
void oscillate_linear_wave(double amplitude, double t, double x1, double y1, double x2, double y2, double *phi[NX],
double *psi[NX])
/* oscillating boundary condition at (x,y), beta version */
@ -720,9 +911,7 @@ void draw_wave_highres_diss(int size, double *phi[NX], double *psi[NX], double *
}
void draw_wave_epalette(double *phi[NX], double *psi[NX], double *total_energy[NX], double *total_flux,
double *color_scale[NX],
short int *xy_in[NX], double scale, int time, int plot, int palette, int fade, double fade_value)
void draw_wave_epalette(double *phi[NX], double *psi[NX], double *total_energy[NX], double *average_energy[NX], double *total_flux, double *color_scale[NX], short int *xy_in[NX], double scale, int time, int plot, int palette, int fade, double fade_value)
/* same as draw_wave_e, but with color scheme specification */
{
int i, j, k, iplus, iminus, jplus, jminus;
@ -853,7 +1042,7 @@ void draw_wave_epalette(double *phi[NX], double *psi[NX], double *total_energy[N
}
double wave_value(int i, int j, double *phi[NX], double *psi[NX], double *total_energy[NX], double *total_flux, short int *xy_in[NX], double scale, int time, int plot, int palette, double rgb[3])
double wave_value(int i, int j, double *phi[NX], double *psi[NX], double *total_energy[NX], double *average_energy[NX], double *total_flux, short int *xy_in[NX], double scale, int time, int plot, int palette, double rgb[3])
/* compute value of wave and color */
{
int k;
@ -940,52 +1129,100 @@ double wave_value(int i, int j, double *phi[NX], double *psi[NX], double *total_
for (k=0; k<3; k++) rgb[k] *= flux_factor;
break;
}
case (P_AVERAGE_ENERGY):
{
energy = compute_energy(phi, psi, xy_in, i, j);
average_energy[i][j] = AVRG_E_FACTOR*average_energy[i][j] + (1.0 - AVRG_E_FACTOR)*energy;
value = average_energy[i][j];
if (COLOR_PALETTE >= COL_TURBO)
color_scheme_asym_palette(COLOR_SCHEME, palette, value, scale, time, rgb);
else color_scheme_palette(COLOR_SCHEME, palette, value, scale, time, rgb);
break;
}
case (P_LOG_AVERAGE_ENERGY):
{
energy = compute_energy(phi, psi, xy_in, i, j);
average_energy[i][j] = AVRG_E_FACTOR*average_energy[i][j] + (1.0 - AVRG_E_FACTOR)*energy;
if (average_energy[i][j] == 0.0) value = LOG_SHIFT - 10.0*LOG_SCALE;
else value = LOG_SHIFT + LOG_SCALE*log(average_energy[i][j]);
color_scheme_palette(COLOR_SCHEME, palette, value, scale, time, rgb);
break;
}
}
return(value);
}
void draw_wave_profile_horizontal(double *values, int size, int fade, double fade_value)
void draw_wave_profile_horizontal(double *values, int size, int average, int pnb, int fade, double fade_value)
/* draw a horizontal profile of the wave, if option DRAW_WAVE_PROFILE is active */
{
int i, k;
double vmin, vmax, deltav, a, b, y;
static int imin, imax, jmin, jmax, jmid, d, first = 1;
static double deltaj, ymin;
int i, k, ij[2];
double deltav, a, b, y;
static int imin, imax, jmin, jmax, jmid, jval, d, first = 1;
static double vmin[2], vmax[2], deltaj, ymin, average_vals[NX];
if (first)
{
imin = 100;
imax = NX - 250;
jmin = NY - 150;
jmax = NY - 50;
if (PROFILE_AT_BOTTOM)
{
jmin = 50;
jmax = 150;
}
else
{
jmin = NY - 150;
jmax = NY - 50;
}
jmid = (jmin + jmax)/2;
jmid -= (jmid%size);
xy_to_ij(0.0, WAVE_PROFILE_Y, ij);
jval = ij[1];
jval -= (jval%size);
d = (jmax - jmin)/10 + 1;
deltaj = (double)(jmax - jmin - 2*d);
ymin = (double)(jmin + d);
for (i=0; i<NX; i++) average_vals[i] = 0.0;
for (k=0; k<2; k++)
{
vmin[k] = 1.0e10;
vmax[k] = -vmin[k];
if (average) vmin[k] = 0.0;
}
first = 0;
}
vmin = 1.0e10;
vmax = -vmin;
for (i=imin; i<imax; i+=size)
if (average)
{
if (values[i*NY+jmin] > vmax) vmax = values[i*NY+jmin];
if (values[i*NY+jmin] < vmin) vmin = values[i*NY+jmin];
for (i=imin; i<imax; i+=size)
average_vals[i] = 0.99*average_vals[i] + 0.01*values[i*NY+jval]*values[i*NY+jval];
for (i=imin; i<imax; i+=size)
if (average_vals[i] > vmax[pnb]) vmax[pnb] = average_vals[i];
}
else
{
for (i=imin; i<imax; i+=size)
{
// if (values[i*NY+jmin] > vmax) vmax = values[i*NY+jmin];
// if (values[i*NY+jmin] < vmin) vmin = values[i*NY+jmin];
if (values[i*NY+jval] > vmax[pnb]) vmax[pnb] = values[i*NY+jval];
if (values[i*NY+jval] < vmin[pnb]) vmin[pnb] = values[i*NY+jval];
}
}
// if (vmax <= vmin) vmax = vmin + 0.01;
if ((vmin < 0.0)&&(vmax > 0.0))
if ((vmin[pnb] < 0.0)&&(vmax[pnb] > 0.0))
{
if (vmax > -vmin) vmin = -vmax;
else if (vmax < -vmin) vmax = -vmin;
if (vmax[pnb] > -vmin[pnb]) vmin[pnb] = -vmax[pnb];
else if (vmax[pnb] < -vmin[pnb]) vmax[pnb] = -vmin[pnb];
}
// printf("vmin = %.3lg, vmax = %.3lg\n", vmin, vmax);
deltav = vmax-vmin;
deltav = vmax[pnb]-vmin[pnb];
if (deltav <= 0.0) deltav = 0.01;
a = deltaj/deltav;
b = ymin - a*vmin;
b = ymin - a*vmin[pnb];
erase_area_ij(imin, jmin, imax, jmax);
@ -994,8 +1231,10 @@ void draw_wave_profile_horizontal(double *values, int size, int fade, double fad
glBegin(GL_LINE_STRIP);
for (i=imin; i<imax; i+=size)
{
y = a*values[i*NY+jmin] + b;
glVertex2d((double)i, y);
// y = a*values[i*NY+jmin] + b;
if (average) y = a*average_vals[i] + b;
else y = a*values[i*NY+jval] + b;
if (y > ymin) glVertex2d((double)i, y);
}
glEnd();
@ -1005,16 +1244,20 @@ void draw_wave_profile_horizontal(double *values, int size, int fade, double fad
glVertex2i(imax, jmax);
glVertex2i(imin, jmax);
glEnd();
/* slightly decrease extramal values in case signal gets weaker */
vmax[pnb] *= 0.99;
vmin[pnb] *= 0.99;
}
void draw_wave_profile_vertical(double *values, int size, int fade, double fade_value)
void draw_wave_profile_vertical(double *values, int size, int average, int pnb, int fade, double fade_value)
/* draw a vertical profile of the wave, if option DRAW_WAVE_PROFILE is active */
{
int j, k;
double vmin, vmax, deltav, a, b, x;
static int imin, imax, jmin, jmax, imid, d, first = 1;
static double deltai, xmin;
int j, k, ij[2];
double deltav, a, b, x;
static int imin, imax, ival, jmin, jmax, imid, d, first = 1;
static double vmin[2], vmax[2], deltai, xmin, average_vals[NY];
if (first)
{
@ -1024,31 +1267,56 @@ void draw_wave_profile_vertical(double *values, int size, int fade, double fade_
imax = NX - 50;
imid = (imin + imax)/2;
imid -= (imid%size);
xy_to_ij(WAVE_PROFILE_X, 0.0, ij);
ival = ij[0];
ival -= (ival%size);
d = (imax - imin)/10 + 1;
deltai = (double)(imax - imin - 2*d);
xmin = (double)(imin + d);
for (j=0; j<NY; j++) average_vals[j] = 0.0;
for (k=0; k<2; k++)
{
vmin[k] = 1.0e10;
vmax[k] = -vmin[k];
if (average) vmin[k] = 0.0;
}
first = 0;
}
vmin = 1.0e10;
vmax = -vmin;
for (j=jmin; j<jmax; j+=size)
if (average)
{
if (values[imin*NY+j] > vmax) vmax = values[imin*NY+j];
if (values[imin*NY+j] < vmin) vmin = values[imin*NY+j];
for (j=jmin; j<jmax; j+=size)
average_vals[j] = 0.99*average_vals[j] + 0.01*values[ival*NY+j]*values[ival*NY+j];
for (j=jmin; j<jmax; j+=size)
if (average_vals[j] > vmax[pnb]) vmax[pnb] = average_vals[j];
}
// if ((vmin < 0.0)&&(vmax > 0.0))
else
{
if (vmax > -vmin) vmin = -vmax;
else if (vmax < -vmin) vmax = -vmin;
for (j=jmin; j<jmax; j+=size)
{
// if (values[imin*NY+j] > vmax) vmax = values[imin*NY+j];
// if (values[imin*NY+j] < vmin) vmin = values[imin*NY+j];
if (values[ival*NY+j] > vmax[pnb]) vmax[pnb] = values[ival*NY+j];
if (values[ival*NY+j] < vmin[pnb]) vmin[pnb] = values[ival*NY+j];
}
/* symmetrize output */
// if ((vmin[pnb] < 0.0)&&(vmax[pnb] > 0.0))
// {
// if (vmax[pnb] > -vmin[pnb]) vmin[pnb] = -vmax[pnb];
// else if (vmax[pnb] < -vmin[pnb]) vmax[pnb] = -vmin[pnb];
// }
// if (vmax > -vmin) vmin = -vmax;
// else if (vmax < -vmin) vmax = -vmin;
}
// else if (vmax > 0.0) vmin = 0.0;
// else if (vmin < 0.0) vmax = 0.0;
// printf("vmin = %.3lg, vmax = %.3lg\n", vmin, vmax);
deltav = vmax-vmin;
// printf("vmin = %.3lg, vmax = %.3lg\n", vmin[pnb], vmax[pnb]);
deltav = vmax[pnb]-vmin[pnb];
if (deltav <= 0.0) deltav = 0.01;
a = deltai/deltav;
b = xmin - a*vmin;
b = xmin - a*vmin[pnb];
erase_area_ij(imin, jmin, imax, jmax);
@ -1057,8 +1325,10 @@ void draw_wave_profile_vertical(double *values, int size, int fade, double fade_
glBegin(GL_LINE_STRIP);
for (j=jmin; j<jmax; j+=size)
{
x = a*values[imin*NY+j] + b;
glVertex2d(x, (double)j);
if (average) x = a*average_vals[j] + b;
else x = a*values[ival*NY+j] + b;
// else x = a*values[imin*NY+j] + b;
if (x >= xmin) glVertex2d(x, (double)j);
}
glEnd();
@ -1068,29 +1338,187 @@ void draw_wave_profile_vertical(double *values, int size, int fade, double fade_
glVertex2i(imax, jmax);
glVertex2i(imin, jmax);
glEnd();
/* slightly decrease extramal values in case signal gets weaker */
vmax[pnb] *= 0.99;
vmin[pnb] *= 0.99;
}
void draw_wave_profile(double *values, int size, int p_number, int fade, double fade_value)
/* draw a profile of the wave, if option DRAW_WAVE_PROFILE is active */
{
if (VERTICAL_WAVE_PROFILE)
draw_wave_profile_vertical(values, size, AVERAGE_WAVE_PROFILE, p_number, fade, fade_value);
if (HORIZONTAL_WAVE_PROFILE)
draw_wave_profile_horizontal(values, size, AVERAGE_WAVE_PROFILE, p_number, fade, fade_value);
}
void draw_exit_timeseries(double xleft, double yleft, double xtest, double ytest, double *values, int size, int top, int symmetrize, int fade, double fade_value)
/* draw a profile of the wave, if option DRAW_WAVE_TIMESERIES is active */
{
int t, t1, s, padding = 50, nvals = TIMESERIES_NVALUES;
double a, b, deltav, x, y, wmin, wmax;
static int ij[2], ij_test[2], imin, imax, jmintop, jmaxtop, jminbot, jmaxbot, jmin, jmax, itest, jtest, jtesttop, jtestbot, counter[2], first = 1, window = 5;
static double timeseries[TIMESERIES_NVALUES][2], average[TIMESERIES_NVALUES][2], vmin[2], vmax[2], ymin, deltaj, deltai;
if (first)
{
xy_to_ij(xleft, yleft, ij);
xy_to_ij(xtest, ytest, ij_test);
jmaxtop = NY - padding;
jmintop = 2*ij[1] - jmaxtop;
jtesttop = ij_test[1];
// printf("jmintop = %i, jmaxtop = %i\n", jmintop, jmaxtop);
xy_to_ij(xleft, -yleft, ij);
xy_to_ij(xtest, -ytest, ij_test);
jminbot = padding;
jmaxbot = 2*ij[1] - jminbot;
jtestbot = ij_test[1];
// printf("jminbot = %i, jmaxbot = %i\n", jminbot, jmaxbot);
imin = ij[0];
imax = NX - padding;
deltai = (double)(imax - imin)/(double)nvals;
vmin[0] = 1.0e10;
vmax[0] = -vmin[0];
vmin[1] = 1.0e10;
vmax[1] = -vmin[1];
for (t=0; t<nvals; t++)
{
timeseries[t][0] = 0.0;
timeseries[t][1] = 0.0;
}
counter[0] = 0;
counter[1] = 0;
first = 0;
}
if (top)
{
jmin = jmintop;
jmax = jmaxtop;
jtest = jtesttop;
}
else
{
jmin = jminbot;
jmax = jmaxbot;
jtest = jtestbot;
}
ymin = (double)(jmin);
itest = ij_test[0];
deltaj = (double)(jmax - jmin);
timeseries[counter[top]][top] = values[itest*NY + jtest] + values[(itest-1)*NY + jtest] + values[(itest)*NY + jtest + 1] + values[(itest-1)*NY + jtest + 1];
counter[top]++;
if (counter[top] == nvals) counter[top] = 0;
// for (t=0; t<nvals; t++) printf("val[%i] = %.3lg\n", t, timeseries[t]);
for (t=0; t<nvals; t++)
{
if (timeseries[t][top] > vmax[top]) vmax[top] = timeseries[t][top];
if (timeseries[t][top] < vmin[top]) vmin[top] = timeseries[t][top];
}
if (symmetrize)
{
if (vmax[top] > -vmin[top]) vmin[top] = -vmax[top];
else if (vmax[top] < -vmin[top]) vmax[top] = -vmin[top];
}
// printf("vmin = %.3lg, vmax = %.3lg\n", vmin[top], vmax[top]);
deltav = vmax[top]-vmin[top];
if (deltav <= 0.0) deltav = 0.01;
a = deltaj/deltav;
b = ymin - a*vmin[top];
/* compute average */
for (t=window; t<nvals-window; t++)
{
average[t][top] = 0.0;
for (s=-window; s<window; s++)
{
t1 = counter[top] - t + s;
if (t1 < 0) t1 += nvals;
if (t1 > nvals-1) t1 -= nvals;
average[t][top] += timeseries[t1][top]*timeseries[t1][top];
}
average[t][top] = sqrt(average[t][top]*0.5/(double)window);
}
erase_area_ij(imin, jmin, imax, jmax);
if (fade) glColor3f(fade_value, 0.0, 0.0);
else glColor3f(1.0, 0.0, 0.0);
glBegin(GL_LINE_STRIP);
for (t=0; t<nvals; t++)
{
t1 = counter[top] - t;
if (t1 < 0) t1 += nvals;
x = (double)imin + deltai*(double)t;
y = a*timeseries[t1][top] + b;
glVertex2d(x, y);
}
glEnd();
// printf("(x,y) = (%.2f, %.2f)\n", x, y);
/* draw average */
if (fade) glColor3f(fade_value, fade_value, fade_value);
else glColor3f(1.0, 1.0, 1.0);
glBegin(GL_LINE_STRIP);
for (t1=window; t1<nvals-window; t1++)
{
x = (double)imin + deltai*(double)t1;
y = -a*average[t1][top] + b;
if (x >= imin) glVertex2d(x, y);
}
glEnd();
if (symmetrize)
{
glBegin(GL_LINE_STRIP);
for (t1=window; t1<nvals-window; t1++)
{
x = (double)imin + deltai*(double)t1;
y = a*average[t1][top] + b;
glVertex2d(x, y);
}
glEnd();
}
if (fade) glColor3f(fade_value, fade_value, fade_value);
else glColor3f(1.0, 1.0, 1.0);
glBegin(GL_LINE_LOOP);
glVertex2i(imin, jmin);
glVertex2i(imax, jmin);
glVertex2i(imax, jmax);
glVertex2i(imin, jmax);
glEnd();
}
void draw_wave_profile(double *values, int size, int fade, double fade_value)
/* draw a profile of the wave, if option DRAW_WAVE_PROFILE is active */
{
if (VERTICAL_WAVE_PROFILE) draw_wave_profile_vertical(values, size, fade, fade_value);
else draw_wave_profile_horizontal(values, size, fade, fade_value);
}
void draw_exit_timeseries(double *values, int size, int fade, double fade_value)
void draw_exit_timeseries_old(double *values, int size, int fade, double fade_value)
/* draw a profile of the wave, if option DRAW_WAVE_TIMESERIES is active */
{
int t, t1, s, padding = 50, nvals = 200;
int t, t1, s, padding = 50, nvals = TIMESERIES_NVALUES;
double a, b, deltav, x, y, wmin, wmax;
static int ij[2], ij_test[2], imin, imax, jmin, jmax, jmid, itest, jtest, counter = 0, first = 1, window = 3;
static double timeseries[200], average[200], vmin, vmax, ymin, deltaj, deltai;
static int ij[2], ij_test[2], imin, imax, jmin, jmax, jmid, itest, jtest, counter = 0, first = 1, window = 5;
static double timeseries[TIMESERIES_NVALUES], average[TIMESERIES_NVALUES], vmin, vmax, ymin, deltaj, deltai;
if (first)
{
xy_to_ij(LAMBDA, -1.0 + MU, ij);
// xy_to_ij(LAMBDA - 0.1*MU, -1.0 + MU, ij_test);
xy_to_ij(LAMBDA, -1.0 + MU, ij_test);
xy_to_ij(LAMBDA, -1.0 + 2.0*MU, ij_test);
imin = ij[0];
imax = NX - padding;
jmin = padding;
@ -1156,6 +1584,7 @@ void draw_exit_timeseries(double *values, int size, int fade, double fade_value)
glVertex2d(x, y);
}
glEnd();
printf("(x,y) = (%.2f, %.2f)\n", x, y);
/* draw average */
if (fade) glColor3f(fade_value, 0.0, 0.0);
@ -1165,7 +1594,7 @@ void draw_exit_timeseries(double *values, int size, int fade, double fade_value)
{
x = (double)imin + deltai*(double)t1;
y = a*average[t1] + b;
glVertex2d(x, y);
if (x >= imin) glVertex2d(x, y);
}
glEnd();
glBegin(GL_LINE_STRIP);
@ -1189,10 +1618,10 @@ void draw_exit_timeseries(double *values, int size, int fade, double fade_value)
}
void draw_entrance_timeseries(double *values, int size, int fade, double fade_value)
void draw_entrance_timeseries(double xleft, double yleft, double *values, int size, int fade, double fade_value)
/* draw a profile of the wave, if option DRAW_WAVE_TIMESERIES is active */
{
int t, t1, padding = 50, nvals = 200;
int t, t1, padding = 50, nvals = TIMESERIES_NVALUES, ishift = 4;
double vmin, vmax, deltav, x, y;
static int ij[2], imin, imax, jmin, jmax, jmid, itest, jtest, counter = 0, first = 1,
time = 0;
@ -1200,7 +1629,7 @@ void draw_entrance_timeseries(double *values, int size, int fade, double fade_va
if (first)
{
xy_to_ij(-LAMBDA, 1.0 - MU, ij);
xy_to_ij(-xleft, yleft, ij);
imin = padding;
imax = ij[0];
jmax = NY - padding;
@ -1225,13 +1654,14 @@ void draw_entrance_timeseries(double *values, int size, int fade, double fade_va
// glEnable(GL_SCISSOR_TEST);
// glScissor(imin, jmin, imax-imin, jmax-jmin);
glBegin(GL_LINE_STRIP);
for (t=0; t<nvals; t++)
for (t=0; t<nvals + ishift; t++)
{
t1 = counter - t + nvals;
if (t1 >= NSTEPS) t1 = NSTEPS;
x = (double)imin + deltai*(double)t;
// x = (double)imin + deltai*(double)t;
x = (double)imin + deltai*(double)(t-ishift);
y = a*(double)input_signal[t1] + b;
glVertex2d(x, y);
if (t > ishift) glVertex2d(x, y);
}
glEnd();
// glDisable(GL_SCISSOR_TEST);
@ -1244,14 +1674,25 @@ void draw_entrance_timeseries(double *values, int size, int fade, double fade_va
glEnd();
}
void draw_wave_timeseries(double *values, int size, int fade, double fade_value)
void draw_wave_timeseries(double xleft, double yleft, double xtest, double ytest, double *values, int size, int fade, double fade_value)
/* draw a profile of the wave, if option DRAW_WAVE_TIMESERIES is active */
{
draw_exit_timeseries(values, size, fade, fade_value);
draw_entrance_timeseries(values, size, fade, fade_value);
int symmetrize = 1;
draw_exit_timeseries(xleft, yleft, xtest, ytest, values, size, 0, symmetrize, fade, fade_value);
if (DRAW_WAVE_TIMESERIES == 2)
draw_exit_timeseries(xleft, yleft, xtest, ytest, values, size, 1, symmetrize, fade, fade_value);
draw_entrance_timeseries(xleft, yleft, values, size, fade, fade_value);
}
void draw_wave_highres_palette(int size, double *phi[NX], double *psi[NX], double *total_energy[NX], double *total_flux, short int *xy_in[NX], double scale, int time, int plot, int palette, int fade, double fade_value)
void draw_wave_timeseries_old(double *values, int size, int fade, double fade_value)
/* draw a profile of the wave, if option DRAW_WAVE_TIMESERIES is active */
{
draw_exit_timeseries_old(values, size, fade, fade_value);
draw_entrance_timeseries(1.0, 1.0, values, size, fade, fade_value);
}
void draw_wave_highres_palette(int size, double *phi[NX], double *psi[NX], double *total_energy[NX], double *average_energy[NX], double *total_flux, short int *xy_in[NX], double scale, int time, int plot, int palette, int pnumber, int fade, double fade_value)
/* same as draw_wave_highres, but with color scheme option */
{
int i, j, k, iplus, iminus, jplus, jminus;
@ -1271,7 +1712,7 @@ void draw_wave_highres_palette(int size, double *phi[NX], double *psi[NX], doubl
{
if ((TWOSPEEDS)||(xy_in[i][j]))
{
value = wave_value(i, j, phi, psi, total_energy, total_flux, xy_in, scale, time, plot, palette, rgb);
value = wave_value(i, j, phi, psi, total_energy, average_energy, total_flux, xy_in, scale, time, plot, palette, rgb);
if ((DRAW_WAVE_PROFILE)||(DRAW_WAVE_TIMESERIES)) values[i*NY+j] = value;
@ -1287,9 +1728,16 @@ void draw_wave_highres_palette(int size, double *phi[NX], double *psi[NX], doubl
glEnd ();
if (DRAW_WAVE_TIMESERIES) draw_wave_timeseries(values, size, fade, fade_value);
if (DRAW_WAVE_PROFILE) draw_wave_profile(values, size, fade, fade_value);
draw_billiard(fade, fade_value);
if (DRAW_WAVE_TIMESERIES) draw_wave_timeseries(1.0, 1.0, 1.0, 0.5, values, size, fade, fade_value);
if (DRAW_WAVE_PROFILE) draw_wave_profile(values, size, pnumber, fade, fade_value);
if ((DRAW_WAVE_PROFILE)||(DRAW_WAVE_TIMESERIES)) free(values);
if (DRAW_WAVE_SOURCE)
{
glColor3f(0.0, 0.0, 0.0);
draw_circle(wave_source_x, wave_source_y, 0.005, 100);
}
}

View File

@ -254,6 +254,22 @@
#define MU_B 1.0 /* parameter controlling the dimensions of domain */
#define VERTICAL_WAVE_PROFILE 0 /* set to 1 to draw wave profile vertically */
#define DRAW_WAVE_TIMESERIES 0 /* set to 1 to draw a time series of the wave */
#define WALL_WIDTH 0.1 /* width of wall separating lenses */
#define 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 */
#define MESSAGE_LINTERVAL 54 /* length of interval between dashes/dots for Morse code message */
#define MESSAGE_LINTERLETTER 60 /* length of interval between letters for Morse code message */
#define MESSAGE_LSPACE 48 /* length of space for Morse code message */
#define MESSAGE_INITIAL_TIME 100 /* initial time before starting message for Morse code message */
#define AVRG_E_FACTOR 0.95 /* controls time window size in P_AVERAGE_ENERGY scheme */
#define HORIZONTAL_WAVE_PROFILE 0 /* set to 1 to draw wave profile vertically */
#define WAVE_PROFILE_X 2.1 /* value of x to sample wave profile */
#define WAVE_PROFILE_Y -1.0 /* value of y to sample wave profile */
#define PROFILE_AT_BOTTOM 1 /* draw wave profile at bottom instead of top */
#define AVERAGE_WAVE_PROFILE 1 /* set to 1 to draw time-average of wave profile squared*/
#define TIMESERIES_NVALUES 400 /* number of values plotted in time series */
#define DRAW_WAVE_SOURCE 0 /* set to 1 to draw source of wave at (wave_source_x, wave_source_y) */
/* end of constants only used by sub_wave and sub_maze */

View File

@ -228,6 +228,22 @@
#define DRAW_WAVE_PROFILE 0 /* set to 1 to draw a profile of the wave */
#define VERTICAL_WAVE_PROFILE 0 /* set to 1 to draw wave profile vertically */
#define DRAW_WAVE_TIMESERIES 0 /* set to 1 to draw a time series of the wave */
#define WALL_WIDTH 0.1 /* width of wall separating lenses */
#define 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 */
#define MESSAGE_LINTERVAL 54 /* length of interval between dashes/dots for Morse code message */
#define MESSAGE_LINTERLETTER 60 /* length of interval between letters for Morse code message */
#define MESSAGE_LSPACE 48 /* length of space for Morse code message */
#define MESSAGE_INITIAL_TIME 100 /* initial time before starting message for Morse code message */
#define AVRG_E_FACTOR 0.95 /* controls time window size in P_AVERAGE_ENERGY scheme */
#define HORIZONTAL_WAVE_PROFILE 0 /* set to 1 to draw wave profile vertically */
#define WAVE_PROFILE_X 2.1 /* value of x to sample wave profile */
#define WAVE_PROFILE_Y -1.0 /* value of y to sample wave profile */
#define PROFILE_AT_BOTTOM 1 /* draw wave profile at bottom instead of top */
#define AVERAGE_WAVE_PROFILE 1 /* set to 1 to draw time-average of wave profile squared*/
#define TIMESERIES_NVALUES 400 /* number of values plotted in time series */
#define DRAW_WAVE_SOURCE 0 /* set to 1 to draw source of wave at (wave_source_x, wave_source_y) */
/* end of constants only used by sub_wave and sub_maze */
#include "global_pdes.c" /* constants and global variables */

View File

@ -40,7 +40,7 @@
#include <time.h>
#define MOVIE 0 /* set to 1 to generate movie */
#define DOUBLE_MOVIE 1 /* set to 1 to produce movies for wave height and energy simultaneously */
#define DOUBLE_MOVIE 0 /* set to 1 to produce movies for wave height and energy simultaneously */
#define SAVE_MEMORY 1 /* set to 1 to save memory when writing tiff images */
#define NO_EXTRA_BUFFER_SWAP 1 /* some OS require one less buffer swap when recording images */
@ -48,22 +48,16 @@
#define WINWIDTH 1920 /* window width */
#define WINHEIGHT 1150 /* window height */
// // // #define NX 2500 /* number of grid points on x axis */
// // // #define NY 1250 /* number of grid points on y axis */
#define NX 2560 /* number of grid points on x axis */
#define NY 1280 /* number of grid points on y axis */
// #define NX 1280 /* number of grid points on x axis */
// #define NY 640 /* number of grid points on y axis */
// #define NX 2048 /* number of grid points on x axis */
// #define NY 1024 /* number of grid points on y axis */
// #define NX 3064 /* number of grid points on x axis */
// #define NY 1536 /* number of grid points on y axis */
// #define NX 1024 /* number of grid points on x axis */
// #define NY 512 /* number of grid points on y axis */
// #define NX 2048 /* number of grid points on x axis */
// #define NY 1024 /* number of grid points on y axis */
// #define NX 1024 /* number of grid points on x axis */
// #define NY 512 /* number of grid points on y axis */
#define DPOLE 20 /* safety distance to poles */
#define DPOLE 30 /* safety distance to poles */
#define SMOOTHPOLE 0.1 /* smoothing coefficient at poles */
#define ZERO_MERIDIAN 180.0 /* choice of zero meridian (will be at left/right boundary of 2d plot) */
#define ZERO_MERIDIAN 190.0 /* choice of zero meridian (will be at left/right boundary of 2d plot) */
#define XMIN -2.0
#define XMAX 2.0 /* x interval */
@ -80,6 +74,7 @@
/* Choice of the billiard table */
// #define B_DOMAIN 999 /* choice of domain shape, see list in global_pdes.c */
#define B_DOMAIN 84 /* choice of domain shape, see list in global_pdes.c */
#define CIRCLE_PATTERN 33 /* pattern of circles or polygons, see list in global_pdes.c */
@ -88,8 +83,8 @@
#define B_DOMAIN_B 20 /* second domain shape, for comparisons */
#define CIRCLE_PATTERN_B 0 /* second pattern of circles or polygons */
#define VARIABLE_IOR 0 /* set to 1 for a variable index of refraction */
#define IOR 10 /* choice of index of refraction, see list in global_pdes.c */
#define VARIABLE_IOR 1 /* set to 1 for a variable index of refraction */
#define IOR 20 /* 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 */
@ -109,6 +104,7 @@
#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.6 /* width of wall separating lenses */
#define X_SHOOTER -0.2
#define Y_SHOOTER -0.6
@ -136,10 +132,11 @@
#define AMPLITUDE 0.8 /* amplitude of periodic excitation */
#define ACHIRP 0.2 /* acceleration coefficient in chirp */
#define DAMPING 0.0 /* damping of periodic excitation */
#define COURANT 0.05 /* Courant number */
#define COURANTB 0.002 /* Courant number in medium B */
#define GAMMA 0.0 /* damping factor in wave equation */
#define GAMMAB 1.0e-2 /* damping factor in wave equation */
#define COURANT 0.08 /* Courant number */
#define COURANTB 0.005 /* Courant number in medium B */
// #define GAMMA 2.0e-6 /* damping factor in wave equation */
#define GAMMA 0.0 /* damping factor in wave equation */
#define GAMMAB 0.0 /* damping factor in wave equation */
#define GAMMA_SIDES 1.0e-4 /* damping factor on boundary */
#define GAMMA_TOPBOT 1.0e-7 /* damping factor on boundary */
#define KAPPA 0.0 /* "elasticity" term enforcing oscillations */
@ -160,19 +157,29 @@
#define N_WAVE_PACKETS 15 /* number of wave packets */
#define WAVE_PACKET_RADIUS 20 /* radius of wave packets */
#define ADD_FORCING 0 /* set to 1 to add periodic forcing */
#define FORCING_AMP 0.0 /* amplitude of periodic forcing */
#define FORCING_CONST_AMP 1.0-10 /* amplitude of periodic forcing */
#define FORCING_PERIOD 2400 /* period of forcing */
#define DRIFT_WAVE 0 /* add drift of wave to the right (experimental) */
#define DRIFT_FREQ 5 /* frequency of drift adding (experimental) */
#define MOVING_FRAME 0 /* set to 1 to use wave equation in moving frame */
#define VOVERC 0.025 /* moving frame speed over wave speed */
/* Boundary conditions, see list in global_pdes.c */
// #define B_COND 1
#define B_COND 2
#define PRECOMPUTE_BC 0 /* set to 1 to compute neighbours for Laplacian in advance */
/* Parameters for length and speed of simulation */
#define NSTEPS 2400 /* number of frames of movie */
#define NSTEPS 1500 /* number of frames of movie */
// #define NSTEPS 500 /* number of frames of movie */
#define NVID 4 /* number of iterations between images displayed on screen */
// #define NVID 10 /* number of iterations between images displayed on screen */
// #define NVID 6 /* number of iterations between images displayed on screen */
#define NVID 10 /* 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 */
@ -188,7 +195,7 @@
/* Parameters of initial condition */
#define INITIAL_AMP 1.0 /* amplitude of initial condition */
#define INITIAL_AMP 0.03 /* amplitude of initial condition */
#define INITIAL_VARIANCE 0.00005 /* variance of initial condition */
#define INITIAL_WAVELENGTH 0.002 /* wavelength of initial condition */
@ -203,8 +210,8 @@
#define CHANGE_LUMINOSITY 1 /* set to 1 to let luminosity depend on energy flux intensity */
#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 SHADE_2D 0 /* set to 1 to change luminosity according to normal vector to plane */
#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 to plane */
#define SHADE_WAVE 1 /* set to 1 to have luminosity depend on wave height */
#define NON_DIRICHLET_BC 0 /* 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 */
@ -223,7 +230,7 @@
/* 3D representation */
#define REPRESENTATION_3D 1 /* choice of 3D representation */
#define PLOT_2D 0 /* switch to 2D representation, equirectangular projection */
#define PLOT_2D 1 /* switch to 2D representation, equirectangular projection */
#define PHISHIFT 0.0 /* shift of phi in 2D plot (in degrees) */
#define FLOODING 1 /* set to 1 to draw waves above altitude (for Earth representations) */
@ -231,7 +238,7 @@
#define REP_PROJ_3D 1 /* projection on plane orthogonal to observer line of sight */
#define ROTATE_VIEW 1 /* set to 1 to rotate position of observer */
#define ROTATE_ANGLE 720.0 /* total angle of rotation during simulation */
#define ROTATE_ANGLE -360.0 /* total angle of rotation during simulation */
// #define ROTATE_ANGLE -50.0 /* total angle of rotation during simulation */
#define ROTATE_VIEW_WHILE_FADE 1 /* set to 1 to keep rotating viewpoint during fade */
@ -251,8 +258,8 @@
#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 0.5 /* sensitivity of color on wave amplitude */
#define VSCALE_AMPLITUDE 1.5 /* additional scaling factor for color scheme P_3D_AMPLITUDE */
#define SLOPE 1.0 /* sensitivity of color on wave amplitude */
#define VSCALE_AMPLITUDE 50.0 /* additional scaling factor for color scheme P_3D_AMPLITUDE */
#define VSCALE_ENERGY 5.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 */
@ -273,6 +280,13 @@
#define HUEMEAN 240.0 /* mean value of hue for color scheme C_HUE */
#define HUEAMP -200.0 /* amplitude of variation of hue for color scheme C_HUE */
#define MESSAGE_LDASH 14 /* length of dash for Morse code message */
#define MESSAGE_LDOT 8 /* length of dot for Morse code message */
#define MESSAGE_LINTERVAL 54 /* length of interval between dashes/dots for Morse code message */
#define MESSAGE_LINTERLETTER 60 /* length of interval between letters for Morse code message */
#define MESSAGE_LSPACE 48 /* length of space for Morse code message */
#define MESSAGE_INITIAL_TIME 100 /* initial time before starting message for Morse code message */
#define NXMAZE 8 /* width of maze */
#define NYMAZE 32 /* height of maze */
#define MAZE_MAX_NGBH 5 /* max number of neighbours of maze cell */
@ -280,17 +294,28 @@
#define MAZE_XSHIFT 0.0 /* horizontal shift of maze */
#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 6.0 /* scale of color scheme bar */
#define DRAW_COLOR_SCHEME 0 /* set to 1 to plot the color scheme */
#define COLORBAR_RANGE 3.0 /* scale of color scheme bar */
#define COLORBAR_RANGE_B 6.0 /* 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 */
#define DRAW_MOON_POSITION 0 /* set to 1 to draw position of Moon (for tide simulation) */
#define DRAW_WAVE_PROFILE 0 /* set to 1 to draw a profile of the wave */
#define VERTICAL_WAVE_PROFILE 0 /* set to 1 to draw wave profile vertically */
#define DRAW_WAVE_TIMESERIES 0 /* set to 1 to draw a time series of the wave */
#define TIMESERIES_NVALUES 400 /* number of values plotted in time series */
#define SAVE_TIME_SERIES 0 /* set to 1 to save wave time series at a point */
#define OSCIL_YMAX 0.35 /* defines oscillation range */
#define AVRG_E_FACTOR 0.95 /* controls time window size in P_AVERAGE_ENERGY scheme */
#define HORIZONTAL_WAVE_PROFILE 0 /* set to 1 to draw wave profile vertically */
#define WAVE_PROFILE_X 2.1 /* value of x to sample wave profile */
#define WAVE_PROFILE_Y -1.0 /* value of y to sample wave profile */
#define PROFILE_AT_BOTTOM 0 /* draw wave profile at bottom instead of top */
#define AVERAGE_WAVE_PROFILE 0 /* set to 1 to draw time-average of wave profile squared*/
#define TIMESERIES_NVALUES 400 /* number of values plotted in time series */
#define DRAW_WAVE_SOURCE 0 /* set to 1 to draw source of wave at (wave_source_x, wave_source_y) */
#define ADD_POTENTIAL 0 /* set to 1 to add potential to z coordinate */
#define POTENTIAL 10
@ -299,7 +324,7 @@
/* For debugging purposes only */
#define FLOOR 1 /* set to 1 to limit wave amplitude to VMAX */
#define VMAX 10.0 /* max value of wave amplitude */
#define VMAX 5.0 /* max value of wave amplitude */
/* Parameters controlling 3D projection */
@ -307,29 +332,31 @@ 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] = {-6.0, -3.0, 4.5}; /* location of observer for REP_PROJ_3D representation */
double observer[3] = {-5.0, -5.0, 3.5}; /* location of observer for REP_PROJ_3D representation */
int reset_view = 0; /* switch to reset 3D view parameters (for option ROTATE_VIEW) */
#define ADD_DEM 1 /* 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 0 /* set to 1 to smoothen DEM (to make altitude less constant) */
#define DEM_SMOOTH_STEPS 5 /* number of smoothening steps */
#define DEM_SMOOTH_HEIGHT 0.5 /* relative height below which to smoothen */
#define ADD_NEGATIVE_DEM 1 /* add DEM with bathymetric data */
#define RSCALE_DEM 0.1 /* scaling factor of radial component for DEM */
#define SMOOTH_DEM 5 /* set to 1 to smoothen DEM (to make altitude less constant) */
#define DEM_SMOOTH_STEPS 1 /* 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) */
#define DEM_MAXDEPTH -10000 /* max depth of DEM */
#define PLANET_SEALEVEL 0.0 /* sea level for flooded planet */
// #define PLANET_SEALEVEL 3850.0 /* sea level for flooded planet */
#define VENUS_NODATA_FACTOR 0.5 /* altitude to assign to DEM points without data (fraction of mean altitude) */
#define TRANSPARENT_WAVE 0 /* set to 1 for waves to be "transparent" */
#define RSCALE 0.025 /* scaling factor of radial component */
#define RMAX 1.5 /* max value of radial component */
#define RSCALE 1.0 /* scaling factor of radial component */
#define RMAX 10.0 /* max value of radial component */
#define Z_SCALING_FACTOR 0.8 /* overall scaling factor of z axis for REP_PROJ_3D representation */
#define RMIN 0.5 /* min value of radial component */
#define Z_SCALING_FACTOR 0.8 /* overall scaling factor of z axis for REP_PROJ_3D representation */
#define XY_SCALING_FACTOR 2.2 /* overall scaling factor for on-screen (x,y) coordinates after projection */
#define ZMAX_FACTOR 1.0 /* max value of z coordinate for REP_PROJ_3D representation */
#define XSHIFT_3D 0.0 /* overall x shift for REP_PROJ_3D representation */
#define YSHIFT_3D 0.0 /* overall y shift for REP_PROJ_3D representation */
#define COS_VISIBLE -0.7 /* limit on cosine of normal to shown facets */
#define COS_VISIBLE -0.3 /* limit on cosine of normal to shown facets */
#include "global_pdes.c" /* constants and global variables */
#include "global_3d.c" /* constants and global variables */
@ -344,18 +371,88 @@ FILE *time_series_left, *time_series_right, *image_file;
double courant2, courantb2; /* Courant parameters squared */
void compute_forcing_schedule(int t, t_wave_sphere wsphere[NX*NY])
/* compute periodic forcing */
{
int i, j;
double phase;
phase = DPI*(double)t/(double)FORCING_PERIOD + ZERO_MERIDIAN*PI/180.0 + 0.5*PID;
for (i=0; i<NX; i++) for (j=0.0; j<NY; j++)
{
wsphere[i*NY+j].force = FORCING_AMP*wsphere[i*NY+j].stheta*sin(2.0*(wsphere[i*NY+j].phi - phase));
wsphere[i*NY+j].force += FORCING_CONST_AMP*wsphere[i*NY+j].stheta*cos(2.0*(wsphere[i*NY+j].phi));
}
moon_position = (int)((double)NX*(phase/DPI + 0.625));
while (moon_position < 0) moon_position += NX;
while (moon_position >= NX) moon_position -= NX;
// i = NX/2;
i = moon_position;
printf("Phase = %.5lg, Forcing at i = %i: %.5lg, Moon position = %i\n", phase, i, wsphere[i*NY+NY/2].force, moon_position);
}
void shift_fields(double phi[NX*NY], short int xy_in[NX*NY])
/* EXPERIMENTAL */
{
int i, j;
double temp;
#pragma omp parallel for private(j,i)
// for (j=DPOLE; j<NY-DPOLE; j++)
for (j=0; j<NY; j++)
{
temp = phi[j];
for (i=0; i<NX-1; i++) if (xy_in[i*NY+j])
{
phi[i*NY+j] = phi[(i+1)*NY+j];
}
if (xy_in[j])
{
phi[(NX-1)*NY+j] = temp;
}
}
// for (j=0; j<NY; j++)
// {
// temp = phi[(NX-1)*NY+j];
// for (i=NX-1; i>1; i--) if (xy_in[i*NY+j])
// {
// phi[i*NY+j] = phi[(i-1)*NY+j];
// }
// if (xy_in[j])
// {
// phi[j] = temp;
// }
// }
/* smoothing at poles */
for (j=0; j<DPOLE; j++)
for (i=0; i<NX; i++)
phi[i*NY+j] = 0.0;
for (j=NY-DPOLE; j<NY; j++)
for (i=0; i<NX; i++)
phi[i*NY+j] = 0.0;
}
void evolve_wave_half(double phi_in[NX*NY], double psi_in[NX*NY], double phi_out[NX*NY],
short int xy_in[NX*NY], double tc[NX*NY], double tcc[NX*NY], double tgamma[NX*NY])
short int xy_in[NX*NY], double tc[NX*NY], double tcc[NX*NY], double tgamma[NX*NY], t_wave_sphere wsphere[NX*NY], int t)
/* time step of field evolution */
/* phi is value of field at time t, psi at time t-1 */
/* this version of the function has been rewritten in order to minimize the number of if-branches */
{
int i, j, iplus, iminus, jplus, jminus, jtop, jbot;
double delta, x, y, c, cc, gamma, sintheta, cottheta, invstheta, sum, avrg;
double delta, x, y, c, cc, gamma, sintheta, cottheta, invstheta, sum, avrg, force;
double tmp_phi[NY];
static long time = 0;
static short int first = 1;
static double dphi, dtheta, cphiphi, ctheta;
static double dphi, dtheta, cphiphi, ctheta, dt, vdrift;
static int counter = 0;
if (first)
{
@ -363,8 +460,10 @@ void evolve_wave_half(double phi_in[NX*NY], double psi_in[NX*NY], double phi_out
dtheta = PI/(double)NY;
cphiphi = dphi*dphi/(dtheta*dtheta);
ctheta = dphi*dphi/(2.0*dtheta);
dt = (double)NVID*COURANT*(XMAX-XMIN)/((double)NX);
vdrift = COURANT*VOVERC;
printf("dphi = %.5lg, dtheta = %.5lg, cphiphi = %.5lg, ctheta = %.5lg\n", dphi, dtheta, cphiphi, ctheta);
printf("dphi = %.5lg, dtheta = %.5lg, cphiphi = %.5lg, ctheta = %.5lg, dt = %.5lg\n", dphi, dtheta, cphiphi, ctheta, dt);
first = 0;
}
@ -374,11 +473,15 @@ void evolve_wave_half(double phi_in[NX*NY], double psi_in[NX*NY], double phi_out
#pragma omp parallel for private(i,j,iplus,iminus,jplus,jminus,delta,x,y)
/* evolution in the bulk */
for (j=DPOLE; j<NY-DPOLE; j++){
sintheta = sin(j*dtheta);
// sintheta = sin(j*dtheta);
/* NEW: used wsphere to accelerate computation */
sintheta = wsphere[i*NY+j].stheta;
// invstheta = 1.0/(sintheta*sintheta);
invstheta = 1.0/(sintheta*sintheta + SMOOTHPOLE*SMOOTHPOLE);
// cottheta = ctheta*cos(j*dtheta)/sintheta;
cottheta = ctheta*cos(j*dtheta)/(sintheta + SMOOTHPOLE);
// cottheta = ctheta*cos(j*dtheta)/(sintheta + SMOOTHPOLE);
cottheta = ctheta*wsphere[i*NY+j].ctheta/(sintheta + SMOOTHPOLE);
for (i=1; i<NX-1; i++){
if ((TWOSPEEDS)||(xy_in[i*NY+j] != 0)){
@ -397,15 +500,29 @@ void evolve_wave_half(double phi_in[NX*NY], double psi_in[NX*NY], double phi_out
/* evolve phi */
phi_out[i*NY+j] = -y + 2*x + tcc[i*NY+j]*delta - KAPPA*x - tgamma[i*NY+j]*(x-y);
if (ADD_FORCING) phi_out[i*NY+j] += wsphere[i*NY+j].force*dt;
if (MOVING_FRAME)
{
// phi_out[i*NY+j] += vdrift*wsphere[i*NY+j].stheta*(phi_in[(i+1)*NY+j] - phi_in[(i-1)*NY+j] - psi_in[(i+1)*NY+j] + psi_in[(i-1)*NY+j]);
phi_out[i*NY+j] += VOVERC*tc[i*NY+j]*wsphere[i*NY+j].stheta*(phi_in[(i+1)*NY+j] - phi_in[(i-1)*NY+j] - psi_in[(i+1)*NY+j] + psi_in[(i-1)*NY+j]);
/* the .stheta factor is not really correct, but prevents instability */
}
/* optional: add const*delta to smoothen ? */
}
}
}
/* evolution at longitude zero */
for (j=DPOLE; j<NY-DPOLE; j++){
sintheta = sin(j*dtheta);
invstheta = 1.0/(sintheta*sintheta);
cottheta = ctheta*cos(j*dtheta)/sintheta;
// sintheta = sin(j*dtheta);
sintheta = wsphere[j].stheta;
invstheta = 1.0/(sintheta*sintheta + SMOOTHPOLE*SMOOTHPOLE);
// cottheta = ctheta*cos(j*dtheta)/(sintheta + SMOOTHPOLE);
cottheta = ctheta*wsphere[j].ctheta/(sintheta + SMOOTHPOLE);
/* i = 0 */
if ((TWOSPEEDS)||(xy_in[j] != 0)){
@ -424,6 +541,16 @@ void evolve_wave_half(double phi_in[NX*NY], double psi_in[NX*NY], double phi_out
/* evolve phi */
phi_out[j] = -y + 2*x + tcc[j]*delta - KAPPA*x - tgamma[j]*(x-y);
if (ADD_FORCING) phi_out[j] += wsphere[j].force*dt;
if (MOVING_FRAME)
{
// phi_out[j] += vdrift*wsphere[j].stheta*(phi_in[NY+j] - phi_in[(NX-1)*NY+j] - psi_in[NY+j] + psi_in[(NX-1)*NY+j]);
phi_out[j] += VOVERC*tc[j]*wsphere[j].stheta*(phi_in[NY+j] - phi_in[(NX-1)*NY+j] - psi_in[NY+j] + psi_in[(NX-1)*NY+j]);
}
// if (j%100==0)
// printf("tcc*delta = %.5lg, forcing = %.5lg\n", tcc[j]*delta, forcing_schedule(t, i, 0, wsphere)*dt);
}
/* i = NX-1 */
@ -443,64 +570,32 @@ void evolve_wave_half(double phi_in[NX*NY], double psi_in[NX*NY], double phi_out
/* evolve phi */
phi_out[(NX-1)*NY+j] = -y + 2*x + tcc[(NX-1)*NY+j]*delta - KAPPA*x - tgamma[(NX-1)*NY+j]*(x-y);
if (ADD_FORCING) phi_out[(NX-1)*NY + j] += wsphere[(NX-1)*NY + j].force*dt;
if (MOVING_FRAME)
{
// phi_out[(NX-1)*NY+j] += vdrift*wsphere[(NX-1)*NY+j].stheta*(phi_in[j] - phi_in[(NX-2)*NY+j] - psi_in[j] + psi_in[(NX-2)*NY+j]);
phi_out[(NX-1)*NY+j] += VOVERC*tc[i*NY+j]*wsphere[(NX-1)*NY+j].stheta*(phi_in[j] - phi_in[(NX-2)*NY+j] - psi_in[j] + psi_in[(NX-2)*NY+j]);
}
}
}
/* compute average at north pole */
sum = 0.0;
for (i=0; i<NX; i++) sum += phi_out[i*NY + DPOLE];
// for (i=0; i<NX; i++) sum += phi_out[i*NY + DPOLE];
for (i=0; i<NX; i++) sum += phi_out[i*NY + DPOLE - 1];
avrg = sum/(double)NX;
for (i=0; i<NX; i++) for (j=0; j<DPOLE; j++)
phi_out[i*NY + j] = avrg;
// {
// x = phi_in[(NX-1)*NY+j];
// y = psi_in[(NX-1)*NY+j];
// phi_out[(NX-1)*NY+j] = -y + 2*x + tcc[(NX-1)*NY+j]*avrg - KAPPA*x - tgamma[(NX-1)*NY+j]*(x-y);
// //
// }
/* compute average at south pole */
sum = 0.0;
for (i=0; i<NX; i++) sum += phi_out[i*NY + NY-1-DPOLE];
// for (i=0; i<NX; i++) sum += phi_out[i*NY + NY-1-DPOLE];
for (i=0; i<NX; i++) sum += phi_out[i*NY + NY-DPOLE];
avrg = sum/(double)NX;
for (i=0; i<NX; i++) for (j=NY-DPOLE; j<NY; j++)
phi_out[i*NY + j] = avrg;
// {
// x = phi_in[(NX-1)*NY+j];
// y = psi_in[(NX-1)*NY+j];
// phi_out[(NX-1)*NY+j] = -y + 2*x + tcc[(NX-1)*NY+j]*avrg - KAPPA*x - tgamma[(NX-1)*NY+j]*(x-y);
// //
// }
// /* north pole, j = 0 */
// if ((TWOSPEEDS)||(xy_in[0] != 0)){
// x = phi_in[0];
// y = psi_in[0];
//
// /* discretized Laplacian */
// delta = cphiphi*(phi_in[1] + phi_in[(NX/4)*NY+1] + phi_in[(NX/2)*NY+1] + phi_in[(3*NX/4)*NY+1] - 4.0*x);
//
// /* evolve phi */
// phi_out[0] = -y + 2*x + tcc[0]*delta - KAPPA*x - tgamma[0]*(x-y);
//
// /* set same values for all i */
// for (i=1; i<NX; i++) phi_out[i*NY] = phi_out[0];
// }
//
// /* south pole, j = NY-1 */
// if ((TWOSPEEDS)||(xy_in[NY-1] != 0)){
// x = phi_in[NY-1];
// y = psi_in[NY-1];
//
// /* discretized Laplacian */
// delta = cphiphi*(phi_in[NY-2] + phi_in[(NX/4)*NY+NY-2] + phi_in[(NX/2)*NY+NY-2] + phi_in[(3*NX/4)*NY+NY-2] - 4.0*x);
//
// /* evolve phi */
// phi_out[NY-1] = -y + 2*x + tcc[0]*delta - KAPPA*x - tgamma[0]*(x-y);
//
// /* set same values for all i */
// for (i=1; i<NX; i++) phi_out[i*NY+NY-1] = phi_out[NY-1];
// }
/* for debugging purposes/if there is a risk of blow-up */
if (FLOOR) for (i=0; i<NX; i++){
@ -516,14 +611,13 @@ void evolve_wave_half(double phi_in[NX*NY], double psi_in[NX*NY], double phi_out
void evolve_wave(double phi[NX*NY], double psi[NX*NY], double tmp[NX*NY], short int xy_in[NX*NY],
double tc[NX*NY], double tcc[NX*NY], double tgamma[NX*NY], t_laplacian laplace[NX*NY], t_laplacian laplace1[NX*NY],
t_laplacian laplace2[NX*NY])
double tc[NX*NY], double tcc[NX*NY], double tgamma[NX*NY], t_laplacian laplace[NX*NY], t_laplacian laplace1[NX*NY], t_laplacian laplace2[NX*NY], t_wave_sphere wsphere[NX*NY], int t)
/* time step of field evolution */
/* phi is value of field at time t, psi at time t-1 */
{
evolve_wave_half(phi, psi, tmp, xy_in, tc, tcc, tgamma);
evolve_wave_half(tmp, phi, psi, xy_in, tc, tcc, tgamma);
evolve_wave_half(psi, tmp, phi, xy_in, tc, tcc, tgamma);
evolve_wave_half(phi, psi, tmp, xy_in, tc, tcc, tgamma, wsphere, t);
evolve_wave_half(tmp, phi, psi, xy_in, tc, tcc, tgamma, wsphere, t);
evolve_wave_half(psi, tmp, phi, xy_in, tc, tcc, tgamma, wsphere, t);
}
@ -620,7 +714,7 @@ void animation()
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, drift_counter = 0;
static int counter = 0, first_source = 1;
long int wave_value;
t_wave *wave;
@ -734,47 +828,16 @@ void animation()
// add_circular_wave_mod(1.0, lambda1*cos(((double)j+0.5)*angle), lambda1*sin(((double)j+0.5)*angle), phi, psi, xy_in);
/* Kilauea, Hawaii, USA */
init_circular_wave_sphere(155.2867*PI/180.0, 19.42109*PI/180.0, phi, psi, xy_in, wsphere);
// init_circular_wave_sphere(155.2867*PI/180.0, 19.42109*PI/180.0, phi, psi, xy_in, wsphere);
/* Mount Etna, Sicily, Italy */
add_circular_wave_sphere(1.0, -14.9950*PI/180.0, 37.7550*PI/180.0, phi, psi, xy_in, wsphere);
/* Eyjafjallajökull, Iceland */
add_circular_wave_sphere(1.0, 19.61333*PI/180.0, 63.62000*PI/180.0, phi, psi, xy_in, wsphere);
// init_moving_tidal_wave_sphere(0.0, 0.05, 0.025, phi, psi, xy_in, wsphere);
/* Mount Vesuvius, Italy */
add_circular_wave_sphere(1.0, -14.433*PI/180.0, 40.817*PI/180.0, phi, psi, xy_in, wsphere);
/* Sakurajima, Japan */
add_circular_wave_sphere(1.0, -130.65806*PI/180.0, 31.58056*PI/180.0, phi, psi, xy_in, wsphere);
/* Mount Merapi, Indonesia */
add_circular_wave_sphere(1.0, -110.44611*PI/180.0, -7.54139*PI/180.0, phi, psi, xy_in, wsphere);
init_moving_tidal_wave_sphere(0.0, 2.5, 1.25, phi, psi, xy_in, wsphere);
/* Ulawun, Papua New Guinea */
add_circular_wave_sphere(1.0, -151.33333*PI/180.0, -5.05000*PI/180.0, phi, psi, xy_in, wsphere);
// init_circular_wave_sphere(0.0, -0.5, phi, psi, xy_in, wsphere);
/* Santa María, Guatemala */
add_circular_wave_sphere(1.0, 91.55167*PI/180.0, 14.75556*PI/180.0, phi, psi, xy_in, wsphere);
// init_wave_flat_sphere(phi, psi, xy_in, wsphere);
/* Mount Erebus, Antarctica */
add_circular_wave_sphere(1.0, -167.15333*PI/180.0, -77.52972*PI/180.0, phi, psi, xy_in, wsphere);
/* Piton de la Fournaise, Reunion island, Indian Ocean */
add_circular_wave_sphere(0.75, -55.70889*PI/180.0, -21.24250*PI/180.0, phi, psi, xy_in, wsphere);
/* Soufrière Hills, Montserrat */
add_circular_wave_sphere(0.75, 62.1773*PI/180.0, 16.7103*PI/180.0, phi, psi, xy_in, wsphere);
/* Axial Seamount, Pacific Ocean */
add_circular_wave_sphere(0.5, 130.00*PI/180.0, 45.95*PI/180.0, phi, psi, xy_in, wsphere);
/* Havre Seamount, New Zealand */
add_circular_wave_sphere(0.5, 179.968611*PI/180.0, -31.120278*PI/180.0, phi, psi, xy_in, wsphere);
/* Boomerang Seamount, Indian Ocean */
add_circular_wave_sphere(0.5, -77.825*PI/180.0, -37.721*PI/180.0, phi, psi, xy_in, wsphere);
// init_wave_flat_sphere(phi, psi, xy_in, wsphere);
// for (j=0; j<6; j++)
// add_circular_wave_sphere(1.0, (double)j*PI/3.0, 0.925*PID, phi, psi, xy_in, wsphere);
@ -840,10 +903,13 @@ void animation()
reset_view = 1;
}
if (ADD_FORCING) compute_forcing_schedule(i, wsphere);
draw_wave_sphere(0, phi, psi, xy_in, wave, wsphere, ZPLOT, CPLOT, COLOR_PALETTE, 0, 1.0, 1);
for (j=0; j<NVID; j++)
{
evolve_wave(phi, psi, tmp, xy_in, tc, tcc, tgamma, laplace, laplace1, laplace2);
evolve_wave(phi, psi, tmp, xy_in, tc, tcc, tgamma, laplace, laplace1, laplace2, wsphere, i);
if (SAVE_TIME_SERIES)
{
wave_value = (long int)(phi[sample_left[0]*NY+sample_left[1]]*1.0e16);
@ -852,10 +918,32 @@ void animation()
fprintf(time_series_right, "%019ld\n", wave_value);
if ((j == 0)&&(i%10 == 0)) printf("Frame %i of %i\n", i, NSTEPS);
// fprintf(time_series_right, "%.15f\n", phi[sample_right[0]][sample_right[1]]);
/* Experimental */
if (DRIFT_WAVE)
{
if (drift_counter == DRIFT_FREQ)
{
shift_fields(phi, xy_in);
shift_fields(psi, xy_in);
shift_fields(tmp, xy_in); /* needed? */
drift_counter = 0;
}
else drift_counter++;
}
}
// if (i % 10 == 9) oscillate_linear_wave(0.2*scale, 0.15*(double)(i*NVID + j), -1.5, YMIN, -1.5, YMAX, phi, psi);
}
/* Experimental */
// if (DRIFT_WAVE != 0)
// if (i%DRIFT_FREQ == 0)
// {
// shift_fields(phi, xy_in);
// shift_fields(psi, xy_in);
// shift_fields(tmp, xy_in); /* needed? */
// }
// draw_billiard();
if (DRAW_COLOR_SCHEME) draw_color_bar_palette(CPLOT, COLORBAR_RANGE, COLOR_PALETTE, CIRC_COLORBAR, fade, fade_value);