ppmpy.euler module#
The main Euler solver classes.
- class Euler(nx, C, *, fixed_dt=None, bc_left_type='outflow', bc_right_type='outflow', gamma=1.4, init_cond=None, grav_func=None, params=None, use_hse_reconstruction=False, hse_as_perturbation=False, use_limiting=True, use_flattening=True)[source]#
Bases:
object
A 1D compressible Euler solver using the piecewise parabolic method (PPM), following the original Colella & Woodward ideas
- Parameters:
nx (int) – the number of zones
C (float) – the CFL number
fixed_dt (float, optional) – a fixed timestep to use for every step. In this case we do not estimate the timestep using the CFL criteria.
bc_left_type (str) – boundary condition type at the left edge. Allowed values are: “reflect”, “outflow”, “periodic”
bc_left_type – boundary condition type at the right edge. Allowed values are: “reflect”, “outflow”, “periodic”
init_cond (function) – the function to call to initialize the conserved state. This has the signature init_cond(euler) where euler is an Euler object.
grav_func (function) – the function to call to compute the gravitational acceleration. This has the signature: g = grav_func(grid, rho, params), where grid is a FVGrid`, rho is the density (array), and params is a dict of option parameters needed to interpret gravity.
params (dict, optional) – a dictionary of parameters that is passed to the initial condition and gravity functions. The ratio specific heats can be set here as “gamma”.
use_hse_reconstruction (bool, optional) – do we subtract off HSE from pressure before doing the parabolic reconstruction?
hse_as_perturbation (bool, optional) – do we do the characteristic tracing on p’ – the pressure perturbation?
use_limiting (bool, optional) – do we limit the parabola coefficients?
use_flattening (bool, optional) – do we apply flattening to the shock to smear them out?
- compute_fluxes(q_left, q_right)[source]#
given the left and right states, solve the Riemann problem to get the interface state and return the fluxes
- Parameters:
q_left (ndarray) – the left primitive variable state on the interface.
q_right (ndarray) – the right primitive variable state on the interface.
- Returns:
flux – the conserved flux through each interface.
- Return type:
ndarray
- cons_flux(state)[source]#
given an interface state, return the conservative flux
- Parameters:
state (RiemannState) – the interface state from the Riemann solver.
- Returns:
flux – the conserved flux through the interface for the input state.
- Return type:
ndarray
- cons_to_prim()[source]#
Convert the conserved variable state to primitive variables
- Returns:
q – the primitive variable array.
- Return type:
ndarray
- draw_prim(gp, ivar)[source]#
Draw the parabola for a primitive variable (ivar) on a GridPlot object
- Parameters:
gp (GridPlot) – the grid plot object for the figure
ivar (int) – the index of the primitive variable to plot
- draw_waves(gp)[source]#
Draw the domains seen by each of the 3 characteristic waves and the interface they interact with
- Parameters:
gp (GridPlot) – the grid plot object for the figure
- evolve(tmax, *, verbose=True)[source]#
The main evolution driver to advance the state to time tmax
- Parameters:
tmax (float) – maximum simulation time to evolve to
verbose (bool, optional) – enable / disable verbosity
- interface_states()[source]#
Trace the primitive variables to the interfaces by integrating under the parabola and doing a characteristic projection
- Returns:
q_left (ndarray) – the left primitive variable state on the interface.
q_right (ndarray) – the right primitive variable state on the interface.