include/vecmat/eos.h file

Local equations of state.

Two scalars in, pressure and sound speed out.

Each call returns ok = false on non-positive density or on a negative $c^2$. No clamping. f64 is the contract; f32 uses the same formula. The _n forms are strided batches: item i reads rho[i * rho_stride] and writes p[i], c[i]. A failure leaves that item and the rest unwritten.

Classes

struct vm_eos_state
Pressure and sound speed from an equation of state.
struct vm_ideal_gas
Ideal gas: $p = (\gamma - 1)\rho e$, $c = \sqrt{\gamma p / \rho}$.
struct vm_stiff_gas
Stiffened gas: $p = (\gamma - 1)\rho e - \gamma p_\infty$.
struct vm_mie
Mie–Grüneisen on a linear Hugoniot $U_s = c_0 + s U_p$.
struct vm_jwl
Jones–Wilkins–Lee.

Functions

auto vm_eos_ideal(vm_eos_state* out, const vm_ideal_gas* eos, vm_float_t rho, vm_float_t e) -> bool
Ideal-gas pressure and sound speed.
auto vm_eos_stiffened(vm_eos_state* out, const vm_stiff_gas* eos, vm_float_t rho, vm_float_t e) -> bool
Stiffened-gas pressure and sound speed.
auto vm_eos_mie(vm_eos_state* out, const vm_mie* eos, vm_float_t rho, vm_float_t e) -> bool
Mie–Grüneisen pressure and sound speed on a linear Hugoniot.
auto vm_eos_jwl(vm_eos_state* out, const vm_jwl* eos, vm_float_t rho, vm_float_t e) -> bool
Jones–Wilkins–Lee pressure and sound speed.
auto vm_eos_ideal_n(vm_float_t* p, vm_float_t* c, const vm_ideal_gas* eos, const vm_float_t* rho, int rho_stride, const vm_float_t* e, int e_stride, int n) -> bool
Batched ideal gas.
auto vm_eos_stiffened_n(vm_float_t* p, vm_float_t* c, const vm_stiff_gas* eos, const vm_float_t* rho, int rho_stride, const vm_float_t* e, int e_stride, int n) -> bool
Batched stiffened gas.
auto vm_eos_mie_n(vm_float_t* p, vm_float_t* c, const vm_mie* eos, const vm_float_t* rho, int rho_stride, const vm_float_t* e, int e_stride, int n) -> bool
Batched Mie–Grüneisen.
auto vm_eos_jwl_n(vm_float_t* p, vm_float_t* c, const vm_jwl* eos, const vm_float_t* rho, int rho_stride, const vm_float_t* e, int e_stride, int n) -> bool
Batched Jones–Wilkins–Lee.

Function documentation

bool vm_eos_ideal(vm_eos_state* out, const vm_ideal_gas* eos, vm_float_t rho, vm_float_t e)

Ideal-gas pressure and sound speed.

Returns false if density is non-positive, gamma is not > 1, or $c^2 < 0$.

bool vm_eos_stiffened(vm_eos_state* out, const vm_stiff_gas* eos, vm_float_t rho, vm_float_t e)

Stiffened-gas pressure and sound speed.

Returns false if density is non-positive, gamma is not > 1, or $c^2 < 0$.

bool vm_eos_mie(vm_eos_state* out, const vm_mie* eos, vm_float_t rho, vm_float_t e)

Mie–Grüneisen pressure and sound speed on a linear Hugoniot.

Returns false if density or reference density is non-positive, or $c^2 < 0$.

bool vm_eos_jwl(vm_eos_state* out, const vm_jwl* eos, vm_float_t rho, vm_float_t e)

Jones–Wilkins–Lee pressure and sound speed.

Returns false if density or reference density is non-positive, or $c^2 < 0$.

bool vm_eos_ideal_n(vm_float_t* p, vm_float_t* c, const vm_ideal_gas* eos, const vm_float_t* rho, int rho_stride, const vm_float_t* e, int e_stride, int n)

Batched ideal gas.

Returns false if n is non-positive, gamma is not > 1, or any item fails.

bool vm_eos_stiffened_n(vm_float_t* p, vm_float_t* c, const vm_stiff_gas* eos, const vm_float_t* rho, int rho_stride, const vm_float_t* e, int e_stride, int n)

Batched stiffened gas.

Returns false if n is non-positive, gamma is not > 1, or any item fails.

bool vm_eos_mie_n(vm_float_t* p, vm_float_t* c, const vm_mie* eos, const vm_float_t* rho, int rho_stride, const vm_float_t* e, int e_stride, int n)

Batched Mie–Grüneisen.

Returns false if n is non-positive or any item fails.

Scalar; the per-item branch stays.

bool vm_eos_jwl_n(vm_float_t* p, vm_float_t* c, const vm_jwl* eos, const vm_float_t* rho, int rho_stride, const vm_float_t* e, int e_stride, int n)

Batched Jones–Wilkins–Lee.

Returns false if n is non-positive or any item fails.

Scalar.