- estimate A & B diffusion at all bins with a discretized version of the diffusion equation
- react any A + B => S that are in the same bin, at all bins
- update A, B, S concentrations to reflect reactions at all bins

11 views (last 30 days)

Show older comments

William Rose
on 3 Jun 2021

Here is a simulation. Figure 1 shows the concentration profiles at specific time points. The simulation should conserve mass. Figure 2 shows that it does. Figure 2 also shows that the base is fully consumed by about t=0.55.

The time step is dt=1e-5. This value was chosen because negative concentrations occurred when dt=1e-4, which indicates dt=1e-4 is not small enough.

For each time step

- estimate A & B diffusion at all bins with a discretized version of the diffusion equation
- react any A + B => S that are in the same bin, at all bins
- update A, B, S concentrations to reflect reactions at all bins

Repeat

Salt does not diffuse from its site of formation.

William Rose
on 3 Jun 2021

William Rose
on 1 Jun 2021

Do you expect to end up with a partial differential equation, as expected for diffusion? Of course the 1D equation is

where u=concentration and α=diffusion constant.

Or do you expect to get an ordinary differential equation, which can result if you can make enough simplifying assumptions about the geometry?

Are the acid slab and the base slab porous solids in which acid and base diffuse, or are the slabs well-stirred liquids, or something else? As the product forms at the interface, does it accumulate to make a growing third slab in between the other two? In that case, the acid and base on each side must diffuse through the growing product slab in order to reach one another. And then we must ask whether reactions can occur within the product slab, or only on its outer edges.

A simple version of this problem is to assume u=0 at x=0, at all times, and that the acid and base sides are independent and have the same diffusion constant and initial value, and the concentrations are initally uniform through each slab. These are boundary conditions. Then it is like a 1-D heat problem where one end of the bar is at T=0.

Create a 2D array u(i,j) whose elements are the acid (or base; they're the same) concentrations at . In other words, row 1 elements are the concentrations at t=0, for various positions. Column 1 elements are the concentrations at x=0, for various times. Column 1 will be zero for the whole simulation, because the reactant reaching x=0 is immediately consumed. Row 1 is a row of constants (except for a 0 in column 1), beacuse we assume a uniform concentration in the slab at t=0. The rest of the rows are unknown. Compute row 2 by applying the discretized diffusion equation to row 1, and think about how you want to treat the edges. Repeat for successive rows, until done, i.e. until completing the final time step. Will it reach a steady state? Do the simulation to find out.

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!