0

fipy を使って微分方程式を解くことに興味があります。

Grid2D を使用している場合、次のコードは正しく機能しています。

from fipy import *

mesh = Grid2D(nx=3, ny=3)
#mesh = Grid3D(nx=3, ny=3, nz=3)
phi = CellVariable(name='solution variable', mesh=mesh, value=0.)
phi.constrain(0, mesh.facesLeft)
phi.constrain(10, mesh.facesRight)
coeff = CellVariable(mesh=mesh, value=1.)

eq = DiffusionTerm(coeff) == 0
eq.solve(var=phi)

Grid2D (コメント行) の代わりに Grid3D を使用している場合、次のエラーが発生します。

Traceback (most recent call last):
  File "/home/user/Programming/python/fdms/forSo.py", line 11, in <module>
    eq.solve(var=phi)
  File "/home/user/Programs/miniconda2/envs/FipyEnv2/lib/python3.6/site-packages/fipy/terms/term.py", line 211, in solve
    solver = self._prepareLinearSystem(var, solver, boundaryConditions, dt)
  File "/home/user/Programs/miniconda2/envs/FipyEnv2/lib/python3.6/site-packages/fipy/terms/term.py", line 169, in _prepareLinearSystem
    diffusionGeomCoeff=self._getDiffusionGeomCoeff(var),
  File "/home/user/Programs/miniconda2/envs/FipyEnv2/lib/python3.6/site-packages/fipy/terms/abstractDiffusionTerm.py", line 458, in _getDiffusionGeomCoeff
    return self._getGeomCoeff(var)
  File "/home/user/Programs/miniconda2/envs/FipyEnv2/lib/python3.6/site-packages/fipy/terms/term.py", line 465, in _getGeomCoeff
    self.geomCoeff = self._calcGeomCoeff(var)
  File "/home/user/Programs/miniconda2/envs/FipyEnv2/lib/python3.6/site-packages/fipy/terms/abstractDiffusionTerm.py", line 177, in _calcGeomCoeff
    tmpBop = (coeff * FaceVariable(mesh=mesh, value=mesh._faceAreas) / mesh._cellDistances)[numerix.newaxis, :]
  File "/home/user/Programs/miniconda2/envs/FipyEnv2/lib/python3.6/site-packages/fipy/variables/variable.py", line 1151, in __mul__
    return self._BinaryOperatorVariable(lambda a,b: a*b, other)
  File "/home/user/Programs/miniconda2/envs/FipyEnv2/lib/python3.6/site-packages/fipy/variables/variable.py", line 1116, in _BinaryOperatorVariable
    if not v.unit.isDimensionless() or len(v.shape) > 3:
  File "/home/user/Programs/miniconda2/envs/FipyEnv2/lib/python3.6/site-packages/fipy/variables/variable.py", line 255, in _getUnit
    return self._extractUnit(self.value)
  File "/home/user/Programs/miniconda2/envs/FipyEnv2/lib/python3.6/site-packages/fipy/variables/variable.py", line 538, in _getValue
    value = self._calcValue()
  File "/home/user/Programs/miniconda2/envs/FipyEnv2/lib/python3.6/site-packages/fipy/variables/cellToFaceVariable.py", line 48, in _calcValue
    alpha = self.mesh._faceToCellDistanceRatio
  File "/home/user/Programs/miniconda2/envs/FipyEnv2/lib/python3.6/site-packages/fipy/meshes/uniformGrid3D.py", line 269, in _faceToCellDistanceRatio
    XZdis[..., 0,...] = 1
IndexError: an index can only have a single ellipsis ('...')

https://www.ctcms.nist.gov/fipy/INSTALLATION.htmlの «推奨される方法» を使用して fipy をインストールしました。Pthon 3.6 と Python 2.7 の両方に Miniconda を使用してインストールしようとしましたが、同じエラーが発生しました。

Grid3D を使用して方程式を解くには?

4

1 に答える 1