5
$\begingroup$

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?

$\endgroup$
4
  • 1
    $\begingroup$ 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. $\endgroup$ Mar 22, 2021 at 13:33
  • 2
    $\begingroup$ 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]}|>]] ? $\endgroup$
    – user21
    Mar 22, 2021 at 14:43
  • 1
    $\begingroup$ 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. $\endgroup$
    – Tim Laska
    Mar 23, 2021 at 14:02
  • $\begingroup$ 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 :) $\endgroup$
    – Walser
    Mar 24, 2021 at 3:43

1 Answer 1

2
$\begingroup$

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.

$\endgroup$
2
  • $\begingroup$ 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 $\endgroup$
    – Walser
    Mar 24, 2021 at 4:05
  • $\begingroup$ 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. $\endgroup$
    – Walser
    Mar 24, 2021 at 4:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.