From 2b0b35b3ca26ca00c2ef8c56c6b3a243bbbec846 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <schaller@strw.leidenuniv.nl> Date: Mon, 20 May 2024 18:32:21 +0200 Subject: [PATCH] Fix computation of the potential energy in the isothermal potential case --- src/potential/isothermal/potential.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/potential/isothermal/potential.h b/src/potential/isothermal/potential.h index 408561116b..0e6bc3b813 100644 --- a/src/potential/isothermal/potential.h +++ b/src/potential/isothermal/potential.h @@ -97,7 +97,7 @@ __attribute__((always_inline)) INLINE static float external_gravity_timestep( return potential->timestep_mult * sqrtf(a_2 / dota_2); } -/** +/**c * @brief Computes the gravitational acceleration from an isothermal potential. * * Note that the accelerations are multiplied by Newton's G constant @@ -138,7 +138,7 @@ __attribute__((always_inline)) INLINE static void external_gravity_acceleration( * @brief Computes the gravitational potential energy of a particle in an * 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 potential The #external_potential used in the run. @@ -154,7 +154,7 @@ external_gravity_get_potential_energy( const float dy = g->x[1] - potential->x[1]; 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); } -- GitLab