0
$\begingroup$
 theta = .2;
 sol = NDSolve[{D[g[x, t], t] == x (1 - x) D[g[x, t], x, x]  , g[1, t] == 0, 
 g[0, t] == theta (1 - Exp[-10000000 t]) }, g, {t, 0, 2 }, {x, 0, 1}]
f[x_, t_] := (g /. sol[[1, 1]])[x, t];
t = 0.5;
LogLogPlot[{f[x, t]/(x (1 - x)), 0.2/x}, {x, 0, 1}, PlotRange -> All, 
   PlotStyle -> {Red, Blue}]

One initial condition is required to solve the above equation as g[x, 0]. I do not have the functional form of g[x,0] whereas i have the data for

 g[x,0]={19., 5., 4., 3., 3., 1., 3., 2., 2., 2., 3., 2., 0., 1., 0., 0., 0.,0., 0., 0., 0., 1., 0., 0., 0., 1., 1., 1., 1., 0., 0., 0., 1., 0.,1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 1., 0., 1., 0., 0., 0.,0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.} in steps of 0.01 and x varies from 0 to 1.

Can I use the values of g[x,0] from the list and invoke into the NDSolve to obtain the final numerical solution.

$\endgroup$
6
  • $\begingroup$ You could create an InterpolatingFunction and use that. $\endgroup$
    – user21
    May 12, 2022 at 7:11
  • $\begingroup$ Could you please write the commands for this? $\endgroup$ May 12, 2022 at 7:14
  • $\begingroup$ You have second order in x but only gave one boundary condition at x=0 $\endgroup$
    – Nasser
    May 12, 2022 at 7:15
  • $\begingroup$ There are two boundary conditions, one at x=0 and other at x=1 and there is one initial condition too which is given by list g[x,0]. $\endgroup$ May 12, 2022 at 7:24
  • 3
    $\begingroup$ I did not see g[1, t] == 0. Just an advice. always write the pde on its own, write the BC on its own, and the ic on its own (i.e. on separate lines) and use these later in the call to NDSolve. This always makes things more clear instead of writing everything in one long command. $\endgroup$
    – Nasser
    May 12, 2022 at 7:31

1 Answer 1

2
$\begingroup$

Try to interpolate g (see @user21 comment)

gi = {19., 5., 4., 3., 3., 1., 3., 2., 2., 2., 3., 2., 0., 1., 0., 0.,
0., 0., 0., 0., 0., 1., 0., 0., 0., 1., 1., 1., 1., 0., 0., 0., 
1., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 1., 0., 1., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.};

tg = Transpose[{Subdivide[0, 1, Length[gi] - 1], gi}];
ipg = Interpolation[tg, InterpolationOrder -> 1]

ipg[x] fits the points tg!

theta = .2;
G = NDSolveValue[{D[g[x, t], t] == x (1 - x) D[g[x, t], x, x], g[1, t] == 0, g[0, t] == theta (1 - Exp[-10000000 t]), g[x, 0] == ipg[x]}, g, {t, 0, 2}, {x, 0, 1}] 

G[x,t]is the solution of your pde

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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