Skip to content
Snippets Groups Projects
Commit 2b0b35b3 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Fix computation of the potential energy in the isothermal potential case

parent 73ca24b8
No related branches found
No related tags found
7 merge requests!1997Yet another master into zoom buffer branch merge (with formatting all done!),!1994Draft: Testing master -> zoom merge,!1987Update zoom_merge with master updates (after wrangling immense conflicts),!1982Update zoom merge branch with latest master developments,!1956Rename space_getsid to space_getsid_and_swap_cells() to try to prevent...,!1945Another master->zoom_merge update,!1921Mhd canvas
...@@ -97,7 +97,7 @@ __attribute__((always_inline)) INLINE static float external_gravity_timestep( ...@@ -97,7 +97,7 @@ __attribute__((always_inline)) INLINE static float external_gravity_timestep(
return potential->timestep_mult * sqrtf(a_2 / dota_2); return potential->timestep_mult * sqrtf(a_2 / dota_2);
} }
/** /**c
* @brief Computes the gravitational acceleration from an isothermal potential. * @brief Computes the gravitational acceleration from an isothermal potential.
* *
* Note that the accelerations are multiplied by Newton's G constant * Note that the accelerations are multiplied by Newton's G constant
...@@ -138,7 +138,7 @@ __attribute__((always_inline)) INLINE static void external_gravity_acceleration( ...@@ -138,7 +138,7 @@ __attribute__((always_inline)) INLINE static void external_gravity_acceleration(
* @brief Computes the gravitational potential energy of a particle in an * @brief Computes the gravitational potential energy of a particle in an
* isothermal potential. * isothermal potential.
* *
* phi = -0.5 * vrot^2 * ln(r^2 + epsilon^2) * phi = 0.5 * vrot^2 * ln(r^2 + epsilon^2)
* *
* @param time The current time (unused here). * @param time The current time (unused here).
* @param potential The #external_potential used in the run. * @param potential The #external_potential used in the run.
...@@ -154,7 +154,7 @@ external_gravity_get_potential_energy( ...@@ -154,7 +154,7 @@ external_gravity_get_potential_energy(
const float dy = g->x[1] - potential->x[1]; const float dy = g->x[1] - potential->x[1];
const float dz = g->x[2] - potential->x[2]; const float dz = g->x[2] - potential->x[2];
return potential->vrot * potential->vrot * return 0.5f * potential->vrot * potential->vrot *
logf(dx * dx + dy * dy + dz * dz + potential->epsilon2); logf(dx * dx + dy * dy + dz * dz + potential->epsilon2);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment