I don't think it's finding a trivial solution. I think that the issue is that you never solve the system. Having set up your linear solver, you are missing:
psi_solver.solve()
However, the linear solver in your code has another problem.
The equation isn't symmetric (the  beta*phi*psi.dx(0)*dx  term) so CG is unlikely to work. For 2D problems, using a direct solver is usually the right start:
 
solver_parameters={
                                         'ksp_type':'preonly',
                                         'pc_type':'lu'
                                      }
 
Second, should we be able to use matplotlib to plot the solutions?  I was able to get a demo to work but I can't do it for this script.
 
 
There are two problems here. The first is that you are calling the plot command from Matplotlib. Unsurprisingly, this does not know about Firedrake Functions. You need to call the Firedrake plot command.
p = plot(psi_soln)
p.show()
 
However, more importantly, the matplotlib functionality is mostly useful for debugging small systems. Your 50 x 50 mesh is already going to be very slow via this route.
 
2) The SW problem is not working much better I'm afraid.  It does not converge to a solution, which is I suppose better than converging to an incorrect solution.  I have a couple of concerns.
https://github.com/francispoulin/firedrakeQG/blob/master/linear_stommel_sw.py
First, i am trying to impose no-normal flow BCs.  I am trying to do what I understood Colin suggested but since it's not converging, maybe I misunderstood.
Second, I presume there is a better solver that I should be using?
 
 
 
 
Same problem as above. You are attempting to use CG for a non-symmetric system. In this case it's a saddle point system. Try using a direct solver instead.
Regards,
David
 
Thanks in advance for your help.
 
 
 
 
 
Sent: Saturday, November 26, 2016 6:54 PM
 
 
 
Hello,
Minor progress.
I found out that the problem with my QG code was how I imposed the boundary conditions. Now I am happy to say that they both run.  Unfortunately, they both give me a zero solution even though the winds are not zero.  I plotting the winds and so I know that
 they're not zero. Maybe I"ll have more luck tomorrow.
Cheers,
Francis
Hello again,
Minor update on my wind-driven gyre problem.
I just put together a SW version of the code that solve the Linear Stommel problem.  You can find the code in the same github repo,
https://github.com/francispoulin/firedrakeQG/blob/master/linear_stommel_sw.py
To my surprise the solver does not complain, and it is exactly the same thing as in the QG version so maybe that part of it is ok.  Unfortunately, the solution seems to be zero.  So this code is at least giving me an answer, but a wrong one. 
Cheers, Francis
Hello,
Thank you Colin and everyone else for your responses.  That was very helpful.  
We are working on a bunch of problems right now, both QG and SW.   We have many different codes working in FEniCS but I am going to start translating them into Firedrake.  Maybe make a demo if people seem interested?
The first code is to solve the Linear Stommel problem in one-layer QG. I was able to translate most of it ok but I seem to be having problems with the solver for some reason.
If anyone had any advice on what I am doing wrong that would be greatly appreciated. You can find a link on github
 
https://github.com/francispoulin/firedrakeQG/blob/master/linear_stommel_qg.py
After I get this working I will like to solve a variety of other problems.  One is the Munk problem, then look at non-linear gyre solutions, then find these solutions in SW. 
Cheers, Francis
Hi Francis,
  That depends on the formulation of the equations. If you are using a streamfunction-vorticity formulation as for QG, then you need to set a zero boundary condition for the streamfunction, as a scalar. If you are using a velocity
formulation based on H(div) spaces  (BDM, RT etc.) then there are only u.n DOFs on the boundary, so setting:
bcs = [DirichletBC(Z.sub(0), Constant((0, 0)), (blah,)), ...
actually only sets the normal component. That's one of the reasons that I like these spaces for GFD.
cheers
--cjc