{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "ExecuteTime": { "end_time": "2019-09-26T06:39:45.474473Z", "start_time": "2019-09-26T06:39:42.982516Z" } }, "outputs": [], "source": [ "%matplotlib inline \n", "import json\n", "import numpy as np\n", "import os\n", "import pylab as plt" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import matplotlib as mpl\n", "mpl.rc('font', family='Times New Roman')\n", "plt.rcParams[\"mathtext.fontset\"] = \"stix\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [ "parameters" ] }, "outputs": [], "source": [ "input_file = 'output.json'" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Values from a previous calculation can be inserted here to reproduce the results \n", "step_dict = {}\n", "if os.path.exists(input_file):\n", " with open(input_file, 'r') as f:\n", " step_dict_str = json.load(f)\n", " for k,v in step_dict_str.items():\n", " step_dict[int(k)] = v" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ind, temp_lst = [], []\n", "for k,v in step_dict.items():\n", " ind.append(k)\n", " temp_lst.append(v['temperature_next'])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "temp_array = np.array(temp_lst)[np.array(ind)]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# plot the convergence of loop calculations\n", "plt.plot(np.arange(1, len(temp_array)), temp_array[0:-1], 'ro-', label=r\"$T^e$\")\n", "plt.plot(np.arange(1, len(temp_array)), temp_array[1:], 'bo-', label=r\"$T^p$\")\n", "plt.legend(fontsize=14)\n", "plt.tick_params(axis='both', labelsize=14)\n", "plt.xlabel('Number of loops', fontsize=14)\n", "plt.ylabel('Temperature (K)', fontsize=14)\n" ] } ], "metadata": { "celltoolbar": "Tags", "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.3" }, "toc": { "base_numbering": 1, "nav_menu": { "height": "120px", "width": "252px" }, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": { "height": "calc(100% - 180px)", "left": "10px", "top": "150px", "width": "166.796875px" }, "toc_section_display": "block", "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 2 }