States

A Riemann Problem is specified by the state of the material to the left and right of the interface. In this hydrodynamic problem, the state is fully determined by an equation of state and the variables

$$ {\bf U} = \begin{pmatrix} \rho_0 \\ v_x \\ v_t \\ \epsilon \end{pmatrix}, $$

where $\rho_0$ is the rest-mass density, $v_x$ the velocity normal to the interface, $v_t$ the velocity tangential to the interface, and $\epsilon$ the specific internal energy.

Defining a state

In r3d2 we define a state from an equation of state and the values of the key variables:


In [1]:
from r3d2 import eos_defns, State

In [2]:
eos = eos_defns.eos_gamma_law(5.0/3.0)
U = State(1.0, 0.1, 0.0, 2.0, eos)

Inside the notebook, the state will automatically display the values of the key variables:


In [3]:
U


Out[3]:
\begin{equation}\begin{pmatrix} \rho \\ v_x \\ v_t \\ \epsilon \end{pmatrix}= \begin{pmatrix} 1.0000 \\ 0.1000 \\ 0.0000 \\ 2.0000 \end{pmatrix}\end{equation}

Adding a label to the state for output purposes requires an extra keyword:


In [4]:
U2 = State(10.0, -0.3, 0.1, 5.0, eos, label="L")
U2


Out[4]:
\begin{equation}\begin{pmatrix} \rho \\ v_x \\ v_t \\ \epsilon \end{pmatrix}_{L} = \begin{pmatrix} 10.0000 \\ -0.3000 \\ 0.1000 \\ 5.0000 \end{pmatrix}\end{equation}

Reactive states

If the state has energy available for reactions, that information is built into the equation of state. The definition of the equation of state changes: the definition of the state itself does not:


In [5]:
q_available = 0.1
t_ignition = 10.0
Cv = 1.0
eos_reactive = eos_defns.eos_gamma_law_react(5.0/3.0, q_available, Cv, t_ignition, eos)
U_reactive = State(5.0, 0.1, 0.1, 2.0, eos_reactive, label="Reactive")
U_reactive


Out[5]:
\begin{equation}\begin{pmatrix} \rho \\ v_x \\ v_t \\ \epsilon \\ q \end{pmatrix}_{Reactive} = \begin{pmatrix} 5.0000 \\ 0.1000 \\ 0.1000 \\ 2.0000 \\ 0.1000 \end{pmatrix}\end{equation}

Additional functions

A state knows its own wavespeeds. Given a wavenumber (the left acoustic wave is 0, the middle contact or advective wave is 1, and the right acoustic wave is 2), we have:


In [6]:
print("Left wavespeed of first state is {}".format(U.wavespeed(0)))
print("Middle wavespeed of second state is {}".format(U2.wavespeed(1)))
print("Right wavespeed of reactive state is {}".format(U.wavespeed(2)))


Left wavespeed of first state is -0.6636390537799616
Middle wavespeed of second state is -0.3
Right wavespeed of reactive state is 0.7615771981098584

A state will return the key primitive variables ($\rho, v_x, v_t, \epsilon$):


In [7]:
print("Primitive variables of first state are {}".format(U.prim()))


Primitive variables of first state are [1.  0.1 0.  2. ]

A state will return all the variables it computes, which is $\rho, v_x, v_t, \epsilon, p, W, h, c_s$: the primitive variables as above, the pressure $p$, Lorentz factor $W$, specific enthalpy $h$, and speed of sound $c_s$:


In [8]:
print("All variables of second state are {}".format(U.state()))


All variables of second state are [1.         0.1        0.         2.         1.33333333 1.00503782
 4.33333333 0.71611487]