218 Computational Modelling in Hydraulic and Coastal Engineering
Computer code 8.4
% Example 8.4 Advective Diffusion by Random Particle Motion
- Thermaikos Gulf
% dif = Diffusion coefficient;
% dec = Decay coefficient;
% ipp = Number of simulated particles;
% xo, yo = Initial position of particles [m];
% Dd = Spatial computational step [m];
% Dt = Time computational step [s];
% nx = Number of computational steps in the x-direction;
% ny = Number of computational steps in the y-direction;
% nt = Number of computational steps in time;
clc; clear all; close all;
% Input data
dif=5;
dec=0.00001;
ipp=5000;
xo=24000;
yo=24000;
Dd=2000;
Dt=600;
nx=22;
ny=23;
nt=288;
% Importing data for depths, velocities and diffusion
coefficients;
load ThermD.txt
load ThermU.txt
load ThermV.txt
fDep=ThermD;
fCoU=ThermU;
fCoV=ThermV;
% Subroutine for depths h=fm(i,j,fDep);
% Subroutine for velocity u=fm(i,j,fCoU);
% Subroutine for velocity v=fm(i,j,fCoV);
for i=1:nx
for
j=1:ny
cmax(i,j)=0;
end
end
imm=(nx-1)*Dd;
jmm=(ny-1)*Dd;
% Initial position of particles;
for i=1:ipp
x(i,1)=xo;
y(i,1)=yo;
end
% Number of decaying particles on every time step;
depp=round(ipp*Dt*dec);
Computer code 8.4
% Example 8.4 Advective Diffusion by Random Particle Motion
- Thermaikos Gulf
% dif = Diffusion coefficient;
% dec = Decay coefficient;
% ipp = Number of simulated particles;
% xo, yo = Initial position of particles [m];
% Dd = Spatial computational step [m];
% Dt = Time computational step [s];
% nx = Number of computational steps in the x-direction;
% ny = Number of computational steps in the y-direction;
% nt = Number of computational steps in time;
clc; clear all; close all;
% Input data
dif=5;
dec=0.00001;
ipp=5000;
xo=24000;
yo=24000;
Dd=2000;
Dt=600;
nx=22;
ny=23;
nt=288;
% Importing data for depths, velocities and diffusion
coefficients;
load ThermD.txt
load ThermU.txt
load ThermV.txt
fDep=ThermD;
fCoU=ThermU;
fCoV=ThermV;
% Subroutine for depths h=fm(i,j,fDep);
% Subroutine for velocity u=fm(i,j,fCoU);
% Subroutine for velocity v=fm(i,j,fCoV);
for i=1:nx
for
j=1:ny
cmax(i,j)=0;
end
end
imm=(nx-1)*Dd;
jmm=(ny-1)*Dd;
% Initial position of particles;
for i=1:ipp
x(i,1)=xo;
y(i,1)=yo;
end
% Number of decaying particles on every time step;
depp=round(ipp*Dt*dec);
