5

I'm trying to model the following boundary condition using MassTransferValue.

$$ D_A \frac{\partial[A]} {\partial x} + D_B \frac{\partial[B]} {\partial x}+ D_C \frac{\partial[C]} {\partial x}=0 $$

The help file does have an example where it handles two species and I can add a third one.

MassTransferValue[
 x >= 0, {{Subscript[c, 1][x], Subscript[c, 2][x]}, {x}}, <|
  "AmbientConcentration" -> {Subscript[c, ext1][t, x, y], 
    Subscript[c, ext2][t, x, y]}, 
  "MassTransferCoefficient" -> {Subscript[k, 1], Subscript[k, 2]}|>]

However the output to this consists of two separate Neumann conditions (rather than one). Maybe I can link the two together using the MassTransferCoefficient but is there a cleaner way to do it?

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Walser
  • 351
  • 1
  • 8
  • 1
    Can you show the minimal working example with A,B,C involved? We should underline, that in the tutorial there is no any example with sum as in your question. The implementation of such bc with FEM is not a problem, even without MassTransferCoefficient. – Alex Trounev Mar 22 '21 at 13:33
  • 2
    How about Total[MassTransferValue[ x >= 0, {{Subscript[c, 1][x], Subscript[c, 2][x]}, {x}}, <| "AmbientConcentration" -> {Subscript[c, ext1][t, x, y], Subscript[c, ext2][t, x, y]}, "MassTransferCoefficient" -> {Subscript[k, 1], Subscript[k, 2]}|>]] ? – user21 Mar 22 '21 at 14:43
  • 1
    Are you trying to represent surface reactions as you did in your previous 2 species cyclic voltammetry question 240407? If so, I think you need to provide the rate expressions as well. – Tim Laska Mar 23 '21 at 14:02
  • Pretty much. I'm going through different kinds of reactions to model them. This was one model with a boundary condition. I want to sort the problems out on my own before seeking help for the final push :) – Walser Mar 24 '21 at 03:43

1 Answers1

2

What you can do is:

vars = {{Subscript[c, 1][x], Subscript[c, 2][x]}, {x}};
pars = <|"DiffusionCoefficient" -> {{1, 0}, {0, 1}}, 
   "AmbientConcentration" -> {Subscript[c, ext1][t, x, y], 
     Subscript[c, ext2][t, x, y]}, 
   "MassTransferCoefficient" -> {Subscript[k, 1], Subscript[k, 2]}|>;

Total[MassTransferValue[x >= 0, vars, pars]]

However, I am not quite sure why you would want to do that. The corresponding PDE is a system of 2 PDEs:

MassTransportPDEComponent[vars, pars]
{Inactive[Div][{{-1}} . Inactive[Grad][Subscript[c, 1][x], {x}], {x}], 
 Inactive[Div][{{-1}} . Inactive[Grad][Subscript[c, 2][x], {x}], {x}]}

And this fits nicely with the boundary condition that also returns two equations:

MassTransportPDEComponent[vars, pars] == 
 MassTransferValue[x >= 0, vars, pars]

{Inactive[Div][{{-1}} . Inactive[Grad][Subscript[c, 1][x], {x}], {x}], Inactive[Div][{{-1}} . Inactive[Grad][Subscript[c, 2][x], {x}], {x}]} == {NeumannValue[Subscript[k, 1](-Subscript[c, 1][x] + Subscript[c, ext1][t, x, y]), x >= 0], NeumannValue[Subscript[k, 2](-Subscript[c, 2][x] + Subscript[c, ext2][t, x, y]), x >= 0]}

If for some reason (and I'd be curious to know) you want the boundary condition to be associated with a specific equation you can use:

MassTransportPDEComponent[vars, pars] == {0, 
  Total[MassTransferValue[x >= 0, vars, pars]]}

If you wanted to associate it with the second equation. Leave me a comment why this is important to be able to do.

user21
  • 39,710
  • 8
  • 110
  • 167
  • Well I'm new to this side of Mathematica and was trying to replicate some of the models lying around. This happened to be one of the boundary conditions in one model. What kind of confused me is that the rate expressions (k) will have to be 0 in order to generate the Neumann value via MassTransferValue – Walser Mar 24 '21 at 04:05
  • One purpose was to be able to create demonstrations for different models for my students and show them how changing parameters affect the species concentration and the shape of the voltammogram. – Walser Mar 24 '21 at 04:19