Issue with single precision complex numbers in petsc4py
Dear PETSc community, I have a question regarding the single precision complex numbers of petsc4py. I configured PETSc with the “--with-scalar-type=complex --with-precision=single" option before compiling, but all the DA structures I created with petsc4py had double precision. Here is a minimum test code on Python 3.8/PETSc 3.12/petsc4py 3.12: both print commands show data type of complex128. Could anybody please help me? Thanks! import petsc4py import sys petsc4py.init(sys.argv) from petsc4py import PETSc da=PETSc.DA().create(sizes=[2,2,2],dof=1,stencil_type=0,stencil_width=1,boundary_type=1) da_1 = da.createGlobalVec() print(petsc4py.PETSc.ComplexType) print(da_1.getArray().dtype) Best regards, Peng Sun
First send configure.log so we can see the setup. Thanks, Matt On Thu, Oct 13, 2022 at 12:53 AM Peng Sun <[email protected]> wrote:
Dear PETSc community,
I have a question regarding the single precision complex numbers of petsc4py. I configured PETSc with the “--with-scalar-type=complex --with-precision=single" option before compiling, but all the DA structures I created with petsc4py had double precision.
Here is a minimum test code on Python 3.8/PETSc 3.12/petsc4py 3.12: both print commands show data type of complex128. Could anybody please help me? Thanks!
import petsc4pyimport sys petsc4py.init(sys.argv)from petsc4py import PETSc
da=PETSc.DA().create(sizes=[2,2,2],dof=1,stencil_type=0,stencil_width=1,boundary_type=1) da_1 = da.createGlobalVec()print(petsc4py.PETSc.ComplexType)print(da_1.getArray().dtype)
Best regards,
Peng Sun
-- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
Hi Matt, Sure, please see the attached configure.log file. Thanks! Best regards, Peng Sun ________________________________ From: Matthew Knepley <[email protected]> Sent: Thursday, October 13, 2022 6:34 AM To: Peng Sun <[email protected]> Cc: [email protected] <[email protected]> Subject: Re: [petsc-users] Issue with single precision complex numbers in petsc4py First send configure.log so we can see the setup. Thanks, Matt On Thu, Oct 13, 2022 at 12:53 AM Peng Sun <[email protected]<mailto:[email protected]>> wrote: Dear PETSc community, I have a question regarding the single precision complex numbers of petsc4py. I configured PETSc with the “--with-scalar-type=complex --with-precision=single" option before compiling, but all the DA structures I created with petsc4py had double precision. Here is a minimum test code on Python 3.8/PETSc 3.12/petsc4py 3.12: both print commands show data type of complex128. Could anybody please help me? Thanks! import petsc4py import sys petsc4py.init(sys.argv) from petsc4py import PETSc da=PETSc.DA().create(sizes=[2,2,2],dof=1,stencil_type=0,stencil_width=1,boundary_type=1) da_1 = da.createGlobalVec() print(petsc4py.PETSc.ComplexType) print(da_1.getArray().dtype) Best regards, Peng Sun -- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener https://www.cse.buffalo.edu/~knepley/<http://www.cse.buffalo.edu/~knepley/>
Lisandro, PETSc is compiled for single. Does petsc4py respect this, or does it always use double for getArray() and friends? Thanks, Matt On Thu, Oct 13, 2022 at 11:42 AM Peng Sun <[email protected]> wrote:
Hi Matt,
Sure, please see the attached configure.log file. Thanks!
Best regards, Peng Sun
------------------------------ *From:* Matthew Knepley <[email protected]> *Sent:* Thursday, October 13, 2022 6:34 AM *To:* Peng Sun <[email protected]> *Cc:* [email protected] <[email protected]> *Subject:* Re: [petsc-users] Issue with single precision complex numbers in petsc4py
First send configure.log so we can see the setup.
Thanks,
Matt
On Thu, Oct 13, 2022 at 12:53 AM Peng Sun <[email protected]> wrote:
Dear PETSc community,
I have a question regarding the single precision complex numbers of petsc4py. I configured PETSc with the “--with-scalar-type=complex --with-precision=single" option before compiling, but all the DA structures I created with petsc4py had double precision.
Here is a minimum test code on Python 3.8/PETSc 3.12/petsc4py 3.12: both print commands show data type of complex128. Could anybody please help me? Thanks!
import petsc4pyimport sys petsc4py.init(sys.argv)from petsc4py import PETSc
da=PETSc.DA().create(sizes=[2,2,2],dof=1,stencil_type=0,stencil_width=1,boundary_type=1) da_1 = da.createGlobalVec()print(petsc4py.PETSc.ComplexType)print(da_1.getArray().dtype)
Best regards,
Peng Sun
-- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener
https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
Matt Yes, petsc4py does the right thing. This is probably. Picking up the wrong PETSc arch. Peng, can you please run this? import petsc4py petsc4py.init() print(petsc4py.get_config())
On Oct 13, 2022, at 11:23 PM, Matthew Knepley <[email protected]> wrote:
Lisandro,
PETSc is compiled for single. Does petsc4py respect this, or does it always use double for getArray() and friends?
Thanks,
Matt
On Thu, Oct 13, 2022 at 11:42 AM Peng Sun <[email protected] <mailto:[email protected]>> wrote: Hi Matt,
Sure, please see the attached configure.log file. Thanks!
Best regards, Peng Sun
From: Matthew Knepley <[email protected] <mailto:[email protected]>> Sent: Thursday, October 13, 2022 6:34 AM To: Peng Sun <[email protected] <mailto:[email protected]>> Cc: [email protected] <mailto:[email protected]> <[email protected] <mailto:[email protected]>> Subject: Re: [petsc-users] Issue with single precision complex numbers in petsc4py
First send configure.log so we can see the setup.
Thanks,
Matt
On Thu, Oct 13, 2022 at 12:53 AM Peng Sun <[email protected] <mailto:[email protected]>> wrote: Dear PETSc community,
I have a question regarding the single precision complex numbers of petsc4py. I configured PETSc with the “--with-scalar-type=complex --with-precision=single" option before compiling, but all the DA structures I created with petsc4py had double precision.
Here is a minimum test code on Python 3.8/PETSc 3.12/petsc4py 3.12: both print commands show data type of complex128. Could anybody please help me? Thanks!
import petsc4py import sys petsc4py.init(sys.argv) from petsc4py import PETSc
da=PETSc.DA().create(sizes=[2,2,2],dof=1,stencil_type=0,stencil_width=1,boundary_type=1) da_1 = da.createGlobalVec() print(petsc4py.PETSc.ComplexType) print(da_1.getArray().dtype)
Best regards,
Peng Sun
-- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener
https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener
https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
Hi Stefano, Sure, please see the following. The PETSC_ARCH field is empty in the printout despite the fact that it was set to 'arch-linux-c-opt' in the shell. {'PETSC_DIR': '/home/pesun/.emopt', 'PETSC_ARCH': ''} Best regards, Peng Sun ________________________________ From: Stefano Zampini <[email protected]> Sent: Thursday, October 13, 2022 1:57 PM To: Matthew Knepley <[email protected]> Cc: Peng Sun <[email protected]>; [email protected] <[email protected]> Subject: Re: [petsc-users] Issue with single precision complex numbers in petsc4py Matt Yes, petsc4py does the right thing. This is probably. Picking up the wrong PETSc arch. Peng, can you please run this? import petsc4py petsc4py.init() print(petsc4py.get_config()) On Oct 13, 2022, at 11:23 PM, Matthew Knepley <[email protected]<mailto:[email protected]>> wrote: Lisandro, PETSc is compiled for single. Does petsc4py respect this, or does it always use double for getArray() and friends? Thanks, Matt On Thu, Oct 13, 2022 at 11:42 AM Peng Sun <[email protected]<mailto:[email protected]>> wrote: Hi Matt, Sure, please see the attached configure.log file. Thanks! Best regards, Peng Sun ________________________________ From: Matthew Knepley <[email protected]<mailto:[email protected]>> Sent: Thursday, October 13, 2022 6:34 AM To: Peng Sun <[email protected]<mailto:[email protected]>> Cc: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>> Subject: Re: [petsc-users] Issue with single precision complex numbers in petsc4py First send configure.log so we can see the setup. Thanks, Matt On Thu, Oct 13, 2022 at 12:53 AM Peng Sun <[email protected]<mailto:[email protected]>> wrote: Dear PETSc community, I have a question regarding the single precision complex numbers of petsc4py. I configured PETSc with the “--with-scalar-type=complex --with-precision=single" option before compiling, but all the DA structures I created with petsc4py had double precision. Here is a minimum test code on Python 3.8/PETSc 3.12/petsc4py 3.12: both print commands show data type of complex128. Could anybody please help me? Thanks! import petsc4py import sys petsc4py.init(sys.argv) from petsc4py import PETSc da=PETSc.DA().create(sizes=[2,2,2],dof=1,stencil_type=0,stencil_width=1,boundary_type=1) da_1 = da.createGlobalVec() print(petsc4py.PETSc.ComplexType) print(da_1.getArray().dtype) Best regards, Peng Sun -- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener https://www.cse.buffalo.edu/~knepley/<http://www.cse.buffalo.edu/~knepley/> -- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener https://www.cse.buffalo.edu/~knepley/<http://www.cse.buffalo.edu/~knepley/>
On Thu, Oct 13, 2022 at 5:27 PM Peng Sun <[email protected]> wrote:
Hi Stefano,
Sure, please see the following. The PETSC_ARCH field is empty in the printout despite the fact that it was set to 'arch-linux-c-opt' in the shell.
{'PETSC_DIR': '/home/pesun/.emopt', 'PETSC_ARCH': ''}
Can you show the whole output? Also, did you remember to 'export' it so that it goes to subshells? Matt
Best regards, Peng Sun ------------------------------ *From:* Stefano Zampini <[email protected]> *Sent:* Thursday, October 13, 2022 1:57 PM *To:* Matthew Knepley <[email protected]> *Cc:* Peng Sun <[email protected]>; [email protected] < [email protected]> *Subject:* Re: [petsc-users] Issue with single precision complex numbers in petsc4py
Matt
Yes, petsc4py does the right thing. This is probably. Picking up the wrong PETSc arch.
Peng, can you please run this?
import petsc4py petsc4py.init() print(petsc4py.get_config())
On Oct 13, 2022, at 11:23 PM, Matthew Knepley <[email protected]> wrote:
Lisandro,
PETSc is compiled for single. Does petsc4py respect this, or does it always use double for getArray() and friends?
Thanks,
Matt
On Thu, Oct 13, 2022 at 11:42 AM Peng Sun <[email protected]> wrote:
Hi Matt,
Sure, please see the attached configure.log file. Thanks!
Best regards, Peng Sun
------------------------------ *From:* Matthew Knepley <[email protected]> *Sent:* Thursday, October 13, 2022 6:34 AM *To:* Peng Sun <[email protected]> *Cc:* [email protected] <[email protected]> *Subject:* Re: [petsc-users] Issue with single precision complex numbers in petsc4py
First send configure.log so we can see the setup.
Thanks,
Matt
On Thu, Oct 13, 2022 at 12:53 AM Peng Sun <[email protected]> wrote:
Dear PETSc community,
I have a question regarding the single precision complex numbers of petsc4py. I configured PETSc with the “--with-scalar-type=complex --with-precision=single" option before compiling, but all the DA structures I created with petsc4py had double precision.
Here is a minimum test code on Python 3.8/PETSc 3.12/petsc4py 3.12: both print commands show data type of complex128. Could anybody please help me? Thanks!
import petsc4pyimport sys petsc4py.init(sys.argv)from petsc4py import PETSc
da=PETSc.DA().create(sizes=[2,2,2],dof=1,stencil_type=0,stencil_width=1,boundary_type=1) da_1 = da.createGlobalVec()print(petsc4py.PETSc.ComplexType)print(da_1.getArray().dtype)
Best regards,
Peng Sun
-- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener
https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener
https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
Hi Matt, Please see the following screenshot. Yes, I exported the PETSC_ARCH variable before running the script. Note the "Invalid MIT-MAGIC-COOKIE-1 key" string is related to the X server and in all Python printout, not on PETSc. [cid:95e2940b-842a-4f1b-a542-bad8737d3b38] Best regards, Peng Sun ________________________________ From: Matthew Knepley <[email protected]> Sent: Thursday, October 13, 2022 3:57 PM To: Peng Sun <[email protected]> Cc: Stefano Zampini <[email protected]>; [email protected] <[email protected]> Subject: Re: [petsc-users] Issue with single precision complex numbers in petsc4py On Thu, Oct 13, 2022 at 5:27 PM Peng Sun <[email protected]<mailto:[email protected]>> wrote: Hi Stefano, Sure, please see the following. The PETSC_ARCH field is empty in the printout despite the fact that it was set to 'arch-linux-c-opt' in the shell. {'PETSC_DIR': '/home/pesun/.emopt', 'PETSC_ARCH': ''} Can you show the whole output? Also, did you remember to 'export' it so that it goes to subshells? Matt Best regards, Peng Sun ________________________________ From: Stefano Zampini <[email protected]<mailto:[email protected]>> Sent: Thursday, October 13, 2022 1:57 PM To: Matthew Knepley <[email protected]<mailto:[email protected]>> Cc: Peng Sun <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>> Subject: Re: [petsc-users] Issue with single precision complex numbers in petsc4py Matt Yes, petsc4py does the right thing. This is probably. Picking up the wrong PETSc arch. Peng, can you please run this? import petsc4py petsc4py.init() print(petsc4py.get_config()) On Oct 13, 2022, at 11:23 PM, Matthew Knepley <[email protected]<mailto:[email protected]>> wrote: Lisandro, PETSc is compiled for single. Does petsc4py respect this, or does it always use double for getArray() and friends? Thanks, Matt On Thu, Oct 13, 2022 at 11:42 AM Peng Sun <[email protected]<mailto:[email protected]>> wrote: Hi Matt, Sure, please see the attached configure.log file. Thanks! Best regards, Peng Sun ________________________________ From: Matthew Knepley <[email protected]<mailto:[email protected]>> Sent: Thursday, October 13, 2022 6:34 AM To: Peng Sun <[email protected]<mailto:[email protected]>> Cc: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>> Subject: Re: [petsc-users] Issue with single precision complex numbers in petsc4py First send configure.log so we can see the setup. Thanks, Matt On Thu, Oct 13, 2022 at 12:53 AM Peng Sun <[email protected]<mailto:[email protected]>> wrote: Dear PETSc community, I have a question regarding the single precision complex numbers of petsc4py. I configured PETSc with the “--with-scalar-type=complex --with-precision=single" option before compiling, but all the DA structures I created with petsc4py had double precision. Here is a minimum test code on Python 3.8/PETSc 3.12/petsc4py 3.12: both print commands show data type of complex128. Could anybody please help me? Thanks! import petsc4py import sys petsc4py.init(sys.argv) from petsc4py import PETSc da=PETSc.DA().create(sizes=[2,2,2],dof=1,stencil_type=0,stencil_width=1,boundary_type=1) da_1 = da.createGlobalVec() print(petsc4py.PETSc.ComplexType) print(da_1.getArray().dtype) Best regards, Peng Sun -- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener https://www.cse.buffalo.edu/~knepley/<http://www.cse.buffalo.edu/~knepley/> -- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener https://www.cse.buffalo.edu/~knepley/<http://www.cse.buffalo.edu/~knepley/> -- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener https://www.cse.buffalo.edu/~knepley/<http://www.cse.buffalo.edu/~knepley/>
It seems that you installed petsc4py separately. I would suggest to add the configure option --with-petsc4py=1 and follow the instructions to set PYTHONPATH before using petsc4py. Hong (Mr.)
On Oct 13, 2022, at 10:42 AM, Peng Sun <[email protected]> wrote:
Hi Matt,
Sure, please see the attached configure.log file. Thanks!
Best regards, Peng Sun
From: Matthew Knepley <[email protected]> Sent: Thursday, October 13, 2022 6:34 AM To: Peng Sun <[email protected]> Cc: [email protected] <[email protected]> Subject: Re: [petsc-users] Issue with single precision complex numbers in petsc4py
First send configure.log so we can see the setup.
Thanks,
Matt
On Thu, Oct 13, 2022 at 12:53 AM Peng Sun <[email protected]> wrote: Dear PETSc community,
I have a question regarding the single precision complex numbers of petsc4py. I configured PETSc with the “--with-scalar-type=complex --with-precision=single" option before compiling, but all the DA structures I created with petsc4py had double precision.
Here is a minimum test code on Python 3.8/PETSc 3.12/petsc4py 3.12: both print commands show data type of complex128. Could anybody please help me? Thanks!
import petsc4py
import sys petsc4py.init(sys.argv)
from petsc4py import PETSc
da=PETSc.DA().create(sizes=[ 2,2,2],dof=1,stencil_type=0,stencil_width=1,boundary_type=1 ) da_1 = da.createGlobalVec()
print (petsc4py.PETSc.ComplexType)
print(da_1.getArray().dtype)
Best regards, Peng Sun
-- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener
https://www.cse.buffalo.edu/~knepley/ <configure.log>
Hi Hong, Thanks for the advice. I could not install petsc4py with the --with-petsc4py=1 option, which gave me an "No rule to make target 'petsc4py-install'" error when I ran "make install". That was why I needed to install petsc4py separately after the PETSc was installed. Best regards, Peng Sun ________________________________ From: Zhang, Hong <[email protected]> Sent: Thursday, October 13, 2022 4:30 PM To: Peng Sun <[email protected]> Cc: [email protected] <[email protected]> Subject: Re: [petsc-users] Issue with single precision complex numbers in petsc4py It seems that you installed petsc4py separately. I would suggest to add the configure option --with-petsc4py=1 and follow the instructions to set PYTHONPATH before using petsc4py. Hong (Mr.)
On Oct 13, 2022, at 10:42 AM, Peng Sun <[email protected]> wrote:
Hi Matt,
Sure, please see the attached configure.log file. Thanks!
Best regards, Peng Sun
From: Matthew Knepley <[email protected]> Sent: Thursday, October 13, 2022 6:34 AM To: Peng Sun <[email protected]> Cc: [email protected] <[email protected]> Subject: Re: [petsc-users] Issue with single precision complex numbers in petsc4py
First send configure.log so we can see the setup.
Thanks,
Matt
On Thu, Oct 13, 2022 at 12:53 AM Peng Sun <[email protected]> wrote: Dear PETSc community,
I have a question regarding the single precision complex numbers of petsc4py. I configured PETSc with the “--with-scalar-type=complex --with-precision=single" option before compiling, but all the DA structures I created with petsc4py had double precision.
Here is a minimum test code on Python 3.8/PETSc 3.12/petsc4py 3.12: both print commands show data type of complex128. Could anybody please help me? Thanks!
import petsc4py
import sys petsc4py.init(sys.argv)
from petsc4py import PETSc
da=PETSc.DA().create(sizes=[ 2,2,2],dof=1,stencil_type=0,stencil_width=1,boundary_type=1 ) da_1 = da.createGlobalVec()
print (petsc4py.PETSc.ComplexType)
print(da_1.getArray().dtype)
Best regards, Peng Sun
-- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener
https://www.cse.buffalo.edu/~knepley/ <configure.log>
Is there any reason you can't use the most recent version of PETSc4py? The one you are working with is several years old
On Oct 13, 2022, at 8:53 PM, Peng Sun <[email protected]> wrote:
Hi Hong,
Thanks for the advice. I could not install petsc4py with the --with-petsc4py=1 option, which gave me an "No rule to make target 'petsc4py-install'" error when I ran "make install". That was why I needed to install petsc4py separately after the PETSc was installed.
Best regards, Peng Sun From: Zhang, Hong <[email protected] <mailto:[email protected]>> Sent: Thursday, October 13, 2022 4:30 PM To: Peng Sun <[email protected] <mailto:[email protected]>> Cc: [email protected] <mailto:[email protected]> <[email protected] <mailto:[email protected]>> Subject: Re: [petsc-users] Issue with single precision complex numbers in petsc4py
It seems that you installed petsc4py separately. I would suggest to add the configure option --with-petsc4py=1 and follow the instructions to set PYTHONPATH before using petsc4py.
Hong (Mr.)
On Oct 13, 2022, at 10:42 AM, Peng Sun <[email protected] <mailto:[email protected]>> wrote:
Hi Matt,
Sure, please see the attached configure.log file. Thanks!
Best regards, Peng Sun
From: Matthew Knepley <[email protected] <mailto:[email protected]>> Sent: Thursday, October 13, 2022 6:34 AM To: Peng Sun <[email protected] <mailto:[email protected]>> Cc: [email protected] <mailto:[email protected]> <[email protected] <mailto:[email protected]>> Subject: Re: [petsc-users] Issue with single precision complex numbers in petsc4py
First send configure.log so we can see the setup.
Thanks,
Matt
On Thu, Oct 13, 2022 at 12:53 AM Peng Sun <[email protected] <mailto:[email protected]>> wrote: Dear PETSc community,
I have a question regarding the single precision complex numbers of petsc4py. I configured PETSc with the “--with-scalar-type=complex --with-precision=single" option before compiling, but all the DA structures I created with petsc4py had double precision.
Here is a minimum test code on Python 3.8/PETSc 3.12/petsc4py 3.12: both print commands show data type of complex128. Could anybody please help me? Thanks!
import petsc4py
import sys petsc4py.init(sys.argv)
from petsc4py import PETSc
da=PETSc.DA().create(sizes=[ 2,2,2],dof=1,stencil_type=0,stencil_width=1,boundary_type=1 ) da_1 = da.createGlobalVec()
print (petsc4py.PETSc.ComplexType)
print(da_1.getArray().dtype)
Best regards, Peng Sun
-- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener
https://www.cse.buffalo.edu/~knepley/ <https://www.cse.buffalo.edu/~knepley/> <configure.log>
Hi Barry, I overwrote the old v3.12.0 with the latest version of 3.18.0, and I could use single-precision complex successfully. Then I switched back to v3.12.0 and I can reproduce the same issue. So it seems like that the single-precision complex issue is specific to v3.12.0. I do not necessarily need to use the old version. Thanks for your help! Best regards, Peng Sun ________________________________ From: Barry Smith <[email protected]> Sent: Thursday, October 13, 2022 7:03 PM To: Peng Sun <[email protected]> Cc: Zhang, Hong <[email protected]>; [email protected] <[email protected]> Subject: Re: [petsc-users] Issue with single precision complex numbers in petsc4py Is there any reason you can't use the most recent version of PETSc4py? The one you are working with is several years old On Oct 13, 2022, at 8:53 PM, Peng Sun <[email protected]<mailto:[email protected]>> wrote: Hi Hong, Thanks for the advice. I could not install petsc4py with the --with-petsc4py=1 option, which gave me an "No rule to make target 'petsc4py-install'" error when I ran "make install". That was why I needed to install petsc4py separately after the PETSc was installed. Best regards, Peng Sun ________________________________ From: Zhang, Hong <[email protected]<mailto:[email protected]>> Sent: Thursday, October 13, 2022 4:30 PM To: Peng Sun <[email protected]<mailto:[email protected]>> Cc: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>> Subject: Re: [petsc-users] Issue with single precision complex numbers in petsc4py It seems that you installed petsc4py separately. I would suggest to add the configure option --with-petsc4py=1 and follow the instructions to set PYTHONPATH before using petsc4py. Hong (Mr.)
On Oct 13, 2022, at 10:42 AM, Peng Sun <[email protected]<mailto:[email protected]>> wrote:
Hi Matt,
Sure, please see the attached configure.log file. Thanks!
Best regards, Peng Sun
From: Matthew Knepley <[email protected]<mailto:[email protected]>> Sent: Thursday, October 13, 2022 6:34 AM To: Peng Sun <[email protected]<mailto:[email protected]>> Cc: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>> Subject: Re: [petsc-users] Issue with single precision complex numbers in petsc4py
First send configure.log so we can see the setup.
Thanks,
Matt
On Thu, Oct 13, 2022 at 12:53 AM Peng Sun <[email protected]<mailto:[email protected]>> wrote: Dear PETSc community,
I have a question regarding the single precision complex numbers of petsc4py. I configured PETSc with the “--with-scalar-type=complex --with-precision=single" option before compiling, but all the DA structures I created with petsc4py had double precision.
Here is a minimum test code on Python 3.8/PETSc 3.12/petsc4py 3.12: both print commands show data type of complex128. Could anybody please help me? Thanks!
import petsc4py
import sys petsc4py.init(sys.argv)
from petsc4py import PETSc
da=PETSc.DA().create(sizes=[ 2,2,2],dof=1,stencil_type=0,stencil_width=1,boundary_type=1 ) da_1 = da.createGlobalVec()
print (petsc4py.PETSc.ComplexType)
print(da_1.getArray().dtype)
Best regards, Peng Sun
-- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener
https://www.cse.buffalo.edu/~knepley/ <configure.log>
On Oct 14, 2022, at 3:53 AM, Peng Sun <[email protected]> wrote:
Hi Hong,
Thanks for the advice. I could not install petsc4py with the --with-petsc4py=1 option, which gave me an "No rule to make target 'petsc4py-install'" error when I ran "make install". That was why I needed to install petsc4py separately after the PETSc was installed.
After you installed PETSc, go to src/binding/petsc4py and run make install there. It will install in .local and it will be visible to python. Is this how you installed it?
Best regards, Peng Sun From: Zhang, Hong <[email protected]> Sent: Thursday, October 13, 2022 4:30 PM To: Peng Sun <[email protected]> Cc: [email protected] <[email protected]> Subject: Re: [petsc-users] Issue with single precision complex numbers in petsc4py
It seems that you installed petsc4py separately. I would suggest to add the configure option --with-petsc4py=1 and follow the instructions to set PYTHONPATH before using petsc4py.
Hong (Mr.)
On Oct 13, 2022, at 10:42 AM, Peng Sun <[email protected]> wrote:
Hi Matt,
Sure, please see the attached configure.log file. Thanks!
Best regards, Peng Sun
From: Matthew Knepley <[email protected]> Sent: Thursday, October 13, 2022 6:34 AM To: Peng Sun <[email protected]> Cc: [email protected] <[email protected]> Subject: Re: [petsc-users] Issue with single precision complex numbers in petsc4py
First send configure.log so we can see the setup.
Thanks,
Matt
On Thu, Oct 13, 2022 at 12:53 AM Peng Sun <[email protected]> wrote: Dear PETSc community,
I have a question regarding the single precision complex numbers of petsc4py. I configured PETSc with the “--with-scalar-type=complex --with-precision=single" option before compiling, but all the DA structures I created with petsc4py had double precision.
Here is a minimum test code on Python 3.8/PETSc 3.12/petsc4py 3.12: both print commands show data type of complex128. Could anybody please help me? Thanks!
import petsc4py
import sys petsc4py.init(sys.argv)
from petsc4py import PETSc
da=PETSc.DA().create(sizes=[ 2,2,2],dof=1,stencil_type=0,stencil_width=1,boundary_type=1 ) da_1 = da.createGlobalVec()
print (petsc4py.PETSc.ComplexType)
print(da_1.getArray().dtype)
Best regards, Peng Sun
-- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener
https://www.cse.buffalo.edu/~knepley/ <https://www.cse.buffalo.edu/~knepley/> <configure.log>
Hi Stefano, No I used pip to install petsc4py after I installed PETSc. I did not see the binding folder under /src. Best regards, Peng Sun ________________________________ From: Stefano Zampini <[email protected]> Sent: Friday, October 14, 2022 4:36 AM To: Peng Sun <[email protected]> Cc: Zhang, Hong <[email protected]>; [email protected] <[email protected]> Subject: Re: [petsc-users] Issue with single precision complex numbers in petsc4py On Oct 14, 2022, at 3:53 AM, Peng Sun <[email protected]<mailto:[email protected]>> wrote: Hi Hong, Thanks for the advice. I could not install petsc4py with the --with-petsc4py=1 option, which gave me an "No rule to make target 'petsc4py-install'" error when I ran "make install". That was why I needed to install petsc4py separately after the PETSc was installed. After you installed PETSc, go to src/binding/petsc4py and run make install there. It will install in .local and it will be visible to python. Is this how you installed it? Best regards, Peng Sun ________________________________ From: Zhang, Hong <[email protected]<mailto:[email protected]>> Sent: Thursday, October 13, 2022 4:30 PM To: Peng Sun <[email protected]<mailto:[email protected]>> Cc: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>> Subject: Re: [petsc-users] Issue with single precision complex numbers in petsc4py It seems that you installed petsc4py separately. I would suggest to add the configure option --with-petsc4py=1 and follow the instructions to set PYTHONPATH before using petsc4py. Hong (Mr.)
On Oct 13, 2022, at 10:42 AM, Peng Sun <[email protected]<mailto:[email protected]>> wrote:
Hi Matt,
Sure, please see the attached configure.log file. Thanks!
Best regards, Peng Sun
From: Matthew Knepley <[email protected]<mailto:[email protected]>> Sent: Thursday, October 13, 2022 6:34 AM To: Peng Sun <[email protected]<mailto:[email protected]>> Cc: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>> Subject: Re: [petsc-users] Issue with single precision complex numbers in petsc4py
First send configure.log so we can see the setup.
Thanks,
Matt
On Thu, Oct 13, 2022 at 12:53 AM Peng Sun <[email protected]<mailto:[email protected]>> wrote: Dear PETSc community,
I have a question regarding the single precision complex numbers of petsc4py. I configured PETSc with the “--with-scalar-type=complex --with-precision=single" option before compiling, but all the DA structures I created with petsc4py had double precision.
Here is a minimum test code on Python 3.8/PETSc 3.12/petsc4py 3.12: both print commands show data type of complex128. Could anybody please help me? Thanks!
import petsc4py
import sys petsc4py.init(sys.argv)
from petsc4py import PETSc
da=PETSc.DA().create(sizes=[ 2,2,2],dof=1,stencil_type=0,stencil_width=1,boundary_type=1 ) da_1 = da.createGlobalVec()
print (petsc4py.PETSc.ComplexType)
print(da_1.getArray().dtype)
Best regards, Peng Sun
-- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener
https://www.cse.buffalo.edu/~knepley/ <configure.log>
On Fri, Oct 14, 2022, 19:46 Peng Sun <[email protected]> wrote:
Hi Stefano,
No I used pip to install petsc4py after I installed PETSc. I did not see the binding folder under /src
Not sure which was the first version petsc4py was shipped with PETSc , for sure 3.18 has it. Best regards,
Peng Sun ------------------------------ *From:* Stefano Zampini <[email protected]> *Sent:* Friday, October 14, 2022 4:36 AM *To:* Peng Sun <[email protected]> *Cc:* Zhang, Hong <[email protected]>; [email protected] < [email protected]> *Subject:* Re: [petsc-users] Issue with single precision complex numbers in petsc4py
On Oct 14, 2022, at 3:53 AM, Peng Sun <[email protected]> wrote:
Hi Hong,
Thanks for the advice. I could not install petsc4py with the --with-petsc4py=1 option, which gave me an "No rule to make target 'petsc4py-install'" error when I ran "make install". That was why I needed to install petsc4py separately after the PETSc was installed.
After you installed PETSc, go to src/binding/petsc4py and run make install there. It will install in .local and it will be visible to python. Is this how you installed it?
Best regards, Peng Sun ------------------------------ *From:* Zhang, Hong <[email protected]> *Sent:* Thursday, October 13, 2022 4:30 PM *To:* Peng Sun <[email protected]> *Cc:* [email protected] <[email protected]> *Subject:* Re: [petsc-users] Issue with single precision complex numbers in petsc4py
It seems that you installed petsc4py separately. I would suggest to add the configure option --with-petsc4py=1 and follow the instructions to set PYTHONPATH before using petsc4py.
Hong (Mr.)
On Oct 13, 2022, at 10:42 AM, Peng Sun <[email protected]> wrote:
Hi Matt,
Sure, please see the attached configure.log file. Thanks!
Best regards, Peng Sun
From: Matthew Knepley <[email protected]> Sent: Thursday, October 13, 2022 6:34 AM To: Peng Sun <[email protected]> Cc: [email protected] <[email protected]> Subject: Re: [petsc-users] Issue with single precision complex numbers in petsc4py
First send configure.log so we can see the setup.
Thanks,
Matt
On Thu, Oct 13, 2022 at 12:53 AM Peng Sun <[email protected]> wrote: Dear PETSc community,
I have a question regarding the single precision complex numbers of petsc4py. I configured PETSc with the “--with-scalar-type=complex --with-precision=single" option before compiling, but all the DA structures I created with petsc4py had double precision.
Here is a minimum test code on Python 3.8/PETSc 3.12/petsc4py 3.12: both print commands show data type of complex128. Could anybody please help me? Thanks!
import petsc4py
import sys petsc4py.init(sys.argv)
from petsc4py import PETSc
da=PETSc.DA().create(sizes=[ 2,2,2],dof=1,stencil_type=0,stencil_width=1,boundary_type=1 ) da_1 = da.createGlobalVec()
print (petsc4py.PETSc.ComplexType)
print(da_1.getArray().dtype)
Best regards, Peng Sun
-- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener
https://www.cse.buffalo.edu/~knepley/ <configure.log>
participants (5)
-
Barry Smith -
Matthew Knepley -
Peng Sun -
Stefano Zampini -
Zhang, Hong