2
$\begingroup$

I'm trying to use Mathematica to solve the following equation $$\partial_t u = \partial_x (u^2 \partial_xu)$$ with $$u(0,t)=u(1,t)=0$$ and $$u_0(x)=\sin(\pi x)$$ in order to check a numerical method I developed with Python. What I obtain at time $t=1$ with Python is the following one:

enter image description here

I want to use Mathematica to see whether its solution is the same I obtain or not, but since I'm not familiar, I can't do that and I need a check.

Any confirm or check is highly appreciated !

$\endgroup$
5
$\begingroup$

How about

sol = NDSolveValue[{
   D[u[x, t], t] == D[u[x, t]^2 D[u[x, t], x], x],
   u[0, t] == 0, u[1, t] == 0, u[x, 0] == Sin[Pi x]}
  , u, {x, 0, 1}, {t, 0, 1}]

Then

Plot[sol[x, t] /. t -> Range[0, 5]/5 // Evaluate, {x, 0, 1}, 
 PlotLegends -> Range[0, 5]/5, PlotStyle -> ColorData[10]]

enter image description here

$\endgroup$
2
  • $\begingroup$ Thanks I'm going to try now, but I can't understand (from your graph), what is the colour that corresponds to $t=1$. $\endgroup$
    – Vefhug
    Sep 18 '20 at 19:40
  • 1
    $\begingroup$ I just reimplemented everything with finite differences (following this question math.stackexchange.com/questions/3805692/…), and I find the same solution you wrote for different times! Still don't know what's wrong with my FEM, but thanks again! $\endgroup$
    – Vefhug
    Sep 18 '20 at 23:04

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.