3
$\begingroup$

Kindly I hope to know what is the wrong here. How to use NDsolve for a coupled ODE-PDE differential equations

NDSolve[{F''[t]+F[t]==0,
F[0]==0,F'[3*Pi]==1,D[u[t,x],t]==D[u[t,x],x,x],u[0,x]==0,u[t,0]==5*F[t],u[t,5]==0},
{F,u},{t,0,3*Pi},{x,0,5}];

I have received the following messages

Function::fpct: Too many parameters in {t,x} to be filled from Function[{t,x},0][t].

NDSolve::ndode: The equations {(F^[Prime])[3 [Pi]]==1,F[t]+(F^[Prime][Prime])[t]==0} are not differential equations or initial conditions in the dependent variables {u}.

$\endgroup$
  • 1
    $\begingroup$ Functions must be defined in the whole area {t,0,3*Pi},{x,0,5}. It is necessary to separate the ODE from the PDE. Or calculate the function F[t,x], but then the problem loses its meaning $\endgroup$ – Alex Trounev Jan 15 at 12:23
  • $\begingroup$ Many thanks for your reply. But I want to solve them simultaneously. How I can do that $\endgroup$ – Esza Jan 15 at 17:38
6
$\begingroup$

You can solve for F and use that solution to solve for u:

solF = NDSolve[{F''[t] + F[t] == 0, F[0] == 0, F'[3*Pi] == 1}, {F}, {t, 0, 3*Pi}][[1]];
ff = F /. solF;
Plot[ff[t], {t, 0, 3*Pi}, AxesLabel -> {"t", "F[t]"}]

enter image description here

solu = NDSolve[{D[u[t, x], t] == D[u[t, x], x, x], u[0, x] == 0, 
     u[t, 0] == 5*ff[t], u[t, 5] == 0}, {u}, {t, 0, 3*Pi}, {x, 0, 5}][[1, 1]];
Plot3D[Evaluate[u[t, x] /. solu], {t, 0, 3*Pi}, {x, 0, 5}, 
 AxesLabel -> {"t", "x", "u[t,x]"}]

enter image description here

$\endgroup$
  • $\begingroup$ Many thanks for your reply. But I want to solve them simultaneously. How I can do that? $\endgroup$ – Esza Jan 15 at 17:38
3
$\begingroup$

To solve the equations jointly, we need to define the problem so that there is a Cauchy problem. I will propose the option that the solution of the system of equations coincides with that obtained by another method by @kglr

sol = NDSolve[{D[F[t, x], t, t] + F[t, x] == D[F[t, x], x, x], 
    F[0, x] == 0, Derivative[1, 0][F][0, x] == -1, 
    Derivative[0, 1][F][t, 0] == 0, Derivative[0, 1][F][t, 5] == 0, 
    D[u[t, x], t] == D[u[t, x], x, x], u[0, x] == 0, 
    u[t, 0] == 5*F[t, 0], u[t, 5] == 0}, {F, u}, {t, 0, 3*Pi}, {x, 0, 
    5}];

{Plot3D[F[t, x] /. sol, {t, 0, 3*Pi}, {x, 0, 5}, 
  AxesLabel -> Automatic, PlotLabel -> "F"], 
 Plot3D[u[t, x] /. sol, {t, 0, 3*Pi}, {x, 0, 5}, 
  AxesLabel -> Automatic, PlotLabel -> "u"]}

fig1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.