Bug introduced in 10 or earlier and fixed in version 10.4
I am really not sure if this is a bug or I am missing something very trivial.
QUESTION: What I am missing in order to obtain the partial derivative of the interpolating function (in this case the fem solution)?
EDIT: take a look at the comment by user21 directly underneath this question, the solution is to use t
as the first variable.
Context:
I am testing the following pde with the Mathematica FEM
Needs["NDSolve`FEM`"]
(*Domain*)
xmin = 0;
xmax = 10;
reg = ImplicitRegion[xmin <= x <= xmax, {x}];
(*Field equation*)
sig[x_, t_] := Ef[x, t]*eps[x, t];
eps[x_, t_] := D[u[x, t], x];
feq = D[Af[x, t]*sig[x, t], x] + nf[x, t];
(*Paremeters*)
E0 = 3;
Ef[x_, t_] := E0;
A0 = 7;
Af[x_, t_] := A0;
sig0 = 2;
(*Inhomogeneity*)
nf[x_, t_] := 0;
F[t_] := A0*sig0*3*t;
(*Conditions*)
iconds = u[x, 0] == 0;
bconds = {DirichletCondition[u[x, t] == 0, x == xmin]};
nconds = NeumannValue[-F[t], x == xmax];
(*Fem solution*)
ufem = NDSolveValue[{feq == nconds, iconds, bconds}, u,
Element[x, reg], {t, 0, 1}];
(*Plot*)
Plot[Table[ufem[x, ti], {ti, 0, 1, 0.2}], {x, xmin, xmax},
AxesLabel -> {"x", "u(x,t)"}]
From mechanics, the solution looks fine, it is linear in space $x$ and time $t$, just as it should be in this case. Just for fun I wanted to compute the spatial derivative of the solution. But I dont get a constant spatial derivative, as you can see in the plots below, e.g., for $t=0.2$.
Plot[ufem[x, 0.2], {x, xmin, xmax}, AxesLabel -> {"x", "ufem(x,0.2)"}]
loc = Derivative[1, 0][ufem];
Plot[loc[x, 0.2], {x, xmin, xmax}, AxesLabel -> {"x", "loc(x,0.2)"}]
From the InterpolatingFunction
documentation, I assumed that partial derivates are computable, see screenshot below.
QUESTION: What I am missing in order to obtain the partial derivative of the interpolating function (in this case the fem solution)?
t
as the first indepdent variable in your equations. This is a bug. $\endgroup$t
as the first variable. But that is a weirdness I can live with :D Thanks! $\endgroup$InterpolatingFunction
? Or both? Introduced in 10 or earlier? $\endgroup$