Is it possible to solve such Quasi-Statics problem in Dolfin/FeniCS?

Asked by Norbert

Hello!
I'm going to solve problem, governed by Laplace/Poisson differential equation with Neumann boundary condition in 3d.
Usually I solve this problem in COMSOL Multiphysics in its «AC/DC Module — Quasi-Statics, Electric — Electric Currents».

I have two nested subdomains in it:
1. For simplicity outer is a unit cube (1 m side) with unit conductivity (1 m/Ohm) and Neumann boundary condition on its surface (so, it is surrounded by air).
2. There is a small cube (1 mm side) in the center, it has continuity boundary condition for electric potential, unit conductivity (1 m/Ohm), it has external current density vector Je=[0, 0, 1e9] A/m2.

I'm going to calculate electric potential from small cube on the surface of the big cube. In COMSOL it's fast to define and calculate such model. Model geometry and COMSOL results are in image (http://i49.tinypic.com/161e0w4.jpg).

How I can construct this model in Dolfin? For big cube I can use UnitCube function I guess.
How I can draw a smaller one and set-up current density in it? If setting current density is impossible, how I can create a point current dipole source (with three coordinates for position and dipole moment vector)?

Question information

Language:
English Edit question
Status:
Answered
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
N.A. Borggren (nborggren) said :
#1

Hello,
   I think it would be constructive for you to try building the model yourself and posting codes demonstrating problems as they arise. Some of the demos will be useful for guidance:

demo_poisson.py demonstrates how to develop the necessary variational forms for the poisson equation
demo_neumann_poisson.py will help with the neumann boundary conditions
demo_submesh.py will help with working with SubDomain to work with your box inside of a box
for setting your external current density you can use a constant
J=Constant((0,0,1e9))
which should appear in your variational form. You can use a vector valued expression Expression((...,...,...)) if your current should have a spatial dependence. There are a number of other poisson related demos as well that could be of use.

Good luck,
  Nathan Borggren, PhD

Revision history for this message
Norbert (nrbrtx) said :
#2

Hello, Nathan!

Thank you. I tried to write some code.
Submesh and subdmain examples are very complicated, so I tried to create finite dipole. I started from demo_neumann_poisson.py example.
It does not work, it reports zero potential on big cube.

from dolfin import *

# Create mesh and define function space
mesh = UnitCube(10, 10, 10)
V = FunctionSpace(mesh, "CG", 1)
R = FunctionSpace(mesh, "R", 0)
W = V * R

# Define variational problem
(u, c) = TrialFunction(W)
(v, d) = TestFunctions(W)
# Form finite dipole
f = Expression("1e9*(x[0] == 0.4995) * (x[1] == 0.4995) * (x[2] == 0.4995) - 1e9*(x[0] == 0.5005) * (x[1] == 0.5005) * (x[2] == 0.5005)")
g = 0;
a = (inner(grad(u), grad(v)) + c*v + u*d)*dx
L = f*v*dx + g*v*ds

# Compute solution
w = Function(W)
solve(a == L, w)
(u, c) = w.split()

# Plot solution
plot(u, interactive=True)

Revision history for this message
N.A. Borggren (nborggren) said :
#3

By finite dipole do you mean that you are trying to place a charge at (0.4995,.4995,.4995) and another at (.5005,.5005,.5005)? Your form is such that a constant charge density has been placed throughout the cube, I think you are wanting localized charge sources. Perhaps try using a gaussian distribution to approximate your point sources and place them at those points.

Revision history for this message
Norbert (nrbrtx) said :
#4

I realized your suggestion as
f= Expression("1e9*exp(-(pow(x[0] - 0.4995, 2) + pow(x[1] - 0.4995, 2) + pow(x[2] - 0.4995, 2)) ) - 1e9*exp(-(pow(x[0] - 0.5005, 2) + pow(x[1] - 0.5005, 2) + pow(x[2] - 0.5005, 2)) )");

The surface potential is not zero, but its summetry differs from expected (it is diagnonal, not horizontal plane at z=0.5).

Revision history for this message
N.A. Borggren (nborggren) said :
#5

I would expect diagonal symmetry from your choice of locations, I think you mean:

f= Expression("1e9*exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2) + pow(x[2] - 0.4995, 2)) ) - 1e9*exp(-(pow(x[0] - 0.500, 2) + pow(x[1] - 0.500, 2) + pow(x[2] - 0.5005, 2)) )")

Revision history for this message
Norbert (nrbrtx) said :
#6

I made small mistake, you are right. Thank you. The summetry now is OK. So we created point current point dipole source, right?
It is to possible to realize original idea with known current density in a small volume?

Revision history for this message
N.A. Borggren (nborggren) said :
#7

Yes, we created a point dipole source, but you would need to normalize it still to make the 1e9 meaningful. Try again with the SubDomains and SubMesh demos, you need to understand how to define and mark an internal boundary. Your variational form will contain terms integrated over dx(0), if 0 marks the inner volume, and terms integrated over dx(1), if marked 1 otherwise. You will define your current density much like you did with f, but just a vector expression or constant. I think if you fight with the demos, making sure you see how the forms are obtained from the differential equations, you should have no trouble solving this. This isn't really the forum to develop a problem from scratch, we need codes that break in order to fix them!

Revision history for this message
Norbert (nrbrtx) said :
#8

Thank you for your answers, Nathan.
I'll try to learn examples, do some trial-and-error attempts and reopen the question if I face problems.

Can you help with this problem?

Provide an answer of your own, or ask Norbert for more information if necessary.

To post a message you must log in.