Details
Examples
Basic Examples
See Also
NDSolve`FEM`
DiscretizePDE::femdpop
Details
Examples
Basic Examples (3)
In the following case, there is a transition from the real to the complex plane:
NDSolveValue[{D[u[x], {x, 2}] == u[x] ^ (3 / 2) / Sqrt[x], u[0] == 1, u[10] == 0}, u, {x, 0, 10}, Method -> "FiniteElement"]One possible workaround is to add a 0 complex component to the equation, such that the solver works in the complex plane:
NDSolveValue[{D[u[x],{x,2}]==u[x]^(3/2)/Sqrt[x]+0.I,u[0]==1,u[10]==0},u,{x,0,10},Method->"FiniteElement"]An alternative in this case is to specify a complex-valued InitialSeeding:
sol = NDSolveValue[{D[u[x], {x, 2}] == u[x] ^ (3 / 2) / Sqrt[x], u[0] == 1, u[10] == 0}, u, {x, 0, 10}, Method -> "FiniteElement", InitialSeeding -> u[x] == 0.I]Visualize the solution making use of Re:
Plot[Re[sol[x]], {x, 0, 10}, PlotRange -> All]Note there is a small complex part of the solution:
Plot[Im[sol[x]], {x, 0, 10}, PlotRange -> All]This message can indicate that an overflow did occur:
f[x_ ? NumericQ] := If[x <= 1 / 2, 0, 2 * $MaxNumber]
NDSolve[{DiffusionPDETerm[{u[x], {x}}, 1] == f[x], DirichletCondition[u[x] == 0, x == 0]}, u, {x, 0, 1}]This message can indicate numbers with a different precision than MachinePrecision numbers were generated:
f[x_ ? NumericQ] := If[x <= 1 / 2, 0, 2 * $MaxMachineNumber]
NDSolve[{DiffusionPDETerm[{u[x], {x}}, 1] == f[x], DirichletCondition[u[x] == 0, x == 0]}, u, {x, 0, 1}]