Theoretical studies of gas mixing in the lung