[petsc-users] petsc4py with complex numbers?

Aurelien Ponte aurelien.ponte at ifremer.fr
Sun Sep 25 23:47:03 CDT 2016


Hi,

I am trying to solve a linear problem whose operator has complex 
coefficients via petsc4py
but keep running into the following error:

   File 
"/Users/aponte/Current_projects/people/kraig_marine/wd_response/solver/set_L.py", 
line 52, in set_L
     L.setValueStencil(row, col, value)
   File "PETSc/Mat.pyx", line 882, in petsc4py.PETSc.Mat.setValueStencil 
(src/petsc4py.PETSc.c:124785)
   File "PETSc/petscmat.pxi", line 1017, in 
petsc4py.PETSc.matsetvaluestencil (src/petsc4py.PETSc.c:31469)
   File "PETSc/arraynpy.pxi", line 140, in petsc4py.PETSc.iarray_s 
(src/petsc4py.PETSc.c:8811)
   File "PETSc/arraynpy.pxi", line 121, in petsc4py.PETSc.iarray 
(src/petsc4py.PETSc.c:8542)
TypeError: can't convert complex to float

The code looks like:

for j in range(ys, ye):
     for i in range(xs, xe):
         row.index = (i, j, kx)
         row.field = 0
         col.index = (i, j, kx) col.field=0
         L.setValueStencil(row, col, 1j)

Any idea about what am I doing wrong?

cheers

aurelien



-- 
Aurélien Ponte
Tel: (+33) 2 98 22 40 73
Fax: (+33) 2 98 22 44 96
UMR 6523, IFREMER
ZI de la Pointe du Diable
CS 10070
29280 Plouzané



More information about the petsc-users mailing list