{"id":22576438,"url":"https://github.com/localhost-four/ising","last_synced_at":"2025-03-28T15:43:59.021Z","repository":{"id":251117629,"uuid":"836445536","full_name":"localhost-four/Ising","owner":"localhost-four","description":null,"archived":false,"fork":false,"pushed_at":"2024-07-31T21:41:23.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-02T15:53:41.379Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://localhost-four.github.io/Ising/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/localhost-four.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-31T21:40:26.000Z","updated_at":"2024-07-31T21:42:44.000Z","dependencies_parsed_at":"2024-08-01T01:56:04.128Z","dependency_job_id":null,"html_url":"https://github.com/localhost-four/Ising","commit_stats":null,"previous_names":["localhost-four/ising"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localhost-four%2FIsing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localhost-four%2FIsing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localhost-four%2FIsing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localhost-four%2FIsing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/localhost-four","download_url":"https://codeload.github.com/localhost-four/Ising/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246057568,"owners_count":20716952,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-08T04:06:58.719Z","updated_at":"2025-03-28T15:43:58.998Z","avatar_url":"https://github.com/localhost-four.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ising\nThis is a P5.js animation of a simple [Ising model](https://en.wikipedia.org/wiki/Ising_model) for a ferromagnet on a two-dimensional square lattice. This program visualizes magnetic domains and can simulate temperature or magnetic field curves. \nIf wanted, the simulation data and indiviual frames are automatically saved for later evaluation or presentation. \n(In particular, the captured frames can be used to create a video animation.)\n\n## Physical Model\nThe state of a Ising ferromagnet is described by a discrete spin vector S \n\n\tS = (s_1, s_2, ..., s_N) ∈ {-1, +1}^N\n\t\nwhere each spin s_i can assume only two possible values -1 or +1 (spin-down or spin-up). The energy of a certain state is given by the dimensionless Hamilitonian (J = mu = 1):\n\n\tH(S) = - ∑_\u003ci,j\u003e s_i s_j - h ∑_i s_i = - ∑_i (h_i + h) s_i\n\t\nwhere the first sum is taken over all pairs i,j of adjacent spins. h denotes the external magnetic field and h_i is the so-called exchange field. In thermodynamic equilibrium, the systems shows a Boltzmann distribution (k = 1):\n\n\tp(S) = const * exp( - H(S) / T) \n\nwhere T is the temperature of the spin system. \n\n## Metropolis Algorithm\nThe Ising system is simulated by a Markov chain of spin states S(t) as a function of discrete time t, which fulfills the Boltzmann distributions. The algorithm can summarized by the following:\n\n1. Choose an initial spin configuration S(0)\n2. Choose a random i and calculate the energy change for a single spin-flip s_i → -s_i:\n   ```\n\t∆E = - 2 s_i (h_i + h)\n   ```\t\n3. Attempt a spin-flip with the transition probability\n   ```\n\t                ┌\n\t                │ 1          \t∆E ≥ 0\n\tp(s_i → -s_i) = ┤\n\t                │ exp(∆E / T)\t∆E \u003c 0\n\t                └\n   ```\n   For this, generate a random number r ∈ [0,1] and flip the spin, if r \u003c p(s_i → -s_i). Otherwise keep the current state.\n4. Go to 2. and repeat\n\n## Usage\n\nIsing is called with a settings object as a single argument, that summarizes all parameters of the simulation:\n```javascript\nvar mySettings = { \n\twidth:            Number                                  // width of the spin lattice \n\theight:           Number,                                 // height of the spin lattice\n\tmcStepsPerFrame:  Number,                                 // number of iterations in a simulation step\n\taveragingFrames:  Number,                                 // number of simulation steps for averaging \n\ttemperature:      Number,                                 // initial temperature \n\tmagneticField:    Number,                                 // initial magnetic field \n\trandomizeLattice: Boolean,                                // initial spin configuration \n\tloopMode:         'TSWEEP'|'TLOOP'|'HSWEEP'|'HLOOP'|null, // specifies temperature/field curve\n\tloopTargetValue:  Number,                                 // target value for temperature/field \n\tloopIncrement:    Number,                                 // step size for temperature/field \n\timageFile:        String|null,                            // file name for animation frames\n\tdataFile:         String|null                             // file name for the simulation data\n};\nvar mySimulation = new Ising(mySettings);\n```\nOnly the parameters imageFile, dataFile and loopMode are optional and should be set to null if not used. In order to excute and animate the simulation, the function simulationStep() must be called in the draw function:\n```javascript\nfunction draw() {\n\tmySimulation.simulationStep();\n}\n```\nImage and data files are automatically saved to the local download directory.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flocalhost-four%2Fising","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flocalhost-four%2Fising","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flocalhost-four%2Fising/lists"}