

% 1D domain 
L = 2^10 ;
xDom = (1:(L-1))' ; 

alpha = 1 ; 

% IC 
f = @(x) sign( (L/2) - x ) ;
g = @(x) 0.75*sin( (1*pi*x/L).^4 )  ;

% BC 
u1 = 1   ;
u2 = -1  ;

u1g = 0 ; 
u2g = 0 ; 


Ub = u1 + (u2-u1)*xDom/(L-1)  ; 
F  = f(xDom) - Ub ;  

Ubg= u1g + (u2g-u1g)*xDom/(L-1)  ; 
G  = g(xDom) - Ubg ;  
 
% sine transform
Fn = dst(F)  ; 
Gn = dst(G) ; 
% Sampling in time
tDom = L * [ (0:0.0011:0.05)  (0.05:0.021:1) (1:1.1:100) ] ; 

titleText = "Heat distributions of 2 different rods. The simulation runs in 3 different speeds." ;

nDom=(1:length(Fn))' ; 
res = [] ; 
for tCur=tDom 
    res = Ub + idst( Fn .*  exp ( - tCur * (xDom*alpha*pi/L).^2 ) )  ; 
    clf; hold on ; 
    plot(xDom,res); title (titleText) ;  axis([0 L -2 2])  ;
 
    res = Ubg + idst( Gn .*  exp ( - tCur * (xDom*alpha*pi/L).^2 ) )  ; 
    plot(xDom,res, 'r');    

    legend ( sprintf('%2.2f', tCur/L) ) ;  
    pause(0.00031) ; 
    
    
end


return ; 
