# How to draw a contour line that intersects with a specified line (perpendecular to xy plane)?

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$

• Please show the form of $f(x,y)$. – MarcoB Jun 7 '16 at 18:05
• @MarcoB idk. thats the result of NDSolve and is in terms of interpolating function. How can I show that to you? – AHB Jun 7 '16 at 18:07
• Then post the NDSolve[] snippet that produces your function. – J. M.'s torpor Jun 7 '16 at 18:07
• What is 3D scalar field f(x,y)? Shouldn't it be f(x,y,z)? And then it will be contour surface? – BlacKow Jun 7 '16 at 18:09
• @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. – AHB Jun 7 '16 at 18:11

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]]


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]]


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.} *)

• @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. – BlacKow Jun 7 '16 at 18:33
• @AHB yes... Since you were using NDSolveValue initially, I edited the answer. – BlacKow Jun 7 '16 at 18:37