Flux quantization on a lattice