http://www.lps.ens.fr/~krauth/index.php?title=Special:Recentchanges&hideminor=1&days=30&limit=500&hidebots=&hideanons=1&feed=atomWerner KRAUTH - Recent changes [en]2024-03-17T02:35:02ZTrack the most recent changes to the wiki on this page.MediaWiki 1.6.12http://www.lps.ens.fr/~krauth/index.php/Category:Oxford_2024Category:Oxford 20242024-03-05T17:13:08Z<p></p>
<p><b>New page</b></p><div>These are programs that I presented in my Lectures on Algorithms in theoretical physics at the University of Oxford, in 2024.</div>Wernerhttp://www.lps.ens.fr/~krauth/index.php/Oxford_Lectures_2024Oxford Lectures 20242024-03-05T13:49:42Z<p></p>
<table border='0' width='98%' cellpadding='0' cellspacing='4' style="background-color: white;">
<tr>
<td colspan='2' width='50%' align='center' style="background-color: white;">Revision as of 13:49, 5 March 2024</td>
<td colspan='2' width='50%' align='center' style="background-color: white;">Current revision</td>
</tr>
<tr><td colspan="2" align="left"><strong>Line 13:</strong></td>
<td colspan="2" align="left"><strong>Line 13:</strong></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">[http://www.lps.ens.fr/%7Ekrauth/images/b/b4/WK_Lecture7_Oxford2024.pdf Here are the notes for the seventh lecture.]</td><td> </td><td style="background: #eee; font-size: smaller;">[http://www.lps.ens.fr/%7Ekrauth/images/b/b4/WK_Lecture7_Oxford2024.pdf Here are the notes for the seventh lecture.]</td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;">[[Two_cycles.py| Two_cycles.py]] [[direct_N_bosons.py| Direct_bosons.py]]</td><td>+</td><td style="background: #cfc; font-size: smaller;"> </td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;">[[Two_cycles.py| Two_cycles.py]] </td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"> </td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;">[[direct_N_bosons.py| Direct_bosons<span style="color: red; font-weight: bold;">.py]]</span></td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"> </td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"><span style="color: red; font-weight: bold;">[http://www.lps.ens.fr/%7Ekrauth/images/f/fe/WK_Lecture8_Oxford2024.pdf Here are the notes for the eighth lecture.]</span></td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"> </td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"><span style="color: red; font-weight: bold;">[[Enumerate_ising.py|Enumerate_ising.py]]</span></td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"> </td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"><span style="color: red; font-weight: bold;">[[Markov_ising.py|Markov_ising.py]]</span></td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"> </td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"><span style="color: red; font-weight: bold;">[[Heatbath_ising.py|Heatbath_ising.py]]</span></td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"> </td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"><span style="color: red; font-weight: bold;">[[Cluster_ising.py| Cluster_ising</span>.py]]</td></tr>
</table>
Wernerhttp://www.lps.ens.fr/~krauth/index.php/Special:Log/uploadSpecial:Log/upload2024-03-05T13:35:55Z<p>uploaded "[[Image:WK Lecture8 Oxford2024.pdf]]"</p>
Wernerhttp://www.lps.ens.fr/~krauth/index.php/Heatbath_ising.pyHeatbath ising.py2024-03-05T12:58:40Z<p></p>
<table border='0' width='98%' cellpadding='0' cellspacing='4' style="background-color: white;">
<tr>
<td colspan='2' width='50%' align='center' style="background-color: white;">Revision as of 12:58, 5 March 2024</td>
<td colspan='2' width='50%' align='center' style="background-color: white;">Current revision</td>
</tr>
<tr><td colspan="2" align="left"><strong>Line 1:</strong></td>
<td colspan="2" align="left"><strong>Line 1:</strong></td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;">This page presents the Python3 program heatbath_ising.py, a Markov-chain algorithm for the Ising model on an <span style="color: red; font-weight: bold;">LXL </span>square lattice in two dimensions<span style="color: red; font-weight: bold;">, </span>with periodic boundary conditions. This program uses the heatbath algorithm.</td><td>+</td><td style="background: #cfc; font-size: smaller;">This page presents the Python3 program heatbath_ising.py, a Markov-chain algorithm for the Ising model on an <span style="color: red; font-weight: bold;">L x L </span>square lattice in two dimensions with periodic boundary conditions. This program uses the heatbath algorithm.</td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">__FORCETOC__</td><td> </td><td style="background: #eee; font-size: smaller;">__FORCETOC__</td></tr>
</table>
Wernerhttp://www.lps.ens.fr/~krauth/index.php/Enumerate_ising.pyEnumerate ising.py2024-03-05T09:30:20Z<p></p>
<table border='0' width='98%' cellpadding='0' cellspacing='4' style="background-color: white;">
<tr>
<td colspan='2' width='50%' align='center' style="background-color: white;">Revision as of 09:30, 5 March 2024</td>
<td colspan='2' width='50%' align='center' style="background-color: white;">Current revision</td>
</tr>
<tr><td colspan="2" align="left"><strong>Line 1:</strong></td>
<td colspan="2" align="left"><strong>Line 1:</strong></td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;">This page presents the program enumerate_ising.py, an enumeration algorithm for the Ising model using the Gray code.</td><td>+</td><td style="background: #cfc; font-size: smaller;">This page presents the <span style="color: red; font-weight: bold;">Python3 </span>program enumerate_ising.py, an enumeration algorithm for the Ising model using the Gray code<span style="color: red; font-weight: bold;">, on the two-dimensional L x L lattice with periodic boundary conditions. As it stands, the program is only really suited for L=2 and L=4. As Python is a bit slow, it will take a few hours to terminate for L=6</span>. </td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">__FORCETOC__</td><td> </td><td style="background: #eee; font-size: smaller;">__FORCETOC__</td></tr>
<tr><td colspan="2" align="left"><strong>Line 27:</strong></td>
<td colspan="2" align="left"><strong>Line 27:</strong></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"> E += 2 * h * S[k - 1]</td><td> </td><td style="background: #eee; font-size: smaller;"> E += 2 * h * S[k - 1]</td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"> S[k - 1] *= -1</td><td> </td><td style="background: #eee; font-size: smaller;"> S[k - 1] *= -1</td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;"> print S, E</td><td>+</td><td style="background: #cfc; font-size: smaller;"> print<span style="color: red; font-weight: bold;">(</span>S, E<span style="color: red; font-weight: bold;">)</span></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">=Version=</td><td> </td><td style="background: #eee; font-size: smaller;">=Version=</td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">See history for version information.</td><td> </td><td style="background: #eee; font-size: smaller;">See history for version information.</td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;">[[Category:Python]] [[Category:<span style="color: red; font-weight: bold;">Honnef_2015</span>]] [[Category:MOOC_SMAC]]</td><td>+</td><td style="background: #cfc; font-size: smaller;">[[Category:Python]] [[Category:<span style="color: red; font-weight: bold;">Oxford_2024</span>]] [[Category:MOOC_SMAC]]</td></tr>
</table>
Wernerhttp://www.lps.ens.fr/~krauth/index.php/Markov_ising.pyMarkov ising.py2024-03-04T22:40:47Z<p>/* Version */ </p>
<table border='0' width='98%' cellpadding='0' cellspacing='4' style="background-color: white;">
<tr>
<td colspan='2' width='50%' align='center' style="background-color: white;">Revision as of 22:40, 4 March 2024</td>
<td colspan='2' width='50%' align='center' style="background-color: white;">Current revision</td>
</tr>
<tr><td colspan="2" align="left"><strong>Line 1:</strong></td>
<td colspan="2" align="left"><strong>Line 1:</strong></td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;">This page presents the program markov_ising.py, a Markov-chain algorithm for the Ising model on an LXL square lattice in two dimensions, with periodic boundary conditions. </td><td>+</td><td style="background: #cfc; font-size: smaller;">This page presents the <span style="color: red; font-weight: bold;">Python3 </span>program markov_ising.py, a Markov-chain algorithm for the Ising model on an LXL square lattice in two dimensions, with periodic boundary conditions<span style="color: red; font-weight: bold;">. The program uses the Metropolis algorithm</span>.</td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">__FORCETOC__</td><td> </td><td style="background: #eee; font-size: smaller;">__FORCETOC__</td></tr>
<tr><td colspan="2" align="left"><strong>Line 38:</strong></td>
<td colspan="2" align="left"><strong>Line 38:</strong></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">See history for version information.</td><td> </td><td style="background: #eee; font-size: smaller;">See history for version information.</td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;">[[Category:Python]] [[Category:<span style="color: red; font-weight: bold;">Honnef_2015</span>]] [[Category:MOOC_SMAC]]</td><td>+</td><td style="background: #cfc; font-size: smaller;">[[Category:Python]] [[Category:<span style="color: red; font-weight: bold;">Oxford_2024</span>]] [[Category:MOOC_SMAC]]</td></tr>
</table>
Wernerhttp://www.lps.ens.fr/~krauth/index.php/Cluster_ising.pyCluster ising.py2024-03-04T22:38:41Z<p></p>
<table border='0' width='98%' cellpadding='0' cellspacing='4' style="background-color: white;">
<tr>
<td colspan='2' width='50%' align='center' style="background-color: white;">Revision as of 22:38, 4 March 2024</td>
<td colspan='2' width='50%' align='center' style="background-color: white;">Current revision</td>
</tr>
<tr><td colspan="2" align="left"><strong>Line 1:</strong></td>
<td colspan="2" align="left"><strong>Line 1:</strong></td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;">This page presents the program cluster_ising.py, the Wolff cluster algorithm for the Ising model on an LxL square lattice in two dimensions</td><td>+</td><td style="background: #cfc; font-size: smaller;">This page presents the <span style="color: red; font-weight: bold;">Python3 </span>program cluster_ising.py, the Wolff cluster algorithm for the Ising model on an LxL square lattice in two dimensions</td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">__FORCETOC__</td><td> </td><td style="background: #eee; font-size: smaller;">__FORCETOC__</td></tr>
<tr><td colspan="2" align="left"><strong>Line 5:</strong></td>
<td colspan="2" align="left"><strong>Line 5:</strong></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">=Program=</td><td> </td><td style="background: #eee; font-size: smaller;">=Program=</td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;"></td><td colspan="2"> </td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;"></td><td colspan="2"> </td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;"></td><td colspan="2"> </td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr>
<tr><td colspan="2" align="left"><strong>Line 34:</strong></td>
<td colspan="2" align="left"><strong>Line 31:</strong></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"> for j in Cluster:</td><td> </td><td style="background: #eee; font-size: smaller;"> for j in Cluster:</td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"> S[j] *= -1</td><td> </td><td style="background: #eee; font-size: smaller;"> S[j] *= -1</td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;"> </td><td colspan="2"> </td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">=Version=</td><td> </td><td style="background: #eee; font-size: smaller;">=Version=</td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">See history for version information.</td><td> </td><td style="background: #eee; font-size: smaller;">See history for version information.</td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;">[[Category:Python]] [[Category:<span style="color: red; font-weight: bold;">Honnef_2015</span>]] [[Category:MOOC_SMAC]]</td><td>+</td><td style="background: #cfc; font-size: smaller;">[[Category:Python]] [[Category:<span style="color: red; font-weight: bold;">Oxford_2024</span>]] [[Category:MOOC_SMAC]]</td></tr>
</table>
Wernerhttp://www.lps.ens.fr/~krauth/index.php/Heatbath_ising.pyHeatbath ising.py2024-03-04T22:37:15Z<p></p>
<p><b>New page</b></p><div>This page presents the Python3 program heatbath_ising.py, a Markov-chain algorithm for the Ising model on an LXL square lattice in two dimensions, with periodic boundary conditions. This program uses the heatbath algorithm.<br />
<br />
__FORCETOC__<br />
=Description=<br />
The program is described in my 2024 Oxford Lecture No 8, and also in my book. This version of the program estimates the energy per particle, and the specific heat. <br />
=Program=<br />
<br />
<br />
import random, math<br />
<br />
L = 6<br />
N = L * L<br />
nbr = {i : ((i // L) * L + (i + 1) % L, (i + L) % N,<br />
(i // L) * L + (i - 1) % L, (i - L) % N) \<br />
for i in range(N)}<br />
nsteps = 10000000<br />
beta = 1.0<br />
S = [random.choice([-1, 1]) for site in range(N)]<br />
E = -0.5 * sum(S[k] * sum(S[nn] for nn in nbr[k]) \<br />
for k in range(N))<br />
E_tot, E2_tot = 0.0, 0.0<br />
for step in range(nsteps):<br />
k = random.randint(0, N - 1)<br />
Upsilon = random.uniform(0.0, 1.0)<br />
h = sum(S[nn] for nn in nbr[k])<br />
Sk_old = S[k]<br />
S[k] = -1<br />
if Upsilon < 1.0 / (1.0 + math.exp(-2.0 * beta * h)):<br />
S[k] = 1<br />
if S[k] != Sk_old:<br />
E -= 2.0 * h * S[k]<br />
E_tot += E<br />
E2_tot += E ** 2<br />
E_av = E_tot / float(nsteps)<br />
E2_av = E2_tot / float(nsteps)<br />
c_V = beta ** 2 * (E2_av - E_av ** 2) / float(N)<br />
print(E_av / N,c_V)<br />
<br />
=Version=<br />
See history for version information.<br />
<br />
[[Category:Python]] [[Category:Oxford_2024]] [[Category:MOOC_SMAC]]</div>Wernerhttp://www.lps.ens.fr/~krauth/index.php/Markov_ising.pyMarkov ising.py2024-03-04T22:27:38Z<p></p>
<table border='0' width='98%' cellpadding='0' cellspacing='4' style="background-color: white;">
<tr>
<td colspan='2' width='50%' align='center' style="background-color: white;">Revision as of 22:27, 4 March 2024</td>
<td colspan='2' width='50%' align='center' style="background-color: white;">Current revision</td>
</tr>
<tr><td colspan="2" align="left"><strong>Line 1:</strong></td>
<td colspan="2" align="left"><strong>Line 1:</strong></td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;">This page presents the program markov_ising.py, a Markov-chain algorithm for the Ising model on an LXL square lattice in two dimensions.</td><td>+</td><td style="background: #cfc; font-size: smaller;">This page presents the program markov_ising.py, a Markov-chain algorithm for the Ising model on an LXL square lattice in two dimensions<span style="color: red; font-weight: bold;">, with periodic boundary conditions</span>. </td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"> </td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">__FORCETOC__</td><td> </td><td style="background: #eee; font-size: smaller;">__FORCETOC__</td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">=Description=</td><td> </td><td style="background: #eee; font-size: smaller;">=Description=</td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"><span style="color: red; font-weight: bold;">The program is described in my 2024 Oxford Lecture No 8, and also in my book. This version of the program estimates the energy per particle, and the specific heat. </span></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">=Program=</td><td> </td><td style="background: #eee; font-size: smaller;">=Program=</td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"><span style="color: red; font-weight: bold;"> </span></td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"> import random, math</td><td> </td><td style="background: #eee; font-size: smaller;"> import random, math</td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"> </td><td> </td><td style="background: #eee; font-size: smaller;"> </td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;"> L = <span style="color: red; font-weight: bold;">16</span></td><td>+</td><td style="background: #cfc; font-size: smaller;"> L = <span style="color: red; font-weight: bold;">6</span></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"> N = L * L</td><td> </td><td style="background: #eee; font-size: smaller;"> N = L * L</td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"> nbr = {i : ((i // L) * L + (i + 1) % L, (i + L) % N,</td><td> </td><td style="background: #eee; font-size: smaller;"> nbr = {i : ((i // L) * L + (i + 1) % L, (i + L) % N,</td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"> (i // L) * L + (i - 1) % L, (i - L) % N) \</td><td> </td><td style="background: #eee; font-size: smaller;"> (i // L) * L + (i - 1) % L, (i - L) % N) \</td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"> for i in range(N)}</td><td> </td><td style="background: #eee; font-size: smaller;"> for i in range(N)}</td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;"> nsteps = <span style="color: red; font-weight: bold;">1000000</span></td><td>+</td><td style="background: #cfc; font-size: smaller;"> nsteps = <span style="color: red; font-weight: bold;">10000000</span></td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;"> T = <span style="color: red; font-weight: bold;">2</span>.0</td><td>+</td><td style="background: #cfc; font-size: smaller;"> T = <span style="color: red; font-weight: bold;">1</span>.0</td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"> beta = 1.0 / T</td><td> </td><td style="background: #eee; font-size: smaller;"> beta = 1.0 / T</td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"> S = [random.choice([1, -1]) for k in range(N)]</td><td> </td><td style="background: #eee; font-size: smaller;"> S = [random.choice([1, -1]) for k in range(N)]</td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"> E = -0.5 * sum(S[k] * sum(S[nn] for nn in nbr[k]) \</td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"> for k in range(N))</td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"> E_tot, E2_tot = 0.0, 0.0</td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"> for step in range(nsteps):</td><td> </td><td style="background: #eee; font-size: smaller;"> for step in range(nsteps):</td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"> k = random.randint(0, N - 1)</td><td> </td><td style="background: #eee; font-size: smaller;"> k = random.randint(0, N - 1)</td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;"> <span style="color: red; font-weight: bold;">delta_E </span>= <span style="color: red; font-weight: bold;">2.0 * S[k] * </span>sum(S[nn] for nn in nbr[k])</td><td>+</td><td style="background: #cfc; font-size: smaller;"> <span style="color: red; font-weight: bold;">h </span>= sum(S[nn] for nn in nbr[k])</td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"><span style="color: red; font-weight: bold;"> Sk_old = S[k]</span></td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"><span style="color: red; font-weight: bold;"> delta_E = 2.0 * S[k] * h</span></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"> if random.uniform(0.0, 1.0) < math.exp(-beta * delta_E):</td><td> </td><td style="background: #eee; font-size: smaller;"> if random.uniform(0.0, 1.0) < math.exp(-beta * delta_E):</td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"> S[k] *= -1</td><td> </td><td style="background: #eee; font-size: smaller;"> S[k] *= -1</td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;"> print <span style="color: red; font-weight: bold;">S, sum</span>(<span style="color: red; font-weight: bold;">S</span>)</td><td>+</td><td style="background: #cfc; font-size: smaller;"><span style="color: red; font-weight: bold;"> E -= 2.0 * h * S[k]</span></td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"><span style="color: red; font-weight: bold;"> E_tot += E</span></td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"><span style="color: red; font-weight: bold;"> E2_tot += E ** 2</span></td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"><span style="color: red; font-weight: bold;"> E_av = E_tot / float(nsteps)</span></td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"><span style="color: red; font-weight: bold;"> E2_av = E2_tot / float(nsteps)</span></td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"><span style="color: red; font-weight: bold;"> c_V = beta ** 2 * (E2_av - E_av ** 2) / float(N)</span></td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"> print(<span style="color: red; font-weight: bold;">E_av / N, c_V</span>)</td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">=Version=</td><td> </td><td style="background: #eee; font-size: smaller;">=Version=</td></tr>
</table>
Wernerhttp://www.lps.ens.fr/~krauth/index.php/Oxford_Lectures_2024Oxford Lectures 20242024-02-27T13:05:55Z<p></p>
<table border='0' width='98%' cellpadding='0' cellspacing='4' style="background-color: white;">
<tr>
<td colspan='2' width='50%' align='center' style="background-color: white;">Revision as of 13:05, 27 February 2024</td>
<td colspan='2' width='50%' align='center' style="background-color: white;">Current revision</td>
</tr>
<tr><td colspan="2" align="left"><strong>Line 11:</strong></td>
<td colspan="2" align="left"><strong>Line 11:</strong></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">[http://www.lps.ens.fr/%7Ekrauth/images/9/98/WK_Lecture6_Oxford2024.pdf Here are the notes for the sixth lecture.]</td><td> </td><td style="background: #eee; font-size: smaller;">[http://www.lps.ens.fr/%7Ekrauth/images/9/98/WK_Lecture6_Oxford2024.pdf Here are the notes for the sixth lecture.]</td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;">[http://www.lps.ens.fr/%7Ekrauth/images/b/b4/WK_Lecture7_Oxford2024.pdf Here are the notes for the seventh lecture.]</td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">[[Two_cycles.py| Two_cycles.py]] [[direct_N_bosons.py| Direct_bosons.py]]</td><td> </td><td style="background: #eee; font-size: smaller;">[[Two_cycles.py| Two_cycles.py]] [[direct_N_bosons.py| Direct_bosons.py]]</td></tr>
</table>
Wernerhttp://www.lps.ens.fr/~krauth/index.php/Special:Log/uploadSpecial:Log/upload2024-02-27T13:05:05Z<p>uploaded "[[Image:WK Lecture7 Oxford2024.pdf]]"</p>
Wernerhttp://www.lps.ens.fr/~krauth/index.php/Oxford_Lectures_2024Oxford Lectures 20242024-02-27T11:51:05Z<p></p>
<table border='0' width='98%' cellpadding='0' cellspacing='4' style="background-color: white;">
<tr>
<td colspan='2' width='50%' align='center' style="background-color: white;">Revision as of 11:51, 27 February 2024</td>
<td colspan='2' width='50%' align='center' style="background-color: white;">Current revision</td>
</tr>
<tr><td colspan="2" align="left"><strong>Line 10:</strong></td>
<td colspan="2" align="left"><strong>Line 10:</strong></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">[http://www.lps.ens.fr/%7Ekrauth/images/9/98/WK_Lecture6_Oxford2024.pdf Here are the notes for the sixth lecture.]</td><td> </td><td style="background: #eee; font-size: smaller;">[http://www.lps.ens.fr/%7Ekrauth/images/9/98/WK_Lecture6_Oxford2024.pdf Here are the notes for the sixth lecture.]</td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;">[[Two_cycles.py| Two_cycles.py]] [[direct_N_bosons.py| Direct_bosons.py]]</td></tr>
</table>
Wernerhttp://www.lps.ens.fr/~krauth/index.php/Main_PageMain Page2024-02-27T02:44:43Z<p>/* Oxford Lectures 2024 */ </p>
<table border='0' width='98%' cellpadding='0' cellspacing='4' style="background-color: white;">
<tr>
<td colspan='2' width='50%' align='center' style="background-color: white;">Revision as of 02:44, 27 February 2024</td>
<td colspan='2' width='50%' align='center' style="background-color: white;">Current revision</td>
</tr>
<tr><td colspan="2" align="left"><strong>Line 20:</strong></td>
<td colspan="2" align="left"><strong>Line 20:</strong></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">=Oxford Lectures 2024=</td><td> </td><td style="background: #eee; font-size: smaller;">=Oxford Lectures 2024=</td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;">My 2024 Lectures at the University of Oxford (UK) run from 16 January 2024 through 5 March 2024.</td><td colspan="2"> </td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;">[<span style="color: red; font-weight: bold;">http</span>://www.<span style="color: red; font-weight: bold;">lps</span>.<span style="color: red; font-weight: bold;">ens</span>.<span style="color: red; font-weight: bold;">fr</span>/<span style="color: red; font-weight: bold;">%7Ekrauth</span>/<span style="color: red; font-weight: bold;">images/c/c5/WK_Lecture1_Oxford2024.pdf Here are </span>the <span style="color: red; font-weight: bold;"> notes for the first lecture. </span>]</td><td>+</td><td style="background: #cfc; font-size: smaller;"><span style="color: red; font-weight: bold;">My </span>[<span style="color: red; font-weight: bold;">https</span>://www.<span style="color: red; font-weight: bold;">physics</span>.<span style="color: red; font-weight: bold;">ox</span>.<span style="color: red; font-weight: bold;">ac.uk</span>/<span style="color: red; font-weight: bold;">events</span>/<span style="color: red; font-weight: bold;">algorithms-and-computations-theoretical-physics-set-lectures 2024 Public Lectures at </span>the <span style="color: red; font-weight: bold;">University of Oxford (UK)</span>] <span style="color: red; font-weight: bold;">run from 16 January 2024 through </span>5 <span style="color: red; font-weight: bold;">March 2024</span>. [<span style="color: red; font-weight: bold;">[Oxford_Lectures_2024| Click here </span>for lecture notes <span style="color: red; font-weight: bold;">and other material</span>]]</td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;"><span style="color: red; font-weight: bold;">[http://www.lps.ens.fr/%7Ekrauth/images/</span>5<span style="color: red; font-weight: bold;">/5a/WK_Lecture2_Oxford2024</span>.<span style="color: red; font-weight: bold;">pdf Here are the notes for the second and third lectures. ]</span></td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;">[<span style="color: red; font-weight: bold;">http://www.lps.ens.fr/%7Ekrauth/images/1/19/WK_Lecture4_Oxford2024.pdf Here are the preliminary notes </span>for <span style="color: red; font-weight: bold;">the fourth </span>lecture<span style="color: red; font-weight: bold;">.]</span></td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;"><span style="color: red; font-weight: bold;">[http://www.lps.ens.fr/%7Ekrauth/images/6/63/WK_Lecture5_Oxford2024.pdf Here are the preliminary </span>notes <span style="color: red; font-weight: bold;">for the fifth lecture.</span>]</td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;"><span style="color: red; font-weight: bold;">[http://www.lps.ens.fr/%7Ekrauth/images/9/98/WK_Lecture6_Oxford2024.pdf Here are the notes for the sixth lecture.</span>]</td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">=Lectures at the International Center for Theoretical Physics=</td><td> </td><td style="background: #eee; font-size: smaller;">=Lectures at the International Center for Theoretical Physics=</td></tr>
</table>
Wernerhttp://www.lps.ens.fr/~krauth/index.php/MediaWiki:SidebarMediaWiki:Sidebar2024-02-27T02:41:11Z<p></p>
<table border='0' width='98%' cellpadding='0' cellspacing='4' style="background-color: white;">
<tr>
<td colspan='2' width='50%' align='center' style="background-color: white;">Revision as of 02:41, 27 February 2024</td>
<td colspan='2' width='50%' align='center' style="background-color: white;">Current revision</td>
</tr>
<tr><td colspan="2" align="left"><strong>Line 5:</strong></td>
<td colspan="2" align="left"><strong>Line 5:</strong></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">** Publications_WK|Publications</td><td> </td><td style="background: #eee; font-size: smaller;">** Publications_WK|Publications</td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">** Group_WK|Group, Webinars</td><td> </td><td style="background: #eee; font-size: smaller;">** Group_WK|Group, Webinars</td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;">** Oxford_Lectures_2024| 2024 Oxford Lectures </td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">** KingsCollege Masterclass_2022|2022 Master class King's College London</td><td> </td><td style="background: #eee; font-size: smaller;">** KingsCollege Masterclass_2022|2022 Master class King's College London</td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">** Advanced_topics_MCMC_2023|2023 Course: Advanced topics in MCMC</td><td> </td><td style="background: #eee; font-size: smaller;">** Advanced_topics_MCMC_2023|2023 Course: Advanced topics in MCMC</td></tr>
</table>
Wernerhttp://www.lps.ens.fr/~krauth/index.php/Oxford_Lectures_2024Oxford Lectures 20242024-02-27T02:38:57Z<p></p>
<table border='0' width='98%' cellpadding='0' cellspacing='4' style="background-color: white;">
<tr>
<td colspan='2' width='50%' align='center' style="background-color: white;">Revision as of 02:38, 27 February 2024</td>
<td colspan='2' width='50%' align='center' style="background-color: white;">Current revision</td>
</tr>
<tr><td colspan="2" align="left"><strong>Line 1:</strong></td>
<td colspan="2" align="left"><strong>Line 1:</strong></td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;"> </td><td>+</td><td style="background: #cfc; font-size: smaller;">My <span style="color: red; font-weight: bold;">[https://www.physics.ox.ac.uk/events/algorithms-and-computations-theoretical-physics-set-lectures </span>2024 <span style="color: red; font-weight: bold;">Public </span>Lectures at the University of Oxford (UK)<span style="color: red; font-weight: bold;">] </span>run from 16 January 2024 through 5 March 2024.</td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;">My 2024 Lectures at the University of Oxford (UK) run from 16 January 2024 through 5 March 2024.</td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">[http://www.lps.ens.fr/%7Ekrauth/images/c/c5/WK_Lecture1_Oxford2024.pdf Here are the notes for the first lecture. ]</td><td> </td><td style="background: #eee; font-size: smaller;">[http://www.lps.ens.fr/%7Ekrauth/images/c/c5/WK_Lecture1_Oxford2024.pdf Here are the notes for the first lecture. ]</td></tr>
</table>
Wernerhttp://www.lps.ens.fr/~krauth/index.php/Two_cycles.pyTwo cycles.py2024-02-27T02:34:37Z<p></p>
<p><b>New page</b></p><div>This is a Python3 program to sample random permutations P of N elements subject to the constraint that the lengths of the cycles in P can only be one or two. The algorithm is based on a recursive-sampling strategy discussed in my book and presented in my 2024 Oxford lectures. <br />
<br />
import random<br />
from sympy.combinatorics import Permutation<br />
Y = {-1: 0, 0:1, 1:1}<br />
N = 4<br />
Stats = {}<br />
for k in range(2, N + 1):<br />
Y[k] = Y[k - 1] + (k - 1) * Y[k - 2]<br />
for iter in range(100000):<br />
Q = list(range(N))<br />
random.shuffle(Q)<br />
M = N<br />
P = []<br />
while M > 0:<br />
if random.uniform(0.0, Y[M]) < Y[M - 1]:<br />
P.append([Q[M - 1]])<br />
M -= 1<br />
else:<br />
P.append([Q[M - 1] , Q[M - 2]])<br />
M -= 2<br />
P = tuple(Permutation(P).array_form)<br />
if P in Stats:<br />
Stats[P] += 1<br />
else:<br />
Stats[P] = 1<br />
print(Stats)</div>Wernerhttp://www.lps.ens.fr/~krauth/index.php/Oxford_Lectures_2024Oxford Lectures 20242024-02-26T16:59:02Z<p></p>
<p><b>New page</b></p><div><br />
My 2024 Lectures at the University of Oxford (UK) run from 16 January 2024 through 5 March 2024.<br />
<br />
[http://www.lps.ens.fr/%7Ekrauth/images/c/c5/WK_Lecture1_Oxford2024.pdf Here are the notes for the first lecture. ]<br />
<br />
[http://www.lps.ens.fr/%7Ekrauth/images/5/5a/WK_Lecture2_Oxford2024.pdf Here are the notes for the second and third lectures. ]<br />
<br />
[http://www.lps.ens.fr/%7Ekrauth/images/1/19/WK_Lecture4_Oxford2024.pdf Here are the preliminary notes for the fourth lecture.]<br />
<br />
[http://www.lps.ens.fr/%7Ekrauth/images/6/63/WK_Lecture5_Oxford2024.pdf Here are the preliminary notes for the fifth lecture.]<br />
<br />
[http://www.lps.ens.fr/%7Ekrauth/images/9/98/WK_Lecture6_Oxford2024.pdf Here are the notes for the sixth lecture.]</div>Wernerhttp://www.lps.ens.fr/~krauth/index.php/Direct_N_bosons.pyDirect N bosons.py2024-02-26T16:56:05Z<p></p>
<table border='0' width='98%' cellpadding='0' cellspacing='4' style="background-color: white;">
<tr>
<td colspan='2' width='50%' align='center' style="background-color: white;">Revision as of 16:56, 26 February 2024</td>
<td colspan='2' width='50%' align='center' style="background-color: white;">Current revision</td>
</tr>
<tr><td colspan="2" align="left"><strong>Line 1:</strong></td>
<td colspan="2" align="left"><strong>Line 1:</strong></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">This is a Python3 program for the direct sampling of N non-interacting bosons in a three-dimensional harmonic trap. </td><td> </td><td style="background: #eee; font-size: smaller;">This is a Python3 program for the direct sampling of N non-interacting bosons in a three-dimensional harmonic trap. </td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;">[[Image:Boson trap fast.gif|100px|right|frame|Direct-sampling algorithm for ideal bosons in a trap. The output shown here was produced with a more elaborate version of the program than the one shown on this page]]</td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"><br clear="all" /></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"> import pylab, math, random</td><td> </td><td style="background: #eee; font-size: smaller;"> import pylab, math, random</td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"> def z(beta, k):</td><td> </td><td style="background: #eee; font-size: smaller;"> def z(beta, k):</td></tr>
</table>
Wernerhttp://www.lps.ens.fr/~krauth/index.php/Main_PageMain Page2024-02-26T16:52:24Z<p>/* A picture book of algorithms */ </p>
<table border='0' width='98%' cellpadding='0' cellspacing='4' style="background-color: white;">
<tr>
<td colspan='2' width='50%' align='center' style="background-color: white;">Revision as of 16:52, 26 February 2024</td>
<td colspan='2' width='50%' align='center' style="background-color: white;">Current revision</td>
</tr>
<tr><td colspan="2" align="left"><strong>Line 166:</strong></td>
<td colspan="2" align="left"><strong>Line 166:</strong></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr>
<tr><td>-</td><td style="background: #ffa; font-size: smaller;">[[Image:Boson trap fast.gif|100px|right|frame|Direct-sampling algorithm for ideal bosons in a trap (see [[Holzmann Krauth 1999|article with M. Holzmann]]). Adapted for interacting bosons, this algorithm was used in a variety of articles.]]</td><td>+</td><td style="background: #cfc; font-size: smaller;">[[Image:Boson trap fast.gif|100px|right|frame<span style="color: red; font-weight: bold;">|[[Direct N bosons.py</span>|Direct-sampling algorithm for ideal bosons in a trap<span style="color: red; font-weight: bold;">]] </span>(see [[Holzmann Krauth 1999|article with M. Holzmann]]). Adapted for interacting bosons, this algorithm was used in a variety of articles.]]</td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">[[Image:Event chain movie small.gif|100px|left|frame|Event-chain Monte Carlo algorithm for hard spheres and related systems (see [[Bernard Krauth Wilson 2009|article with E. P. Bernard and D. B. Wilson, including Python implementation]]). This (fantastic) algorithm, about two orders of magnitude faster than local Monte Carlo, was used in our [[Bernard Krauth 2011|discovery of the first-order liquid-hexatic phase transition in hard disks]]. The method can be generalized to [[Michel_Kapfer_Krauth_2013|continuous potentials]], and we used it to [[Kapfer_Krauth_2014|map out the phase diagrams of soft-disk systems]]. Look [[Event chain.py|here for an implementation of the event-chain algorithm]] ]]</td><td> </td><td style="background: #eee; font-size: smaller;">[[Image:Event chain movie small.gif|100px|left|frame|Event-chain Monte Carlo algorithm for hard spheres and related systems (see [[Bernard Krauth Wilson 2009|article with E. P. Bernard and D. B. Wilson, including Python implementation]]). This (fantastic) algorithm, about two orders of magnitude faster than local Monte Carlo, was used in our [[Bernard Krauth 2011|discovery of the first-order liquid-hexatic phase transition in hard disks]]. The method can be generalized to [[Michel_Kapfer_Krauth_2013|continuous potentials]], and we used it to [[Kapfer_Krauth_2014|map out the phase diagrams of soft-disk systems]]. Look [[Event chain.py|here for an implementation of the event-chain algorithm]] ]]</td></tr>
</table>
Wernerhttp://www.lps.ens.fr/~krauth/index.php/Direct_N_bosons.pyDirect N bosons.py2024-02-26T16:50:16Z<p></p>
<p><b>New page</b></p><div>This is a Python3 program for the direct sampling of N non-interacting bosons in a three-dimensional harmonic trap. <br />
<br />
import pylab, math, random<br />
def z(beta, k):<br />
sum = 1.0 / (1.0 - math.exp(-k * beta)) ** 3<br />
return sum<br />
def canonic_recursion(beta,N):<br />
Z = [1.0]<br />
for M in range(1, N + 1):<br />
Z.append(sum(Z[k] * z(beta, M - k) for k in range(M)) / M)<br />
return Z<br />
def pi_list_make(Z, M):<br />
pi_list = [0] + [z(beta, k) * Z[M - k] / Z[M] / M for k in range(1, M + 1)]<br />
pi_sum = [0]<br />
for k in range(1, M + 1):<br />
pi_sum.append(pi_sum[k - 1] + pi_list[k])<br />
return pi_sum<br />
def tower_sample(data, Upsilon): #fully naive tower sampling<br />
for k in range(len(data)):<br />
if Upsilon < data[k]: break<br />
return k<br />
def levy_harmonic_path(Del_tau, N):<br />
beta = N * Del_tau<br />
xN = random.gauss(0.0, 1.0 / math.sqrt(2.0 * math.tanh(beta / 2.0)))<br />
x = [xN]<br />
for k in range(1, N):<br />
Upsilon_1 = 1.0 / math.tanh(Del_tau) + 1.0 / math.tanh((N - k) * Del_tau)<br />
Upsilon_2 = x[k - 1]/ math.sinh(Del_tau) + xN / math.sinh((N - k) * Del_tau)<br />
x_mean = Upsilon_2 / Upsilon_1<br />
sigma = 1.0 / math.sqrt(Upsilon_1)<br />
x.append(random.gauss(x_mean, sigma))<br />
return x<br />
<br />
N = 100 # this naive program may overflow for N > 100<br />
T_star = 0.1<br />
T = T_star * N ** (1.0 / 3.0)<br />
beta = 1.0 / T<br />
Z = canonic_recursion(beta, N)<br />
print(Z)<br />
M = N<br />
x_config = []<br />
y_config = []<br />
while M > 0:<br />
pi_sum = pi_list_make(Z, M)<br />
Upsilon = random.uniform(0.0, 1.0)<br />
k = tower_sample(pi_sum, Upsilon)<br />
x_config += levy_harmonic_path(beta, k)<br />
y_config += levy_harmonic_path(beta, k)<br />
M -= k<br />
pylab.figure(1)<br />
pylab.axis('scaled')<br />
pylab.xlim(-5.0, 5.0)<br />
pylab.ylim(-5.0, 5.0)<br />
pylab.plot(x_config, y_config,'ro')<br />
pylab.xlabel('$x$')<br />
pylab.ylabel('$y$')<br />
pylab.title('3d bosons in trap (2d projection):'+' $N$= '+str(N)+' T* =' + str(T_star))<br />
pylab.show()</div>Wernerhttp://www.lps.ens.fr/~krauth/index.php/Main_PageMain Page2024-02-26T10:13:02Z<p>/* Oxford Lectures 2024 */ </p>
<table border='0' width='98%' cellpadding='0' cellspacing='4' style="background-color: white;">
<tr>
<td colspan='2' width='50%' align='center' style="background-color: white;">Revision as of 10:13, 26 February 2024</td>
<td colspan='2' width='50%' align='center' style="background-color: white;">Current revision</td>
</tr>
<tr><td colspan="2" align="left"><strong>Line 29:</strong></td>
<td colspan="2" align="left"><strong>Line 29:</strong></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">[http://www.lps.ens.fr/%7Ekrauth/images/6/63/WK_Lecture5_Oxford2024.pdf Here are the preliminary notes for the fifth lecture.]</td><td> </td><td style="background: #eee; font-size: smaller;">[http://www.lps.ens.fr/%7Ekrauth/images/6/63/WK_Lecture5_Oxford2024.pdf Here are the preliminary notes for the fifth lecture.]</td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr>
<tr><td colspan="2"> </td><td>+</td><td style="background: #cfc; font-size: smaller;">[http://www.lps.ens.fr/%7Ekrauth/images/9/98/WK_Lecture6_Oxford2024.pdf Here are the notes for the sixth lecture.]</td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr>
<tr><td> </td><td style="background: #eee; font-size: smaller;">=Lectures at the International Center for Theoretical Physics=</td><td> </td><td style="background: #eee; font-size: smaller;">=Lectures at the International Center for Theoretical Physics=</td></tr>
</table>
Wernerhttp://www.lps.ens.fr/~krauth/index.php/Special:Log/uploadSpecial:Log/upload2024-02-26T10:12:26Z<p>uploaded "[[Image:WK Lecture6 Oxford2024.pdf]]"</p>
Werner