06: Partly solve 1c
This commit is contained in:
@ -257,7 +257,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 106,
|
"execution_count": 111,
|
||||||
"id": "6e4a6d63",
|
"id": "6e4a6d63",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"deletable": false,
|
"deletable": false,
|
||||||
@ -311,7 +311,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 109,
|
"execution_count": 112,
|
||||||
"id": "3f810041",
|
"id": "3f810041",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"deletable": false,
|
"deletable": false,
|
||||||
@ -342,7 +342,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 110,
|
"execution_count": 113,
|
||||||
"id": "bde560e4",
|
"id": "bde560e4",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"deletable": false,
|
"deletable": false,
|
||||||
@ -391,7 +391,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 124,
|
||||||
"id": "1f91dd67",
|
"id": "1f91dd67",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"deletable": false,
|
"deletable": false,
|
||||||
@ -406,20 +406,103 @@
|
|||||||
"task": false
|
"task": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"T = 0.5\n",
|
||||||
|
"\tequilibrating took 5.3386430740356445 seconds\n",
|
||||||
|
"\tmeasuring took 13.652144193649292 seconds\n",
|
||||||
|
"\n",
|
||||||
|
"T = 0.6\n",
|
||||||
|
"\tequilibrating took 5.194417953491211 seconds\n",
|
||||||
|
"\tmeasuring took 12.401273727416992 seconds\n",
|
||||||
|
"\n",
|
||||||
|
"T = 0.7\n",
|
||||||
|
"\tequilibrating took 4.591171503067017 seconds\n",
|
||||||
|
"\tmeasuring took 11.19827151298523 seconds\n",
|
||||||
|
"\n",
|
||||||
|
"T = 0.8\n",
|
||||||
|
"\tequilibrating took 3.9237494468688965 seconds\n",
|
||||||
|
"\tmeasuring took 10.341700792312622 seconds\n",
|
||||||
|
"\n",
|
||||||
|
"T = 0.9\n",
|
||||||
|
"\tequilibrating took 3.6344528198242188 seconds\n",
|
||||||
|
"\tmeasuring took 9.163604021072388 seconds\n",
|
||||||
|
"\n",
|
||||||
|
"T = 1.0\n",
|
||||||
|
"\tequilibrating took 2.604698896408081 seconds\n",
|
||||||
|
"\tmeasuring took 6.472257137298584 seconds\n",
|
||||||
|
"\n",
|
||||||
|
"T = 1.1\n",
|
||||||
|
"\tequilibrating took 1.5426356792449951 seconds\n",
|
||||||
|
"\tmeasuring took 3.485330104827881 seconds\n",
|
||||||
|
"\n",
|
||||||
|
"T = 1.2000000000000002\n",
|
||||||
|
"\tequilibrating took 0.4475827217102051 seconds\n",
|
||||||
|
"\tmeasuring took 1.3380379676818848 seconds\n",
|
||||||
|
"\n",
|
||||||
|
"T = 1.3\n",
|
||||||
|
"\tequilibrating took 0.294419527053833 seconds\n",
|
||||||
|
"\tmeasuring took 0.7950901985168457 seconds\n",
|
||||||
|
"\n",
|
||||||
|
"T = 1.4\n",
|
||||||
|
"\tequilibrating took 0.2504415512084961 seconds\n",
|
||||||
|
"\tmeasuring took 0.46738409996032715 seconds\n",
|
||||||
|
"\n",
|
||||||
|
"T = 1.5\n",
|
||||||
|
"\tequilibrating took 0.14740800857543945 seconds\n",
|
||||||
|
"\tmeasuring took 0.39183998107910156 seconds\n",
|
||||||
|
"\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"temperatures = np.linspace(0.5,1.5,11)\n",
|
"temperatures = np.linspace(0.5,1.5,11)\n",
|
||||||
"width = 25\n",
|
"width = 25\n",
|
||||||
"equilibration_moves = 400\n",
|
"equilibration_moves = 400\n",
|
||||||
"measurement_moves = 1000\n",
|
"measurement_moves = 1000\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# YOUR CODE HERE\n",
|
"import h5py\n",
|
||||||
"raise NotImplementedError()"
|
"import time\n",
|
||||||
|
"\n",
|
||||||
|
"t_0 = time.time()\n",
|
||||||
|
"def toc():\n",
|
||||||
|
" global t_0\n",
|
||||||
|
" dt = time.time() - t_0\n",
|
||||||
|
" t_0 = time.time()\n",
|
||||||
|
" return dt\n",
|
||||||
|
"\n",
|
||||||
|
"with h5py.File('xy_data.hdf5','a') as f:\n",
|
||||||
|
" #del f[\"cluster-size\"]\n",
|
||||||
|
" if not \"cluster-size\" in f:\n",
|
||||||
|
" state = xy_aligned_init_config(width)\n",
|
||||||
|
" cluster_sizes = np.zeros(len(temperatures))\n",
|
||||||
|
" \n",
|
||||||
|
" t_0 = time.time()\n",
|
||||||
|
" for idx, T in enumerate(temperatures):\n",
|
||||||
|
" print(\"T =\", T)\n",
|
||||||
|
" beta = 1/T\n",
|
||||||
|
" \n",
|
||||||
|
" # Equilibrate\n",
|
||||||
|
" for _ in range(equilibration_moves):\n",
|
||||||
|
" xy_cluster_move(state,beta)\n",
|
||||||
|
" print(\"\\tequilibrating took\", toc(), \" seconds\")\n",
|
||||||
|
" \n",
|
||||||
|
" # Measure\n",
|
||||||
|
" for _ in range(measurement_moves):\n",
|
||||||
|
" cluster_sizes[idx] += xy_cluster_move(state,beta)\n",
|
||||||
|
" cluster_sizes[idx] /= measurement_moves\n",
|
||||||
|
" print(\"\\tmeasuring took\", toc(), \" seconds\")\n",
|
||||||
|
" print()\n",
|
||||||
|
" \n",
|
||||||
|
" f.create_dataset(\"cluster-size\",data=cluster_sizes)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 125,
|
||||||
"id": "f5ea3143",
|
"id": "f5ea3143",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"deletable": false,
|
"deletable": false,
|
||||||
|
|||||||
BIN
Exercise sheet 6/xy_data.hdf5
Normal file
BIN
Exercise sheet 6/xy_data.hdf5
Normal file
Binary file not shown.
Reference in New Issue
Block a user