Ok, below works as I would expect ( note Dx and Dz are constants)

"
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from fipy import *


nx = 50.
ny = 50.
dx = .4
dy = .4
L = dx*nx
mesh = Grid2D(ny=ny,dy=dy, dx=dx,nx=nx)

w=10 #waveguide width um
dpe = 3 #initial Proton ex depth
dxpe = .098 # pe diffusion
dzpe=.056 #um^2/h
umax=0.2*dpe*(dxpe/dzpe)**.5

C = CellVariable(name = "solution variable",mesh = mesh, value = 0.,hasOld=1)

X,Z=mesh.cellCenters
wdpe = (Z<=dpe) & ((L/2-w/2)< X) &  (X < (w/2 +L/2 ))

C.setValue(1,where = wdpe)

viewer = Viewer(vars=C, datamin=0., datamax=1.1)


Dx=1.
Dz=5.
eqX = TransientTerm() == DiffusionTerm([[[Dx,0],[0,Dz]]])


timeStepDuration = 2
steps = 5
time=2
while time<=10:
    C.updateOld()
    input('')
    viewer.plot()
    for step in range(steps):
        print(eqX.sweep(var=C,dt=timeStepDuration))
        #input('d')


    time+=2

"

But when
[[[Dx,0],[0,Dz]]] replaced by [[Dx,Dz]]

is has the following error

---------------------------------------------------------------------------
AssertionError                             Traceback (most recent call last)
<ipython-input-27-8001c64231a4> in<module>() 42 viewer.plot()43 for step in range(steps):---> 44print(eqX.sweep(var=C,dt=timeStepDuration))45 #input('d')46 C:\Users\philb\AppData\Local\Continuum\Anaconda3\lib\site-packages\fipy-unknown-py3.5.egg\fipy\terms\term.py in sweep(self, var, solver, boundaryConditions, dt, underRelaxation, residualFn, cacheResidual, cacheError) 221 222 """ --> 223solver = self._prepareLinearSystem(var=var, solver=solver, boundaryConditions=boundaryConditions, dt=dt)224 solver._applyUnderRelaxation(underRelaxation=underRelaxation)225 residual = solver._calcResidual(residualFn=residualFn)C:\Users\philb\AppData\Local\Continuum\Anaconda3\lib\site-packages\fipy-unknown-py3.5.egg\fipy\terms\term.py in _prepareLinearSystem(self, var, solver, boundaryConditions, dt) 155 transientGeomCoeff=self._getTransientGeomCoeff(var),156 diffusionGeomCoeff=self._getDiffusionGeomCoeff(var),--> 157buildExplicitIfOther=self._buildExplcitIfOther) 158 159 self._buildCache(matrix, RHSvector)C:\Users\philb\AppData\Local\Continuum\Anaconda3\lib\site-packages\fipy-unknown-py3.5.egg\fipy\terms\binaryTerm.py in _buildAndAddMatrices(self, var, SparseMatrix, boundaryConditions, dt, transientGeomCoeff, diffusionGeomCoeff, buildExplicitIfOther) 66 transientGeomCoeff=transientGeomCoeff,67 diffusionGeomCoeff=diffusionGeomCoeff,---> 68buildExplicitIfOther=buildExplicitIfOther) 69 70 matrix += tmpMatrixC:\Users\philb\AppData\Local\Continuum\Anaconda3\lib\site-packages\fipy-unknown-py3.5.egg\fipy\terms\unaryTerm.py in _buildAndAddMatrices(self, var, SparseMatrix, boundaryConditions, dt, transientGeomCoeff, diffusionGeomCoeff, buildExplicitIfOther) 97 dt=dt,98 transientGeomCoeff=transientGeomCoeff,---> 99diffusionGeomCoeff=diffusionGeomCoeff) 100 elif buildExplicitIfOther:101 _, matrix, RHSvector = self._buildMatrix(self.var, C:\Users\philb\AppData\Local\Continuum\Anaconda3\lib\site-packages\fipy-unknown-py3.5.egg\fipy\terms\abstractDiffusionTerm.py in _buildMatrix(self, var, SparseMatrix, boundaryConditions, dt, transientGeomCoeff, diffusionGeomCoeff) 351 352 ids = self._reshapeIDs(var, numerix.arange(mesh.numberOfCells))--> 353L.addAt(self.constraintL.ravel(), ids.ravel(), ids.swapaxes(0,1).ravel())354 b += numerix.reshape(self.constraintB.ravel(), ids.shape).sum(-2).ravel()355 C:\Users\philb\AppData\Local\Continuum\Anaconda3\lib\site-packages\fipy-unknown-py3.5.egg\fipy\matrices\scipyMatrix.py in addAt(self, vector, id1, id2) 251 2.500000 --- 2.200000252 """ --> 253assert(len(id1) == len(id2) == len(vector))254 255 temp = sp.csr_matrix((vector, (id1, id2)), self.matrix.shape)AssertionError:






On 4/18/2016 10:04 AM, Daniel Wheeler wrote:
On Mon, Apr 18, 2016 at 11:49 AM, Phil Battle <[email protected]> wrote:
is it possible the conversion to python 3 is the issue with the
equivalency in the case of a constant anisotropic diffusion coeff. ?
I was wondering about that. Can you post a snippet (enough to demo the
issue) and I'll try it in Python 2.7 if you don't have FiPy working in
2.7.


_______________________________________________
fipy mailing list
[email protected]
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]

Reply via email to