#include #include #include #include typedef struct { double m; double x, y; double vx, vy; double fx, fy; } particle; int main() { int N; // numero di particelle particle * p; int t, T; int i, j; double deltat, deltat2; double LX, LY; double thre; FILE * gp; double temp; int VIS; N = 100; T = 1000000; VIS = 100; deltat = 0.01; deltat2=deltat*deltat; LX = 100; LY = 100; thre = 1e-2; temp = 0.01; p = calloc(N, sizeof(particle)); gp = popen("gnuplot", "w"); fprintf(gp, "set xrange [0:%f]; set yrange [0:%f]\n", LX, LY); // initial conditions srand48(time(NULL)); for (i=0; i LX) { p[i].x = 2 * LX - p[i].x; p[i].vx *= -1; } if (p[i].y > LX) { p[i].y = 2 * LY - p[i].y; p[i].vy *= -1; } } // prima metà della velocità for (i=0; i