[petsc-users] petsc4py with complex numbers?

Aurelien Ponte aurelien.ponte at ifremer.fr
Mon Sep 26 10:23:04 CDT 2016


The output is:
<type 'numpy.float64'>

I installed petsc via macport and wrongly assumed complex number support 
would have been default.
I've just reinstalled petsc with it and it seems to be working.

thanks Lisandro !

aurelien



Le 25/09/16 à 23:00, Lisandro Dalcin a écrit :
> Are you sure you built petsc4py with a PETSc build with complex 
> scalars? Whats the output of  "print(PETSc.ScalarType)" ?
>
>
> On 26 September 2016 at 07:47, Aurelien Ponte 
> <aurelien.ponte at ifremer.fr <mailto:aurelien.ponte at ifremer.fr>> wrote:
>
>     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é
>
>
>
>
> -- 
> Lisandro Dalcin
> ============
> Research Scientist
> Computer, Electrical and Mathematical Sciences & Engineering (CEMSE)
> Extreme Computing Research Center (ECRC)
> King Abdullah University of Science and Technology (KAUST)
> http://ecrc.kaust.edu.sa/
>
> 4700 King Abdullah University of Science and Technology
> al-Khawarizmi Bldg (Bldg 1), Office # 0109
> Thuwal 23955-6900, Kingdom of Saudi Arabia
> http://www.kaust.edu.sa
>
> Office Phone: +966 12 808-0459


-- 
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é

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160926/b46133ab/attachment-0001.html>


More information about the petsc-users mailing list