1

I'm just getting started with FiPy and thus looked at the examples. However, when running the "examples.diffusion.mesh20x20" I get the following error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-2-368b9682144d> in <module>
     22 
     23 # to the top-left and bottom-right corners. Neumann boundary conditions are automatically applied to the top-right and bottom-left corners.
---> 24 X, Y = mesh.faceCenters
     25 
     26 facesTopLeft = ((mesh.facesLeft & (Y > L / 2))

~\Anaconda3\lib\site-packages\fipy\meshes\abstractMesh.py in faceCenters(self)
     93     def faceCenters(self):
     94         from fipy.variables.faceVariable import FaceVariable
---> 95         return FaceVariable(mesh=self, value=self._faceCenters,
     96                             rank=1)
     97 

~\Anaconda3\lib\site-packages\fipy\meshes\uniformGrid2D.py in _faceCenters(self)
    415         Vcen[1, ...] = (indices[1] + 0.5) * self.dy
    416 
--> 417         return numerix.concatenate((Hcen.reshape((2, self.numberOfHorizontalFaces), order="FORTRAN"),
    418                                     Vcen.reshape((2,
    419                                         self.numberOfVerticalFaces),

ValueError: Non-string object detected for the array ordering. Please pass in 'C', 'F', 'A', or 'K' instead

Here is the code from "examples.diffusion.mesh20x20" I'm trying to run:

from fipy import CellVariable, Grid2D, Viewer, TransientTerm, DiffusionTerm
from fipy.tools import numerix
nx = 20
ny = nx
dx = 1.
dy = dx
L = dx * nx
mesh = Grid2D(dx=dx, dy=dy, nx=nx, ny=ny)

# We create a CellVariable and initialize it to zero:
phi = CellVariable(name = "solution variable",
                   mesh = mesh,
                   value = 0.)

# and then create a diffusion equation. This is solved by default with an iterative conjugate gradient solver.
D = 1.
eq = TransientTerm() == DiffusionTerm(coeff=D)

# We apply Dirichlet boundary conditions
valueTopLeft = 0
valueBottomRight = 1

# to the top-left and bottom-right corners. Neumann boundary conditions are automatically applied to the top-right and bottom-left corners.
X, Y = mesh.faceCenters

facesTopLeft = ((mesh.facesLeft & (Y > L / 2))
    | (mesh.facesTop & (X < L / 2)))
facesBottomRight = ((mesh.facesRight & (Y < L / 2))
    | (mesh.facesBottom & (X > L / 2)))
phi.constrain(valueTopLeft, facesTopLeft)
phi.constrain(valueBottomRight, facesBottomRight)
# We create a viewer to see the results
if __name__ == '__main__':
    viewer = Viewer(vars=phi, datamin=0., datamax=1.)
    viewer.plot()
# and solve the equation by repeatedly looping in time:
timeStepDuration = 10 * 0.9 * dx**2 / (2 * D)
steps = 10
from builtins import range
for step in range(steps):
    eq.solve(var=phi,
             dt=timeStepDuration)
    if __name__ == '__main__':
        viewer.plot()

Unfortunately, I could not find any solution when searching for the error message. Perhaps, there is something wrong with my installation? Hopefully one of you can help me.

artanik
  • 2,599
  • 15
  • 24
Julian
  • 13
  • 2

1 Answers1

1

This problem is caused because you have a newer version of numpy than FiPy is tested with. (see issue #703). We will be pushing a fix for this problem hopefully today or tomorrow.

jeguyer
  • 2,379
  • 1
  • 11
  • 15
  • Thank you! Downgrading numpy to version 1.17 solved the issue for now. Looking forward to the new Version. – Julian Feb 13 '20 at 07:08