Hi Julien, There is nothing obviously wrong. Unfortunately, I can't look into this right now because I'm preparing for a conference next week. I'll put this on my list for when I return and try and debug it then (week beginning the 7th of March). I would say that the level set sections of the code have not received a lot of attention over the last few years other than satisfying the tests that are already there. However, for your usage, it should function.
On Tue, Feb 22, 2011 at 7:30 AM, Julien Derr <[email protected]> wrote: > Hi everyone, > > I tried to do a simple level set technique : particules (concentration field > c) are diffusing and aggregating to an aggregate (represented by the > interface phi=0) > > I used the template of examples.levelSet.electroChem.howToWriteAScript > to write the following few lines attached at the end , and I get an obscure > (for me) error > like this : > > is there anything obviously wrong ? > thanks for your help! > > Julien > > > In [5]: run levelset.py > --------------------------------------------------------------------------- > IndexError Traceback (most recent call last) > > /home/julien/Dropbox/levelset/levelset.py in <module>() > 54 c.updateOld() > 55 > ---> 56 phi.extendVariable(c.getFaceGrad()) > 57 > 58 dt = cflNumber * cellSize / c.getFaceGrad().max() > > /usr/local/lib/python2.6/dist-packages/FiPy-2.2_dev-py2.6.egg/fipy/models/levelSet/distanceFunction/distanceVariable.pyc > in extendVariable(self, extensionVariable, deleteIslands) > 227 self.tmpValue = self._value.copy() > 228 numericExtensionVariable = numerix.array(extensionVariable) > --> 229 self._calcDistanceFunction(numericExtensionVariable, > deleteIslands = deleteIslands) > 230 extensionVariable[:] = numericExtensionVariable > 231 self._value = self.tmpValue > > /usr/local/lib/python2.6/dist-packages/FiPy-2.2_dev-py2.6.egg/fipy/models/levelSet/distanceFunction/distanceVariable.pyc > in _calcDistanceFunction(self, extensionVariable, narrowBandWidth, > deleteIslands) > 335 > 336 for id in trialIDs: > --> 337 self._value[...,id], extensionVariable[id] = > self._calcTrialValue(id, evaluatedFlag, extensionVariable) > 338 > 339 while len(trialIDs): > > IndexError: index out of bounds > WARNING: Failure executing file: <levelset.py> > > > > ############################################################################# > script: > ############################################################################### > from fipy import * > > #parameters > Rstart=10 > cellSize=0.25 > nx = ny = 1000 > dx = dy = cellSize > D=1 > > #mesh definition > mesh = Grid2D(nx=nx, ny=ny, dx=dx,dy=dy) > > #Variables definitions > c = CellVariable(name="c", mesh=mesh,value=0.,hasOld=1) > > #phi the distance variable > narrowBandWidth = 10* cellSize > phi = DistanceVariable(name='phi',mesh= > mesh,value=-1.,narrowBandWidth=narrowBandWidth,hasOld=1) > x, y = mesh.getCellCenters() > phi.setValue(1., where=((x-50)**2+(y-50)**2 > Rstart**2 )) > phi.calcDistanceFunction() > > #Advection equation for phi : dphi dt+vextgradphi=0 ou divergence ? signe ? > advectionEquation = > buildHigherOrderAdvectionEquation(advectionCoeff=c.getFaceGrad()) > > #metal equation (the particules concentration diffuses only where phi=1) > ceq= > buildMetalIonDiffusionEquation(ionVar=c,distanceVar=phi,depositionRate=c.getFaceGrad(),diffusionCoeff=D) > BCs = FixedValue(faces=mesh.getExteriorFaces(), value=1) > > #visualization: > try: > viewer = MayaviSurfactantViewer(phi, > zoomFactor=1e6, > datamax=1.0, > datamin=0.0, > smooth=1) > except: > viewer = MultiViewer(viewers=( > Viewer(phi, datamin=-1e-9, datamax=1e-9))) > > ##main loop > > numberOfsteps=10 > cflNumber = 0.2 > for step in range(numberOfsteps): > viewer.plot() > > phi.calcDistanceFunction() > > phi.updateOld() > c.updateOld() > > phi.extendVariable(c.getFaceGrad()) > > dt = cflNumber * cellSize / c.getFaceGrad().max() > > advectionEquation.solve(phi, dt=dt) > > ceq.solve(var=c, dt=dt,boundaryConditions=BCs) > > > > > -- Daniel Wheeler
