Skip to main content
5 of 5
edited tags
user21
  • 40.7k
  • 8
  • 114
  • 170

Using DSolve and NDSolve for 1D steady-state diffusion equation with a reaction term

I am trying to solve for a 1D steady-state diffusion equation (Fick's Second Law/Heat Equation) with a reaction term. I wanted to compare using both DSolve and NDSolve.

However, when running the code, I get multiple errors: enter image description here

(*L+rUnderoverscript[\[Equilibrium], d1, k1]R*)
k1 = 0.00193
d1 = 0.00700
K1 = d1/k1
NT = 1.7
(*Total Receptors(NT) = r+R*)
R = (NT*u[x])/(K1 + u[x])
r = NT - R
RL = (d1*R) - (k1*u[x]*r)

diffCo = 0.0001; (*Diffusion coefficient*)
bc = {DirichletCondition[u[x] == 1, x == 0], DirichletCondition[u[x] == 0, x == 100]};
eqn = diffCo*u''[x] + RL == 0;

solDSolve = u[x] /. First@DSolve[{eqn, bc}, u[x], {x, 0, 100}]

solNDSolve = 
 NDSolve[{eqn, bc}, u, {x, 0, 100}, 
  Method -> {"FiniteElement", MeshOptions -> MaxCellMeasure -> 0.001}]

Am I setting something up incorrectly? Thank you.

AhWee
  • 123
  • 5