dragonfly_sim.utils.NS_utils ============================ .. py:module:: dragonfly_sim.utils.NS_utils .. autoapi-nested-parse:: Navier-Stokes / RANS building blocks on top of Euler_utils (used by core/RANS_model.py and by CompressibleEulerModel whenever the state carries extra transported scalars). The state is the conservative mean flow U_m = (rho, rho*u, rho*E), n_mean = 2 + dim components, optionally followed by conservative transported scalars (rho*phi_k, e.g. rho*nu_tilde for Spalart-Allmaras). Euler_utils only ever sees the mean-flow slice; the scalars are convected passively here, with the mean flow's wave speeds. Every flux is written against an explicit n_mean, and reduces to the corresponding Euler_utils expression when there are no extra components. Nondimensionalization is the solver's: rho_inf = p_inf = 1, reference length 1, so T is only ever needed as the ratio (p/rho)/(p_inf/rho_inf). The heat flux is written in terms of p/rho, which removes the gas constant: q = -kappa grad T = -(gamma/(gamma-1)) (mu/Pr + mu_t/Pr_t) grad(p/rho) .. !! processed by numpydoc !! Functions --------- .. autoapisummary:: dragonfly_sim.utils.NS_utils.concat_state dragonfly_sim.utils.NS_utils.extended_boundary_flux dragonfly_sim.utils.NS_utils.extended_flux dragonfly_sim.utils.NS_utils.extended_hll_flux dragonfly_sim.utils.NS_utils.extended_normal_flux dragonfly_sim.utils.NS_utils.extra_components dragonfly_sim.utils.NS_utils.mean_flow dragonfly_sim.utils.NS_utils.primitive_gradients dragonfly_sim.utils.NS_utils.sutherland_viscosity dragonfly_sim.utils.NS_utils.viscous_flux dragonfly_sim.utils.NS_utils.viscous_stress dragonfly_sim.utils.NS_utils.vorticity_magnitude Module Contents --------------- .. py:function:: concat_state(U_mean, extras) A full state from a mean-flow vector and a list of scalars. .. !! processed by numpydoc !! .. py:function:: extended_boundary_flux(U, U_ext, n, gamma, n_mean) Euler_utils.boundary_flux on the full state. .. !! processed by numpydoc !! .. py:function:: extended_flux(U, gamma, n_mean) The inviscid flux tensor, (n_state, dim): Euler rows, then rho*phi*u. .. !! processed by numpydoc !! .. py:function:: extended_hll_flux(U_p, U_m, n, gamma, n_mean) hll_flux on the full state. The wave speeds come from the mean flow alone, and the same single-intermediate-state formula is applied to every component, so the mean-flow rows are exactly hll_flux and each scalar is upwinded with the fan of the flow carrying it. .. !! processed by numpydoc !! .. py:function:: extended_normal_flux(U, n, gamma, n_mean) .. py:function:: extra_components(U, n_mean) The transported scalars rho*phi_k of U, as a list. .. !! processed by numpydoc !! .. py:function:: mean_flow(U, n_mean) The mean-flow slice of the state expression U. .. !! processed by numpydoc !! .. py:function:: primitive_gradients(U, G, gamma, n_mean) grad(u), grad(p/rho) and grad(phi_k) from the state U and a tensor G standing in for grad(U), shape (n_state, dim). G is an argument rather than ufl.grad(U) because the interior-penalty terms evaluate the viscous flux with the jump tensor [U] (x) n in place of the gradient. Everything returned is linear in G. .. !! processed by numpydoc !! .. py:function:: sutherland_viscosity(U, gamma, n_mean, mu_inf, T_ratio_inf, S_ratio) Sutherland's law in the solver's units: mu/mu_inf = theta^(3/2) (1 + S) / (theta + S), theta = T/T_inf = (p/rho) / (p_inf/rho_inf), S = S_dim / T_inf_dim `T_ratio_inf` is p_inf/rho_inf. theta is floored so a transiently negative pressure cannot hand theta^(3/2) a negative base. .. !! processed by numpydoc !! .. py:function:: viscous_flux(U, G, gamma, n_mean, mu, mu_t, Pr, Pr_t, extra_fluxes=None, heat_flux=True) The viscous flux tensor F_v(U, G), shape (n_state, dim), linear in G: mass 0 momentum tau = (mu + mu_t)(grad u + grad u^T - 2/3 div u I) energy tau u - q scalars extra_fluxes(grad_phi, grad_rho), one row per scalar `mu` and `mu_t` are expressions of the state (not of G). heat_flux=False drops the conduction term, which is how the adiabatic wall imposes q.n = 0. .. !! processed by numpydoc !! .. py:function:: viscous_stress(grad_u, mu_eff) .. py:function:: vorticity_magnitude(grad_u, eps=1e-16) sqrt(2 W:W), W the antisymmetric part of grad(u). Regularized by eps inside the root so its derivative stays finite where the flow is irrotational (the whole free stream). .. !! processed by numpydoc !!