Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
8e2b479e
Commit
8e2b479e
authored
Aug 06, 2016
by
Matthieu Schaller
Browse files
Ported to the other SPH schemes and updated documentation of the EoS.
parent
816954ee
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/equation_of_state.h
View file @
8e2b479e
...
...
@@ -31,13 +31,16 @@
#include
"debug.h"
#include
"inline.h"
/* ------------------------------------------------------------------------- */
#if defined(IDEAL_GAS)
/**
* @brief Returns the internal energy given density and entropy
*
* @param density The density
* @param entropy The entropy
* Computes \f$u = \frac{S\rho^{\gamma-1} }{\gamma - 1}\f$.
*
* @param density The density \f$\rho\f$.
* @param entropy The entropy \f$S\f$.
*/
__attribute__
((
always_inline
))
INLINE
static
float
gas_internal_energy_from_entropy
(
float
density
,
float
entropy
)
{
...
...
@@ -46,6 +49,92 @@ gas_internal_energy_from_entropy(float density, float entropy) {
hydro_one_over_gamma_minus_one
;
}
/**
* @brief Returns the pressure given density and entropy
*
* Computes \f$P = S\rho^\gamma\f$.
*
* @param density The density \f$\rho\f$.
* @param entropy The entropy \f$S\f$.
*/
__attribute__
((
always_inline
))
INLINE
static
float
gas_pressure_from_entropy
(
float
density
,
float
entropy
)
{
return
entropy
*
pow_gamma
(
density
);
}
/**
* @brief Returns the sound speed given density and entropy
*
* Computes \f$c = \sqrt{\gamma S \rho^{\gamma-1}}\f$.
*
* @param density The density \f$\rho\f$.
* @param entropy The entropy \f$S\f$.
*/
__attribute__
((
always_inline
))
INLINE
static
float
gas_soundspeed_from_entropy
(
float
density
,
float
entropy
)
{
return
sqrtf
(
hydro_gamma
*
pow_gamma_minus_one
(
density
)
*
entropy
);
}
/**
* @brief Returns the entropy given density and internal energy
*
* Computes \f$S = \frac{(\gamma - 1)u}{\rho^{\gamma-1}}\f$.
*
* @param density The density \f$\rho\f$
* @param u The internal energy \f$u\f$
*/
__attribute__
((
always_inline
))
INLINE
static
float
gas_entropy_from_internal_energy
(
float
density
,
float
u
)
{
return
hydro_gamma_minus_one
*
u
*
pow_minus_gamma_minus_one
(
density
);
}
/**
* @brief Returns the pressure given density and internal energy
*
* Computes \f$P = (\gamma - 1)u\rho\f$.
*
* @param density The density \f$\rho\f$
* @param u The internal energy \f$u\f$
*/
__attribute__
((
always_inline
))
INLINE
static
float
gas_pressure_from_internal_energy
(
float
density
,
float
u
)
{
return
hydro_gamma_minus_one
*
u
*
density
;
}
/**
* @brief Returns the sound speed given density and internal energy
*
* Computes \f$c = \sqrt{\gamma (\gamma - 1) u }\f$.
*
* @param density The density \f$\rho\f$
* @param u The internal energy \f$u\f$
*/
__attribute__
((
always_inline
))
INLINE
static
float
gas_soundspeed_from_internal_energy
(
float
density
,
float
u
)
{
return
sqrtf
(
u
*
hydro_gamma
*
hydro_gamma_minus_one
);
}
/* ------------------------------------------------------------------------- */
#elif defined(ISOTHERMAL_GAS)
/**
* @brief Returns the internal energy given density and entropy
*
* @param density The density
* @param entropy The entropy
*/
__attribute__
((
always_inline
))
INLINE
static
float
gas_internal_energy_from_entropy
(
float
density
,
float
entropy
)
{
error
(
"Missing definition !"
);
return
0
.
f
;
}
/**
* @brief Returns the pressure given density and entropy
*
...
...
@@ -55,7 +144,8 @@ gas_internal_energy_from_entropy(float density, float entropy) {
__attribute__
((
always_inline
))
INLINE
static
float
gas_pressure_from_entropy
(
float
density
,
float
entropy
)
{
return
entropy
*
pow_gamma
(
density
);
error
(
"Missing definition !"
);
return
0
.
f
;
}
/**
...
...
@@ -67,7 +157,8 @@ __attribute__((always_inline)) INLINE static float gas_pressure_from_entropy(
__attribute__
((
always_inline
))
INLINE
static
float
gas_entropy_from_internal_energy
(
float
density
,
float
u
)
{
return
hydro_gamma_minus_one
*
u
*
pow_minus_gamma_minus_one
(
density
);
error
(
"Missing definition !"
);
return
0
.
f
;
}
/**
...
...
@@ -79,14 +170,24 @@ gas_entropy_from_internal_energy(float density, float u) {
__attribute__
((
always_inline
))
INLINE
static
float
gas_pressure_from_internal_energy
(
float
density
,
float
u
)
{
return
hydro_gamma_minus_one
*
u
*
density
;
error
(
"Missing definition !"
);
return
0
.
f
;
}
/**
* @brief Returns the sound speed given density and internal energy
*
* @param density The density
* @param u The internal energy
*/
__attribute__
((
always_inline
))
INLINE
static
float
gas_soundspeed_from_internal_energy
(
float
density
,
float
u
)
{
#elif defined(ISOTHERMAL_GAS)
#error "Missing definitions !"
error
(
"Missing definition !"
);
return
0
.
f
;
}
/* ------------------------------------------------------------------------- */
#else
#error "An Equation of state needs to be chosen in const.h !"
...
...
src/hydro/Default/hydro.h
View file @
8e2b479e
...
...
@@ -19,9 +19,58 @@
#include
"adiabatic_index.h"
#include
"approx_math.h"
#include
"equation_of_state.h"
#include
<float.h>
/**
* @brief Returns the internal energy of a particle
*
* @param p The particle of interest
* @param dt Time since the last kick
*/
__attribute__
((
always_inline
))
INLINE
static
float
hydro_get_internal_energy
(
const
struct
part
*
restrict
p
,
float
dt
)
{
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
gas_pressure_from_internal_energy
(
p
->
rho
,
p
->
u
);
}
/**
* @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
gas_entropy_from_internal_energy
(
p
->
rho
,
p
->
u
);
}
/**
* @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
p
->
force
.
soundspeed
;
}
/**
* @brief Computes the hydro time-step of a given particle
*
...
...
@@ -253,51 +302,3 @@ __attribute__((always_inline)) INLINE static void hydro_kick_extra(
*/
__attribute__
((
always_inline
))
INLINE
static
void
hydro_convert_quantities
(
struct
part
*
restrict
p
)
{}
/**
* @brief Returns the internal energy of a particle
*
* @param p The particle of interest
* @param dt Time since the last kick
*/
__attribute__
((
always_inline
))
INLINE
static
float
hydro_get_internal_energy
(
const
struct
part
*
restrict
p
,
float
dt
)
{
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
->
force
.
P_over_rho2
*
p
->
rho
*
p
->
rho
/
p
->
rho_dh
;
}
/**
* @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
p
->
force
.
soundspeed
;
}
src/hydro/Minimal/hydro.h
View file @
8e2b479e
...
...
@@ -19,6 +19,63 @@
#include
"adiabatic_index.h"
#include
"approx_math.h"
#include
"equation_of_state.h"
/**
* @brief Returns the internal energy of a particle
*
* For implementations where the main thermodynamic variable
* is not internal energy, this function computes the internal
* energy from the thermodynamic variable.
*
* @param p The particle of interest
* @param dt Time since the last kick
*/
__attribute__
((
always_inline
))
INLINE
static
float
hydro_get_internal_energy
(
const
struct
part
*
restrict
p
,
float
dt
)
{
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
gas_pressure_from_internal_energy
(
p
->
rho
,
p
->
u
);
}
/**
* @brief Returns the entropy of a particle
*
* For implementations where the main thermodynamic variable
* is not entropy, this function computes the entropy from
* the thermodynamic variable.
*
* @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
gas_entropy_from_internal_energy
(
p
->
rho
,
p
->
u
);
}
/**
* @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
gas_soundspeed_from_internal_energy
(
p
->
rho
,
p
->
u
);
}
/**
* @brief Computes the hydro time-step of a given particle
...
...
@@ -230,55 +287,3 @@ __attribute__((always_inline)) INLINE static void hydro_kick_extra(
*/
__attribute__
((
always_inline
))
INLINE
static
void
hydro_convert_quantities
(
struct
part
*
restrict
p
)
{}
/**
* @brief Returns the internal energy of a particle
*
* For implementations where the main thermodynamic variable
* is not internal energy, this function computes the internal
* energy from the thermodynamic variable.
*
* @param p The particle of interest
* @param dt Time since the last kick
*/
__attribute__
((
always_inline
))
INLINE
static
float
hydro_get_internal_energy
(
const
struct
part
*
restrict
p
,
float
dt
)
{
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
);
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment