[petsc-users] Matrix exponential
Jose E. Roman
jroman at dsic.upv.es
Sat Sep 4 04:33:43 CDT 2021
No problem, do
F.setScale(-1j*t)
What do you mean "still facing problem with complex matrices"? Did you get an error during installation? Did it install for real scalars? Try setting PETSC_CONFIGURE_OPTIONS only, and unset PETSC_DIR PETSC_ARCH. Otherwise pip may not take into account --with-scalar-type=complex
Jose
> El 4 sept 2021, a las 2:11, Paul, Sanku <paulsank at msu.edu> escribió:
>
> Hi Jose,
>
> I tried to install
> ml -* foss/2019b Python SciPy-bundle/2019.10-Python-3.7.4
> virtualenv slepc4py
> cd slepc4py
> source bin/activate
> pip install numpy mpi4py cython
> export PETSC_CONFIGURE_OPTIONS="--with-scalar-type=complex"
> export PETSC_DIR=/path/to/petsc PETSC_ARCH=your-arch-name
> pip install petsc petsc4py
> pip install slepc slepc4py
>
> But still facing problem with complex matrices. Please help me to fix this.
>
> Thanks,
> Sanku
>
>
> From: Paul, Sanku <paulsank at msu.edu>
> Sent: Friday, September 3, 2021 7:39 PM
> To: Jose E. Roman <jroman at dsic.upv.es>
> Cc: PETSc <petsc-users at mcs.anl.gov>
> Subject: Re: [petsc-users] Matrix exponential
>
> Hi Jose,
>
> I could now do matrix exponential but facing a problem with a complex matrix. In particular, I want to do \exp(-itH), where H is a Hamiltonian. How to implement this?
>
> Thanks,
> Sanku
> From: Jose E. Roman <jroman at dsic.upv.es>
> Sent: Friday, September 3, 2021 2:53 PM
> To: Paul, Sanku <paulsank at msu.edu>
> Cc: PETSc <petsc-users at mcs.anl.gov>
> Subject: Re: [petsc-users] Matrix exponential
>
> Please always reply to the list (Reply-All), not to myself.
>
> You should be able to convert from a scipy sparse matrix to a PETSc matrix via PETSc.Mat().createAIJWithArrays(). Don't know how if there is any example in the petsc4py documentation.
>
> Jose
>
>
> > El 3 sept 2021, a las 20:26, Paul, Sanku <paulsank at msu.edu> escribió:
> >
> > Dear Jose,
> >
> > Thank you very much for your help. I have another question can we just simply pass a sparse.csr.matrix to A. For instance, if B is the sparse.csr.matrix can we do A=B.copy(). Or do I have to do it in a different way?
> >
> > Best,
> > Sanku
> > From: Jose E. Roman <jroman at dsic.upv.es>
> > Sent: Friday, September 3, 2021 2:13 PM
> > To: Paul, Sanku <paulsank at msu.edu>
> > Cc: petsc-users at mcs.anl.gov <petsc-users at mcs.anl.gov>
> > Subject: Re: [petsc-users] Matrix exponential
> >
> > You should either create the FN object and then
> >
> > E.setFN(F)
> >
> > or extract the FN object and assign to a variable
> >
> > F = E.getFN()
> >
> > You can see an example in $SLEPC_DIR/src/binding/slepc4py/demo/ex6.py
> >
> >
> > Jose
> >
> >
> > > El 3 sept 2021, a las 19:53, Paul, Sanku <paulsank at msu.edu> escribió:
> > >
> > > Dear Sir/Ma'am,
> > >
> > > I am trying to use SLEPc to calculate matrix exponential in my python code but I am not getting the correct result. I have attached the code. Could you let me know what I am doing wrong. This is my first time using SLEPc. So, I would like to ask you if you could send me a tutorial on matrix exponential using SLEPc in python code.
> > >
> > > Best,
> > > Sanku
> > > <ex2.py>
More information about the petsc-users
mailing list