Grand canonical generative diffusion model for crystalline phases and grain boundaries