0

I want to solve the following set of 3 coupled pdes in python using fipy

∇2n − (∇2ψ)n − (∇ψ).∇n = n/10, 
∇2p + (∇2ψ)p + (∇ψ).∇p = p/10,
∇2ψ = −(p − n) 

The variables are p,n and ψ. As can be seen from the first and second equation, the first term can be set as the diffusion term in the pde solver in fipy. If the other terms of the first and second equation are to be incorporated in the fipy pde solver, I suppose that they should be incorporated in the Implicit Source Term in fipy. But considering the presence of vector identities in these terms, I am facing some difficulty in incorporating these equations in the fipy pde solver. Any help regarding this would be appreciated.

David
  • 424
  • 3
  • 16
Anweshan
  • 29
  • 6

1 Answers1

1

Assuming the instances of 2 that appear in your equations are squaring of the nabla (del) operator, you certainly can write for the first equation:

DiffusionTerm(var=n) - ImplicitSourceTerm(coeff=psi.faceGrad.divergence, var=n) - psi.grad.dot(n.grad) == ImplicitSourceTerm(coeff=1./10, var=n)

however, this is not a very implicit representation.

Better is to apply the chain rule:

$\nabla (n \nabla \psi) \equiv \nabla n \cdot \nabla \psi + n \nabla^2 \psi$

such that

$\nabla^2 n - \nabla(n \nabla psi) == n / 10$

This is then

DiffusionTerm(var=n) - DiffusionTerm(coeff=n, var=psi) == ImplicitSourceTerm(coeff=1./10, var=n)

if you wish to couple your equations, and

DiffusionTerm(var=n) - ConvectionTerm(coeff=psi.faceGrad, var=n) == ImplicitSourceTerm(coeff=1./10, var=n)

if you don't.

jeguyer
  • 2,379
  • 1
  • 11
  • 15