From 6c182752808e0c5ff5e844450063deebc31ba41b Mon Sep 17 00:00:00 2001 From: Kees van Kempen Date: Tue, 18 Oct 2022 16:42:21 +0200 Subject: [PATCH] 06: Draft ugh --- Exercise sheet 6/exercise_sheet_06.ipynb | 38 ++++++++++++++++++------ 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/Exercise sheet 6/exercise_sheet_06.ipynb b/Exercise sheet 6/exercise_sheet_06.ipynb index 2c83051..4dc034e 100644 --- a/Exercise sheet 6/exercise_sheet_06.ipynb +++ b/Exercise sheet 6/exercise_sheet_06.ipynb @@ -20,13 +20,13 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "b388fbcf", "metadata": {}, "outputs": [], "source": [ - "NAME = \"\"\n", - "NAMES_OF_COLLABORATORS = \"\"" + "NAME = \"Kees van Kempen\"\n", + "NAMES_OF_COLLABORATORS = \"Bart Steeman\"" ] }, { @@ -62,7 +62,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "cb41d2a1", "metadata": { "deletable": false, @@ -219,7 +219,18 @@ } }, "source": [ - "YOUR ANSWER HERE" + "The condition for detailed balance is $$\\frac{P(s\\rightarrow s')}{P(s'\\rightarrow s)}=\\frac{\\pi(s')}{\\pi(s)}.$$\n", + "Let's work to that expression by following the idea of the proof for the Ising model proof.\n", + "\n", + "Starting from the left-hand side, consider the same cluster from the same seed and unit vector $\\hat{n}$ but from different states $s$ and $s'$. Flipping between $s$ and $s'$ is done by the same cluster $C$. The probability of this happening is given by the boundaries of the clusters, namely that they are not added to the cluster, with probability $1 - p_{add}$ per boundary site. Again, like in the Ising model proof, we take the boundary of $C$ to be of $m + n$ length with $m$ the number of aligned sites and $n$ the number of anti-aligned sites. This gives a ratio $$\\frac{P(s\\rightarrow s')}{P(s'\\rightarrow s)} = (1-p_{add})^{m-n}.$$\n", + "\n", + "For the right-hand side, $$\\frac{\\pi(s')}{\\pi(s)} = e^{\\beta \\left[H_{XY}(s)-H_{XY}(s')\\right]}$$ just from the definition of $\\pi$.\n", + "This difference in energy we can write as\n", + "$$\n", + "H_{XY}(s)-H_{XY}(s') = \\sum_{ \\in boundary} \\left[ s_i \\cdot s_j - s'_i \\cdot s_j \\right]\n", + " = \\sum_{ \\in boundary} 2(s_i \\cdot \\hat{n})(s_j \\cdot \\hat{n})\n", + "$$\n", + "by summing over all pairs $i, j$ on the boundary of $C$, with $i \\in C$ and $j$ an outside neigbour, as pairs not across the boundary do not give rise to an energy change. The last step is due to" ] }, { @@ -245,7 +256,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "id": "6e4a6d63", "metadata": { "deletable": false, @@ -269,8 +280,17 @@ "def xy_cluster_flip(state,seed,nhat,beta):\n", " '''Perform a cluster move with specified seed and vector nhat on the state at temperature beta.'''\n", " w = len(state)\n", - " # YOUR CODE HERE\n", - " raise NotImplementedError()\n", + " spin = state[seed]\n", + " state[seed] = state[seed] - 2*np.dot(state[seed], nhat)*nhat\n", + " cluster_size = 1\n", + " unvisited = deque([seed]) # use a deque to efficiently track the unvisited cluster sites\n", + " while unvisited: # while unvisited sites remain\n", + " site = unvisited.pop() # take one and remove from the unvisited list\n", + " for nbr in neighboring_sites(site,w):\n", + " if state[nbr] == spin and rng.uniform() < p_add:\n", + " state[nbr] = -spin\n", + " unvisited.appendleft(nbr)\n", + " cluster_size += 1\n", " return cluster_size\n", "\n", "def xy_cluster_move(state,beta):\n", @@ -666,7 +686,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" },