Code crashes when using ParticleMonitor and losses occur due to aperture element (shape mismatch in arrays)