A library for Monte Carlo simulations based on 2/3D square lattices