How to plot the derivative after indicating the value?

I have used the FEM tool to solve this PDE system with control equation and boundary conditions, after calculation the ufun1[x, y] are calculated, and I want the partial derivative of the ufun1[x, y] and plot the curve of D[ufun1[x, y], y]] /. {y -> 0.15} and -D[ufun1[x, y], x]] /. {y -> 0.15}.

As the above results are all the 2D function of x and y, so and I indicate that {y -> 0.15} and then we can plot one curve vs. x, however, I can not plot the second one, what is the reason?

The codes are as follows:

Needs["NDSolveFEM"];
(*sh=0.2;sh2=0.02;sw=0.3;*)
ToothNumber = 3;
SlotNumber = ToothNumber - 1;
RectangleNumber = ToothNumber + SlotNumber;

ToothLength = 0.1;

ToothHeight = 0.1;
SlotHeight = 0.1;

coordinates = {{0., 0.}, {ToothLength, 0}, {ToothLength,
ToothHeight}, {2*ToothLength, ToothHeight}, {2*ToothLength,
0}, {3*ToothLength, 0}, {3*ToothLength,
ToothHeight}, {4*ToothLength, ToothHeight}, {4*ToothLength,
0}, {5*ToothLength, 0}, {5*ToothLength,
ToothHeight + SlotHeight}, {0, ToothHeight + SlotHeight}};
el1 = LineElement[{{1, 2}, {2, 3}, {3, 4}, {4, 5}, {5, 6}, {6, 7}, {7,
8}, {8, 9}, {9, 10}, {10, 11}, {11, 12}, {12, 1}}];
bMesh2 = ToBoundaryMesh["Coordinates" -> coordinates,
"BoundaryElements" -> {el1}];
GraphicsRow[{bMesh2["Wireframe"]}]

mesh2 = ToElementMesh[bMesh2];
mesh2["Wireframe"]

\[Mu]Air = 4 \[Pi]*10^-7;
Km = 10^5;
m = 1;
p = 2;
alpha = 0;

K[x_] := Km*Cos[m*p*(x - alpha)];

(*it is one matrix*)
op1 = Inactive[Div][(*-\[Epsilon]r.*)
Inactive[Grad][u[x, y], {x, y}], {x, y}] -
NeumannValue[0,
x == ToothLength || x == 2*ToothLength || x == 3*ToothLength ||
x == 4*ToothLength || y == ToothHeight || y == 0(*||
x\[LessEqual]sw&&sh\[LessEqual]y\[LessEqual]sh+sh2*)];
Subscript[\[CapitalGamma],
D] = {DirichletCondition[u[x, y] == \[Mu]Air*K[x],
0 <= x <= 5*ToothLength && y == ToothHeight + SlotHeight],
DirichletCondition[u[x, y] == 0, x == 0 || x == 5*ToothLength]};

ufun1 = NDSolveValue[{op1 == 0, Subscript[\[CapitalGamma], D]},
u, {x, y} \[Element] mesh2];

(*
Bx[x_,y_]:=D[ufun1,y];
By[x_,y_]:=-D[ufun1,x];
*)
{minsol, maxsol} = MinMax[ufun1["ValuesOnGrid"]]
(*
ufun2=NDSolveValue[{op2\[Equal]0,Subscript[\[CapitalGamma], \
D]},u,{x,y}\[Element]mesh2];
*)
Show[ContourPlot[ufun1[x, y], {x, y} \[Element] mesh2,
ColorFunction -> "TemperatureMap", AspectRatio -> Automatic,
Contours -> Range[minsol, maxsol, (maxsol - minsol)/50],
PlotLegends -> Automatic],
bMesh2["Wireframe"]]

Plot[Evaluate[D[ufun1[x, y], y]] /. {y -> 0.15}, {x, 0, 0.5}]

Plot[Evaluate[-D[ufun1[x, y], x]] /. {y -> 0.15}, {x, 0, 0.5}]


There is a conflict between the plot variable x and the derivative variable x!
Plot[ -Derivative[1, 0][ufun1][x, .15]  , {x, 0, 0.5}]

• Other workarounds are Plot[Evaluate[-D [ufun1[xx, .15], xx] /. xx -> x], {x, 0, 0.5}] or deriv = D [ufun1[x , .15], x ];Plot[ -deriv , {x, 0, 0.5}]. ` Commented Mar 29, 2023 at 12:45