0
$\begingroup$

I've just wrote my own script to solve the homogeneous heat equation in the unit square $[0,1] \times [0,1]$ with homogeneous Dirichlet boundary conditions and an initial data $u_0(x,y)$. Namely

$$ u_t = u_{xx} + u_{yy} \\u_{| \partial \Omega} = 0 \\u(x,y,0)=u_0(x,y)$$

Now, in order to verify my implementation, I need to find an analytical solution and compare my numerical solution.

But I found only solutions in terms of infinite series. Does anyone know an initial conditon $u_0(x)$ for which the analytical solution is easy, in order to put it on my script and do an error analysis?

$\endgroup$
2
  • 1
    $\begingroup$ Shouldn't your initial data depend on two variables, namely $u(x,y,0) = u_0(x,y)$? $\endgroup$
    – Hugo
    Commented Nov 21, 2019 at 23:14
  • $\begingroup$ Yes sure, edited thanks! $\endgroup$
    – slamWolfen
    Commented Nov 21, 2019 at 23:14

1 Answer 1

1
$\begingroup$

You are correct that the general solution can only be expressed as infinite series. However, you can take a single term of this series and that will also be a solution. For example, the function $$u(x,y) = e^{-\pi^2(m^2+n^2)t}\sin m\pi x\sin n\pi y$$ is a solution for $u_0(x,y) = \sin m\pi x\sin n\pi y$ where $m$ and $n$ are integers

$\endgroup$
8
  • $\begingroup$ Thanks for your answer! But $u_0$ doesn't seems to satisfy the requirement to be $0$ at the boundary $\endgroup$
    – slamWolfen
    Commented Nov 21, 2019 at 23:27
  • $\begingroup$ Is there any smart way to fix this and obtain a simple solution? honestly, I can't find one $\endgroup$
    – slamWolfen
    Commented Nov 22, 2019 at 0:01
  • $\begingroup$ oh sorry I thought you had written a Neumann boundary condition for some reason. Will fix $\endgroup$
    – whpowell96
    Commented Nov 22, 2019 at 2:17
  • $\begingroup$ Many thanks! graphically my solutions is okay! I'd like to ask you one more question: once I obtain my numerical solution $\hat{u}$, I have a $Nx \times N_y$ matrix where in the entry $(i,j)$ I have the solution at point $(x_i,y_j)$ of the grid. To compare the error w.r.t the analytical solution at the final time $\bar{t}$, i.e. $u(x,y,\bar{t})$ , is it okay to do $|| \hat{u} - u||$ in some norm ? $\endgroup$
    – slamWolfen
    Commented Nov 22, 2019 at 10:30
  • $\begingroup$ Yes, but be careful when computing norms of a matrix in your computing environment using some norm command. These will likely give you operator norms, which is now what you want. It would be better to take the maximum absolute value of the difference or use the Frobenius norm $\endgroup$
    – whpowell96
    Commented Nov 23, 2019 at 0:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .