Another way is to solve the ODE exactly and use FindRoot
to solve for the boundary conditions. There are infinitely many solutions for the parameters C[1]
and C[2]
, but they yield only two distinct solutions, one of which has a singularity.
Clear[Ns, sol, dsol, findparam];
ode = D[theta[x], {x, 2}] == SH*theta[x]^2;
bcs = {theta[0] == 1, theta'[1] == 0};
dsol[SH_] = DSolveValue[{ode}, theta, {x, 0, 1}];
findparam[SH_?NumericQ, c1_?NumericQ, c2_?NumericQ] :=
FindRoot[bcs /. theta -> dsol[SH] /.
Thread[{C[1], C[2]} -> {u, v}], {{u, c1}, {v, c2}},
WorkingPrecision -> (Precision@{SH, c1, c2} /.
p_?(! NumericQ[#] &) :> MachinePrecision)] /.
Thread[{u, v} -> {C[1], C[2]}];
sol[SH_, c1_?NumericQ, c2_?NumericQ] :=
theta[x] /. theta -> dsol[SH] /. {C[1] -> c1, C[2] -> c2};
Ns[SH_, Tr_, c1_?NumericQ, c2_?NumericQ] := With[{s = sol[SH, c1, c2]},
SH*s*(Log[1 + Tr*s] - s/(s + (Tr - 1)^(-1)))
];
Plot[
Evaluate[Ns[10, 1.2`44, C[1], C[2]] /. findparam[10, 1, 1/2]]
, {x, 0, 1}]
I used ContourPlot
initially to see where the BCs might be satisfied, but the following is more accurate once you know where to look:
ics = {theta[0], theta'[0]}; negsol =
Table[Quiet@Check[findparam[10, k, -5.`32], $Failed], {k, 5}];
possol = Table[Quiet@Check[findparam[10, k, 0.1`32], $Failed], {k, 5}];
paramsols =
DeleteDuplicates[Join[negsol, possol] /. $Failed -> Nothing,
Norm[(ics /. theta -> dsol[10] /. #1) - (ics /.
theta -> dsol[10] /. #2)] < 10^-8 &]
(*
{{C[1] -> 0.74517523946507200325661614980780,
C[2] -> -4.4126787665722546011617781190585},
{C[1] -> 11.430806610070804819523668005587,
C[2] -> 0.14721944767874966824783455933860}}
*)
ReImPlot[
Evaluate[{1, 10} (Ns[10, 1.2`44, C[1], C[2]] /. paramsols)],
{x, 0, 1},
WorkingPrecision -> 16, PlotRange -> All,
Method -> {"BoundaryOffset" -> False},
Frame -> True,
FrameTicks -> {{Automatic, Charting`ScaledTicks[{10 # &, #/10 &}]},
Automatic}]
SH
. For instance,sol[3]
works fine, and so therefore doesNs[3, 1.2]
for instance. $\endgroup$