1
$\begingroup$
dsd[q_?NumericQ] := NDSolve[{D[f1[t, x], t] == q D[x D[f1[t, x], x], x], 
  f1[0, x] == f1[1, x] == UnitStep[x - 1], f1[t, 1] == 1, 
  (D[f1[t, x], x] /. x -> 0) == 0}, f1, {t, 0, 1}, {x, 0, 1}]
solt[t_, x_] = f1[t, x] /. dsd[0.011][[1]]

The solution obtained does not match with the boundary condition given in t at t=0 and 1. Please help me out to solve the problem

$\endgroup$
1
  • $\begingroup$ What is the PDE you want to solve? t makes me think it might be a time dependent problem. Also the use of Inactive might be neccessary. If you could edit your question such that it contains the equation you would like to solve, that would help. $\endgroup$
    – user21
    Commented Mar 3, 2015 at 12:25

1 Answer 1

2
$\begingroup$

Running the code (with Mathematica 10.0.2.0 in Windows 8.1) yields a warning message instead.

NDSolve::femcscd: The PDE is convection dominated and the result may not be stable. Adding artificial diffusion may help. >>

but nonetheless produces an answer,

enter image description here

Its appearance confirms the warning message. The computation is unstable. (I suspect that you would obtain the same result upon rerunning the calculation with a fresh notebook after restarting Mathematica.)

Incidentally, I reformatted your code to make it more accessible to readers. (It produced the same results before and after the reformatting.)

Comments on Boundary Conditions

The boundary condition f1[0, x] == f1[1, x] == UnitStep[x - 1] is equivalent to f1[0, x] == f1[1, x] == 0 over the computational range {x, 0, 1}. Also, since the equation to be solved is the diffusion equation, specifying boundary conditions at both t == 0 and t == 1 may be inappropriate. If f1[0, x] == 0 only is used instead, the warning message given in the Question appears. This is because two of the boundary conditions now are f1[0, x] == 0, f1[t, 1] == 1, which is inconsistent at x == t == 0. (Why NDSolve did not give this warning with f1[1, x] == 0 also specified is unclear.) The boundary conditions easily can be made consistent without changing the character of the problem, for instance by using f1[0, x] == 0, f1[t, 1] == 1 - Exp[-100 t], whereupon the warning error disappears. With these changes, the code reads,

dsd[q_?NumericQ] := NDSolve[{D[f1[t, x], t] == q D[x D[f1[t, x], x], x], f1[0, x] == 0, 
  f1[t, 1] == 1 - Exp[-100 t], (D[f1[t, x], x] /. x -> 0) == 0}, f1, {t, 0, 1}, {x, 0, 1}];
solt[t_, x_] = f1[t, x] /. dsd[0.011][[1]]

and a plot of the solution, produced as before by

Plot3D[solt[t, x], {t, 0, 1}, {x, 0, 1}, AxesLabel -> {t, x}, PlotRange -> All]

is the reasonable

enter image description here

$\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.