Я только начинаю с FiPy и, таким образом, посмотрел примеры. Однако при запуске "examples.diffusion.mesh20x20" я получаю следующую ошибку:
---------------------------------------------------------------------------
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
Вот код из "examples.diffusion.mesh20x20" Я пытаюсь запустить:
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()
К сожалению, я не смог найти никакого решения при поиске сообщения об ошибке. Возможно, что-то не так с моей установкой? Надеюсь, один из вас сможет мне помочь.