Add files via upload

This commit is contained in:
Nils Berglund
2023-01-22 16:49:04 +01:00
committed by GitHub
parent 59cc5fbcf3
commit e3a7a58057
21 changed files with 7632 additions and 620 deletions

View File

@@ -37,12 +37,16 @@
#include <time.h>
#define MOVIE 0 /* set to 1 to generate movie */
#define DOUBLE_MOVIE 1 /* set to 1 to produce movies for wave height and energy simultaneously */
#define DOUBLE_MOVIE 0 /* set to 1 to produce movies for wave height and energy simultaneously */
#define SAVE_MEMORY 1 /* set to 1 to save memory while saving frames */
#define NO_EXTRA_BUFFER_SWAP 0 /* some OS require one less buffer swap when recording images */
#define TIME_LAPSE 0 /* set to 1 to add a time-lapse movie at the end */
#define TIME_LAPSE 1 /* set to 1 to add a time-lapse movie at the end */
/* so far incompatible with double movie */
#define TIME_LAPSE_FACTOR 3 /* factor of time-lapse movie */
#define TIME_LAPSE_FIRST 0 /* set to 1 to show time-lapse version first */
#define TIME_LAPSE_FIRST 1 /* set to 1 to show time-lapse version first */
#define SAVE_TIME_SERIES 0 /* set to 1 to save time series of particle positions */
/* General geometrical parameters */
@@ -54,10 +58,10 @@
#define YMIN -1.125
#define YMAX 1.125 /* y interval for 9/16 aspect ratio */
#define INITXMIN -1.95
#define INITXMAX 1.95 /* x interval for initial condition */
#define INITYMIN -1.1
#define INITYMAX 0.15 /* y interval for initial condition */
#define INITXMIN -1.92
#define INITXMAX 1.92 /* x interval for initial condition */
#define INITYMIN -1.05
#define INITYMAX 1.05 /* y interval for initial condition */
#define BCXMIN -2.0
#define BCXMAX 2.0 /* x interval for boundary condition */
@@ -67,20 +71,20 @@
#define OBSXMIN -2.0
#define OBSXMAX 2.0 /* x interval for motion of obstacle */
#define CIRCLE_PATTERN 8 /* pattern of circles, see list in global_ljones.c */
#define CIRCLE_PATTERN 8 /* pattern of circles, see list in global_ljones.c */
#define ADD_FIXED_OBSTACLES 0 /* set to 1 do add fixed circular obstacles */
#define OBSTACLE_PATTERN 3 /* pattern of obstacles, see list in global_ljones.c */
#define OBSTACLE_PATTERN 181 /* pattern of obstacles, see list in global_ljones.c */
#define ADD_FIXED_SEGMENTS 1 /* set to 1 to add fixed segments as obstacles */
#define SEGMENT_PATTERN 19 /* pattern of repelling segments, see list in global_ljones.c */
#define ADD_FIXED_SEGMENTS 0 /* set to 1 to add fixed segments as obstacles */
#define SEGMENT_PATTERN 181 /* pattern of repelling segments, see list in global_ljones.c */
#define ROCKET_SHAPE 2 /* shape of rocket combustion chamber, see list in global_ljones.c */
#define ROCKET_SHAPE_B 2 /* shape of second rocket */
#define NOZZLE_SHAPE 1 /* shape of nozzle, see list in global_ljones.c */
#define NOZZLE_SHAPE_B 0 /* shape of nozzle for second rocket, see list in global_ljones.c */
#define NOZZLE_SHAPE 2 /* shape of nozzle, see list in global_ljones.c */
#define NOZZLE_SHAPE_B 4 /* shape of nozzle for second rocket, see list in global_ljones.c */
#define TWO_TYPES 0 /* set to 1 to have two types of particles */
#define TPYE_PROPORTION 0.5 /* proportion of particles of first type */
#define TYPE_PROPORTION 0.66 /* proportion of particles of first type */
#define SYMMETRIZE_FORCE 1 /* set to 1 to symmetrize two-particle interaction, only needed if particles are not all the same */
#define CENTER_PX 0 /* set to 1 to center horizontal momentum */
#define CENTER_PY 0 /* set to 1 to center vertical momentum */
@@ -93,16 +97,15 @@
#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 3.0 /* minimal distance in Poisson disc process, controls density of particles */
#define PDISC_DISTANCE 4.7 /* 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.3 /* parameter controlling the dimensions of domain */
#define MU 0.009 /* parameter controlling radius of particles */
#define MU_B 0.018 /* parameter controlling radius of particles of second type */
// #define NPOLY 4 /* number of sides of polygon */
#define NPOLY 3 /* number of sides of polygon */
#define APOLY 1.0 /* angle by which to turn polygon, in units of Pi/2 */
#define LAMBDA 0.8 /* parameter controlling the dimensions of domain */
#define MU 0.008 /* parameter controlling radius of particles */
#define MU_B 0.012 /* parameter controlling radius of particles of second type */
#define NPOLY 25 /* number of sides of polygon */
#define APOLY 0.666666666 /* angle by which to turn polygon, in units of Pi/2 */
#define MDEPTH 4 /* depth of computation of Menger gasket */
#define MRATIO 3 /* ratio defining Menger gasket */
#define MANDELLEVEL 1000 /* iteration level for Mandelbrot set */
@@ -122,11 +125,11 @@
/* Parameters for length and speed of simulation */
#define NSTEPS 1500 /* number of frames of movie */
#define NVID 100 /* number of iterations between images displayed on screen */
#define NSTEPS 1000 /* number of frames of movie */
#define NVID 150 /* number of iterations between images displayed on screen */
#define NSEG 250 /* number of segments of boundary */
#define INITIAL_TIME 250 /* time after which to start saving frames */
#define OBSTACLE_INITIAL_TIME 350 /* time after which to start moving obstacle */
#define INITIAL_TIME 25 /* time after which to start saving frames */
#define OBSTACLE_INITIAL_TIME 200 /* time after which to start moving obstacle */
#define BOUNDARY_WIDTH 1 /* width of particle boundary */
#define LINK_WIDTH 2 /* width of links between particles */
#define CONTAINER_WIDTH 4 /* width of container boundary */
@@ -140,18 +143,18 @@
/* Boundary conditions, see list in global_ljones.c */
#define BOUNDARY_COND 0
#define BOUNDARY_COND 3
/* Plot type, see list in global_ljones.c */
#define PLOT 0
#define PLOT_B 8 /* plot type for second movie */
#define PLOT 5
#define PLOT_B 0 /* plot type for second movie */
#define DRAW_BONDS 0 /* set to 1 to draw bonds between neighbours */
#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 */
#define FILL_TRIANGLES 1 /* set to 1 to fill triangles between neighbours */
#define ALTITUDE_LINES 0 /* set to 1 to add horizontal lines to show altitude */
#define COLOR_SEG_GROUPS 1 /* set to 1 to collor segment groups differently */
#define COLOR_SEG_GROUPS 0 /* set to 1 to collor segment groups differently */
/* Color schemes */
@@ -178,36 +181,40 @@
#define ENERGY_HUE_MAX 50.0 /* color of saturated particle */
#define PARTICLE_HUE_MIN 359.0 /* color of original particle */
#define PARTICLE_HUE_MAX 0.0 /* color of saturated particle */
#define PARTICLE_EMAX 3.0e2 /* energy of particle with hottest color */
#define PARTICLE_EMAX 1.2e3 /* energy of particle with hottest color */
#define HUE_TYPE0 70.0 /* hue of particles of type 0 */
#define HUE_TYPE1 280.0 /* hue of particles of type 1 */
#define HUE_TYPE2 .0 /* hue of particles of type 2 */
#define HUE_TYPE3 210.0 /* hue of particles of type 3 */
#define HUE_TYPE1 150.0 /* hue of particles of type 1 */
#define HUE_TYPE2 190.0 /* hue of particles of type 2 */
#define HUE_TYPE3 220.0 /* hue of particles of type 3 */
// #define HUE_TYPE1 310.0 /* hue of particles of type 1 */
// #define HUE_TYPE2 150.0 /* hue of particles of type 2 */
// #define HUE_TYPE3 180.0 /* hue of particles of type 3 */
#define RANDOM_RADIUS 0 /* set to 1 for random circle radius */
#define DT_PARTICLE 3.0e-6 /* time step for particle displacement */
#define KREPEL 12.0 /* constant in repelling force between particles */
#define EQUILIBRIUM_DIST 4.0 /* Lennard-Jones equilibrium distance */
#define EQUILIBRIUM_DIST 3.5 /* Lennard-Jones equilibrium distance */
#define EQUILIBRIUM_DIST_B 3.5 /* Lennard-Jones equilibrium distance for second type of particle */
#define REPEL_RADIUS 20.0 /* radius in which repelling force acts (in units of particle radius) */
#define DAMPING 10.0 /* damping coefficient of particles */
#define INITIAL_DAMPING 35.0 /* damping coefficient of particles during initial phase */
#define REPEL_RADIUS 15.0 /* radius in which repelling force acts (in units of particle radius) */
#define DAMPING 0.0 /* damping coefficient of particles */
#define INITIAL_DAMPING 0.0 /* damping coefficient of particles during initial phase */
#define PARTICLE_MASS 1.0 /* mass of particle of radius MU */
#define PARTICLE_MASS_B 1.0 /* mass of particle of radius MU */
#define PARTICLE_INERTIA_MOMENT 0.2 /* moment of inertia of particle */
#define PARTICLE_MASS_B 2.0 /* mass of particle of radius MU */
#define PARTICLE_INERTIA_MOMENT 0.02 /* moment of inertia of particle */
#define PARTICLE_INERTIA_MOMENT_B 0.02 /* moment of inertia of second type of particle */
#define V_INITIAL 0.0 /* initial velocity range */
#define OMEGA_INITIAL 10.0 /* initial angular velocity range */
#define THERMOSTAT 0 /* set to 1 to switch on thermostat */
#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.02 /* initial inverse temperature */
#define BETA 0.01 /* initial inverse temperature */
#define MU_XI 0.01 /* friction constant in thermostat */
#define KSPRING_BOUNDARY 1.0e7 /* confining harmonic potential outside simulation region */
#define KSPRING_OBSTACLE 1.0e11 /* harmonic potential of obstacles */
#define NBH_DIST_FACTOR 7.5 /* radius in which to count neighbours */
#define GRAVITY 1500.0 /* gravity acting on all particles */
#define NBH_DIST_FACTOR 10.0 /* radius in which to count neighbours */
// #define NBH_DIST_FACTOR 7.5 /* radius in which to count neighbours */
#define GRAVITY 0.0 /* gravity acting on all particles */
#define GRAVITY_X 0.0 /* horizontal gravity acting on all particles */
#define INCREASE_GRAVITY 0 /* set to 1 to increase gravity during the simulation */
#define GRAVITY_SCHEDULE 2 /* type of gravity schedule, see list in global_ljones.c */
@@ -215,7 +222,7 @@
#define GRAVITY_INITIAL_TIME 200 /* time at start of simulation with constant gravity */
#define GRAVITY_RESTORE_TIME 700 /* time at end of simulation with gravity restored to initial value */
#define ROTATION 0 /* set to 1 to include rotation of particles */
#define ROTATION 1 /* set to 1 to include rotation of particles */
#define COUPLE_ANGLE_TO_THERMOSTAT 0 /* set to 1 to couple angular degrees of freedom to thermostat */
#define DIMENSION_FACTOR 1.0 /* scaling factor taking into account number of degrees of freedom */
#define KTORQUE 100.0 /* force constant in angular dynamics */
@@ -232,8 +239,8 @@
#define BETA_FACTOR 0.025 /* factor by which to change BETA during simulation */
#define N_TOSCILLATIONS 1.5 /* number of temperature oscillations in BETA schedule */
#define NO_OSCILLATION 1 /* set to 1 to have exponential BETA change only */
#define MIDDLE_CONSTANT_PHASE 1600 /* final phase in which temperature is constant */
#define FINAL_DECREASE_PHASE 1500 /* final phase in which temperature decreases */
#define MIDDLE_CONSTANT_PHASE 2000 /* final phase in which temperature is constant */
#define FINAL_DECREASE_PHASE 1300 /* final phase in which temperature decreases */
#define FINAL_CONSTANT_PHASE -1 /* final phase in which temperature is constant */
#define DECREASE_CONTAINER_SIZE 0 /* set to 1 to decrease size of container */
@@ -271,6 +278,7 @@
#define ADD_PARTICLES 0 /* set to 1 to add particles */
#define ADD_TIME 0 /* time at which to add first particle */
#define ADD_PERIOD 10000 /* time interval between adding further particles */
#define N_ADD_PARTICLES 20 /* number of particles to add */
#define FINAL_NOADD_PERIOD 200 /* final period where no particles are added */
#define SAFETY_FACTOR 2.0 /* no particles are added at distance less than MU*SAFETY_FACTOR of other particles */
@@ -289,40 +297,48 @@
#define OMEGAMAX 100.0 /* maximal rotation speed */
#define PRINT_OMEGA 0 /* set to 1 to print angular speed */
#define PRINT_PARTICLE_SPEEDS 0 /* set to 1 to print average speeds/momenta of particles */
#define PRINT_SEGMENTS_SPEEDS 0 /* set to 1 to print velocity of moving segments */
#define PRINT_SEGMENTS_SPEEDS 1 /* set to 1 to print velocity of moving segments */
#define MOVE_BOUNDARY 0 /* set to 1 to move repelling segments, due to force from particles */
#define SEGMENTS_MASS 40.0 /* mass of collection of segments */
#define DEACTIVATE_SEGMENT 1 /* set to 1 to deactivate last segment after a certain time */
#define SEGMENT_DEACTIVATION_TIME 200 /* time at which to deactivate last segment */
#define RELEASE_ROCKET_AT_DEACTIVATION 1 /* set to 1 to limit segments velocity before segment release */
#define SEGMENTS_X0 1.0 /* initial position of segments */
#define SEGMENTS_Y0 0.8 /* initial position of segments */
#define SEGMENTS_X0 1.5 /* initial position of segments */
#define SEGMENTS_Y0 0.0 /* initial position of segments */
#define SEGMENTS_VX0 0.0 /* initial velocity of segments */
#define SEGMENTS_VY0 0.0 /* initial velocity of segments */
#define DAMP_SEGS_AT_NEGATIVE_Y 0 /* set to 1 to dampen segments when y coordinate is negative */
#define MOVE_SEGMENT_GROUPS 1 /* set to 1 to group segments into moving units */
#define SEGMENT_GROUP_MASS 750.0 /* mass of segment group */
#define SEGMENT_GROUP_I 500.0 /* moment of inertia of segment group */
#define SEGMENT_GROUP_MASS 1000.0 /* mass of segment group */
#define SEGMENT_GROUP_I 1000.0 /* moment of inertia of segment group */
#define SEGMENT_GROUP_DAMPING 0.0 /* damping of segment groups */
#define GROUP_REPULSION 1 /* set to 1 for groups of segments to repel each other */
#define KSPRING_GROUPS 1.0e11 /* harmonic potential between segment groups */
#define GROUP_WIDTH 0.05 /* interaction width of groups */
#define GROUP_G_REPEL 0 /* set to 1 to add repulsion between centers of mass of groups */
#define GROUP_G_REPEL 1 /* set to 1 to add repulsion between centers of mass of groups */
#define GROUP_G_REPEL_RADIUS 1.2 /* radius within which centers of mass of groups repel each other */
#define TRACK_SEGMENT_GROUPS 0 /* set to 1 for view to track group of segments */
#define TRACK_SEGMENT_GROUPS 1 /* set to 1 for view to track group of segments */
#define TRACK_X_PADDING 2.0 /* distance from x boundary where tracking starts */
#define POSITION_DEPENDENT_TYPE 0 /* set to 1 to make particle type depend on initial position */
#define POSITION_Y_DEPENDENCE 0 /* set to 1 for the separation between particles to be horizontal */
#define PRINT_ENTROPY 0 /* set to 1 to compute entropy */
#define REACTION_DIFFUSION 0 /* set to 1 to simulate a chemical reaction (particles may change type) */
#define RD_TYPES 3 /* number of types in reaction-diffusion equation */
#define REACTION_PROB 0.0045 /* probability controlling reaction term */
#define REACTION_DIFFUSION 1 /* set to 1 to simulate a chemical reaction (particles may change type) */
#define RD_REACTION 8 /* type of reaction, see list in global_ljones.c */
#define RD_TYPES 9 /* number of types in reaction-diffusion equation */
#define RD_INITIAL_COND 2 /* initial condition of particles */
#define REACION_DIST 3.5 /* maximal distance for reaction to occur */
#define REACTION_PROB 0.5 /* probability controlling reaction term */
#define DISSOCIATION_PROB 0.005 /* probability controlling dissociation reaction */
#define CENTER_COLLIDED_PARTICLES 0 /* set to 1 to recenter particles upon reaction (may interfere with thermostat) */
#define COLLISION_TIME 25 /* time during which collisions are shown */
#define PRINT_PARTICLE_NUMBER 0 /* set to 1 to print total number of particles */
#define PLOT_PARTICLE_NUMBER 1 /* set to 1 to make of plot of particle number over time */
#define PARTICLE_NB_PLOT_FACTOR 1.0 /* expected final number of particles over initial number */
#define PRINT_LEFT 0 /* set to 1 to print certain parameters at the top left instead of right */
#define PLOT_SPEEDS 0 /* set to 1 to add a plot of obstacle speeds (e.g. for rockets) */
#define PLOT_TRAJECTORIES 0 /* set to 1 to add a plot of obstacle trajectories (e.g. for rockets) */
@@ -345,12 +361,12 @@
#define MAZE_XSHIFT 0.0 /* horizontal shift of maze */
#define FLOOR_FORCE 1 /* set to 1 to limit force on particle to FMAX */
#define FMAX 1.0e12 /* maximal force */
#define FMAX 1.0e10 /* maximal force */
#define FLOOR_OMEGA 0 /* set to 1 to limit particle momentum to PMAX */
#define PMAX 1000.0 /* maximal force */
#define HASHX 120 /* size of hashgrid in x direction */
#define HASHY 60 /* size of hashgrid in y direction */
#define HASHX 90 /* size of hashgrid in x direction */
#define HASHY 45 /* 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 */
@@ -385,6 +401,7 @@ int thermostat_on = 1; /* thermostat switch used when VARY_THERMOSTAT is on *
#include "sub_lj.c"
#include "sub_hashgrid.c"
FILE *lj_time_series, *lj_final_position;
/*********************/
/* animation part */
@@ -1032,12 +1049,14 @@ 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, krepel = KREPEL, pos[2], prop, vx,
beta = BETA, xi = 0.0, xmincontainer = BCXMIN, xmaxcontainer = BCXMAX, torque, torque_ij,
fboundary = 0.0, pleft = 0.0, pright = 0.0, entropy[2], mean_energy, gravity = GRAVITY, speed_ratio;
fboundary = 0.0, pleft = 0.0, pright = 0.0, entropy[2], mean_energy, gravity = GRAVITY, speed_ratio,
ymin, ymax;
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, nactive = 0, nadd_particle = 0, nmove = 0, nsuccess = 0,
tracer_n[N_TRACER_PARTICLES], traj_position = 0, traj_length = 0, move = 0, old, m0, floor, nthermo, wall = 0,
group, gshift;
group, gshift, n_total_active = 0, ncollisions = 0;
int *particle_numbers;
static int imin, imax;
static short int first = 1;
t_particle *particle;
@@ -1046,6 +1065,7 @@ void animation()
t_group_segments *segment_group;
t_tracer *trajectory;
t_group_data *group_speeds;
t_collision *collisions;
t_hashgrid *hashgrid;
char message[100];
@@ -1058,7 +1078,8 @@ void animation()
segment_group = (t_group_segments *)malloc(NMAXGROUPS*sizeof(t_group_segments));
}
if (TRACER_PARTICLE) trajectory = (t_tracer *)malloc(TRAJECTORY_LENGTH*N_TRACER_PARTICLES*sizeof(t_tracer));
if (TRACER_PARTICLE)
trajectory = (t_tracer *)malloc(TRAJECTORY_LENGTH*N_TRACER_PARTICLES*sizeof(t_tracer));
hashgrid = (t_hashgrid *)malloc(HASHX*HASHY*sizeof(t_hashgrid)); /* hashgrid */
@@ -1070,6 +1091,17 @@ void animation()
pangle = (double *)malloc(NMAXCIRCLES*sizeof(double));
pressure = (double *)malloc(N_PRESSURES*sizeof(double));
if (REACTION_DIFFUSION)
{
collisions = (t_collision *)malloc(2*NMAXCIRCLES*sizeof(t_collision));
for (i=0; i<2*NMAXCIRCLES; i++) collisions[i].time = 0;
}
if (SAVE_TIME_SERIES)
{
lj_time_series = fopen("lj_time_series.dat", "w");
lj_final_position = fopen("lj_final_position.dat", "w");
}
/* initialise positions and radii of circles */
init_particle_config(particle);
@@ -1081,7 +1113,7 @@ void animation()
if (ADD_FIXED_OBSTACLES) init_obstacle_config(obstacle);
if (ADD_FIXED_SEGMENTS) init_segment_config(segment);
if (MOVE_SEGMENT_GROUPS)
if ((MOVE_SEGMENT_GROUPS)&&(ADD_FIXED_SEGMENTS))
{
for (i=0; i<ngroups; i++) init_segment_group(segment, i, segment_group);
group_speeds = (t_group_data *)malloc(ngroups*(INITIAL_TIME + NSTEPS)*sizeof(t_group_data));
@@ -1089,6 +1121,9 @@ void animation()
if (RECORD_PRESSURES) for (i=0; i<N_PRESSURES; i++) pressure[i] = 0.0;
if (PLOT_SPEEDS) obstacle_speeds = (double *)malloc(2*ngroups*(INITIAL_TIME + NSTEPS)*sizeof(double));
if (PLOT_PARTICLE_NUMBER)
particle_numbers = (int *)malloc((NSTEPS+1)*(RD_TYPES+1)*sizeof(int));
// printf("1\n");
@@ -1115,7 +1150,7 @@ void animation()
for (i=0; i<=INITIAL_TIME + NSTEPS; i++)
{
printf("Computing frame %d\n",i);
printf("Computing frame %d\n",i);
if (INCREASE_KREPEL) krepel = repel_schedule(i);
if (INCREASE_BETA) beta = temperature_schedule(i);
@@ -1133,7 +1168,21 @@ void animation()
/* deactivate some segments */
if ((ADD_FIXED_SEGMENTS)&&(DEACTIVATE_SEGMENT)&&(i == INITIAL_TIME + SEGMENT_DEACTIVATION_TIME + 1))
for (j=0; j<nsegments; j++) if (segment[j].inactivate) segment[j].active = 0;
/* recolor particles in case if P_INITIAL_POS color code */
if ((i <= INITIAL_TIME-1)&&(i%10 == 0)&&((PLOT == P_INITIAL_POS)||(PLOT_B == P_INITIAL_POS)))
{
printf("Recoloring particles\n");
ymin = particle[0].yc;
ymax = particle[0].yc;
for (j=1; j<ncircles; j++) if (particle[j].active)
{
if (particle[j].yc < ymin) ymin = particle[j].yc;
if (particle[j].yc > ymax) ymax = particle[j].yc;
}
for (j=0; j<ncircles; j++) if (particle[j].active)
particle[j].color_hue = 360.0*(particle[j].yc - ymin)/(ymax - ymin);
}
blank();
fboundary = 0.0;
@@ -1212,6 +1261,18 @@ void animation()
if ((MOVE_SEGMENT_GROUPS)&&(i > OBSTACLE_INITIAL_TIME)) evolve_segment_groups(segment, i, segment_group);
} /* end of for (n=0; n<NVID; n++) */
if ((i>INITIAL_TIME)&&(SAVE_TIME_SERIES))
{
n_total_active = 0;
for (j=0; j<ncircles; j++) if (particle[j].active) n_total_active++;
fprintf(lj_time_series, "%i\n", n_total_active);
for (j=0; j<ncircles; j++) if (particle[j].active)
{
fprintf(lj_time_series, "%.4f\n", particle[j].xc);
fprintf(lj_time_series, "%.4f\n", particle[j].yc);
}
}
// printf("evolved particles\n");
@@ -1299,24 +1360,46 @@ void animation()
// printf("Min number of neighbours: %i\n", min_nb);
// printf("Max number of neighbours: %i\n", max_nb);
blank();
/* case of reaction-diffusion equation */
if ((i > INITIAL_TIME)&&(REACTION_DIFFUSION))
{
ncollisions = update_types(particle, collisions, ncollisions);
nactive = 0;
for (j=0; j<ncircles; j++) if (particle[j].active)
{
nactive++;
qx[j] = particle[j].xc;
qy[j] = particle[j].yc;
px[j] = particle[j].vx;
py[j] = particle[j].vy;
}
// draw_collisions(collisions, ncollisions);
}
if (TRACER_PARTICLE) draw_trajectory(trajectory, traj_position, traj_length);
draw_particles(particle, PLOT, beta);
draw_particles(particle, PLOT, beta, collisions, ncollisions);
draw_container(xmincontainer, xmaxcontainer, obstacle, segment, wall);
/* add a particle */
if ((ADD_PARTICLES)&&(i > ADD_TIME)&&((i - INITIAL_TIME - ADD_TIME)%ADD_PERIOD == 1)&&(i < NSTEPS - FINAL_NOADD_PERIOD))
{
for (k=0; k<N_ADD_PARTICLES; k++)
nadd_particle = add_particles(particle, px, py, nadd_particle);
}
/* case of reaction-diffusion equation */
if (REACTION_DIFFUSION) update_types(particle);
update_hashgrid(particle, hashgrid, 1);
print_parameters(beta, mean_energy, krepel, xmaxcontainer - xmincontainer,
fboundary/(double)(ncircles*NVID), PRINT_LEFT, pressure, gravity);
if ((BOUNDARY_COND == BC_EHRENFEST)||(BOUNDARY_COND == BC_RECTANGLE_WALL))
print_ehrenfest_parameters(particle, pleft, pright);
else if (PRINT_PARTICLE_NUMBER) print_particle_number(ncircles);
else if (PRINT_PARTICLE_NUMBER)
{
if (REACTION_DIFFUSION)
print_particle_types_number(particle, RD_TYPES);
else print_particle_number(ncircles);
}
if ((i > INITIAL_TIME + WALL_TIME)&&(PRINT_ENTROPY))
{
@@ -1335,8 +1418,13 @@ void animation()
if (MOVE_BOUNDARY) print_segments_speeds(vxsegments, vysegments);
else print_segment_group_speeds(segment_group);
}
if ((i > INITIAL_TIME)&&(PLOT_PARTICLE_NUMBER))
{
count_particle_number(particle, particle_numbers, i - INITIAL_TIME);
draw_particle_nb_plot(particle_numbers, i - INITIAL_TIME);
}
glutSwapBuffers();
if (!((NO_EXTRA_BUFFER_SWAP)&&(MOVIE))) glutSwapBuffers();
if (MOVIE)
{
@@ -1365,14 +1453,19 @@ void animation()
if ((i >= INITIAL_TIME)&&(DOUBLE_MOVIE))
{
if (TRACER_PARTICLE) draw_trajectory(trajectory, traj_position, traj_length);
draw_particles(particle, PLOT_B, beta);
draw_particles(particle, PLOT_B, beta, collisions, ncollisions);
draw_container(xmincontainer, xmaxcontainer, obstacle, segment, wall);
print_parameters(beta, mean_energy, krepel, xmaxcontainer - xmincontainer,
fboundary/(double)(ncircles*NVID), PRINT_LEFT, pressure, gravity);
if (PLOT_SPEEDS) draw_speed_plot(group_speeds, i);
if (PLOT_TRAJECTORIES) draw_trajectory_plot(group_speeds, i);
if (BOUNDARY_COND == BC_EHRENFEST) print_ehrenfest_parameters(particle, pleft, pright);
else if (PRINT_PARTICLE_NUMBER) print_particle_number(ncircles);
else if (PRINT_PARTICLE_NUMBER)
{
if (REACTION_DIFFUSION)
print_particle_types_number(particle, RD_TYPES);
else print_particle_number(ncircles);
}
if (PRINT_OMEGA) print_omega(angular_speed);
else if (PRINT_PARTICLE_SPEEDS) print_particles_speeds(particle);
else if (PRINT_SEGMENTS_SPEEDS) print_segment_group_speeds(segment_group);
@@ -1381,6 +1474,7 @@ void animation()
save_frame_lj_counter(NSTEPS + MID_FRAMES + 1 + counter);
counter++;
}
else if (NO_EXTRA_BUFFER_SWAP) glutSwapBuffers();
/* it seems that saving too many files too fast can cause trouble with the file system */
/* so this is to make a pause from time to time - parameter PAUSE may need adjusting */
@@ -1393,20 +1487,38 @@ void animation()
}
}
if (SAVE_TIME_SERIES)
{
n_total_active = 0;
for (j=0; j<ncircles; j++) if (particle[j].active) n_total_active++;
fprintf(lj_final_position, "%i\n", n_total_active);
for (j=0; j<ncircles; j++) if (particle[j].active)
{
fprintf(lj_final_position, "%i\n", j);
fprintf(lj_final_position, "%.4f\n", particle[j].xc);
fprintf(lj_final_position, "%.4f\n", particle[j].yc);
}
}
if (MOVIE)
{
if (DOUBLE_MOVIE)
{
if (TRACER_PARTICLE) draw_trajectory(trajectory, traj_position, traj_length);
draw_particles(particle, PLOT, beta);
draw_particles(particle, PLOT, beta, collisions, ncollisions);
draw_container(xmincontainer, xmaxcontainer, obstacle, segment, wall);
print_parameters(beta, mean_energy, krepel, xmaxcontainer - xmincontainer,
fboundary/(double)(ncircles*NVID), PRINT_LEFT, pressure, gravity);
if (PLOT_SPEEDS) draw_speed_plot(group_speeds, i);
if (PLOT_TRAJECTORIES) draw_trajectory_plot(group_speeds, i);
if (BOUNDARY_COND == BC_EHRENFEST) print_ehrenfest_parameters(particle, pleft, pright);
else if (PRINT_PARTICLE_NUMBER) print_particle_number(ncircles);
else if (PRINT_PARTICLE_NUMBER)
{
if (REACTION_DIFFUSION)
print_particle_types_number(particle, RD_TYPES);
else print_particle_number(ncircles);
}
if (PRINT_OMEGA) print_omega(angular_speed);
else if (PRINT_PARTICLE_SPEEDS) print_particles_speeds(particle);
else if (PRINT_SEGMENTS_SPEEDS) print_segment_group_speeds(segment_group);
@@ -1417,19 +1529,24 @@ void animation()
if (DOUBLE_MOVIE)
{
if (TRACER_PARTICLE) draw_trajectory(trajectory, traj_position, traj_length);
draw_particles(particle, PLOT_B, beta);
draw_particles(particle, PLOT_B, beta, collisions, ncollisions);
draw_container(xmincontainer, xmaxcontainer, obstacle, segment, wall);
print_parameters(beta, mean_energy, krepel, xmaxcontainer - xmincontainer,
fboundary/(double)(ncircles*NVID), PRINT_LEFT, pressure, gravity);
if (PLOT_SPEEDS) draw_speed_plot(group_speeds, i);
if (PLOT_TRAJECTORIES) draw_trajectory_plot(group_speeds, i);
if (BOUNDARY_COND == BC_EHRENFEST) print_ehrenfest_parameters(particle, pleft, pright);
else if (PRINT_PARTICLE_NUMBER) print_particle_number(ncircles);
else if (PRINT_PARTICLE_NUMBER)
{
if (REACTION_DIFFUSION)
print_particle_types_number(particle, RD_TYPES);
else print_particle_number(ncircles);
}
if (PRINT_OMEGA) print_omega(angular_speed);
else if (PRINT_PARTICLE_SPEEDS) print_particles_speeds(particle);
else if (PRINT_SEGMENTS_SPEEDS) print_segment_group_speeds(segment_group);
// print_segments_speeds(vxsegments, vysegments);
glutSwapBuffers();
if (!((NO_EXTRA_BUFFER_SWAP)&&(MOVIE))) glutSwapBuffers();
}
if ((TIME_LAPSE)&&(!DOUBLE_MOVIE))
{
@@ -1441,26 +1558,52 @@ void animation()
s = system("mv lj*.tif tif_ljones/");
}
nactive = 0;
for (j=0; j<ncircles; j++) if (particle[j].active) nactive++;
printf("%i active particles\n", nactive);
printf("1\n");
free(particle);
printf("2\n");
if (ADD_FIXED_OBSTACLES) free(obstacle);
printf("3\n");
if (ADD_FIXED_SEGMENTS)
{
free(segment);
free(segment_group);
}
printf("4\n");
if (MOVE_SEGMENT_GROUPS) free(group_speeds);
printf("5\n");
if (TRACER_PARTICLE) free(trajectory);
printf("6\n");
if (PLOT_SPEEDS) free(obstacle_speeds);
printf("7\n");
if (PLOT_PARTICLE_NUMBER) free(particle_numbers);
printf("8\n");
free(hashgrid);
printf("9\n");
free(qx);
printf("10\n");
free(qy);
printf("11\n");
free(px);
printf("12\n");
free(py);
printf("13\n");
free(qangle);
printf("14\n");
free(pangle);
printf("15\n");
free(pressure);
printf("16\n");
if (REACTION_DIFFUSION) free(collisions);
if (SAVE_TIME_SERIES)
{
fclose(lj_time_series);
fclose(lj_final_position);
}
}