Divergence

Asked by Bruno Martins

I have a case slightly similar to what occurred on question 181682: laplacian.

I first calculate function Jn by taking the gradient of two distinct variables:
Jn=a1*grad(v)+a2*grad(n)

Now I need to calculate div(Jn) but I have the same error as reported in that question. It was suggested to solve the Laplacian as an escript PDE but it is not clear how I can do the same with my two-variable problem. Is there a way to calculate these two Laplacians in escript or is that an inherent limitation of the program?

Thank you.

Question information

Language:
English Edit question
Status:
Solved
For:
esys-escript Edit question
Assignee:
No assignee Edit question
Solved by:
Bob
Solved:
Last query:
Last reply:
Revision history for this message
Lutz Gross (l-gross) said :
#1

The answer applies to your case (assuming v and n are scalars). In fact the name "laplacian" is missleading as this is not the Laplace equation but the solution of the PDE is the evaluation of the Laplace operator of sol. In your case this would take the form:

  div = LinearPDE(domain, numEquations=1)
  div.setValue(D=1, X=-Jn)

assumung that inner(Jn,normal)=0. An alternative is to project the Jn back to a solution, e.g. see http://esys.esscc.uq.edu.au/esys13/3.2.1/epydoc/esys.escript.pdetools.Projector-class.html:

   from esys.escript.pdetools import Projection
   proj=Projection(domain)
   Jn=proj(a1*grad(v)+a2*grad(n))

then you can apply the divergence operator.

Revision history for this message
Bruno Martins (bvc-martins) said :
#2

The first solution worked well but I got the following error when trying the second:

from esys.escript.pdetools import Projection
ImportError: cannot import name Projection

I am using escript 3.3-1. I successfully import class Locator from the same module, so it should not be a path location problem.

Revision history for this message
Best Bob (caltinay) said :
#3

Try this instead:

from esys.escript.pdetools import Projector
proj=Projector(domain)
...

Revision history for this message
Bruno Martins (bvc-martins) said :
#4

Thanks Cihan Altinay, that solved my question.