Skip to main content
edited body
Source Link
Michael E2
  • 244.7k
  • 18
  • 351
  • 774

The residuals are not very good at the boundaries. I'm not very familiar with PDEs, so I'm not sure what to make of that. It seemed a better solution than f[x, t] = 11+t, g[x, t] = 0 given in the first paragraph above.

The residuals are not very good at the boundaries. I'm not very familiar with PDEs, so I'm not sure what to make of that. It seemed a better solution than f[x, t] = 1, g[x, t] = 0 given in the first paragraph above.

The residuals are not very good at the boundaries. I'm not very familiar with PDEs, so I'm not sure what to make of that. It seemed a better solution than f[x, t] = 1+t, g[x, t] = 0 given in the first paragraph above.

Source Link
Michael E2
  • 244.7k
  • 18
  • 351
  • 774

What you have, I guess, is DAE in the variable t. If you specify the initial condition g[x, 0] == Cosh[x]/Cosh[Pi], NDSolve will compute a "solution," but warns that "an insufficient number of boundary conditions have been specified for the direction of independent variable x." It then computes different initial values, that lead g to be almost identically zero.

One approach that might work is to differentiate the g-equation with respect to t to get a differential equation (with respect to time). Since we know the initial condition in the OP's example, this is easy to set up. Otherwise, we would have to solve for the IC.

NDSolve[{D[f[x, t], t] == 1 - D[f[x, t], x] g[x, t], 
  D[g[x, t], x, x] == g[x, t] f[x, t], f[x, 0] == 1, 
  f[-π, t] == f[π, t] == 1, 
  g[-π, t] == g[π, t] == 1}, {f, g}, {x, -π, π}, {t, 
  0, 1}]

{sol} = NDSolve[{D[f[x, t], t] == 1 - D[f[x, t], x] g[x, t], 
    D[D[g[x, t], x, x] == g[x, t] f[x, t], t],
    f[x, 0] == 1, f[-π, t] == f[π, t] == 1,
    g[x, 0] == Cosh[x]/Cosh[Pi], g[-π, t] == g[π, t] == 1},
   {f, g}, {x, -π, π}, {t, 0, 1}];

Result:

GraphicsRow[
 Plot3D[Last[#][x, t], {x, -π, π}, {t, 0, 1}, 
    AxesLabel -> Automatic, PlotLabel -> First[#]] & /@ sol
 ]

Mathematica graphics

The residuals are not very good at the boundaries. I'm not very familiar with PDEs, so I'm not sure what to make of that. It seemed a better solution than f[x, t] = 1, g[x, t] = 0 given in the first paragraph above.

GraphicsRow[
 Plot3D[Evaluate[# /. sol /. Equal -> Subtract], {x, -π, π}, {t, 0, 1}, 
    AxesLabel -> Automatic, PlotLabel -> #, 
    PlotRange -> All] & /@ {D[f[x, t], t] == 
    1 - D[f[x, t], x] g[x, t], D[g[x, t], x, x] == g[x, t] f[x, t]}
 ]

Mathematica graphics

GraphicsRow[
 Plot3D[Evaluate[# /. sol /. Equal -> Subtract], {x, -π, π}, {t, 0, 1}, 
    AxesLabel -> Automatic, PlotLabel -> #, 
    PlotRange -> 0.0002] & /@ {D[f[x, t], t] == 
    1 - D[f[x, t], x] g[x, t], D[g[x, t], x, x] == g[x, t] f[x, t]}
 ]

Mathematica graphics