# Piecewise Initial Conditions in NDSolve

Posted 10 years ago
5054 Views
|
3 Replies
|
0 Total Likes
|
 Hello,I'm trying to solve the system like this. The main problem is piecewise initial conditions. I tried to use Piecewise function in Mathematica, but Mathematica throws an error"The first argument {1,0<=thet<=\[Pi]/6} of Piecewise is not a list \of pairs. "What is my mistake? Here's the code c = 100; b = 1;  a = 1.01; mu = 1; r0 = 0.1;   w = NDSolve[{D[u[r, thet, t], t] ==      D[u[r, thet, t], {r, 2}] + (1/r) D[u[r, thet, t], r] + (1/r^2) D[       u[r, thet, t], {thet, 2}] +      u[r, thet, t] (1 - u[r, thet, t] - c*x[r, thet, t]),   D[x[r, thet, t], t] ==     mu*(D[x[r, thet, t], {r, 2}] + (1/r) D[x[r, thet, t],           r] + (1/r^2) D[x[r, thet, t], {thet, 2}]) +      a*x[r, thet, t] (1 - c*u[r, thet, t] - b*x[r, thet, t]),   D[u[r, thet, t], r] == 0 /. {r -> 1},   D[x[r, thet, t], r] == 0 /. {r -> 1},   u[r, thet, 0] ==     Piecewise[{{Piecewise[{1, 0 <= thet <= Pi/6}, {0,          Pi/6 < thet < 2 Pi}], r <= r0}}, {0, r > r0}],   x[r, thet, 0] == u[r, thet, 0] ==     Piecewise[{{Piecewise[{0, 0 <= thet <= Pi/6}, {1,          Pi/6 < thet < 2 Pi}], r <= r0}}, {0, r > r0}],   }, {u[r, thet, t], x[r, thet, t]}, {t, 0, 100}, {r, 0, 1}, {thet,    0, 2 Pi}]Thanks!
3 Replies
Sort By:
Posted 10 years ago
 Here's the solution, the mistake was with brackets  w = NDSolve[{D[u[r, thet, t], t] ==      D[u[r, thet, t], {r, 2}] + (1/r) D[u[r, thet, t], r] + (1/r^2) D[        u[r, thet, t], {thet, 2}] +       u[r, thet, t] (1 - u[r, thet, t] - c*x[r, thet, t]),    D[x[r, thet, t], t] ==      mu*(D[x[r, thet, t], {r, 2}] + (1/r) D[x[r, thet, t],            r] + (1/r^2) D[x[r, thet, t], {thet, 2}]) +       a*x[r, thet, t] (1 - c*u[r, thet, t] - b*x[r, thet, t]),   D[u[r, thet, t], r] == 0 /. {r -> 1},   D[x[r, thet, t], r] == 0 /. {r -> 1},   D[u[r, thet, t], r] == 0 /. {r -> 0.01},   D[x[r, thet, t], r] == 0 /. {r -> 0.01},   u[r, thet, 0] ==     Piecewise[{{Piecewise[{{0, 0 <= thet <= Pi/6}, {1,           Pi/6 < thet < 2 Pi}}], r <= r0}, {0, r > r0}}],   x[r, thet, 0] ==     Piecewise[{{Piecewise[{{1, 0 <= thet <= Pi/6}, {0,           Pi/6 < thet < 2 Pi}}], r <= r0}, {0, r > r0}}]}, {u[r, thet,     t], x[r, thet, t]}, {t, 0, 10}, {r, 1}, {thet, 2 Pi}]
Posted 10 years ago