1.
Chemical Spill Diffusion in a Sealed River Segment
Scenario:
An environmental agency is investigating how a pollutant disperses in a stagnant segment of
a river that has been sealed off at both ends to prevent the spread of contamination. The
segment is 1 km long, and the pollutant was introduced uniformly at time t=0 , following a
specific initial concentration profile. The goal is to model the pollutant's diffusion over time
and predict how the concentration changes at different locations within the river segment.
Problem Statement:
The concentration of the pollutant, denoted by C ( x , t ) , evolves according to the one-
2
∂C ∂ C
dimensional diffusion equation: = ,
∂ t ∂ x2
where:
C (x , t) is the pollutant concentration at position x ∈[0 , 1] km and time t (in hours),
D is the diffusion coefficient (in km²/hour),
The river segment is sealed at both ends, implying no flux at the boundaries.
Initial and boundary conditions:
C ( 0 , t )=0 , C ( 1 , t ) =10 , and
C (x , 0)=100 x (1−x ), initial pollutant distribution, peaking at the centre of the segment.
Tasks:
Develop a MATLAB script that uses separation of variables to compute the analytical
solution.
syms u(x, t) x t % Symbolic variables and functions
PDE = diff(u, t) == diff(u, x, 2);
syms X(x) T(t)
u(x, t) = X(x) * T(t); % Assume u(x,t) = X(x)T(t)
PDE_sep = subs(PDE, u, X(x)*T(t)); % Substitute into the PDE
PDE_sep = PDE_sep / (X(x) * T(t));
eq1 = diff(T, t) / T == diff(X, x, 2) / X; % Separate variables
syms lambda
eqT = diff(T, t) == -lambda * T; % Set equal to separation constant -
lambda
eqX = diff(X, x, 2) == -lambda * X;
% Solve the ODEs
T_sol = dsolve(eqT, T(0) == 100*x*(1-x))% Arbitrary initial condition
for T
X_sol = dsolve(eqX, X(0) == 0, X(1) == 10)
OUTPUT:
T_sol =
X_sol =
2. Heat Distribution in a Pipeline Carrying Hot Fluid
Scenario:
In chemical plants, hot fluids are transported through long insulated pipelines. Over time,
heat escapes through the pipe walls, especially near the ends. To maintain efficiency and
prevent issues like thickening of fluids or energy loss, engineers simulate how heat spreads
and dissipates along the pipeline.
A section of the pipe is modelled as a 1−D rod with its ends exposed to the environment.
The goal is to predict temperature evolution over time.
Problem Statement:
2
∂u ∂ u
The temperature u(x , t) satisfies the 1−D heat equation: =4 2 , with the following
∂t ∂x
boundary conditions u(0 ,t )=0 , u(1 , t)=1 , u(x , 0)=80 sin ( πx ).
Tasks:
Develop a MATLAB script that uses separation of variables to compute the analytical
solution.
syms u(x, t) x t % Symbolic variables and functions
PDE = diff(u, t) ==4*diff(u, x, 2);
syms X(x) T(t)
u(x, t) = X(x) * T(t); % Assume u(x,t) = X(x)T(t)
PDE_sep = subs(PDE, u, X(x)*T(t)); % Substitute into the PDE
PDE_sep = PDE_sep / (X(x) * T(t));
eq1 = diff(T, t) / T == diff(X, x, 2) / X; % Separate variables
syms lambda
eqT = diff(T, t) == -lambda * T; % Set equal to separation constant-
lambda
eqX = diff(X, x, 2) == -lambda * X; % Solve the ODEs
T_sol = dsolve(eqT, T(0) == 80*sin(pi*x)) % Arbitrary initial
condition for T
X_sol = dsolve(eqX, X(0) == 0, X(1) == 1)
OUTPUT:
T_sol =
X_sol =