Application of the Galerkin and Collocation methods
to Solve a One-Dimensional Heat Conduction Problem 
Author's Data: Housam BINOUS
Department of Chemical Engineering
National Institute of Applied Sciences and Technology
Tunis, TUNISIA
Email: binoushousam@yahoo.com

Acknowledgement :

This problem was presented in the excellent book by W. F. Ramirez, Computational Methods for Process Simulation, Second Edition, 1997, Butterworth Heinemann, Oxford.

Exact solution to the heat conduction problem where the thermal conductivity is a linear function of temperature.

eq1 = 
      D[(1 + a θ[x]) D[θ[x], {x, 1}], {x, 1}] ==  
        0

a = 1

init1 = θ[0] ==  0; 
    init2 = θ[1] ==  1;

sol = DSolve[{eq1, init1, init2}, {θ[x]}, x]

plt1 = 
      Plot[θ[x] /. sol, {x, 0, 1}, 
        PlotStyle ->  RGBColor[1, 0, 0]]

Attempting to solve the problem with a second order collocation method.

θ2[x_] :=  
        x + A1 (x^2 - x) + A2 (x^3 - x);

R=(1 + a θ2[x]) (θ2)''[x] +a θ2'[x]^2

R /. x ->  0.211325

R /. x ->  0.788675

sol2 = 
      Solve[{0 ==  R /. x ->  0.788675, 
          0 ==  R /. x ->  0.211325}, {A1, A2}]

plt2 = 
      Plot[θ2[x] /. sol2[[2]], {x, 0, 1}, 
        PlotStyle ->  RGBColor[0, 0, 1]]

Attempting to solve the problem with a second order Galerkin method.

sol3 = 
      Solve[{0 ==  Integrate[x (1 - x) R, {x, 0, 1}], 
          0 ==  
            Integrate[x (1 - x) (0.5 - x) R, {x, 0, 1}]}, {A1, 
          A2}]

plt3 = 
      Plot[θ2[x] /. sol3[[3]], {x, 0, 1}, 
        PlotStyle ->  RGBColor[0, 1, 0]]

comparing results obtained using the three methods

Show[plt1, plt2, plt3]

xt = {0, 0.1, 0.25, 0.5, 0.75, 0.9, 1};

Evaluate[θ[x] /. sol /. x ->  xt]

θ2[xt] /. sol2[[2]]

θ2[xt] /. sol3[[3]]