The effects include isolated cells and lack of grid convergence in the final position of the interface when the system shuts down.
To deal with the isolated cells, cells that are surrounded by an electrode will be switched to electrode when the level set update is called.
To check the interface drifting we need to check if the velocity has shut down if the interface is still moving due to level set updates.
Need to run simulations with changing values for the level set update frequency
In [1]:
%load_ext autoreload
%autoreload 2
from tools import getSMTRecords, smt_ipy_table
records = getSMTRecords()
annular10Records = getSMTRecords(records=records, tags=['annular10'])
In [2]:
from tools import getSMTRecords
import numpy as np
from multiViewer import MultiViewer
import pandas as pd
def plotSandNx(rboundary, titlesub=400, Nxs=(100, 200, 400, 800), spacing_ratios=(1.2,)):
def getrecord(s, n):
rs = getSMTRecords(records=annular10Records, parameters={'Nx' : n, 'rboundary' : rboundary, 'spacing_ratio' : s})
if len(rs) > 0:
return rs[0]
else:
return None
tmp = [[getrecord(s, n) for n in Nxs] for s in spacing_ratios]
def columntitle(r):
if r:
return r'$N$={0}'.format(r.parameters['Nx'])
else:
return r'$N$={0}'.format(titlesub)
viewer = MultiViewer(tmp,
columntitle=columntitle,
rowtitle=lambda r: r'$s$={0}'.format(r.parameters['spacing_ratio']),
figsize=(1.5, 6))
viewer.plot(times=np.arange(10) * 4000. / 9.)
return smt_ipy_table([j for i in tmp for j in i if j], fields=['label', 'timestamp', 'parameters', 'duration', 'version', 'tags'], parameters=['spacing_ratio', 'rboundary', 'Nx', 'kPlus', 'kMinus'])
In [3]:
plotSandNx(20e-6, Nxs=(400, 800), spacing_ratios=(1.2,), titlesub=800)
Out[3]:
In [4]:
plotSandNx(320e-6, Nxs=(100, 200, 400), spacing_ratios=(1.8,))
Out[4]:
In [29]:
testRecord = getSMTRecords(records=annular10Records, parameters={'Nx' : 800, 'rboundary' : 2e-5, 'spacing_ratio' : 1.2})[0]
smt_ipy_table([testRecord], fields=['label', 'timestamp', 'parameters', 'duration', 'version', 'tags'], parameters=['spacing_ratio', 'rboundary', 'Nx', 'kPlus', 'kMinus'])
Out[29]:
In [17]:
testRecord = getSMTRecords(records=annular10Records, parameters={'Nx' : 400, 'rboundary' : 2e-5, 'spacing_ratio' : 1.2})[0]
smt_ipy_table([testRecord], fields=['label', 'timestamp', 'parameters', 'duration', 'version', 'tags'], parameters=['spacing_ratio', 'rboundary', 'Nx', 'kPlus', 'kMinus'])
Out[17]:
In [35]:
from contourViewer import ContourViewer
cv = ContourViewer(testRecord)
cv.plot((4000,))
print cv.phi.shape
print np.amax(cv.phi[:,:200], axis=0)
Method to delete islands, just deletes the anomolous islands that form.
class DistanceVariableNonUniform(fp.DistanceVariable):
def deleteIslands(self):
from fipy.tools import numerix
from fipy.tools.numerix import MA
cellToCellIDs = self.mesh._getCellToCellIDs()
adjVals = numerix.take(self.value, cellToCellIDs)
adjInterfaceValues = MA.masked_array(adjVals, mask = (adjVals * self.value) > 0)
masksum = numerix.sum(numerix.logical_not(MA.getmask(adjInterfaceValues)), 0)
tmp = MA.logical_and(masksum == 4, self.value > 0)
self.value = numerix.array(MA.where(tmp, -1, self.value))
In [ ]:
# Simulations launched on 08/27/2013
Varying `Nx`, `levelset_update_frequency` and `delete_islands`
In [28]:
from tools import batch_launch
reason = "Testing island deletion and levelset_update_frequency"
for Nx in (100, 200, 400, 800):
for levelset_update_frequency in (25, 50, 100, 200, 400):
for delete_islands in (0, 1):
batch_launch(reason=reason,
tags=['annular13'],
kPlus=400.,
rboundary=2e-5,
Nx=Nx,
spacing_ratio=1.2,
levelset_update_frequency=levelset_update_frequency,
delete_islands=delete_islands)
In [34]:
!date
!qstat
In [1]:
%load_ext autoreload
%autoreload 2
from tools import getSMTRecords, smt_ipy_table
records = getSMTRecords()
annular13Records = getSMTRecords(records=records, tags=['annular13'])
In [2]:
smt_ipy_table(annular13Records, fields=['label', 'timestamp', 'parameters', 'duration', 'version', 'tags'], parameters=['Nx', 'delete_islands', 'levelset_update_frequency'])
Out[2]:
In [3]:
from tools import getSMTRecords
import numpy as np
from multiViewer import MultiViewer
import pandas as pd
def plotFandNx(Nxs=(100, 200, 400, 800), levelset_update_frequency=(25, 50, 100, 200, 400), delete_islands=0, times=np.arange(10) * 4000. / 9.):
def getrecord(s, n):
rs = getSMTRecords(records=annular13Records, parameters={'Nx' : n, 'levelset_update_frequency' : s, 'delete_islands' : delete_islands})
if len(rs) > 0:
return rs[0]
else:
return None
tmp = [[getrecord(s, n) for n in Nxs] for s in levelset_update_frequency]
def columntitle(r):
if r:
return r'$N$={0}'.format(r.parameters['Nx'])
else:
return r'$N$={0}'.format('?')
def rowtitle(r):
if r:
return r'$f$={0}'.format(r.parameters['levelset_update_frequency'])
else:
return r'$f$={0}'.format('?')
viewer = MultiViewer(tmp,
columntitle=columntitle,
rowtitle=rowtitle,
figsize=(1.5, 6))
viewer.plot(times=times)
return smt_ipy_table([j for i in tmp for j in i if j], fields=['label', 'timestamp', 'parameters', 'duration', 'version', 'tags'], parameters=['Nx', 'levelset_update_frequency', 'delete_islands'])
In [4]:
plotFandNx(delete_islands=0, times=np.arange(10) * 4000. / 9.)
Out[4]:
In [5]:
plotFandNx(delete_islands=1)
Out[5]:
In [42]:
import os.path
from dicttable import DictTable
def getDepositionRates(record):
datafile = os.path.join(record.datastore.root, record.output_data[0].path)
data = DictTable(datafile, 'r')
latestIndex = data.getLatestIndex()
indexJump = 10
index = 0
elapsedTimes = []
depositionRates = []
while index <= latestIndex:
d = data[index]
elapsedTimes.append(d['elapsedTime'])
depositionRates.append(d['extensionGlobalValue'])
index += indexJump
return elapsedTimes, depositionRates
In [43]:
record = getSMTRecords(records=annular13Records, parameters={'Nx' : 100, 'levelset_update_frequency' : 50, 'delete_islands' : 0})
print len(record)
In [45]:
t, d = getDepositionRates(record[0])
plt.semilogy(t, d)
Out[45]:
In [47]:
for Nx in (100, 200, 400):
record = getSMTRecords(records=annular13Records, parameters={'Nx' : Nx, 'levelset_update_frequency' : 25, 'delete_islands' : 0})[0]
t, d = getDepositionRates(record)
plt.semilogy(t, d)
In [48]:
for Nx in (100, 200, 400):
record = getSMTRecords(records=annular13Records, parameters={'Nx' : Nx, 'levelset_update_frequency' : 50, 'delete_islands' : 0})[0]
t, d = getDepositionRates(record)
plt.semilogy(t, d)
In [59]:
for Nx in (100, 200, 400):
record = getSMTRecords(records=annular13Records, parameters={'Nx' : Nx, 'levelset_update_frequency' : 50, 'delete_islands' : 0})[0]
t, d = getDepositionRates(record)
print np.array(t)[np.array(d) > 10**(-12)][-1]
plt.semilogy(t, d)
In [65]:
plotFandNx(delete_islands=0, times=np.arange(10) * 2400. / 9., levelset_update_frequency=(50,))
Out[65]:
In [67]:
plotFandNx(delete_islands=0, times=np.arange(10) * 4000. / 9., levelset_update_frequency=(50,))
Out[67]:
In [ ]:
rm