{"id":39646730,"url":"https://github.com/davifeliciano/ising_animate","last_synced_at":"2026-01-18T09:06:19.075Z","repository":{"id":62571786,"uuid":"411065248","full_name":"davifeliciano/ising_animate","owner":"davifeliciano","description":"Monte Carlo simulation of the Ising Model using the Metropolis Algorithm","archived":false,"fork":false,"pushed_at":"2021-10-26T20:17:48.000Z","size":83765,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-20T08:55:45.596Z","etag":null,"topics":["animation","ising","ising-model","ising-model-2d","ising-spin-models","mathematics","monte-carlo","physics","physics-simulation","python","simulation","visualization"],"latest_commit_sha":null,"homepage":"https://davifeliciano.github.io/ising_animate/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davifeliciano.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}},"created_at":"2021-09-27T22:49:12.000Z","updated_at":"2024-01-20T09:26:37.000Z","dependencies_parsed_at":"2022-11-03T18:25:55.486Z","dependency_job_id":null,"html_url":"https://github.com/davifeliciano/ising_animate","commit_stats":null,"previous_names":["davifeliciano/ising_model"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/davifeliciano/ising_animate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davifeliciano%2Fising_animate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davifeliciano%2Fising_animate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davifeliciano%2Fising_animate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davifeliciano%2Fising_animate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davifeliciano","download_url":"https://codeload.github.com/davifeliciano/ising_animate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davifeliciano%2Fising_animate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28534154,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T00:39:45.795Z","status":"online","status_checked_at":"2026-01-18T02:00:07.578Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["animation","ising","ising-model","ising-model-2d","ising-spin-models","mathematics","monte-carlo","physics","physics-simulation","python","simulation","visualization"],"created_at":"2026-01-18T09:06:18.487Z","updated_at":"2026-01-18T09:06:19.063Z","avatar_url":"https://github.com/davifeliciano.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ising_animate\nA Python Package to easily generate animations of the [Ising Model](https://en.wikipedia.org/wiki/Ising_model) \nusing the [Metropolis Algorithm](https://en.wikipedia.org/wiki/Metropolis%E2%80%93Hastings_algorithm), the most\ncommonly used Markov Chain Monte Carlo method to calculate estimations for this system.\n\n![ising_2021-10-12_15-14-51](https://user-images.githubusercontent.com/26972046/137008265-33f7b181-7047-4afe-b044-ac5f856df73c.gif)\n## Installation\n\nBe sure to have Python 3.6 or newer installed on your machine. Then you can simply use pip to install the package and its dependencies.\n```\npip install ising_animate\n```\n## Usage\n\n### Command Line Tool\nThis package can be used as a command line tool to generate the desired animations. For instance, the animation above was created using the command\n\n```\npython -m ising_animate\n```\nYou can specify the desired size, initial state, temperature or field using some command line options. For example, the command\n```\npython -m ising_animate --size 256 --temp 1.5 --field 1.0 --init-state \"down\" --time-series\n```\nyields\n![ising_2021-10-12_15-26-03](https://user-images.githubusercontent.com/26972046/137010154-bc7d30c0-7ab3-44a9-b8a4-8e76f3e5b2c7.gif)\n\nFor a full description of all the available options, type in ```python -m ising_animate --help```.\n### Import\nWhen imported, there are four classes of objects that can be used to create custom animations: \n* [Ising](https://davifeliciano.github.io/ising_animate/ising.html#ising_animate.ising.Ising): just the core implementation of the Ising Model, no animation;\n* [AnimatedIsing](https://davifeliciano.github.io/ising_animate/ising.html#ising_animate.ising.AnimatedIsing): an animation of the Ising Model with both temperature and external magnetic field held at fixed values;\n* [CoolingAnimatedIsing](https://davifeliciano.github.io/ising_animate/ising.html#ising_animate.ising.CoolingAnimatedIsing): an animation of the Ising Model with the temperature droping (or raising) exponentially to a target value, at a given rate;\n* [DynamicAnimatedIsing](https://davifeliciano.github.io/ising_animate/ising.html#ising_animate.ising.DynamicAnimatedIsing): an animation of the Ising Model with temperature and external magnetic field both described by given functions of time.\n\nThe usage of all of them are very similar. You just have to create an instance with the desired arguments...\n```python\nfrom ising_animate import DynamicAnimatedIsing\nfrom math import sin\n\nframes = 100\n\ndynamic = DynamicAnimatedIsing(\n    shape=(256, 256),                # the shape of the lattice\n    temp=lambda t: 1.0 + 0.3 * t,    # temperature as a function of time\n    field=lambda t: sin(t),          # external magnetic field as a function of time\n    time_series=True,                # plot evolution of physical quantities over time\n    interval=100,                    # interval of each frame\n    frames=frames,                   # amount of frames in the animation\n)\n```\nand the animation itself is now given by a matplotlib [FuncAnimation](https://matplotlib.org/stable/api/_as_gen/matplotlib.animation.FuncAnimation.html)\nobject stored at ```dynamic.animation```. This object has a [save](https://matplotlib.org/stable/api/_as_gen/matplotlib.animation.Animation.html#matplotlib.animation.Animation.save) \nmethod of which the most important arguments is the output filename and the fps of the animation. The fps can be chosen as you wish,\nbut the natural value is 1000 (the amount of milliseconds in one second) divided by the interval of each frame. So, in that case, fps is 10.\n```python\ndynamic.animation.save(\"outfile.gif\", fps=10)\n```\n![outfile](https://user-images.githubusercontent.com/26972046/137047228-f8a0f75c-fbae-4320-8416-c1aff0503548.gif)\nAnother useful feature of the save method is the possibility to pass a progress callback function that\nwill be called after drawing each frame, with the count of already drawn frames and the total number of frames on\nthe animation. This makes easy to use a package like progressbar2 to show the progress in a progress bar.\n```python\nimport progressbar\n\nwith progressbar.ProgressBar(max_value=frames) as bar:\n    dynamic.animation.save(\n        \"outfile.gif\",\n        fps=10,\n        progress_callback=lambda i, n: bar.update(i),\n    )\n```\nTo install progressbar2, use the following command in a terminal.\n```\npip install progressbar2\n```\nTo view a full description of each class, take a look at the [full documentation](https://davifeliciano.github.io/ising_animate/index.html).\n\n## Examples\n\nThere is a subpackage ```ising_animate.examples``` with some usage examples of usage of this library. The example \nabove is one of them, and can be run using \n\n```\npython -m ising_animate.examples.dynamic\n```\n\nAnother interesting one can be run with\n\n```\npython -m ising_animate.examples.heating\n```\n\nwhich yields two plots with the dependency of the mean energy and the specific heat density with the temperature. \nThis example is a good illustration of the phase thansition that occurs at the temperature of 2.27, in energy units.\n\n![heating_2021-10-26_17-01](https://user-images.githubusercontent.com/26972046/138952988-0d64fb42-d1e0-46ec-b3b8-4755efcbc47d.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavifeliciano%2Fising_animate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavifeliciano%2Fising_animate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavifeliciano%2Fising_animate/lists"}