This is a code for 2 dimensional ising Model which i have used for my project. Note that in my project i used non-zero external Magnetic field so it wont give you second order phase transition rather a new phenomena called crossover phenomena. Where order parameter varies very slowly and it goes to new phase without giving discontinuity in your thermodynamic quantities like specific heat and Susceptibiliity. There are other codes for Bragg-William approximations and Bethe approximation where we solved the transcendal equations to find magnetization and Susceptibility and comapred with monte carlo results.
Check pathria's 13 chapter 'scaling and universality' to get the equation which were used in the code.