lm_atm package¶
The pyro solver for low Mach number atmospheric flow. This implements as second-order approximate projection method. The general flow is:
- create the limited slopes of rho, u and v (in both directions)
- get the advective velocities through a piecewise linear Godunov method
- enforce the divergence constraint on the velocities through a projection (the MAC projection)
- predict rho to edges and do the conservative update
- recompute the interface states using the new advective velocity
- update U in time to get the provisional velocity field
- project the final velocity to enforce the divergence constraint.
The projections are done using multigrid
Submodules¶
lm_atm.LM_atm_interface module¶
-
lm_atm.LM_atm_interface.
get_interface_states
[source]¶ Compute the unsplit predictions of u and v on both the x- and y-interfaces. This includes the transverse terms.
Note that the
gradp_x
,gradp_y
should have any coefficients already included (e.g. \(\beta_0/\rho\))Parameters: - ng : int
The number of ghost cells
- dx, dy : float
The cell spacings
- dt : float
The timestep
- u, v : ndarray
x-velocity and y-velocity
- ldelta_ux, ldelta_uy: ndarray
Limited slopes of the x-velocity in the x and y directions
- ldelta_vx, ldelta_vy: ndarray
Limited slopes of the y-velocity in the x and y directions
- gradp_x, gradp_y : ndarray
Pressure gradients in the x and y directions
- source : ndarray
Source terms
Returns: - out : ndarray, ndarray, ndarray, ndarray, ndarray, ndarray, ndarray, ndarray
unsplit predictions of u and v on both the x- and y-interfaces
-
lm_atm.LM_atm_interface.
is_asymmetric
[source]¶ Is the left half of s asymmetric to the right half?
Parameters: - ng : int
The number of ghost cells
- nodal: bool
Is the data nodal?
- s : ndarray
The array to be compared
Returns: - out : int
Is it asymmetric? (1 = yes, 0 = no)
-
lm_atm.LM_atm_interface.
is_asymmetric_pair
[source]¶ Are sl and sr asymmetric about an axis parallel with the y-axis in the center of domain the x-direction?
Parameters: - ng : int
The number of ghost cells
- nodal: bool
Is the data nodal?
- sl, sr : ndarray
The two arrays to be compared
Returns: - out : int
Are they asymmetric? (1 = yes, 0 = no)
-
lm_atm.LM_atm_interface.
is_symmetric
[source]¶ Is the left half of s the mirror image of the right half?
Parameters: - ng : int
The number of ghost cells
- nodal: bool
Is the data nodal?
- s : ndarray
The array to be compared
Returns: - out : int
Is it symmetric? (1 = yes, 0 = no)
-
lm_atm.LM_atm_interface.
is_symmetric_pair
[source]¶ Are sl and sr symmetric about an axis parallel with the y-axis in the center of domain the x-direction?
Parameters: - ng : int
The number of ghost cells
- nodal: bool
Is the data nodal?
- sl, sr : ndarray
The two arrays to be compared
Returns: - out : int
Are they symmetric? (1 = yes, 0 = no)
-
lm_atm.LM_atm_interface.
mac_vels
[source]¶ Calculate the MAC velocities in the x and y directions.
Parameters: - ng : int
The number of ghost cells
- dx, dy : float
The cell spacings
- dt : float
The timestep
- u, v : ndarray
x-velocity and y-velocity
- ldelta_ux, ldelta_uy: ndarray
Limited slopes of the x-velocity in the x and y directions
- ldelta_vx, ldelta_vy: ndarray
Limited slopes of the y-velocity in the x and y directions
- gradp_x, gradp_y : ndarray
Pressure gradients in the x and y directions
- source : ndarray
Source terms
Returns: - out : ndarray, ndarray
MAC velocities in the x and y directions
-
lm_atm.LM_atm_interface.
rho_states
[source]¶ This predicts rho to the interfaces. We use the MAC velocities to do the upwinding
Parameters: - ng : int
The number of ghost cells
- dx, dy : float
The cell spacings
- rho : ndarray
density
- u_MAC, v_MAC : ndarray
MAC velocities in the x and y directions
- ldelta_rx, ldelta_ry: ndarray
Limited slopes of the density in the x and y directions
Returns: - out : ndarray, ndarray
rho predicted to the interfaces
-
lm_atm.LM_atm_interface.
riemann
[source]¶ Solve the Burger’s Riemann problem given the input left and right states and return the state on the interface.
This uses the expressions from Almgren, Bell, and Szymczak 1996.
Parameters: - ng : int
The number of ghost cells
- q_l, q_r : ndarray
left and right states
Returns: - out : ndarray
Interface state
-
lm_atm.LM_atm_interface.
riemann_and_upwind
[source]¶ First solve the Riemann problem given q_l and q_r to give the velocity on the interface and: use this velocity to upwind to determine the state (q_l, q_r, or a mix) on the interface).
This differs from upwind, above, in that we don’t take in a velocity to upwind with).
Parameters: - ng : int
The number of ghost cells
- q_l, q_r : ndarray
left and right states
Returns: - out : ndarray
Upwinded state
-
lm_atm.LM_atm_interface.
states
[source]¶ This is similar to
mac_vels
, but it predicts the interface states of both u and v on both interfaces, using the MAC velocities to do the upwinding.Parameters: - ng : int
The number of ghost cells
- dx, dy : float
The cell spacings
- dt : float
The timestep
- u, v : ndarray
x-velocity and y-velocity
- ldelta_ux, ldelta_uy: ndarray
Limited slopes of the x-velocity in the x and y directions
- ldelta_vx, ldelta_vy: ndarray
Limited slopes of the y-velocity in the x and y directions
- source : ndarray
Source terms
- gradp_x, gradp_y : ndarray
Pressure gradients in the x and y directions
- u_MAC, v_MAC : ndarray
MAC velocities in the x and y directions
Returns: - out : ndarray, ndarray, ndarray, ndarray
x and y velocities predicted to the interfaces
-
lm_atm.LM_atm_interface.
upwind
[source]¶ upwind the left and right states based on the specified input velocity, s. The resulting interface state is q_int
Parameters: - ng : int
The number of ghost cells
- q_l, q_r : ndarray
left and right states
- s : ndarray
velocity
Returns: - q_int : ndarray
Upwinded state
lm_atm.simulation module¶
-
class
lm_atm.simulation.
Simulation
(solver_name, problem_name, rp, timers=None)[source]¶ Bases:
simulation_null.NullSimulation
-
initialize
()[source]¶ Initialize the grid and variables for low Mach atmospheric flow and set the initial conditions for the chosen problem.
-
method_compute_timestep
()[source]¶ The timestep() function computes the advective timestep (CFL) constraint. The CFL constraint says that information cannot propagate further than one zone per timestep.
We use the driver.cfl parameter to control what fraction of the CFL step we actually take.
-