Printing the Jacobian matrix for a nonlinear problem

Asked by Christopher Laing

Suppose that I have a nonlinear variational problem.

Let's call the form F, with a Function u and a TrialFunction du.

We can compute the Jacobian of F using:

jacobian = derivative(F,u,du)

1) What is the best method for assembling the system in order to get access to the assembled jacobian?

2) How can the jacobian be extracted in a useful form for manipulation and display, such as a numpy array?

Any advice would be greatly appreciated!

Christopher

Question information

Language:
English Edit question
Status:
Solved
For:
FEniCS Project Edit question
Assignee:
No assignee Edit question
Solved by:
Johan Hake
Solved:
Last query:
Last reply:
Revision history for this message
Best Johan Hake (johan-hake) said :
#1

On 08/14/2012 08:05 AM, Christopher Laing wrote:
> New question #205763 on FEniCS Project:
> https://answers.launchpad.net/fenics/+question/205763
>
> Suppose that I have a nonlinear variational problem.
>
> Let's call the form F, with a Function u and a TrialFunction du.
>
> We can compute the Jacobian of F using:
>
> jacobian = derivative(F,u,du)
>
> 1) What is the best method for assembling the system in order to get access to the assembled jacobian?

  J = assemble(jacobian)

> 2) How can the jacobian be extracted in a useful form for manipulation and display, such as a numpy array?

  J_np = J.array()

But keep in mind that J_np will be a dense version of J.

Johan

> Any advice would be greatly appreciated!
>
> Christopher
>

Revision history for this message
Christopher Laing (9e9o1k-chris) said :
#2

Thanks Johan Hake, that solved my question.

Revision history for this message
Christopher Laing (9e9o1k-chris) said :
#3

Well, that was obvious. I thought I'd tried that, but perhaps not!

Thanks :-)