Skip to content

Commit

Permalink
build based on fa8e7f2
Browse files Browse the repository at this point in the history
  • Loading branch information
Documenter.jl committed Aug 29, 2023
1 parent 62517bd commit 3f56362
Show file tree
Hide file tree
Showing 19 changed files with 3,075 additions and 83 deletions.
941 changes: 941 additions & 0 deletions dev/assets/notebooks/fei2_classical.ipynb

Large diffs are not rendered by default.

766 changes: 766 additions & 0 deletions dev/assets/notebooks/fei2_tutorial.ipynb

Large diffs are not rendered by default.

179 changes: 179 additions & 0 deletions dev/assets/notebooks/ising2d.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
{
"cells": [
{
"cell_type": "markdown",
"source": [
"# Classical Ising model\n",
"\n",
"This tutorial illustrates simulation of the classical 2D Ising model."
],
"metadata": {}
},
{
"outputs": [],
"cell_type": "code",
"source": [
"using Sunny, Plots"
],
"metadata": {},
"execution_count": null
},
{
"cell_type": "markdown",
"source": [
"Sunny expects a 3D `Crystal` unit cell. To model a square lattice, we\n",
"create an orthogonal unit cell where the $z$-spacing is distinct from the $x$\n",
"and $y$ spacing."
],
"metadata": {}
},
{
"outputs": [],
"cell_type": "code",
"source": [
"a = 1\n",
"latvecs = lattice_vectors(a,a,10a,90,90,90)\n",
"crystal = Crystal(latvecs, [[0,0,0]])"
],
"metadata": {},
"execution_count": null
},
{
"cell_type": "markdown",
"source": [
"Create a `System` of spins with linear size `L` in the $x$ and $y$\n",
"directions, and only one layer in the $z$ direction. The option `:dipole`\n",
"means that the system will store Heisenberg spins, as opposed to SU($N$)\n",
"coherent states. Polarize the initial spin configuration using\n",
"`polarize_spins!`. Following the Ising convention, we will restrict\n",
"these spins to the $z$-axis and give them magnitude $S=1$.\n",
"\n",
"By default, Sunny uses physical units, e.g. magnetic field in tesla. Here we\n",
"specify an alternative `Units` system, so that the Zeeman coupling\n",
"between the spin dipole $𝐬$ and an external field $𝐁$ has the dimensionless\n",
"form $-𝐁⋅𝐬$."
],
"metadata": {}
},
{
"outputs": [],
"cell_type": "code",
"source": [
"L = 128\n",
"sys = System(crystal, (L,L,1), [SpinInfo(1, S=1, g=1)], :dipole, units=Units.theory, seed=0)\n",
"polarize_spins!(sys, (0,0,1))"
],
"metadata": {},
"execution_count": null
},
{
"cell_type": "markdown",
"source": [
"Use `set_exchange!` to include a ferromagnetic Heisenberg interaction\n",
"along nearest-neighbor bonds. The `Bond` below connects two spins\n",
"displaced by one lattice constant in the $x$-direction. This interaction will\n",
"be propagated to all nearest-neighbors bonds in the system, consistent with\n",
"the symmetries of the square lattice."
],
"metadata": {}
},
{
"outputs": [],
"cell_type": "code",
"source": [
"set_exchange!(sys, -1.0, Bond(1,1,(1,0,0)))"
],
"metadata": {},
"execution_count": null
},
{
"cell_type": "markdown",
"source": [
"If an external field is desired, it can be set using\n",
"`set_external_field!`."
],
"metadata": {}
},
{
"outputs": [],
"cell_type": "code",
"source": [
"B = 0\n",
"set_external_field!(sys, (0,0,B))"
],
"metadata": {},
"execution_count": null
},
{
"cell_type": "markdown",
"source": [
"The critical temperature for the Ising model is known analytically."
],
"metadata": {}
},
{
"outputs": [],
"cell_type": "code",
"source": [
"Tc = 2/log(1+√2)"
],
"metadata": {},
"execution_count": null
},
{
"cell_type": "markdown",
"source": [
"Use a `LocalSampler` to perform `nsweeps` Monte Carlo sweeps. A sweep\n",
"consists of, on average, one trial update per spin in the system. Each\n",
"proposed update is accepted or rejected according to the Metropolis acceptance\n",
"probability. As its name suggests, the `propose_flip` function will\n",
"only propose pure spin flips, $𝐬 \\rightarrow -𝐬$."
],
"metadata": {}
},
{
"outputs": [],
"cell_type": "code",
"source": [
"nsweeps = 4000\n",
"sampler = LocalSampler(kT=Tc, propose=propose_flip)\n",
"for i in 1:nsweeps\n",
" step!(sys, sampler)\n",
"end"
],
"metadata": {},
"execution_count": null
},
{
"cell_type": "markdown",
"source": [
"Plot the Ising spins by extracting the $z$-component of the dipoles"
],
"metadata": {}
},
{
"outputs": [],
"cell_type": "code",
"source": [
"heatmap(reshape([s.z for s in sys.dipoles], (L,L)))"
],
"metadata": {},
"execution_count": null
}
],
"nbformat_minor": 3,
"metadata": {
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.9.3"
},
"kernelspec": {
"name": "julia-1.9",
"display_name": "Julia 1.9.3",
"language": "julia"
}
},
"nbformat": 4
}
Loading

0 comments on commit 3f56362

Please sign in to comment.