A model for reactive magnetron sputtering