diff --git a/.gitignore b/.gitignore index 05c488df5bd8da1fa991ea0a048f910becd347dd..cc936154b298d48a7661070b35dc7d2f326d56ce 100644 --- a/.gitignore +++ b/.gitignore @@ -48,6 +48,7 @@ tests/swift_dopair_standard.dat tests/brute_force_perturbed.dat tests/swift_dopair_perturbed.dat tests/test27cells +tests/test27cells_subset tests/testPeriodicBC tests/test125cells tests/brute_force_27_standard.dat diff --git a/src/cosmology.c b/src/cosmology.c index c85a23788cd4e7300ccaeb7a2787974f43db767a..40889c8ce7b677af514cb0c2598de5818fdfcefb 100644 --- a/src/cosmology.c +++ b/src/cosmology.c @@ -137,7 +137,7 @@ void cosmology_update(struct cosmology *c, integertime_t ti_current) { c->a = a; c->a_inv = a_inv; c->a3_inv = a_inv * a_inv * a_inv; - c->a_factor_sig_vel = + c->a_factor_sound_speed = pow(a, -1.5 * hydro_gamma_minus_one); /* a^{3*(1-gamma)/2} */ c->a_factor_grav_accel = a_inv * a_inv; /* 1 / a^2 */ c->a_factor_hydro_accel = @@ -458,7 +458,7 @@ void cosmology_init_no_cosmo(const struct swift_params *params, c->a = 1.; c->a_inv = 1.; c->a3_inv = 1.; - c->a_factor_sig_vel = 1.; + c->a_factor_sound_speed = 1.; c->a_factor_hydro_accel = 1.; c->a_factor_grav_accel = 1.; diff --git a/src/cosmology.h b/src/cosmology.h index 0d7d55db876b295ada39ce0b83a529044e66d4b7..57b0744f6bbf3aee5bef29afbdbcc49757ec64c3 100644 --- a/src/cosmology.h +++ b/src/cosmology.h @@ -41,8 +41,8 @@ struct cosmology { /*! Inverse cube of the current expansion factor of the Universe */ double a3_inv; - /*! Power of the scale-factor used for signal-velocity conversion */ - double a_factor_sig_vel; + /*! Power of the scale-factor used for sound-speed conversion */ + double a_factor_sound_speed; /*! Power of the scale-factor used for gravity accelerations */ double a_factor_grav_accel; diff --git a/src/hydro/Gadget2/hydro.h b/src/hydro/Gadget2/hydro.h index 8b81f6e8e8c79d9a3904d3263da01c3f9877149f..536f4864346b196e87d4307ff6066e9bc20dfd42 100644 --- a/src/hydro/Gadget2/hydro.h +++ b/src/hydro/Gadget2/hydro.h @@ -42,7 +42,7 @@ #include "minmax.h" /** - * @brief Returns the internal energy of a particle + * @brief Returns the comoving internal energy of a particle * * @param p The particle of interest */ @@ -53,7 +53,7 @@ hydro_get_comoving_internal_energy(const struct part *restrict p) { } /** - * @brief Returns the internal energy of a particle + * @brief Returns the physical internal energy of a particle * * @param p The particle of interest. * @param cosmo The cosmological model. @@ -66,16 +66,27 @@ hydro_get_physical_internal_energy(const struct part *restrict p, } /** - * @brief Returns the pressure of a particle + * @brief Returns the comoving pressure of a particle * * @param p The particle of interest */ -__attribute__((always_inline)) INLINE static float hydro_get_pressure( +__attribute__((always_inline)) INLINE static float hydro_get_comoving_pressure( const struct part *restrict p) { return gas_pressure_from_entropy(p->rho, p->entropy); } +/** + * @brief Returns the physical pressure of a particle + * + * @param p The particle of interest + */ +__attribute__((always_inline)) INLINE static float hydro_get_physical_pressure( + const struct part *restrict p, const struct cosmology *cosmo) { + + return gas_pressure_from_entropy(p->rho * cosmo->a3_inv, p->entropy); +} + /** * @brief Returns the comoving entropy of a particle * @@ -100,16 +111,29 @@ __attribute__((always_inline)) INLINE static float hydro_get_physical_entropy( } /** - * @brief Returns the sound speed of a particle + * @brief Returns the comoving sound speed of a particle * * @param p The particle of interest */ -__attribute__((always_inline)) INLINE static float hydro_get_soundspeed( - const struct part *restrict p) { +__attribute__((always_inline)) INLINE static float +hydro_get_comoving_soundspeed(const struct part *restrict p) { return p->force.soundspeed; } +/** + * @brief Returns the physical sound speed of a particle + * + * @param p The particle of interest + * @param cosmo The cosmological model. + */ +__attribute__((always_inline)) INLINE static float +hydro_get_physical_soundspeed(const struct part *restrict p, + const struct cosmology *cosmo) { + + return cosmo->a_factor_sound_speed * p->force.soundspeed; +} + /** * @brief Returns the comoving density of a particle * @@ -209,7 +233,7 @@ __attribute__((always_inline)) INLINE static float hydro_compute_timestep( /* CFL condition */ const float dt_cfl = 2.f * kernel_gamma * CFL * cosmo->a * p->h / - (cosmo->a_factor_sig_vel * p->force.v_sig); + (cosmo->a_factor_sound_speed * p->force.v_sig); return dt_cfl; } diff --git a/src/hydro/Gadget2/hydro_debug.h b/src/hydro/Gadget2/hydro_debug.h index 6500d1126bd5b5a65d3e511c13afb8364574e0ba..d0642a03a4c4eecb2da80fdae473948e460c5e31 100644 --- a/src/hydro/Gadget2/hydro_debug.h +++ b/src/hydro/Gadget2/hydro_debug.h @@ -31,7 +31,7 @@ __attribute__((always_inline)) INLINE static void hydro_debug_particle( p->x[0], p->x[1], p->x[2], p->v[0], p->v[1], p->v[2], xp->v_full[0], xp->v_full[1], xp->v_full[2], p->a_hydro[0], p->a_hydro[1], p->a_hydro[2], p->h, p->density.wcount, p->density.wcount_dh, p->mass, p->density.rho_dh, - p->rho, hydro_get_pressure(p), p->force.P_over_rho2, p->entropy, + p->rho, hydro_get_comoving_pressure(p), p->force.P_over_rho2, p->entropy, p->entropy_dt, p->force.soundspeed, p->density.div_v, p->density.rot_v[0], p->density.rot_v[1], p->density.rot_v[2], p->force.balsara, p->force.v_sig, p->force.h_dt, p->time_bin); diff --git a/src/hydro/Gadget2/hydro_io.h b/src/hydro/Gadget2/hydro_io.h index e4766a468ec66f3cbc2c5e83be694c0a1c298754..1d1f5ed453f249191b6853a3a699de847ed501f2 100644 --- a/src/hydro/Gadget2/hydro_io.h +++ b/src/hydro/Gadget2/hydro_io.h @@ -62,7 +62,7 @@ void convert_u(const struct engine* e, const struct part* p, float* ret) { void convert_P(const struct engine* e, const struct part* p, float* ret) { - ret[0] = hydro_get_pressure(p); + ret[0] = hydro_get_comoving_pressure(p); } void convert_part_pos(const struct engine* e, const struct part* p, diff --git a/tests/test125cells.c b/tests/test125cells.c index efaf4f168585953233ebd7401142b44a43823cce..1033dc96cd93a203491499188778244903108252 100644 --- a/tests/test125cells.c +++ b/tests/test125cells.c @@ -1,4 +1,3 @@ - /******************************************************************************* * This file is part of SWIFT. * Copyright (C) 2016 Matthieu Schaller (matthieu.schaller@durham.ac.uk). @@ -411,8 +410,8 @@ void dump_particle_fields(char *fileName, struct cell *main_cell, #endif hydro_get_comoving_entropy(&main_cell->parts[pid]), hydro_get_comoving_internal_energy(&main_cell->parts[pid]), - hydro_get_pressure(&main_cell->parts[pid]), - hydro_get_soundspeed(&main_cell->parts[pid]), + hydro_get_comoving_pressure(&main_cell->parts[pid]), + hydro_get_comoving_soundspeed(&main_cell->parts[pid]), main_cell->parts[pid].a_hydro[0], main_cell->parts[pid].a_hydro[1], main_cell->parts[pid].a_hydro[2], main_cell->parts[pid].force.h_dt, #if defined(GADGET2_SPH) diff --git a/tests/testInteractions.c b/tests/testInteractions.c index d7ef9eb0a35dc3446827f16acd57ce658294a709..caa0ee1bcc6649548c49287e26271ff4ca7e3114 100644 --- a/tests/testInteractions.c +++ b/tests/testInteractions.c @@ -137,8 +137,8 @@ void dump_indv_particle_fields(char *fileName, struct part *p) { p->density.div_v, #endif hydro_get_comoving_entropy(p), hydro_get_comoving_internal_energy(p), - hydro_get_pressure(p), hydro_get_soundspeed(p), p->a_hydro[0], - p->a_hydro[1], p->a_hydro[2], p->force.h_dt, + hydro_get_comoving_pressure(p), hydro_get_comoving_soundspeed(p), + p->a_hydro[0], p->a_hydro[1], p->a_hydro[2], p->force.h_dt, #if defined(GADGET2_SPH) p->force.v_sig, p->entropy_dt, 0.f #elif defined(DEFAULT_SPH)