I have serval reaction-diffusion equations to be solved. Which are equivalent to the following problem:
First is a simple diffusion equation of $Z(t,r)$ like below: $$ \dfrac{\partial Z}{\partial t}=A(t,r)\dfrac{\partial^2 Z}{\partial r^2} $$
Then $Z(t,r)$ is actually defined from: $$ Z(t,r) \equiv \dfrac{\partial V(t,r)}{\partial r}$$ In my problem, I must have the value of $V(t,r)$ at every $(t,r)$ to determine the value of, for example, $A(t,r)=F(V(t,r))$. Bondary condtions are $$ V(t,0)=0,V(t,1)=0,\\ Z_r(t,0)=0,Z_r(t,1)=0 $$
For testing, I just set $A$ a constant, and tried something like below:
A = 0.01; L = 1; tmax = 10;
eqns = {V[t, r] == Integrate[Z[t, r], r],
D[Z[t, r], t] - A D[Z[t, r], {r, 2}] == NeumannValue[0, r == 0 || r == 1]};
INIs = {Z[0, r] == 2 Pi Cos[2 Pi r]};
BCs = {DirichletCondition[V[t, r] == 0, r == 0 || r == 1 ]};
sys = {eqns, BCs, INIs};
sol = NDSolve[sys, {V, Z}, {r, 0, L}, {t, 0, tmax}]
The codes run successfully without warning, but the results are quite strange: In the result $Z(t, r)$ is correctly calculated, while $V(t, r)$ is not correct. Does anyone know why it behaviors like this? Or any other way to do deal with this problem? Thanks a lot.
Update
I found that this system is solved by NDSovle as differential algebraic equations. I tried index reduction of DAE as described in this. Here are the codes:
A = 0.01; L = 1; tmax = 10;
eqns = {V[t, r] == Integrate[Z[t, r], r],
D[Z[t, r], t] - A D[Z[t, r], {r, 2}] ==
NeumannValue[0, r == 0 || r == L]};
INIs = {Z[0, r] == 2 Pi Cos[2 Pi r],
V[0, r] == Sin[2 Pi r]};
BCs = {DirichletCondition[V[t, r] == 0, r == 0 || r == L]
};
sys = {eqns, BCs, INIs};
sol = NDSolve[sys, {V, Z}, {r, 0, L}, {t, 0, tmax},
Method -> {"IndexReduction" -> {"StructuralMatrix"}}]
And the results are different.
- In the previous codes, all BCs are satisfied, but initial value of $V(t,r)$ is not I wanted.
- In the updated codes, with index reduction. I can add the initial value of $V(t,r)$, which is satisfied by the result. But one of the boundary conditions of $Z(t,r)$ is violated.
Why can't it satisfy both ICs and BCs as I gave?
NDSolve
getting solution forZ
since there is no any special algorithm to solve mixture integral and differential equations, see, for example, my post about it on mathematica.stackexchange.com/questions/217201/… $\endgroup$Integrate[W[x, y, t], {y, 0, y}]
doesn't make sense to me. I would write it asIntegrate[W[x, yy, t], {yy, 0, y}]
orIntegrate[W[x, y, t], {y, 0, L}]
depending on the problem. $\endgroup$