As a follow up/ simplification of this question I would like to compute the potential created by a charged square outside of the square. I would like to impose that far enough the outgoing flux behaves as though the cube was a point mass.

Let me define a region between a square and a disk as

reg = 
 RegionDifference[Disk[{0, 0}, 2], Rectangle[{-1, -1}, {1, 1}]]

and extract a mesh out of it

mesh = ToElementMesh[reg, MaxCellMeasure -> 0.05, 
   "MaxBoundaryCellMeasure" -> 0.01];
Show[mesh["Wireframe"], Frame -> True, PlotRange -> All]

Mathematica graphics

Let me try and solve of the Laplacian, aiming to fix the potential on the square and the outgoing flux on the disk

  edge = DirichletCondition[1, {x, y} \[Element] Rectangle[{-1, -1}, {1, 1}]]

so that

  sol = NDSolveValue[{-Laplacian[u[x, y], {x, y}] ==
   NeumannValue[1, {x, y} \[Element] Disk[{0, 0}, 2]], edge}, u, {x, y} \[Element] mesh]

I get this error message

NDSolveValue::femibcnd: No DirichletCondition or Robin-type NeumannValue
was specified for {u}; the result may not be unique.

and the plot looks wrong (it does not have the symmetry of the problem and the values are very large).

ContourPlot[sol[x, y], Element[{x, y}, mesh], AspectRatio -> 1,Contours -> 20]

Mathematica graphics


What am I doing wrong with the boundary condition?

I am guessing this is some trivial issue but...? I would be great if the preprocessing of mathematica could guide (more) the user in this context?


How about:

sol = NDSolveValue[{-Laplacian[u[x, y], {x, y}] == 
     NeumannValue[1, x^2 + y^2 > 2^2], 
    DirichletCondition[u[x, y] == 1, -1 <= x <= 1 && -1 <= y <= 1]}, 
   u, {x, y} \[Element] mesh];
ContourPlot[sol[x, y], Element[{x, y}, mesh], AspectRatio -> 1, 
 Contours -> 20]

enter image description here

| improve this answer | |
  • $\begingroup$ @chris, fixed the ^2 issue. I did look at the question - but I do not understand it. $\endgroup$ – user21 Jan 28 '18 at 16:47
  • $\begingroup$ @chris, I'll have a look tomorrow. $\endgroup$ – user21 Jan 28 '18 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.