In [1]:
%load_ext autoreload
%autoreload 2
from extremefill2D.tools import getSMTRecords, smt_ipy_table
records = getSMTRecords(tags=['fig5_nx200_2'], path='../extremefill2D')
In [2]:
smt_ipy_table(records, fields=['label', 'timestamp', 'parameters', 'duration', 'version', 'tags'], parameters=['kPlus', 'kMinus', 'appliedPotential', 'bulkSuppressor', 'Nx'])
Out[2]:
In [4]:
import pandas as pd
from extremefill2D.featureProperty import FeatureProperty
import itertools
fps = [FeatureProperty(r) for r in records]
latestIndex = max([fp.getLatestIndex() for fp in fps])
columns = zip(*list(itertools.product(records, ('times', 'heights', 'potentials', 'thetas'))))
columns = pd.MultiIndex.from_arrays(columns)
height_df = pd.DataFrame(columns=columns, index=np.arange(0, latestIndex + 1, 10))
for fp in fps:
latestIndex = fp.getLatestIndex()
for i in np.arange(0, latestIndex + 1, 10):
height_df[(fp.record, 'times')][i] = fp.getTime(i)
height_df[(fp.record, 'heights')][i] = fp.getHeight(i)
height_df[(fp.record, 'potentials')][i] = fp.getPotential(i)
height_df[(fp.record, 'thetas')][i] = fp.getTheta(i)
fp.close()
In [5]:
from scipy import interpolate
def getVelocity(r, height_df):
x = np.array(height_df[(r, 'times')].dropna()[1:])
y = np.array(height_df[(r, 'heights')].dropna()[1:])
p = np.array(height_df[(r, 'potentials')].dropna()[1:])
t = np.array(height_df[(r, 'thetas')].dropna()[1:])
tck = interpolate.splrep(x,y,s=0)
tckp = interpolate.splrep(x,p,s=0)
tckt = interpolate.splrep(x,t,s=0)
xnew = np.logspace(np.log10(x[0]), np.log10(x[-1]), 1000)
return xnew, interpolate.splev(xnew, tck, der=0) * 56e-6, interpolate.splev(xnew, tck, der=1) * 56e-6, interpolate.splev(xnew, tckp, der=0), interpolate.splev(xnew, tckt, der=0)
In [6]:
for r in records:
r.x, r.y, r.v, r.p, r.t = getVelocity(r, height_df)
In [8]:
import matplotlib.pyplot as plt
import prettyplotlib as ppl
from extremefill2D.tools import smooth
axislabelfontsize = 24
legendfontsize = 20
ticklabelfontsize = 20
titlefontsize = 24
labels = ['passivated', 'activated', 'voided']
fig = plt.figure(figsize=(18, 6), dpi=200)
ax1 = fig.add_subplot(1, 3, 1)
for i, (r, l) in enumerate(zip(records, labels)):
label = '{0}'.format(l)
x = r.x
y = r.v
if i == 1 or True:
window = 7
n = (window - 1) / 2
y = smooth(y, window)[n:-n]
ppl.loglog(ax1, x[y > 1e-12], y[y > 1e-12], label=label, linewidth=2)
plt.xlabel(r'$t$ $\left(\second\right)$', fontdict={'fontsize' : axislabelfontsize})
plt.ylabel(r'$v$ $\left(\meter\per\second\right)$', fontdict={'fontsize' : axislabelfontsize})
plt.ylim(1e-10, 1e-7)
ppl.legend(ax1, loc="upper left", prop={'size' : legendfontsize})
plt.tick_params(axis='both', which='major', labelsize=ticklabelfontsize)
plt.tick_params(axis='both', which='minor', labelsize=ticklabelfontsize)
plt.title(r'$\text{(a)}$', fontsize=titlefontsize, color=ppl.almost_black)
plt.xticks((10**0, 10**2, 10**4))
ax2 = fig.add_subplot(1, 3, 2)
for i, (r, l) in enumerate(zip(records, labels)):
#label = '{0} ($\\texttt{{{1}}}$)'.format(l, r.label[:8])
label = '{0}'.format(l)
y = r.p
x = r.x
#window = 5
#n = (window - 1) / 2
#y = smooth(y, window)[n:-n]
#if i == 1:
# y = y[x < 1200]
# x = x[x < 1200]
ppl.semilogx(ax2, x[y > 1e-12], -y[y > 1e-12], label=label, linewidth=2)
plt.xlabel(r'$t$ $\left(\second\right)$', fontdict={'fontsize' : axislabelfontsize})
plt.ylabel(r'$\eta$ $\left(\volt\right)$', fontdict={'fontsize' : axislabelfontsize})
plt.ylim(-0.25, 0)
#ppl.legend(ax2, loc="upper left", prop={'size' : legendfontsize})
plt.tick_params(axis='both', which='major', labelsize=ticklabelfontsize)
plt.tick_params(axis='both', which='minor', labelsize=ticklabelfontsize)
plt.title(r'$\text{(b)}$', fontsize=titlefontsize, color=ppl.almost_black)
plt.xticks((10**0, 10**2, 10**4))
ax3 = fig.add_subplot(1, 3, 3)
for i, (r, l) in enumerate(zip(records, labels)):
#label = '{0} ($\\texttt{{{1}}}$)'.format(l, r.label[:8])
label = '{0}'.format(l)
y = r.t
x = r.x
#window = 1
#n = (window - 1) / 2
#y = smooth(y, window)[n:-n]
#if i == 1:
# y = y[x < 1200]
# x = x[x < 1200]
ppl.semilogx(ax3, x[y > 1e-12], y[y > 1e-12], label=label, linewidth=2)
plt.xlabel(r'$t$ $\left(\second\right)$', fontdict={'fontsize' : axislabelfontsize})
plt.ylabel(r'$\theta$', fontdict={'fontsize' : axislabelfontsize})
plt.ylim(0, 1)
#ppl.legend(ax2, loc="upper left", prop={'size' : legendfontsize})
plt.tick_params(axis='both', which='major', labelsize=ticklabelfontsize)
plt.tick_params(axis='both', which='minor', labelsize=ticklabelfontsize)
plt.title(r'$\text{(c)}$', fontsize=titlefontsize, color=ppl.almost_black)
plt.xticks((10**0, 10**2, 10**4))
fig.subplots_adjust(wspace=.3)
plt.savefig('../figures/fig5.png')
In [9]:
from extremefill2D.multiViewer import MultiViewer
from extremefill2D.tools import getRecord
reorderedRecords = [records]
viewer = MultiViewer(reorderedRecords,
figsize=(1.15, 5.))
viewer.plot(times=np.arange(40) * 5000. / 39)
In [ ]: