Commit 20d99103 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

External potentials add to the acceleration. They don't overwrite it.

parent da35a19a
......@@ -48,7 +48,7 @@ __attribute__((always_inline)) INLINE static float cooling_rate(
const struct cooling_function_data* cooling, const struct part* p) {
/* Get particle density */
const float rho = p->rho;
const float rho = hydro_get_density(p);
/* Get cooling function properties */
const float X_H = cooling->hydrogen_mass_abundance;
......@@ -91,6 +91,7 @@ __attribute__((always_inline)) INLINE static void cooling_cool_part(
} else {
u_new = u_floor;
}
/* Update the internal energy */
hydro_set_internal_energy(p, u_new);
......
......@@ -28,7 +28,7 @@
*/
struct cooling_function_data {
/*! Cooling rate in cgs units. Defined by 'rho * du/dt = -lambda * n_H^2'*/
/*! Cooling rate in internal units */
double lambda;
/*! Fraction of gas mass that is Hydrogen. Used to calculate n_H */
......
......@@ -107,13 +107,13 @@ __attribute__((always_inline)) INLINE static void external_gravity_acceleration(
const float dy = g->x[1] - potential->y;
const float dz = g->x[2] - potential->z;
const float rinv2 = 1. / (dx * dx + dy * dy + dz * dz);
const float rinv2 = 1.f / (dx * dx + dy * dy + dz * dz);
const double term = -potential->vrot2_over_G * rinv2;
g->a_grav[0] = term * dx;
g->a_grav[1] = term * dy;
g->a_grav[2] = term * dz;
g->a_grav[0] += term * dx;
g->a_grav[1] += term * dy;
g->a_grav[2] += term * dz;
}
/**
......
......@@ -118,9 +118,9 @@ __attribute__((always_inline)) INLINE static void external_gravity_acceleration(
const double term = -potential->vrot2_over_G * r2_plus_epsilon2_inv;
g->a_grav[0] = term * dx;
g->a_grav[1] = term * dy;
g->a_grav[2] = term * dz;
g->a_grav[0] += term * dx;
g->a_grav[1] += term * dy;
g->a_grav[2] += term * dz;
}
/**
......
......@@ -52,7 +52,6 @@
#include "hydro_properties.h"
#include "kick.h"
#include "minmax.h"
#include "potential.h"
#include "scheduler.h"
#include "sourceterms.h"
#include "space.h"
......
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