Skip to main content
added 81 characters in body
Source Link
user21
  • 40.7k
  • 8
  • 114
  • 170

This is the same approach that Tim describes in his solution, but implemented with the ToGradedMeshToGradedMesh function added in version 13.0:

mesh = ToGradedMesh[
   Line[{{0}, {xmax}}], <|"Alignment" -> "Left", 
    "ElementCount" -> 100, "MinimalDistance" -> xmax/10000|>];
MeshRegion[mesh]

mesh

eqsH = {D[H[x, t], t] - dH D[H[x, t], x, x] == 
    NeumannValue[Ls Exp[a f Ea] P[x, t] - Ls Exp[-a f Ea] H[x, t], 
     x == 0], H[x, 0] == 1};
eqsP = {D[P[x, t], t] == 
    NeumannValue[-Ls Exp[a f Ea] P[x, t] + Ls Exp[-a f Ea] H[x, t], 
     x == 0], P[x, 0] == 1};

{Hfun, Pfun} = 
  NDSolveValue[{eqsH, eqsP}, {H, P}, x \[Element] mesh, {t, 0, tmax}, 
   Method -> {"MethodOfLines", "SpatialDiscretization" -> {"FiniteElement"}}];

imgs = Plot[Hfun[x, #], x \[Element] mesh, 
     PlotRange -> {{0, 0.015}, {0.99999, 1.002}}] & /@ Subdivide[0, 2, 120];
ListAnimate@imgs

plot

This is the same approach that Tim describes in his solution, but implemented with the ToGradedMesh function added in version 13.0:

mesh = ToGradedMesh[
   Line[{{0}, {xmax}}], <|"Alignment" -> "Left", 
    "ElementCount" -> 100, "MinimalDistance" -> xmax/10000|>];
MeshRegion[mesh]

mesh

eqsH = {D[H[x, t], t] - dH D[H[x, t], x, x] == 
    NeumannValue[Ls Exp[a f Ea] P[x, t] - Ls Exp[-a f Ea] H[x, t], 
     x == 0], H[x, 0] == 1};
eqsP = {D[P[x, t], t] == 
    NeumannValue[-Ls Exp[a f Ea] P[x, t] + Ls Exp[-a f Ea] H[x, t], 
     x == 0], P[x, 0] == 1};

{Hfun, Pfun} = 
  NDSolveValue[{eqsH, eqsP}, {H, P}, x \[Element] mesh, {t, 0, tmax}, 
   Method -> {"MethodOfLines", "SpatialDiscretization" -> {"FiniteElement"}}];

imgs = Plot[Hfun[x, #], x \[Element] mesh, 
     PlotRange -> {{0, 0.015}, {0.99999, 1.002}}] & /@ Subdivide[0, 2, 120];
ListAnimate@imgs

plot

This is the same approach that Tim describes in his solution, but implemented with the ToGradedMesh function added in version 13.0:

mesh = ToGradedMesh[
   Line[{{0}, {xmax}}], <|"Alignment" -> "Left", 
    "ElementCount" -> 100, "MinimalDistance" -> xmax/10000|>];
MeshRegion[mesh]

mesh

eqsH = {D[H[x, t], t] - dH D[H[x, t], x, x] == 
    NeumannValue[Ls Exp[a f Ea] P[x, t] - Ls Exp[-a f Ea] H[x, t], 
     x == 0], H[x, 0] == 1};
eqsP = {D[P[x, t], t] == 
    NeumannValue[-Ls Exp[a f Ea] P[x, t] + Ls Exp[-a f Ea] H[x, t], 
     x == 0], P[x, 0] == 1};

{Hfun, Pfun} = 
  NDSolveValue[{eqsH, eqsP}, {H, P}, x \[Element] mesh, {t, 0, tmax}, 
   Method -> {"MethodOfLines", "SpatialDiscretization" -> {"FiniteElement"}}];

imgs = Plot[Hfun[x, #], x \[Element] mesh, 
     PlotRange -> {{0, 0.015}, {0.99999, 1.002}}] & /@ Subdivide[0, 2, 120];
ListAnimate@imgs

plot

Source Link
HeNeos
  • 306
  • 3
  • 4

This is the same approach that Tim describes in his solution, but implemented with the ToGradedMesh function added in version 13.0:

mesh = ToGradedMesh[
   Line[{{0}, {xmax}}], <|"Alignment" -> "Left", 
    "ElementCount" -> 100, "MinimalDistance" -> xmax/10000|>];
MeshRegion[mesh]

mesh

eqsH = {D[H[x, t], t] - dH D[H[x, t], x, x] == 
    NeumannValue[Ls Exp[a f Ea] P[x, t] - Ls Exp[-a f Ea] H[x, t], 
     x == 0], H[x, 0] == 1};
eqsP = {D[P[x, t], t] == 
    NeumannValue[-Ls Exp[a f Ea] P[x, t] + Ls Exp[-a f Ea] H[x, t], 
     x == 0], P[x, 0] == 1};

{Hfun, Pfun} = 
  NDSolveValue[{eqsH, eqsP}, {H, P}, x \[Element] mesh, {t, 0, tmax}, 
   Method -> {"MethodOfLines", "SpatialDiscretization" -> {"FiniteElement"}}];

imgs = Plot[Hfun[x, #], x \[Element] mesh, 
     PlotRange -> {{0, 0.015}, {0.99999, 1.002}}] & /@ Subdivide[0, 2, 120];
ListAnimate@imgs

plot