A variational method for wave scattering from penetrable rough layers