In attempting to solve a fourth order system I have encountered an issue with the way NDSolve uses boundary conditions. Consider the following three different attempts:
Nep = 1/2;
Nhp = 2;
Nen = 2;
Nhn = 1/2;
xmin = -2;
xmax = 2;
sol1 = NDSolve[{2 ϕ''[x] ==
Ne[x] - Nh[x] - UnitStep[x] (Nen - Nhn) -
UnitStep[-x] (Nep - Nhp), -Nh[x] ϕ'[x] - Nh'[x] ==
0, -Ne[x] ϕ'[x] + Ne'[x] == 0, ϕ[xmin] ==
0, ϕ'[xmin] == 0, ϕ'[xmax] == 0,
Ne[xmin] Nh[xmin] == 1}, {ϕ, Ne, Nh}, {x, xmin, xmax}];
Plot[Evaluate[ϕ[x] /. sol1], {x, xmin, xmax}, PlotRange -> All,
AxesLabel -> {"\!\(\*OverscriptBox[\(x\), \(~\)]\)",
"\!\(\*OverscriptBox[\(ϕ\), \(~\)]\)"}]
sol2 = NDSolve[{2 ϕ''[x] ==
Ne[x] - Nh[x] - UnitStep[x] (Nen - Nhn) -
UnitStep[-x] (Nep - Nhp), -Nh[x] ϕ'[x] - Nh'[x] ==
0, -Ne[x] ϕ'[x] + Ne'[x] == 0, ϕ[0] ==
0, ϕ'[xmin] == 0, ϕ'[xmax] == 0,
Ne[xmin] Nh[xmin] == 1}, {ϕ, Ne, Nh}, {x, xmin, xmax}];
Plot[Evaluate[ϕ[x] /. sol2], {x, xmin, xmax}, PlotRange -> All,
AxesLabel -> {"\!\(\*OverscriptBox[\(x\), \(~\)]\)",
"\!\(\*OverscriptBox[\(ϕ\), \(~\)]\)"}]
sol3 = NDSolve[{2 ϕ''[x] ==
Ne[x] - Nh[x] - UnitStep[x] (Nen - Nhn) -
UnitStep[-x] (Nep - Nhp), -Nh[x] ϕ'[x] - Nh'[x] ==
0, -Ne[x] ϕ'[x] + Ne'[x] == 0, ϕ[xmax] ==
0, ϕ'[xmin] == 0, ϕ'[xmax] == 0,
Ne[xmin] Nh[xmin] == 1}, {ϕ, Ne, Nh}, {x, xmin, xmax}];
Plot[Evaluate[ϕ[x] /. sol3], {x, xmin, xmax}, PlotRange -> All,
AxesLabel -> {"\!\(\*OverscriptBox[\(x\), \(~\)]\)",
"\!\(\*OverscriptBox[\(ϕ\), \(~\)]\)"}]
The difference between the three is just in the position at which a value of $\phi$ is specified. Given that there is no explicit dependence on $\phi$ in the system of equations, this shouldn't affect the solution up to the addition of a constant. However, only the second, where $\phi$ is specified at $x=0$ runs successfully. Why is this happening when all three problems are well-posed? Is there a fix?
Thanks in advance for any help.
sol1
also successed by with a warning throwed out,sol3
failed... $\endgroup$