Add files via upload
This commit is contained in:
parent
f773d3940d
commit
008fbf4612
@ -37,6 +37,7 @@
|
||||
#define GF_AIRFOIL 3 /* curved repelling ellipse */
|
||||
#define GF_WING 4 /* wing shape */
|
||||
#define GF_COMPUTE_FROM_BC 5 /* compute force field as gradient of bc_field2 */
|
||||
#define GF_EARTH 6 /* field depends on altitude on continents */
|
||||
|
||||
/* Choice of water depth for shallow water equation */
|
||||
|
||||
@ -82,7 +83,10 @@
|
||||
#define PLANET ((B_DOMAIN == D_SPHERE_EARTH)||(B_DOMAIN == D_SPHERE_MARS)||(B_DOMAIN == D_SPHERE_MOON)||(B_DOMAIN == D_SPHERE_VENUS)||(B_DOMAIN == D_SPHERE_MERCURY))
|
||||
#define OTHER_PLANET ((B_DOMAIN == D_SPHERE_MARS)||(B_DOMAIN == D_SPHERE_MOON)||(B_DOMAIN == D_SPHERE_VENUS)||(B_DOMAIN == D_SPHERE_MERCURY))
|
||||
|
||||
#define RDE_PLANET ((ADAPT_STATE_TO_BC)&&(OBSTACLE_GEOMETRY == D_SPHERE_EARTH))
|
||||
|
||||
#define NMAXCIRC_SPHERE 100 /* max number of circles on sphere */
|
||||
#define NMAX_TRACER_PTS 20 /* max number of tracer points recorded per cell */
|
||||
|
||||
int global_time = 0;
|
||||
double max_depth = 1.0;
|
||||
@ -132,6 +136,10 @@ typedef struct
|
||||
double depth; /* water depth */
|
||||
double cos_depth_angle; /* cos of angle of depth profile */
|
||||
double gradx, grady; /* gradient of water depth */
|
||||
short int tracer; /* has value 1 if cell contains a tracer */
|
||||
short int n_tracer_pts; /* number of recorded tracer points per cell */
|
||||
double tracerx[NMAX_TRACER_PTS], tracery[NMAX_TRACER_PTS]; /* coordinates of tracer */
|
||||
int prev_cell; /* cell where tracer was previously */
|
||||
} t_rde;
|
||||
|
||||
|
||||
@ -147,6 +155,7 @@ typedef struct
|
||||
double phi, theta; /* phi, theta angles */
|
||||
double cphi, sphi; /* cos and sin of phi */
|
||||
double ctheta, stheta, cottheta; /* cos, sin and cotangent of theta */
|
||||
double reg_cottheta; /* regularized 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 */
|
||||
|
@ -18,6 +18,7 @@
|
||||
#define NMAXGROUPS 50 /* max number of groups of segments */
|
||||
#define NMAXCOLLISIONS 200000 /* max number of collisions */
|
||||
#define NMAXPARTNERS 30 /* max number of partners in molecule */
|
||||
#define NMAXPARTNERMOLECULES 10 /* max number of partners of a molecule */
|
||||
|
||||
#define C_SQUARE 0 /* square grid of circles */
|
||||
#define C_HEX 1 /* hexagonal/triangular grid of circles */
|
||||
@ -48,6 +49,8 @@
|
||||
#define O_CIRCLE 4 /* one circle at the origin */
|
||||
#define O_FOUR_CIRCLES 5 /* four circles */
|
||||
#define O_HEX 6 /* hexagonal lattice */
|
||||
#define O_SIDES 7 /* grid along the sides of the simulation rectangle */
|
||||
#define O_SIDES_B 71 /* finer grid along the sides of the simulation rectangle */
|
||||
|
||||
/* pattern of additional repelling segments */
|
||||
#define S_RECTANGLE 0 /* segments forming a rectangle */
|
||||
@ -101,6 +104,10 @@
|
||||
#define I_VICSEK_SPEED 10 /* Vicsek-type interaction with speed adjustment */
|
||||
#define I_VICSEK_SHARK 11 /* Vicsek-type interaction with speed adjustment, and one shark */
|
||||
#define I_COULOMB_LJ 12 /* Coulomb force regularised by Lennard-Jones repulsion */
|
||||
#define I_COULOMB_PENTA 13 /* Lennard-Jones force with or without pentagonal symmetry depending on charge */
|
||||
#define I_COULOMB_IMAGINARY 14 /* Coulomb interaction with "imaginary charge" */
|
||||
#define I_DNA_CHARGED 15 /* Coulomb-type interaction between end points of DNA nucleotides */
|
||||
#define I_DNA_CHARGED_B 151 /* stronger Coulomb-type interaction between end points of DNA nucleotides */
|
||||
|
||||
/* Boundary conditions */
|
||||
|
||||
@ -144,6 +151,8 @@
|
||||
#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 */
|
||||
#define TS_ATAN 7 /* atan approaching asymptotic value */
|
||||
#define TS_TANH 8 /* tanh approaching asymptotic value */
|
||||
|
||||
/* Gravity schedules */
|
||||
|
||||
@ -191,6 +200,14 @@
|
||||
#define CHEM_2H2O_H3O_OH 21 /* 2 H2O <-> H3O+ + OH- */
|
||||
#define CHEM_AGGREGATION 22 /* agregation of molecules coming close */
|
||||
#define CHEM_AGGREGATION_CHARGE 23 /* agregation of charged molecules coming close */
|
||||
#define CHEM_AGGREGATION_NNEIGH 24 /* agregation of molecules with limitation on neighbours */
|
||||
#define CHEM_DNA 25 /* aggregation of DNA molecules */
|
||||
#define CHEM_DNA_ALT 251 /* aggregation of DNA molecules with constraints on connections */
|
||||
#define CHEM_DNA_DOUBLE 252 /* aggregation of DNA molecules with different ends */
|
||||
#define CHEM_DNA_DSPLIT 253 /* aggregation/splitting of DNA molecules with different ends */
|
||||
#define CHEM_DNA_BASE_SPLIT 254 /* aggregation/splitting of DNA molecules when base pairs don't match */
|
||||
#define CHEM_DNA_ENZYME 255 /* aggregation/splitting of DNA molecules in presence of enzymes */
|
||||
#define CHEM_DNA_ENZYME_REPAIR 256 /* aggregation/splitting of DNA molecules in presence of enzymes and additional repairing of bad connections */
|
||||
|
||||
/* Initial conditions for chemical reactions */
|
||||
|
||||
@ -206,6 +223,8 @@
|
||||
#define IC_SIGNX 7 /* type 1 or 2 depending on sign of x */
|
||||
#define IC_TWOROCKETS 8 /* type 1 or 2 depending on rocket position */
|
||||
#define IC_TWOROCKETS_TWOFUELS 9 /* type 1 and 2 or 1 and 3 depending on rocket */
|
||||
#define IC_DNA_POLYMERASE 10 /* initial condition for DNA polymerase */
|
||||
#define IC_DNA_POLYMERASE_REC 11 /* initial condition for DNA polymerase with recombination */
|
||||
|
||||
/* Initial conditions for option TWO_TYPES */
|
||||
|
||||
@ -259,10 +278,15 @@
|
||||
#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_SOAP_N 41 /* polymers with pairwise coupling and neutral polar end */
|
||||
#define POLY_SOAP_NMIX 42 /* polymers mixing neutral polar and neutral 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 */
|
||||
#define POLY_DNA 7 /* simplified model for DNA */
|
||||
#define POLY_DNA_ALT 71 /* simplified model for DNA with different short ends */
|
||||
#define POLY_DNA_DOUBLE 72 /* simplified model for DNA with double ends for rigidity */
|
||||
#define POLY_DNA_FLEX 73 /* simplified model for DNA with less backbone rigidity (beta) */
|
||||
|
||||
/* Background color schemes */
|
||||
|
||||
@ -342,8 +366,15 @@ typedef struct
|
||||
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) */
|
||||
// short int mol_angle; /* for color scheme P_MOL_ANGLE */
|
||||
int cluster; /* number of cluster */
|
||||
int molecule; /* number of molecule */
|
||||
short int tested, cactive; /* for cluster search */
|
||||
short int coulomb; /* has value 1 if DNA-Coulomb interaction is attractive */
|
||||
short int added; /* has value 1 if particle has been added */
|
||||
short int reactive; /* has value 1 if particle can react */
|
||||
short int paired; /* has value 1 if belongs to base-paired molecule */
|
||||
int partner_molecule; /* number of partner molecule */
|
||||
} t_particle;
|
||||
|
||||
typedef struct
|
||||
@ -434,6 +465,15 @@ typedef struct
|
||||
int color; /* color hue in case of different collisions */
|
||||
} t_collision;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int nparticles; /* number of particles */
|
||||
int particle[NPARTNERS+1]; /* list of particles */
|
||||
int npartners; /* number of partner molecules */
|
||||
int partner[NMAXPARTNERMOLECULES]; /* list of partner molecules */
|
||||
int connection_type[NMAXPARTNERMOLECULES]; /* types of particles in connection */
|
||||
short int added; /* has value 1 if molecule has been added */
|
||||
} t_molecule;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -456,5 +496,6 @@ typedef struct
|
||||
|
||||
|
||||
|
||||
int ncircles, nobstacles, nsegments, ngroups = 1, counter = 0;
|
||||
int frame_time = 0, ncircles, nobstacles, nsegments, ngroups = 1, counter = 0, nmolecules = 0;
|
||||
FILE *lj_log;
|
||||
|
||||
|
@ -100,7 +100,9 @@
|
||||
#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 */
|
||||
#define D_RITCHEY_CHRETIEN_SPHERICAL 75 /* Ritchey-Chrétien telescope with spherical mirrors */
|
||||
#define D_RITCHEY_CHRETIEN_HYPERBOLIC 751 /* Ritchey-Chrétien telescope with hyperbolic mirrors */
|
||||
#define D_GRADIENT_INDEX_LENS 76 /* gradient index lens (only affects draw_billiard) */
|
||||
|
||||
/* for wave_sphere.c */
|
||||
|
||||
@ -120,6 +122,7 @@
|
||||
|
||||
#define NMAXCIRCLES 10000 /* total number of circles/polygons (must be at least NCX*NCY for square grid) */
|
||||
#define NMAXPOLY 50000 /* maximal number of vertices of polygonal lines (for von Koch et al) */
|
||||
#define NMAXSOURCES 10 /* maximal number of sources */
|
||||
|
||||
#define C_SQUARE 0 /* square grid of circles */
|
||||
#define C_HEX 1 /* hexagonal/triangular grid of circles */
|
||||
@ -185,6 +188,10 @@
|
||||
#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_GRADIENT_INDEX_LENS 18 /* gradient index lens (parabolic c(r)^2) */
|
||||
#define IOR_GRADIENT_INDEX_LENS_B 181 /* gradient index lens (parabolic c(r)) */
|
||||
#define IOR_LINEAR_X_A 19 /* IoR depending linearly on x */
|
||||
#define IOR_LINEAR_X_B 191 /* IoR depending linearly on x, with correct boundary values */
|
||||
|
||||
#define IOR_EARTH_DEM 20 /* digital elevation model (for waves on sphere) */
|
||||
|
||||
@ -204,11 +211,14 @@
|
||||
#define OSC_PERIODIC 0 /* periodic oscillation */
|
||||
#define OSC_SLOWING 1 /* oscillation of slowing frequency (anti-chirp) */
|
||||
#define OSC_WAVE_PACKET 2 /* Gaussian wave packet */
|
||||
#define OSC_WAVE_PACKETS 21 /* Gaussian wave packets */
|
||||
#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 */
|
||||
#define OSC_TWO_WAVES 6 /* two linear waves at an angle, separate */
|
||||
#define OSC_TWO_WAVES_ADDED 61 /* two linear waves at an angle, superimposed */
|
||||
|
||||
/* Wave packet types */
|
||||
|
||||
@ -305,6 +315,8 @@
|
||||
#define Z_NORM_GRADIENT_INTENSITY 24 /* gradient and intensity of polar angle */
|
||||
#define Z_VORTICITY 25 /* curl of polar angle */
|
||||
#define Z_VORTICITY_ABS 251 /* absolute value of curl of polar angle */
|
||||
#define Z_MAXTYPE_RPS 26 /* color or type with maximal density */
|
||||
// #define Z_ZERO 99 /* return zero */
|
||||
|
||||
/* for Schrodinger equation */
|
||||
#define Z_MODULE 30 /* module squared of first two fields */
|
||||
@ -315,6 +327,7 @@
|
||||
#define Z_MAXTYPE_RPSLZ 40 /* color of type with maximal density */
|
||||
#define Z_THETA_RPSLZ 41 /* polar angle */
|
||||
#define Z_NORM_GRADIENT_RPSLZ 42 /* gradient of polar angle */
|
||||
#define Z_NORM_GRADIENT_RPSLZ_ASYM 43 /* gradient of polar angle */
|
||||
|
||||
/* for Euler incompressible Euler equation */
|
||||
#define Z_EULER_VORTICITY 50 /* vorticity of velocity */
|
||||
@ -415,7 +428,6 @@ typedef struct
|
||||
} t_wave_source;
|
||||
|
||||
|
||||
|
||||
int ncircles = NMAXCIRCLES; /* actual number of circles, can be decreased e.g. for random patterns */
|
||||
int npolyline = NMAXPOLY; /* actual length of polyline */
|
||||
int npolyrect = NMAXPOLY; /* actual number of polyrect */
|
||||
@ -438,8 +450,11 @@ t_circle circles_b[NMAXCIRCLES]; /* circular scatterers */
|
||||
t_polygon polygons_b[NMAXCIRCLES]; /* polygonal scatterers */
|
||||
t_vertex polyline_b[NMAXPOLY]; /* vertices of polygonal line */
|
||||
|
||||
double courant2, courantb2; /* Courant parameters squared */
|
||||
|
||||
// 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 wave_source_x[NMAXSOURCES], wave_source_y[NMAXSOURCES]; /* position of wave source */
|
||||
double focus_x = XMAX; /* position of focus */
|
||||
double michelson_position = 0.0; /* position of mirror in Michelson interferometer */
|
||||
|
9
heat.c
9
heat.c
@ -227,6 +227,15 @@
|
||||
#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 WAVE_PROFILE_X 2.1 /* value of x to sample wave profile */
|
||||
#define HRES 1 /* dummy, only used by rde.c */
|
||||
#define INITIAL_SHIFT 20.0 /* time shift of initial wave packet (in oscillation periods) */
|
||||
#define WAVE_PACKET_SHIFT 200.0 /* time shift between wave packets (in oscillation periods) */
|
||||
#define FADE_IN_OBSTACLE 0 /* set to 1 to fade color inside obstacles */
|
||||
#define SHADE_2D 0 /* set to 1 to add pseudo-3d shading effect */
|
||||
#define SHADE_SCALE_2D 0.05 /* lower value increases sensitivity of shading */
|
||||
#define N_SOURCES 1 /* number of sources, for option draw_sources */
|
||||
double light[2] = {0.40824829, 0.816496581}; /* location of light source for SHADE_2D option*/
|
||||
/* end of constants only used by sub_wave and sub_maze */
|
||||
|
||||
#include "global_pdes.c"
|
||||
|
300
lennardjones.c
300
lennardjones.c
@ -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 1 /* set to 1 to generate movie */
|
||||
#define DOUBLE_MOVIE 0 /* set to 1 to produce movies for wave height and energy simultaneously */
|
||||
#define SAVE_MEMORY 1 /* set to 1 to save memory while saving frames */
|
||||
#define NO_EXTRA_BUFFER_SWAP 1 /* some OS require one less buffer swap when recording images */
|
||||
|
||||
@ -50,8 +50,6 @@
|
||||
|
||||
/* General geometrical parameters */
|
||||
|
||||
// #define WINWIDTH 1440 /* window width */
|
||||
// #define WINHEIGHT 810 /* window height */
|
||||
#define WINWIDTH 1760 /* window width */
|
||||
#define WINHEIGHT 990 /* window height */
|
||||
|
||||
@ -60,20 +58,20 @@
|
||||
#define YMIN -1.125
|
||||
#define YMAX 1.125 /* y interval for 9/16 aspect ratio */
|
||||
|
||||
#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 INITXMIN -1.95
|
||||
#define INITXMAX 1.95 /* x interval for initial condition */
|
||||
#define INITYMIN -1.1
|
||||
#define INITYMAX 1.1 /* y interval for initial condition */
|
||||
|
||||
#define THERMOXMIN -1.25
|
||||
#define THERMOXMAX 1.25 /* x interval for initial condition */
|
||||
#define THERMOYMIN 0.0
|
||||
#define THERMOYMAX 0.75 /* y interval for initial condition */
|
||||
|
||||
#define ADDXMIN -1.95
|
||||
#define ADDXMAX 1.95 /* x interval for adding particles */
|
||||
#define ADDYMIN 1.4
|
||||
#define ADDYMAX 3.7 /* y interval for adding particles */
|
||||
#define ADDXMIN -1.5
|
||||
#define ADDXMAX 1.5 /* x interval for adding particles */
|
||||
#define ADDYMIN -1.0
|
||||
#define ADDYMAX 1.0 /* y interval for adding particles */
|
||||
#define ADDRMIN 4.75
|
||||
#define ADDRMAX 6.0 /* r interval for adding particles */
|
||||
|
||||
@ -85,13 +83,13 @@
|
||||
#define OBSXMIN -2.0
|
||||
#define OBSXMAX 2.0 /* x interval for motion of obstacle */
|
||||
|
||||
#define CIRCLE_PATTERN 1 /* pattern of circles, see list in global_ljones.c */
|
||||
#define CIRCLE_PATTERN 8 /* pattern of circles, see list in global_ljones.c */
|
||||
|
||||
#define ADD_INITIAL_PARTICLES 0 /* set to 1 to add a second type of particles */
|
||||
#define CIRCLE_PATTERN_B 1 /* pattern of circles for additional particles */
|
||||
#define CIRCLE_PATTERN_B 0 /* pattern of circles for additional particles */
|
||||
|
||||
#define ADD_FIXED_OBSTACLES 0 /* set to 1 do add fixed circular obstacles */
|
||||
#define OBSTACLE_PATTERN 6 /* pattern of obstacles, see list in global_ljones.c */
|
||||
#define OBSTACLE_PATTERN 71 /* 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 29 /* pattern of repelling segments, see list in global_ljones.c */
|
||||
@ -108,23 +106,21 @@
|
||||
#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 SPIN_INTER_FREQUENCY 2.0 /* angular frequency of spin-spin interaction */
|
||||
#define SPIN_INTER_FREQUENCY_B 2.0 /* angular frequency of spin-spin interaction for second particle type */
|
||||
#define MOL_ANGLE_FACTOR 1.0 /* rotation angle for P_MOL_ANGLE color scheme */
|
||||
|
||||
#define P_PERCOL 0.25 /* probability of having a circle in C_RAND_PERCOL arrangement */
|
||||
#define NPOISSON 100 /* number of points for Poisson C_RAND_POISSON arrangement */
|
||||
#define PDISC_DISTANCE 9.0 /* minimal distance in Poisson disc process, controls density of particles */
|
||||
#define PDISC_DISTANCE 9.6 /* 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.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 LAMBDA 0.2 /* parameter controlling the dimensions of domain */
|
||||
#define MU 0.0087 /* parameter controlling radius of particles */
|
||||
#define MU_B 0.012 /* 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 */
|
||||
@ -133,8 +129,8 @@
|
||||
#define MANDELLEVEL 1000 /* iteration level for Mandelbrot set */
|
||||
#define MANDELLIMIT 10.0 /* limit value for approximation of Mandelbrot set */
|
||||
#define FOCI 1 /* set to 1 to draw focal points of ellipse */
|
||||
#define NGRIDX 20 /* number of grid point for grid of disks */
|
||||
#define NGRIDY 10 /* number of grid point for grid of disks */
|
||||
#define NGRIDX 40 /* number of grid point for grid of disks */
|
||||
#define NGRIDY 20 /* 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 */
|
||||
@ -150,11 +146,11 @@
|
||||
|
||||
/* Parameters for length and speed of simulation */
|
||||
|
||||
#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 NSTEPS 2500 /* number of frames of movie */
|
||||
// #define NSTEPS 200 /* number of frames of movie */
|
||||
#define NVID 50 /* number of iterations between images displayed on screen */
|
||||
#define NSEG 25 /* number of segments of boundary of circles */
|
||||
#define INITIAL_TIME 0 /* time after which to start saving frames */
|
||||
#define INITIAL_TIME 5 /* time after which to start saving frames */
|
||||
#define OBSTACLE_INITIAL_TIME 0 /* time after which to start moving obstacle */
|
||||
#define BOUNDARY_WIDTH 1 /* width of particle boundary */
|
||||
#define LINK_WIDTH 2 /* width of links between particles */
|
||||
@ -164,7 +160,7 @@
|
||||
#define PSLEEP 1 /* sleep time during pause */
|
||||
#define SLEEP1 1 /* initial sleeping time */
|
||||
#define SLEEP2 1 /* final sleeping time */
|
||||
#define MID_FRAMES 20 /* number of still frames between parts of two-part movie */
|
||||
#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 END_FRAMES 100 /* number of still frames at end of movie */
|
||||
|
||||
@ -174,15 +170,14 @@
|
||||
|
||||
/* Plot type, see list in global_ljones.c */
|
||||
|
||||
#define PLOT 19
|
||||
// #define PLOT_B 1 /* plot type for second movie */
|
||||
#define PLOT_B 18 /* plot type for second movie */
|
||||
#define PLOT 5
|
||||
#define PLOT_B 13 /* plot type for second movie */
|
||||
|
||||
/* Background color depending on particle properties */
|
||||
|
||||
#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 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 DRAW_BONDS 1 /* set to 1 to draw bonds between neighbours */
|
||||
#define COLOR_BONDS 1 /* set to 1 to color bonds according to length */
|
||||
@ -198,13 +193,13 @@
|
||||
|
||||
#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_ANGLE 10 /* 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_CHARGE 18 /* Color palette for charge representation */
|
||||
#define COLOR_PALETTE_CLUSTER 0 /* Color palette for cluster representation */
|
||||
#define COLOR_PALETTE_CLUSTER 11 /* Color palette for cluster representation */
|
||||
|
||||
#define BLACK 1 /* background */
|
||||
|
||||
@ -241,24 +236,28 @@
|
||||
#define PARTICLE_HUE_MAX 0.0 /* color of saturated particle */
|
||||
// #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 70.0 /* hue of particles of type 2 */
|
||||
#define HUE_TYPE3 60.0 /* hue of particles of type 3 */
|
||||
#define PARTICLE_EMAX 20000.0 /* energy of particle with hottest color */
|
||||
#define HUE_TYPE0 300.0 /* hue of particles of type 0 */
|
||||
#define HUE_TYPE1 00.0 /* hue of particles of type 1 */
|
||||
#define HUE_TYPE2 340.0 /* hue of particles of type 2 */
|
||||
#define HUE_TYPE3 260.0 /* hue of particles of type 3 */
|
||||
#define HUE_TYPE4 200.0 /* hue of particles of type 4 */
|
||||
#define HUE_TYPE5 60.0 /* hue of particles of type 5 */
|
||||
#define HUE_TYPE6 130.0 /* hue of particles of type 6 */
|
||||
#define HUE_TYPE7 150.0 /* hue of particles of type 7 */
|
||||
#define BG_FORCE_SLOPE 7.5e-8 /* contant in BG_FORCE backgound color scheme*/
|
||||
|
||||
#define RANDOM_RADIUS 0 /* set to 1 for random circle radius */
|
||||
#define DT_PARTICLE 3.0e-6 /* time step for particle displacement */
|
||||
#define KREPEL 150.0 /* constant in repelling force between particles */
|
||||
#define KREPEL 15.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 25.0 /* radius in which repelling force acts (in units of particle radius) */
|
||||
#define DAMPING 20.0 /* damping coefficient of particles */
|
||||
#define DAMPING 500.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 1.0 /* mass of particle of radius MU */
|
||||
#define PARTICLE_MASS_B 2.0 /* mass of particle of radius MU_B */
|
||||
#define DAMPING_ROT 1.0e6 /* damping coefficient for rotation of particles */
|
||||
#define PARTICLE_MASS 2.0 /* mass of particle of radius MU */
|
||||
#define PARTICLE_MASS_B 16.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 */
|
||||
@ -271,7 +270,7 @@
|
||||
#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.0005 /* initial inverse temperature */
|
||||
#define BETA 0.00007 /* 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 */
|
||||
@ -288,39 +287,40 @@
|
||||
#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 50000.0 /* value of electric field */
|
||||
#define EFIELD 100000.0 /* value of electric field */
|
||||
#define ADD_BFIELD 0 /* set to 1 to add a magnetic field */
|
||||
#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 CHARGE 1.0 /* charge of particles of first type */
|
||||
#define CHARGE_B -1.5 /* charge of particles of second type */
|
||||
#define INCREASE_E 0 /* set to 1 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 20000.0 /* factor by which to increase magnetic field */
|
||||
#define CHARGE_OBSTACLES 1 /* set to 1 for obstacles to be charged */
|
||||
#define CHARGE_OBSTACLES 0 /* 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 */
|
||||
|
||||
#define ROTATION 0 /* set to 1 to include rotation of particles */
|
||||
#define COUPLE_ANGLE_TO_THERMOSTAT 1 /* set to 1 to couple angular degrees of freedom to thermostat */
|
||||
#define COUPLE_ANGLE_TO_THERMOSTAT 0 /* set to 1 to couple angular degrees of freedom to thermostat */
|
||||
#define DIMENSION_FACTOR 1.0 /* scaling factor taking into account number of degrees of freedom */
|
||||
#define KTORQUE 50.0 /* force constant in angular dynamics */
|
||||
#define KTORQUE -100.0 /* force constant in angular dynamics */
|
||||
#define KTORQUE_BOUNDARY 1.0e6 /* constant in torque from the boundary */
|
||||
#define KTORQUE_B 10.0 /* force constant in angular dynamics */
|
||||
#define KTORQUE_DIFF 150.0 /* force constant in angular dynamics for different particles */
|
||||
#define KTORQUE_DIFF -150.0 /* force constant in angular dynamics for different particles */
|
||||
#define DRAW_SPIN 0 /* set to 1 to draw spin vectors of particles */
|
||||
#define DRAW_SPIN_B 0 /* set to 1 to draw spin vectors of particles */
|
||||
#define DRAW_CROSS 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 SPIN_RANGE_B 10.0 /* range of spin-spin interaction for second type of particle */
|
||||
#define QUADRUPOLE_RATIO 0.6 /* anisotropy in quadrupole potential */
|
||||
|
||||
#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 INCREASE_BETA 1 /* set to 1 to increase BETA during simulation */
|
||||
#define BETA_SCHEDULE 3 /* type of temperature schedule, see TS_* in global_ljones */
|
||||
#define BETA_FACTOR 10.0 /* factor by which to change BETA during simulation */
|
||||
// #define BETA_FACTOR 0.08 /* factor by which to change BETA during simulation */
|
||||
#define TS_SLOPE 8.5 /* controls speed of change of BETA for TS_TANH schedule (default 1.0) */
|
||||
#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 */
|
||||
@ -356,7 +356,7 @@
|
||||
#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 */
|
||||
#define KREPEL_FACTOR 100.0 /* factor by which to change KREPEL during simulation */
|
||||
|
||||
#define PART_AT_BOTTOM 0 /* set to 1 to include "seed" particles at bottom */
|
||||
#define MASS_PART_BOTTOM 10000.0 /* mass of particles at bottom */
|
||||
@ -364,10 +364,10 @@
|
||||
|
||||
#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 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 ADD_TIME 50 /* time at which to add first particle */
|
||||
#define ADD_PERIOD 2 /* time interval between adding further particles */
|
||||
#define N_ADD_PARTICLES 8 /* number of particles to add */
|
||||
#define FINAL_NOADD_PERIOD 4700 /* final period where no particles are added */
|
||||
#define SAFETY_FACTOR 4.0 /* no particles are added at distance less than MU*SAFETY_FACTOR of other particles */
|
||||
|
||||
#define TRACER_PARTICLE 0 /* set to 1 to have a tracer particle */
|
||||
@ -417,20 +417,21 @@
|
||||
#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 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_DIFFUSION 0 /* set to 1 to simulate a chemical reaction (particles may change type) */
|
||||
#define RD_REACTION 256 /* type of reaction, see list in global_ljones.c */
|
||||
#define RD_TYPES 6 /* number of types in reaction-diffusion equation */
|
||||
#define RD_INITIAL_COND 10 /* 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.0001 /* probability controlling dissociation reaction */
|
||||
#define DISSOCIATION_PROB 0.0 /* probability controlling dissociation reaction */
|
||||
#define KILLING_PROB 0.0015 /* probability of enzymes being killed */
|
||||
#define CENTER_COLLIDED_PARTICLES 0 /* set to 1 to recenter particles upon reaction (may interfere with thermostat) */
|
||||
#define EXOTHERMIC 0 /* set to 1 to make reaction exo/endothermic */
|
||||
#define DELTA_EKIN 2000.0 /* change of kinetic energy in reaction */
|
||||
#define 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 DELTAVMAX 1000.0 /* maximal deltav allowed for pairing molecules */
|
||||
#define AGREGMAX 11 /* maximal number of partners for CHEM_AGGREGATION reaction */
|
||||
#define AGREG_DECOUPLE 12 /* 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 */
|
||||
@ -458,29 +459,34 @@
|
||||
#define PROP_MAX 0.9 /* max proportion of type 1 particles */
|
||||
|
||||
#define PAIR_PARTICLES 1 /* set to 1 to form particles pairs */
|
||||
#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 RANDOMIZE_ANGLE 0 /* set to 1 for random orientation */
|
||||
#define DEACIVATE_CLOSE_PAIRS 1 /* set to 1 to test for closeness to other particles */
|
||||
#define 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 THIRD_TYPE_PROPORTION 1.0 /* proportion of third type pairings, for certain pairing types */
|
||||
|
||||
#define KSPRING_PAIRS 1.0e10 /* spring constant for pair interaction */
|
||||
#define KTORQUE_PAIRS 1.0e10 /* constant for angular coupling in pair interaction */
|
||||
#define KTORQUE_PAIR_ANGLE 0.0 /* constant for coupling between orientation in pairs */
|
||||
#define NPARTNERS 8 /* number of partners of particles */
|
||||
#define NARMS 1 /* number of "arms" for certain paring types */
|
||||
#define PAIRING_TYPE 42 /* 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 PAIR_DRATIO 0.9 /* ratio between equilibrium distance and radius (default: 1.0) */
|
||||
#define MU_C 0.0125 /* radius of partner particle */
|
||||
#define PARTICLE_MASS_C 8.0 /* mass or partner particle */
|
||||
#define CHARGE_C -1.0 /* 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 SECONDARY_PAIRING 0 /* set to 1 to pair with secondary partners, experimental */
|
||||
#define DNA_RIGIDITY 0.5 /* controls rigidity for POLY_DNA_DOUBLE pairs, default = 1 */
|
||||
|
||||
#define PAIR_TYPEB_PARTICLES 1 /* set to 1 to pair particle of type 1 */
|
||||
#define 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 NPARTNERS_B 2 /* number of partners of particles */
|
||||
#define NARMS_B 1 /* number of "arms" for certain paring types */
|
||||
#define PAIRING_TYPE_B 2 /* type of pairing, see POLY_ in global_ljones.c */
|
||||
#define MU_D 0.008 /* radius of partner particle */
|
||||
#define PARTICLE_MASS_D 1.0 /* mass or partner particle */
|
||||
#define CHARGE_D 0.75 /* charge of partner particle */
|
||||
|
||||
#define NXMAZE 12 /* width of maze */
|
||||
#define NYMAZE 12 /* height of maze */
|
||||
@ -494,8 +500,8 @@
|
||||
#define FLOOR_OMEGA 0 /* set to 1 to limit particle momentum to PMAX */
|
||||
#define PMAX 1000.0 /* maximal force */
|
||||
|
||||
#define HASHX 60 /* size of hashgrid in x direction */
|
||||
#define HASHY 30 /* size of hashgrid in y direction */
|
||||
#define HASHX 80 /* size of hashgrid in x direction */
|
||||
#define HASHY 40 /* 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 */
|
||||
|
||||
@ -512,7 +518,8 @@
|
||||
#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)))
|
||||
#define PAIR_FORCE ((PAIR_PARTICLES)||((REACTION_DIFFUSION)&&((RD_REACTION == CHEM_AGGREGATION)||(RD_REACTION == CHEM_AGGREGATION_CHARGE)||(RD_REACTION == CHEM_AGGREGATION_NNEIGH))))
|
||||
#define COMPUTE_PAIR_TORQUE (KTORQUE_PAIR_ANGLE != 0.0)
|
||||
|
||||
double xshift = 0.0; /* x shift of shown window */
|
||||
double xspeed = 0.0; /* x speed of obstacle */
|
||||
@ -654,6 +661,16 @@ double temperature_schedule(int i)
|
||||
bc = -0.5*log(BETA_FACTOR);
|
||||
break;
|
||||
}
|
||||
case (TS_ATAN):
|
||||
{
|
||||
factor2 = (1.0/BETA_FACTOR - 1.0)*2.0/PI;
|
||||
break;
|
||||
}
|
||||
case (TS_TANH):
|
||||
{
|
||||
factor2 = 1.0/BETA_FACTOR - 1.0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
bexp2 = -log(factor2)/(double)(FINAL_DECREASE_PHASE);
|
||||
first = 0;
|
||||
@ -705,6 +722,16 @@ double temperature_schedule(int i)
|
||||
beta = BETA*exp(bc*(-1.0 + cos(N_TOSCILLATIONS*DPI*(t - 0.5*t*(1.0-t)))));
|
||||
break;
|
||||
}
|
||||
case (TS_ATAN):
|
||||
{
|
||||
beta = BETA/(1.0 + factor2*atan(2.0*(double)(i - INITIAL_TIME)/(double)(t1)));
|
||||
break;
|
||||
}
|
||||
case (TS_TANH):
|
||||
{
|
||||
beta = BETA/(1.0 + factor2*tanh(TS_SLOPE*(double)(i - INITIAL_TIME)/(double)(t1)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (i < INITIAL_TIME + t2) beta = BETA*factor2;
|
||||
@ -1010,6 +1037,7 @@ double evolve_particles(t_particle particle[NMAXCIRCLES], t_hashgrid hashgrid[HA
|
||||
px[j] *= exp(- DT_PARTICLE*damping);
|
||||
py[j] *= exp(- DT_PARTICLE*damping);
|
||||
pangle[j] *= exp(- DT_PARTICLE*DAMPING_ROT);
|
||||
// printf("Damping particle angular velocity\n");
|
||||
}
|
||||
if ((THERMOSTAT_ON)&&(COUPLE_ANGLE_TO_THERMOSTAT)&&(particle[j].thermostat))
|
||||
pangle[j] *= exp(- 0.5*DT_PARTICLE*xi);
|
||||
@ -1365,7 +1393,8 @@ 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, xmin, xmax, 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,
|
||||
angle, theta;
|
||||
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,
|
||||
@ -1382,6 +1411,7 @@ void animation()
|
||||
t_group_data *group_speeds;
|
||||
t_collision *collisions;
|
||||
t_hashgrid *hashgrid;
|
||||
t_molecule *molecule;
|
||||
t_lj_parameters params;
|
||||
char message[100];
|
||||
|
||||
@ -1407,6 +1437,9 @@ void animation()
|
||||
if (TRACER_PARTICLE)
|
||||
trajectory = (t_tracer *)malloc(TRAJECTORY_LENGTH*N_TRACER_PARTICLES*sizeof(t_tracer));
|
||||
|
||||
if (PAIR_PARTICLES)
|
||||
molecule = (t_molecule *)malloc(NMAXCIRCLES*sizeof(t_molecule)); /* molecules */
|
||||
|
||||
hashgrid = (t_hashgrid *)malloc(HASHX*HASHY*sizeof(t_hashgrid)); /* hashgrid */
|
||||
|
||||
qx = (double *)malloc(NMAXCIRCLES*sizeof(double));
|
||||
@ -1429,6 +1462,8 @@ void animation()
|
||||
lj_final_position = fopen("lj_final_position.dat", "w");
|
||||
}
|
||||
|
||||
lj_log = fopen("lj_logfile.txt", "w");
|
||||
|
||||
if (ADD_FIXED_OBSTACLES) init_obstacle_config(obstacle);
|
||||
if (ADD_FIXED_SEGMENTS) init_segment_config(segment);
|
||||
|
||||
@ -1445,7 +1480,11 @@ void animation()
|
||||
init_particle_config(particle);
|
||||
|
||||
/* add some particles, beta */
|
||||
if (ADD_INITIAL_PARTICLES) add_particle_config(particle, -0.6, 1.6, -1.0, 1.0, MU_B);
|
||||
if (ADD_INITIAL_PARTICLES)
|
||||
{
|
||||
add_particle_config(particle, INITXMIN - 0.5, INITXMAX + 0.5, INITYMAX + 0.1, YMAX-0.1, NGRIDX*5/4, 3, 0, MU);
|
||||
add_particle_config(particle, INITXMIN - 0.5, INITXMAX + 0.5, YMIN + 0.1, INITYMIN-0.1, NGRIDX*5/4, 3, 0, MU);
|
||||
}
|
||||
|
||||
init_hashgrid(hashgrid);
|
||||
|
||||
@ -1461,7 +1500,7 @@ void animation()
|
||||
|
||||
printf("Initializing configuration\n");
|
||||
|
||||
params.nactive = initialize_configuration(particle, hashgrid, obstacle, px, py, pangle, tracer_n, segment);
|
||||
params.nactive = initialize_configuration(particle, hashgrid, obstacle, px, py, pangle, tracer_n, segment, molecule);
|
||||
|
||||
printf("%i active particles\n", params.nactive);
|
||||
|
||||
@ -1486,6 +1525,10 @@ void animation()
|
||||
|
||||
for (i=0; i<=INITIAL_TIME + NSTEPS; i++)
|
||||
{
|
||||
/* TEST */
|
||||
// if (i >= 2000) exit(0);
|
||||
|
||||
frame_time++;
|
||||
printf("Computing frame %d\n",i);
|
||||
|
||||
if (INCREASE_KREPEL) params.krepel = repel_schedule(i);
|
||||
@ -1615,8 +1658,42 @@ void animation()
|
||||
if (speed > VICSEK_VMAX) speed = 0.5*(speed + VICSEK_VMAX);
|
||||
px[j] = speed*cos(particle[j].angle);
|
||||
py[j] = speed*sin(particle[j].angle);
|
||||
}
|
||||
|
||||
|
||||
/* TEST - adjust angles */
|
||||
if ((REACTION_DIFFUSION)&&(RD_REACTION == CHEM_AGGREGATION_NNEIGH))
|
||||
{
|
||||
// if (particle[j].npartners >= 1)
|
||||
// {
|
||||
// angle = 0.0;
|
||||
// theta = 0.99;
|
||||
// for (p=0; p<particle[j].npartners; p++)
|
||||
// angle += particle[particle[j].partner[p]].angle;
|
||||
// angle *= 1.0/(double)particle[j].npartners;
|
||||
// // particle[j].angle = theta*particle[j].angle - (1.0 - theta)*angle;
|
||||
// for (p=0; p<particle[j].npartners; p++)
|
||||
// {
|
||||
// k = particle[j].partner[p];
|
||||
// particle[k].angle = theta*particle[k].angle + (1.0 - theta)*angle;
|
||||
// }
|
||||
// }
|
||||
if (particle[j].npartners >= 1)
|
||||
{
|
||||
x = 0.0;
|
||||
y = 0.0;
|
||||
for (p=0; p<particle[j].npartners; p++)
|
||||
{
|
||||
x += particle[particle[j].partner[p]].xc;
|
||||
y += particle[particle[j].partner[p]].yc;
|
||||
}
|
||||
angle = argument(x, y);
|
||||
particle[i].angle = angle;
|
||||
for (p=0; p<particle[j].npartners; p++)
|
||||
{
|
||||
k = particle[j].partner[p];
|
||||
particle[k].angle = -angle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* add gravity */
|
||||
@ -1804,7 +1881,7 @@ void animation()
|
||||
/* case of reaction-diffusion equation */
|
||||
if ((i > INITIAL_TIME)&&(REACTION_DIFFUSION))
|
||||
{
|
||||
ncollisions = update_types(particle, collisions, ncollisions, particle_numbers, i - INITIAL_TIME - 1, &delta_energy);
|
||||
ncollisions = update_types(particle, molecule, collisions, ncollisions, particle_numbers, i - INITIAL_TIME - 1, &delta_energy);
|
||||
if (EXOTHERMIC) params.beta *= 1.0/(1.0 + delta_energy/totalenergy);
|
||||
params.nactive = 0;
|
||||
for (j=0; j<ncircles; j++) if (particle[j].active)
|
||||
@ -1832,9 +1909,15 @@ void animation()
|
||||
|
||||
/* add a particle */
|
||||
if ((ADD_PARTICLES)&&(i > ADD_TIME)&&((i - INITIAL_TIME - ADD_TIME)%ADD_PERIOD == 1)&&(i < NSTEPS - FINAL_NOADD_PERIOD))
|
||||
{
|
||||
/* add enzymes */
|
||||
if ((REACTION_DIFFUSION)&&((RD_REACTION == CHEM_DNA_ENZYME)||(RD_REACTION == CHEM_DNA_ENZYME_REPAIR)))
|
||||
{
|
||||
for (k=0; k<N_ADD_PARTICLES; k++)
|
||||
nadd_particle = add_particles(particle, px, py, nadd_particle, params);
|
||||
nadd_particle = add_particles(particle, px, py, nadd_particle, 7, molecule);
|
||||
}
|
||||
else for (k=0; k<N_ADD_PARTICLES; k++)
|
||||
nadd_particle = add_particles(particle, px, py, nadd_particle, 0, molecule);
|
||||
// params.nactive = nadd_particle;
|
||||
params.nactive = 0;
|
||||
for (j=0; j<ncircles; j++) if (particle[j].active) params.nactive++;
|
||||
@ -1923,6 +2006,8 @@ void animation()
|
||||
}
|
||||
}
|
||||
|
||||
fclose(lj_log);
|
||||
lj_log = fopen("lj_logfile.txt", "a");
|
||||
}
|
||||
|
||||
if (SAVE_TIME_SERIES)
|
||||
@ -1947,7 +2032,7 @@ void animation()
|
||||
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++)
|
||||
if (DOUBLE_MOVIE) for (i=0; i<MID_FRAMES; i++)
|
||||
{
|
||||
save_frame_lj();
|
||||
if (!NO_EXTRA_BUFFER_SWAP) glutSwapBuffers();
|
||||
@ -1962,10 +2047,13 @@ void animation()
|
||||
}
|
||||
if ((TIME_LAPSE)&&(!DOUBLE_MOVIE))
|
||||
{
|
||||
for (i=0; i<MID_FRAMES; i++) save_frame_lj();
|
||||
for (i=0; i<END_FRAMES; i++)
|
||||
save_frame_lj_counter(NSTEPS + MID_FRAMES + NSTEPS/TIME_LAPSE_FACTOR + i);
|
||||
}
|
||||
else for (i=0; i<END_FRAMES; i++) save_frame_lj_counter(NSTEPS + MID_FRAMES + 1 + counter + i);
|
||||
else if (DOUBLE_MOVIE)
|
||||
for (i=0; i<END_FRAMES; i++) save_frame_lj_counter(NSTEPS + MID_FRAMES + 1 + counter + i);
|
||||
else for (i=0; i<END_FRAMES; i++) save_frame_lj_counter(NSTEPS + 1 + counter + i);
|
||||
|
||||
s = system("mv lj*.tif tif_ljones/");
|
||||
}
|
||||
@ -2011,11 +2099,15 @@ void animation()
|
||||
// printf("16\n");
|
||||
if (REACTION_DIFFUSION) free(collisions);
|
||||
|
||||
if (PAIR_PARTICLES) free(molecule);
|
||||
|
||||
if (SAVE_TIME_SERIES)
|
||||
{
|
||||
fclose(lj_time_series);
|
||||
fclose(lj_final_position);
|
||||
}
|
||||
|
||||
fclose(lj_log);
|
||||
}
|
||||
|
||||
|
||||
|
@ -276,6 +276,14 @@
|
||||
#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) */
|
||||
#define HRES 1 /* dummy, only used by rde.c */
|
||||
#define INITIAL_SHIFT 20.0 /* time shift of initial wave packet (in oscillation periods) */
|
||||
#define WAVE_PACKET_SHIFT 200.0 /* time shift between wave packets (in oscillation periods) */
|
||||
#define FADE_IN_OBSTACLE 0 /* set to 1 to fade color inside obstacles */
|
||||
#define SHADE_2D 0 /* set to 1 to add pseudo-3d shading effect */
|
||||
#define SHADE_SCALE_2D 0.05 /* lower value increases sensitivity of shading */
|
||||
#define N_SOURCES 1 /* number of sources, for option draw_sources */
|
||||
double light[2] = {0.40824829, 0.816496581}; /* location of light source for SHADE_2D option*/
|
||||
/* end of constants only used by sub_wave and sub_maze */
|
||||
|
||||
#include "global_pdes.c"
|
||||
|
418
rde.c
418
rde.c
@ -39,7 +39,7 @@
|
||||
#include <omp.h>
|
||||
#include <time.h>
|
||||
|
||||
#define MOVIE 0 /* set to 1 to generate movie */
|
||||
#define MOVIE 1 /* set to 1 to generate movie */
|
||||
#define DOUBLE_MOVIE 1 /* set to 1 to produce movies for wave height and energy simultaneously */
|
||||
#define SAVE_MEMORY 1 /* set to 1 to save memory when writing tiff images */
|
||||
#define NO_EXTRA_BUFFER_SWAP 1 /* some OS require one less buffer swap when recording images */
|
||||
@ -48,8 +48,13 @@
|
||||
|
||||
#define WINWIDTH 1920 /* window width */
|
||||
#define WINHEIGHT 1150 /* window height */
|
||||
#define NX 1500 /* number of grid points on x axis */
|
||||
#define NY 750 /* number of grid points on y axis */
|
||||
// #define NX 240 /* number of grid points on x axis */
|
||||
// #define NY 120 /* number of grid points on y axis */
|
||||
// #define NX 960 /* number of grid points on x axis */
|
||||
// #define NY 500 /* number of grid points on y axis */
|
||||
#define NX 780 /* number of grid points on x axis */
|
||||
#define NY 400 /* number of grid points on y axis */
|
||||
#define HRES 2 /* factor for high resolution plots */
|
||||
|
||||
#define XMIN -2.0
|
||||
#define XMAX 2.0 /* x interval */
|
||||
@ -58,28 +63,32 @@
|
||||
|
||||
/* Choice of simulated equation */
|
||||
|
||||
#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 RDE_EQUATION 7 /* 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 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 DSMOOTH 1 /* size of neighbourhood of poles that are smoothed */
|
||||
#define SMOOTHPOLE 0.01 /* smoothing coefficient at poles */
|
||||
#define SMOOTHCOTPOLE 0.01 /* smoothing coefficient of cotangent at poles */
|
||||
#define PHISHIFT 0.0 /* shift of phi in 2D plot (in degrees) */
|
||||
#define SMOOTHBLOCKS 1 /* set to 1 to use blocks of points near the poles */
|
||||
#define BLOCKDIST 64 /* distance to poles where points are blocked */
|
||||
#define ZERO_MERIDIAN 190.0 /* choice of zero meridian (will be at left/right boundary of 2d plot) */
|
||||
|
||||
#define 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 0 /* set to 1 to add a foce field (for compressible Euler equation) */
|
||||
#define ADD_FORCE_FIELD 1 /* 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) */
|
||||
#define FORCE_FIELD 6 /* type of force field, see list in global_3d.c */
|
||||
#define ADD_CORIOLIS_FORCE 1 /* set to 1 to add Coriolis force (quasigeostrophic Euler equations) */
|
||||
#define VARIABLE_DEPTH 0 /* set to 1 for variable depth in shallow water equation */
|
||||
#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 0 /* to smoothly adapt initial state to obstacles */
|
||||
#define OBSTACLE_GEOMETRY 1 /* geometry of obstacles, as in B_DOMAIN */
|
||||
#define ADAPT_STATE_TO_BC 1 /* to smoothly adapt initial state to obstacles */
|
||||
#define OBSTACLE_GEOMETRY 84 /* geometry of obstacles, as in B_DOMAIN */
|
||||
#define BC_STIFFNESS 50.0 /* controls region of boundary condition control */
|
||||
#define CHECK_INTEGRAL 1 /* set to 1 to check integral of first field */
|
||||
|
||||
@ -98,8 +107,8 @@
|
||||
#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 0.9 /* parameter controlling the dimensions of domain */
|
||||
#define MU 0.06 /* parameter controlling the dimensions of domain */
|
||||
#define LAMBDA 1.0 /* parameter controlling the dimensions of domain */
|
||||
#define MU 1.0 /* 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 */
|
||||
#define MDEPTH 7 /* depth of computation of Menger gasket */
|
||||
@ -128,14 +137,20 @@
|
||||
|
||||
/* Physical parameters of wave equation */
|
||||
|
||||
#define DT 0.0000002
|
||||
// #define DT 0.0000001
|
||||
#define DT 0.00000015
|
||||
// #define DT 0.0000002
|
||||
// #define DT 0.0000012
|
||||
// #define DT 0.000003
|
||||
// #define DT 0.0000022
|
||||
// #define DT 0.0000012
|
||||
|
||||
#define VISCOSITY 0.075
|
||||
#define VISCOSITY 0.02
|
||||
#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 RPSLZB 0.0 /* 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 */
|
||||
@ -148,23 +163,24 @@
|
||||
#define BZQ 0.0008 /* parameter in BZ equation */
|
||||
#define BZF 1.2 /* parameter in BZ equation */
|
||||
#define B_FIELD 10.0 /* magnetic field */
|
||||
#define G_FIELD 0.75 /* gravity */
|
||||
#define G_FIELD 0.03 /* gravity/Coriolis force */
|
||||
#define BC_FIELD 1.0e-5 /* constant in repulsive field from obstacles */
|
||||
#define AB_RADIUS 0.2 /* radius of region with magnetic field for Aharonov-Bohm effect */
|
||||
#define K_EULER 50.0 /* constant in stream function integration of Euler equation */
|
||||
#define K_EULER_INC 0.5 /* constant in incompressible Euler equation */
|
||||
#define C_EULER_COMP 0.1 /* constant in compressible Euler equation */
|
||||
|
||||
#define SMOOTHEN_VORTICITY 0 /* set to 1 to smoothen vorticity field in Euler equation */
|
||||
#define SMOOTHEN_VELOCITY 0 /* set to 1 to smoothen velocity field in Euler equation */
|
||||
#define SMOOTHEN_VELOCITY 1 /* 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 SMOOTH_FACTOR 0.05 /* factor by which to smoothen */
|
||||
|
||||
#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 0 /* set to 1 to add tracer particles (for Euler equations) */
|
||||
#define N_TRACERS 1000 /* number of tracer particles */
|
||||
#define ADD_TRACERS 1 /* set to 1 to add tracer particles (for Euler equations) */
|
||||
#define N_TRACERS 2000 /* number of tracer particles */
|
||||
#define TRACERS_STEP 0.005 /* step size in tracer evolution */
|
||||
|
||||
#define T_OUT 2.0 /* outside temperature */
|
||||
@ -181,10 +197,9 @@
|
||||
#define ADJUST_INTSTEP 0 /* set to 1 to decrease integration step when viscosity increases */
|
||||
#define VISCOSITY_INITIAL_TIME 10 /* initial time during which viscosity remains constant */
|
||||
#define VISCOSITY_FACTOR 100.0 /* factor by which to change viscosity */
|
||||
#define VISCOSITY_MAX 2.0 /* max value of viscosity beyond which NVID is increased and integration step is decrase,
|
||||
for numerical stability */
|
||||
#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 1 /* set to 1 to change second parameter in Rock-Paper-Scissors-Lizard-Spock equation */
|
||||
#define CHANGE_RPSLZB 0 /* 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 */
|
||||
@ -215,11 +230,11 @@
|
||||
#define B_COND_TOP 0
|
||||
#define B_COND_BOTTOM 0
|
||||
|
||||
|
||||
/* Parameters for length and speed of simulation */
|
||||
|
||||
#define NSTEPS 3500 /* number of frames of movie */
|
||||
#define NVID 8 /* number of iterations between images displayed on screen */
|
||||
#define NSTEPS 1900 /* 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 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 */
|
||||
@ -242,23 +257,25 @@
|
||||
|
||||
#define ROTATE_VIEW 1 /* set to 1 to rotate position of observer */
|
||||
#define ROTATE_ANGLE 360.0 /* total angle of rotation during simulation */
|
||||
// #define ROTATE_ANGLE 90.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 VIEWPOINT_TRAJ 0 /* type of viewpoint trajectory */
|
||||
#define MAX_LATITUDE 45.0 /* maximal latitude for viewpoint trajectory VP_ORBIT2 */
|
||||
|
||||
#define DRAW_PERIODICISED 0 /* set to 1 to repeat wave periodically in x and y directions */
|
||||
|
||||
/* Plot type - color scheme */
|
||||
|
||||
#define CPLOT 40
|
||||
#define CPLOT_B 42
|
||||
#define CPLOT 62
|
||||
#define CPLOT_B 64
|
||||
|
||||
/* Plot type - height of 3D plot */
|
||||
|
||||
#define ZPLOT 42 /* z coordinate in 3D plot */
|
||||
#define ZPLOT_B 42 /* z coordinate in second 3D plot */
|
||||
#define ZPLOT 62 /* z coordinate in 3D plot */
|
||||
#define ZPLOT_B 64 /* 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 */
|
||||
#define NON_DIRICHLET_BC 0 /* set to 1 to draw only facets in domain, if field is not zero on boundary */
|
||||
#define WRAP_ANGLE 1 /* experimental: wrap angle to [0, 2Pi) for interpolation in angle schemes */
|
||||
#define FADE_IN_OBSTACLE 0 /* set to 1 to fade color inside obstacles */
|
||||
@ -275,7 +292,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 1 /* set to 1 to print rpslzb parameter */
|
||||
#define PRINT_RPSLZB 0 /* 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 */
|
||||
@ -299,7 +316,7 @@
|
||||
|
||||
/* Color schemes, see list in global_pdes.c */
|
||||
|
||||
#define COLOR_PALETTE 0 /* Color palette, see list in global_pdes.c */
|
||||
#define COLOR_PALETTE 10 /* Color palette, see list in global_pdes.c */
|
||||
#define COLOR_PALETTE_B 17 /* Color palette, see list in global_pdes.c */
|
||||
|
||||
#define BLACK 1 /* black background */
|
||||
@ -313,17 +330,17 @@
|
||||
|
||||
#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 0.5 /* additional scaling factor for color scheme P_3D_AMPLITUDE */
|
||||
#define VSCALE_AMPLITUDE 100.0 /* additional scaling factor for color scheme P_3D_AMPLITUDE */
|
||||
#define ATTENUATION 0.0 /* exponential attenuation coefficient of contrast with time */
|
||||
#define CURL_SCALE 0.000015 /* scaling factor for curl representation */
|
||||
#define CURL_SCALE 1.0 /* scaling factor for curl representation */
|
||||
#define RESCALE_COLOR_IN_CENTER 0 /* set to 1 to decrease color intentiy in the center (for wave escaping ring) */
|
||||
#define SLOPE_SCHROD_LUM 400.0 /* sensitivity of luminosity on module, for color scheme Z_ARGUMENT */
|
||||
#define MIN_SCHROD_LUM 0.2 /* minimal luminosity in color scheme Z_ARGUMENT*/
|
||||
#define SLOPE_SCHROD_LUM 100.0 /* sensitivity of luminosity on module, for color scheme Z_ARGUMENT */
|
||||
#define MIN_SCHROD_LUM 0.1 /* minimal luminosity in color scheme Z_ARGUMENT*/
|
||||
#define VSCALE_PRESSURE 2.0 /* additional scaling factor for color scheme Z_EULER_PRESSURE */
|
||||
#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 SHADE_SCALE_2D 0.25 /* 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 */
|
||||
@ -336,13 +353,15 @@
|
||||
#define LOG_SCALE 0.5 /* scaling factor for energy log representation */
|
||||
#define LOG_SHIFT 1.0
|
||||
#define LOG_MIN 1.0e-3 /* floor value for log vorticity plot */
|
||||
#define VSCALE_SPEED 200.0 /* additional scaling factor for color scheme Z_EULER_SPEED */
|
||||
#define VSCALE_SPEED 50.0 /* additional scaling factor for color scheme Z_EULER_SPEED */
|
||||
#define VMEAN_SPEED 0.0 /* mean value around which to scale for color scheme Z_EULER_SPEED */
|
||||
#define SHIFT_DENSITY 8.5 /* shift for color scheme Z_EULER_DENSITY */
|
||||
#define VSCALE_DENSITY 3.0 /* additional scaling factor for color scheme Z_EULER_DENSITY */
|
||||
#define VSCALE_VORTICITY 20.0 /* additional scaling factor for color scheme Z_EULERC_VORTICITY */
|
||||
#define SHIFT_DENSITY 1.0 /* shift for color scheme Z_EULER_DENSITY */
|
||||
#define VSCALE_DENSITY 30.0 /* additional scaling factor for color scheme Z_EULER_DENSITY */
|
||||
#define VSCALE_VORTICITY 15.0 /* additional scaling factor for color scheme Z_EULERC_VORTICITY */
|
||||
#define VORTICITY_SHIFT 0.0 /* vertical shift of vorticity */
|
||||
#define ZSCALE_SPEED 0.3 /* additional scaling factor for z-coord Z_EULER_SPEED and Z_SWATER_SPEED */
|
||||
#define ZSCALE_SPEED 0.5 /* additional scaling factor for z-coord Z_EULER_SPEED and Z_SWATER_SPEED */
|
||||
#define ZSHIFT_SPEED 0.0 /* additional shift of z-coord Z_EULER_SPEED and Z_SWATER_SPEED */
|
||||
#define ZSCALE_NORMGRADIENT -0.0001 /* vertical scaling for Z_NORM_GRADIENT */
|
||||
#define VSCALE_SWATER 250.0 /* additional scaling factor for color scheme Z_EULER_DENSITY */
|
||||
|
||||
#define NXMAZE 7 /* width of maze */
|
||||
@ -352,11 +371,11 @@
|
||||
#define MAZE_XSHIFT 0.0 /* horizontal shift of maze */
|
||||
#define MAZE_WIDTH 0.04 /* half width of maze walls */
|
||||
|
||||
#define DRAW_COLOR_SCHEME 0 /* set to 1 to plot the color scheme */
|
||||
#define COLORBAR_RANGE 2.5 /* scale of color scheme bar */
|
||||
#define DRAW_COLOR_SCHEME 1 /* set to 1 to plot the color scheme */
|
||||
#define COLORBAR_RANGE 3.0 /* scale of color scheme bar */
|
||||
#define COLORBAR_RANGE_B 2.5 /* scale of color scheme bar for 2nd part */
|
||||
#define ROTATE_COLOR_SCHEME 0 /* set to 1 to draw color scheme horizontally */
|
||||
#define CIRC_COLORBAR 1 /* set to 1 to draw circular color scheme */
|
||||
#define CIRC_COLORBAR 0 /* set to 1 to draw circular color scheme */
|
||||
#define CIRC_COLORBAR_B 1 /* set to 1 to draw circular color scheme */
|
||||
|
||||
/* only for compatibility with wave_common.c */
|
||||
@ -386,9 +405,12 @@
|
||||
#define FLUX_WINDOW 20 /* averaging window for energy flux */
|
||||
#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_SOURCES 1 /* number of wave 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 INITIAL_SHIFT 20.0 /* time shift of initial wave packet (in oscillation periods) */
|
||||
#define WAVE_PACKET_SHIFT 200.0 /* time shift between wave packets (in oscillation periods) */
|
||||
#define 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 */
|
||||
@ -403,33 +425,48 @@
|
||||
#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 */
|
||||
#define MESSAGE_LDASH 1 /* length of dash for Morse code message */
|
||||
#define MESSAGE_LDOT 1 /* length of dot for Morse code message */
|
||||
#define MESSAGE_LINTERVAL 1 /* length of interval between dashes/dots for Morse code message */
|
||||
#define MESSAGE_LINTERLETTER 1 /* length of interval between letters for Morse code message */
|
||||
#define MESSAGE_LSPACE 1 /* length of space for Morse code message */
|
||||
#define MESSAGE_INITIAL_TIME 1 /* initial time before starting message for Morse code message */
|
||||
/* end of constants added only for compatibility with wave_common.c */
|
||||
|
||||
|
||||
double u_3d[2] = {0.75, -0.45}; /* projections of basis vectors for REP_AXO_3D representation */
|
||||
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, 8.0, 7.0}; /* location of observer for REP_PROJ_3D representation */
|
||||
double light[3] = {-0.40824829, -0.816496581, 0.40824829}; /* vector of "light" direction for P_3D_ANGLE color scheme */
|
||||
double observer[3] = {-8.0, -4.0, 4.0}; /* location of observer for REP_PROJ_3D representation */
|
||||
int reset_view = 0; /* switch to reset 3D view parameters (for option ROTATE_VIEW) */
|
||||
|
||||
/* constants for simulations on planets */
|
||||
#define ADD_DEM 1 /* add DEM (digital elevation model) */
|
||||
#define ADD_NEGATIVE_DEM 0 /* add DEM with bathymetric data */
|
||||
#define RSCALE_DEM 0.1 /* 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 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 VENUS_NODATA_FACTOR 0.5 /* altitude to assign to DEM points without data (fraction of mean altitude) */
|
||||
|
||||
#define Z_SCALING_FACTOR 0.8 /* overall scaling factor of z axis for REP_PROJ_3D representation */
|
||||
#define XY_SCALING_FACTOR 2.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.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 DRAW_ARROW 0 /* set to 1 to draw arrow above sphere */
|
||||
|
||||
#define RSCALE 0.01 /* scaling factor of radial component */
|
||||
#define RSHIFT -0.01 /* shift in radial component */
|
||||
#define RMAX 2.0 /* max value of radial component */
|
||||
#define RMIN 0.5 /* min value of radial component */
|
||||
// #define COS_VISIBLE -1.1 /* limit on cosine of normal to shown facets */
|
||||
#define COS_VISIBLE -0.3 /* limit on cosine of normal to shown facets */
|
||||
|
||||
#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 */
|
||||
@ -443,6 +480,9 @@ int reset_view = 0; /* switch to reset 3D view parameters (for option RO
|
||||
|
||||
#define ASYM_SPEED_COLOR (VMEAN_SPEED == 0.0)
|
||||
|
||||
int block_sizes[NY]; /* table of block sizes for blocking around poles */
|
||||
int block_numbers[NY]; /* table of block numbers for blocking around poles */
|
||||
|
||||
#include "global_pdes.c"
|
||||
#include "global_3d.c" /* constants and global variables */
|
||||
|
||||
@ -665,7 +705,7 @@ void initialize_vector_potential(double vpotential_field[2*NX*NY])
|
||||
}
|
||||
}
|
||||
|
||||
void initialize_gfield(double gfield[2*NX*NY], double bc_field[NX*NY], double bc_field2[NX*NY])
|
||||
void initialize_gfield(double gfield[2*NX*NY], double bc_field[NX*NY], double bc_field2[NX*NY], t_wave_sphere *wsphere, t_wave_sphere *wsphere_hr)
|
||||
/* initialize the exterior field, e.g. for the compressible Euler equation */
|
||||
{
|
||||
int i, j;
|
||||
@ -701,7 +741,37 @@ void initialize_gfield(double gfield[2*NX*NY], double bc_field[NX*NY], double bc
|
||||
gfield[NX*NY+(NX-1)*NY+j] = 0.0;
|
||||
}
|
||||
}
|
||||
else if (FORCE_FIELD == GF_EARTH)
|
||||
{
|
||||
dx = (XMAX - XMIN)/(double)NX;
|
||||
dy = (YMAX - YMIN)/(double)NY;
|
||||
init_earth_map_rde(wsphere, 1);
|
||||
init_earth_map_rde(wsphere_hr, HRES);
|
||||
|
||||
#pragma omp parallel for private(i,j)
|
||||
for (i=1; i<NX-1; i++){
|
||||
for (j=1; j<NY-1; j++){
|
||||
gfield[i*NY+j] = BC_FIELD*(wsphere[(i+1)*NY+j].altitude - wsphere[(i-1)*NY+j].altitude)/dx;
|
||||
gfield[NX*NY+i*NY+j] = BC_FIELD*(wsphere[i*NY+j+1].altitude - wsphere[i*NY+j-1].altitude)/dy;
|
||||
}
|
||||
}
|
||||
|
||||
/* boundaries TODO */
|
||||
for (i=0; i<NX; i++)
|
||||
{
|
||||
gfield[i*NY] = 0.0;
|
||||
gfield[NX*NY+i*NY] = 0.0;
|
||||
gfield[i*NY+NY-1] = 0.0;
|
||||
gfield[NX*NY+i*NY+NY-1] = 0.0;
|
||||
}
|
||||
for (j=0; j<NY; j++)
|
||||
{
|
||||
gfield[j] = 0.0;
|
||||
gfield[NX*NY+j] = 0.0;
|
||||
gfield[(NX-1)*NY+j] = 0.0;
|
||||
gfield[NX*NY+(NX-1)*NY+j] = 0.0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#pragma omp parallel for private(i,j)
|
||||
@ -990,7 +1060,8 @@ double gfield[2*NX*NY], t_rde rde[NX*NY], t_wave_sphere wsphere[NX*NY])
|
||||
}
|
||||
|
||||
/* smooth vector fields at poles */
|
||||
if (SPHERE) for (k=0; k<NFIELDS; k++) smooth_poles(phi_in[k]);
|
||||
if ((SPHERE)&&(!SMOOTHBLOCKS)) for (k=0; k<NFIELDS; k++) smooth_poles(phi_in[k]);
|
||||
else for (k=0; k<NFIELDS; k++) block_poles(phi_in[k]);
|
||||
|
||||
for (i=0; i<NLAPLACIANS; i++) delta_phi[i] = (double *)malloc(NX*NY*sizeof(double));
|
||||
|
||||
@ -1048,8 +1119,8 @@ double gfield[2*NX*NY], t_rde rde[NX*NY], t_wave_sphere wsphere[NX*NY])
|
||||
case (E_EULER_COMP):
|
||||
{
|
||||
nabla_rho = (double *)malloc(2*NX*NY*sizeof(double));
|
||||
compute_gradient_euler_test(phi_in[0], nabla_rho, xy_in);
|
||||
compute_velocity_gradients(phi_in, rde, xy_in);
|
||||
compute_gradient_euler_test(phi_in[0], nabla_rho, xy_in, wsphere);
|
||||
compute_velocity_gradients(phi_in, rde, xy_in, wsphere);
|
||||
|
||||
if (SMOOTHEN_VELOCITY) /* beta: try to reduce formation of ripples */
|
||||
{
|
||||
@ -1075,8 +1146,8 @@ double gfield[2*NX*NY], t_rde rde[NX*NY], t_wave_sphere wsphere[NX*NY])
|
||||
case (E_SHALLOW_WATER):
|
||||
{
|
||||
nabla_eta = (double *)malloc(2*NX*NY*sizeof(double));
|
||||
compute_gradient_euler_test(phi_in[0], nabla_eta, xy_in);
|
||||
compute_velocity_gradients(phi_in, rde, xy_in);
|
||||
compute_gradient_euler_test(phi_in[0], nabla_eta, xy_in, wsphere);
|
||||
compute_velocity_gradients(phi_in, rde, xy_in, wsphere);
|
||||
|
||||
if (VISCOSITY > 0.0)
|
||||
{
|
||||
@ -1213,7 +1284,7 @@ double gfield[2*NX*NY], t_rde rde[NX*NY], t_wave_sphere wsphere[NX*NY])
|
||||
vx = rde[i*NY+j].dxv;
|
||||
vy = rde[i*NY+j].dyv;
|
||||
|
||||
phi_out[0][i*NY+j] = rho - intstep*(u*rhox + v*rhoy + rho*(ux + vy));
|
||||
phi_out[0][i*NY+j] = rho - intstep*C_EULER_COMP*(u*rhox + v*rhoy + rho*(ux + vy));
|
||||
phi_out[1][i*NY+j] = u - intstep*(u*ux + v*uy + K_EULER_INC*rhox/rho);
|
||||
phi_out[2][i*NY+j] = v - intstep*(u*vx + v*vy + K_EULER_INC*rhoy/rho);
|
||||
|
||||
@ -1223,10 +1294,24 @@ double gfield[2*NX*NY], t_rde rde[NX*NY], t_wave_sphere wsphere[NX*NY])
|
||||
phi_out[2][i*NY+j] += intstep*gfield[NX*NY+i*NY+j];
|
||||
}
|
||||
if (ADD_CORIOLIS_FORCE)
|
||||
{
|
||||
if (SPHERE)
|
||||
{
|
||||
phi_out[1][i*NY+j] += intstep*G_FIELD*v*wsphere[i*NY+j].ctheta;
|
||||
phi_out[2][i*NY+j] -= intstep*G_FIELD*u*wsphere[i*NY+j].reg_cottheta;
|
||||
// phi_out[1][i*NY+j] += intstep*G_FIELD*v;
|
||||
// phi_out[2][i*NY+j] -= intstep*G_FIELD*u;
|
||||
// phi_out[1][i*NY+j] -= intstep*G_FIELD*v;
|
||||
// phi_out[2][i*NY+j] += intstep*G_FIELD*u;
|
||||
// phi_out[1][i*NY+j] -= intstep*G_FIELD*v*wsphere[i*NY+j].ctheta;
|
||||
// phi_out[2][i*NY+j] += intstep*G_FIELD*u*wsphere[i*NY+j].ctheta;
|
||||
}
|
||||
else
|
||||
{
|
||||
phi_out[1][i*NY+j] += intstep*G_FIELD*v;
|
||||
phi_out[2][i*NY+j] -= intstep*G_FIELD*u;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case (E_SHALLOW_WATER):
|
||||
@ -1340,11 +1425,58 @@ void evolve_wave(double *phi[NFIELDS], double *phi_tmp[NFIELDS], short int xy_in
|
||||
evolve_wave_half(phi_tmp, phi, xy_in, potential_field, vector_potential_field, gfield, rde, wsphere);
|
||||
}
|
||||
|
||||
void update_tracer_table(double tracers[2*N_TRACERS*NSTEPS], t_rde rde[NX*NY], int time)
|
||||
/* update tracer information in rde */
|
||||
{
|
||||
int tracer, t, t1, maxtime, i, j, n, ij[2], length = 50, cell, oldcell;
|
||||
double x, y;
|
||||
|
||||
void evolve_tracers(double *phi[NFIELDS], double tracers[2*N_TRACERS*NSTEPS], int time, int nsteps, double step)
|
||||
#pragma omp parallel for private(cell)
|
||||
for (cell=0; cell<NX*NY; cell++)
|
||||
{
|
||||
rde[cell].tracer = 0;
|
||||
rde[cell].prev_cell = cell;
|
||||
rde[cell].n_tracer_pts = 0;
|
||||
}
|
||||
|
||||
maxtime = length;
|
||||
if (maxtime > time) maxtime = time;
|
||||
|
||||
#pragma omp parallel for private(tracer)
|
||||
for (tracer = 0; tracer < N_TRACERS; tracer++)
|
||||
{
|
||||
for (t = 0; t < maxtime; t++)
|
||||
{
|
||||
t1 = time - t;
|
||||
|
||||
x = tracers[t1*2*N_TRACERS + 2*tracer];
|
||||
y = tracers[t1*2*N_TRACERS + 2*tracer + 1];
|
||||
|
||||
xy_to_ij(x, y, ij);
|
||||
cell = ij[0]*NY + ij[1];
|
||||
|
||||
n = rde[cell].n_tracer_pts;
|
||||
if (n < NMAX_TRACER_PTS)
|
||||
{
|
||||
rde[cell].tracerx[n] = x;
|
||||
rde[cell].tracery[n] = y;
|
||||
rde[cell].n_tracer_pts++;
|
||||
rde[cell].tracer = length - t;
|
||||
}
|
||||
// else printf("More than %i tracer points per cell\n", NMAX_TRACER_PTS);
|
||||
|
||||
if ((cell != oldcell)&&(t > 0))
|
||||
rde[cell].prev_cell = oldcell;
|
||||
|
||||
oldcell = cell;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void evolve_tracers(double *phi[NFIELDS], double tracers[2*N_TRACERS*NSTEPS], t_rde rde[NX*NY], int time, int nsteps, double step)
|
||||
/* time steps of tracer particle evolution (for Euler equation) */
|
||||
{
|
||||
int tracer, i, j, t, ij[2], iplus, jplus;
|
||||
int tracer, i, j, n, t, ij[2], iplus, jplus, prev_cell, new_cell;
|
||||
double x, y, xy[2], vx, vy;
|
||||
|
||||
step = TRACERS_STEP;
|
||||
@ -1408,6 +1540,8 @@ void evolve_tracers(double *phi[NFIELDS], double tracers[2*N_TRACERS*NSTEPS], in
|
||||
tracers[(time+1)*2*N_TRACERS + 2*tracer + 1] = y;
|
||||
}
|
||||
}
|
||||
|
||||
if ((PLOT_3D)&&(time+1 < NSTEPS)) update_tracer_table(tracers, rde, time);
|
||||
}
|
||||
|
||||
|
||||
@ -1542,7 +1676,7 @@ void draw_color_bar_palette(int plot, double range, int palette, int circular, i
|
||||
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);
|
||||
draw_color_scheme_palette_fade(XMIN + 0.8, YMIN + 0.05, XMAX - 0.8, YMIN + 0.05 + 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);
|
||||
}
|
||||
@ -1599,35 +1733,73 @@ void viewpoint_schedule(int i)
|
||||
/* change position of observer */
|
||||
{
|
||||
int j;
|
||||
double angle, ca, sa;
|
||||
static double observer_initial[3];
|
||||
double angle, ca, sa, r1, interpolate, rho;
|
||||
static double observer_initial[3], r, ratio, rho0, zmax;
|
||||
static int first = 1;
|
||||
|
||||
if (first)
|
||||
{
|
||||
for (j=0; j<3; j++) observer_initial[j] = observer[j];
|
||||
r1 = observer[0]*observer[0] + observer[1]*observer[1];
|
||||
r = sqrt(r1 + observer[2]*observer[2]);
|
||||
ratio = r/sqrt(r1);
|
||||
rho0 = module2(observer[0], observer[1]);
|
||||
if (vabs(rho0) < 0.001) rho0 = 0.001;
|
||||
zmax = r*sin(MAX_LATITUDE*PI/180.0);
|
||||
first = 0;
|
||||
}
|
||||
|
||||
angle = (ROTATE_ANGLE*DPI/360.0)*(double)i/(double)NSTEPS;
|
||||
interpolate = (double)i/(double)NSTEPS;
|
||||
angle = (ROTATE_ANGLE*DPI/360.0)*interpolate;
|
||||
// printf("i = %i, interpolate = %.3lg, angle = %.3lg\n", i, interpolate, angle);
|
||||
ca = cos(angle);
|
||||
sa = sin(angle);
|
||||
switch (VIEWPOINT_TRAJ)
|
||||
{
|
||||
case (VP_HORIZONTAL):
|
||||
{
|
||||
observer[0] = ca*observer_initial[0] - sa*observer_initial[1];
|
||||
observer[1] = sa*observer_initial[0] + ca*observer_initial[1];
|
||||
break;
|
||||
}
|
||||
case (VP_ORBIT):
|
||||
{
|
||||
observer[0] = ca*observer_initial[0] - sa*observer_initial[1]*ratio;
|
||||
observer[1] = ca*observer_initial[1] + sa*observer_initial[0]*ratio;
|
||||
observer[2] = ca*observer_initial[2];
|
||||
break;
|
||||
}
|
||||
case (VP_ORBIT2):
|
||||
{
|
||||
observer[0] = ca*observer_initial[0] - sa*observer_initial[1]*ratio;
|
||||
observer[1] = ca*observer_initial[1] + sa*observer_initial[0]*ratio;
|
||||
observer[2] = sa*zmax;
|
||||
break;
|
||||
}
|
||||
case (VP_POLAR):
|
||||
{
|
||||
rho = -sa*observer_initial[2] + ca*rho0;
|
||||
observer[0] = observer_initial[0]*rho/rho0;
|
||||
observer[1] = observer_initial[1]*rho/rho0;
|
||||
observer[2] = ca*observer_initial[2] + sa*rho0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
printf("Angle %.3lg, Observer position (%.3lg, %.3lg, %.3lg)\n", angle, observer[0], observer[1], observer[2]);
|
||||
}
|
||||
|
||||
|
||||
void animation()
|
||||
{
|
||||
double time = 0.0, scale, dx, var, jangle, cosj, sinj, sqrintstep,
|
||||
double time = 0.0, scale, dx, var, jangle, cosj, sinj, sqrintstep, phishift, thetashift, amp,
|
||||
intstep0, viscosity_printed, fade_value, noise = NOISE_INTENSITY, x, y, sign, phase;
|
||||
double *phi[NFIELDS], *phi_tmp[NFIELDS], *potential_field, *vector_potential_field, *tracers, *gfield, *bc_field, *bc_field2;
|
||||
short int *xy_in;
|
||||
int i, j, k, s, nvid, field;
|
||||
static int counter = 0;
|
||||
t_rde *rde;
|
||||
t_wave_sphere *wsphere;
|
||||
t_wave_sphere *wsphere, *wsphere_hr;
|
||||
|
||||
/* Since NX and NY are big, it seemed wiser to use some memory allocation here */
|
||||
for (i=0; i<NFIELDS; i++)
|
||||
@ -1642,7 +1814,10 @@ void animation()
|
||||
if (SPHERE)
|
||||
{
|
||||
wsphere = (t_wave_sphere *)malloc(NX*NY*sizeof(t_wave_sphere));
|
||||
init_wave_sphere_rde(wsphere);
|
||||
init_wave_sphere_rde(wsphere,1);
|
||||
/* high resolution version for planet simulations */
|
||||
wsphere_hr = (t_wave_sphere *)malloc(HRES*HRES*NX*NY*sizeof(t_wave_sphere));
|
||||
init_wave_sphere_rde(wsphere_hr,HRES);
|
||||
}
|
||||
|
||||
npolyline = init_polyline(MDEPTH, polyline);
|
||||
@ -1676,7 +1851,7 @@ void animation()
|
||||
bc_field = (double *)malloc(NX*NY*sizeof(double));
|
||||
bc_field2 = (double *)malloc(NX*NY*sizeof(double));
|
||||
|
||||
initialize_bcfield(bc_field, bc_field2, polyrect);
|
||||
initialize_bcfield(bc_field, bc_field2, polyrect, wsphere);
|
||||
}
|
||||
if (ADD_FORCE_FIELD)
|
||||
{
|
||||
@ -1686,7 +1861,7 @@ void animation()
|
||||
exit(1);
|
||||
}
|
||||
gfield = (double *)malloc(2*NX*NY*sizeof(double));
|
||||
initialize_gfield(gfield, bc_field, bc_field2);
|
||||
initialize_gfield(gfield, bc_field, bc_field2, wsphere, wsphere_hr);
|
||||
}
|
||||
|
||||
|
||||
@ -1707,7 +1882,7 @@ void animation()
|
||||
|
||||
/* initialize field */
|
||||
// init_random(0.5, 0.4, phi, xy_in);
|
||||
init_random(0.5, 0.25, phi, xy_in, wsphere);
|
||||
// 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(0.0, 0.0, 10.0, 0.0, 0.1, phi, xy_in);
|
||||
@ -1734,10 +1909,44 @@ void animation()
|
||||
// add_vortex_state(-0.35, -0.75, -0.1, 0.4, 0.5, phi, xy_in);
|
||||
// add_vortex_state(0.1, -0.3, 0.7, 0.1, -0.5, phi, xy_in);
|
||||
|
||||
// init_vortex_state(0.1, 0.4, 0.0, 0.3, -0.1, phi, xy_in);
|
||||
// add_vortex_state(0.1, -0.4, 0.0, 0.3, 0.1, phi, xy_in);
|
||||
|
||||
// init_laminar_flow(double amp, double xmodulation, double ymodulation, double xperiod, double yperiod, double yshift, double density_mod, double *phi[NFIELDS], short int xy_in[NX*NY])
|
||||
|
||||
init_laminar_flow_earth(0.04, phi, xy_in);
|
||||
|
||||
/* high pressure systems, northern hemisphere */
|
||||
init_vortex_state_sphere_mod(1, 0.5, 2.5*PID, PID + 0.6, 0.03, 0.04, phi, xy_in, wsphere);
|
||||
init_vortex_state_sphere_mod(1, 0.6, 3.7*PID, PID + 0.7, 0.035, 0.04, phi, xy_in, wsphere);
|
||||
init_vortex_state_sphere_mod(1, 0.2, 2.5*PID, PID + 1.3, 0.01, 0.01, phi, xy_in, wsphere);
|
||||
init_vortex_state_sphere_mod(1, 0.5, 1.0*PID, PID + 1.0, 0.03, 0.02, phi, xy_in, wsphere);
|
||||
// init_vortex_state_sphere_mod(1, 0.1, 3.0*PID, 0.9*PI, 0.01, 0.01, phi, xy_in, wsphere);
|
||||
/* low pressure systems, northern hemisphere */
|
||||
init_vortex_state_sphere_mod(1, -0.5, 3.0*PID, PID + 0.6, 0.03, -0.04, phi, xy_in, wsphere);
|
||||
init_vortex_state_sphere_mod(1, -0.2, 2.3*PID, PID + 1.1, 0.01, -0.02, phi, xy_in, wsphere);
|
||||
init_vortex_state_sphere_mod(1, -0.5, 1.2*PID, PID + 0.4, 0.01, -0.04, phi, xy_in, wsphere);
|
||||
init_vortex_state_sphere_mod(1, -0.8, 0.3*PID, PID + 0.6, 0.01, -0.04, phi, xy_in, wsphere);
|
||||
/* high pressure systems, southern hemisphere */
|
||||
init_vortex_state_sphere_mod(1, -0.6, 2.4*PID, PID - 0.7, 0.03, 0.04, phi, xy_in, wsphere);
|
||||
init_vortex_state_sphere_mod(1, -0.6, 1.6*PID, PID - 0.7, 0.02, 0.04, phi, xy_in, wsphere);
|
||||
init_vortex_state_sphere_mod(1, -0.4, 0.5*PID, PID - 0.7, 0.02, 0.04, phi, xy_in, wsphere);
|
||||
/* low pressure systems, southern hemisphere */
|
||||
init_vortex_state_sphere_mod(1, 0.5, 3.4*PID, PID - 0.7, 0.03, -0.04, phi, xy_in, wsphere);
|
||||
init_vortex_state_sphere_mod(1, 0.2, 2.0*PID, PID - 0.1, 0.04, -0.04, phi, xy_in, wsphere);
|
||||
init_vortex_state_sphere_mod(1, 0.3, 1.0*PID, PID - 0.6, 0.03, -0.04, phi, xy_in, wsphere);
|
||||
init_vortex_state_sphere_mod(1, 0.4, 0.1*PID, PID - 0.5, 0.03, -0.04, phi, xy_in, wsphere);
|
||||
init_vortex_state_sphere_mod(1, 0.2, 0.1*PID, 0.1, 0.1, -0.01, phi, xy_in, wsphere);
|
||||
|
||||
// init_pressure_gradient_flow(flow_speed_schedule(0), 1.0 + PRESSURE_GRADIENT, 1.0 - PRESSURE_GRADIENT, phi, xy_in, bc_field);
|
||||
|
||||
// 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_shear_flow_sphere(1.0, 0.25, 0.25, 6, 6, 0.75, phi, xy_in, wsphere);
|
||||
|
||||
// phishift = 0.0;
|
||||
// thetashift = 0.2*PID;
|
||||
// amp = 1.0;
|
||||
// init_vortex_state_sphere(0, amp, phishift, PID + thetashift, 0.15, 0.3, phi, xy_in, wsphere);
|
||||
|
||||
|
||||
// init_gaussian_wave(-1.0, 0.0, 0.005, 0.25, SWATER_MIN_HEIGHT, phi, xy_in);
|
||||
|
||||
@ -1749,6 +1958,7 @@ void animation()
|
||||
|
||||
// add_gaussian_wave(-1.6, -0.5, 0.015, 0.25, SWATER_MIN_HEIGHT, phi, xy_in);
|
||||
|
||||
if (SMOOTHBLOCKS) for (k=0; k<NFIELDS; k++) block_poles(phi[k]);
|
||||
if (ADAPT_STATE_TO_BC) adapt_state_to_bc(phi, bc_field, xy_in);
|
||||
|
||||
init_cfield_rde(phi, xy_in, CPLOT, rde, 0);
|
||||
@ -1774,7 +1984,7 @@ void animation()
|
||||
|
||||
printf("Drawing wave\n");
|
||||
|
||||
draw_wave_rde(0, phi, xy_in, rde, wsphere, potential_field, ZPLOT, CPLOT, COLOR_PALETTE, 0, 1.0, 1);
|
||||
draw_wave_rde(0, phi, xy_in, rde, wsphere, wsphere_hr, 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);
|
||||
@ -1812,7 +2022,7 @@ void animation()
|
||||
}
|
||||
|
||||
printf("Drawing wave %i\n", i);
|
||||
draw_wave_rde(0, phi, xy_in, rde, wsphere, potential_field, ZPLOT, CPLOT, COLOR_PALETTE, 0, 1.0, 1);
|
||||
draw_wave_rde(0, phi, xy_in, rde, wsphere, wsphere_hr, 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 */
|
||||
@ -1840,12 +2050,15 @@ void animation()
|
||||
if (ADD_TRACERS)
|
||||
{
|
||||
printf("Evolving tracer particles\n");
|
||||
evolve_tracers(phi, tracers, i, 10, 0.1);
|
||||
evolve_tracers(phi, tracers, rde, i, 10, 0.1);
|
||||
// for (j=0; j<N_TRACERS; j++)
|
||||
// printf("Tracer %i position (%.2f, %.2f)\n", j, tracers[2*N_TRACERS*i + 2*j], tracers[2*N_TRACERS*i + 2*j + 1]);
|
||||
if (!PLOT_3D)
|
||||
{
|
||||
printf("Drawing tracer particles\n");
|
||||
draw_tracers(phi, tracers, i, 0, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
if (ANTISYMMETRIZE_WAVE_FCT) antisymmetrize_wave_function(phi, xy_in);
|
||||
|
||||
@ -1906,8 +2119,8 @@ void animation()
|
||||
|
||||
if ((i >= INITIAL_TIME)&&(DOUBLE_MOVIE))
|
||||
{
|
||||
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_wave_rde(1, phi, xy_in, rde, wsphere, wsphere_hr, potential_field, ZPLOT_B, CPLOT_B, COLOR_PALETTE_B, 0, 1.0, REFRESH_B);
|
||||
if ((ADD_TRACERS)&&(!PLOT_3D)) 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);
|
||||
if (DRAW_COLOR_SCHEME) draw_color_bar_palette(CPLOT_B, COLORBAR_RANGE_B, COLOR_PALETTE_B, CIRC_COLORBAR_B, 0, 1.0);
|
||||
@ -1938,8 +2151,8 @@ void animation()
|
||||
{
|
||||
if (DOUBLE_MOVIE)
|
||||
{
|
||||
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_wave_rde(0, phi, xy_in, rde, wsphere, wsphere_hr, potential_field, ZPLOT, CPLOT, COLOR_PALETTE, 0, 1.0, 1);
|
||||
if ((ADD_TRACERS)&&(!PLOT_3D)) 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);
|
||||
if (DRAW_COLOR_SCHEME) draw_color_bar_palette(CPLOT, COLORBAR_RANGE, COLOR_PALETTE, CIRC_COLORBAR, 0, 1.0);
|
||||
@ -1950,16 +2163,16 @@ 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, wsphere, potential_field, ZPLOT, CPLOT, COLOR_PALETTE, 1, fade_value, 0);
|
||||
if (ADD_TRACERS) draw_tracers(phi, tracers, NSTEPS, 1, fade_value);
|
||||
draw_wave_rde(0, phi, xy_in, rde, wsphere, wsphere_hr, potential_field, ZPLOT, CPLOT, COLOR_PALETTE, 1, fade_value, 0);
|
||||
if ((ADD_TRACERS)&&(!PLOT_3D)) 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);
|
||||
if (DRAW_COLOR_SCHEME) draw_color_bar_palette(CPLOT, COLORBAR_RANGE, COLOR_PALETTE, CIRC_COLORBAR, 1, fade_value);
|
||||
if (!NO_EXTRA_BUFFER_SWAP) glutSwapBuffers();
|
||||
save_frame_counter(NSTEPS + i + 1);
|
||||
}
|
||||
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);
|
||||
draw_wave_rde(1, phi, xy_in, rde, wsphere, wsphere_hr, potential_field, ZPLOT_B, CPLOT_B, COLOR_PALETTE_B, 0, 1.0, REFRESH_B);
|
||||
if ((ADD_TRACERS)&&(!PLOT_3D)) 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);
|
||||
glutSwapBuffers();
|
||||
@ -1968,8 +2181,8 @@ 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, 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);
|
||||
draw_wave_rde(1, phi, xy_in, rde, wsphere, wsphere_hr, potential_field, ZPLOT_B, CPLOT_B, COLOR_PALETTE_B, 1, fade_value, 0);
|
||||
if ((ADD_TRACERS)&&(!PLOT_3D)) 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);
|
||||
glutSwapBuffers();
|
||||
@ -1982,8 +2195,8 @@ 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, wsphere, potential_field, ZPLOT, CPLOT, COLOR_PALETTE, 1, fade_value, 0);
|
||||
if (ADD_TRACERS) draw_tracers(phi, tracers, NSTEPS, 1, fade_value);
|
||||
draw_wave_rde(0, phi, xy_in, rde, wsphere, wsphere_hr, potential_field, ZPLOT, CPLOT, COLOR_PALETTE, 1, fade_value, 0);
|
||||
if ((ADD_TRACERS)&&(!PLOT_3D)) 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();
|
||||
save_frame_counter(NSTEPS + 1 + counter + i);
|
||||
@ -1999,7 +2212,11 @@ void animation()
|
||||
free(phi_tmp[i]);
|
||||
}
|
||||
free(xy_in);
|
||||
if (SPHERE) free(wsphere);
|
||||
if (SPHERE)
|
||||
{
|
||||
free(wsphere);
|
||||
free(wsphere_hr);
|
||||
}
|
||||
if (ADD_POTENTIAL) free(potential_field);
|
||||
else if (ADD_MAGNETIC_FIELD)
|
||||
{
|
||||
@ -2057,7 +2274,8 @@ int main(int argc, char** argv)
|
||||
glutCreateWindow("FitzHugh-Nagumo equation in a planar domain");
|
||||
|
||||
if (PLOT_3D) init_3d();
|
||||
else init();
|
||||
else init_hres(HRES);
|
||||
// else init();
|
||||
|
||||
glutDisplayFunc(display);
|
||||
|
||||
|
@ -207,6 +207,15 @@
|
||||
#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 WAVE_PROFILE_X 2.1 /* value of x to sample wave profile */
|
||||
#define HRES 1 /* dummy, only used by rde.c */
|
||||
#define INITIAL_SHIFT 20.0 /* time shift of initial wave packet (in oscillation periods) */
|
||||
#define WAVE_PACKET_SHIFT 200.0 /* time shift between wave packets (in oscillation periods) */
|
||||
#define FADE_IN_OBSTACLE 0 /* set to 1 to fade color inside obstacles */
|
||||
#define SHADE_2D 0 /* set to 1 to add pseudo-3d shading effect */
|
||||
#define SHADE_SCALE_2D 0.05 /* lower value increases sensitivity of shading */
|
||||
#define N_SOURCES 1 /* number of sources, for option draw_sources */
|
||||
double light[2] = {0.40824829, 0.816496581}; /* location of light source for SHADE_2D option*/
|
||||
/* end of constants only used by sub_wave and sub_maze */
|
||||
|
||||
|
||||
|
320
sub_wave.c
320
sub_wave.c
@ -134,6 +134,16 @@ void init() /* initialisation of window */
|
||||
glOrtho(0.0, NX, 0.0, NY, -1.0, 1.0);
|
||||
}
|
||||
|
||||
void init_hres(int res) /* initialisation of window in higher resolution */
|
||||
{
|
||||
glLineWidth(3);
|
||||
|
||||
glClearColor(0.0, 0.0, 0.0, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
// glOrtho(XMIN, XMAX, YMIN, YMAX , -1.0, 1.0);
|
||||
glOrtho(0.0, res*NX, 0.0, res*NY, -1.0, 1.0);
|
||||
}
|
||||
void blank()
|
||||
{
|
||||
if (BLACK) glClearColor(0.0, 0.0, 0.0, 1.0);
|
||||
@ -427,6 +437,19 @@ void xy_to_pos(double x, double y, double pos[2])
|
||||
}
|
||||
|
||||
|
||||
void xy_to_pos_hres(double x, double y, double pos[2])
|
||||
/* convert (x,y) position to double-valued position in table representing wave */
|
||||
{
|
||||
double x1, y1;
|
||||
|
||||
x1 = (x - XMIN)/(XMAX - XMIN);
|
||||
y1 = (y - YMIN)/(YMAX - YMIN);
|
||||
|
||||
pos[0] = x1*(double)(HRES*NX);
|
||||
pos[1] = y1*(double)(HRES*NY);
|
||||
}
|
||||
|
||||
|
||||
void ij_to_xy(int i, int j, double xy[2])
|
||||
/* convert (i,j) position in table representing wave to (x,y) */
|
||||
{
|
||||
@ -492,6 +515,14 @@ void erase_area_hsl(double x, double y, double dx, double dy, double h, double s
|
||||
erase_area_rgb(x, y, dx, dy, rgb);
|
||||
}
|
||||
|
||||
void draw_vertex(double x, double y)
|
||||
{
|
||||
double pos[2];
|
||||
|
||||
xy_to_pos(x, y, pos);
|
||||
glVertex2d(pos[0], pos[1]);
|
||||
}
|
||||
|
||||
void draw_line(double x1, double y1, double x2, double y2)
|
||||
{
|
||||
double pos[2];
|
||||
@ -504,6 +535,18 @@ void draw_line(double x1, double y1, double x2, double y2)
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void draw_line_hres(double x1, double y1, double x2, double y2)
|
||||
{
|
||||
double pos[2];
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
xy_to_pos_hres(x1, y1, pos);
|
||||
glVertex2d(pos[0], pos[1]);
|
||||
xy_to_pos_hres(x2, y2, pos);
|
||||
glVertex2d(pos[0], pos[1]);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void draw_rectangle(double x1, double y1, double x2, double y2)
|
||||
{
|
||||
double pos[2];
|
||||
@ -2450,6 +2493,58 @@ int xy_in_arc(double x, double y, t_arc arc)
|
||||
return(alpha <= arc.dangle);
|
||||
}
|
||||
|
||||
|
||||
int rc_hyp(double x, double y)
|
||||
/* xy_in for D_RITCHEY_CHRETIEN_HYPERBOLIC domain */
|
||||
{
|
||||
static int first = 1;
|
||||
static double m, d, dprime, b, r1, r2, e1, e2, a1, b1, a2, b2, x01, x02;
|
||||
double y1, f, f1, f2;
|
||||
|
||||
if (first)
|
||||
{
|
||||
m = LAMBDA; /* secondary magnification */
|
||||
d = 2.5; /* distance between mirrors */
|
||||
b = 3.0; /* distance between secondary mirror and effective focal point */
|
||||
|
||||
f = m*d + b;
|
||||
f1 = f/m; /* focal distance of primary mirror */
|
||||
dprime = f1 - d; /* distance between secondary mirror and primary focal point */
|
||||
f2 = m*dprime/(m+1); /* focal distance of secondary mirror */
|
||||
|
||||
r1 = 2.0*f/m; /* radius of curvature of primary mirror */
|
||||
r2 = 2.0*b/(m - 1.0); /* radius of curvature of secondary mirror */
|
||||
e1 = sqrt(1.0 + 2.0*b/(m*m*m*d)); /* eccentricity of primary mirror */
|
||||
e2 = sqrt(1.0 + 2.0*(m*(2.0*m - 1.0) + b/d)/((m-1)*(m-1)*(m-1)));
|
||||
/* eccentricity of secondary mirror */
|
||||
a1 = f1/e1;
|
||||
b1 = sqrt(a1*r1); /* semi-axes of primary mirror */
|
||||
x01 = 0.5*d + a1; /* center of primary hyperbola */
|
||||
|
||||
a2 = f2/e2;
|
||||
b2 = sqrt(a2*r2); /* semi-axes of secondary mirror */
|
||||
x02 = -0.5*d + a2; /* center of secondary hyperbola */
|
||||
|
||||
first = 0;
|
||||
}
|
||||
|
||||
|
||||
y1 = vabs(y);
|
||||
|
||||
if (x > 0.0) /* primary mirror */
|
||||
{
|
||||
if (y1 < MU) return(1);
|
||||
if (x > 0.5*d + WALL_WIDTH) return(1);
|
||||
return((x-x01)*(x-x01) > a1*a1*(1.0 + y*y/(b1*b1)));
|
||||
}
|
||||
else /* secondary mirror */
|
||||
{
|
||||
if (y1 > 0.3) return(1);
|
||||
// if (x < -0.5*d - WALL_WIDTH) return(1);
|
||||
return((x > x02)||((x-x02)*(x-x02) < a2*a2*(1.0 + y*y/(b2*b2))));
|
||||
}
|
||||
}
|
||||
|
||||
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 */
|
||||
{
|
||||
@ -3420,7 +3515,7 @@ int xy_in_billiard_single_domain(double x, double y, int b_domain, int ncirc, t_
|
||||
if ((vabs(x) < LAMBDA)&&(vabs(y - h) < 0.5*WALL_WIDTH)) return(2);
|
||||
return(0);
|
||||
}
|
||||
case (D_RITCHEY_CHRETIEN):
|
||||
case (D_RITCHEY_CHRETIEN_SPHERICAL):
|
||||
{
|
||||
/* LAMBDA is magnification M */
|
||||
d = 2.5;
|
||||
@ -3443,6 +3538,15 @@ int xy_in_billiard_single_domain(double x, double y, int b_domain, int ncirc, t_
|
||||
return(module2(x-x1, y1) < r1);
|
||||
}
|
||||
}
|
||||
case (D_RITCHEY_CHRETIEN_HYPERBOLIC):
|
||||
{
|
||||
return(rc_hyp(x, y));
|
||||
}
|
||||
case (D_GRADIENT_INDEX_LENS):
|
||||
{
|
||||
/* use IOR_GRADIENT_INDEX_LENS for index of refraction control */
|
||||
return(1);
|
||||
}
|
||||
case (D_MENGER):
|
||||
{
|
||||
x1 = 0.5*(x+1.0);
|
||||
@ -3650,6 +3754,80 @@ void hex_transfo(double u, double v, double *x, double *y)
|
||||
*y = rb*v;
|
||||
}
|
||||
|
||||
void draw_rc_hyp()
|
||||
/* draw D_RITCHEY_CHRETIEN_HYPERBOLIC domain */
|
||||
{
|
||||
static int first = 1;
|
||||
static double m, d, dprime, b, r1, r2, e1, e2, a1, b1, a2, b2, x01, x02, dy;
|
||||
double x, y, f, f1, f2;
|
||||
|
||||
if (first)
|
||||
{
|
||||
m = LAMBDA; /* secondary magnification */
|
||||
d = 2.5; /* distance between mirrors */
|
||||
b = 3.0; /* distance between secondary mirror and effective focal point */
|
||||
|
||||
f = m*d + b;
|
||||
f1 = f/m; /* focal distance of primary mirror */
|
||||
dprime = f1 - d; /* distance between secondary mirror and primary focal point */
|
||||
f2 = m*dprime/(m+1); /* focal distance of secondary mirror */
|
||||
|
||||
r1 = 2.0*f/m; /* radius of curvature of primary mirror */
|
||||
r2 = 2.0*b/(m - 1.0); /* radius of curvature of secondary mirror */
|
||||
e1 = sqrt(1.0 + 2.0*b/(m*m*m*d)); /* eccentricity of primary mirror */
|
||||
e2 = sqrt(1.0 + 2.0*(m*(2.0*m - 1.0) + b/d)/((m-1)*(m-1)*(m-1)));
|
||||
|
||||
a1 = f1/e1;
|
||||
b1 = sqrt(a1*r1); /* semi-axes of primary mirror */
|
||||
x01 = 0.5*d + a1; /* center of primary hyperbola */
|
||||
|
||||
a2 = f2/e2;
|
||||
b2 = sqrt(a2*r2); /* semi-axes of secondary mirror */
|
||||
x02 = -0.5*d + a2; /* center of secondary hyperbola */
|
||||
|
||||
dy = (YMAX - YMIN)/(double)NSEG;
|
||||
first = 0;
|
||||
}
|
||||
|
||||
/* primary mirror */
|
||||
glBegin(GL_LINE_STRIP);
|
||||
draw_vertex(0.5*d + WALL_WIDTH, YMAX);
|
||||
draw_vertex(0.5*d + WALL_WIDTH, MU);
|
||||
for (y = MU; y < YMAX; y += dy)
|
||||
{
|
||||
x = x01 - a1*sqrt(1.0 + y*y/(b1*b1));
|
||||
draw_vertex(x, y);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
draw_vertex(0.5*d + WALL_WIDTH, YMIN);
|
||||
draw_vertex(0.5*d + WALL_WIDTH, -MU);
|
||||
for (y = -MU; y > YMIN; y -= dy)
|
||||
{
|
||||
x = x01 - a1*sqrt(1.0 + y*y/(b1*b1));
|
||||
draw_vertex(x, y);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
/* secondary mirror */
|
||||
glBegin(GL_LINE_STRIP);
|
||||
draw_vertex(XMIN, -0.3);
|
||||
for (y = -0.3; y < 0.3; y += dy)
|
||||
{
|
||||
x = x02 - a2*sqrt(1.0 + y*y/(b2*b2));
|
||||
draw_vertex(x, y);
|
||||
}
|
||||
draw_vertex(XMIN, 0.3);
|
||||
glEnd();
|
||||
|
||||
/* focal plane */
|
||||
glBegin(GL_LINE_STRIP);
|
||||
draw_vertex(b - 0.5*d, YMIN);
|
||||
draw_vertex(b - 0.5*d, YMAX);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
||||
void draw_billiard(int fade, double fade_value) /* draws the billiard boundary */
|
||||
{
|
||||
@ -5411,7 +5589,7 @@ void draw_billiard(int fade, double fade_value) /* draws the billiard bound
|
||||
write_text(pos[0], pos[1], message);
|
||||
break;
|
||||
}
|
||||
case (D_RITCHEY_CHRETIEN):
|
||||
case (D_RITCHEY_CHRETIEN_SPHERICAL):
|
||||
{
|
||||
d = 2.5;
|
||||
b = 3.5;
|
||||
@ -5437,6 +5615,21 @@ void draw_billiard(int fade, double fade_value) /* draws the billiard bound
|
||||
draw_line(0.5*d + WALL_WIDTH, -MU, 0.5*d + WALL_WIDTH, YMIN);
|
||||
break;
|
||||
}
|
||||
case (D_RITCHEY_CHRETIEN_HYPERBOLIC):
|
||||
{
|
||||
draw_rc_hyp();
|
||||
break;
|
||||
}
|
||||
case (D_GRADIENT_INDEX_LENS):
|
||||
{
|
||||
draw_line(-LAMBDA, YMIN, -LAMBDA, YMAX);
|
||||
draw_line(LAMBDA, YMIN, LAMBDA, YMAX);
|
||||
draw_line(-LAMBDA, -1.0, LAMBDA, -1.0);
|
||||
draw_line(-LAMBDA, 1.0, LAMBDA, 1.0);
|
||||
/* focal plane */
|
||||
draw_line(WAVE_PROFILE_X, YMIN, WAVE_PROFILE_X, YMAX);
|
||||
break;
|
||||
}
|
||||
case (D_MENGER):
|
||||
{
|
||||
glLineWidth(3);
|
||||
@ -6769,7 +6962,7 @@ void compute_laplacian(double phi[NX*NY], t_laplacian laplace[NX*NY], double del
|
||||
double oscillating_bc(int time, int j)
|
||||
{
|
||||
int ij[2], jmin, jmax;
|
||||
double t, phase, a, envelope, omega, amp, dist2;
|
||||
double t, t1, phase, a, envelope, omega, amp, dist2;
|
||||
|
||||
switch (OSCILLATION_SCHEDULE)
|
||||
{
|
||||
@ -6793,11 +6986,18 @@ double oscillating_bc(int time, int j)
|
||||
case (OSC_WAVE_PACKET):
|
||||
{
|
||||
t = (double)time*OMEGA;
|
||||
// a = 10.0;
|
||||
// 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);
|
||||
envelope = exp(-(t-INITIAL_SHIFT)*(t-INITIAL_SHIFT)/(a*a))*sqrt(DPI/a);
|
||||
return(phase*envelope);
|
||||
}
|
||||
case (OSC_WAVE_PACKETS):
|
||||
{
|
||||
t = (double)time*OMEGA;
|
||||
t1 = t - (double)((int)(t/WAVE_PACKET_SHIFT + 0.5))*WAVE_PACKET_SHIFT;
|
||||
a = sqrt(INITIAL_VARIANCE)/OMEGA;
|
||||
phase = AMPLITUDE*cos(t);
|
||||
envelope = exp(-(t1-INITIAL_SHIFT)*(t1-INITIAL_SHIFT)/(a*a))*sqrt(DPI/a);
|
||||
return(phase*envelope);
|
||||
}
|
||||
case (OSC_CHIRP):
|
||||
@ -6857,6 +7057,23 @@ double oscillating_bc(int time, int j)
|
||||
amp *= exp(-dist2/INITIAL_VARIANCE);
|
||||
return(amp);
|
||||
}
|
||||
case (OSC_TWO_WAVES):
|
||||
{
|
||||
t = (double)time*OMEGA + (double)(NY-j)*OSCIL_LEFT_YSHIFT/(double)NY;
|
||||
t1 = (double)time*OMEGA + (double)(j)*OSCIL_LEFT_YSHIFT/(double)NY;
|
||||
if (j < NY/2) amp = cos(t);
|
||||
else amp = cos(t1);
|
||||
return(AMPLITUDE*amp);
|
||||
}
|
||||
case (OSC_TWO_WAVES_ADDED):
|
||||
{
|
||||
t = (double)time*OMEGA + (double)(NY-j)*OSCIL_LEFT_YSHIFT/(double)NY;
|
||||
t1 = (double)time*OMEGA + (double)(j)*OSCIL_LEFT_YSHIFT/(double)NY;
|
||||
amp = 0.0;
|
||||
if (t > 0.0) amp += cos(t);
|
||||
if (t1 > 0.0) amp += cos(t1);
|
||||
return(AMPLITUDE*amp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -7256,6 +7473,7 @@ void init_ior_2d(short int *xy_in[NX], double *tcc_table[NX], double *tgamma_tab
|
||||
{
|
||||
printf("Initializing IOR_LENS_WALL\n");
|
||||
for (i=0; i<NX; i++){
|
||||
printf("i = %i\n", i);
|
||||
for (j=0; j<NY; j++){
|
||||
ij_to_xy(i, j, xy);
|
||||
x = xy[0];
|
||||
@ -7267,7 +7485,7 @@ void init_ior_2d(short int *xy_in[NX], double *tcc_table[NX], double *tgamma_tab
|
||||
}
|
||||
else
|
||||
{
|
||||
if (xy_in[i][j] == 1)
|
||||
if (xy_in[i][j] != 0)
|
||||
{
|
||||
tcc_table[i][j] = courant2;
|
||||
tgamma_table[i][j] = GAMMA;
|
||||
@ -7518,6 +7736,94 @@ void init_ior_2d(short int *xy_in[NX], double *tcc_table[NX], double *tgamma_tab
|
||||
}
|
||||
break;
|
||||
}
|
||||
case (IOR_GRADIENT_INDEX_LENS):
|
||||
{
|
||||
/* focal distance is f = 1/(4*LAMBDA*n0*MU) */
|
||||
/* with n0 = COURANT/COURANTB */
|
||||
for (i=0; i<NX; i++){
|
||||
for (j=0; j<NY; j++){
|
||||
ij_to_xy(i, j, xy);
|
||||
x = vabs(xy[0]);
|
||||
y = vabs(xy[1]);
|
||||
if ((x > LAMBDA))
|
||||
{
|
||||
tcc_table[i][j] = courant2;
|
||||
tgamma_table[i][j] = GAMMA;
|
||||
}
|
||||
else if (y > 1.0)
|
||||
{
|
||||
tcc_table[i][j] = 0.0;
|
||||
tgamma_table[i][j] = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
tcc_table[i][j] = courantb2/(1.0 - MU*y*y);
|
||||
tgamma_table[i][j] = GAMMAB;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case (IOR_GRADIENT_INDEX_LENS_B):
|
||||
{
|
||||
/* focal distance is f = 1/(4*LAMBDA*n0*MU) */
|
||||
/* with n0 = COURANT/COURANTB */
|
||||
for (i=0; i<NX; i++){
|
||||
for (j=0; j<NY; j++){
|
||||
ij_to_xy(i, j, xy);
|
||||
x = vabs(xy[0]);
|
||||
y = vabs(xy[1]);
|
||||
if ((x > LAMBDA))
|
||||
{
|
||||
tcc_table[i][j] = courant2;
|
||||
tgamma_table[i][j] = GAMMA;
|
||||
}
|
||||
else if (y > 1.0)
|
||||
{
|
||||
tcc_table[i][j] = 0.0;
|
||||
tgamma_table[i][j] = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
speed = 1.0/(1.0 - MU*y*y);
|
||||
speed *= speed;
|
||||
tcc_table[i][j] = courantb2*speed;
|
||||
tgamma_table[i][j] = GAMMAB;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case (IOR_LINEAR_X_A):
|
||||
{
|
||||
/* Warning: Depending on COURANT and COURANTB */
|
||||
/* this may generate a wave speed of the form |a - bx| */
|
||||
/* Use IOR_LINEAR_X_B instead to avoid this */
|
||||
for (i=0; i<NX; i++){
|
||||
for (j=0; j<NY; j++){
|
||||
ij_to_xy(i, j, xy);
|
||||
x = xy[0];
|
||||
speed = COURANT*(1.0-x) + COURANTB*x;
|
||||
tcc_table[i][j] = speed*speed;
|
||||
tgamma_table[i][j] = GAMMA;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case (IOR_LINEAR_X_B):
|
||||
{
|
||||
for (i=0; i<NX; i++){
|
||||
for (j=0; j<NY; j++){
|
||||
ij_to_xy(i, j, xy);
|
||||
x = xy[0];
|
||||
a = (x-XMIN)/(XMAX-XMIN);
|
||||
speed = COURANT*(1.0-a) + COURANTB*a;
|
||||
tcc_table[i][j] = speed*speed;
|
||||
tgamma_table[i][j] = GAMMA;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
for (i=0; i<NX; i++){
|
||||
|
108
sub_wave_3d.c
108
sub_wave_3d.c
@ -1620,6 +1620,114 @@ void init_speed_dissipation(short int xy_in[NX*NY], double tc[NX*NY], double tcc
|
||||
|
||||
break;
|
||||
}
|
||||
case (IOR_LENS_WALL):
|
||||
{
|
||||
printf("Case IOR_LENS_WALL in init_speed_dissipation of sub_wave_3d needs to be updated\n");
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
case (IOR_LENS_CONCAVE):
|
||||
{
|
||||
printf("Case IOR_LENS_CONCAVE in init_speed_dissipation of sub_wave_3d needs to be updated\n");
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
case (IOR_LENS_CONVEX_CONCAVE):
|
||||
{
|
||||
printf("Case IOR_LENS_CONVEX_CONCAVE in init_speed_dissipation of sub_wave_3d needs to be updated\n");
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
case (IOR_TREE):
|
||||
{
|
||||
printf("Case IOR_TREE in init_speed_dissipation of sub_wave_3d needs to be updated\n");
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
case (IOR_WAVE_GUIDES_COUPLED):
|
||||
{
|
||||
printf("Case IOR_WAVE_GUIDES_COUPLED in init_speed_dissipation of sub_wave_3d needs to be updated\n");
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
case (IOR_WAVE_GUIDES_COUPLED_B):
|
||||
{
|
||||
printf("Case IOR_WAVE_GUIDES_COUPLED_B in init_speed_dissipation of sub_wave_3d needs to be updated\n");
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
case (IOR_WAVE_GUIDE_COATED):
|
||||
{
|
||||
printf("Case IOR_WAVE_GUIDE_COATED in init_speed_dissipation of sub_wave_3d needs to be updated\n");
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
case (IOR_MICHELSON):
|
||||
{
|
||||
printf("Case IOR_MICHELSON in init_speed_dissipation of sub_wave_3d needs to be updated\n");
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
case (IOR_GRADIENT_INDEX_LENS):
|
||||
{
|
||||
/* focal distance if f = 1/(4*LAMBDA*n0*MU) */
|
||||
/* with n0 = COURANT/COURANTB */
|
||||
for (i=0; i<NX; i++){
|
||||
for (j=0; j<NY; j++){
|
||||
ij_to_xy(i, j, xy);
|
||||
x = vabs(xy[0]);
|
||||
y = vabs(xy[1]);
|
||||
tc[i*NY+j] = COURANT;
|
||||
if ((x > LAMBDA))
|
||||
{
|
||||
tcc[i*NY+j] = courant2;
|
||||
tgamma[i*NY+j] = GAMMA;
|
||||
}
|
||||
else if (y > 1.0)
|
||||
{
|
||||
tcc[i*NY+j] = 0.0;
|
||||
tgamma[i*NY+j] = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
tcc[i*NY+j] = courantb2/(1.0 - MU*y*y);
|
||||
tgamma[i*NY+j] = GAMMAB;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case (IOR_GRADIENT_INDEX_LENS_B):
|
||||
{
|
||||
/* focal distance if f = 1/(4*LAMBDA*n0*MU) */
|
||||
/* with n0 = COURANT/COURANTB */
|
||||
for (i=0; i<NX; i++){
|
||||
for (j=0; j<NY; j++){
|
||||
ij_to_xy(i, j, xy);
|
||||
x = vabs(xy[0]);
|
||||
y = vabs(xy[1]);
|
||||
tc[i*NY+j] = COURANT;
|
||||
if ((x > LAMBDA))
|
||||
{
|
||||
tcc[i*NY+j] = courant2;
|
||||
tgamma[i*NY+j] = GAMMA;
|
||||
}
|
||||
else if (y > 1.0)
|
||||
{
|
||||
tcc[i*NY+j] = 0.0;
|
||||
tgamma[i*NY+j] = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
speed = 1.0/(1.0 - MU*y*y);
|
||||
speed *= speed;
|
||||
tcc[i*NY+j] = courantb2*speed;
|
||||
tgamma[i*NY+j] = GAMMAB;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
for (i=0; i<NX; i++){
|
||||
|
@ -15,46 +15,47 @@ void init_3d() /* initialisation of window */
|
||||
}
|
||||
|
||||
|
||||
void init_wave_sphere_rde(t_wave_sphere wsphere[NX*NY])
|
||||
void init_wave_sphere_rde(t_wave_sphere *wsphere, int res)
|
||||
/* initialize sphere data, taken from sub_sphere.c */
|
||||
/* wsphere is assumed to have size res*res*NX*NY */
|
||||
{
|
||||
int i, j;
|
||||
double dphi, dtheta, theta0, xy[2], phishift;
|
||||
double dphi, dtheta, theta0, xy[2], phishift, reg_cot;
|
||||
|
||||
printf("Initializing wsphere\n");
|
||||
|
||||
dphi = DPI/(double)NX;
|
||||
dtheta = PI/(double)NY;
|
||||
dphi = DPI/(double)(res*NX);
|
||||
dtheta = PI/(double)(res*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 (i=0; i<res*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++)
|
||||
for (j=0; j<res*NY; j++)
|
||||
{
|
||||
wsphere[i*NY+j].phi = (double)i*dphi;
|
||||
wsphere[i*NY+j].theta = (double)j*dtheta;
|
||||
wsphere[i*res*NY+j].phi = (double)i*dphi;
|
||||
wsphere[i*res*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*res*NY+j].cphi = cos(wsphere[i*res*NY+j].phi);
|
||||
wsphere[i*res*NY+j].sphi = sin(wsphere[i*res*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*res*NY+j].ctheta = cos(wsphere[i*res*NY+j].theta);
|
||||
wsphere[i*res*NY+j].stheta = sin(wsphere[i*res*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*res*NY+j].x = wsphere[i*res*NY+j].cphi*wsphere[i*res*NY+j].stheta;
|
||||
wsphere[i*res*NY+j].y = wsphere[i*res*NY+j].sphi*wsphere[i*res*NY+j].stheta;
|
||||
wsphere[i*res*NY+j].z = -wsphere[i*res*NY+j].ctheta;
|
||||
|
||||
wsphere[i*NY+j].radius = 1.0;
|
||||
wsphere[i*NY+j].radius_dem = 1.0;
|
||||
wsphere[i*res*NY+j].radius = 1.0;
|
||||
wsphere[i*res*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);
|
||||
@ -65,17 +66,541 @@ void init_wave_sphere_rde(t_wave_sphere wsphere[NX*NY])
|
||||
|
||||
xy[1] *= (double)NY/(double)(NY-2*DPOLE);
|
||||
|
||||
wsphere[i*NY+j].x2d = xy[0];
|
||||
wsphere[i*NY+j].y2d = xy[1];
|
||||
wsphere[i*res*NY+j].x2d = xy[0];
|
||||
wsphere[i*res*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];
|
||||
wsphere[i*res*NY+j].cos_angle_sphere = wsphere[i*res*NY+j].x*light[0] + wsphere[i*res*NY+j].y*light[1] + wsphere[i*res*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;
|
||||
for (j=DPOLE; j<res*NY-DPOLE; j++) wsphere[i*res*NY+j].cottheta = wsphere[i*res*NY+j].ctheta/wsphere[i*res*NY+j].stheta;
|
||||
for (j=0; j<DPOLE; j++) wsphere[i*res*NY+j].cottheta = wsphere[i*res*NY+DPOLE].cottheta;
|
||||
for (j=res*NY-res*DPOLE; j<NY; j++) wsphere[i*res*NY+j].cottheta = wsphere[i*res*NY+DPOLE-1].cottheta;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* regularized cotangent */
|
||||
|
||||
for (j=0; j<res*NY; j++)
|
||||
{
|
||||
reg_cot = wsphere[j].ctheta/sqrt(1.0 + SMOOTHCOTPOLE*wsphere[j].stheta*wsphere[j].stheta);
|
||||
for (i=0; i<res*NX; i++)
|
||||
{
|
||||
wsphere[i*res*NY+j].reg_cottheta = reg_cot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void init_dem_rde(t_wave_sphere *wsphere, int dem_number, int res)
|
||||
/* init heights from digital elevation map */
|
||||
{
|
||||
int i, j, ii, jj, k, nx, ny, maxrgb, nmaxpixels = 4915200, scan, rgbval, diff, sshift, nshift, hmin, hmax, ishift, hsum, rnx, rny;
|
||||
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, vshift;
|
||||
double *height_values, *height_values_tmp;
|
||||
FILE *image_file;
|
||||
|
||||
printf("Reading digital elevation model\n");
|
||||
rnx = res*NX;
|
||||
rny = res*NY;
|
||||
|
||||
switch (dem_number) {
|
||||
case (DEM_EARTH):
|
||||
{
|
||||
nmaxpixels = 4915200;
|
||||
image_file = fopen("digital_elevation_model_large.ppm", "r");
|
||||
hsea = 12.0; /* sea level #0c0c0c */
|
||||
break;
|
||||
}
|
||||
case (DEM_MARS):
|
||||
{
|
||||
nmaxpixels = 8388608;
|
||||
image_file = fopen("marscyl2.ppm", "r");
|
||||
hsea = 6.0 + 255.0*PLANET_SEALEVEL/DEM_MAXHEIGHT;
|
||||
break;
|
||||
}
|
||||
case (DEM_MOON):
|
||||
{
|
||||
nmaxpixels = 2097152;
|
||||
image_file = fopen("Moon_LRO_LOLA_global_LDEM_1024.ppm", "r");
|
||||
hsea = 255.0*PLANET_SEALEVEL/(DEM_MAXHEIGHT - DEM_MAXDEPTH);
|
||||
break;
|
||||
}
|
||||
case (DEM_VENUS):
|
||||
{
|
||||
nmaxpixels = 4096*2048;
|
||||
image_file = fopen("Venus_Magellan_Topography_Global_4641m_v02_scaled2.ppm", "r");
|
||||
hsea = 255.0*PLANET_SEALEVEL/DEM_MAXHEIGHT;
|
||||
break;
|
||||
}
|
||||
case (DEM_MERCURY):
|
||||
{
|
||||
nmaxpixels = 1280*380;
|
||||
image_file = fopen("Mercury_Messenger_DEM_Global_665m_1024_1_cropped.ppm", "r");
|
||||
hsea = 255.0*PLANET_SEALEVEL/DEM_MAXHEIGHT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
rgb_values = (int *)malloc(3*nmaxpixels*sizeof(int));
|
||||
height_values = (double *)malloc(rnx*rny*sizeof(double));
|
||||
height_values_tmp = (double *)malloc(rnx*rny*sizeof(double));
|
||||
|
||||
// image_file = fopen("digital_elevation_model_large.ppm", "r");
|
||||
scan = fscanf(image_file,"%i %i\n", &nx, &ny);
|
||||
scan = fscanf(image_file,"%i\n", &maxrgb);
|
||||
|
||||
printf("nx = %i, ny = %i, maxrgb = %i\n", nx, ny, maxrgb);
|
||||
sleep(1);
|
||||
|
||||
hmin = maxrgb;
|
||||
hmax = 0;
|
||||
|
||||
if (nx*ny > nmaxpixels)
|
||||
{
|
||||
printf("DEM too large, increase nmaxpixels in init_dem()\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* shift due to min/max latitudes of image */
|
||||
sshift = 0 + DPOLE;
|
||||
nshift = 0 + DPOLE;
|
||||
|
||||
/* choice of zero meridian */
|
||||
ishift = (int)(nx*ZERO_MERIDIAN/360.0);
|
||||
|
||||
printf("Reading RGB values\n");
|
||||
|
||||
/* read rgb values */
|
||||
for (j=0; j<ny; j++)
|
||||
for (i=0; i<nx; i++)
|
||||
for (k=0; k<3; k++)
|
||||
{
|
||||
scan = fscanf(image_file,"%i\n", &rgbval);
|
||||
rgb_values[3*(j*nx+i)+k] = rgbval;
|
||||
if (rgbval < hmin)
|
||||
{
|
||||
if (B_DOMAIN == D_SPHERE_VENUS)
|
||||
{
|
||||
if (rgbval > 0) hmin = rgbval;
|
||||
}
|
||||
else hmin = rgbval;
|
||||
}
|
||||
if (rgbval > hmax) hmax = rgbval;
|
||||
}
|
||||
|
||||
printf("hmin = %i, hmax = %i, hsea = %i\n", hmin, hmax, (int)hsea);
|
||||
|
||||
if (B_DOMAIN == D_SPHERE_VENUS)
|
||||
{
|
||||
hsum = 0;
|
||||
for (j=0; j<ny; j++)
|
||||
for (i=0; i<nx; i++)
|
||||
hsum += rgb_values[3*(j*nx+i)];
|
||||
hmean = (double)hsum/(double)(nx*ny);
|
||||
printf("hmean = %.2f\n", hmean);
|
||||
}
|
||||
|
||||
cratio = 1.0/(double)(hmax-hmin);
|
||||
rx = (double)nx/(double)(rnx);
|
||||
ry = (double)ny/(double)(rny - sshift - nshift);
|
||||
|
||||
/* build height table */
|
||||
vshift = PLANET_SEALEVEL/(DEM_MAXHEIGHT - DEM_MAXDEPTH);
|
||||
for (i=0; i<rnx; i++)
|
||||
for (j=0; j<rny; j++)
|
||||
{
|
||||
ii = (int)(rx*(double)(rnx-1 - i)) + nx/2 + ishift;
|
||||
if (ii > nx-1) ii -= nx;
|
||||
if (ii < 0) ii = 0;
|
||||
jj = (int)(ry*(double)(rny-nshift - j));
|
||||
if (jj > ny-1) jj = ny-1;
|
||||
if (jj < 0) jj = 0;
|
||||
height_values[i*rny+j] = ((double)rgb_values[3*(jj*nx+ii)]-hsea)*cratio;
|
||||
wsphere[i*rny+j].altitude = ((double)rgb_values[3*(jj*nx+ii)]-hsea)*cratio;
|
||||
|
||||
/* take care of black areas (missing data) on venus */
|
||||
if ((B_DOMAIN == D_SPHERE_VENUS)&&(rgb_values[3*(jj*nx+ii)] == 0))
|
||||
{
|
||||
height_values[i*rny+j] = VENUS_NODATA_FACTOR*hmean*cratio;
|
||||
wsphere[i*rny+j].altitude = VENUS_NODATA_FACTOR*hmean*cratio;
|
||||
}
|
||||
|
||||
if (OTHER_PLANET)
|
||||
wsphere[i*rny+j].indomain = (wsphere[i*rny+j].altitude < vshift);
|
||||
|
||||
// if (wsphere[i*rny+j].indomain) printf("rgb = %i, altitude = %.3lg\n", rgb_values[3*(jj*nx+ii)], height_values[i*rny+j]);
|
||||
}
|
||||
|
||||
/* smooth values in case of high resolution */
|
||||
if ((rnx > nx)||(rny > ny))
|
||||
{
|
||||
for (i=1; i<rnx-1; i++)
|
||||
for (j=1; j<rny-1; j++)
|
||||
{
|
||||
height_values[i*rny+j] *= 0.2;
|
||||
height_values[i*rny+j] += 0.2*height_values[(i+1)*rny+j];
|
||||
height_values[i*rny+j] += 0.2*height_values[(i-1)*rny+j];
|
||||
height_values[i*rny+j] += 0.2*height_values[i*rny+j-1];
|
||||
height_values[i*rny+j] += 0.2*height_values[i*rny+j+1];
|
||||
|
||||
wsphere[i*rny+j].altitude *= 0.2;
|
||||
wsphere[i*rny+j].altitude += 0.2*wsphere[(i+1)*rny+j].altitude;
|
||||
wsphere[i*rny+j].altitude += 0.2*wsphere[(i-1)*rny+j].altitude;
|
||||
wsphere[i*rny+j].altitude += 0.2*wsphere[i*rny+j-1].altitude;
|
||||
wsphere[i*rny+j].altitude += 0.2*wsphere[i*rny+j+1].altitude;
|
||||
}
|
||||
|
||||
/* i = 0 */
|
||||
for (j=1; j<rny-1; j++)
|
||||
{
|
||||
height_values[j] *= 0.2;
|
||||
height_values[j] += 0.2*height_values[rny+j];
|
||||
height_values[j] += 0.2*height_values[(rnx-1)*rny+j];
|
||||
height_values[j] += 0.2*height_values[j-1];
|
||||
height_values[j] += 0.2*height_values[j+1];
|
||||
|
||||
wsphere[j].altitude *= 0.2;
|
||||
wsphere[j].altitude += 0.2*wsphere[rny+j].altitude;
|
||||
wsphere[j].altitude += 0.2*wsphere[(rnx-1)*rny+j].altitude;
|
||||
wsphere[j].altitude += 0.2*wsphere[j-1].altitude;
|
||||
wsphere[j].altitude += 0.2*wsphere[j+1].altitude;
|
||||
}
|
||||
|
||||
/* i = rny-1 */
|
||||
for (j=1; j<rny-1; j++)
|
||||
{
|
||||
height_values[(rny-1)*rny+j] *= 0.2;
|
||||
height_values[(rny-1)*rny+j] += 0.2*height_values[j];
|
||||
height_values[(rny-1)*rny+j] += 0.2*height_values[(rny-2)*rny+j];
|
||||
height_values[(rny-1)*rny+j] += 0.2*height_values[(rny-1)*rny+j-1];
|
||||
height_values[(rny-1)*rny+j] += 0.2*height_values[(rny-1)*rny+j+1];
|
||||
|
||||
wsphere[(rny-1)*rny+j].altitude *= 0.2;
|
||||
wsphere[(rny-1)*rny+j].altitude += 0.2*wsphere[j].altitude;
|
||||
wsphere[(rny-1)*rny+j].altitude += 0.2*wsphere[(rny-2)*rny+j].altitude;
|
||||
wsphere[(rny-1)*rny+j].altitude += 0.2*wsphere[(rny-1)*rny+j-1].altitude;
|
||||
wsphere[(rny-1)*rny+j].altitude += 0.2*wsphere[(rny-1)*rny+j+1].altitude;
|
||||
}
|
||||
}
|
||||
|
||||
printf("Closing rgb_values\n");
|
||||
fclose(image_file);
|
||||
free(rgb_values);
|
||||
|
||||
/* smoothen values at low altitude */
|
||||
if (SMOOTH_DEM) for (k=1; k<DEM_SMOOTH_STEPS; k++)
|
||||
{
|
||||
printf("Smoothing step %i\n", k);
|
||||
for (i=1; i<rnx-1; i++)
|
||||
for (j=1; j<rny-1; j++)
|
||||
if ((!wsphere[i*rny+j].indomain)&&(height_values[i*rny+j] <= DEM_SMOOTH_HEIGHT))
|
||||
{
|
||||
height_values_tmp[i*rny+j] = height_values[i*rny+j] + 0.1*(height_values[(i+1)*rny+j] + height_values[(i-1)*rny+j] + height_values[i*rny+j+1] + height_values[i*rny+j-1] - 4.0*height_values[i*rny+j]);
|
||||
|
||||
height_values[i*rny+j] = height_values_tmp[i*rny+j] + 0.1*(height_values_tmp[(i+1)*rny+j] + height_values_tmp[(i-1)*rny+j] + height_values_tmp[i*rny+j+1] + height_values_tmp[i*rny+j-1] - 4.0*height_values_tmp[i*rny+j]);
|
||||
}
|
||||
/* i = 0 */
|
||||
for (j=1; j<rny-1; j++)
|
||||
if ((!wsphere[j].indomain)&&(height_values[j] <= DEM_SMOOTH_HEIGHT))
|
||||
{
|
||||
height_values_tmp[j] = height_values[j] + 0.1*(height_values[rny+j] + height_values[(rnx-1)*rny+j] + height_values[j+1] + height_values[j-1] - 4.0*height_values[j]);
|
||||
|
||||
height_values[j] = height_values_tmp[j] + 0.1*(height_values_tmp[rny+j] + height_values_tmp[(rnx-1)*rny+j] + height_values_tmp[j+1] + height_values_tmp[j-1] - 4.0*height_values_tmp[j]);
|
||||
}
|
||||
/* i = rny-1 */
|
||||
for (j=1; j<rny-1; j++)
|
||||
if ((!wsphere[(rnx-1)*rny+j].indomain)&&(height_values[(rnx-1)*rny+j] <= DEM_SMOOTH_HEIGHT))
|
||||
{
|
||||
height_values_tmp[(rnx-1)*rny+j] = height_values[(rnx-1)*rny+j] + 0.1*(height_values[j] + height_values[(rnx-2)*rny+j] + height_values[(rnx-1)*rny+j+1] + height_values[(rnx-1)*rny+j-1] - 4.0*height_values[(rnx-1)*rny+j]);
|
||||
|
||||
height_values[(rnx-1)*rny+j] = height_values_tmp[(rnx-1)*rny+j] + 0.1*(height_values_tmp[j] + height_values_tmp[(rnx-2)*rny+j] + height_values_tmp[(rnx-1)*rny+j+1] + height_values_tmp[(rnx-1)*rny+j-1] - 4.0*height_values_tmp[(rnx-1)*rny+j]);
|
||||
}
|
||||
}
|
||||
|
||||
if (SMOOTH_DEM) for (i=0; i<rnx; i++)
|
||||
for (j=1; j<rny-1; j++)
|
||||
if ((!wsphere[i*rny+j].indomain)&&(wsphere[i*rny+j].altitude <= DEM_SMOOTH_HEIGHT))
|
||||
{
|
||||
wsphere[i*rny+j].altitude = height_values[i*rny+j];
|
||||
}
|
||||
|
||||
// if ((ADD_NEGATIVE_DEM)&&(dem_number == DEM_EARTH))
|
||||
// read_negative_dem_values(height_values, wsphere);
|
||||
|
||||
/* set radius */
|
||||
for (i=0; i<rnx; i++)
|
||||
for (j=0; j<rny; j++)
|
||||
wsphere[i*rny+j].radius_dem = 1.0 + RSCALE_DEM*(wsphere[i*rny+j].altitude - vshift);
|
||||
|
||||
/* compute light angle */
|
||||
dx = 2.0*(XMAX - XMIN)/(double)rnx;
|
||||
dy = 2.0*(YMAX - YMIN)/(double)rny;
|
||||
vscale1 = 0.1*SHADE_SCALE_2D;
|
||||
vscale2 = vscale1*vscale1;
|
||||
|
||||
if (SHADE_2D)
|
||||
{
|
||||
for (i=1; i<rnx-1; i++)
|
||||
for (j=1; j<rny-1; j++)
|
||||
{
|
||||
gradx = (wsphere[(i+1)*rny+j].radius_dem - wsphere[(i-1)*rny+j].radius_dem)/dx;
|
||||
grady = (wsphere[i*rny+j+1].radius_dem - wsphere[i*rny+j-1].radius_dem)/dy;
|
||||
|
||||
norm = sqrt(vscale2 + gradx*gradx + grady*grady);
|
||||
pscal = -gradx*light[0] - grady*light[1] + vscale1;
|
||||
|
||||
wsphere[i*rny+j].cos_angle = pscal/norm;
|
||||
}
|
||||
/* i = 0 */
|
||||
for (j=1; j<rny-1; j++)
|
||||
{
|
||||
gradx = (wsphere[rny+j].radius_dem - wsphere[(rnx-1)*rny+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;
|
||||
|
||||
wsphere[j].cos_angle = pscal/norm;
|
||||
}
|
||||
/* i = N-1 */
|
||||
for (j=1; j<rny-1; j++)
|
||||
{
|
||||
gradx = (wsphere[j].radius_dem - wsphere[(rnx-2)*rny+j].radius_dem)/dx;
|
||||
grady = (wsphere[(rnx-1)*rny+j+1].radius_dem - wsphere[(rnx-1)*rny+j-1].radius_dem)/dy;
|
||||
|
||||
norm = sqrt(vscale2 + gradx*gradx + grady*grady);
|
||||
pscal = -gradx*light[0] - grady*light[1] + vscale1;
|
||||
|
||||
wsphere[(rnx-1)*rny+j].cos_angle = pscal/norm;
|
||||
}
|
||||
}
|
||||
else if (SHADE_3D)
|
||||
{
|
||||
dphi = DPI/(double)rnx;
|
||||
dtheta = PI/(double)rny;
|
||||
|
||||
for (i=1; i<rnx-1; i++)
|
||||
for (j=1; j<rny-1; j++)
|
||||
{
|
||||
/* computation of tangent vectors */
|
||||
deltar = (wsphere[(i+1)*rny+j].radius_dem - wsphere[i*rny+j].radius_dem)/dphi;
|
||||
|
||||
deltai[0] = -wsphere[i*rny+j].radius_dem*wsphere[i*rny+j].sphi;
|
||||
deltai[0] += deltar*wsphere[i*rny+j].cphi;
|
||||
|
||||
deltai[1] = wsphere[i*rny+j].radius_dem*wsphere[i*rny+j].cphi;
|
||||
deltai[1] += deltar*wsphere[i*rny+j].sphi;
|
||||
|
||||
deltai[2] = -deltar*wsphere[i*rny+j].cottheta;
|
||||
|
||||
deltar = (wsphere[i*rny+j+1].radius_dem - wsphere[i*rny+j].radius_dem)/dtheta;
|
||||
|
||||
deltaj[0] = wsphere[i*rny+j].radius_dem*wsphere[i*rny+j].cphi*wsphere[i*rny+j].ctheta;
|
||||
deltaj[0] += deltar*wsphere[i*rny+j].cphi*wsphere[i*rny+j].stheta;
|
||||
|
||||
deltaj[1] = wsphere[i*rny+j].radius_dem*wsphere[i*rny+j].sphi*wsphere[i*rny+j].ctheta;
|
||||
deltaj[1] += deltar*wsphere[i*rny+j].sphi*wsphere[i*rny+j].stheta;
|
||||
|
||||
deltaj[2] = wsphere[i*rny+j].radius_dem*wsphere[i*rny+j].stheta;
|
||||
deltaj[2] += -deltar*wsphere[i*rny+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];
|
||||
|
||||
wsphere[i*rny+j].cos_angle = pscal/norm;
|
||||
}
|
||||
/* i = 0 */
|
||||
for (j=1; j<rny-1; j++)
|
||||
{
|
||||
/* computation of tangent vectors */
|
||||
deltar = (wsphere[rny+j].radius_dem - wsphere[j].radius_dem)/dphi;
|
||||
|
||||
deltai[0] = -wsphere[j].radius_dem*wsphere[j].sphi;
|
||||
deltai[0] += deltar*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_dem - wsphere[j].radius_dem)/dtheta;
|
||||
|
||||
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_dem*wsphere[j].sphi*wsphere[j].ctheta;
|
||||
deltaj[1] += deltar*wsphere[j].sphi*wsphere[j].stheta;
|
||||
|
||||
deltaj[2] = wsphere[j].radius_dem*wsphere[j].stheta;
|
||||
deltaj[2] += -deltar*wsphere[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];
|
||||
|
||||
wsphere[j].cos_angle = pscal/norm;
|
||||
}
|
||||
/* i = rnx-1 */
|
||||
for (j=1; j<rny-1; j++)
|
||||
{
|
||||
/* computation of tangent vectors */
|
||||
deltar = (wsphere[j].radius_dem - wsphere[(rnx-1)*rny+j].radius_dem)/dphi;
|
||||
|
||||
deltai[0] = -wsphere[(rnx-1)*rny+j].radius_dem*wsphere[(rnx-1)*rny+j].sphi;
|
||||
deltai[0] += deltar*wsphere[(rnx-1)*rny+j].cphi;
|
||||
|
||||
deltai[1] = wsphere[(rnx-1)*rny+j].radius_dem*wsphere[(rnx-1)*rny+j].cphi;
|
||||
deltai[1] += deltar*wsphere[(rnx-1)*rny+j].sphi;
|
||||
|
||||
deltai[2] = -deltar*wsphere[(rnx-1)*rny+j].cottheta;
|
||||
|
||||
deltar = (wsphere[(rnx-1)*rny+j+1].radius_dem - wsphere[(rnx-1)*rny+j].radius_dem)/dtheta;
|
||||
|
||||
deltaj[0] = wsphere[(rnx-1)*rny+j].radius_dem*wsphere[(rnx-1)*rny+j].cphi*wsphere[(rnx-1)*rny+j].ctheta;
|
||||
deltaj[0] += deltar*wsphere[(rnx-1)*rny+j].cphi*wsphere[(rnx-1)*rny+j].stheta;
|
||||
|
||||
deltaj[1] = wsphere[(rnx-1)*rny+j].radius_dem*wsphere[(rnx-1)*rny+j].sphi*wsphere[(rnx-1)*rny+j].ctheta;
|
||||
deltaj[1] += deltar*wsphere[(rnx-1)*rny+j].sphi*wsphere[(rnx-1)*rny+j].stheta;
|
||||
|
||||
deltaj[2] = wsphere[(rnx-1)*rny+j].radius_dem*wsphere[(rnx-1)*rny+j].stheta;
|
||||
deltaj[2] += -deltar*wsphere[(rnx-1)*rny+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];
|
||||
|
||||
wsphere[(rnx-1)*rny+j].cos_angle = pscal/norm;
|
||||
}
|
||||
}
|
||||
|
||||
free(height_values);
|
||||
free(height_values_tmp);
|
||||
}
|
||||
|
||||
void init_earth_map_rde(t_wave_sphere *wsphere, int res)
|
||||
/* init file from earth map */
|
||||
{
|
||||
int i, j, ii, jj, k, nx, ny, maxrgb, nmaxpixels = 4915200, scan, rgbval, diff, sshift, nshift, ishift;
|
||||
int *rgb_values;
|
||||
double cratio, rx, ry, cy, vshift;
|
||||
FILE *image_file;
|
||||
|
||||
printf("Reading Earth map at resolution %i\n", res);
|
||||
|
||||
rgb_values = (int *)malloc(3*nmaxpixels*sizeof(int));
|
||||
|
||||
image_file = fopen("Earth_Map_Blue_Marble_2002_large.ppm", "r");
|
||||
scan = fscanf(image_file,"%i %i\n", &nx, &ny);
|
||||
scan = fscanf(image_file,"%i\n", &maxrgb);
|
||||
|
||||
if (nx*ny > nmaxpixels)
|
||||
{
|
||||
printf("Image too large, increase nmaxpixels in init_earth_map()\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* shift due to min/max latitudes of image */
|
||||
sshift = 0 + DPOLE;
|
||||
nshift = 0 + DPOLE;
|
||||
|
||||
/* choice of zero meridian */
|
||||
ishift = (int)(nx*ZERO_MERIDIAN/360.0);
|
||||
|
||||
/* read rgb values */
|
||||
for (j=0; j<ny; j++)
|
||||
for (i=0; i<nx; i++)
|
||||
for (k=0; k<3; k++)
|
||||
{
|
||||
scan = fscanf(image_file,"%i\n", &rgbval);
|
||||
rgb_values[3*(j*nx+i)+k] = rgbval;
|
||||
}
|
||||
|
||||
cratio = 1.0/(double)maxrgb;
|
||||
rx = (double)nx/(double)(res*NX);
|
||||
ry = (double)ny/(double)(res*NY - sshift - nshift);
|
||||
// cy = rx*(double)(NY - nshift);
|
||||
|
||||
/* build wave table */
|
||||
for (i=0; i<res*NX; i++)
|
||||
for (j=0; j<res*NY; j++)
|
||||
{
|
||||
ii = (int)(rx*(double)(res*NX-1 - i)) + nx/2 + ishift;
|
||||
if (ii > nx-1) ii -= nx;
|
||||
// jj = (int)(-ry*(double)j + cy);
|
||||
// jj = (int)(ry*(double)(NY-nshift - j)) + sshift;
|
||||
jj = (int)(ry*(double)(res*NY-nshift - j));
|
||||
if (jj > ny-1) jj = ny-1;
|
||||
if (jj < 0) jj = 0;
|
||||
wsphere[i*res*NY+j].r = (double)rgb_values[3*(jj*nx+ii)]*cratio;
|
||||
wsphere[i*res*NY+j].g = (double)rgb_values[3*(jj*nx+ii)+1]*cratio;
|
||||
wsphere[i*res*NY+j].b = (double)rgb_values[3*(jj*nx+ii)+2]*cratio;
|
||||
|
||||
// printf("RGB at (%i, %i) = (%.3lg, %3.lg, %.3lg)\n", i, j, wsphere[i*NY+j].r, wsphere[i*NY+j].g, wsphere[i*NY+j].b);
|
||||
|
||||
/* decide which points are in the Sea */
|
||||
diff = iabs(rgb_values[3*(jj*nx+ii)] - 10);
|
||||
diff += iabs(rgb_values[3*(jj*nx+ii)+1] - 10);
|
||||
diff += iabs(rgb_values[3*(jj*nx+ii)+2] - 51);
|
||||
wsphere[i*res*NY+j].indomain = (diff < 15);
|
||||
}
|
||||
|
||||
/* smooth colors in case of high resolution */
|
||||
if ((res*NX > nx)||(res*NY > ny))
|
||||
for (i=1; i<res*NX-1; i++)
|
||||
for (j=1; j<res*NY-1; j++)
|
||||
{
|
||||
wsphere[i*res*NY+j].r *= 0.2;
|
||||
wsphere[i*res*NY+j].r += 0.2*wsphere[(i+1)*res*NY+j].r;
|
||||
wsphere[i*res*NY+j].r += 0.2*wsphere[(i-1)*res*NY+j].r;
|
||||
wsphere[i*res*NY+j].r += 0.2*wsphere[i*res*NY+j-1].r;
|
||||
wsphere[i*res*NY+j].r += 0.2*wsphere[i*res*NY+j+1].r;
|
||||
|
||||
wsphere[i*res*NY+j].g *= 0.2;
|
||||
wsphere[i*res*NY+j].g += 0.2*wsphere[(i+1)*res*NY+j].g;
|
||||
wsphere[i*res*NY+j].g += 0.2*wsphere[(i-1)*res*NY+j].g;
|
||||
wsphere[i*res*NY+j].g += 0.2*wsphere[i*res*NY+j-1].g;
|
||||
wsphere[i*res*NY+j].g += 0.2*wsphere[i*res*NY+j+1].g;
|
||||
|
||||
wsphere[i*res*NY+j].b *= 0.2;
|
||||
wsphere[i*res*NY+j].b += 0.2*wsphere[(i+1)*res*NY+j].b;
|
||||
wsphere[i*res*NY+j].b += 0.2*wsphere[(i-1)*res*NY+j].b;
|
||||
wsphere[i*res*NY+j].b += 0.2*wsphere[i*res*NY+j-1].b;
|
||||
wsphere[i*res*NY+j].b += 0.2*wsphere[i*res*NY+j+1].b;
|
||||
}
|
||||
|
||||
free(rgb_values);
|
||||
fclose(image_file);
|
||||
|
||||
// if (ADD_DEM)
|
||||
init_dem_rde(wsphere, DEM_EARTH, res);
|
||||
|
||||
/* set radius */
|
||||
vshift = PLANET_SEALEVEL/(DEM_MAXHEIGHT - DEM_MAXDEPTH);
|
||||
for (i=0; i<res*NX; i++)
|
||||
for (j=0; j<res*NY; j++)
|
||||
{
|
||||
wsphere[i*res*NY+j].radius_dem = 1.0 + RSCALE_DEM*(wsphere[i*res*NY+j].altitude - vshift);
|
||||
// printf("Radius_dem at (%i,%i) = %.3lg\n", i, j, wsphere[i*NY+j].radius_dem);
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,6 +641,43 @@ int ij_to_sphere(int i, int j, double r, t_wave_sphere wsphere[NX*NY], double xy
|
||||
return(pscal/norm_observer > COS_VISIBLE);
|
||||
}
|
||||
|
||||
int ij_to_sphere_hres(int i, int j, double r, t_wave_sphere wsphere[HRES*HRES*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*HRES*NY+j].x;
|
||||
xyz[1] = wsphere[i*HRES*NY+j].y;
|
||||
xyz[2] = wsphere[i*HRES*NY+j].z;
|
||||
|
||||
pscal = xyz[0]*observer[0] + xyz[1]*observer[1] + xyz[2]*observer[2];
|
||||
|
||||
if (use_wave_radius)
|
||||
{
|
||||
newr = wsphere[i*HRES*NY+j].radius;
|
||||
xyz[0] *= newr;
|
||||
xyz[1] *= newr;
|
||||
xyz[2] *= newr;
|
||||
}
|
||||
else
|
||||
{
|
||||
newr = wsphere[i*HRES*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;
|
||||
@ -165,6 +727,36 @@ void xyz_to_xy(double x, double y, double z, double xy_out[2])
|
||||
}
|
||||
}
|
||||
|
||||
void draw_vertex_in_spherical_coords(double x, double y, double r, int i)
|
||||
{
|
||||
double phi, theta, x1, y1, z1, xy_screen[2];
|
||||
static double phi_ratio, theta_ratio, phi_offset, theta_offset;
|
||||
static int first = 1;
|
||||
|
||||
if (first)
|
||||
{
|
||||
phi_ratio = DPI/(XMAX - XMIN);
|
||||
theta_ratio = PI/(YMAX - YMIN);
|
||||
phi_offset = phi_ratio*XMIN;
|
||||
theta_offset = theta_ratio*YMIN;
|
||||
first = 0;
|
||||
}
|
||||
|
||||
phi = phi_ratio*x - phi_offset;
|
||||
theta = theta_ratio*y - theta_offset;
|
||||
// phi = DPI*(x - XMIN)/(XMAX - XMIN);
|
||||
// theta = PI*(y - YMIN)/(YMAX - YMIN);
|
||||
x1 = r*cos(phi)*sin(theta);
|
||||
y1 = r*sin(phi)*sin(theta);
|
||||
z1 = -r*cos(theta);
|
||||
|
||||
// printf("(phi, theta) = (%.5lg, %.5lg)\n", phi, theta);
|
||||
// printf("(x1, y1, z1) = (%.5lg, %.5lg, %.5lg)\n", x1, y1, z1);
|
||||
|
||||
xyz_to_xy(x1, y1, z1, xy_screen);
|
||||
glVertex2d(xy_screen[0], xy_screen[1]);
|
||||
}
|
||||
|
||||
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 */
|
||||
{
|
||||
@ -1871,6 +2463,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_EULER_DIRECTION):
|
||||
{
|
||||
value = dy_phase*(double)(j);
|
||||
color_scheme_palette(C_ONEDIM_LINEAR, palette, value, 1.0, 1, rgb);
|
||||
break;
|
||||
}
|
||||
case (Z_EULER_DIRECTION_SPEED):
|
||||
{
|
||||
value = 0.5 - 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);
|
||||
|
181
wave_3d.c
181
wave_3d.c
@ -44,7 +44,7 @@
|
||||
#include <time.h>
|
||||
|
||||
#define MOVIE 0 /* set to 1 to generate movie */
|
||||
#define DOUBLE_MOVIE 0 /* set to 1 to produce movies for wave height and energy simultaneously */
|
||||
#define DOUBLE_MOVIE 1 /* set to 1 to produce movies for wave height and energy simultaneously */
|
||||
#define SAVE_MEMORY 1 /* set to 1 to save memory when writing tiff images */
|
||||
#define NO_EXTRA_BUFFER_SWAP 1 /* some OS require one less buffer swap when recording images */
|
||||
|
||||
@ -52,47 +52,23 @@
|
||||
|
||||
#define WINWIDTH 1920 /* window width */
|
||||
#define WINHEIGHT 1150 /* window height */
|
||||
// // #define NX 1920 /* 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 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 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 HIGHRES 0 /* set to 1 if resolution of grid is double that of displayed image */
|
||||
|
||||
// #define WINWIDTH 1280 /* window width */
|
||||
// #define WINHEIGHT 720 /* window height */
|
||||
//
|
||||
// // #define NX 1280 /* number of grid points on x axis */
|
||||
// // #define NX 720 /* number of grid points on x axis */
|
||||
// // #define NY 720 /* number of grid points on y axis */
|
||||
// #define NX 2560 /* number of grid points on x axis */
|
||||
// // #define NX 1440 /* number of grid points on x axis */
|
||||
// #define NY 1440 /* number of grid points on y axis */
|
||||
//
|
||||
// // #define NX 360 /* number of grid points on x axis */
|
||||
// // #define NY 360 /* number of grid points on y axis */
|
||||
//
|
||||
// #define XMIN -2.0
|
||||
// #define XMAX 2.0 /* x interval */
|
||||
// #define YMIN -1.125
|
||||
// #define YMAX 1.125 /* y interval for 9/16 aspect ratio */
|
||||
#define HIGHRES 1 /* set to 1 if resolution of grid is double that of displayed image */
|
||||
|
||||
#define JULIA_SCALE 0.8 /* scaling for Julia sets */
|
||||
|
||||
/* Choice of the billiard table */
|
||||
|
||||
#define B_DOMAIN 17 /* choice of domain shape, see list in global_pdes.c */
|
||||
#define B_DOMAIN 76 /* 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 */
|
||||
|
||||
@ -100,8 +76,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 9 /* 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 181 /* choice of index of refraction, see list in global_pdes.c */
|
||||
#define IOR_TOTAL_TURNS 1.0 /* total angle of rotation for IOR_PERIODIC_WELLS_ROTATING */
|
||||
#define MANDEL_IOR_SCALE -0.05 /* parameter controlling dependence of IoR on Mandelbrot escape speed */
|
||||
|
||||
@ -109,11 +85,11 @@
|
||||
#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 3.0 /* parameter controlling the dimensions of domain */
|
||||
#define MU 0.14 /* parameter controlling the dimensions of domain */
|
||||
#define LAMBDA 1.0 /* parameter controlling the dimensions of domain */
|
||||
#define MU 0.35 /* parameter controlling the dimensions of domain */
|
||||
#define NPOLY 6 /* number of sides of polygon */
|
||||
#define APOLY 0.0 /* angle by which to turn polygon, in units of Pi/2 */
|
||||
#define MDEPTH 2 /* depth of computation of Menger gasket */
|
||||
#define MDEPTH 7 /* depth of computation of Menger gasket */
|
||||
#define MRATIO 3 /* ratio defining Menger gasket */
|
||||
#define MANDELLEVEL 2000 /* iteration level for Mandelbrot set */
|
||||
#define MANDELLIMIT 20.0 /* limit value for approximation of Mandelbrot set */
|
||||
@ -140,17 +116,19 @@
|
||||
/* Physical parameters of wave equation */
|
||||
|
||||
#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_LEFT 0 /* set to 1 to add oscilating boundary condition on the left */
|
||||
#define OSCILLATE_TOPBOT 0 /* set to 1 to enforce a planar wave on top and bottom boundary */
|
||||
#define OSCILLATION_SCHEDULE 3 /* oscillation schedule, see list in global_pdes.c */
|
||||
#define OSCIL_YMAX 0.35 /* defines oscillation range */
|
||||
#define INITIAL_SHIFT 20.0 /* time shift of initial wave packet (in oscillation periods) */
|
||||
#define WAVE_PACKET_SHIFT 200.0 /* time shift between wave packets (in oscillation periods) */
|
||||
|
||||
#define OMEGA 0.015 /* frequency of periodic excitation */
|
||||
#define AMPLITUDE 1.0 /* amplitude of periodic excitation */
|
||||
#define OMEGA 0.025 /* frequency of periodic excitation */
|
||||
#define AMPLITUDE 0.5 /* 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 */
|
||||
#define COURANTB 0.01 /* Courant number in medium B */
|
||||
#define COURANTB 0.08 /* Courant number in medium B */
|
||||
#define GAMMA 0.0 /* damping factor in wave equation */
|
||||
#define GAMMAB 1.0e-6 /* damping factor in wave equation */
|
||||
#define GAMMA_SIDES 1.0e-4 /* damping factor on boundary */
|
||||
@ -164,8 +142,8 @@
|
||||
/* Increasing COURANT speeds up the simulation, but decreases accuracy */
|
||||
/* For similar wave forms, COURANT^2*GAMMA should be kept constant */
|
||||
|
||||
#define ADD_OSCILLATING_SOURCE 0 /* set to 1 to add an oscillating wave source */
|
||||
#define OSCILLATING_SOURCE_PERIOD 30 /* period of oscillating source */
|
||||
#define ADD_OSCILLATING_SOURCE 1 /* set to 1 to add an oscillating wave source */
|
||||
#define OSCILLATING_SOURCE_PERIOD 9 /* 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 */
|
||||
@ -175,17 +153,14 @@
|
||||
|
||||
/* Boundary conditions, see list in global_pdes.c */
|
||||
|
||||
// #define B_COND 1
|
||||
#define B_COND 3
|
||||
#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 1000 /* number of frames of movie */
|
||||
// #define NSTEPS 300 /* number of frames of movie */
|
||||
#define NVID 20 /* number of iterations between images displayed on screen */
|
||||
// #define NVID 10 /* number of iterations between images displayed on screen */
|
||||
#define NSTEPS 1800 /* 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 BOUNDARY_WIDTH 2 /* width of billiard boundary */
|
||||
@ -202,19 +177,18 @@
|
||||
|
||||
/* Parameters 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 */
|
||||
#define INITIAL_AMP 1.0 /* amplitude of initial condition */
|
||||
#define INITIAL_VARIANCE 0.00001 /* variance of initial condition */
|
||||
#define INITIAL_WAVELENGTH 0.025 /* wavelength of initial condition */
|
||||
|
||||
|
||||
/* Plot type, see list in global_pdes.c */
|
||||
|
||||
#define ZPLOT 108 /* wave height */
|
||||
#define CPLOT 108 /* color scheme */
|
||||
#define ZPLOT 103 /* wave height */
|
||||
#define CPLOT 103 /* color scheme */
|
||||
|
||||
#define ZPLOT_B 103
|
||||
#define CPLOT_B 103 /* plot type for second movie */
|
||||
#define ZPLOT_B 108
|
||||
#define CPLOT_B 108 /* 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 */
|
||||
@ -240,12 +214,11 @@
|
||||
|
||||
#define ROTATE_VIEW 0 /* set to 1 to rotate position of observer */
|
||||
#define ROTATE_ANGLE 360.0 /* total angle of rotation during simulation */
|
||||
// #define ROTATE_ANGLE 45.0 /* total angle of rotation during simulation */
|
||||
|
||||
/* Color schemes */
|
||||
|
||||
#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 COLOR_PALETTE 17 /* Color palette, see list in global_pdes.c */
|
||||
#define COLOR_PALETTE_B 14 /* Color palette, see list in global_pdes.c */
|
||||
|
||||
#define BLACK 1 /* background */
|
||||
|
||||
@ -254,11 +227,11 @@
|
||||
#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 1.5 /* additional scaling factor for color scheme P_3D_ENERGY */
|
||||
#define VSCALE_ENERGY 3.0 /* additional scaling factor for color scheme P_3D_ENERGY */
|
||||
#define PHASE_FACTOR 20.0 /* factor in computation of phase in color scheme P_3D_PHASE */
|
||||
#define PHASE_SHIFT 0.0 /* shift of phase in color scheme P_3D_PHASE */
|
||||
#define ATTENUATION 0.0 /* exponential attenuation coefficient of contrast with time */
|
||||
#define E_SCALE 50.0 /* scaling factor for energy representation */
|
||||
#define E_SCALE 100.0 /* scaling factor for energy representation */
|
||||
#define LOG_SCALE 0.75 /* scaling factor for energy log representation */
|
||||
#define LOG_SHIFT 0.5 /* shift of colors on log scale */
|
||||
#define LOG_ENERGY_FLOOR -10.0 /* floor value for log of (total) energy */
|
||||
@ -290,16 +263,15 @@
|
||||
#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 1.0 /* scale of color scheme bar */
|
||||
#define COLORBAR_RANGE_B 1.5 /* scale of color scheme bar for 2nd part */
|
||||
#define COLORBAR_RANGE 3.0 /* scale of color scheme bar */
|
||||
#define COLORBAR_RANGE_B 2.0 /* scale of color scheme bar for 2nd part */
|
||||
#define ROTATE_COLOR_SCHEME 0 /* set to 1 to draw color scheme horizontally */
|
||||
|
||||
#define SAVE_TIME_SERIES 0 /* set to 1 to save wave time series at a point */
|
||||
|
||||
#define ADD_POTENTIAL 1 /* set to 1 to add potential to z coordinate */
|
||||
// #define POT_MAZE 7
|
||||
#define POTENTIAL 10
|
||||
#define POT_FACT 20.0
|
||||
#define POT_FACT 200.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 */
|
||||
@ -311,6 +283,10 @@
|
||||
#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) */
|
||||
#define HRES 1 /* dummy, only used by rde.c */
|
||||
#define SHADE_2D 0 /* set to 1 to add pseudo-3d shading effect */
|
||||
#define SHADE_SCALE_2D 0.05 /* lower value increases sensitivity of shading */
|
||||
#define N_SOURCES 1 /* number of sources, for option draw_sources */
|
||||
/* end of constants only used by sub_wave and sub_maze */
|
||||
|
||||
|
||||
@ -330,8 +306,8 @@ int reset_view = 0; /* switch to reset 3D view parameters (for option RO
|
||||
#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.1 /* overall x shift for REP_PROJ_3D representation */
|
||||
#define YSHIFT_3D 0.1 /* 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.3 /* overall y shift for REP_PROJ_3D representation */
|
||||
|
||||
|
||||
#include "global_pdes.c" /* constants and global variables */
|
||||
@ -1174,73 +1150,8 @@ void animation()
|
||||
if ((ADD_OSCILLATING_SOURCE)&&(i%OSCILLATING_SOURCE_PERIOD == 1))
|
||||
{
|
||||
if (ALTERNATE_OSCILLATING_SOURCE) sign = -sign;
|
||||
add_circular_wave_mod(sign, -0.5, 0.0, phi, psi, xy_in);
|
||||
|
||||
// phase_shift = 1/30.0;
|
||||
// // phase_shift = 1/60.0;
|
||||
//
|
||||
// if (first_source) for (k=0; k<25; k++)
|
||||
// {
|
||||
// angle = 0.0;
|
||||
// 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 > 0.0) wave_source[k].sign = 1;
|
||||
// // else wave_source[k].sign = -1;
|
||||
// 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;
|
||||
// // phase_shift = 0.02 + 0.08*(double)i/(double)NSTEPS;
|
||||
// // printf("Phase shift = %.3lg\n", phase_shift);
|
||||
//
|
||||
// for (k=0; k<25; k++)
|
||||
// {
|
||||
// // wave_source[k].phase += 0.07;
|
||||
// wave_source[k].phase += phase_shift;
|
||||
// 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_mod((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;
|
||||
// }
|
||||
// }
|
||||
|
||||
// for (j=0; j<NPOLY; j++)
|
||||
// add_circular_wave_mod(sign, lambda1*cos(((double)j+0.5)*angle), lambda1*sin(((double)j+0.5)*angle), phi, psi, xy_in);
|
||||
|
||||
// p = phased_array_schedule(i);
|
||||
// p = 2;
|
||||
// y = -1.0;
|
||||
// sign1 = sign;
|
||||
// printf("p = %i\n", p);
|
||||
// for (k=-8; k<9; k++)
|
||||
// {
|
||||
// x1 = 0.05*((double)source_counter/(double)p + (double)k);
|
||||
// if ((x1 > 0.083333333*XMIN)&&(x1 < 0.083333333*XMAX))
|
||||
// {
|
||||
// add_circular_wave_mod(sign1, x1, y, phi, psi, xy_in);
|
||||
// printf("Adding wave at (%.2lg, %.2lg)\n", x1, y);
|
||||
// }
|
||||
// sign1 = -sign1;
|
||||
// }
|
||||
// source_counter++;
|
||||
// if (p > 0) q = p;
|
||||
// else q = -p;
|
||||
// if (source_counter >= q)
|
||||
// {
|
||||
// source_counter = 0;
|
||||
// sign = -sign;
|
||||
// }
|
||||
add_circular_wave_mod(sign, -1.75, 0.3, phi, psi, xy_in);
|
||||
add_circular_wave_mod(sign, -1.75, -0.3, phi, psi, xy_in);
|
||||
|
||||
}
|
||||
if (PRINT_SPEED) print_speed_3d(speed, 0, 1.0);
|
||||
|
149
wave_billiard.c
149
wave_billiard.c
@ -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 17 /* choice of index of refraction, see list in global_pdes.c */
|
||||
#define IOR 191 /* 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 */
|
||||
|
||||
@ -57,23 +57,26 @@
|
||||
|
||||
#define WINWIDTH 1920 /* window width */
|
||||
#define WINHEIGHT 1150 /* window height */
|
||||
// #define NX 1920 /* number of grid points on x axis */
|
||||
// #define NY 1150 /* number of grid points on y axis */
|
||||
#define NX 3840 /* number of grid points on x axis */
|
||||
#define NY 2300 /* number of grid points on y axis */
|
||||
|
||||
#define XMIN -1.6
|
||||
#define XMAX 2.4 /* x interval */
|
||||
#define XMIN -2.0
|
||||
#define XMAX 2.0 /* x interval */
|
||||
#define YMIN -1.197916667
|
||||
#define YMAX 1.197916667 /* y interval for 9/16 aspect ratio */
|
||||
|
||||
#define HIGHRES 1 /* set to 1 if resolution of grid is double that of displayed image */
|
||||
#define HRES 1 /* dummy, only used by rde.c */
|
||||
|
||||
#define JULIA_SCALE 1.0 /* scaling for Julia sets */
|
||||
|
||||
/* Choice of the billiard table */
|
||||
|
||||
#define B_DOMAIN 75 /* choice of domain shape, see list in global_pdes.c */
|
||||
#define B_DOMAIN 20 /* 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 */
|
||||
#define CIRCLE_PATTERN 1 /* pattern of circles or polygons, see list in global_pdes.c */
|
||||
|
||||
#define COMPARISON 0 /* set to 1 to compare two different patterns (beta) */
|
||||
#define B_DOMAIN_B 20 /* second domain shape, for comparisons */
|
||||
@ -83,9 +86,9 @@
|
||||
#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 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 LAMBDA 0.2 /* parameter controlling the dimensions of domain */
|
||||
#define MU 0.012 /* parameter controlling the dimensions of domain */
|
||||
#define MU_B 1.0 /* parameter controlling the dimensions of domain */
|
||||
#define NPOLY 6 /* number of sides of polygon */
|
||||
#define APOLY -0.666666666666 /* angle by which to turn polygon, in units of Pi/2 */
|
||||
#define MDEPTH 6 /* depth of computation of Menger gasket */
|
||||
@ -93,8 +96,8 @@
|
||||
#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 10 /* number of grid point for grid of disks */
|
||||
#define NGRIDX 24 /* number of grid point for grid of disks */
|
||||
#define NGRIDY 40 /* number of grid point for grid of disks */
|
||||
#define WALL_WIDTH 0.1 /* width of wall separating lenses */
|
||||
|
||||
#define X_SHOOTER -0.2
|
||||
@ -114,17 +117,19 @@
|
||||
/* Physical parameters of wave equation */
|
||||
|
||||
#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_LEFT 0 /* set to 1 to add oscilating boundary condition on the left */
|
||||
#define OSCILLATE_TOPBOT 0 /* set to 1 to enforce a planar wave on top and bottom boundary */
|
||||
#define OSCILLATION_SCHEDULE 0 /* oscillation schedule, see list in global_pdes.c */
|
||||
#define OSCILLATION_SCHEDULE 61 /* oscillation schedule, see list in global_pdes.c */
|
||||
#define OSCIL_YMAX 0.35 /* defines oscillation range */
|
||||
#define INITIAL_SHIFT 20.0 /* time shift of initial wave packet (in oscillation periods) */
|
||||
#define WAVE_PACKET_SHIFT 200.0 /* time shift between wave packets (in oscillation periods) */
|
||||
|
||||
#define OMEGA 0.015 /* frequency of periodic excitation */
|
||||
#define AMPLITUDE 1.0 /* amplitude of periodic excitation */
|
||||
#define OMEGA 0.025 /* frequency of periodic excitation */
|
||||
#define AMPLITUDE 0.5 /* amplitude of periodic excitation */
|
||||
#define ACHIRP 0.25 /* acceleration coefficient in chirp */
|
||||
#define DAMPING 0.0 /* damping of periodic excitation */
|
||||
#define COURANT 0.1 /* Courant number */
|
||||
#define COURANTB 0.03 /* Courant number in medium B */
|
||||
#define COURANT 0.2 /* Courant number */
|
||||
#define COURANTB 0.0 /* Courant number in medium B */
|
||||
#define GAMMA 0.0 /* damping factor in wave equation */
|
||||
#define GAMMAB 0.0 /* damping factor in wave equation */
|
||||
#define GAMMA_SIDES 1.0e-4 /* damping factor on boundary */
|
||||
@ -132,15 +137,16 @@
|
||||
#define KAPPA 0.0 /* "elasticity" term enforcing oscillations */
|
||||
#define KAPPA_SIDES 5.0e-4 /* "elasticity" term on absorbing boundary */
|
||||
#define KAPPA_TOPBOT 0.0 /* "elasticity" term on absorbing boundary */
|
||||
#define OSCIL_LEFT_YSHIFT 0.0 /* y-dependence of left oscillation (for non-horizontal waves) */
|
||||
#define OSCIL_LEFT_YSHIFT 40.0 /* y-dependence of left oscillation (for non-horizontal waves) */
|
||||
/* The Courant number is given by c*DT/DX, where DT is the time step and DX the lattice spacing */
|
||||
/* The physical damping coefficient is given by GAMMA/(DT)^2 */
|
||||
/* Increasing COURANT speeds up the simulation, but decreases accuracy */
|
||||
/* For similar wave forms, COURANT^2*GAMMA should be kept constant */
|
||||
|
||||
#define ADD_OSCILLATING_SOURCE 0 /* set to 1 to add an oscillating wave source */
|
||||
#define OSCILLATING_SOURCE_PERIOD 4 /* period of oscillating source */
|
||||
#define ADD_OSCILLATING_SOURCE 1 /* set to 1 to add an oscillating wave source */
|
||||
#define OSCILLATING_SOURCE_PERIOD 8 /* period of oscillating source */
|
||||
#define ALTERNATE_OSCILLATING_SOURCE 1 /* set to 1 to alternate sign of oscillating source */
|
||||
#define N_SOURCES 2 /* number of sources, for option draw_sources */
|
||||
|
||||
#define ADD_WAVE_PACKET_SOURCES 0 /* set to 1 to add several sources emitting wave packets */
|
||||
#define WAVE_PACKET_SOURCE_TYPE 3 /* type of wave packet sources */
|
||||
@ -151,14 +157,14 @@
|
||||
|
||||
/* Boundary conditions, see list in global_pdes.c */
|
||||
|
||||
#define B_COND 3
|
||||
#define B_COND 2
|
||||
|
||||
/* Parameters for length and speed of simulation */
|
||||
|
||||
#define NSTEPS 2200 /* number of frames of movie */
|
||||
#define NVID 15 /* number of iterations between images displayed on screen */
|
||||
#define NSTEPS 1600 /* number of frames of movie */
|
||||
#define NVID 8 /* number of iterations between images displayed on screen */
|
||||
#define NSEG 1000 /* number of segments of boundary */
|
||||
#define INITIAL_TIME 50 /* time after which to start saving frames */
|
||||
#define INITIAL_TIME 0 /* 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) */
|
||||
@ -173,8 +179,8 @@
|
||||
|
||||
/* Parameters of initial condition */
|
||||
|
||||
#define INITIAL_AMP 0.75 /* amplitude of initial condition */
|
||||
#define INITIAL_VARIANCE 0.01 /* variance of initial condition */
|
||||
#define INITIAL_AMP 1.5 /* amplitude of initial condition */
|
||||
#define INITIAL_VARIANCE 0.00001 /* variance of initial condition */
|
||||
#define INITIAL_WAVELENGTH 0.025 /* wavelength of initial condition */
|
||||
|
||||
/* Plot type, see list in global_pdes.c */
|
||||
@ -185,8 +191,8 @@
|
||||
|
||||
/* Color schemes */
|
||||
|
||||
#define COLOR_PALETTE 17 /* Color palette, see list in global_pdes.c */
|
||||
#define COLOR_PALETTE_B 13 /* Color palette, see list in global_pdes.c */
|
||||
#define COLOR_PALETTE 11 /* Color palette, see list in global_pdes.c */
|
||||
#define COLOR_PALETTE_B 14 /* Color palette, see list in global_pdes.c */
|
||||
|
||||
#define BLACK 1 /* background */
|
||||
|
||||
@ -197,12 +203,15 @@
|
||||
#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 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 E_SCALE 55.0 /* scaling factor for energy representation */
|
||||
#define LOG_SCALE 1.0 /* scaling factor for energy log representation */
|
||||
#define LOG_SHIFT 0.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 FADE_IN_OBSTACLE 0 /* set to 1 to fade color inside obstacles */
|
||||
#define SHADE_2D 1 /* set to 1 to add pseudo-3d shading effect */
|
||||
#define SHADE_SCALE_2D 0.05 /* lower value increases sensitivity of shading */
|
||||
|
||||
#define 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 */
|
||||
@ -212,23 +221,23 @@
|
||||
#define HUEAMP -180.0 /* amplitude of variation of hue for color scheme C_HUE */
|
||||
|
||||
#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 COLORBAR_RANGE 2.0 /* scale of color scheme bar */
|
||||
#define COLORBAR_RANGE_B 0.8 /* 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_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 WAVE_PROFILE_X 1.9 /* value of x to sample wave profile */
|
||||
#define WAVE_PROFILE_Y 0.075 /* 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 DRAW_WAVE_SOURCE 1 /* set to 1 to draw source of wave at (wave_source_x, wave_source_y), set to 2 to also draw focus */
|
||||
|
||||
#define MESSAGE_LDASH 14 /* length of dash for Morse code message */
|
||||
#define MESSAGE_LDOT 8 /* length of dot for Morse code message */
|
||||
@ -257,6 +266,8 @@
|
||||
#define MEAN_FLUX (PLOT == P_TOTAL_ENERGY_FLUX)||(PLOT_B == P_TOTAL_ENERGY_FLUX)
|
||||
#define REFRESH_IOR ((IOR == IOR_PERIODIC_WELLS_ROTATING)||(IOR == IOR_PERIODIC_WELLS_ROTATING_LARGE))
|
||||
|
||||
double light[2] = {0.40824829, 0.816496581}; /* location of light source for SHADE_2D option*/
|
||||
|
||||
#include "global_pdes.c" /* constants and global variables */
|
||||
#include "sub_maze.c" /* support for generating mazes */
|
||||
#include "sub_wave.c" /* common functions for wave_billiard, heat and schrodinger */
|
||||
@ -264,8 +275,6 @@
|
||||
|
||||
FILE *time_series_left, *time_series_right;
|
||||
|
||||
double courant2, courantb2; /* Courant parameters squared */
|
||||
|
||||
/*********************/
|
||||
/* animation part */
|
||||
/*********************/
|
||||
@ -296,22 +305,11 @@ void evolve_wave_half(double *phi_in[NX], double *psi_in[NX], double *phi_out[NX
|
||||
for (j=0; j<NY; j++){
|
||||
if (xy_in[i][j] != 0)
|
||||
{
|
||||
tc[i][j] = COURANT;
|
||||
if (!VARIABLE_IOR)
|
||||
{
|
||||
tcc[i][j] = courant2;
|
||||
if (xy_in[i][j] == 1) tgamma[i][j] = GAMMA;
|
||||
else tgamma[i][j] = GAMMAB;
|
||||
}
|
||||
tc[i][j] = sqrt(tcc[i][j]);
|
||||
}
|
||||
else if (TWOSPEEDS)
|
||||
{
|
||||
tc[i][j] = COURANTB;
|
||||
if (!VARIABLE_IOR)
|
||||
{
|
||||
tcc[i][j] = courantb2;
|
||||
tgamma[i][j] = GAMMAB;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -590,8 +588,8 @@ 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, 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];
|
||||
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 = 1.0, ior_angle = 0.0, omega, phase_shift, vshift, dsource, finv;
|
||||
double *phi[NX], *psi[NX], *tmp[NX], *total_energy[NX], *average_energy[NX], *color_scale[NX], *total_flux, *tcc_table[NX], *tgamma_table[NX], *fade_table;
|
||||
short int *xy_in[NX];
|
||||
int i, j, k, s, sample_left[2], sample_right[2], period = 0, fade, source_counter = 0, p, q, first_source = 1, imin, imax, ij[2];
|
||||
// static int image_counter = 0;
|
||||
@ -620,6 +618,8 @@ void animation()
|
||||
tgamma_table[i] = (double *)malloc(NX*sizeof(double));
|
||||
}
|
||||
|
||||
if (FADE_IN_OBSTACLE) fade_table = (double *)malloc(NX*NY*sizeof(double));
|
||||
|
||||
if (MEAN_FLUX) total_flux = (double *)malloc(4*NX*NY*sizeof(double));
|
||||
|
||||
if (ADD_WAVE_PACKET_SOURCES)
|
||||
@ -706,8 +706,8 @@ void animation()
|
||||
|
||||
init_wave_flat(phi, psi, xy_in);
|
||||
|
||||
// if (VARIABLE_IOR)
|
||||
init_ior_2d(xy_in, tcc_table, tgamma_table, ior_angle);
|
||||
if (FADE_IN_OBSTACLE) init_fade_table(tcc_table, fade_table);
|
||||
|
||||
// init_circular_wave(-1.5, 0.0, phi, psi, xy_in);
|
||||
// x = XMIN + (XMAX - XMIN)*rand()/RAND_MAX;
|
||||
@ -760,7 +760,7 @@ 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, average_energy, total_flux, xy_in, 1.0, 0, PLOT, COLOR_PALETTE, 1, 0, 1.0);
|
||||
if (HIGHRES) draw_wave_highres_palette(2, phi, psi, total_energy, average_energy, fade_table, 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);
|
||||
@ -797,7 +797,7 @@ 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, average_energy, total_flux, xy_in, scale, i, PLOT, COLOR_PALETTE, 0, 0, 1.0);
|
||||
if (HIGHRES) draw_wave_highres_palette(2, phi, psi, total_energy, average_energy, fade_table, 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++)
|
||||
{
|
||||
@ -819,26 +819,19 @@ void animation()
|
||||
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)
|
||||
wave_source_x[0] = -1.6;
|
||||
wave_source_y[0] = 0.5;
|
||||
wave_source_x[1] = -1.6;
|
||||
wave_source_y[1] = -0.5;
|
||||
if ((ADD_OSCILLATING_SOURCE)&&(i%OSCILLATING_SOURCE_PERIOD == 1))
|
||||
{
|
||||
if (ALTERNATE_OSCILLATING_SOURCE) sign = -sign;
|
||||
|
||||
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 (input_signal[i])
|
||||
// {
|
||||
// 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);
|
||||
// }
|
||||
// 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);
|
||||
// }
|
||||
add_circular_wave(sign*INITIAL_AMP, wave_source_x[0], wave_source_y[0], phi, psi, xy_in);
|
||||
}
|
||||
if ((ADD_OSCILLATING_SOURCE)&&(i%(OSCILLATING_SOURCE_PERIOD/3) == 1))
|
||||
{
|
||||
if (ALTERNATE_OSCILLATING_SOURCE) sign1 = -sign1;
|
||||
add_circular_wave(sign1*INITIAL_AMP/sqrt(3.0), wave_source_x[1], wave_source_y[1], phi, psi, xy_in);
|
||||
}
|
||||
|
||||
if (ADD_WAVE_PACKET_SOURCES) add_wave_packets(phi, psi, xy_in, packet, i, WAVE_PACKET_RADIUS, 1, 4, 1);
|
||||
@ -869,7 +862,7 @@ void animation()
|
||||
{
|
||||
// draw_wave(phi, psi, xy_in, scale, i, PLOT_B);
|
||||
if (HIGHRES)
|
||||
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);
|
||||
draw_wave_highres_palette(2, phi, psi, total_energy, average_energy, fade_table, 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);
|
||||
@ -900,7 +893,7 @@ 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, average_energy, total_flux, xy_in, scale, NSTEPS, PLOT, COLOR_PALETTE, 0, 0, 1.0);
|
||||
if (HIGHRES) draw_wave_highres_palette(2, phi, psi, total_energy, average_energy, fade_table, 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);
|
||||
@ -913,7 +906,7 @@ void animation()
|
||||
{
|
||||
fade_value = 1.0 - (double)i/(double)MID_FRAMES;
|
||||
if (HIGHRES)
|
||||
draw_wave_highres_palette(2, phi, psi, total_energy, average_energy, total_flux, xy_in, scale, NSTEPS, PLOT, COLOR_PALETTE, 0, 1, fade_value);
|
||||
draw_wave_highres_palette(2, phi, psi, total_energy, average_energy, fade_table, 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);
|
||||
@ -926,7 +919,7 @@ void animation()
|
||||
{
|
||||
// draw_wave(phi, psi, xy_in, scale, i, PLOT_B);
|
||||
if (HIGHRES)
|
||||
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);
|
||||
draw_wave_highres_palette(2, phi, psi, total_energy, average_energy, fade_table, 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);
|
||||
@ -939,7 +932,7 @@ void animation()
|
||||
{
|
||||
fade_value = 1.0 - (double)i/(double)END_FRAMES;
|
||||
if (HIGHRES)
|
||||
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);
|
||||
draw_wave_highres_palette(2, phi, psi, total_energy, average_energy, fade_table, 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);
|
||||
@ -965,6 +958,8 @@ void animation()
|
||||
free(tgamma_table[i]);
|
||||
}
|
||||
|
||||
if (FADE_IN_OBSTACLE) free(fade_table);
|
||||
|
||||
if (MEAN_FLUX) free(total_flux);
|
||||
|
||||
if (ADD_WAVE_PACKET_SOURCES) free(packet);
|
||||
|
105
wave_common.c
105
wave_common.c
@ -1194,7 +1194,7 @@ void draw_wave_profile_horizontal(double *values, int size, int average, int pnb
|
||||
first = 0;
|
||||
}
|
||||
|
||||
if (average)
|
||||
if ((average)&&(!fade))
|
||||
{
|
||||
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];
|
||||
@ -1202,7 +1202,7 @@ void draw_wave_profile_horizontal(double *values, int size, int average, int pnb
|
||||
if (average_vals[i] > vmax[pnb]) vmax[pnb] = average_vals[i];
|
||||
|
||||
}
|
||||
else
|
||||
else /*if (!fade)*/
|
||||
{
|
||||
for (i=imin; i<imax; i+=size)
|
||||
{
|
||||
@ -1245,9 +1245,12 @@ void draw_wave_profile_horizontal(double *values, int size, int average, int pnb
|
||||
glVertex2i(imin, jmax);
|
||||
glEnd();
|
||||
|
||||
/* slightly decrease extramal values in case signal gets weaker */
|
||||
/* slightly decrease extremal values in case signal gets weaker */
|
||||
if (!fade)
|
||||
{
|
||||
vmax[pnb] *= 0.99;
|
||||
vmin[pnb] *= 0.99;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1283,7 +1286,16 @@ void draw_wave_profile_vertical(double *values, int size, int average, int pnb,
|
||||
first = 0;
|
||||
}
|
||||
|
||||
if (average)
|
||||
if (DRAW_WAVE_SOURCE == 2)
|
||||
{
|
||||
xy_to_ij(focus_x, 0.0, ij);
|
||||
if (ij[0] < 0) ij[0] = 0;
|
||||
if (ij[0] > NX-1) ij[0] = NX-1;
|
||||
ival = ij[0];
|
||||
ival -= (ival%size);
|
||||
}
|
||||
|
||||
if ((average)&&(!fade))
|
||||
{
|
||||
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];
|
||||
@ -1291,7 +1303,9 @@ void draw_wave_profile_vertical(double *values, int size, int average, int pnb,
|
||||
if (average_vals[j] > vmax[pnb]) vmax[pnb] = average_vals[j];
|
||||
|
||||
}
|
||||
else
|
||||
|
||||
|
||||
else if (!fade)
|
||||
{
|
||||
for (j=jmin; j<jmax; j+=size)
|
||||
{
|
||||
@ -1313,6 +1327,12 @@ void draw_wave_profile_vertical(double *values, int size, int average, int pnb,
|
||||
|
||||
// printf("vmin = %.3lg, vmax = %.3lg\n", vmin[pnb], vmax[pnb]);
|
||||
|
||||
// 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];
|
||||
// }
|
||||
|
||||
deltav = vmax[pnb]-vmin[pnb];
|
||||
if (deltav <= 0.0) deltav = 0.01;
|
||||
a = deltai/deltav;
|
||||
@ -1340,8 +1360,11 @@ void draw_wave_profile_vertical(double *values, int size, int average, int pnb,
|
||||
glEnd();
|
||||
|
||||
/* slightly decrease extramal values in case signal gets weaker */
|
||||
if (!fade)
|
||||
{
|
||||
vmax[pnb] *= 0.99;
|
||||
vmin[pnb] *= 0.99;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1692,16 +1715,56 @@ void draw_wave_timeseries_old(double *values, int size, int fade, double fade_va
|
||||
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)
|
||||
|
||||
void init_fade_table(double *tcc_table[NX], double *fade_table)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
for (i=0; i<NX; i++)
|
||||
for (j=0; j<NY; j++)
|
||||
fade_table[i*NY + j] = tcc_table[i][j]/courant2;
|
||||
}
|
||||
|
||||
void draw_wave_highres_palette(int size, double *phi[NX], double *psi[NX], double *total_energy[NX], double *average_energy[NX], double *fade_table, 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;
|
||||
double value, rgb[3], xy[2], x1, y1, x2, y2, velocity, energy, gradientx2, gradienty2, arg, mod, flux_factor, gx, gy, mgx, mgy;
|
||||
double value, rgb[3], xy[2], x1, y1, x2, y2, velocity, energy, gradientx, gradienty, arg, mod, flux_factor, gx, gy, mgx, mgy, factor, norm, pscal, ca, vscale2;
|
||||
// double vmin, vmax, deltav;
|
||||
static double dtinverse = ((double)NX)/(COURANT*(XMAX-XMIN)), dx = (XMAX-XMIN)/((double)NX);
|
||||
double *values;
|
||||
double *values, *shade, *rgbvals;
|
||||
|
||||
if ((DRAW_WAVE_PROFILE)||(DRAW_WAVE_TIMESERIES)) values = (double *)malloc(NX*NY*sizeof(double));
|
||||
values = (double *)malloc(NX*NY*sizeof(double));
|
||||
rgbvals = (double *)malloc(3*NX*NY*sizeof(double));
|
||||
#pragma omp parallel for private(i,j,rgb)
|
||||
for (i=0; i<NX; i+=size)
|
||||
for (j=0; j<NY; j+=size)
|
||||
{
|
||||
values[i*NY+j] = wave_value(i, j, phi, psi, total_energy, average_energy, total_flux, xy_in, scale, time, plot, palette, rgb);
|
||||
rgbvals[i*NY+j] = rgb[0];
|
||||
rgbvals[NX*NY+i*NY+j] = rgb[1];
|
||||
rgbvals[2*NX*NY+i*NY+j] = rgb[2];
|
||||
}
|
||||
|
||||
if (SHADE_2D)
|
||||
{
|
||||
vscale2 = SHADE_SCALE_2D*SHADE_SCALE_2D;
|
||||
shade = (double *)malloc(NX*NY*sizeof(double));
|
||||
#pragma omp parallel for private(i,j,gradientx,gradienty,norm,pscal,ca)
|
||||
for (i=0; i<NX-size; i+=size)
|
||||
{
|
||||
for (j=0; j<NY-size; j+=size)
|
||||
{
|
||||
gradientx = values[(i+1)*NY+j] - values[i*NY+j];
|
||||
gradienty = values[i*NY+j+1] - values[i*NY+j];
|
||||
norm = sqrt(vscale2 + gradientx*gradientx + gradienty*gradienty);
|
||||
pscal = -gradientx*light[0] - gradienty*light[1] + SHADE_SCALE_2D;
|
||||
ca = pscal/norm;
|
||||
ca = (ca + 1.0)*0.4 + 0.2;
|
||||
for (k=0; k<3; k++) rgbvals[k*NX*NY+i*NY+j] *= ca;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
@ -1712,12 +1775,18 @@ 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, average_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;
|
||||
// if ((DRAW_WAVE_PROFILE)||(DRAW_WAVE_TIMESERIES)) values[i*NY+j] = value;
|
||||
// rgb[0] = r[i*NY+j];
|
||||
// rgb[1] = g[i*NY+j];
|
||||
// rgb[2] = b[i*NY+j];
|
||||
|
||||
if (fade) for (k=0; k<3; k++) rgb[k] *= fade_value;
|
||||
glColor3f(rgb[0], rgb[1], rgb[2]);
|
||||
if (FADE_IN_OBSTACLE)
|
||||
for (k=0; k<3; k++) rgbvals[k*NX*NY+i*NY+j] *= fade_table[i*NY+j];
|
||||
|
||||
if (fade) for (k=0; k<3; k++) rgbvals[k*NX*NY+i*NY+j] *= fade_value;
|
||||
glColor3f(rgbvals[i*NY+j], rgbvals[NX*NY+i*NY+j], rgbvals[2*NX*NY+i*NY+j]);
|
||||
|
||||
glVertex2i(i, j);
|
||||
glVertex2i(i+size, j);
|
||||
@ -1732,13 +1801,17 @@ void draw_wave_highres_palette(int size, double *phi[NX], double *psi[NX], doubl
|
||||
|
||||
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)
|
||||
if (SHADE_2D) free(shade);
|
||||
if (DRAW_WAVE_SOURCE >= 1)
|
||||
{
|
||||
glColor3f(0.0, 0.0, 0.0);
|
||||
draw_circle(wave_source_x, wave_source_y, 0.005, 100);
|
||||
for (k=0; k<N_SOURCES; k++) draw_circle(wave_source_x[k], wave_source_y[k], 0.005, 100);
|
||||
if (DRAW_WAVE_SOURCE >= 2)
|
||||
draw_circle(focus_x, 0.0, 0.005, 100);
|
||||
}
|
||||
|
||||
free(values);
|
||||
free(rgbvals);
|
||||
}
|
||||
|
||||
/* modified function for "flattened" wave tables */
|
||||
|
@ -270,6 +270,14 @@
|
||||
#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) */
|
||||
#define HRES 1 /* dummy, only used by rde.c */
|
||||
#define INITIAL_SHIFT 20.0 /* time shift of initial wave packet (in oscillation periods) */
|
||||
#define WAVE_PACKET_SHIFT 200.0 /* time shift between wave packets (in oscillation periods) */
|
||||
#define FADE_IN_OBSTACLE 0 /* set to 1 to fade color inside obstacles */
|
||||
#define SHADE_2D 0 /* set to 1 to add pseudo-3d shading effect */
|
||||
#define SHADE_SCALE_2D 0.05 /* lower value increases sensitivity of shading */
|
||||
#define N_SOURCES 1 /* number of sources, for option draw_sources */
|
||||
double light[2] = {0.40824829, 0.816496581}; /* location of light source for SHADE_2D option*/
|
||||
/* end of constants only used by sub_wave and sub_maze */
|
||||
|
||||
|
||||
|
@ -244,6 +244,14 @@
|
||||
#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) */
|
||||
#define HRES 1 /* dummy, only used by rde.c */
|
||||
#define INITIAL_SHIFT 20.0 /* time shift of initial wave packet (in oscillation periods) */
|
||||
#define WAVE_PACKET_SHIFT 200.0 /* time shift between wave packets (in oscillation periods) */
|
||||
#define FADE_IN_OBSTACLE 0 /* set to 1 to fade color inside obstacles */
|
||||
#define SHADE_2D 0 /* set to 1 to add pseudo-3d shading effect */
|
||||
#define SHADE_SCALE_2D 0.05 /* lower value increases sensitivity of shading */
|
||||
#define N_SOURCES 1 /* number of sources, for option draw_sources */
|
||||
double light[2] = {0.40824829, 0.816496581}; /* location of light source for SHADE_2D option*/
|
||||
/* end of constants only used by sub_wave and sub_maze */
|
||||
|
||||
#include "global_pdes.c" /* constants and global variables */
|
||||
|
@ -320,6 +320,11 @@
|
||||
#define ADD_POTENTIAL 0 /* set to 1 to add potential to z coordinate */
|
||||
#define POTENTIAL 10
|
||||
#define POT_FACT 20.0
|
||||
#define HRES 1 /* dummy, only used by rde.c */
|
||||
#define INITIAL_SHIFT 20.0 /* time shift of initial wave packet (in oscillation periods) */
|
||||
#define WAVE_PACKET_SHIFT 200.0 /* time shift between wave packets (in oscillation periods) */
|
||||
#define FADE_IN_OBSTACLE 0 /* set to 1 to fade color inside obstacles */
|
||||
#define N_SOURCES 1 /* number of sources, for option draw_sources */
|
||||
/* end of constants only used by sub_wave and sub_maze */
|
||||
|
||||
/* For debugging purposes only */
|
||||
|
Loading…
Reference in New Issue
Block a user