def METHOD_NAME(
    phase,
    P='pore.pressure',
    T='pore.temperature',
    MW='param.molecular_weight',
):
    r"""
    Uses ideal gas law to calculate the mass density of an ideal gas
    Parameters
    ----------
    %(phase)s
    %(T)s
    %(P)s
    %(MW)s
    Returns
    -------
    """
    P = phase[P]
    T = phase[T]
    try:
        # If phase is a pure species, it should have molecular weight in params
        MW = phase[MW]
    except KeyError:
        # Otherwise, get the mole weighted average value
        MW = phase.get_mix_vals(MW)
    R = 8.314462618  # J/(mol.K)
    value = P/(R*T)*(MW/1000)  # Convert to kg/m3
    return value