Peano
Loading...
Searching...
No Matches
equation_of_state.h
Go to the documentation of this file.
1/*******************************************************************************
2 * This file is part of SWIFT.
3 * Copyright (c) 2016 Matthieu Schaller (schaller@strw.leidenuniv.nl).
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published
7 * by the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 ******************************************************************************/
19#ifndef SWIFT_IDEAL_GAS_EQUATION_OF_STATE_H
20#define SWIFT_IDEAL_GAS_EQUATION_OF_STATE_H
21
22/* Some standard headers. */
23#include <math.h>
24
25/* Local headers. */
26#include "adiabatic_index.h"
27//#include "common_io.h"
28#include "inline.h"
29//#include "physical_constants.h"
30
31extern struct eos_parameters eos;
32
39
48__attribute__((always_inline, const)) INLINE static float
49gas_internal_energy_from_entropy(float density, float entropy) {
50
51 return entropy * pow_gamma_minus_one(density) *
52 hydro_one_over_gamma_minus_one;
53}
54
63__attribute__((always_inline, const)) INLINE static float
64gas_pressure_from_entropy(float density, float entropy) {
65
66 return entropy * pow_gamma(density);
67}
68
78__attribute__((always_inline, const)) INLINE static float
79gas_entropy_from_pressure(float density, float pressure) {
80
81 return pressure * pow_minus_gamma(density);
82}
83
92__attribute__((always_inline, const)) INLINE static float
93gas_soundspeed_from_entropy(float density, float entropy) {
94
95 return sqrtf(hydro_gamma * pow_gamma_minus_one(density) * entropy);
96}
97
106__attribute__((always_inline, const)) INLINE static float
107gas_entropy_from_internal_energy(float density, float u) {
108
109 return hydro_gamma_minus_one * u * pow_minus_gamma_minus_one(density);
110}
111
120__attribute__((always_inline, const)) INLINE static float
121gas_pressure_from_internal_energy(float density, float u) {
122
123 return hydro_gamma_minus_one * u * density;
124}
125
135__attribute__((always_inline, const)) INLINE static float
136gas_internal_energy_from_pressure(float density, float pressure) {
137
138 return hydro_one_over_gamma_minus_one * pressure / density;
139}
140
149__attribute__((always_inline, const)) INLINE static float
150gas_soundspeed_from_internal_energy(float density, float u) {
151
152 return sqrtf(u * hydro_gamma * hydro_gamma_minus_one);
153}
154
163__attribute__((always_inline, const)) INLINE static float
164gas_soundspeed_from_pressure(float density, float P) {
165
166 return sqrtf(hydro_gamma * P / density);
167}
168
179INLINE static void eos_init(struct eos_parameters *e,
180 const struct phys_const *phys_const,
181 const struct unit_system *us,
182 struct swift_params *params) {}
188INLINE static void eos_print(const struct eos_parameters *e) {
189
190// message("Equation of state: Ideal gas.");
191
192// message("Adiabatic index gamma: %f.", hydro_gamma);
193}
194
195#if defined(HAVE_HDF5)
202INLINE static void eos_print_snapshot(hid_t h_grpsph,
203 const struct eos_parameters *e) {
204
205 io_write_attribute_f(h_grpsph, "Adiabatic index", hydro_gamma);
206
207 io_write_attribute_s(h_grpsph, "Equation of state", "Ideal gas");
208}
209#endif
210
211#endif /* SWIFT_IDEAL_GAS_EQUATION_OF_STATE_H */
Defines the adiabatic index (polytropix index) of the problem and (fast) mathematical functions invo...
float pressure
static INLINE void eos_init(struct eos_parameters *e, const struct phys_const *phys_const, const struct unit_system *us, struct swift_params *params)
Initialize the eos parameters.
static INLINE void eos_print(const struct eos_parameters *e)
Print the equation of state.
float u
__attribute__((always_inline, const)) INLINE static float gas_internal_energy_from_entropy(float density
Returns the internal energy given density and entropy.
float P
float entropy
struct eos_parameters eos
#define INLINE
Defines inline.
Definition inline.h:36
The parameters of the equation of state for the gas.