In [ ]:
%matplotlib inline 
import json
import numpy as np
import os
import pylab as plt
In [ ]:
import matplotlib as mpl
mpl.rc('font', family='Times New Roman')
plt.rcParams["mathtext.fontset"] = "stix"
In [ ]:
input_file = 'output.json'
In [ ]:
# Values from a previous calculation can be inserted here to reproduce the results 
step_dict = {}
if os.path.exists(input_file):
    with open(input_file, 'r') as f:
        step_dict_str = json.load(f)
    for k,v in step_dict_str.items():
        step_dict[int(k)] = v
In [ ]:
ind, temp_lst = [], []
for k,v in step_dict.items():
    ind.append(k)
    temp_lst.append(v['temperature_next'])
In [ ]:
temp_array = np.array(temp_lst)[np.array(ind)]
In [ ]:
# plot the convergence of loop calculations
plt.plot(np.arange(1, len(temp_array)), temp_array[0:-1], 'ro-', label=r"$T^e$")
plt.plot(np.arange(1, len(temp_array)), temp_array[1:], 'bo-', label=r"$T^p$")
plt.legend(fontsize=14)
plt.tick_params(axis='both', labelsize=14)
plt.xlabel('Number of loops', fontsize=14)
plt.ylabel('Temperature (K)', fontsize=14)