More helpfully, comparing it to your qg code, it looks like you need an equivalent to the line:


eigenmodes_real.vector()[:], eigenmodes_imag.vector()[:] = vr, vi


when the eigenmodes are functions on a mixed space.


J


From: firedrake-bounces@imperial.ac.uk <firedrake-bounces@imperial.ac.uk> on behalf of Shipton, Jemma <j.shipton@imperial.ac.uk>
Sent: 07 December 2016 15:57:33
To: firedrake
Subject: Re: [firedrake] eigenvalue problems with SLEPc
 

Hi Francis,


Your code doesn't assign anything to em_real and em_imag.


Jemma


From: firedrake-bounces@imperial.ac.uk <firedrake-bounces@imperial.ac.uk> on behalf of Francis Poulin <fpoulin@uwaterloo.ca>
Sent: 07 December 2016 15:34:50
To: firedrake
Subject: Re: [firedrake] eigenvalue problems with SLEPc
 
Hello Lawrence,

Thanks! 

I see that one major difference is you don't try and ask for the imaginary eigenavlue of magnitude 3.14 but for the eigenvalue of that magnitude. Since the eigenvalues are purely imaginary that is a clever way to get around that. Yes, that's working brilliantly.

However, I now see that my plots are just plotting zero.  I guess that means that I did something silly.  Maybe I can get your advice?

Using getEigenpair below we get petsc matrices vr an vi.  If we can convert say vr to em_real, then we can split it and plot the different fields.  Unfortunately, what worked in the QG code didn't seem to work here. 


# Find eigenvalues an eigenvectors
vr, vi = petsc_a.getVecs()
for i in range(nconv):
    lam = es.getEigenpair(i, vr, vi)
    print lam
    eval_real.append(lam.real)
    eval_imag.append(lam.imag)

    u_real, eta_real = em_real.split()
    #u_imag, eta_imag = em_imag.split()

    p = plot(eta_real)
    p.show()

What do you suggest we try?

Cheers, Francis


------------------
Francis Poulin
Associate Professor
Department of Applied Mathematics
University of Waterloo

email:           fpoulin@uwaterloo.ca
Web:            https://uwaterloo.ca/poulin-research-group/
Telephone:  +1 519 888 4567 x32637


________________________________________
From: firedrake-bounces@imperial.ac.uk [firedrake-bounces@imperial.ac.uk] on behalf of Lawrence Mitchell [lawrence.mitchell@imperial.ac.uk]
Sent: Wednesday, December 07, 2016 10:20 AM
To: firedrake@imperial.ac.uk
Subject: Re: [firedrake] eigenvalue problems with SLEPc

On 07/12/16 14:46, Francis Poulin wrote:
> Hello Lawrence,
>
> Thanks for the reply.
>
> 1) Sadly no.  I commented out the lines because they weren't
> working.  If you uncomment them you will see that plotting gives an
> error.
>
> Traceback (most recent call last): File "basin_modes_sw.py", line
> 86, in <module> p = plot(eta_real) File
> "/home/fpoulin/software/firedrake/src/firedrake/firedrake/plot.py",
> line 125, in plot raise TypeError("Unexpected type") TypeError:
> Unexpected type

Aha, I see, I was confusing which code I was looking at.

> 2) The version that I have posted now uses lapack and when I run
> that i get numbers I believe.  Some zero eigenavalues but the first
> non-zero ones have an imaginary part of 3.14, and then they
> increase.

> The fact that lapack gives the correct answers tells me that the
> weak form is set up correctly.  The problem is that when I use
> krylovschur, which is fast, specify we want a target imaginary,
> with value 3.14, it gives the eigenvalue with the largest
> magnitude.  I know that these are the easiest to converge to but
> SLEPc should allow us to pick a target.  I am not sure if the
> options are being set correctly.
>
> opts.setValue("eps_type", "krylovschur")
> opts.setValue("eps_spectrum", "target imaginary")
> opts.setValue("eps_tol", 1e-10) opts.setValue("spectral_shift",
> 3.14)

No, I don't think this is right.

If I use:

opts.setValue("eps_gen_non_hermitian", None)
opts.setValue("st_pc_factor_shift_type", "NONZERO")
# opts.setValue("eps_type", "lapack")
opts.setValue("eps_type", "krylovschur")
opts.setValue("eps_target_magnitude", None)
opts.setValue("eps_target", 3.14)
opts.setValue("eps_tol", 1e-10)
opts.setValue("st_type", "sinvert")

Then I can converge a few eigenvalues around 3.14i

Does that work for you?

Cheers,

Lawrence


_______________________________________________
firedrake mailing list
firedrake@imperial.ac.uk
https://mailman.ic.ac.uk/mailman/listinfo/firedrake