Optimal control of laser beams for propagation through a turbulent medium