# Problem when solving differential equation [closed]

Can anyone tell me why do I have errors when I try the code below ?

cd[t] = t*e^(t/2);
s0 = 10; u = 0.4; w = 0.9; v = 0.01; k = 0.1; p = 5; L = 4;
pde1 = w*D[c[x, t], t] + u*D[c[x, t], x] - v*D[c[x, t], {x, 2}] == -k*c[x, t]*s[x, t];
pde2 = D[s[x, t], t] == -p*k*c[x, t]*s[x, t];
sol =
NDSolve[
{pde1, pde2, c[0, t] == cd[t], c[L, t] == 0, c[x, 0] == 0, s[x, 0] == s0},
{c, s}, {x, 0, 4}, {t, 0, 10}]
Plot3D[{c[x, t], s[x, t]} /. sol,{t, 0, 4}, {x, 0, 10}]


## closed as off-topic by Daniel Lichtblau, Michael E2, Henrik Schumacher, m_goldberg, MarcoBJun 9 at 15:15

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Daniel Lichtblau, Michael E2, Henrik Schumacher, m_goldberg, MarcoB
If this question can be reworded to fit the rules in the help center, please edit the question.

• What are the error messages? – Michael E2 Jun 8 at 13:11
• InterpolatingFunction::dmval NDSolve::nlnum those are the name of errors i got sorry if i didnt use the right style of this forum i am new here – ilyes abidi Jun 8 at 13:20

You have number of basic syntax errors. You can try this

ClearAll[t,s,x,t,c]
cd[t_] :=t*E^(t/2);
s0=10;u=0.4;w=0.9;v=0.01;k=0.1;p=5;L=4;(*I choose these randomly*)
pde1 = w*D[c[x,t],t]+u*D[c[x,t],x]-v*D[c[x,t],{x,2}]==-k*c[x,t]*s[x,t];
pde2 = D[s[x,t],t]==-p*k*c[x,t]*s[x,t];
sol  = NDSolve[{pde1,pde2,c[0,t]==cd[t],c[L,t]==0,c[x,0]==0,s[x,0]==s0},
{c,s},{x,0,4},{t,0,10}]


Plot3D[{Evaluate[c[x, t] /. sol], Evaluate[s[x, t] /. sol]},
{t, 0, 4}, {x, 0, 10}, PlotStyle -> {Red, Yellow}]


To see full range, you can add PlotRange->All

Plot3D[{Evaluate[c[x, t] /. sol], Evaluate[s[x, t] /. sol]},
{t, 0, 4}, {x, 0, 10}, PlotStyle -> {Red, Yellow}, PlotRange -> All]


Update

You can use specific time instance:

Plot[{Evaluate[c[x, 1] /. sol], Evaluate[s[x, 1] /. sol]},
{x, 0, 10},
PlotStyle -> {Red, Blue},
PlotRange -> {Automatic, {-10, 20}},
ImageSize -> 400,
PlotLegends -> {"c", "s"}]


Or you can make a small manipulate

Manipulate[
Grid[{
{Row[{"time = ", time}]},
{
Plot[{Evaluate[c[x, time] /. sol], Evaluate[s[x, time] /. sol]},
{x, 0, 10},
PlotStyle -> {Red, Blue},
PlotRange -> {Automatic, {-20, 60}},
ImageSize -> 400,
PlotLegends -> {"c", "s"}]
}}],
{{time, 0, "time"}, 0, 10, .1}
]


• thnk you so much for the help can you please tell me how to add different colors to see the difference between s and c – ilyes abidi Jun 8 at 20:53
• @ilyesabidi Added colors. You need to make the two functions as list, and then use PlotStyle. – Nasser Jun 8 at 21:13
• @ilyesabidi added for single time instance example – Nasser Jun 8 at 21:46