TransWikia.com

Solving a heat equation on a finite interval with Neuman boundary conditions

Mathematica Asked by kroner on July 2, 2021

I am new to Mathematica and need to verify my numerical result.
Can anyone please show me how to solve the following heat equation problem $$ u_t = u_{xx}$$
on the interval $ x in [0,1]$. The initial condition is
$$ u(x,0) = (sin(pi x))^{100} $$ and Neumann boundary conditions
$$u_x(0,t)=u_x(1,t)=0$$

I was hoping to plot the solution at time $t=1$ with respect to $x$. Can anyone please help me? I am a complete novice and the internet was not much help.

Edit: this is what I have managed to use for the equation

sol2 = NDSolveValue[{D[u[t, x], {t, 1}] - D[u[t, x], {x, 2}] == 
     NeumannValue[0, x == 0] + NeumannValue[0, x == 1], 
    u[0, x] == (Sin[Pi*x])^100}, u, {x, 0, 1}, {t, 0, 2}, 
   Method -> {"MethodOfLines", 
     "SpatialDiscretization" -> {"FiniteElement"}}];

but I have no idea how to plot

2 Answers

"startup aid"

U = NDSolveValue[{Derivative[0, 1][u][x, t] ==Derivative[2, 0][u][x, t],
 u[x, 0] == Sin[Pi x]^100 }, 
u, {t, 0, 1}, {x, 0, 1} , 
Method -> {"MethodOfLines", "TemporalVariable" -> t,"SpatialDiscretization" -> "FiniteElement"  }]

NDSolveValue evaluates the solution U[x,t] as an interpolation object. "FiniteElement" sets the Neumann boundary conditions to zero.

Plot3D[U[x, t], {x, 0, 1 }, {t, 0, .1},PlotRange -> {0, 1}, MeshFunctions -> {#2 &}, MaxRecursion -> 5]

enter image description here

Correct answer by Ulrich Neumann on July 2, 2021

Also you can it try this way with version 12.2

sol = NDSolveValue[{D[u[t, x], t] + DiffusionPDETerm[{u[t, x], {x}}] == 0, 
   u[0, x] == (Sin[Pi*x])^100}, u, {x, 0, 1}, {t, 0, 2}]

Plot3D[sol[t, x], {x, 0, 1}, {t, 0, 0.1}, PlotRange -> All]

enter image description here

To complete this, the following addition:

heatSol = 
 NDSolveValue[{HeatTransferPDEComponent[{u[t, x], t, {x}}, <|"ThermalConductivity" -> {{1}}|>] == 0, 
   u[0, x] == (Sin[Pi*x])^100}, u, {x, 0, 1}, {t, 0, 2}]

The heattransfer at t =1:

Plot[heatSol[1, x], {x, 0, 1}]

enter image description here

Answered by rmw on July 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP