In this case, the exact solution to the problem is given by
which you can use to test your code.
Extend your code so that it can account for a source term in the ODE:
Hint: The simplest place to start is to set ; in this case, the exact solution is given by
Once you've developed code for the problem with , add an dependence into . Can you find some exact solutions for this case?
Generalise your code so that the source term can now depend on the solution as well as a parameter . Use your code to solve the Bratu problem
when and . Plot the solution as a function of . The Bratu problem appears in mathematical models of combustion and thermal runaway, in which case is the temperature.
Hint: If depends nonlinearly on the solution , then a good initial guess of the solution is usually required for the nonlinear solver (e.g. SciPy's root
function or Newton's method) to converge. For this problem, a good initial guess can be found by noting that when is small, the exponential can be approximated as . The solution in this case is given by (5), which can be used to form an initial guess.
Update your code so that it can account for Dirichlet, Neumann, or Robin boundary conditions.