<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 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
Step1:  Inside the notebook, the state will automatically display the values of the key variables
Step2:  Adding a label to the state for output purposes requires an extra keyword
Step3:  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
Step4:  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
Step5:  A state will return the key primitive variables ($\rho, v_x, v_t, \epsilon$)
Step6:  A state will return all the variables it computes, which is $\rho, v_x, v_t, \epsilon, p, W, h, c_s$
<ASSISTANT_TASK:>
Python Code:
from r3d2 import eos_defns, State
eos = eos_defns.eos_gamma_law(5.0/3.0)
U = State(1.0, 0.1, 0.0, 2.0, eos)
Explanation: 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:
End of explanation
U
Explanation: Inside the notebook, the state will automatically display the values of the key variables:
End of explanation
U2 = State(10.0, -0.3, 0.1, 5.0, eos, label="L")
U2
Explanation: Adding a label to the state for output purposes requires an extra keyword:
End of explanation
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
Explanation: 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:
End of explanation
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)))
Explanation: 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:
End of explanation
print("Primitive variables of first state are {}".format(U.prim()))
Explanation: A state will return the key primitive variables ($\rho, v_x, v_t, \epsilon$):
End of explanation
print("All variables of second state are {}".format(U.state()))
Explanation: 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$:
End of explanation
<END_TASK>