0
$\begingroup$

Assuming I have the 2D scalar field $f(x,y)$ and I want the contour line of $f$ that intersects with the line $x=2,y=3$.

How can I do that?

At further steps I want the equation for that contour line.

Is there a way to do that?


EDIT: the NDSolve snippet:

P = Polygon[{{0, l}, {l, 0}, {d - l, 0}, {d, l}, {d, d}, {0, d}}];

NDSolveValue[{D[u[x, y], x, x] + D[u[x, y], y, y] == 0, DirichletCondition[u[x, y] == V, x + y == l && 0 <= x <= l && 0 <= y <= l], DirichletCondition[u[x, y] == 0, x == y + d - l && d - l <= x <= d && 0 <= y <= l]}, u, {x, y} \[Element] P, Method -> {"FiniteElement", "MeshOptions" -> {"BoundaryMeshGenerator" -> "Continuation"}}]

$d=50,l=0.00001,V=10000$

$\endgroup$
11
  • $\begingroup$ Please show the form of $f(x,y)$. $\endgroup$ – MarcoB Jun 7 '16 at 18:05
  • $\begingroup$ @MarcoB idk. thats the result of NDSolve and is in terms of interpolating function. How can I show that to you? $\endgroup$ – AHB Jun 7 '16 at 18:07
  • $\begingroup$ Then post the NDSolve[] snippet that produces your function. $\endgroup$ – J. M.'s torpor Jun 7 '16 at 18:07
  • $\begingroup$ What is 3D scalar field f(x,y)? Shouldn't it be f(x,y,z)? And then it will be contour surface? $\endgroup$ – BlacKow Jun 7 '16 at 18:09
  • $\begingroup$ @BlacKow hmmmm. The domain is 2D. Range is 1D. This is what I mean. And I want contour lines. Will $f$ be a 2D scalar field then? if yes, I'll edit. $\endgroup$ – AHB Jun 7 '16 at 18:11
3
$\begingroup$

Something like this? The red curve shows your contour line...

P = Polygon[{{0, l}, {l, 0}, {d - l, 0}, {d, l}, {d, d}, {0, d}}];
d = 50;
l = 10^-5;
V = 10000;

sol = NDSolveValue[{D[u[x, y], x, x] + D[u[x, y], y, y] == 0, 
  DirichletCondition[u[x, y] == V, 
  x + y == l && 0 <= x <= l && 0 <= y <= l], 
  DirichletCondition[u[x, y] == 0, 
  x == y + d - l && d - l <= x <= d && 0 <= y <= l]}, 
  u, {x, y} \[Element] P, 
  Method -> {"FiniteElement", 
  "MeshOptions" -> {"BoundaryMeshGenerator" -> "Continuation"}}];


Show[ContourPlot[sol[x, y], {x, 0, 5}, {y, 0, 5}], 
 ContourPlot[sol[x, y] == sol[2, 3], {x, 0, 5}, {y, 0, 5}, 
  ContourStyle -> Red]]

enter image description here

Update: Eliminating l

P = Polygon[{{0, 0}, {d, 0}, {d, 0}, {d, d}, {0, d}}];
d = 50;
V = 10000;
sol = NDSolveValue[{D[u[x, y], x, x] + D[u[x, y], y, y] == 0, 
    DirichletCondition[u[x, y] == V, x^2 + y^2 == 0], 
    DirichletCondition[u[x, y] == 0, 
     x == y + d && d <= x <= d && y == 0]}, u, {x, y} \[Element] P, 
   Method -> {"FiniteElement", 
     "MeshOptions" -> {"BoundaryMeshGenerator" -> "Continuation"}}];


Show[ContourPlot[sol[x, y], {x, 0, 5}, {y, 0, 5}, PlotRange -> Full], 
 ContourPlot[sol[x, y] == sol[2, 3], {x, 0, 5}, {y, 0, 5}, 
  ContourStyle -> Red]]

enter image description here

And check you boundary conditions by evaluating the solution on polygon's vertices:

sol @@@ Apply[# &, P]
(* {10000., -2.04636*10^-12, -2.04636*10^-12, 4834.84, 5162.} *)
$\endgroup$
2
  • $\begingroup$ @AHB NDSolve returns a list of solutions. In your case it has one element, but it's still a list. First takes the first element of the list. $\endgroup$ – BlacKow Jun 7 '16 at 18:33
  • $\begingroup$ @AHB yes... Since you were using NDSolveValue initially, I edited the answer. $\endgroup$ – BlacKow Jun 7 '16 at 18:37

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.