kill(all)$

load packages :

load(lrats)$

heat : nonhomogeneous problem (bc ≠ 0),(ic = f(x),@t=0),version 1.0 (part 2)
peter.vlasschaert@gmail.com,24/07/2019.

rem : no heat generation  ( = without a source)

ref : elementary applied partial differential equations
        with fourier series and boundary value problems
        (richard haberman,prentice hall)

Model  2 ( cartesian coordinates : u(x,t), unsteady = du/dt ≠ 0)
=======
x: space 
t : time         > 0
u : physical quantity ( here : temperature)
D : constant  > 0
l   : length ( for example : rod) , 0<x<l

conditions
---------------

pde :D* 'diff(u,x,2) = 'diff(u,t) 
bc :  u(0,t) =A
        u(l,t  ) = B
ic  :  u(x,0) = f(x)

type : linear homogeneous partial differential equation.
           bc : linear nonhomogeneous boundary conditions.

How to solve  => separation of variables.

Equilibrium temperature : uE
===================

assume(D>0);

p1:D*diff(u(x,t),x,2) = diff(u(x,t),t);

independent of time only function of space
----------------------------------------------------------

depends(uE,x);

dependencies;

u(x,t) => uE(x)
===========

1e) independent of time: du/dt =0
----------------------------------------------

p2:lhs(p1) = 0;
p2a:lratsubst([D=1],p2);
p2b:lratsubst([u(x,t)=uE(x)],p2a);

2e) How to solve uE for bc
-------------------------------------

p3:desolve(p2b,uE(x));

coef : x
====

p3a: coeff(rhs(p3),x)=Cx;

p3b:lratsubst(p3a,p3);

coef :constant
====

p3c:ev(rhs(p3b),x=0)=C;

p3d:lratsubst([p3c],p3b);

3e) how to find space depends
-------------------------------------------
uE(0) = A
uE(l)   = B

p4a:lratsubst([x=0],p3d);
p4b:lratsubst([x=l],p3d);

4e) solve for Cx and C
--------------------------------

p5:solve([p4a,p4b],[Cx,C]);

p5a:flatten(p5);

5e) equilibrium temperature distribution
-------------------------------------------------------

p6:lratsubst(p5a,p3d);

p6a:[uE(0) = A,
uE(l)   = B];

p6b:lratsubst(p6a,p6);

p6c:expand(p6b);

general relation : u(x,t) = v(x,t)+uE(x)
============================
v(x,t) : solution to problem with homogeneous bc conditions

model v(x,t)
=========
pde :D* 'diff(v,x,2) = 'diff(v,t) 
bc :  v(0,t) =0
        v(l,t  ) =0
ic  :  v(x,0)   ?

see : part 1  , u(x,t) =>v(x,t)
====================

p7:u(x,t) = v(x,t)+uE(x);

meaning : v(x,t) : displacement from quilibrium
===================================

p7a:solve(p7,v(x,t))[1];

solution v(x,t)
==========
see :part 1:use p7c

p8:v(x,t)=sum(C4[n]*%e^(-(%pi^2*D*n^2*t)/l^2)*sin((%pi*n*x)/l),n,1,∞);

ic : condition (@t=0)
================

p9:lratsubst([t=0],p7a);

ic: from model 2: u(x,0) = f(x)
======================

p10a:lratsubst([u(x,0)=f(x)],p9);

p10b:lratsubst([t=0],rhs(p8))=rhs(p10a);

p10c:rhs(p10b) = F(x);

p10c1:F(x) =rhs(p10b);

p10d:lratsubst([p10c],p10b);

see : website
pde : separation variables heat equation.(problem :given :ic and bc),version 1.0

from : orthogonality relations we find C4[n]
----------------------------------------------------------
fourier coef. 'see above ,website'

assume(l>0);

p10e:C4[n] = 2/l*integrate(F(x)*sin((n*π*x)/l),x,0,l);

p10e1:lratsubst(p10c1,p10e);

rem : integral ( same value : n=1,2,3,....)
==============================

p11c1:'integrate((sin((%pi*n*x)/l))^2,x,0,l) =lratsubst([n=1],integrate((sin((%pi*n*x)/l))^2,x,0,l));

p11c2:'integrate((sin((%pi*n*x)/l))^2,x,0,l) =lratsubst([n=5],integrate((sin((%pi*n*x)/l))^2,x,0,l));

1e) integral useful:energy or power 
2e) orthogonality of sines

final result temperature distribution : u(x,t)
================================
use : p8,p10e1,p6b

p12:p7;

p12a:lratsubst([p8,p10e1,p6b],p12);

example: l :10
                 A=5
                 B=3
                  f(x) =100
                 D=50

p13:[l=10,A=5,B=3,f(x)=100,D=5];
p13a:lratsubst(p13,p12a);

p13b:ev(p13a,nouns);