I am trying to simulate solute transport of acid (HCl) and consequent mineral dissolution around a grain (calcite).
The governing equation for transport is the advection-diffusion equation, given as:
where C is the concentration, v is the flow velocity, D is the diffusion coefficient. At a constant flow velocity, the above is discretized using an FTCS formulation as:
The dissolution occur at the fluid/solid interface – and can be modelled as a Robin type Bc, which is described as:
where r is the mineral rate of dissolution, ε is the stoichiometric coefficient of species in the dissolution process (this is equal to 1 in the reaction considered), k_(H+) is the rate constant, γ_(H+) is the activity coefficient, and c_(H+) is the molar concentration of reacting specie (in this case Hydrogen or chloride ion).
I have discretized Eq. (4) as:
This is my code so far:
clc; clear; close all;
%%%%%%%%%% Specify inputs
CircleDiam = 40; %in pixels
Co = 0; %initial conc. in the domain [mol/L]
Cin = 0.01; %conc. of injected fluid [mol/L]
Lx = 0.1/100; %Length of domain [m]
nx = 200; %spatial gridpoints in x
dx = Lx/(nx-1); %Length step size [m]
Ly = 0.05/100; %Width of domain [m]
ny = 100; %spatial gridpoints in y
dy = Ly/(ny-1); %Length step size [m]
T = 5/(3600*24); %Simulation time [days]
nt = 8000; %shifts
dt = T/nt; %Time step [days]
% Flow
u = 103.68; %Velocity in x direction [m/day]
v = 0; %Velocity in y direction [m/day]
De = 8.64e-04; %Dispersion coeff. [m2/day]
betaX = u*dt/dx;
betaY = v*dt/dy;
gammaX = De*dt/(dx^2);
gammaY = De*dt/(dy^2);
%%%%%%%%%% Create image with solid object
radius = CircleDiam/2;
% obtain full output grids from grid vectors
[Colgrids, Rowgrids] = meshgrid(1:nx, 1:ny);
% create a logical mask for the circle by specifying the center and diameter of the circle.
centerX = 0.5 + (nx/2);
centerY = 0.5 + (ny/2);
% obtain image from: ( (y-y0)^2 + (x-x0)^2 ) <= r^2, where (y0,x0) is the centre point of circle
SolidImg = (Rowgrids - centerY).^2 + (Colgrids - centerX).^2 <= radius.^2;
% change from logical to numeric labels. Also, transpose matrix to conform with the conc. matrix
P = double(SolidImg');
%figure, imshow(~SolidImg, [], 'InitialMagnification','fit'); box on;
%%%%%%%%%% Find the solid boundaries
BW = im2bw(P);
BW_filled = imfill(BW,'holes');
boundaries = bwboundaries(BW_filled);
for k = 1:size(boundaries, 1)
bdr_matrix = boundaries{k};
end
row = bdr_matrix(:,1);
col = bdr_matrix(:,2);
% Gridblocks
x = 0:dx:Lx;
y = 0:dy:Ly;
t = 0:dt:T;
[X,Y] = meshgrid(x, y);
% specify initial conditions
C = zeros(nx, ny, nt+1);
C(:,:,1) = Co; %Initial condition
% specify Reaction parameters
kh = 77004.081; % [mol/m2/day]
gammaH = 1; % [L/mol]
%iterate finite difference equations
for k = 1:nt
for j = 2:ny-1
for i = 2:nx-1
if P(j,i)==1 %Solid pixels
C(j,i,k+1) = C(j,i,k);
% Apply the robin bc at the fluid/solid interface
if ismember(P(j,i), P(row, col))
C(j,i,k+1) = C(j,i,k)...
- 1000*0.5*De*(C(j,i+1,k)-C(j,i-1,k)/dx)/(kh*gammaH)...
- 1000*0.5*De*(C(j+1,i,k)-C(j-1,i,k)/dy)/(kh*gammaH); % multiply by 1000L to make dimensionally consistent with mol/L
end
else
C(j,i,k+1) = C(j,i-1,k)*(betaX/2+gammaX) + C(j,i+1,k)*(gammaX-betaX/2)...
+ C(j-1,i,k)*(betaY/2+gammaY) + C(j+1,i,k)*(gammaY-betaY/2)...
+ C(j,i,k)*(1-2*gammaX-2*gammaY);
end
end
end
% Insert boundary conditions
C(1,:,k+1) = C(2,:,k+1); % south
C(end,:,k+1) = C(end-1,:,k+1); % north
C(:,1,k+1) = Cin; % west
C(:,end,k+1) = C(:,end-1,k+1); % east
end
My result (see image) does not look like what I would expect (see second image). Ideally, I expect to see something like the above image, and so I am wondering where I might be getting it wrong. I have assumed that both velocity and diffusion coefficient are zero at the solid cells, and I have also prescribed a robin type bc at the fluid/solid interface, however, I get the same outcome when I run the code without eq. (5). I want to believe that I am not doing this the right way. I am not completely sure if I have discretized Eq. (5) the right way, and I am wary of how I have implemented it (i.e., eq. 5) in the code. I thus would very much appreciate if someone can help me out here or point me in the right direction.
PS: The axes are the same in both image. The difference is that mine is in pixels while the other is in cm.
Thank you in anticipation.
EDIT
Thank you so much for your help @Sthavishtha Bhopalam . I am indeed very grateful.
I do have some questions/comments/clarifications:
- I obtained the velocity field from LBM. It’s a pity I didn’t mention this initially. I have now included the appropriate lines of code (without the LBM though) as shown below - and I'd appreciate if you can confirm the correctness.
The following comes just before the loop:
% calculate flow velocity field
[u,v] = FlowVelocitySolver(nx,ny,1000); % iter = 1000;
And then the values of u
and v
at every point in the grid is utilized in the advection term.
- I have run the code with your amendments – and I got the expected shape as in Molins et al. (see the new figure), however:
• I see you changed the inlet velocity from 103.68 m/day (which is 0.12 cm/s) to 10.368 m/day (which is 0.012 cm/s), the former being the same with Molins et al.
• I noticed that numerical instability occurs at the fluid-solid interface when I use 103.68 m/day. This happens even after I adjusted the time step value to match the stability criteria. Is this the reason you changed to 10.368 m/day?
- I was looking to use other kinetic formulations. For example, see pages 68-69 of: https://biblio.ugent.be/publication/8071415/file/8071428.pdf
Would it be right to discretize Eqs. 4.10, given by:
$ -D\textbf n.\nabla c = \frac{V}{A_{s}}k_{het}(c – c_{eq}) $
Many thanks once again.