On Wed, Feb 13, 2013 at 8:01 PM, Edwin Sze Lun Khoo <[email protected]>wrote:

> Hello,
>
> I was going through the examples.diffusion.1D example and got the
> following errors:
>
> Traceback (most recent call last):
>   File "C:\Users\User1\Dropbox\workspace\FiPy
> examples\src\diffusion_mesh1d_example.py", line 29, in <module>
>     eqX.solve(var=phi, dt=timeStepDuration)
>   File "C:\Python27\lib\site-packages\fipy\terms\term.py", line 209, in
> solve
>     solver = self._prepareLinearSystem(var, solver, boundaryConditions, dt)
>   File "C:\Python27\lib\site-packages\fipy\terms\term.py", line 171, in
> _prepareLinearSystem
>     buildExplicitIfOther=self._buildExplcitIfOther)
>   File "C:\Python27\lib\site-packages\fipy\terms\binaryTerm.py", line 68,
> in _buildAndAddMatrices
>     buildExplicitIfOther=buildExplicitIfOther)
>   File "C:\Python27\lib\site-packages\fipy\terms\unaryTerm.py", line 97,
> in _buildAndAddMatrices
>     diffusionGeomCoeff=diffusionGeomCoeff)
>   File "C:\Python27\lib\site-packages\fipy\terms\cellTerm.py", line 164,
> in _buildMatrix
>     self._buildMatrixNoInline_(L=L, oldArray=var.old, b=b, dt=dt,
> coeffVectors=coeffVectors)
>   File "C:\Python27\lib\site-packages\fipy\terms\cellTerm.py", line 149,
> in _buildMatrixNoInline_
>     L.addAt(coeffVectors['new value'].ravel() / dt, ids.ravel(),
> ids.swapaxes(0,1).ravel())
>   File "C:\Python27\lib\site-packages\fipy\matrices\pysparseMatrix.py",
> line 246, in addAt
>     self.matrix.update_add_at(vector, id1, id2)
> TypeError: Cannot cast array data from dtype('int64') to dtype('int32')
> according to the rule 'safe'
>
>
> I have a 64-bit Windows 7 machine and have installed 64-bit versions of
> FiPy 3.0, NumPy 1.7.0, SciPy 0.11.0, PySparse 1.1.1, and PyAMG 2.0.5, which
> are all obtained from http://www.lfd.uci.edu/~gohlke/pythonlibs/. If I
> include the following lines at the beginning of my script
>
> import os
> os.environ['FIPY_SOLVERS'] = 'pyamg'
>
> to force FiPy to use to the PyAMG preconditioners with the SciPy solvers,
> the script runs. Therefore, the problem is probably caused by PySparse. Are
> there workarounds to resolve this problem? Thanks!
>

Hi Edwin,

It is clearly a 32 / 64 bit incompatibility. Is it possible that the
PySparse installation isn’t in fact a 64 bit version?

If you want to hack the source code, you can manually covert the id1 and
id2 arrays to int32 using "astype". You can use the following to convert
before calling addAt.

          if hasattr(id1, 'astype') and id1.dtype.name == 'int64':
              id1 = id1.astype('int32')
          if hasattr(id2, 'astype') and id2.dtype.name == 'int64':
              id2 = id2.astype('int32')


This is taken from matrices/trilinosMatrix.py where there was a similar
issue, but I forget what caused it. You may have to do this in other places
as well, but it should be fairly limited.

Cheers

-- 
Daniel Wheeler
_______________________________________________
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