Dynamic homogenisation of Maxwell's equations with applications to photonic crystals and localised waveforms on gratings