Chemistry of the thermosphere and ionosphere