diff --git a/src/const.h b/src/const.h index 270474d05e9e3059de21c078832205fc730a43ae..50d72e3339d7b8f04e3028f09794aff45f03dc65 100644 --- a/src/const.h +++ b/src/const.h @@ -56,8 +56,8 @@ /* SPH variant to use */ //#define MINIMAL_SPH -//#define GADGET2_SPH -#define DEFAULT_SPH +#define GADGET2_SPH +//#define DEFAULT_SPH /* External potential properties */ #define EXTERNAL_POTENTIAL_POINTMASS diff --git a/src/hydro/Minimal/hydro.h b/src/hydro/Minimal/hydro.h index ee7001700cc63effc8dbd6bab7b74fc6c2f5d426..f1f284d5d2b56af9d20b24c91eaf4a481f94851f 100644 --- a/src/hydro/Minimal/hydro.h +++ b/src/hydro/Minimal/hydro.h @@ -246,3 +246,39 @@ __attribute__((always_inline)) INLINE static float hydro_get_internal_energy( return p->u; } + +/** + * @brief Returns the pressure of a particle + * + * @param p The particle of interest + * @param dt Time since the last kick + */ +__attribute__((always_inline)) INLINE static float hydro_get_pressure( + const struct part *restrict p, float dt) { + + return p->u * p->rho * hydro_gamma_minus_one; +} + +/** + * @brief Returns the entropy of a particle + * + * @param p The particle of interest + * @param dt Time since the last kick + */ +__attribute__((always_inline)) INLINE static float hydro_get_entropy( + const struct part *restrict p, float dt) { + + return hydro_gamma_minus_one * p->u * pow_minus_gamma_minus_one(p->rho); +} + +/** + * @brief Returns the sound speed of a particle + * + * @param p The particle of interest + * @param dt Time since the last kick + */ +__attribute__((always_inline)) INLINE static float hydro_get_soundspeed( + const struct part *restrict p, float dt) { + + return sqrt(p->u * hydro_gamma * hydro_gamma_minus_one); +} diff --git a/tests/test125cells.c b/tests/test125cells.c index 19509db4ee9351a06e1a32a52edfb90364531a32..0aa14061a2bb1eb5780a9c36f5a994d0eb8971ff 100644 --- a/tests/test125cells.c +++ b/tests/test125cells.c @@ -97,6 +97,8 @@ void set_energy_state(struct part *part, enum pressure_field press, float size, part->entropy = pressure / pow_gamma(density); #elif defined(DEFAULT_SPH) part->u = pressure / (hydro_gamma_minus_one * density); +#elif defined(MINIMAL_SPH) + part->u = pressure / (hydro_gamma_minus_one * density); #else error("Need to define pressure here !"); #endif @@ -298,7 +300,12 @@ void dump_particle_fields(char *fileName, struct cell *main_cell, main_cell->parts[pid].x[1], main_cell->parts[pid].x[2], main_cell->parts[pid].v[0], main_cell->parts[pid].v[1], main_cell->parts[pid].v[2], main_cell->parts[pid].h, - main_cell->parts[pid].rho, main_cell->parts[pid].density.div_v, + main_cell->parts[pid].rho, +#ifdef MINIMAL_SPH + 0.f, +#else + main_cell->parts[pid].density.div_v, +#endif hydro_get_entropy(&main_cell->parts[pid], 0.f), hydro_get_internal_energy(&main_cell->parts[pid], 0.f), hydro_get_pressure(&main_cell->parts[pid], 0.f), @@ -310,6 +317,8 @@ void dump_particle_fields(char *fileName, struct cell *main_cell, main_cell->parts[pid].entropy_dt, 0.f #elif defined(DEFAULT_SPH) 0.f, main_cell->parts[pid].force.u_dt +#elif defined(MINIMAL_SPH) + 0.f, main_cell->parts[pid].u_dt #else 0.f, 0.f #endif diff --git a/tests/testNonSymInt.c b/tests/testNonSymInt.c index 23242563bd4e886f0a37d9541de59c2e0cd7e643..338856901840e1f7fad2b0c4caa8462a9fd33f67 100644 --- a/tests/testNonSymInt.c +++ b/tests/testNonSymInt.c @@ -78,8 +78,14 @@ void dump_indv_particle_fields(char *fileName, struct part *p) { "%6llu %10f %10f %10f %10f %10f %10f %13e %13e %13e %13e %13e " "%13e %13e %13e\n", p->id, p->x[0], p->x[1], p->x[2], p->v[0], p->v[1], p->v[2], p->rho, - p->rho_dh, p->density.wcount, p->density.wcount_dh, p->density.div_v, - p->density.rot_v[0], p->density.rot_v[1], p->density.rot_v[2]); + p->rho_dh, p->density.wcount, p->density.wcount_dh, +#ifdef MINIMAL_SPH + 0.f, 0.f, 0.f, 0.f +#else + p->density.div_v, + p->density.rot_v[0], p->density.rot_v[1], p->density.rot_v[2] +#endif + ); fclose(file); } diff --git a/tests/testSymInt.c b/tests/testSymInt.c index 90198219003cc84b65daee22f7c4cc649f1fce99..5158f2bae64303d6ab9b6ab82508a1ae2dde3d47 100644 --- a/tests/testSymInt.c +++ b/tests/testSymInt.c @@ -75,8 +75,14 @@ void dump_indv_particle_fields(char *fileName, struct part *p) { "%6llu %10f %10f %10f %10f %10f %10f %13e %13e %13e %13e %13e " "%13e %13e %13e\n", p->id, p->x[0], p->x[1], p->x[2], p->v[0], p->v[1], p->v[2], p->rho, - p->rho_dh, p->density.wcount, p->density.wcount_dh, p->density.div_v, - p->density.rot_v[0], p->density.rot_v[1], p->density.rot_v[2]); + p->rho_dh, p->density.wcount, p->density.wcount_dh, +#ifdef MINIMAL_SPH + 0.f, 0.f, 0.f, 0.f +#else + p->density.div_v, + p->density.rot_v[0], p->density.rot_v[1], p->density.rot_v[2] +#endif + ); fclose(file); }