Text this: A spectral model for simulation of tides in the middle atmosphere .1. Formulation