Stochastic wave finite element quadratic formulation for periodic media: 1D and 2D