19#ifndef SWIFT_MINIMAL_HYDRO_IACT_H
20#define SWIFT_MINIMAL_HYDRO_IACT_H
54 const float r2,
const float dx[3],
const float hi,
const float hj,
55 struct part *restrict pi,
struct part *restrict
pj,
const float a,
58 float wi, wj, wi_dx, wj_dx;
60#ifdef SWIFT_DEBUG_CHECKS
61 if (pi->time_bin >= time_bin_inhibited)
62 error(
"Inhibited pi in interaction function!");
63 if (
pj->time_bin >= time_bin_inhibited)
64 error(
"Inhibited pj in interaction function!");
68 const float r = sqrtf(r2);
72 const float mi = pi->mass;
81 pi->density.rho_dh -=
mj * (hydro_dimension * wi +
ui * wi_dx);
82 pi->density.wcount += wi;
83 pi->density.wcount_dh -= (hydro_dimension * wi +
ui * wi_dx);
103 dv[0] = pi->v[0] -
pj->
v[0];
104 dv[1] = pi->v[1] -
pj->
v[1];
105 dv[2] = pi->v[2] -
pj->
v[2];
138 const float r2,
const float dx[3],
const float hi,
const float hj,
139 struct part *restrict pi,
const struct part *restrict
pj,
const float a,
144#ifdef SWIFT_DEBUG_CHECKS
145 if (pi->time_bin >= time_bin_inhibited)
146 error(
"Inhibited pi in interaction function!");
147 if (
pj->time_bin >= time_bin_inhibited)
148 error(
"Inhibited pj in interaction function!");
155 const float r = sqrtf(r2);
156 const float r_inv =
r ? 1.0f /
r : 0.0f;
163 pi->density.rho_dh -=
mj * (hydro_dimension * wi +
ui * wi_dx);
164 pi->density.wcount += wi;
165 pi->density.wcount_dh -= (hydro_dimension * wi +
ui * wi_dx);
173 dv[0] = pi->v[0] -
pj->
v[0];
174 dv[1] = pi->v[1] -
pj->
v[1];
175 dv[2] = pi->v[2] -
pj->
v[2];
206 const float r2,
const float dx[3],
const float hi,
const float hj,
207 struct part *restrict pi,
struct part *restrict
pj,
const float a,
227 const float r2,
const float dx[3],
const float hi,
const float hj,
228 struct part *restrict pi,
struct part *restrict
pj,
const float a,
244 const float r2,
const float dx[3],
const float hi,
const float hj,
245 struct part *restrict pi,
struct part *restrict
pj,
const float a,
248#ifdef SWIFT_DEBUG_CHECKS
249 if (pi->time_bin >= time_bin_inhibited)
250 error(
"Inhibited pi in interaction function!");
251 if (
pj->time_bin >= time_bin_inhibited)
252 error(
"Inhibited pj in interaction function!");
256 const float fac_mu = pow_three_gamma_minus_five_over_two(
a);
257 const float a2_Hubble =
a *
a *
H;
260 const float r = sqrtf(r2);
261 const float r_inv =
r ? 1.0f /
r : 0.0f;
264 const float mi = pi->mass;
266 const float rhoi = pi->rho;
267 const float rhoj =
pj->
rho;
268 const float pressurei = pi->force.pressure;
277 const float wi_dr = hid_inv * wi_dx;
285 const float wj_dr = hjd_inv * wj_dx;
288 const float f_ij = 1.f - pi->force.f /
mj;
292 const float P_over_rho2_i = pressurei / (rhoi * rhoi) * f_ij;
293 const float P_over_rho2_j = pressurej / (rhoj * rhoj) * f_ji;
296 const float dvdr = (pi->v[0] -
pj->
v[0]) *
dx[0] +
297 (pi->v[1] -
pj->
v[1]) *
dx[1] +
298 (pi->v[2] -
pj->
v[2]) *
dx[2];
301 const float dvdr_Hubble =
dvdr + a2_Hubble * r2;
304 const float omega_ij =
MIN(dvdr_Hubble, 0.f);
305 const float mu_ij = fac_mu *
r_inv * omega_ij;
311 const float balsara_i = pi->force.balsara;
315 const float rho_ij = 0.5f * (rhoi + rhoj);
316 const float visc = -0.25f *
v_sig * (balsara_i + balsara_j) *
mu_ij / rho_ij;
319 const float visc_acc_term =
320 0.5f * visc * (wi_dr * f_ij + wj_dr * f_ji) *
r_inv;
323 const float sph_acc_term =
324 (P_over_rho2_i * wi_dr + P_over_rho2_j * wj_dr) *
r_inv;
327 const float adapt_soft_acc_term =
328 adaptive_softening_get_acc_term(pi,
pj, wi_dr, wj_dr, f_ij, f_ji,
r_inv);
331 const float acc = sph_acc_term + visc_acc_term + adapt_soft_acc_term;
334 pi->a_hydro[0] -=
mj * acc *
dx[0];
335 pi->a_hydro[1] -=
mj * acc *
dx[1];
336 pi->a_hydro[2] -=
mj * acc *
dx[2];
343 const float sph_du_term_i = P_over_rho2_i *
dvdr *
r_inv * wi_dr;
344 const float sph_du_term_j = P_over_rho2_j *
dvdr *
r_inv * wj_dr;
347 const float visc_du_term = 0.5f * visc_acc_term * dvdr_Hubble;
350 const float du_dt_i = sph_du_term_i + visc_du_term;
351 const float du_dt_j = sph_du_term_j + visc_du_term;
354 pi->u_dt += du_dt_i *
mj;
358 pi->force.h_dt -=
mj *
dvdr *
r_inv / rhoj * wi_dr * f_ij;
362 pi->force.v_sig =
MAX(pi->force.v_sig,
v_sig);
379 const float r2,
const float dx[3],
const float hi,
const float hj,
380 struct part *restrict pi,
const struct part *restrict
pj,
const float a,
383#ifdef SWIFT_DEBUG_CHECKS
384 if (pi->time_bin >= time_bin_inhibited)
385 error(
"Inhibited pi in interaction function!");
386 if (
pj->time_bin >= time_bin_inhibited)
387 error(
"Inhibited pj in interaction function!");
391 const float fac_mu = pow_three_gamma_minus_five_over_two(
a);
392 const float a2_Hubble =
a *
a *
H;
395 const float r = sqrtf(r2);
396 const float r_inv =
r ? 1.0f /
r : 0.0f;
399 const float mi = pi->mass;
401 const float rhoi = pi->rho;
402 const float rhoj =
pj->
rho;
403 const float pressurei = pi->force.pressure;
412 const float wi_dr = hid_inv * wi_dx;
420 const float wj_dr = hjd_inv * wj_dx;
423 const float f_ij = 1.f - pi->force.f /
mj;
427 const float P_over_rho2_i = pressurei / (rhoi * rhoi) * f_ij;
428 const float P_over_rho2_j = pressurej / (rhoj * rhoj) * f_ji;
431 const float dvdr = (pi->v[0] -
pj->
v[0]) *
dx[0] +
432 (pi->v[1] -
pj->
v[1]) *
dx[1] +
433 (pi->v[2] -
pj->
v[2]) *
dx[2];
436 const float dvdr_Hubble =
dvdr + a2_Hubble * r2;
439 const float omega_ij =
MIN(dvdr_Hubble, 0.f);
440 const float mu_ij = fac_mu *
r_inv * omega_ij;
446 const float balsara_i = pi->force.balsara;
450 const float rho_ij = 0.5f * (rhoi + rhoj);
451 const float visc = -0.25f *
v_sig * (balsara_i + balsara_j) *
mu_ij / rho_ij;
454 const float visc_acc_term =
455 0.5f * visc * (wi_dr * f_ij + wj_dr * f_ji) *
r_inv;
458 const float sph_acc_term =
459 (P_over_rho2_i * wi_dr + P_over_rho2_j * wj_dr) *
r_inv;
462 const float adapt_soft_acc_term =
463 adaptive_softening_get_acc_term(pi,
pj, wi_dr, wj_dr, f_ij, f_ji,
r_inv);
466 const float acc = sph_acc_term + visc_acc_term + adapt_soft_acc_term;
469 pi->a_hydro[0] -=
mj * acc *
dx[0];
470 pi->a_hydro[1] -=
mj * acc *
dx[1];
471 pi->a_hydro[2] -=
mj * acc *
dx[2];
474 const float sph_du_term_i = P_over_rho2_i *
dvdr *
r_inv * wi_dr;
477 const float visc_du_term = 0.5f * visc_acc_term * dvdr_Hubble;
480 const float du_dt_i = sph_du_term_i + visc_du_term;
483 pi->u_dt += du_dt_i *
mj;
486 pi->force.h_dt -=
mj *
dvdr *
r_inv / rhoj * wi_dr * f_ij;
489 pi->force.v_sig =
MAX(pi->force.v_sig,
v_sig);
Defines the adiabatic index (polytropix index) of the problem and (fast) mathematical functions invo...
const float const float const float hj
const float const float hi
adaptive_softening_add_correction_term(pi, ui, hi_inv, mj)
const float const float const float struct part *restrict struct part *restrict pj
kernel_deval(ui, &wi, &wi_dx)
const float const float const float struct part *restrict struct part *restrict const float const float H
const float const float const float struct part *restrict struct part *restrict const float a
__attribute__((always_inline)) INLINE static void runner_iact_density(const float r2
Density interaction between two particles.
#define const_viscosity_beta
#define INLINE
Defines inline.
#define MIN(a, b)
Minimum of two numbers.
#define MAX(a, b)
Maximum of two numbers.
InlineMethod T pow_dimension_plus_one(T x)
returns x^{ndim+1}
const struct part *restrict const struct part *restrict const float mu_ij
Particle fields for the SPH particles.
struct part::@3::@6 force
Structure for the variables only used in the force loop over neighbours.
struct part::@3::@5 density
Structure for the variables only used in the density loop over neighbours.