# differential equations – ndsolve with several initial conditions

I'm trying to solve a PDE using the NDsolve with initial and boundary conditions,

``````NDSolve[{D[u[t, x], t]- RE[ D[u[t, x], X]]+ D[u[t, x], X]== 10,
you[0, x] == 2,
you[t, 0] == 1,
you[t, 2] == 1
}
you
{t, 0, 5}, {x, 0, 2}, MaxStepSize -> 0.01]
``````

it worked. But when I try to assign an initial condition: u[0,x]= 2 when 0.5 <= x <= 1, u[0,x]= 1 elsewhere in [0,2] by means of If

``````NDSolve[{D[u[t, x], t]- RE[ D[u[t, x], X]]+ D[u[t, x], X]== 10,
Yes[05<=x[05<=x[05<=x[05<=x<= 1, u[0, x] == 2, u[0, x] == 1],
u[t, 0] == 1,
u[t, 2] == 1
},
u,
{t, 0, 5}, {x, 0, 2}, MaxStepSize -> 0.01]
``````

the system has made me

``````NDSolve :: deqn: Equation or list of expected equations instead of If[05<=x<=1u[05<=x<=1u[05<=x<=1u[05<=x<=1u[0,x]== 2, u[0,x]== 1]in the first argument {(u ^ (1,0))[t,x]== 10, if[05<=x<=1u[05<=x<=1u[05<=x<=1u[05<=x<=1u[0,x]== 2, u[0,x]== 1]you[t,0]== 1, u[t,2]== 1}.
``````

I know something is wrong with the expression of my initial conditions, but how do I assign the initial conditions with an if condition. Or a better way to manage it?

Thank you for your time!

Posted on