コード例 #1
0
ファイル: viscous.py プロジェクト: dreamer2368/mirgecom
def diffusive_flux(state, grad_cv):
    r"""Compute the species diffusive flux vector, ($\mathbf{J}_{\alpha}$).

    The species diffusive flux is defined by:

    .. math::

        \mathbf{J}_{\alpha} = -\rho{d}_{(\alpha)}\nabla{Y_{\alpha}}~~
        (\mathtt{no~implied~sum}),

    with species diffusivities ${d}_{\alpha}$, and species mass
    fractions ${Y}_{\alpha}$.

    Parameters
    ----------
    state: :class:`~mirgecom.gas_model.FluidState`

        Full fluid conserved and thermal state

    grad_cv: :class:`~mirgecom.fluid.ConservedVars`

        Gradient of the fluid state

    Returns
    -------
    numpy.ndarray

        The species diffusive flux vector, $\mathbf{J}_{\alpha}$
    """
    return _compute_diffusive_flux(
        state.mass_density, state.species_diffusivity,
        species_mass_fraction_gradient(state.cv, grad_cv))
コード例 #2
0
def diffusive_flux(discr, eos, cv, grad_cv):
    r"""Compute the species diffusive flux vector, ($\mathbf{J}_{\alpha}$).

    The species diffusive flux is defined by:

    .. math::

        \mathbf{J}_{\alpha} = -\rho{d}_{(\alpha)}\nabla{Y_{\alpha}}~~
        (\mathtt{no~implied~sum}),

    with species diffusivities ${d}_{\alpha}$, and species mass
    fractions ${Y}_{\alpha}$.

    Parameters
    ----------
    discr: :class:`grudge.eager.EagerDGDiscretization`
        The discretization to use
    eos: :class:`~mirgecom.eos.GasEOS`
        A gas equation of state with a non-empty
        :class:`~mirgecom.transport.TransportModel`
    cv: :class:`~mirgecom.fluid.ConservedVars`
        Fluid state
    grad_cv: :class:`~mirgecom.fluid.ConservedVars`
        Gradient of the fluid state

    Returns
    -------
    numpy.ndarray
        The species diffusive flux vector, $\mathbf{J}_{\alpha}$
    """
    transport = eos.transport_model()

    grad_y = species_mass_fraction_gradient(discr, cv, grad_cv)
    d = transport.species_diffusivity(eos, cv)
    return -cv.mass * d.reshape(-1, 1) * grad_y
コード例 #3
0
def test_species_mass_gradient(actx_factory, dim):
    """Test gradY structure and values against exact."""
    actx = actx_factory()
    nel_1d = 4

    from meshmode.mesh.generation import generate_regular_rect_mesh
    mesh = generate_regular_rect_mesh(
        a=(1.0,) * dim, b=(2.0,) * dim, nelements_per_axis=(nel_1d,) * dim
    )

    order = 1

    discr = EagerDGDiscretization(actx, mesh, order=order)
    nodes = thaw(actx, discr.nodes())
    zeros = discr.zeros(actx)
    ones = zeros + 1

    nspecies = 2*dim
    mass = 2*ones  # make mass != 1
    energy = zeros + 2.5
    velocity = make_obj_array([ones for _ in range(dim)])
    mom = mass * velocity
    # assemble y so that each one has simple, but unique grad components
    y = make_obj_array([ones for _ in range(nspecies)])
    for idim in range(dim):
        ispec = 2*idim
        y[ispec] = ispec*(idim*dim+1)*sum([(iidim+1)*nodes[iidim]
                                           for iidim in range(dim)])
        y[ispec+1] = -y[ispec]
    species_mass = mass*y

    cv = make_conserved(dim, mass=mass, energy=energy, momentum=mom,
                        species_mass=species_mass)
    from grudge.op import local_grad
    grad_cv = local_grad(discr, cv)

    from mirgecom.fluid import species_mass_fraction_gradient
    grad_y = species_mass_fraction_gradient(cv, grad_cv)

    assert grad_y.shape == (nspecies, dim)
    from meshmode.dof_array import DOFArray
    assert type(grad_y[0, 0]) == DOFArray

    def inf_norm(x):
        return actx.to_numpy(discr.norm(x, np.inf))

    tol = 1e-11
    for idim in range(dim):
        ispec = 2*idim
        exact_grad = np.array([(ispec*(idim*dim+1))*(iidim+1)
                                for iidim in range(dim)])
        assert inf_norm(grad_y[ispec] - exact_grad) < tol
        assert inf_norm(grad_y[ispec+1] + exact_grad) < tol