Giter Club home page Giter Club logo

xy_model_sim's Introduction

XY Model with Python

This is a simple code for performing Monte Carlo simulations of the XY model using Python. The Monte Carlo is performed with Wolff cluster updates.

To get started, create an XY model object as follows.

# Import XY model code
import xy_model as xym

# "J" coupling (J/k*T)
J = <value of J>

# Linear dimension of lattice (total number of sites = N*N)
N = <value of N>

# Create XY model simulation object
sim_obj = xym.XYSimulation(J, N)

There are optional arguments that specify the starting lattice, random number seeds, and the locations on disk to save or load spin configurations (if the user chooses to load or save any at all). The options for the "start" are "hot" or "cold", but if "config" is not None, the code will pick up a lattice located in "load_loc" and start from that lattice. To do a single cluster update, simple invoke the "cluster_update" method as follows.

# Do a single cluster update
sim_obj.cluster_update()

In the "cluster_update" method, you can choose the site to start the cluster from (if "None", then the starting site is random), whether or not you want to save the updated configuration (default is "save = False"), and whether or not you want the method to print some information out once it is done. You can also make simple measurements at any time as follows.

# Measure energy
sim_obj.energ()

# Measure magnetization
sim_obj.magn()

# Print out values of energy and magnetization
print(sim_obj.energy, sim_obj.mag)

And that's about it!

xy_model_sim's People

Contributors

ctpeterson avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.