Functions > Solving and Optimization > Differential Equation Solvers > Example: Heat Flow on a Square Plate - II
Example: Heat Flow on a Square Plate - II
Solve for the steady-state temperature distribution of a square plate using the partial differential equation solver relax.
Solving Poisson's Equation
Solve the heat equation where values of the source function are known and the boundary conditions are non-zero.
* 
The relax function is based on an entirely different solving method, and hence requires a different set of arguments.
1. Define five square matrices a, b, c, d, and e to contain the coefficients for the Laplacian approximation:
Click to copy this expression
* 
These arrays can be of any size you specify. The larger they are, the finer the mesh in the solution.
2. Define the dimension of the square plate:
Click to copy this expression
Click to copy this expression
Click to copy this expression
3. Define the coefficients:
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
4. Define the strength and position of a constant source.
Click to copy this expression
5. Define a square matrix f, of size equal to the size of the grid, to contain the known boundary values of function F(x,y) and guess values for the unknown interior values.
Boundary condition along the top:
Click to copy this expression
Boundary condition along the bottom:
Click to copy this expression
Boundary condition along the edges:
Click to copy this expression
Click to copy this expression
6. Define the Jacobi spectral radius variable r, a real number between 0 and 1.
Click to copy this expression
* 
This parameter controls the convergence of the algorithm. If you see the error message "too many iterations", then try reducing r.
7. Call the relax function:
Click to copy this expression
8. Create a 3D plot to show the heat distribution over the square plate.
Click to copy this expression
9. Create a contour plot to show the lines of constant temperature.
Click to copy this expression
Was this helpful?