Commit a5349e84 authored by Pedro Gonnet's avatar Pedro Gonnet
Browse files

collect the right quantities at the right times.


Former-commit-id: 0625e53e1fdfa055a50cb6eeb81eacce76cf0137
parent d990457c
......@@ -860,6 +860,16 @@ void runner_dokick ( struct runner *r , struct cell *c , int timer ) {
v[2] = v_old[2] + hdt * a[2];
u = u_old + hdt * u_dt;
/* Collect momentum */
mom[0] += m * v[0];
mom[1] += m * v[1];
mom[2] += m * v[2];
/* Collect angular momentum */
ang[0] += m * ( x[1]*v[2] - x[2]*v[1] );
ang[1] += m * ( x[2]*v[0] - x[0]*v[2] );
ang[2] += m * ( x[0]*v[1] - x[1]*v[0] );
/* Collect total energy. */
ekin += 0.5 * m * ( v[0]*v[0] + v[1]*v[1] + v[2]*v[2] );
epot += m * u;
......@@ -879,16 +889,6 @@ void runner_dokick ( struct runner *r , struct cell *c , int timer ) {
(x[2] - x_old[2])*(x[2] - x_old[2]) );
dx_max = fmaxf( dx_max , dx );
/* Collect momentum */
mom[0] += m * v[0];
mom[1] += m * v[1];
mom[2] += m * v[2];
/* Collect angular momentum */
ang[0] += m * ( x[1]*v[2] - x[2]*v[1] );
ang[1] += m * ( x[2]*v[0] - x[0]*v[2] );
ang[2] += m * ( x[0]*v[1] - x[1]*v[0] );
/* Update positions and energies at the half-step. */
p->v[0] = v[0] + dt * a[0];
p->v[1] = v[1] + dt * a[1];
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment