Heterotic Calabi-Yau compactifications with flux