I have a 1_D diffusion equation(adsbygoogle = window.adsbygoogle || []).push({});

dc/dt = D*d^2c/dx^2-Lc

where L,D = constants

I am trying to solve the equation above by following b.c. by FTCS scheme

-D*dc/dx = J0*delta(t); where delta(t)= dirac delta function ----(upper boundary)

I have written the code for it

but i just dont get the satisfactory answers. Could anyone help?

% --- Define constants and initial condition

clc;

clear;

L = 0.02; % length of domain in x direction

I0 = 0.0000829*24*60*60; % Bq m^-2 day^-1

L1 = (0.693/53.2); % Decay constant day^-1

tmax = 120; % end time

nx = 90;% number of nodes in x direction

nt = 121; % number of time steps

dx = L/(nx-1);

dt = tmax/(nt-1);

alpha= 2.5*10^-13*24*3600;

r = alpha*dt/dx^2; rr = 1 - 2*r-L1*dt;

v = 2.5*10^-6; % Convection velocity m day^-1

J0 = I0/sqrt(L1*alpha); % total inventory of Be-7 in soil

% --- Create arrays to save data for export

x = linspace(0,L,nx);

t = linspace(0,tmax,nt);

U = zeros(nx,nt);

% --- Set IC and BC

U(:,1)= 0;

% --- Loop over time steps

for m= 2:nt

U(1,m) = J0; %--- Upper boundary

U(end,m) = 0; %--- Lower boundary

for i= 2:nx-1

U(i,m) = r*U(i-1,m-1)+ rr*U(i,m-1)+ r*U(i+1,m-1);

end

end

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# 1D diffusion equation

**Physics Forums | Science Articles, Homework Help, Discussion**